2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-05-19 06:38:38 +08:00
|
|
|
|
2009-05-20 04:13:50 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// Imaginary literals
|
|
|
|
// ---------------------------------------------------------------------
|
2009-05-19 06:38:38 +08:00
|
|
|
template<typename T>
|
|
|
|
struct ImaginaryLiteral0 {
|
|
|
|
void f(T &x) {
|
|
|
|
x = 3.0I; // expected-error{{incompatible type}}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct ImaginaryLiteral0<_Complex float>;
|
|
|
|
template struct ImaginaryLiteral0<int*>; // expected-note{{instantiation}}
|
2009-05-20 04:02:01 +08:00
|
|
|
|
2009-05-20 04:13:50 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// Compound assignment operator
|
|
|
|
// ---------------------------------------------------------------------
|
2009-05-20 04:02:01 +08:00
|
|
|
namespace N1 {
|
|
|
|
struct X { };
|
|
|
|
|
|
|
|
int& operator+=(X&, int); // expected-note{{candidate}}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace N2 {
|
|
|
|
long& operator+=(N1::X&, long); // expected-note{{candidate}}
|
|
|
|
|
|
|
|
template<typename T, typename U, typename Result>
|
|
|
|
struct PlusEquals0 {
|
|
|
|
void f(T t, U u) {
|
|
|
|
Result r = t += u; // expected-error{{ambiguous}}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace N3 {
|
|
|
|
struct Y : public N1::X {
|
|
|
|
short& operator+=(long); // expected-note{{candidate}}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
template struct N2::PlusEquals0<N1::X, int, int&>;
|
|
|
|
template struct N2::PlusEquals0<N1::X, long, long&>;
|
|
|
|
template struct N2::PlusEquals0<N3::Y, long, short&>;
|
|
|
|
template struct N2::PlusEquals0<int, int, int&>;
|
|
|
|
template struct N2::PlusEquals0<N3::Y, int, short&>; // expected-note{{instantiation}}
|
2009-05-20 04:13:50 +08:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// Conditional operator
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
template<typename T, typename U, typename Result>
|
|
|
|
struct Conditional0 {
|
|
|
|
void f(T t, U u) {
|
|
|
|
Result result = t? : u;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct Conditional0<int, int, int>;
|
2009-05-20 04:31:21 +08:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// Statement expressions
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
template<typename T>
|
|
|
|
struct StatementExpr0 {
|
|
|
|
void f(T t) {
|
2010-05-09 06:20:28 +08:00
|
|
|
(void)({ if (t) t = t + 17; t + 12;}); // expected-error{{contextually convertible}}
|
2009-05-20 04:31:21 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct StatementExpr0<int>;
|
|
|
|
template struct StatementExpr0<N1::X>; // expected-note{{instantiation}}
|
2009-05-20 04:55:31 +08:00
|
|
|
|
2009-05-20 06:43:30 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// __builtin_choose_expr
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
template<bool Cond, typename T, typename U, typename Result>
|
|
|
|
struct Choose0 {
|
|
|
|
void f(T t, U u) {
|
|
|
|
Result r = __builtin_choose_expr(Cond, t, u); // expected-error{{lvalue}}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct Choose0<true, int, float, int&>;
|
|
|
|
template struct Choose0<false, int, float, float&>;
|
|
|
|
template struct Choose0<true, int, float, float&>; // expected-note{{instantiation}}
|
2009-05-20 07:10:31 +08:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
2009-05-20 07:29:16 +08:00
|
|
|
// __builtin_va_arg
|
2009-05-20 07:10:31 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
template<typename ArgType>
|
|
|
|
struct VaArg0 {
|
|
|
|
void f(int n, ...) {
|
|
|
|
__builtin_va_list va;
|
|
|
|
__builtin_va_start(va, n);
|
|
|
|
for (int i = 0; i != n; ++i)
|
|
|
|
(void)__builtin_va_arg(va, ArgType);
|
|
|
|
__builtin_va_end(va);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct VaArg0<int>;
|
2009-05-20 07:29:16 +08:00
|
|
|
|
2009-05-21 02:50:16 +08:00
|
|
|
template<typename VaList, typename ArgType>
|
|
|
|
struct VaArg1 {
|
|
|
|
void f(int n, ...) {
|
|
|
|
VaList va;
|
2009-05-21 04:30:46 +08:00
|
|
|
__builtin_va_start(va, n); // expected-error{{int}}
|
2009-05-21 02:50:16 +08:00
|
|
|
for (int i = 0; i != n; ++i)
|
|
|
|
(void)__builtin_va_arg(va, ArgType);
|
|
|
|
__builtin_va_end(va);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct VaArg1<__builtin_va_list, int>;
|
|
|
|
template struct VaArg1<int, int>; // expected-note{{instantiation}}
|