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