• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
2 
f()3 void f() {
4   typedef int T;
5   int x, *px;
6 
7   // Type id.
8   (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 ()'}}
11 
12   // Expression.
13   x = (T());
14   x = (T())/x;
15 
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}}
19 
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())++;
26 }
27 
28 // Make sure we do tentative parsing correctly in conditions.
29 typedef int type;
30 struct rec { rec(int); };
31 
32 namespace ns {
33   typedef int type;
34   struct rec { rec(int); };
35 }
36 
37 struct cls {
38   typedef int type;
39   struct rec { rec(int); };
40 };
41 
42 struct result {
43   template <class T> result(T);
44   bool check();
45 };
46 
test(int i)47 void 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 
67