1 | // RUN: %clang_cc1 %s -fsyntax-only -verify -triple x86_64-pc-linux-gnu -Wno-unevaluated-expression |
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 | // PR38569: Don't warn when returning a label from a statement expression. |
38 | void test10_logpc(void*); |
39 | void test10a() { |
40 | test10_logpc(({ |
41 | my_pc: |
42 | &&my_pc; |
43 | })); |
44 | } |
45 | |
46 | // PR6034 |
47 | void test11(int bit) { |
48 | switch (bit) |
49 | switch (env->fpscr) // expected-error {{use of undeclared identifier 'env'}} |
50 | { |
51 | } |
52 | } |
53 | |
54 | // rdar://3271964 |
55 | enum Numbers { kOne, kTwo, kThree, kFour}; |
56 | int test12(enum Numbers num) { |
57 | switch (num == kOne) {// expected-warning {{switch condition has boolean value}} |
58 | default: |
59 | case kThree: |
60 | break; |
61 | } |
62 | } |
63 | |
64 | |
65 | enum x { a, b, c, d, e, f, g }; |
66 | |
67 | void foo(enum x X) { |
68 | switch (X) { // expected-warning {{enumeration value 'g' not handled in switch}} |
69 | case a: |
70 | case b: |
71 | case c: |
72 | case d: |
73 | case e: |
74 | case f: |
75 | break; |
76 | } |
77 | |
78 | switch (X) { // expected-warning {{enumeration values 'f' and 'g' not handled in switch}} |
79 | case a: |
80 | case b: |
81 | case c: |
82 | case d: |
83 | case e: |
84 | break; |
85 | } |
86 | |
87 | switch (X) { // expected-warning {{enumeration values 'e', 'f', and 'g' not handled in switch}} |
88 | case a: |
89 | case b: |
90 | case c: |
91 | case d: |
92 | break; |
93 | } |
94 | |
95 | switch (X) { // expected-warning {{5 enumeration values not handled in switch: 'c', 'd', 'e'...}} |
96 | case a: |
97 | case b: |
98 | break; |
99 | } |
100 | } |
101 | |
102 | int test_pr8880() { |
103 | int first = 1; |
104 | for ( ; ({ if (first) { first = 0; continue; } 0; }); ) |
105 | return 0; |
106 | return 1; |
107 | } |
108 | |
109 | // In PR22849, we considered __ptr to be a static data member of the anonymous |
110 | // union. Now we declare it in the parent DeclContext. |
111 | void test_pr22849() { |
112 | struct Bug { |
113 | typeof(({ unsigned long __ptr; (int *)(0); })) __val; |
114 | union Nested { |
115 | typeof(({ unsigned long __ptr; (int *)(0); })) __val; |
116 | } n; |
117 | }; |
118 | enum E { |
119 | SIZE = sizeof(({unsigned long __ptr; __ptr;})) |
120 | }; |
121 | } |
122 | |