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