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