1// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s
2
3void f() {
4  int a;
5  struct S { int m; };
6  typedef S *T;
7
8  // Expressions.
9  T(a)->m = 7;
10  int(a)++; // expected-error {{assignment to cast is illegal}}
11  __extension__ int(a)++; // expected-error {{assignment to cast is illegal}}
12  __typeof(int)(a,5)<<a; // expected-error {{excess elements in scalar initializer}}
13  void(a), ++a;
14  if (int(a)+1) {}
15  for (int(a)+1;;) {} // expected-warning {{expression result unused}}
16  a = sizeof(int()+1);
17  a = sizeof(int(1));
18  typeof(int()+1) a2; // expected-error {{extension used}}
19  (int(1)); // expected-warning {{expression result unused}}
20
21  // type-id
22  (int())1; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}}
23
24  // Declarations.
25  int fd(T(a)); // expected-warning {{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
26  T(*d)(int(p)); // expected-note {{previous}}
27  typedef T td(int(p));
28  extern T tp(int(p));
29  T d3(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
30  T d3v(void);
31  typedef T d3t();
32  extern T f3();
33  __typeof(*T()) f4(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
34  typedef void *V;
35  __typeof(*V()) f5();
36  T multi1,
37    multi2(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
38  T(d)[5]; // expected-error {{redefinition of 'd'}}
39  typeof(int[])(f) = { 1, 2 }; // expected-error {{extension used}}
40  void(b)(int);
41  int(d2) __attribute__(());
42  if (int(a)=1) {}
43  int(d3(int()));
44}
45
46struct RAII {
47  RAII();
48  ~RAII();
49};
50
51void func();
52void func2(short);
53namespace N {
54  struct S;
55
56  void emptyParens() {
57    RAII raii(); // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}}
58    int a, b, c, d, e, // expected-note {{change this ',' to a ';' to call 'func'}}
59    func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
60
61    S s(); // expected-warning {{function declaration}}
62  }
63  void nonEmptyParens() {
64    int f = 0, // g = 0; expected-note {{change this ',' to a ';' to call 'func2'}}
65    func2(short(f)); // expected-warning {{function declaration}} expected-note {{add a pair of parentheses}}
66  }
67}
68
69class C { };
70void fn(int(C)) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
71                    // not: void fn(int C);
72int g(C);
73
74void foo() {
75  fn(1); // expected-error {{no matching function}}
76  fn(g); // OK
77}
78
79namespace PR11874 {
80void foo(); // expected-note 3 {{class 'foo' is hidden by a non-type declaration of 'foo' here}}
81class foo {};
82class bar {
83  bar() {
84    const foo* f1 = 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
85    foo* f2 = 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
86    foo f3; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
87  }
88};
89
90int baz; // expected-note 2 {{class 'baz' is hidden by a non-type declaration of 'baz' here}}
91class baz {};
92void fizbin() {
93  const baz* b1 = 0; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
94  baz* b2; // expected-error {{use of undeclared identifier 'b2'}}
95  baz b3; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
96}
97}
98