1// RUN: %clang_cc1 -fsyntax-only -verify %s 2 3// Test template instantiation for C99-specific features. 4 5// --------------------------------------------------------------------- 6// Designated initializers 7// --------------------------------------------------------------------- 8template<typename T, typename XType, typename YType> 9struct DesigInit0 { 10 void f(XType x, YType y) { 11 T agg = { 12 .y = y, // expected-error{{does not refer}} 13 .x = x // expected-error{{does not refer}} 14 }; 15 } 16}; 17 18struct Point2D { 19 float x, y; 20}; 21 22template struct DesigInit0<Point2D, int, double>; 23 24struct Point3D { 25 float x, y, z; 26}; 27 28template struct DesigInit0<Point3D, int, double>; 29 30struct Color { 31 unsigned char red, green, blue; 32}; 33 34struct ColorPoint3D { 35 Color color; 36 float x, y, z; 37}; 38 39template struct DesigInit0<ColorPoint3D, int, double>; 40template struct DesigInit0<Color, int, double>; // expected-note{{instantiation}} 41 42template<typename T, int Subscript1, int Subscript2, 43 typename Val1, typename Val2> 44struct DesigArrayInit0 { 45 void f(Val1 val1, Val2 val2) { 46 T array = { 47 [Subscript1] = val1, 48 [Subscript2] = val2 // expected-error{{exceeds array bounds}} 49 }; 50 51 int array2[10] = { [5] = 3 }; 52 } 53}; 54 55template struct DesigArrayInit0<int[8], 5, 3, float, int>; 56template struct DesigArrayInit0<int[8], 5, 13, float, int>; // expected-note{{instantiation}} 57 58template<typename T, int Subscript1, int Subscript2, 59 typename Val1> 60struct DesigArrayRangeInit0 { 61 void f(Val1 val1) { 62 T array = { 63 [Subscript1...Subscript2] = val1 // expected-error{{exceeds}} 64 }; 65 } 66}; 67 68template struct DesigArrayRangeInit0<int[8], 3, 5, float>; 69template struct DesigArrayRangeInit0<int[8], 5, 13, float>; // expected-note{{instantiation}} 70 71// --------------------------------------------------------------------- 72// Compound literals 73// --------------------------------------------------------------------- 74template<typename T, typename Arg1, typename Arg2> 75struct CompoundLiteral0 { 76 T f(Arg1 a1, Arg2 a2) { 77 return (T){a1, a2}; 78 } 79}; 80 81template struct CompoundLiteral0<Point2D, int, float>; 82