1 // RUN: %clang_cc1 %s -fsyntax-only -verify
2 
3 typedef unsigned __uint32_t;
4 
5 #define __byte_swap_int_var(x) \
6 __extension__ ({ register __uint32_t __X = (x); \
7    __asm ("bswap %0" : "+r" (__X)); \
8    __X; })
9 
10 int test(int _x) {
11  return (__byte_swap_int_var(_x));
12 }
13 
14 // PR2374
15 int test2() { return ({L:5;}); }
16 int test3() { return ({ {5;} }); }         // expected-error {{returning 'void' from a function with incompatible result type 'int'}}\
17                                            // expected-warning {{expression result unused}}
18 int test4() { return ({ ({5;}); }); }
19 int test5() { return ({L1: L2: L3: 5;}); }
20 int test6() { return ({5;}); }
21 void test7() { ({5;}); }                   // expected-warning {{expression result unused}}
22 
23 // PR3062
24 int test8[({10;})]; // expected-error {{statement expression not allowed at file scope}}
25 
26 // PR3912
27 void test9(const void *P) {
28   __builtin_prefetch(P);
29 }
30 
31 
32 void *test10() {
33 bar:
34   return &&bar;  // expected-warning {{returning address of label, which is local}}
35 }
36 
37 // PR6034
38 void test11(int bit) {
39   switch (bit) // expected-warning {{switch statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
40   switch (env->fpscr)  // expected-error {{use of undeclared identifier 'env'}}
41   {
42   }
43 }
44 
45 // rdar://3271964
46 enum Numbers { kOne,  kTwo,  kThree,  kFour};
47 int test12(enum Numbers num) {
48   switch (num == kOne) {// expected-warning {{switch condition has boolean value}}
49   default:
50   case kThree:
51     break;
52   }
53 }
54 
55 
56 enum x { a, b, c, d, e, f, g };
57 
58 void foo(enum x X) {
59   switch (X) { // expected-warning {{enumeration value 'g' not handled in switch}}
60   case a:
61   case b:
62   case c:
63   case d:
64   case e:
65   case f:
66     break;
67   }
68 
69   switch (X) { // expected-warning {{enumeration values 'f' and 'g' not handled in switch}}
70   case a:
71   case b:
72   case c:
73   case d:
74   case e:
75     break;
76   }
77 
78   switch (X) {  // expected-warning {{enumeration values 'e', 'f', and 'g' not handled in switch}}
79     case a:
80     case b:
81     case c:
82     case d:
83       break;
84   }
85 
86   switch (X) { // expected-warning {{5 enumeration values not handled in switch: 'c', 'd', 'e'...}}
87   case a:
88   case b:
89     break;
90   }
91 }
92 
93 // PR 8880
94 // FIXME: Clang should reject this, since GCC does.  Previously this
95 // was causing a crash in the CFG builder.
96 int test_pr8880() {
97   int first = 1;
98   for ( ; ({ if (first) { first = 0; continue; } 0; }); )
99     return 0;
100   return 1;
101 }
102 
103