2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s
|
2008-10-05 08:06:24 +08:00
|
|
|
|
|
|
|
void f() {
|
|
|
|
int a;
|
|
|
|
struct S { int m; };
|
|
|
|
typedef S *T;
|
|
|
|
|
|
|
|
// Expressions.
|
|
|
|
T(a)->m = 7;
|
2008-11-18 09:26:17 +08:00
|
|
|
int(a)++; // expected-error {{expression is not assignable}}
|
|
|
|
__extension__ int(a)++; // expected-error {{expression is not assignable}}
|
2010-09-09 05:40:08 +08:00
|
|
|
__typeof(int)(a,5)<<a; // expected-error {{excess elements in scalar initializer}}
|
2010-03-12 15:11:26 +08:00
|
|
|
void(a), ++a;
|
2008-10-05 23:03:47 +08:00
|
|
|
if (int(a)+1) {}
|
2010-09-20 07:03:35 +08:00
|
|
|
for (int(a)+1;;) {} // expected-warning {{expression result unused}}
|
2008-10-06 03:56:22 +08:00
|
|
|
a = sizeof(int()+1);
|
2008-10-06 05:10:08 +08:00
|
|
|
a = sizeof(int(1));
|
2009-04-28 11:59:15 +08:00
|
|
|
typeof(int()+1) a2; // expected-error {{extension used}}
|
2010-09-20 07:03:35 +08:00
|
|
|
(int(1)); // expected-warning {{expression result unused}}
|
2008-10-06 05:10:08 +08:00
|
|
|
|
|
|
|
// type-id
|
2009-07-25 23:41:38 +08:00
|
|
|
(int())1; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}}
|
2008-10-05 08:06:24 +08:00
|
|
|
|
|
|
|
// Declarations.
|
2008-10-16 07:21:32 +08:00
|
|
|
int fd(T(a)); // expected-warning {{parentheses were disambiguated as a function declarator}}
|
2008-12-18 00:19:15 +08:00
|
|
|
T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}}
|
|
|
|
T(d)[5]; // expected-error {{redefinition of 'd'}}
|
2009-04-28 11:59:15 +08:00
|
|
|
typeof(int[])(f) = { 1, 2 }; // expected-error {{extension used}}
|
2008-10-05 08:06:24 +08:00
|
|
|
void(b)(int);
|
2008-12-18 00:19:15 +08:00
|
|
|
int(d2) __attribute__(());
|
2008-10-05 23:19:49 +08:00
|
|
|
if (int(a)=1) {}
|
2008-12-18 00:19:15 +08:00
|
|
|
int(d3(int()));
|
2008-10-05 08:06:24 +08:00
|
|
|
}
|
2008-10-06 05:10:08 +08:00
|
|
|
|
|
|
|
class C { };
|
2009-02-04 08:32:51 +08:00
|
|
|
void fn(int(C)) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
|
2008-10-06 05:10:08 +08:00
|
|
|
// not: void fn(int C);
|
|
|
|
int g(C);
|
|
|
|
|
|
|
|
void foo() {
|
2009-02-04 08:32:51 +08:00
|
|
|
fn(1); // expected-error {{no matching function}}
|
2008-10-06 05:10:08 +08:00
|
|
|
fn(g); // OK
|
|
|
|
}
|