blob: 398820567237dad65b3ff61472ab0d8a63d20eb5 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
Argyrios Kyrtzidisf58f45e2009-05-22 10:24:42 +00002
3void f() {
4 typedef int T;
5 int x, *px;
6
7 // Type id.
Sebastian Redl9cc11e72009-07-25 15:41:38 +00008 (T())x; // expected-error {{cast from 'int' to 'T ()'}}
9 (T())+x; // expected-error {{cast from 'int' to 'T ()'}}
10 (T())*px; // expected-error {{cast from 'int' to 'T ()'}}
Argyrios Kyrtzidisf58f45e2009-05-22 10:24:42 +000011
12 // Expression.
13 x = (T());
14 x = (T())/x;
Argyrios Kyrtzidisf303e8a2009-05-22 23:05:39 +000015
16 typedef int *PT;
17 // Make sure stuff inside the parens are parsed only once (only one warning).
18 x = (PT()[(int){1}]); // expected-warning {{compound literals}}
Eli Friedmanb53f08a2009-05-25 19:41:42 +000019
20 // Special case: empty parens is a call, not an expression
21 struct S{int operator()();};
22 (S())();
23
24 // FIXME: Special case: "++" is postfix here, not prefix
25 // (S())++;
Argyrios Kyrtzidisf58f45e2009-05-22 10:24:42 +000026}
John McCallae03cb52009-12-19 00:35:18 +000027
28// Make sure we do tentative parsing correctly in conditions.
29typedef int type;
30struct rec { rec(int); };
31
32namespace ns {
33 typedef int type;
34 struct rec { rec(int); };
35}
36
37struct cls {
38 typedef int type;
39 struct rec { rec(int); };
40};
41
42struct result {
43 template <class T> result(T);
44 bool check();
45};
46
47void test(int i) {
48 if (result((cls::type) i).check())
49 return;
50
51 if (result((ns::type) i).check())
52 return;
53
54 if (result((::type) i).check())
55 return;
56
57 if (result((cls::rec) i).check())
58 return;
59
60 if (result((ns::rec) i).check())
61 return;
62
63 if (result((::rec) i).check())
64 return;
65}
66