1// Header for PCH test exprs.c 2 3// DeclRefExpr 4int i = 17; 5enum Enum { Enumerator = 18 }; 6typedef typeof(i) int_decl_ref; 7typedef typeof(Enumerator) enum_decl_ref; 8 9// IntegerLiteral 10typedef typeof(17) integer_literal; 11typedef typeof(17l) long_literal; 12 13// FloatingLiteral and ParenExpr 14typedef typeof((42.5)) floating_literal; 15 16// ImaginaryLiteral 17typedef typeof(17.0i) imaginary_literal; 18 19// StringLiteral 20const char *hello = "Hello" "PCH" "World"; 21 22// CharacterLiteral 23typedef typeof('a') char_literal; 24 25// UnaryOperator 26typedef typeof(-Enumerator) negate_enum; 27 28// OffsetOfExpr 29struct X { 30 int member; 31}; 32struct Y { 33 struct X array[5]; 34}; 35struct Z { 36 struct Y y; 37}; 38typedef typeof(__builtin_offsetof(struct Z, y.array[1 + 2].member)) 39 offsetof_type; 40 41// UnaryExprOrTypeTraitExpr 42typedef typeof(sizeof(int)) typeof_sizeof; 43typedef typeof(sizeof(Enumerator)) typeof_sizeof2; 44 45// ArraySubscriptExpr 46extern double values[]; 47typedef typeof(values[2]) array_subscript; 48 49// CallExpr 50double dplus(double x, double y); 51double d0, d1; 52typedef typeof((&dplus)(d0, d1)) call_returning_double; 53 54// MemberExpr 55struct S { 56 double x; 57}; 58typedef typeof(((struct S*)0)->x) member_ref_double; 59 60// BinaryOperator 61typedef typeof(i + Enumerator) add_result; 62 63// CompoundAssignOperator 64typedef typeof(i += Enumerator) addeq_result; 65 66// ConditionalOperator 67typedef typeof(i? : d0) conditional_operator; 68 69// CStyleCastExpr 70typedef typeof((void *)0) void_ptr; 71 72// CompoundLiteral 73typedef typeof((struct S){.x = 3.5}) compound_literal; 74 75typedef typeof(i + sizeof(int[i + Enumerator])) add_result_with_typeinfo; 76 77// ExtVectorElementExpr 78typedef __attribute__(( ext_vector_type(2) )) double double2; 79extern double2 vec2, vec2b; 80typedef typeof(vec2.x) ext_vector_element; 81 82// InitListExpr 83double double_array[3] = { 1.0, 2.0 }; 84 85// DesignatedInitExpr 86struct { 87 int x; 88 float y; 89} designated_inits[3] = { [0].y = 17, 90 [2].x = 12.3, // expected-warning {{implicit conversion turns literal floating-point number into integer}} 91 3.5 }; 92 93// TypesCompatibleExpr 94typedef typeof(__builtin_types_compatible_p(float, double)) types_compatible; 95 96// ChooseExpr 97typedef typeof(__builtin_choose_expr(17 > 19, d0, 1)) choose_expr; 98 99// GNUNullExpr FIXME: needs C++ 100// typedef typeof(__null) null_type; 101 102// ShuffleVectorExpr 103typedef typeof(__builtin_shufflevector(vec2, vec2b, 2, 1)) shuffle_expr; 104 105// GenericSelectionExpr 106typedef typeof(_Generic(i, char*: 0, int: 0., default: hello)) 107 generic_selection_expr; 108