statements.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // RUN: %clang_cc1 %s -fsyntax-only -verify -triple x86_64-pc-linux-gnu -Wno-unevaluated-expression
  2. typedef unsigned __uint32_t;
  3. #define __byte_swap_int_var(x) \
  4. __extension__ ({ register __uint32_t __X = (x); \
  5. __asm ("bswap %0" : "+r" (__X)); \
  6. __X; })
  7. int test(int _x) {
  8. return (__byte_swap_int_var(_x));
  9. }
  10. // PR2374
  11. int test2() { return ({L:5;}); }
  12. int test3() { return ({ {5;} }); } // expected-error {{returning 'void' from a function with incompatible result type 'int'}}\
  13. // expected-warning {{expression result unused}}
  14. int test4() { return ({ ({5;}); }); }
  15. int test5() { return ({L1: L2: L3: 5;}); }
  16. int test6() { return ({5;}); }
  17. void test7() { ({5;}); } // expected-warning {{expression result unused}}
  18. // PR3062
  19. int test8[({10;})]; // expected-error {{statement expression not allowed at file scope}}
  20. // PR3912
  21. void test9(const void *P) {
  22. __builtin_prefetch(P);
  23. }
  24. void *test10() {
  25. bar:
  26. return &&bar; // expected-warning {{returning address of label, which is local}}
  27. }
  28. // PR6034
  29. void test11(int bit) {
  30. switch (bit)
  31. switch (env->fpscr) // expected-error {{use of undeclared identifier 'env'}}
  32. {
  33. }
  34. }
  35. // rdar://3271964
  36. enum Numbers { kOne, kTwo, kThree, kFour};
  37. int test12(enum Numbers num) {
  38. switch (num == kOne) {// expected-warning {{switch condition has boolean value}}
  39. default:
  40. case kThree:
  41. break;
  42. }
  43. }
  44. enum x { a, b, c, d, e, f, g };
  45. void foo(enum x X) {
  46. switch (X) { // expected-warning {{enumeration value 'g' not handled in switch}}
  47. case a:
  48. case b:
  49. case c:
  50. case d:
  51. case e:
  52. case f:
  53. break;
  54. }
  55. switch (X) { // expected-warning {{enumeration values 'f' and 'g' not handled in switch}}
  56. case a:
  57. case b:
  58. case c:
  59. case d:
  60. case e:
  61. break;
  62. }
  63. switch (X) { // expected-warning {{enumeration values 'e', 'f', and 'g' not handled in switch}}
  64. case a:
  65. case b:
  66. case c:
  67. case d:
  68. break;
  69. }
  70. switch (X) { // expected-warning {{5 enumeration values not handled in switch: 'c', 'd', 'e'...}}
  71. case a:
  72. case b:
  73. break;
  74. }
  75. }
  76. int test_pr8880() {
  77. int first = 1;
  78. for ( ; ({ if (first) { first = 0; continue; } 0; }); )
  79. return 0;
  80. return 1;
  81. }
  82. // In PR22849, we considered __ptr to be a static data member of the anonymous
  83. // union. Now we declare it in the parent DeclContext.
  84. void test_pr22849() {
  85. struct Bug {
  86. typeof(({ unsigned long __ptr; (int *)(0); })) __val;
  87. union Nested {
  88. typeof(({ unsigned long __ptr; (int *)(0); })) __val;
  89. } n;
  90. };
  91. enum E {
  92. SIZE = sizeof(({unsigned long __ptr; __ptr;}))
  93. };
  94. }