1// RUN: %clang_cc1 %s -fsyntax-only -verify -triple x86_64-pc-linux-gnu -Wno-unevaluated-expression 2 3typedef 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 10int test(int _x) { 11 return (__byte_swap_int_var(_x)); 12} 13 14// PR2374 15int test2() { return ({L:5;}); } 16int test3() { return ({ {5;} }); } // expected-error {{returning 'void' from a function with incompatible result type 'int'}}\ 17 // expected-warning {{expression result unused}} 18int test4() { return ({ ({5;}); }); } 19int test5() { return ({L1: L2: L3: 5;}); } 20int test6() { return ({5;}); } 21void test7() { ({5;}); } // expected-warning {{expression result unused}} 22 23// PR3062 24int test8[({10;})]; // expected-error {{statement expression not allowed at file scope}} 25 26// PR3912 27void test9(const void *P) { 28 __builtin_prefetch(P); 29} 30 31 32void *test10() { 33bar: 34 return &&bar; // expected-warning {{returning address of label, which is local}} 35} 36 37// PR6034 38void test11(int bit) { 39 switch (bit) 40 switch (env->fpscr) // expected-error {{use of undeclared identifier 'env'}} 41 { 42 } 43} 44 45// rdar://3271964 46enum Numbers { kOne, kTwo, kThree, kFour}; 47int 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 56enum x { a, b, c, d, e, f, g }; 57 58void 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 93int test_pr8880() { 94 int first = 1; 95 for ( ; ({ if (first) { first = 0; continue; } 0; }); ) 96 return 0; 97 return 1; 98} 99 100// In PR22849, we considered __ptr to be a static data member of the anonymous 101// union. Now we declare it in the parent DeclContext. 102void test_pr22849() { 103 struct Bug { 104 typeof(({ unsigned long __ptr; (int *)(0); })) __val; 105 union Nested { 106 typeof(({ unsigned long __ptr; (int *)(0); })) __val; 107 } n; 108 }; 109 enum E { 110 SIZE = sizeof(({unsigned long __ptr; __ptr;})) 111 }; 112} 113