1 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 export class foo { }; // expected-error {{expected template}}
5 template x; // expected-error {{C++ requires a type specifier for all declarations}} \
6 // expected-error {{does not refer}}
7 export template x; // expected-error {{expected '<' after 'template'}}
8 export template<class T> class x0; // expected-warning {{exported templates are unsupported}}
9 template < ; // expected-error {{parse error}} expected-error {{declaration does not declare anything}}
10 template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \
11 // expected-error{{extraneous}}
12 template <template <typename> > struct Err2; // expected-error {{expected 'class' before '>'}} \
13 // expected-error{{extraneous}}
14 template <template <typename> Foo> struct Err3; // expected-error {{expected 'class' before 'Foo'}} \
15 // expected-error{{extraneous}}
17 // Template function declarations
18 template <typename T> void foo();
19 template <typename T, typename U> void foo();
21 // Template function definitions.
22 template <typename T> void foo() { }
24 // Template class (forward) declarations
25 template <typename T> struct A;
26 template <typename T, typename U> struct b;
27 template <typename> struct C;
28 template <typename, typename> struct D;
30 // Forward declarations with default parameters?
31 template <typename T = int> class X1;
32 template <typename = int> class X2;
34 // Forward declarations w/template template parameters
35 template <template <typename> class T> class TTP1;
36 template <template <typename> class> class TTP2;
37 template <template <typename> class T = foo> class TTP3; // expected-error{{must be a class template}}
38 template <template <typename> class = foo> class TTP3; // expected-error{{must be a class template}}
39 template <template <typename X, typename Y> class T> class TTP5;
41 // Forward declarations with non-type params
42 template <int> class NTP0;
43 template <int N> class NTP1;
44 template <int N = 5> class NTP2;
45 template <int = 10> class NTP3;
46 template <unsigned int N = 12u> class NTP4;
47 template <unsigned int = 12u> class NTP5;
48 template <unsigned = 15u> class NTP6;
49 template <typename T, T Obj> class NTP7;
51 // Template class declarations
52 template <typename T> struct A { };
53 template <typename T, typename U> struct B { };
55 // Template parameter shadowing
56 template<typename T, // expected-note{{template parameter is declared here}}
57 typename T> // expected-error{{declaration of 'T' shadows template parameter}}
60 template<typename T> // expected-note{{template parameter is declared here}}
61 void shadow2(int T); // expected-error{{declaration of 'T' shadows template parameter}}
63 template<typename T> // expected-note{{template parameter is declared here}}
64 class T { // expected-error{{declaration of 'T' shadows template parameter}}
67 template<int Size> // expected-note{{template parameter is declared here}}
68 void shadow3(int Size); // expected-error{{declaration of 'Size' shadows template parameter}}
70 // <rdar://problem/6952203>
71 template<typename T> // expected-note{{here}}
73 int T; // expected-error{{shadows}}
76 template<typename T> // expected-note{{here}}
78 int T(int, float); // expected-error{{shadows}}
81 // Non-type template parameters in scope
85 Size = i; // expected-error{{expression is not assignable}}
89 const T& min(const T&, const T&);
98 template <> struct S<int> { }; // expected-error{{explicit specialization of non-template struct 'S'}}