1 // RUN: %clang_cc1 -Wno-c99-extensions -Wno-reorder -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -Wno-c99-extensions -Wno-reorder -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -Wno-c99-extensions -Wno-reorder -fsyntax-only -verify -std=c++11 %s
5 // Test template instantiation for C99-specific features.
7 // ---------------------------------------------------------------------
8 // Designated initializers
9 // ---------------------------------------------------------------------
10 template<typename T
, typename XType
, typename YType
>
12 void f(XType x
, YType y
) {
14 #if __cplusplus <= 199711L
15 .y
= y
, // expected-error{{does not refer}}
16 .x
= x
// expected-error{{does not refer}}
18 .y
= static_cast<float>(y
), // expected-error{{does not refer}}
19 .x
= static_cast<float>(x
) // expected-error{{does not refer}}
29 template struct DesigInit0
<Point2D
, int, double>;
35 template struct DesigInit0
<Point3D
, int, double>;
38 unsigned char red
, green
, blue
;
46 template struct DesigInit0
<ColorPoint3D
, int, double>;
47 template struct DesigInit0
<Color
, int, double>; // expected-note{{instantiation}}
49 template<typename T
, int Subscript1
, int Subscript2
,
50 typename Val1
, typename Val2
>
51 struct DesigArrayInit0
{
52 void f(Val1 val1
, Val2 val2
) {
54 #if __cplusplus <= 199711L
57 [Subscript1
] = static_cast<int>(val1
),
59 [Subscript2
] = val2
// expected-error{{exceeds array bounds}}
62 int array2
[10] = { [5] = 3 };
66 template struct DesigArrayInit0
<int[8], 5, 3, float, int>;
67 template struct DesigArrayInit0
<int[8], 5, 13, float, int>; // expected-note{{instantiation}}
69 template<typename T
, int Subscript1
, int Subscript2
,
71 struct DesigArrayRangeInit0
{
74 #if __cplusplus <= 199711L
75 [Subscript1
...Subscript2
] = val1
// expected-error{{exceeds}}
77 [Subscript1
...Subscript2
] = static_cast<int>(val1
) // expected-error{{exceeds}}
83 template struct DesigArrayRangeInit0
<int[8], 3, 5, float>;
84 template struct DesigArrayRangeInit0
<int[8], 5, 13, float>; // expected-note{{instantiation}}
86 // ---------------------------------------------------------------------
88 // ---------------------------------------------------------------------
89 template<typename T
, typename Arg1
, typename Arg2
>
90 struct CompoundLiteral0
{
91 T
f(Arg1 a1
, Arg2 a2
) {
92 #if __cplusplus <= 199711L
95 return (T
){static_cast<float>(a1
), a2
};
100 template struct CompoundLiteral0
<Point2D
, int, float>;