xref: /llvm-project/clang/test/CXX/temp/temp.param/p2.cpp (revision f9a5d5f04a86a4bd9b907f17da88c94b8cea214e)
18fbe78f6SDaniel Dunbar // RUN: %clang_cc1 -fsyntax-only -verify %s
2a223d1c8SFaisal Vali // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DCPP11
3a223d1c8SFaisal Vali // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s -DCPP17
4a5d5c749SDouglas Gregor 
5a5d5c749SDouglas Gregor // There is no semantic difference between class and typename in a
6a5d5c749SDouglas Gregor // template-parameter. typename followed by an unqualified-id names a
7a5d5c749SDouglas Gregor // template type parameter.
8a5d5c749SDouglas Gregor template<class T> struct X;
9a5d5c749SDouglas Gregor template<typename T> struct X;
10a5d5c749SDouglas Gregor 
11a5d5c749SDouglas Gregor // typename followed by a qualified-id denotes the type in a non-type
12a5d5c749SDouglas Gregor // parameter-declaration.
1326aedb74SDouglas Gregor template<typename T, typename T::type Value> struct Y0;
1426aedb74SDouglas Gregor template<typename T, typename X<T>::type Value> struct Y1;
15*f9a5d5f0SRichard Smith template<typename T typename U> struct Y2; // expected-error{{expected ',' or '>'}}
16*f9a5d5f0SRichard Smith template<typename T U> struct Y3; // expected-error{{expected a qualified name after 'typename'}} expected-error{{expected ',' or '>'}}
17*f9a5d5f0SRichard Smith template<typedef T typename U> struct Y4; // expected-error{{expected template parameter}} expected-note {{did you mean to use 'typename'?}} expected-error{{expected ',' or '>'}}
18a5d5c749SDouglas Gregor 
19a5d5c749SDouglas Gregor // A storage class shall not be specified in a template-parameter declaration.
20a223d1c8SFaisal Vali template<static int Value> struct Z; //expected-error{{invalid declaration specifier}}
21*f9a5d5f0SRichard Smith template<typedef int Value> struct Z0; //expected-error{{invalid declaration specifier}}
223a98e518SJan Korous template<extern inline int Value> struct Z1; //expected-error2{{invalid declaration specifier}}
233a98e518SJan Korous template<virtual int Value> struct Z2; //expected-error{{invalid declaration specifier}}
243a98e518SJan Korous template<explicit int Value> struct Z3; //expected-error{{invalid declaration specifier}}
253a98e518SJan Korous template<inline int Value> struct Z4; //expected-error{{invalid declaration specifier}}
263a98e518SJan Korous template<extern int> struct Z5; //expected-error{{invalid declaration specifier}}
273a98e518SJan Korous template<static int> struct Z6;  //expected-error{{invalid declaration specifier}}
283a98e518SJan Korous template<explicit int Value> struct Z7; //expected-error{{invalid declaration specifier}}
293a98e518SJan Korous template<mutable int> struct Z8; //expected-error{{invalid declaration specifier}}
30a223d1c8SFaisal Vali 
313a98e518SJan Korous template<const int> struct Z9; // OK
323a98e518SJan Korous template<volatile int> struct Z10; // OK
33a223d1c8SFaisal Vali 
34a223d1c8SFaisal Vali 
35a223d1c8SFaisal Vali 
36a223d1c8SFaisal Vali #ifdef CPP11
373a98e518SJan Korous template<thread_local int> struct Z11; //expected-error{{invalid declaration specifier}}
383a98e518SJan Korous template<constexpr int> struct Z12; //expected-error{{invalid declaration specifier}}
39a223d1c8SFaisal Vali 
40a223d1c8SFaisal Vali #endif
41a223d1c8SFaisal Vali 
42a223d1c8SFaisal Vali #ifdef CPP17
433a98e518SJan Korous template<auto> struct Z13; // OK
44a223d1c8SFaisal Vali #endif
45a5d5c749SDouglas Gregor 
4671b209deSDouglas Gregor // Make sure that we properly disambiguate non-type template parameters that
4771b209deSDouglas Gregor // start with 'class'.
4871b209deSDouglas Gregor class X1 { };
49*f9a5d5f0SRichard Smith template<class X1 *xptr> struct X2 { };
5071b209deSDouglas Gregor 
51a5d5c749SDouglas Gregor // FIXME: add the example from p2
52