xref: /aosp_15_r20/external/clang/test/SemaTemplate/lookup-dependent-bases.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li namespace basic {
4*67e74705SXin Li struct C {
foo2basic::C5*67e74705SXin Li   static void foo2() {}
6*67e74705SXin Li };
7*67e74705SXin Li template <typename T>
8*67e74705SXin Li struct A {
9*67e74705SXin Li   typedef C D;
10*67e74705SXin Li };
11*67e74705SXin Li 
12*67e74705SXin Li template <typename T>
13*67e74705SXin Li struct B : A<T> {
foobasic::B14*67e74705SXin Li   void foo() {
15*67e74705SXin Li     D::foo2(); // expected-warning {{use of undeclared identifier 'D'; unqualified lookup into dependent bases of class template 'B' is a Microsoft extension}}
16*67e74705SXin Li   }
17*67e74705SXin Li };
18*67e74705SXin Li 
19*67e74705SXin Li template struct B<int>; // Instantiation has no warnings.
20*67e74705SXin Li }
21*67e74705SXin Li 
22*67e74705SXin Li namespace nested_nodep_base {
23*67e74705SXin Li // There are limits to our hacks, MSVC accepts this, but we don't.
24*67e74705SXin Li struct A {
25*67e74705SXin Li   struct D { static void foo2(); };
26*67e74705SXin Li };
27*67e74705SXin Li template <typename T>
28*67e74705SXin Li struct B : T {
29*67e74705SXin Li   struct C {
foonested_nodep_base::B::C30*67e74705SXin Li     void foo() {
31*67e74705SXin Li       D::foo2(); // expected-error {{use of undeclared identifier 'D'}}
32*67e74705SXin Li     }
33*67e74705SXin Li   };
34*67e74705SXin Li };
35*67e74705SXin Li 
36*67e74705SXin Li template struct B<A>; // Instantiation has no warnings.
37*67e74705SXin Li }
38*67e74705SXin Li 
39*67e74705SXin Li namespace nested_dep_base {
40*67e74705SXin Li // We actually accept this because the inner class has a dependent base even
41*67e74705SXin Li // though it isn't a template.
42*67e74705SXin Li struct A {
43*67e74705SXin Li   struct D { static void foo2(); };
44*67e74705SXin Li };
45*67e74705SXin Li template <typename T>
46*67e74705SXin Li struct B {
47*67e74705SXin Li   struct C : T {
foonested_dep_base::B::C48*67e74705SXin Li     void foo() {
49*67e74705SXin Li       D::foo2(); // expected-warning {{use of undeclared identifier 'D'; unqualified lookup into dependent bases of class template 'C' is a Microsoft extension}}
50*67e74705SXin Li     }
51*67e74705SXin Li   };
52*67e74705SXin Li };
53*67e74705SXin Li 
54*67e74705SXin Li template struct B<A>; // Instantiation has no warnings.
55*67e74705SXin Li }
56