// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s namespace RedeclAliasTypedef { template using T = int; template using T = int; template using T = T; } namespace IllegalTypeIds { template using A = void(int n = 0); // expected-error {{default arguments can only be specified for parameters in a function declaration}} template using B = inline void(int n); // expected-error {{type name does not allow function specifier}} template using C = virtual void(int n); // expected-error {{type name does not allow function specifier}} template using D = explicit void(int n); // expected-error {{type name does not allow function specifier}} template using E = void(int n) throw(); // expected-error {{exception specifications are not allowed in type aliases}} template using F = void(*)(int n) &&; // expected-error {{pointer to function type cannot have '&&' qualifier}} template using G = __thread void(int n); // expected-error {{type name does not allow storage class to be specified}} template using H = constexpr int; // expected-error {{type name does not allow constexpr specifier}} template using Y = void(int n); // ok template using Z = void(int n) &&; // ok } namespace IllegalSyntax { template using ::T = void(int n); // expected-error {{name defined in alias declaration must be an identifier}} template using operator int = void(int n); // expected-error {{name defined in alias declaration must be an identifier}} template using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}} template using typename ::V = void(int n); // expected-error {{name defined in alias declaration must be an identifier}} template using typename ::operator bool = void(int n); // expected-error {{name defined in alias declaration must be an identifier}} } namespace VariableLengthArrays { template using T = int[42]; // ok int n = 32; template using T = int[n]; // expected-error {{variable length array declaration not allowed at file scope}} const int m = 42; template using U = int[m]; template using U = int[42]; // expected-note {{previous definition}} template using U = int; // expected-error {{type alias template redefinition with different types ('int' vs 'int [42]')}} } namespace RedeclFunc { int f(int, char**); template using T = int; T f(int, char **); // ok } namespace LookupFilter { namespace N { template using S = int; } using namespace N; template using S = S*; // ok } namespace InFunctions { template struct S0 { template using U = T*; // expected-error {{declaration type contains unexpanded parameter pack 'T'}} U u; }; template using T1 = int; template using T2 = int[-1]; // expected-error {{array size is negative}} template struct S3 { // expected-note {{template parameter is declared here}} template using T = int; // expected-error {{declaration of 'T' shadows template parameter}} }; template using Z = Z; } namespace ClassNameRedecl { class C0 { template using C0 = int; // expected-error {{member 'C0' has the same name as its class}} }; class C1 { template using C1 = C1; // expected-error {{member 'C1' has the same name as its class}} }; class C2 { template using C0 = C1; // ok }; template class C3 { template using f = T; // expected-error {{declaration type contains unexpanded parameter pack 'T'}} }; template class C4 { // expected-note {{template parameter is declared here}} template using T = int; // expected-error {{declaration of 'T' shadows template parameter}} }; class C5 { class c; // expected-note {{previous definition}} template using c = int; // expected-error {{redefinition of 'c' as different kind of symbol}} class d; // expected-note {{previous definition}} template using d = d; // expected-error {{redefinition of 'd' as different kind of symbol}} }; class C6 { class c { template using C6 = int; }; // ok }; } class CtorDtorName { template using X = CtorDtorName; X(); // expected-error {{expected member name}} ~X(); // expected-error {{destructor cannot be declared using a type alias}} }; namespace TagName { template using S = struct { int n; }; // expected-error {{cannot be defined}} template using T = class { int n; }; // expected-error {{cannot be defined}} template using U = enum { a, b, c }; // expected-error {{cannot be defined}} template using V = struct V { int n; }; // expected-error {{'TagName::V' cannot be defined in a type alias template}} } namespace StdExample { template struct pair; template using handler_t = void (*)(T); extern handler_t ignore; extern void (*ignore)(int); // FIXME: we recover as if cell is an undeclared variable template template using cell = pair*>; // expected-error {{use of undeclared identifier 'cell'}} expected-error {{expected expression}} } namespace Access { class C0 { template using U = int; // expected-note {{declared private here}} }; C0::U v; // expected-error {{'U' is a private member}} class C1 { public: template using U = int; }; C1::U w; // ok } namespace VoidArg { template using V = void; V f(int); // ok V g(V); // ok (DR577) } namespace Curried { template struct S; template template using SS = S; // expected-error {{extraneous template parameter list in alias template declaration}} } // PR12647 namespace SFINAE { template struct enable_if; // expected-note 2{{here}} template<> struct enable_if { using type = void; }; template struct is_enum { static constexpr bool value = __is_enum(T); }; template using EnableIf = typename enable_if::type; // expected-error {{undefined template}} template using DisableIf = typename enable_if::type; // expected-error {{undefined template}} template EnableIf> f(); template DisableIf> f(); enum E { e }; int main() { f(); f(); } template>> struct fail1 {}; // expected-note {{here}} template struct fail2 : DisableIf> {}; // expected-note {{here}} fail1 f1; // expected-note {{here}} fail2 f2; // expected-note {{here}} } namespace PR24212 { struct X {}; template struct S { template using T = X[J]; using U = T; }; static_assert(__is_same(S<3>::U, X[2]), ""); // expected-error {{static_assert failed}} } namespace PR39623 { template using void_t = void; template > int sfinae_me() { return 0; } // expected-note{{candidate template ignored: substitution failure}} int g = sfinae_me(); // expected-error{{no matching function for call to 'sfinae_me'}} } namespace NullExceptionDecl { template auto get = []() { try { } catch(...) {}; return I; }; // expected-error{{initializer contains unexpanded parameter pack 'I'}} }