Clang Project

clang_source_code/test/CXX/temp/temp.param/p2.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s 
2// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DCPP11
3// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s -DCPP17
4
5// There is no semantic difference between class and typename in a
6// template-parameter. typename followed by an unqualified-id names a
7// template type parameter.
8template<class T> struct X;
9template<typename T> struct X;
10
11// typename followed by a qualified-id denotes the type in a non-type
12// parameter-declaration.
13template<typename T, typename T::type Value> struct Y0;
14template<typename T, typename X<T>::type Value> struct Y1;
15template<typename T typename U> struct Y2; // expected-error{{expected ',' or '>'}}
16template<typename T U> struct Y3; // expected-error{{expected a qualified name after 'typename'}} expected-error{{expected ',' or '>'}}
17template<typedef T typename U> struct Y4; // expected-error{{expected template parameter}} expected-note {{did you mean to use 'typename'?}} expected-error{{expected ',' or '>'}}
18
19// A storage class shall not be specified in a template-parameter declaration.
20template<static int Value> struct Z; //expected-error{{invalid declaration specifier}}
21template<typedef int Value> struct Z0; //expected-error{{invalid declaration specifier}}
22template<extern inline int Value> struct Z1; //expected-error2{{invalid declaration specifier}}
23template<virtual int Value> struct Z2; //expected-error{{invalid declaration specifier}}
24template<explicit int Value> struct Z3; //expected-error{{invalid declaration specifier}}
25template<inline int Value> struct Z4; //expected-error{{invalid declaration specifier}}
26template<extern int> struct Z5; //expected-error{{invalid declaration specifier}}
27template<static int> struct Z6;  //expected-error{{invalid declaration specifier}}
28template<explicit int Value> struct Z7; //expected-error{{invalid declaration specifier}}
29template<mutable int> struct Z8; //expected-error{{invalid declaration specifier}}
30
31template<const int> struct Z9; // OK
32template<volatile int> struct Z10; // OK
33
34
35
36#ifdef CPP11
37template<thread_local int> struct Z11; //expected-error{{invalid declaration specifier}}
38template<constexpr int> struct Z12; //expected-error{{invalid declaration specifier}}
39
40#endif
41
42#ifdef CPP17
43template<auto> struct Z13; // OK
44#endif
45
46// Make sure that we properly disambiguate non-type template parameters that
47// start with 'class'.
48class X1 { };
49template<class X1 *xptr> struct X2 { };
50
51// FIXME: add the example from p2
52