• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s
2 
f()3 void 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 {{parentheses were disambiguated as a function declarator}}
26   T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}}
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 
46 struct RAII {
47   RAII();
48   ~RAII();
49 };
50 
51 void func();
52 namespace N {
53   struct S;
54 
emptyParens()55   void emptyParens() {
56     RAII raii(); // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}}
57     int a, b, c, d, e, // expected-note {{change this ',' to a ';' to call 'func'}}
58     func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
59 
60     S s(); // expected-warning {{function declaration}}
61   }
62 }
63 
64 class C { };
fn(int (C))65 void fn(int(C)) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
66                     // not: void fn(int C);
67 int g(C);
68 
foo()69 void foo() {
70   fn(1); // expected-error {{no matching function}}
71   fn(g); // OK
72 }
73