1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 4*f4a2713aSLionel Sambuc // Imaginary literals 5*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 6*f4a2713aSLionel Sambuc template<typename T> 7*f4a2713aSLionel Sambuc struct ImaginaryLiteral0 { fImaginaryLiteral08*f4a2713aSLionel Sambuc void f(T &x) { 9*f4a2713aSLionel Sambuc x = 3.0I; // expected-error{{incompatible type}} 10*f4a2713aSLionel Sambuc } 11*f4a2713aSLionel Sambuc }; 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc template struct ImaginaryLiteral0<_Complex float>; 14*f4a2713aSLionel Sambuc template struct ImaginaryLiteral0<int*>; // expected-note{{instantiation}} 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 17*f4a2713aSLionel Sambuc // Compound assignment operator 18*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 19*f4a2713aSLionel Sambuc namespace N1 { 20*f4a2713aSLionel Sambuc struct X { }; 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc int& operator+=(X&, int); // expected-note{{candidate}} 23*f4a2713aSLionel Sambuc } 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc namespace N2 { 26*f4a2713aSLionel Sambuc long& operator+=(N1::X&, long); // expected-note{{candidate}} 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc template<typename T, typename U, typename Result> 29*f4a2713aSLionel Sambuc struct PlusEquals0 { fN2::PlusEquals030*f4a2713aSLionel Sambuc void f(T t, U u) { 31*f4a2713aSLionel Sambuc Result r = t += u; // expected-error{{ambiguous}} 32*f4a2713aSLionel Sambuc } 33*f4a2713aSLionel Sambuc }; 34*f4a2713aSLionel Sambuc } 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc namespace N3 { 37*f4a2713aSLionel Sambuc struct Y : public N1::X { 38*f4a2713aSLionel Sambuc short& operator+=(long); // expected-note{{candidate}} 39*f4a2713aSLionel Sambuc }; 40*f4a2713aSLionel Sambuc } 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc template struct N2::PlusEquals0<N1::X, int, int&>; 43*f4a2713aSLionel Sambuc template struct N2::PlusEquals0<N1::X, long, long&>; 44*f4a2713aSLionel Sambuc template struct N2::PlusEquals0<N3::Y, long, short&>; 45*f4a2713aSLionel Sambuc template struct N2::PlusEquals0<int, int, int&>; 46*f4a2713aSLionel Sambuc template struct N2::PlusEquals0<N3::Y, int, short&>; // expected-note{{instantiation}} 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 49*f4a2713aSLionel Sambuc // Conditional operator 50*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 51*f4a2713aSLionel Sambuc template<typename T, typename U, typename Result> 52*f4a2713aSLionel Sambuc struct Conditional0 { fConditional053*f4a2713aSLionel Sambuc void f(T t, U u) { 54*f4a2713aSLionel Sambuc Result result = t? : u; 55*f4a2713aSLionel Sambuc } 56*f4a2713aSLionel Sambuc }; 57*f4a2713aSLionel Sambuc 58*f4a2713aSLionel Sambuc template struct Conditional0<int, int, int>; 59*f4a2713aSLionel Sambuc 60*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 61*f4a2713aSLionel Sambuc // Statement expressions 62*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 63*f4a2713aSLionel Sambuc template<typename T> 64*f4a2713aSLionel Sambuc struct StatementExpr0 { fStatementExpr065*f4a2713aSLionel Sambuc void f(T t) { 66*f4a2713aSLionel Sambuc (void)({ 67*f4a2713aSLionel Sambuc if (t) // expected-error{{contextually convertible}} 68*f4a2713aSLionel Sambuc t = t + 17; 69*f4a2713aSLionel Sambuc t + 12; // expected-error{{invalid operands}} 70*f4a2713aSLionel Sambuc }); 71*f4a2713aSLionel Sambuc } 72*f4a2713aSLionel Sambuc }; 73*f4a2713aSLionel Sambuc 74*f4a2713aSLionel Sambuc template struct StatementExpr0<int>; 75*f4a2713aSLionel Sambuc template struct StatementExpr0<N1::X>; // expected-note{{instantiation}} 76*f4a2713aSLionel Sambuc 77*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 78*f4a2713aSLionel Sambuc // __builtin_choose_expr 79*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 80*f4a2713aSLionel Sambuc template<bool Cond, typename T, typename U, typename Result> 81*f4a2713aSLionel Sambuc struct Choose0 { fChoose082*f4a2713aSLionel Sambuc void f(T t, U u) { 83*f4a2713aSLionel Sambuc Result r = __builtin_choose_expr(Cond, t, u); // expected-error{{lvalue}} 84*f4a2713aSLionel Sambuc } 85*f4a2713aSLionel Sambuc }; 86*f4a2713aSLionel Sambuc 87*f4a2713aSLionel Sambuc template struct Choose0<true, int, float, int&>; 88*f4a2713aSLionel Sambuc template struct Choose0<false, int, float, float&>; 89*f4a2713aSLionel Sambuc template struct Choose0<true, int, float, float&>; // expected-note{{instantiation}} 90*f4a2713aSLionel Sambuc 91*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 92*f4a2713aSLionel Sambuc // __builtin_va_arg 93*f4a2713aSLionel Sambuc // --------------------------------------------------------------------- 94*f4a2713aSLionel Sambuc template<typename ArgType> 95*f4a2713aSLionel Sambuc struct VaArg0 { fVaArg096*f4a2713aSLionel Sambuc void f(int n, ...) { 97*f4a2713aSLionel Sambuc __builtin_va_list va; 98*f4a2713aSLionel Sambuc __builtin_va_start(va, n); 99*f4a2713aSLionel Sambuc for (int i = 0; i != n; ++i) 100*f4a2713aSLionel Sambuc (void)__builtin_va_arg(va, ArgType); 101*f4a2713aSLionel Sambuc __builtin_va_end(va); 102*f4a2713aSLionel Sambuc } 103*f4a2713aSLionel Sambuc }; 104*f4a2713aSLionel Sambuc 105*f4a2713aSLionel Sambuc template struct VaArg0<int>; 106*f4a2713aSLionel Sambuc 107*f4a2713aSLionel Sambuc template<typename VaList, typename ArgType> 108*f4a2713aSLionel Sambuc struct VaArg1 { fVaArg1109*f4a2713aSLionel Sambuc void f(int n, ...) { 110*f4a2713aSLionel Sambuc VaList va; 111*f4a2713aSLionel Sambuc __builtin_va_start(va, n); // expected-error{{int}} 112*f4a2713aSLionel Sambuc for (int i = 0; i != n; ++i) 113*f4a2713aSLionel Sambuc (void)__builtin_va_arg(va, ArgType); // expected-error{{int}} 114*f4a2713aSLionel Sambuc __builtin_va_end(va); // expected-error{{int}} 115*f4a2713aSLionel Sambuc } 116*f4a2713aSLionel Sambuc }; 117*f4a2713aSLionel Sambuc 118*f4a2713aSLionel Sambuc template struct VaArg1<__builtin_va_list, int>; 119*f4a2713aSLionel Sambuc template struct VaArg1<int, int>; // expected-note{{instantiation}} 120