blob: 227834a26a4ff6db2341bd0bdc692d87af68b8da [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify -pedantic-errors %s
Argyrios Kyrtzidis5404a152008-10-05 00:06:24 +00002
3void f() {
4 int a;
5 struct S { int m; };
6 typedef S *T;
7
8 // Expressions.
9 T(a)->m = 7;
Chris Lattner858bb6f2008-11-18 01:26:17 +000010 int(a)++; // expected-error {{expression is not assignable}}
11 __extension__ int(a)++; // expected-error {{expression is not assignable}}
Argyrios Kyrtzidis5404a152008-10-05 00:06:24 +000012 typeof(int)(a,5)<<a; // expected-error {{function-style cast to a builtin type can only take one argument}}
Douglas Gregor3eb1c542008-12-17 16:19:15 +000013 void(a), ++a; // expected-warning {{expression result unused}}
Argyrios Kyrtzidisa8a45982008-10-05 15:03:47 +000014 if (int(a)+1) {}
Argyrios Kyrtzidisbbc70c02008-10-05 15:50:46 +000015 for (int(a)+1;;) {}
Argyrios Kyrtzidis78c8d802008-10-05 19:56:22 +000016 a = sizeof(int()+1);
Argyrios Kyrtzidisd3dbbb62008-10-05 21:10:08 +000017 a = sizeof(int(1));
Argyrios Kyrtzidis78c8d802008-10-05 19:56:22 +000018 typeof(int()+1) a2;
Argyrios Kyrtzidisd3dbbb62008-10-05 21:10:08 +000019 (int(1)); // expected-warning {{expression result unused}}
20
21 // type-id
Gabor Greif0fe70602008-10-21 11:46:36 +000022 (int())1; // expected-error {{used type 'int (void)' where arithmetic or pointer type is required}}
Argyrios Kyrtzidis5404a152008-10-05 00:06:24 +000023
24 // Declarations.
Argyrios Kyrtzidis259b0d92008-10-15 23:21:32 +000025 int fd(T(a)); // expected-warning {{parentheses were disambiguated as a function declarator}}
Douglas Gregor3eb1c542008-12-17 16:19:15 +000026 T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}}
27 T(d)[5]; // expected-error {{redefinition of 'd'}}
28 typeof(int[])(f) = { 1, 2 };
Argyrios Kyrtzidis5404a152008-10-05 00:06:24 +000029 void(b)(int);
Douglas Gregor3eb1c542008-12-17 16:19:15 +000030 int(d2) __attribute__(());
Argyrios Kyrtzidisca35baa2008-10-05 15:19:49 +000031 if (int(a)=1) {}
Douglas Gregor3eb1c542008-12-17 16:19:15 +000032 int(d3(int()));
Argyrios Kyrtzidis5404a152008-10-05 00:06:24 +000033}
Argyrios Kyrtzidisd3dbbb62008-10-05 21:10:08 +000034
35class C { };
Douglas Gregorfa047642009-02-04 00:32:51 +000036void fn(int(C)) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
Argyrios Kyrtzidisd3dbbb62008-10-05 21:10:08 +000037 // not: void fn(int C);
38int g(C);
39
40void foo() {
Douglas Gregorfa047642009-02-04 00:32:51 +000041 fn(1); // expected-error {{no matching function}}
Argyrios Kyrtzidisd3dbbb62008-10-05 21:10:08 +000042 fn(g); // OK
43}