1 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s 2 f()3void 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 // Special case: "++" is postfix here, not prefix 25 (S())++; // expected-error {{cannot increment value of type 'S'}} 26 27 struct X { int &operator++(int); X operator[](int); int &operator++(); }; 28 int &postfix_incr = (X()[3])++; 29 (X())++ ++; // ok, not a C-style cast 30 (X())++ ++X(); // expected-error {{C-style cast from 'int' to 'X ()'}} 31 int q = (int)++(x); 32 } 33 34 // Make sure we do tentative parsing correctly in conditions. 35 typedef int type; 36 struct rec { rec(int); }; 37 38 namespace ns { 39 typedef int type; 40 struct rec { rec(int); }; 41 } 42 43 struct cls { 44 typedef int type; 45 struct rec { rec(int); }; 46 }; 47 48 struct result { 49 template <class T> result(T); 50 bool check(); 51 }; 52 test(int i)53void test(int i) { 54 if (result((cls::type) i).check()) 55 return; 56 57 if (result((ns::type) i).check()) 58 return; 59 60 if (result((::type) i).check()) 61 return; 62 63 if (result((cls::rec) i).check()) 64 return; 65 66 if (result((ns::rec) i).check()) 67 return; 68 69 if (result((::rec) i).check()) 70 return; 71 } 72 73