1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s 2*67e74705SXin Li f()3*67e74705SXin Livoid f() { 4*67e74705SXin Li typedef int T; 5*67e74705SXin Li int x, *px; 6*67e74705SXin Li 7*67e74705SXin Li // Type id. 8*67e74705SXin Li (T())x; // expected-error {{cast from 'int' to 'T ()'}} 9*67e74705SXin Li (T())+x; // expected-error {{cast from 'int' to 'T ()'}} 10*67e74705SXin Li (T())*px; // expected-error {{cast from 'int' to 'T ()'}} 11*67e74705SXin Li 12*67e74705SXin Li // Expression. 13*67e74705SXin Li x = (T()); 14*67e74705SXin Li x = (T())/x; 15*67e74705SXin Li 16*67e74705SXin Li typedef int *PT; 17*67e74705SXin Li // Make sure stuff inside the parens are parsed only once (only one warning). 18*67e74705SXin Li x = (PT()[(int){1}]); // expected-warning {{compound literals}} 19*67e74705SXin Li 20*67e74705SXin Li // Special case: empty parens is a call, not an expression 21*67e74705SXin Li struct S{int operator()();}; 22*67e74705SXin Li (S())(); 23*67e74705SXin Li 24*67e74705SXin Li // Special case: "++" is postfix here, not prefix 25*67e74705SXin Li (S())++; // expected-error {{cannot increment value of type 'S'}} 26*67e74705SXin Li 27*67e74705SXin Li struct X { int &operator++(int); X operator[](int); int &operator++(); }; 28*67e74705SXin Li int &postfix_incr = (X()[3])++; 29*67e74705SXin Li (X())++ ++; // ok, not a C-style cast 30*67e74705SXin Li (X())++ ++X(); // expected-error {{C-style cast from 'int' to 'X ()'}} 31*67e74705SXin Li int q = (int)++(x); 32*67e74705SXin Li } 33*67e74705SXin Li 34*67e74705SXin Li // Make sure we do tentative parsing correctly in conditions. 35*67e74705SXin Li typedef int type; 36*67e74705SXin Li struct rec { rec(int); }; 37*67e74705SXin Li 38*67e74705SXin Li namespace ns { 39*67e74705SXin Li typedef int type; 40*67e74705SXin Li struct rec { rec(int); }; 41*67e74705SXin Li } 42*67e74705SXin Li 43*67e74705SXin Li struct cls { 44*67e74705SXin Li typedef int type; 45*67e74705SXin Li struct rec { rec(int); }; 46*67e74705SXin Li }; 47*67e74705SXin Li 48*67e74705SXin Li struct result { 49*67e74705SXin Li template <class T> result(T); 50*67e74705SXin Li bool check(); 51*67e74705SXin Li }; 52*67e74705SXin Li test(int i)53*67e74705SXin Livoid test(int i) { 54*67e74705SXin Li if (result((cls::type) i).check()) 55*67e74705SXin Li return; 56*67e74705SXin Li 57*67e74705SXin Li if (result((ns::type) i).check()) 58*67e74705SXin Li return; 59*67e74705SXin Li 60*67e74705SXin Li if (result((::type) i).check()) 61*67e74705SXin Li return; 62*67e74705SXin Li 63*67e74705SXin Li if (result((cls::rec) i).check()) 64*67e74705SXin Li return; 65*67e74705SXin Li 66*67e74705SXin Li if (result((ns::rec) i).check()) 67*67e74705SXin Li return; 68*67e74705SXin Li 69*67e74705SXin Li if (result((::rec) i).check()) 70*67e74705SXin Li return; 71*67e74705SXin Li } 72*67e74705SXin Li 73