Douglas Gregor | 0b74891 | 2009-04-14 21:18:50 +0000 | [diff] [blame] | 1 | // Header for PCH test exprs.c |
| 2 | |
| 3 | // DeclRefExpr |
| 4 | int i = 17; |
| 5 | enum Enum { Enumerator = 18 }; |
| 6 | typedef typeof(i) int_decl_ref; |
| 7 | typedef typeof(Enumerator) enum_decl_ref; |
| 8 | |
Douglas Gregor | 17fc223 | 2009-04-14 21:55:33 +0000 | [diff] [blame] | 9 | // IntegerLiteral |
Douglas Gregor | 0b74891 | 2009-04-14 21:18:50 +0000 | [diff] [blame] | 10 | typedef typeof(17) integer_literal; |
| 11 | typedef typeof(17l) long_literal; |
| 12 | |
Douglas Gregor | db600c3 | 2009-04-15 00:25:59 +0000 | [diff] [blame] | 13 | // FloatingLiteral and ParenExpr |
Douglas Gregor | c04db4f | 2009-04-14 23:59:37 +0000 | [diff] [blame] | 14 | typedef typeof((42.5)) floating_literal; |
Douglas Gregor | 17fc223 | 2009-04-14 21:55:33 +0000 | [diff] [blame] | 15 | |
Douglas Gregor | cb2ca73 | 2009-04-15 22:19:53 +0000 | [diff] [blame] | 16 | // ImaginaryLiteral |
| 17 | typedef typeof(17.0i) imaginary_literal; |
| 18 | |
Douglas Gregor | 673ecd6 | 2009-04-15 16:35:07 +0000 | [diff] [blame] | 19 | // StringLiteral |
| 20 | const char *hello = "Hello" "PCH" "World"; |
| 21 | |
Douglas Gregor | 17fc223 | 2009-04-14 21:55:33 +0000 | [diff] [blame] | 22 | // CharacterLiteral |
Douglas Gregor | 0b74891 | 2009-04-14 21:18:50 +0000 | [diff] [blame] | 23 | typedef typeof('a') char_literal; |
Douglas Gregor | 17fc223 | 2009-04-14 21:55:33 +0000 | [diff] [blame] | 24 | |
Douglas Gregor | 0b0b77f | 2009-04-15 15:58:59 +0000 | [diff] [blame] | 25 | // UnaryOperator |
| 26 | typedef typeof(-Enumerator) negate_enum; |
| 27 | |
| 28 | // SizeOfAlignOfExpr |
| 29 | typedef typeof(sizeof(int)) typeof_sizeof; |
| 30 | typedef typeof(sizeof(Enumerator)) typeof_sizeof2; |
| 31 | |
Douglas Gregor | cb2ca73 | 2009-04-15 22:19:53 +0000 | [diff] [blame] | 32 | // ArraySubscriptExpr |
| 33 | extern double values[]; |
| 34 | typedef typeof(values[2]) array_subscript; |
| 35 | |
Douglas Gregor | 1f0d013 | 2009-04-15 17:43:59 +0000 | [diff] [blame] | 36 | // CallExpr |
| 37 | double dplus(double x, double y); |
| 38 | double d0, d1; |
| 39 | typedef typeof((&dplus)(d0, d1)) call_returning_double; |
| 40 | |
| 41 | // MemberExpr |
| 42 | struct S { |
| 43 | double x; |
| 44 | }; |
| 45 | typedef typeof(((struct S*)0)->x) member_ref_double; |
| 46 | |
Douglas Gregor | db600c3 | 2009-04-15 00:25:59 +0000 | [diff] [blame] | 47 | // BinaryOperator |
| 48 | typedef typeof(i + Enumerator) add_result; |
| 49 | |
Douglas Gregor | ad90e96 | 2009-04-15 22:40:36 +0000 | [diff] [blame] | 50 | // CompoundAssignOperator |
| 51 | typedef typeof(i += Enumerator) addeq_result; |
| 52 | |
| 53 | // ConditionalOperator |
| 54 | typedef typeof(i? : d0) conditional_operator; |
| 55 | |
Douglas Gregor | db600c3 | 2009-04-15 00:25:59 +0000 | [diff] [blame] | 56 | // CStyleCastExpr |
| 57 | typedef typeof((void *)0) void_ptr; |
| 58 | |
Douglas Gregor | ba6d7e7 | 2009-04-16 02:33:48 +0000 | [diff] [blame] | 59 | // CompoundLiteral |
| 60 | typedef typeof((struct S){.x = 3.5}) compound_literal; |
| 61 | |
Douglas Gregor | d3c98a0 | 2009-04-15 23:02:49 +0000 | [diff] [blame] | 62 | // ExtVectorElementExpr |
| 63 | typedef __attribute__(( ext_vector_type(2) )) double double2; |
Douglas Gregor | 94cd5d1 | 2009-04-16 00:01:45 +0000 | [diff] [blame] | 64 | extern double2 vec2, vec2b; |
Douglas Gregor | d3c98a0 | 2009-04-15 23:02:49 +0000 | [diff] [blame] | 65 | typedef typeof(vec2.x) ext_vector_element; |
Douglas Gregor | 44cae0c | 2009-04-15 23:33:31 +0000 | [diff] [blame] | 66 | |
Douglas Gregor | d077d75 | 2009-04-16 00:55:48 +0000 | [diff] [blame] | 67 | // InitListExpr |
| 68 | double double_array[3] = { 1.0, 2.0 }; |
| 69 | |
| 70 | // DesignatedInitExpr |
| 71 | struct { |
| 72 | int x; |
| 73 | float y; |
| 74 | } designated_inits[3] = { [0].y = 17, [2].x = 12.3, 3.5 }; |
| 75 | |
Douglas Gregor | 44cae0c | 2009-04-15 23:33:31 +0000 | [diff] [blame] | 76 | // TypesCompatibleExpr |
| 77 | typedef typeof(__builtin_types_compatible_p(float, double)) types_compatible; |
| 78 | |
| 79 | // ChooseExpr |
| 80 | typedef typeof(__builtin_choose_expr(17 > 19, d0, 1)) choose_expr; |
| 81 | |
| 82 | // GNUNullExpr FIXME: needs C++ |
| 83 | // typedef typeof(__null) null_type; |
Douglas Gregor | 94cd5d1 | 2009-04-16 00:01:45 +0000 | [diff] [blame] | 84 | |
| 85 | // ShuffleVectorExpr |
| 86 | typedef typeof(__builtin_shufflevector(vec2, vec2b, 2, 1)) shuffle_expr; |