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