1 // RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors %s
2 // RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -std=gnu++98 %s
3 // RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -std=gnu++11 %s
4 // RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -x objective-c++ %s
13 int(a
)++; // expected-error {{assignment to cast is illegal}}
14 __extension__
int(a
)++; // expected-error {{assignment to cast is illegal}}
15 __typeof(int)(a
,5)<<a
; // expected-error {{excess elements in scalar initializer}} expected-warning {{expression result unused}}
18 for (int(a
)+1;;) {} // expected-warning {{expression result unused}}
21 typeof(int()+1) a2
; // expected-error {{extension used}}
22 (int(1)); // expected-warning {{expression result unused}}
25 (int())1; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}}
28 int fd(T(a
)); // expected-warning {{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
29 T(*d
)(int(p
)); // expected-note {{previous}}
32 T
d3(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
36 __typeof(*T()) f4(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
38 __typeof(*V()) f5(); // expected-error {{ISO C++ does not allow indirection on operand of type 'V' (aka 'void *')}}
40 multi2(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
41 T(d
)[5]; // expected-error {{redefinition of 'd'}}
42 typeof(int[])(f
) = { 1, 2 }; // expected-error {{extension used}}
44 int(d2
) __attribute__(());
67 RAII
raii(); // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}}
68 int a
, b
, c
, d
, e
, // expected-note {{change this ',' to a ';' to call 'func'}}
69 func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
71 S
s(); // expected-warning {{function declaration}}
72 #if __cplusplus >= 201103L
73 // expected-note@-2 {{replace parentheses with an initializer to declare a variable}}
76 void nonEmptyParens() {
77 int f
= 0, // g = 0; expected-note {{change this ',' to a ';' to call 'func2'}}
78 func2(short(f
)); // expected-warning {{function declaration}} expected-note {{add a pair of parentheses}}
80 RAII(n
); // expected-warning {{parentheses were disambiguated as redundant parentheses around declaration of variable named 'n'}}
81 // expected-note@-1 {{add a variable name to declare a 'RAII' initialized with 'n'}}
82 // expected-note@-2 {{add enclosing parentheses to perform a function-style cast}}
83 // expected-note@-3 {{remove parentheses to silence this warning}}
86 #pragma clang diagnostic push
87 #pragma clang diagnostic warning "-Wredundant-parens"
88 RAII(undeclared2
); // expected-warning {{redundant parentheses surrounding declarator}}
89 #pragma clang diagnostic pop
92 NotRAII(n
); // expected-warning {{parentheses were disambiguated as redundant parentheses around declaration of variable named 'n'}}
93 // expected-note@-1 {{add enclosing parentheses to perform a function-style cast}}
94 // expected-note@-2 {{remove parentheses to silence this warning}}
100 void fn(int(C
)) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
101 // not: void fn(int C);
105 fn(1); // expected-error {{no matching function}}
110 void foo(); // expected-note 3 {{class 'foo' is hidden by a non-type declaration of 'foo' here}}
114 const foo
* f1
= 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
115 foo
* f2
= 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
116 foo f3
; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
120 int baz
; // expected-note 2 {{class 'baz' is hidden by a non-type declaration of 'baz' here}}
123 const baz
* b1
= 0; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
124 baz
* b2
; // expected-error {{use of undeclared identifier 'b2'}}
125 baz b3
; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
129 namespace TemporaryFromFunctionCall
{
137 // FIXME: For the first and second of these (but not the third), we
138 // should produce a vexing-parse warning.