diff options
Diffstat (limited to 'test/Sema')
43 files changed, 425 insertions, 126 deletions
diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c index 6258114..23c1405 100644 --- a/test/Sema/address_spaces.c +++ b/test/Sema/address_spaces.c @@ -36,7 +36,7 @@ struct _st { // rdar://6774906 __attribute__((address_space(256))) void * * const base = 0; void * get_0(void) { - return base[0]; // expected-error {{illegal implicit cast between two pointers with different address spaces}} \ + return base[0]; // expected-error {{illegal implicit conversion between two pointers with different address spaces}} \ expected-warning {{returning 'void __attribute__((address_space(256))) *' from a function with result type 'void *' discards qualifiers}} } diff --git a/test/Sema/align-x86-64.c b/test/Sema/align-x86-64.c new file mode 100644 index 0000000..6dcf571 --- /dev/null +++ b/test/Sema/align-x86-64.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s + +// PR5599 + +void frob(void *); + +void foo(void) { + float x[4]; + char y[__alignof__(x) == 16 ? 1 : -1]; + frob(y); +} diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c index e723255..e7c997f 100644 --- a/test/Sema/attr-deprecated.c +++ b/test/Sema/attr-deprecated.c @@ -4,8 +4,6 @@ int f() __attribute__((deprecated)); void g() __attribute__((deprecated)); void g(); -void z() __attribute__((bogusattr)); // expected-warning {{'bogusattr' attribute ignored}} - extern int var __attribute__((deprecated)); int a() { @@ -45,7 +43,7 @@ typedef struct foo foo_dep __attribute__((deprecated)); foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}} struct bar_dep __attribute__((deprecated, - invalid_attribute)); // expected-warning {{'invalid_attribute' attribute ignored}} + invalid_attribute)); // expected-warning {{unknown attribute 'invalid_attribute' ignored}} struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}} diff --git a/test/Sema/attr-regparm.c b/test/Sema/attr-regparm.c index 045a413..4049e0e 100644 --- a/test/Sema/attr-regparm.c +++ b/test/Sema/attr-regparm.c @@ -1,7 +1,11 @@ // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s -__attribute((regparm(2))) int x(void); -__attribute((regparm(1.0))) int x(void); // expected-error{{'regparm' attribute requires integer constant}} -__attribute((regparm(-1))) int x(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}} -__attribute((regparm(5))) int x(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}} -__attribute((regparm(5,3))) int x(void); // expected-error{{attribute requires 1 argument(s)}} +__attribute((regparm(2))) int x0(void); +__attribute((regparm(1.0))) int x1(void); // expected-error{{'regparm' attribute requires integer constant}} +__attribute((regparm(-1))) int x2(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}} +__attribute((regparm(5))) int x3(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}} +__attribute((regparm(5,3))) int x4(void); // expected-error{{attribute requires 1 argument(s)}} + +void __attribute__((regparm(3))) x5(int); +void x5(int); // expected-note{{previous declaration is here}} +void __attribute__((regparm(2))) x5(int); // expected-error{{function declared with with regparm(2) attribute was previously declared with the regparm(3) attribute}} diff --git a/test/Sema/attr-unknown.c b/test/Sema/attr-unknown.c new file mode 100644 index 0000000..bec2e29 --- /dev/null +++ b/test/Sema/attr-unknown.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunknown-attributes %s + +int x __attribute__((foobar)); // expected-warning {{unknown attribute 'foobar' ignored}} +void z() __attribute__((bogusattr)); // expected-warning {{unknown attribute 'bogusattr' ignored}} diff --git a/test/Sema/bitfield-layout.c b/test/Sema/bitfield-layout.c index edc44bd..2655fc7 100644 --- a/test/Sema/bitfield-layout.c +++ b/test/Sema/bitfield-layout.c @@ -30,3 +30,13 @@ CHECK_ALIGN(struct, e, 1) struct f {__attribute((aligned(8))) int x : 30, y : 30, z : 30;}; CHECK_SIZE(struct, f, 24) CHECK_ALIGN(struct, f, 8) + +// Large structure (overflows i32, in bits). +struct s0 { + char a[0x32100000]; + int x:30, y:30; +}; + +CHECK_SIZE(struct, s0, 0x32100008) +CHECK_ALIGN(struct, s0, 4) + diff --git a/test/Sema/block-call.c b/test/Sema/block-call.c index 318bc6b..28e6c68 100644 --- a/test/Sema/block-call.c +++ b/test/Sema/block-call.c @@ -13,9 +13,11 @@ int main() { int (^IFP) () = PFR; // OK - const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' with an expression of type 'int (^)()'}} + const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' with an expression of type 'int (^)()'}} \ + // expected-warning{{type qualifier on return type has no effect}} + + const int (^CICC) () = CIC; // expected-warning{{type qualifier on return type has no effect}} - const int (^CICC) () = CIC; int * const (^IPCC) () = 0; diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c index 10b3b84..33fd183 100644 --- a/test/Sema/block-return.c +++ b/test/Sema/block-return.c @@ -109,8 +109,11 @@ void foo6() { void foo7() { - const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}} - const int (^CC) (void) = ^const int{ const int i = 1; return i; }; // OK + const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}} \ + // expected-warning{{type qualifier on return type has no effect}} + + const int (^CC) (void) = ^const int{ const int i = 1; return i; }; // expected-warning{{type qualifier on return type has no effect}} + int i; int (^FF) (void) = ^{ return i; }; // OK diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c index 6fa563b..c0a2131 100644 --- a/test/Sema/builtins.c +++ b/test/Sema/builtins.c @@ -40,7 +40,10 @@ void test9(short v) { old = __sync_fetch_and_add(); // expected-error {{too few arguments to function call}} old = __sync_fetch_and_add(&old); // expected-error {{too few arguments to function call}} - old = __sync_fetch_and_add((int**)0, 42i); // expected-warning {{imaginary constants are an extension}} + old = __sync_fetch_and_add((unsigned*)0, 42i); // expected-warning {{imaginary constants are an extension}} + + // PR7600: Pointers are implicitly casted to integers and back. + void *old_ptr = __sync_val_compare_and_swap((void**)0, 0, 0); } diff --git a/test/Sema/compare.c b/test/Sema/compare.c index f997dc1..b2c3563 100644 --- a/test/Sema/compare.c +++ b/test/Sema/compare.c @@ -3,7 +3,7 @@ int test(char *C) { // nothing here should warn. return C != ((void*)0); return C != (void*)0; - return C != 0; + return C != 0; return C != 1; // expected-warning {{comparison between pointer and integer ('char *' and 'int')}} } @@ -218,7 +218,7 @@ int pointers(int *a) { int function_pointers(int (*a)(int), int (*b)(int), void (*c)(int)) { return a > b; // expected-warning {{ordered comparison of function pointers}} - return function_pointers > function_pointers; // expected-warning {{ordered comparison of function pointers}} + return function_pointers > function_pointers; // expected-warning {{self-comparison always evaluates to false}} expected-warning{{ordered comparison of function pointers}} return a > c; // expected-warning {{comparison of distinct pointer types}} return a == (void *) 0; return a == (void *) 1; // expected-warning {{equality comparison between function pointer and void pointer}} @@ -229,6 +229,7 @@ int void_pointers(void* foo) { return foo == (void*) 1; } + int test1(int i) { enum en { zero }; return i > zero; diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index 9c53725..c132b34 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -74,5 +74,5 @@ const _Bool constbool = 0; EVAL_EXPR(35, constbool) EVAL_EXPR(36, constbool) -EVAL_EXPR(37, (1,2.0) == 2.0) +EVAL_EXPR(37, (1,2.0) == 2.0) // expected-warning {{expression result unused}} EVAL_EXPR(38, __builtin_expect(1,1) == 1) diff --git a/test/Sema/conversion-64-32.c b/test/Sema/conversion-64-32.c index 1043996..aa72829 100644 --- a/test/Sema/conversion-64-32.c +++ b/test/Sema/conversion-64-32.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wshorten-64-to-32 -triple x86_64-apple-darwin %s int test0(long v) { - return v; // expected-warning {{implicit cast loses integer precision}} + return v; // expected-warning {{implicit conversion loses integer precision}} } diff --git a/test/Sema/conversion.c b/test/Sema/conversion.c index 5b09ec6..5fbd64d 100644 --- a/test/Sema/conversion.c +++ b/test/Sema/conversion.c @@ -6,17 +6,17 @@ void test0(char c, short s, int i, long l, long long ll) { c = c; - c = s; // expected-warning {{implicit cast loses integer precision}} - c = i; // expected-warning {{implicit cast loses integer precision}} - c = l; // expected-warning {{implicit cast loses integer precision}} + c = s; // expected-warning {{implicit conversion loses integer precision}} + c = i; // expected-warning {{implicit conversion loses integer precision}} + c = l; // expected-warning {{implicit conversion loses integer precision}} s = c; s = s; - s = i; // expected-warning {{implicit cast loses integer precision}} - s = l; // expected-warning {{implicit cast loses integer precision}} + s = i; // expected-warning {{implicit conversion loses integer precision}} + s = l; // expected-warning {{implicit conversion loses integer precision}} i = c; i = s; i = i; - i = l; // expected-warning {{implicit cast loses integer precision}} + i = l; // expected-warning {{implicit conversion loses integer precision}} l = c; l = s; l = i; @@ -40,17 +40,17 @@ void test0(char c, short s, int i, long l, long long ll) { l = (long) 0; c = (char) BIG; - c = (short) BIG; // expected-warning {{implicit cast loses integer precision}} - c = (int) BIG; // expected-warning {{implicit cast loses integer precision}} - c = (long) BIG; // expected-warning {{implicit cast loses integer precision}} + c = (short) BIG; // expected-warning {{implicit conversion loses integer precision}} + c = (int) BIG; // expected-warning {{implicit conversion loses integer precision}} + c = (long) BIG; // expected-warning {{implicit conversion loses integer precision}} s = (char) BIG; s = (short) BIG; - s = (int) BIG; // expected-warning {{implicit cast loses integer precision}} - s = (long) BIG; // expected-warning {{implicit cast loses integer precision}} + s = (int) BIG; // expected-warning {{implicit conversion loses integer precision}} + s = (long) BIG; // expected-warning {{implicit conversion loses integer precision}} i = (char) BIG; i = (short) BIG; i = (int) BIG; - i = (long) BIG; // expected-warning {{implicit cast loses integer precision}} + i = (long) BIG; // expected-warning {{implicit conversion loses integer precision}} l = (char) BIG; l = (short) BIG; l = (int) BIG; @@ -58,39 +58,39 @@ void test0(char c, short s, int i, long l, long long ll) { } char test1(long long ll) { - return (long long) ll; // expected-warning {{implicit cast loses integer precision}} - return (long) ll; // expected-warning {{implicit cast loses integer precision}} - return (int) ll; // expected-warning {{implicit cast loses integer precision}} - return (short) ll; // expected-warning {{implicit cast loses integer precision}} + return (long long) ll; // expected-warning {{implicit conversion loses integer precision}} + return (long) ll; // expected-warning {{implicit conversion loses integer precision}} + return (int) ll; // expected-warning {{implicit conversion loses integer precision}} + return (short) ll; // expected-warning {{implicit conversion loses integer precision}} return (char) ll; - return (long long) BIG; // expected-warning {{implicit cast loses integer precision}} - return (long) BIG; // expected-warning {{implicit cast loses integer precision}} - return (int) BIG; // expected-warning {{implicit cast loses integer precision}} - return (short) BIG; // expected-warning {{implicit cast loses integer precision}} + return (long long) BIG; // expected-warning {{implicit conversion loses integer precision}} + return (long) BIG; // expected-warning {{implicit conversion loses integer precision}} + return (int) BIG; // expected-warning {{implicit conversion loses integer precision}} + return (short) BIG; // expected-warning {{implicit conversion loses integer precision}} return (char) BIG; } short test2(long long ll) { - return (long long) ll; // expected-warning {{implicit cast loses integer precision}} - return (long) ll; // expected-warning {{implicit cast loses integer precision}} - return (int) ll; // expected-warning {{implicit cast loses integer precision}} + return (long long) ll; // expected-warning {{implicit conversion loses integer precision}} + return (long) ll; // expected-warning {{implicit conversion loses integer precision}} + return (int) ll; // expected-warning {{implicit conversion loses integer precision}} return (short) ll; return (char) ll; - return (long long) BIG; // expected-warning {{implicit cast loses integer precision}} - return (long) BIG; // expected-warning {{implicit cast loses integer precision}} - return (int) BIG; // expected-warning {{implicit cast loses integer precision}} + return (long long) BIG; // expected-warning {{implicit conversion loses integer precision}} + return (long) BIG; // expected-warning {{implicit conversion loses integer precision}} + return (int) BIG; // expected-warning {{implicit conversion loses integer precision}} return (short) BIG; return (char) BIG; } int test3(long long ll) { - return (long long) ll; // expected-warning {{implicit cast loses integer precision}} - return (long) ll; // expected-warning {{implicit cast loses integer precision}} + return (long long) ll; // expected-warning {{implicit conversion loses integer precision}} + return (long) ll; // expected-warning {{implicit conversion loses integer precision}} return (int) ll; return (short) ll; return (char) ll; - return (long long) BIG; // expected-warning {{implicit cast loses integer precision}} - return (long) BIG; // expected-warning {{implicit cast loses integer precision}} + return (long long) BIG; // expected-warning {{implicit conversion loses integer precision}} + return (long) BIG; // expected-warning {{implicit conversion loses integer precision}} return (int) BIG; return (short) BIG; return (char) BIG; @@ -143,7 +143,7 @@ void test6(char v) { } void test7(short v) { - takes_char(v); // expected-warning {{implicit cast loses integer precision}} + takes_char(v); // expected-warning {{implicit conversion loses integer precision}} takes_short(v); takes_int(v); takes_long(v); @@ -154,8 +154,8 @@ void test7(short v) { } void test8(int v) { - takes_char(v); // expected-warning {{implicit cast loses integer precision}} - takes_short(v); // expected-warning {{implicit cast loses integer precision}} + takes_char(v); // expected-warning {{implicit conversion loses integer precision}} + takes_short(v); // expected-warning {{implicit conversion loses integer precision}} takes_int(v); takes_long(v); takes_longlong(v); @@ -165,9 +165,9 @@ void test8(int v) { } void test9(long v) { - takes_char(v); // expected-warning {{implicit cast loses integer precision}} - takes_short(v); // expected-warning {{implicit cast loses integer precision}} - takes_int(v); // expected-warning {{implicit cast loses integer precision}} + takes_char(v); // expected-warning {{implicit conversion loses integer precision}} + takes_short(v); // expected-warning {{implicit conversion loses integer precision}} + takes_int(v); // expected-warning {{implicit conversion loses integer precision}} takes_long(v); takes_longlong(v); takes_float(v); @@ -176,9 +176,9 @@ void test9(long v) { } void test10(long long v) { - takes_char(v); // expected-warning {{implicit cast loses integer precision}} - takes_short(v); // expected-warning {{implicit cast loses integer precision}} - takes_int(v); // expected-warning {{implicit cast loses integer precision}} + takes_char(v); // expected-warning {{implicit conversion loses integer precision}} + takes_short(v); // expected-warning {{implicit conversion loses integer precision}} + takes_int(v); // expected-warning {{implicit conversion loses integer precision}} takes_long(v); takes_longlong(v); takes_float(v); @@ -187,35 +187,35 @@ void test10(long long v) { } void test11(float v) { - takes_char(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_short(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_int(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_long(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_longlong(v); // expected-warning {{implicit cast turns floating-point number into integer}} + takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}} takes_float(v); takes_double(v); takes_longdouble(v); } void test12(double v) { - takes_char(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_short(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_int(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_long(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_longlong(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_float(v); // expected-warning {{implicit cast loses floating-point precision}} + takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_float(v); // expected-warning {{implicit conversion loses floating-point precision}} takes_double(v); takes_longdouble(v); } void test13(long double v) { - takes_char(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_short(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_int(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_long(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_longlong(v); // expected-warning {{implicit cast turns floating-point number into integer}} - takes_float(v); // expected-warning {{implicit cast loses floating-point precision}} - takes_double(v); // expected-warning {{implicit cast loses floating-point precision}} + takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}} + takes_float(v); // expected-warning {{implicit conversion loses floating-point precision}} + takes_double(v); // expected-warning {{implicit conversion loses floating-point precision}} takes_longdouble(v); } @@ -229,13 +229,13 @@ void test14(long l) { void test15(char c) { c = c + 1 + c * 2; - c = (short) c + 1 + c * 2; // expected-warning {{implicit cast loses integer precision}} + c = (short) c + 1 + c * 2; // expected-warning {{implicit conversion loses integer precision}} } // PR 5422 extern void *test16_external; void test16(void) { - int a = (unsigned long) &test16_external; // expected-warning {{implicit cast loses integer precision}} + int a = (unsigned long) &test16_external; // expected-warning {{implicit conversion loses integer precision}} } // PR 5938 @@ -249,7 +249,7 @@ void test17() { unsigned int x; x = U.a; x = U.b; - x = U.c; // expected-warning {{implicit cast loses integer precision}} + x = U.c; // expected-warning {{implicit conversion loses integer precision}} } // PR 5939 @@ -277,7 +277,7 @@ unsigned char test19(unsigned long u64) { // <rdar://problem/7631400> void test_7631400(void) { // This should show up despite the caret being inside a macro substitution - char s = LONG_MAX; // expected-warning {{implicit cast loses integer precision: 'long' to 'char'}} + char s = LONG_MAX; // expected-warning {{implicit conversion loses integer precision: 'long' to 'char'}} } // <rdar://problem/7676608>: assertion for compound operators with non-integral RHS @@ -291,9 +291,9 @@ void test_7676608(void) { // <rdar://problem/7904686> void test_7904686(void) { const int i = -1; - unsigned u1 = i; // expected-warning {{implicit cast changes signedness}} - u1 = i; // expected-warning {{implicit cast changes signedness}} + unsigned u1 = i; // expected-warning {{implicit conversion changes signedness}} + u1 = i; // expected-warning {{implicit conversion changes signedness}} - unsigned u2 = -1; // expected-warning {{implicit cast changes signedness}} - u2 = -1; // expected-warning {{implicit cast changes signedness}} + unsigned u2 = -1; // expected-warning {{implicit conversion changes signedness}} + u2 = -1; // expected-warning {{implicit conversion changes signedness}} } diff --git a/test/Sema/enum-packed.c b/test/Sema/enum-packed.c new file mode 100644 index 0000000..0eb6c14 --- /dev/null +++ b/test/Sema/enum-packed.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// PR7477 +enum __attribute__((packed)) E { + Ea, Eb, Ec, Ed +}; + +void test_E(enum E e) { + switch (e) { + case Ea: + case Eb: + case Ec: + case Ed: + break; + } +} diff --git a/test/Sema/enum.c b/test/Sema/enum.c index ba4e56b..0570150 100644 --- a/test/Sema/enum.c +++ b/test/Sema/enum.c @@ -51,7 +51,7 @@ void test4() { } // PR2416 -enum someenum {}; // expected-warning {{use of empty enum extension}} +enum someenum {}; // expected-error {{use of empty enum}} // <rdar://problem/6093889> enum e0 { // expected-note {{previous definition is here}} diff --git a/test/Sema/expr-comma-c89.c b/test/Sema/expr-comma-c89.c index d0883ba..dc42702 100644 --- a/test/Sema/expr-comma-c89.c +++ b/test/Sema/expr-comma-c89.c @@ -11,7 +11,7 @@ int B[sizeof((a.c)) == 17 ? 1 : -1]; // comma does array/function promotion in c99. -int X[sizeof(0, (foo().c)) == sizeof(char*) ? 1 : -1]; -int Y[sizeof(0, (a,b).c) == sizeof(char*) ? 1 : -1]; -int Z[sizeof(0, (a=b).c) == sizeof(char*) ? 1 : -1]; +int X[sizeof(0, (foo().c)) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}} +int Y[sizeof(0, (a,b).c) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}} expected-warning {{expression result unused}} +int Z[sizeof(0, (a=b).c) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}} diff --git a/test/Sema/expr-comma.c b/test/Sema/expr-comma.c index d3e4020..b004fc1 100644 --- a/test/Sema/expr-comma.c +++ b/test/Sema/expr-comma.c @@ -11,7 +11,7 @@ int B[sizeof((a.c)) == 17 ? 1 : -1]; // comma does not promote array/function in c90 unless they are lvalues. -int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1]; -int X[sizeof(0, (foo().c)) == 17 ? 1 : -1]; -int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1]; -int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1]; +int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}} +int X[sizeof(0, (foo().c)) == 17 ? 1 : -1]; // expected-warning {{expression result unused}} +int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1]; // expected-warning {{expression result unused}} // expected-warning {{expression result unused}} +int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1]; // expected-warning {{expression result unused}} diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index dbb6e80..b22b522 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -134,3 +134,11 @@ void test18(int b) { test18_a(b, b); // expected-error {{too many arguments to function call, expected 1, have 2}} test18_a(); // expected-error {{too few arguments to function call, expected 1, have 0}} } + +// PR7569 +void test19() { + *(int*)0 = 0; // expected-warning {{indirection of non-volatile null pointer}} \ + // expected-note {{consider using __builtin_trap}} + *(volatile int*)0 = 0; // Ok. +} + diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c index d297623..7681953 100644 --- a/test/Sema/ext_vector_casts.c +++ b/test/Sema/ext_vector_casts.c @@ -43,3 +43,10 @@ static void test() { ivec4 |= ivec4; ivec4 += ptr; // expected-error {{can't convert between vector values of different size ('int4' and 'int *')}} } + +typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2'}} + +void inc(float2 f2) { + f2++; // expected-error{{cannot increment value of type 'float2'}} + __real f2; // expected-error{{invalid type 'float2' to __real operator}} +} diff --git a/test/Sema/ext_vector_comparisons.c b/test/Sema/ext_vector_comparisons.c new file mode 100644 index 0000000..605ba6c --- /dev/null +++ b/test/Sema/ext_vector_comparisons.c @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unreachable-code %s + +typedef __attribute__(( ext_vector_type(4) )) int int4; + +static int4 test1() { + int4 vec, rv; + + // comparisons to self... + return vec == vec; // expected-warning{{self-comparison always evaluates to a constant}} + return vec != vec; // expected-warning{{self-comparison always evaluates to a constant}} + return vec < vec; // expected-warning{{self-comparison always evaluates to a constant}} + return vec <= vec; // expected-warning{{self-comparison always evaluates to a constant}} + return vec > vec; // expected-warning{{self-comparison always evaluates to a constant}} + return vec >= vec; // expected-warning{{self-comparison always evaluates to a constant}} +} + + +typedef __attribute__(( ext_vector_type(4) )) float float4; + +static int4 test2() { + float4 vec, rv; + + // comparisons to self. no warning, they're floats + return vec == vec; // no-warning + return vec != vec; // no-warning + return vec < vec; // no-warning + return vec <= vec; // no-warning + return vec > vec; // no-warning + return vec >= vec; // no-warning +} diff --git a/test/Sema/extern-redecl.c b/test/Sema/extern-redecl.c new file mode 100644 index 0000000..067e3c2 --- /dev/null +++ b/test/Sema/extern-redecl.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only %s + +// rdar: // 8125274 +static int a16[]; // expected-warning {{tentative array definition assumed to have one element}} + +void f16(void) { + extern int a16[]; +} + diff --git a/test/Sema/format-strings-fixit.c b/test/Sema/format-strings-fixit.c new file mode 100644 index 0000000..7cd76c7 --- /dev/null +++ b/test/Sema/format-strings-fixit.c @@ -0,0 +1,44 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -Wall -fixit %t || true +// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror %t + +/* This is a test of the various code modification hints that are + provided as part of warning or extension diagnostics. All of the + warnings will be fixed by -fixit, and the resulting file should + compile cleanly with -Werror -pedantic. */ + +int printf(char const *, ...); + +void test() { + // Basic types + printf("%s", (int) 123); + printf("abc%0f", "testing testing 123"); + printf("%u", (long) -12); + printf("%p", 123); + printf("%c\n", "x"); + printf("%c\n", 1.23); + + // Larger types + printf("%+.2d", (unsigned long long) 123456); + printf("%1d", (long double) 1.23); + + // Flag handling + printf("%0+s", (unsigned) 31337); // 0 flag should stay + printf("%#p", (void *) 0); + printf("% +f", 1.23); // + flag should stay + printf("%0-f", 1.23); // - flag should stay + + // Positional arguments + printf("%1$f:%2$.*3$f:%4$.*3$f\n", 1, 2, 3, 4); + + // Precision + printf("%10.5d", 1l); // (bug 7394) + printf("%.2c", 'a'); + + // Ignored flags + printf("%0-f", 1.23); + + // Bad length modifiers + printf("%hhs", "foo"); + printf("%1$zp", (void *)0); +} diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index d6d3796..c6dee68 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -172,18 +172,21 @@ void test10(int x, float f, int i, long long lli) { printf("%f\n", (long double) 1.0); // expected-warning{{conversion specifies type 'double' but the argument has type 'long double'}} // The man page says that a zero precision is okay. printf("%.0Lf", (long double) 1.0); // no-warning + printf("%c\n", "x"); // expected-warning{{conversion specifies type 'int' but the argument has type 'char *'}} + printf("%c\n", 1.23); // expected-warning{{conversion specifies type 'int' but the argument has type 'double'}} } void test11(void *p, char *s) { printf("%p", p); // no-warning - printf("%.4p", p); // expected-warning{{precision used in 'p' conversion specifier (where it has no meaning)}} - printf("%+p", p); // expected-warning{{flag '+' results in undefined behavior in 'p' conversion specifier}} - printf("% p", p); // expected-warning{{flag ' ' results in undefined behavior in 'p' conversion specifier}} - printf("%0p", p); // expected-warning{{flag '0' results in undefined behavior in 'p' conversion specifier}} + printf("%p", 123); // expected-warning{{conversion specifies type 'void *' but the argument has type 'int'}} + printf("%.4p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}} + printf("%+p", p); // expected-warning{{flag '+' results in undefined behavior with 'p' conversion specifier}} + printf("% p", p); // expected-warning{{flag ' ' results in undefined behavior with 'p' conversion specifier}} + printf("%0p", p); // expected-warning{{flag '0' results in undefined behavior with 'p' conversion specifier}} printf("%s", s); // no-warning - printf("%+s", p); // expected-warning{{flag '+' results in undefined behavior in 's' conversion specifier}} - printf("% s", p); // expected-warning{{flag ' ' results in undefined behavior in 's' conversion specifier}} - printf("%0s", p); // expected-warning{{flag '0' results in undefined behavior in 's' conversion specifier}} + printf("%+s", p); // expected-warning{{flag '+' results in undefined behavior with 's' conversion specifier}} + printf("% s", p); // expected-warning{{flag ' ' results in undefined behavior with 's' conversion specifier}} + printf("%0s", p); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}} } void test12(char *b) { @@ -254,3 +257,30 @@ void test_pr_6697() { void rdar8026030(FILE *fp) { fprintf(fp, "\%"); // expected-warning{{incomplete format specifier}} } + +void bug7377_bad_length_mod_usage() { + // Bad length modifiers + printf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}} + printf("%1$zp", (void *)0); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}} + printf("%ls", L"foo"); // no-warning + printf("%#.2Lf", (long double)1.234); // no-warning + + // Bad flag usage + printf("%#p", (void *) 0); // expected-warning{{flag '#' results in undefined behavior with 'p' conversion specifier}} + printf("%0d", -1); // no-warning + printf("%#n", (void *) 0); // expected-warning{{flag '#' results in undefined behavior with 'n' conversion specifier}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} + printf("%-n", (void *) 0); // expected-warning{{flag '-' results in undefined behavior with 'n' conversion specifier}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} + printf("%-p", (void *) 0); // no-warning + + // Bad optional amount use + printf("%.2c", 'a'); // expected-warning{{precision used with 'c' conversion specifier, resulting in undefined behavior}} + printf("%1n", (void *) 0); // expected-warning{{field width used with 'n' conversion specifier, resulting in undefined behavior}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} + printf("%.9n", (void *) 0); // expected-warning{{precision used with 'n' conversion specifier, resulting in undefined behavior}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} + + // Ignored flags + printf("% +f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}} + printf("%+ f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}} + printf("%0-f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}} + printf("%-0f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}} + printf("%-+f", 1.23); // no-warning +} diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c index 633ad21..27ec163 100644 --- a/test/Sema/function-redecl.c +++ b/test/Sema/function-redecl.c @@ -126,6 +126,6 @@ void test_x() { x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}} } -enum e0 {}; +enum e0 {one}; void f3(); void f3(enum e0 x) {} diff --git a/test/Sema/function.c b/test/Sema/function.c index 9a83519..b51c137 100644 --- a/test/Sema/function.c +++ b/test/Sema/function.c @@ -34,10 +34,10 @@ void t12(int) {} // expected-error{{parameter name omitted}} // PR2790 void t13() { - return 0; // expected-warning {{void function 't13' should not return a value}} + return 0; // expected-error {{void function 't13' should not return a value}} } int t14() { - return; // expected-warning {{non-void function 't14' should return a value}} + return; // expected-error {{non-void function 't14' should return a value}} } // <rdar://problem/6097326> diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c index 97d9f43..c86a93f 100644 --- a/test/Sema/i-c-e.c +++ b/test/Sema/i-c-e.c @@ -50,9 +50,10 @@ char y[__builtin_constant_p(expr) ? -1 : 1]; char z[__builtin_constant_p(4) ? 1 : -1]; // Comma tests -int comma1[0?1,2:3]; -int comma2[1||(1,2)]; -int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}} +int comma1[0?1,2:3]; // expected-warning {{expression result unused}} +int comma2[1||(1,2)]; // expected-warning {{expression result unused}} +int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}} \ + // expected-warning {{expression result unused}} // Pointer + __builtin_constant_p char pbcp[__builtin_constant_p(4) ? (intptr_t)&expr : 0]; // expected-error {{variable length array declaration not allowed at file scope}} diff --git a/test/Sema/implicit-decl.c b/test/Sema/implicit-decl.c index 830cde9..f455977 100644 --- a/test/Sema/implicit-decl.c +++ b/test/Sema/implicit-decl.c @@ -10,7 +10,6 @@ void func() { if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \ expected-warning {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}} } - return ((void *)0); // expected-warning {{void function 'func' should not return a value}} } Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}} return 0; diff --git a/test/Sema/init.c b/test/Sema/init.c index c2c29ad..ac274a4ce 100644 --- a/test/Sema/init.c +++ b/test/Sema/init.c @@ -118,8 +118,6 @@ int* ptest1 = __builtin_choose_expr(1, (int*)0, (int*)0); typedef int32_t ivector4 __attribute((vector_size(16))); ivector4 vtest1 = 1 ? (ivector4){1} : (ivector4){1}; ivector4 vtest2 = __builtin_choose_expr(1, (ivector4){1}, (ivector4){1}); -ivector4 vtest3 = __real__ (ivector4){1}; -ivector4 vtest4 = __imag__ (ivector4){1}; uintptr_t ptrasintadd1 = (uintptr_t)&a - 4; uintptr_t ptrasintadd2 = (uintptr_t)&a + 4; diff --git a/test/Sema/missing-field-initializers.c b/test/Sema/missing-field-initializers.c index 8281914..6aa48ba 100644 --- a/test/Sema/missing-field-initializers.c +++ b/test/Sema/missing-field-initializers.c @@ -20,6 +20,8 @@ struct Foo bar1[] = { 1 }; // expected-warning {{missing field 'b' initializer}} +struct Foo bar2[] = { {}, {}, {} }; + struct One { int a; int b; }; struct Two { float c; float d; float e; }; diff --git a/test/Sema/opencl-init.c b/test/Sema/opencl-init.c new file mode 100644 index 0000000..3d116bd --- /dev/null +++ b/test/Sema/opencl-init.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 %s -x cl -verify -pedantic -fsyntax-only + +typedef float float8 __attribute((ext_vector_type(8))); + +typedef float float32_t; +typedef __attribute__(( __vector_size__(16) )) float32_t __neon_float32x4_t; +typedef struct __simd128_float32_t { + __neon_float32x4_t val; +} float32x4_t; + +float8 foo(float8 x) { + float32x4_t lo; + float32x4_t hi; + return (float8) (lo.val, hi.val); +} diff --git a/test/Sema/pragma-align-mac68k-unsupported.c b/test/Sema/pragma-align-mac68k-unsupported.c index 6588aa1..c23c01b 100644 --- a/test/Sema/pragma-align-mac68k-unsupported.c +++ b/test/Sema/pragma-align-mac68k-unsupported.c @@ -1,4 +1,4 @@ -// RUN: %clang-cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s -// RUN: %clang-cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify %s /* expected-error {{mac68k alignment pragma is not supported}} */ #pragma options align=mac68k diff --git a/test/Sema/pragma-align-mac68k.c b/test/Sema/pragma-align-mac68k.c index d13a0be..fb8da51 100644 --- a/test/Sema/pragma-align-mac68k.c +++ b/test/Sema/pragma-align-mac68k.c @@ -1,4 +1,4 @@ -// RUN: %clang-cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s #include <stddef.h> diff --git a/test/Sema/pragma-align-packed.c b/test/Sema/pragma-align-packed.c new file mode 100644 index 0000000..30b87bf --- /dev/null +++ b/test/Sema/pragma-align-packed.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s + +#pragma pack(push, 1) +struct s0 { + char f0; + int f1 __attribute__((aligned(4))); +}; +extern int a[sizeof(struct s0) == 5 ? 1 : -1]; +#pragma pack(pop) + +struct __attribute__((packed)) s1 { + char f0; + int f1 __attribute__((aligned(4))); +}; +extern int a[sizeof(struct s1) == 8 ? 1 : -1]; + +#pragma options align=packed +struct s2 { + char f0; + int f1 __attribute__((aligned(4))); +}; +extern int a[sizeof(struct s2) == 5 ? 1 : -1]; +#pragma options align=reset diff --git a/test/Sema/pragma-pack-and-options-align.c b/test/Sema/pragma-pack-and-options-align.c index c880ed6..ebf1ade 100644 --- a/test/Sema/pragma-pack-and-options-align.c +++ b/test/Sema/pragma-pack-and-options-align.c @@ -16,6 +16,14 @@ struct s1 { }; extern int a[sizeof(struct s1) == 8 ? 1 : -1]; +#pragma options align=reset +#pragma options align=native +struct s1_1 { + char c; + int x; +}; +extern int a[sizeof(struct s1_1) == 8 ? 1 : -1]; + #pragma pack(pop) struct s2 { char c; diff --git a/test/Sema/return.c b/test/Sema/return.c index 0d46d98..2d23e08 100644 --- a/test/Sema/return.c +++ b/test/Sema/return.c @@ -1,4 +1,4 @@ -// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value +// RUN: %clang %s -fsyntax-only -Wreturn-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value // clang emits the following warning by default. // With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the diff --git a/test/Sema/self-comparison.c b/test/Sema/self-comparison.c index 1baba27..c5c0611 100644 --- a/test/Sema/self-comparison.c +++ b/test/Sema/self-comparison.c @@ -1,11 +1,21 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s int foo(int x) { - return x == x; // expected-warning {{self-comparison always results}} + return x == x; // expected-warning {{self-comparison always evaluates to true}} } int foo2(int x) { - return (x) != (((x))); // expected-warning {{self-comparison always results}} + return (x) != (((x))); // expected-warning {{self-comparison always evaluates to false}} +} + +void foo3(short s, short t) { + if (s == s) {} // expected-warning {{self-comparison always evaluates to true}} + if (s == t) {} // no-warning +} + +void foo4(void* v, void* w) { + if (v == v) {} // expected-warning {{self-comparison always evaluates to true}} + if (v == w) {} // no-warning } int qux(int x) { @@ -24,15 +34,44 @@ int bar2(float x) { return x != x; // no-warning } -// Motivated by <rdar://problem/6703892>, self-comparisons of enum constants -// should not be warned about. These can be expanded from macros, and thus -// are usually deliberate. -int compare_enum() { - enum { A }; - return A == A; // no-warning +#define IS_THE_ANSWER(x) (x == 42) + +int macro_comparison() { + return IS_THE_ANSWER(42); } // Don't complain in unevaluated contexts. int compare_sizeof(int x) { return sizeof(x == x); // no-warning } + +int array_comparisons() { + int array1[2]; + int array2[2]; + + // + // compare same array + // + return array1 == array1; // expected-warning{{self-comparison always evaluates to true}} + return array1 != array1; // expected-warning{{self-comparison always evaluates to false}} + return array1 < array1; // expected-warning{{self-comparison always evaluates to false}} + return array1 <= array1; // expected-warning{{self-comparison always evaluates to true}} + return array1 > array1; // expected-warning{{self-comparison always evaluates to false}} + return array1 >= array1; // expected-warning{{self-comparison always evaluates to true}} + + // + // compare differrent arrays + // + return array1 == array2; // expected-warning{{array comparison always evaluates to false}} + return array1 != array2; // expected-warning{{array comparison always evaluates to true}} + + // + // we don't know what these are going to be + // + return array1 < array2; // expected-warning{{array comparison always evaluates to a constant}} + return array1 <= array2; // expected-warning{{array comparison always evaluates to a constant}} + return array1 > array2; // expected-warning{{array comparison always evaluates to a constant}} + return array1 >= array2; // expected-warning{{array comparison always evaluates to a constant}} + +} + diff --git a/test/Sema/struct-cast.c b/test/Sema/struct-cast.c index dc7db13..3456665 100644 --- a/test/Sema/struct-cast.c +++ b/test/Sema/struct-cast.c @@ -5,7 +5,8 @@ struct S { int two; }; -struct S const foo(void); +struct S const foo(void); // expected-warning{{type qualifier on return type has no effect}} + struct S tmp; diff --git a/test/Sema/struct-decl.c b/test/Sema/struct-decl.c index f888053..3639d24 100644 --- a/test/Sema/struct-decl.c +++ b/test/Sema/struct-decl.c @@ -41,3 +41,8 @@ struct s0 { }; struct s0 f0(void) {} + +// <rdar://problem/8177927> - This previously triggered an assertion failure. +struct x0 { + unsigned int x1; +}; diff --git a/test/Sema/switch.c b/test/Sema/switch.c index 27ad066..bb48229 100644 --- a/test/Sema/switch.c +++ b/test/Sema/switch.c @@ -277,3 +277,14 @@ void test16() { case '6': return; } } + +// PR7359 +void test17(int x) { + switch (x >= 17) { // expected-warning {{switch condition has boolean value}} + case 0: return; + } + + switch ((int) (x <= 17)) { + case 0: return; + } +} diff --git a/test/Sema/transparent-union.c b/test/Sema/transparent-union.c index cdfc850..27d5c24 100644 --- a/test/Sema/transparent-union.c +++ b/test/Sema/transparent-union.c @@ -38,3 +38,10 @@ typedef union { } TU3 __attribute__((transparent_union)); typedef union { } TU4 __attribute__((transparent_union)); // expected-warning{{field}} + +typedef int int4 __attribute__((ext_vector_type(4))); +typedef union { + int4 vec; // expected-warning{{first field of a transparent union cannot have vector type 'int4'; transparent_union attribute ignored}} +} TU5 __attribute__((transparent_union)); + + diff --git a/test/Sema/types.c b/test/Sema/types.c index 1770bf5..f3244f7 100644 --- a/test/Sema/types.c +++ b/test/Sema/types.c @@ -36,4 +36,4 @@ _Decimal32 x; // expected-error {{GNU decimal type extension not supported}} // rdar://6880951 -int __attribute__ ((vector_size (8), vector_size (8))) v; // expected-error {{invalid vector type}} +int __attribute__ ((vector_size (8), vector_size (8))) v; // expected-error {{invalid vector element type}} diff --git a/test/Sema/var-redecl.c b/test/Sema/var-redecl.c index 71d7ea1..f7576b6 100644 --- a/test/Sema/var-redecl.c +++ b/test/Sema/var-redecl.c @@ -58,5 +58,5 @@ int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \ // PR3645 static int a; -extern int a; -int a; +extern int a; // expected-note {{previous definition is here}} +int a; // expected-error {{non-static declaration of 'a' follows static declaration}} diff --git a/test/Sema/warn-unused-value.c b/test/Sema/warn-unused-value.c index 16b787f..1a7e745 100644 --- a/test/Sema/warn-unused-value.c +++ b/test/Sema/warn-unused-value.c @@ -18,9 +18,9 @@ void pr4806() { i,foo(); // expected-warning {{expression result unused}} foo(),i; // expected-warning {{expression result unused}} - i,j,foo(); // expected-warning {{expression result unused}} - i,foo(),j; // expected-warning {{expression result unused}} - foo(),i,j; // expected-warning {{expression result unused}} + i,j,foo(); // expected-warning {{expression result unused}} expected-warning {{expression result unused}} + i,foo(),j; // expected-warning {{expression result unused}} expected-warning {{expression result unused}} + foo(),i,j; // expected-warning {{expression result unused}} expected-warning {{expression result unused}} i++; @@ -63,6 +63,16 @@ int test_logical_bar() { (x = test_logical_foo1()) || // no-warning (x = test_logical_foo2()) || // no-warning (x = test_logical_foo3()); // no-warning + + x || test_logical_foo1(); // no-warning + return x; } +struct s0 { int f0; }; + +void f0(int a); +void f1(struct s0 *a) { + // rdar://8139785 + f0((int)(a->f0 + 1, 10)); // expected-warning {{expression result unused}} +} |