p3-0x.cpp revision 762bb9d0ad20320b9f97a841dce57ba5e8e48b07
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2
3using X = struct { // ok
4};
5template<typename T> using Y = struct { // expected-error {{can not be defined in a type alias template}}
6};
7
8class K {
9  virtual ~K();
10  // FIXME: Diagnostic could use some work
11  operator struct S {} (); // expected-error{{ 'operator S' cannot be the name of a variable or data member}} \
12  // expected-error{{expected ';' at end of declaration list}}
13};
14
15void 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 {{allocation of incomplete type}} expected-note {{forward declaration}}
22
23  // FIXME: the diagnostic here isn't very good
24  try {} catch (struct U {}); // expected-error 3{{}} expected-note 2{{}}
25
26  (void)(struct V { V(int); })0; // expected-error {{'V' can not be defined in a type specifier}}
27
28  (void)dynamic_cast<struct W {}*>((K*)0); // expected-error {{'W' can not be defined in a type specifier}}
29  (void)static_cast<struct X {}*>(0); // expected-error {{'X' can not be defined in a type specifier}}
30  (void)reinterpret_cast<struct Y {}*>(0); // expected-error {{'Y' can not be defined in a type specifier}}
31  (void)const_cast<struct Z {}*>((const Z*)0); // expected-error {{'Z' can not be defined in a type specifier}}
32}
33
34void g() throw (struct Ex {}) { // expected-error {{'Ex' can not be defined in a type specifier}}
35}
36
37int alignas(struct Aa {}) x; // expected-error {{'Aa' can not be defined in a type specifier}}
38
39int a = sizeof(struct So {}); // expected-error {{'So' can not be defined in a type specifier}}
40int b = alignof(struct Ao {}); // expected-error {{'Ao' can not be defined in a type specifier}}
41
42namespace std { struct type_info; }
43const std::type_info &ti = typeid(struct Ti {}); // expected-error {{'Ti' can not be defined in a type specifier}}
44