exprs.h 2.6 KB

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