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