blob: 80768f8df24e7fda87adf74c71e901e83259a16e [file] [log] [blame]
Douglas Gregor0b748912009-04-14 21:18:50 +00001// 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
Douglas Gregor17fc2232009-04-14 21:55:33 +00009// IntegerLiteral
Douglas Gregor0b748912009-04-14 21:18:50 +000010typedef typeof(17) integer_literal;
11typedef typeof(17l) long_literal;
12
Douglas Gregordb600c32009-04-15 00:25:59 +000013// FloatingLiteral and ParenExpr
Douglas Gregorc04db4f2009-04-14 23:59:37 +000014typedef typeof((42.5)) floating_literal;
Douglas Gregor17fc2232009-04-14 21:55:33 +000015
Douglas Gregorcb2ca732009-04-15 22:19:53 +000016// ImaginaryLiteral
17typedef typeof(17.0i) imaginary_literal;
18
Douglas Gregor673ecd62009-04-15 16:35:07 +000019// StringLiteral
20const char *hello = "Hello" "PCH" "World";
21
Douglas Gregor17fc2232009-04-14 21:55:33 +000022// CharacterLiteral
Douglas Gregor0b748912009-04-14 21:18:50 +000023typedef typeof('a') char_literal;
Douglas Gregor17fc2232009-04-14 21:55:33 +000024
Douglas Gregor0b0b77f2009-04-15 15:58:59 +000025// UnaryOperator
26typedef typeof(-Enumerator) negate_enum;
27
Douglas Gregor8ecdb652010-04-28 22:16:22 +000028// 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
Douglas Gregor0b0b77f2009-04-15 15:58:59 +000041// SizeOfAlignOfExpr
42typedef typeof(sizeof(int)) typeof_sizeof;
43typedef typeof(sizeof(Enumerator)) typeof_sizeof2;
44
Douglas Gregorcb2ca732009-04-15 22:19:53 +000045// ArraySubscriptExpr
46extern double values[];
47typedef typeof(values[2]) array_subscript;
48
Douglas Gregor1f0d0132009-04-15 17:43:59 +000049// 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
Douglas Gregordb600c32009-04-15 00:25:59 +000060// BinaryOperator
61typedef typeof(i + Enumerator) add_result;
62
Douglas Gregorad90e962009-04-15 22:40:36 +000063// CompoundAssignOperator
64typedef typeof(i += Enumerator) addeq_result;
65
66// ConditionalOperator
67typedef typeof(i? : d0) conditional_operator;
68
Douglas Gregordb600c32009-04-15 00:25:59 +000069// CStyleCastExpr
70typedef typeof((void *)0) void_ptr;
71
Douglas Gregorba6d7e72009-04-16 02:33:48 +000072// CompoundLiteral
73typedef typeof((struct S){.x = 3.5}) compound_literal;
74
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000075typedef typeof(i + sizeof(int[i + Enumerator])) add_result_with_typeinfo;
76
Douglas Gregord3c98a02009-04-15 23:02:49 +000077// ExtVectorElementExpr
78typedef __attribute__(( ext_vector_type(2) )) double double2;
Douglas Gregor94cd5d12009-04-16 00:01:45 +000079extern double2 vec2, vec2b;
Douglas Gregord3c98a02009-04-15 23:02:49 +000080typedef typeof(vec2.x) ext_vector_element;
Douglas Gregor44cae0c2009-04-15 23:33:31 +000081
Douglas Gregord077d752009-04-16 00:55:48 +000082// 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, [2].x = 12.3, 3.5 };
90
Douglas Gregor44cae0c2009-04-15 23:33:31 +000091// TypesCompatibleExpr
92typedef typeof(__builtin_types_compatible_p(float, double)) types_compatible;
93
94// ChooseExpr
95typedef typeof(__builtin_choose_expr(17 > 19, d0, 1)) choose_expr;
96
97// GNUNullExpr FIXME: needs C++
98// typedef typeof(__null) null_type;
Douglas Gregor94cd5d12009-04-16 00:01:45 +000099
100// ShuffleVectorExpr
101typedef typeof(__builtin_shufflevector(vec2, vec2b, 2, 1)) shuffle_expr;