1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// RUN: clang-cc -fsyntax-only -verify %s
// ---------------------------------------------------------------------
// Imaginary literals
// ---------------------------------------------------------------------
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}}
// ---------------------------------------------------------------------
// Compound assignment operator
// ---------------------------------------------------------------------
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}}
// ---------------------------------------------------------------------
// 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>;
// ---------------------------------------------------------------------
// Statement expressions
// ---------------------------------------------------------------------
template<typename T>
struct StatementExpr0 {
void f(T t) {
(void)({ if (t) t = t + 17; }); // expected-error{{invalid}}
}
};
template struct StatementExpr0<int>;
template struct StatementExpr0<N1::X>; // expected-note{{instantiation}}
// ---------------------------------------------------------------------
// __builtin_types_compatible_p
// ---------------------------------------------------------------------
template<typename T, typename U, bool Result>
struct TypesCompatible0 {
void f() {
int a[__builtin_types_compatible_p(T, U) == Result? 1 : -1];
}
};
template struct TypesCompatible0<int, const int, true>;
// ---------------------------------------------------------------------
// __builtin_shufflevector
// ---------------------------------------------------------------------
typedef __attribute__(( ext_vector_type(2) )) double double2;
template<typename T, typename U, int N, int M>
struct ShuffleVector0 {
void f(T t, U u, double2 a, double2 b) {
(void)__builtin_shufflevector(t, u, N, M); // expected-error{{index}}
(void)__builtin_shufflevector(a, b, N, M);
(void)__builtin_shufflevector(a, b, 2, 1);
}
};
template struct ShuffleVector0<double2, double2, 2, 1>;
template struct ShuffleVector0<double2, double2, 4, 3>; // expected-note{{instantiation}}
|