xref: /aosp_15_r20/external/clang/test/SemaTemplate/ms-class-specialization-class-scope.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s -Wno-microsoft
2*67e74705SXin Li // RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s -Wno-microsoft
3*67e74705SXin Li 
4*67e74705SXin Li class A {
5*67e74705SXin Li public:
6*67e74705SXin Li   template<typename T> struct X { typedef int x; };
7*67e74705SXin Li 
8*67e74705SXin Li   X<int>::x a; // expected-note {{implicit instantiation first required here}}
9*67e74705SXin Li 
10*67e74705SXin Li   template<> struct X<int>; // expected-error {{explicit specialization of 'A::X<int>' after instantiation}}
11*67e74705SXin Li   template<> struct X<char>; // expected-note {{forward declaration}}
12*67e74705SXin Li 
13*67e74705SXin Li   X<char>::x b; // expected-error {{incomplete type 'A::X<char>' named in nested name specifier}}
14*67e74705SXin Li 
15*67e74705SXin Li   template<> struct X<double> {
16*67e74705SXin Li     typedef int y;
17*67e74705SXin Li   };
18*67e74705SXin Li 
19*67e74705SXin Li   X<double>::y c;
20*67e74705SXin Li 
21*67e74705SXin Li   template<> struct X<float> {}; // expected-note {{previous definition is here}}
22*67e74705SXin Li   template<> struct X<float> {}; // expected-error {{redefinition of 'A::X<float>'}}
23*67e74705SXin Li };
24*67e74705SXin Li 
25*67e74705SXin Li A::X<void>::x axv;
26*67e74705SXin Li A::X<float>::x axf; // expected-error {{no type named 'x'}}
27*67e74705SXin Li 
28*67e74705SXin Li template<class T> class B {
29*67e74705SXin Li public:
30*67e74705SXin Li   template<typename U> struct X { typedef int x; };
31*67e74705SXin Li 
32*67e74705SXin Li   typename X<int>::x a; // expected-note {{implicit instantiation first required here}}
33*67e74705SXin Li 
34*67e74705SXin Li   template<> struct X<int>; // expected-error {{explicit specialization of 'X<int>' after instantiation}}
35*67e74705SXin Li   template<> struct X<char>; // expected-note {{forward declaration}}
36*67e74705SXin Li 
37*67e74705SXin Li   typename X<char>::x b; // expected-error {{incomplete type 'B<float>::X<char>' named in nested name specifier}}
38*67e74705SXin Li 
39*67e74705SXin Li   template<> struct X<double> {
40*67e74705SXin Li     typedef int y;
41*67e74705SXin Li   };
42*67e74705SXin Li 
43*67e74705SXin Li   typename X<double>::y c;
44*67e74705SXin Li 
45*67e74705SXin Li   template<> struct X<float> {}; // expected-note {{previous definition is here}}
46*67e74705SXin Li   template<> struct X<T> {}; // expected-error {{redefinition of 'X<float>'}}
47*67e74705SXin Li };
48*67e74705SXin Li 
49*67e74705SXin Li B<float> b; // expected-note {{in instantiation of}}
50