1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcxx-exceptions
2 
3 using X = struct { // ok
4 };
5 template<typename T> using Y = struct { // expected-error {{cannot be defined in a type alias template}}
6 };
7 
8 class K {
9   virtual ~K();
10   operator struct S {} (); // expected-error{{'K::S' cannot be defined in a type specifier}}
11 };
12 
13 struct A {};
14 
f()15 void f() {
16   int arr[3] = {1,2,3};
17 
18   for (struct S { S(int) {} } s : arr) { // expected-error {{types may not be defined in a for range declaration}}
19   }
20 
21   new struct T {}; // expected-error {{'T' cannot be defined in a type specifier}}
22   new struct A {}; // expected-error {{'A' cannot be defined in a type specifier}}
23 
24   try {} catch (struct U {}) {} // expected-error {{'U' cannot be defined in a type specifier}}
25 
26   (void)(struct V { V(int); })0; // expected-error {{'V' cannot be defined in a type specifier}}
27 
28   (void)dynamic_cast<struct W {}*>((K*)0); // expected-error {{'W' cannot be defined in a type specifier}}
29   (void)static_cast<struct X {}*>(0); // expected-error {{'X' cannot be defined in a type specifier}}
30   (void)reinterpret_cast<struct Y {}*>(0); // expected-error {{'Y' cannot be defined in a type specifier}}
31   (void)const_cast<struct Z {}*>((const Z*)0); // expected-error {{'Z' cannot be defined in a type specifier}}
32 }
33 
g()34 void g() throw (struct Ex {}) { // expected-error {{'Ex' cannot be defined in a type specifier}}
35 }
36 
37 alignas(struct Aa {}) int x; // expected-error {{'Aa' cannot be defined in a type specifier}}
38 
39 int a = sizeof(struct So {}); // expected-error {{'So' cannot be defined in a type specifier}}
40 int b = alignof(struct Ao {}); // expected-error {{'Ao' cannot be defined in a type specifier}}
41 
42 namespace std { struct type_info; }
43 const std::type_info &ti = typeid(struct Ti {}); // expected-error {{'Ti' cannot be defined in a type specifier}}
44