diff options
author | dim <dim@FreeBSD.org> | 2013-06-10 20:45:12 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-06-10 20:45:12 +0000 |
commit | ea266cad53e3d49771fa38103913d3ec7a166694 (patch) | |
tree | 8f7776b7310bebaf415ac5b69e46e9f928c37144 /test/Sema | |
parent | c72c57c9e9b69944e3e009cd5e209634839581d3 (diff) | |
download | FreeBSD-src-ea266cad53e3d49771fa38103913d3ec7a166694.zip FreeBSD-src-ea266cad53e3d49771fa38103913d3ec7a166694.tar.gz |
Vendor import of clang tags/RELEASE_33/final r183502 (effectively, 3.3
release):
http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_33/final@183502
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/MicrosoftCompatibility.cpp | 4 | ||||
-rw-r--r-- | test/Sema/arm-neon-types.c | 12 | ||||
-rw-r--r-- | test/Sema/array-init.c | 2 | ||||
-rw-r--r-- | test/Sema/asm.c | 16 | ||||
-rw-r--r-- | test/Sema/atomic-expr.c | 47 | ||||
-rw-r--r-- | test/Sema/bitfield.c | 15 | ||||
-rw-r--r-- | test/Sema/builtins-aarch64.c | 16 | ||||
-rw-r--r-- | test/Sema/captured-statements.c | 78 | ||||
-rw-r--r-- | test/Sema/crash-invalid-array.c | 7 | ||||
-rw-r--r-- | test/Sema/extern-redecl.c | 29 | ||||
-rw-r--r-- | test/Sema/function-redecl.c | 4 | ||||
-rw-r--r-- | test/Sema/function.c | 11 | ||||
-rw-r--r-- | test/Sema/no-documentation-warn-tagdecl-specifier.c | 85 | ||||
-rw-r--r-- | test/Sema/parentheses.c | 89 | ||||
-rw-r--r-- | test/Sema/parentheses.cpp | 66 | ||||
-rw-r--r-- | test/Sema/pragma-arc-cf-code-audited.c | 2 | ||||
-rw-r--r-- | test/Sema/return.c | 8 | ||||
-rw-r--r-- | test/Sema/thread-specifier.c | 108 | ||||
-rw-r--r-- | test/Sema/var-redecl.c | 4 | ||||
-rw-r--r-- | test/Sema/warn-documentation.cpp | 2 | ||||
-rw-r--r-- | test/Sema/warn-documentation.m | 1 | ||||
-rw-r--r-- | test/Sema/warn-duplicate-enum.c | 9 |
22 files changed, 562 insertions, 53 deletions
diff --git a/test/Sema/MicrosoftCompatibility.cpp b/test/Sema/MicrosoftCompatibility.cpp new file mode 100644 index 0000000..15c2558 --- /dev/null +++ b/test/Sema/MicrosoftCompatibility.cpp @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility + +// PR15845 +int foo(xxx); // expected-error{{unknown type name}} diff --git a/test/Sema/arm-neon-types.c b/test/Sema/arm-neon-types.c index 1a170db..a49de12 100644 --- a/test/Sema/arm-neon-types.c +++ b/test/Sema/arm-neon-types.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversion -ffreestanding -verify %s +#ifndef INCLUDE #include <arm_neon.h> @@ -33,3 +34,14 @@ int16x8_t test5(int *p) { void test6(float *p, int32x2_t v) { return vst1_s32(p, v); // expected-warning {{incompatible pointer types}} } + +#define INCLUDE +#include "arm-neon-types.c" +#else + +// Make sure we don't get a warning about using a static function in an +// extern inline function from a header. +extern inline uint8x8_t test7(uint8x8_t a, uint8x8_t b) { + return vadd_u8(a, b); +} +#endif diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c index b3cae60..f92852f 100644 --- a/test/Sema/array-init.c +++ b/test/Sema/array-init.c @@ -187,7 +187,7 @@ char r6[sizeof r5 == 15 ? 1 : -1]; const char r7[] = "zxcv"; char r8[5] = "5char"; char r9[5] = "6chars"; //expected-warning{{initializer-string for char array is too long}} - +unsigned char r10[] = __extension__ (_Generic(0, int: (__extension__ "foo" ))); int r11[0] = {}; //expected-warning{{zero size arrays are an extension}} expected-warning{{use of GNU empty initializer extension}} // Some struct tests diff --git a/test/Sema/asm.c b/test/Sema/asm.c index 2c60085..c81f16a 100644 --- a/test/Sema/asm.c +++ b/test/Sema/asm.c @@ -130,3 +130,19 @@ void test14(struct S *s) { __asm("": : "a"(*s)); // expected-error {{dereference of pointer to incomplete type 'struct S'}} __asm("": "=a" (*s) :); // expected-error {{dereference of pointer to incomplete type 'struct S'}} } + +// PR15759. +double test15() { + double ret = 0; + __asm("0.0":"="(ret)); // expected-error {{invalid output constraint '=' in asm}} + __asm("0.0":"=&"(ret)); // expected-error {{invalid output constraint '=&' in asm}} + __asm("0.0":"+?"(ret)); // expected-error {{invalid output constraint '+?' in asm}} + __asm("0.0":"+!"(ret)); // expected-error {{invalid output constraint '+!' in asm}} + __asm("0.0":"+#"(ret)); // expected-error {{invalid output constraint '+#' in asm}} + __asm("0.0":"+*"(ret)); // expected-error {{invalid output constraint '+*' in asm}} + __asm("0.0":"=%"(ret)); // expected-error {{invalid output constraint '=%' in asm}} + __asm("0.0":"=,="(ret)); // expected-error {{invalid output constraint '=,=' in asm}} + __asm("0.0":"=,g"(ret)); // no-error + __asm("0.0":"=g"(ret)); // no-error + return ret; +} diff --git a/test/Sema/atomic-expr.c b/test/Sema/atomic-expr.c new file mode 100644 index 0000000..ecc04c4 --- /dev/null +++ b/test/Sema/atomic-expr.c @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only +// expected-no-diagnostics + +_Atomic(unsigned int) data1; +int _Atomic data2; + +// Shift operations + +int func_01 (int x) { + return data1 << x; +} + +int func_02 (int x) { + return x << data1; +} + +int func_03 (int x) { + return data2 << x; +} + +int func_04 (int x) { + return x << data2; +} + +int func_05 () { + return data2 << data1; +} + +int func_06 () { + return data1 << data2; +} + +void func_07 (int x) { + data1 <<= x; +} + +void func_08 (int x) { + data2 <<= x; +} + +void func_09 (int* xp) { + *xp <<= data1; +} + +void func_10 (int* xp) { + *xp <<= data2; +} diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c index a1ce894..ab05a77 100644 --- a/test/Sema/bitfield.c +++ b/test/Sema/bitfield.c @@ -39,3 +39,18 @@ int y; struct PR8025 { double : 2; // expected-error{{anonymous bit-field has non-integral type 'double'}} }; + +struct Test4 { + unsigned bitX : 4; + unsigned bitY : 4; + unsigned var; +}; +void test4(struct Test4 *t) { + (void) sizeof(t->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} + (void) sizeof((t->bitY)); // expected-error {{invalid application of 'sizeof' to bit-field}} + (void) sizeof(t->bitX = 4); // not a bitfield designator in C + (void) sizeof(t->bitX += 4); // not a bitfield designator in C + (void) sizeof((void) 0, t->bitX); // not a bitfield designator in C + (void) sizeof(t->var ? t->bitX : t->bitY); // not a bitfield designator in C + (void) sizeof(t->var ? t->bitX : t->bitX); // not a bitfield designator in C +} diff --git a/test/Sema/builtins-aarch64.c b/test/Sema/builtins-aarch64.c new file mode 100644 index 0000000..03e0334 --- /dev/null +++ b/test/Sema/builtins-aarch64.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsyntax-only -verify %s + +void test_clear_cache_chars(char *start, char *end) { + __clear_cache(start, end); +} + +void test_clear_cache_voids(void *start, void *end) { + __clear_cache(start, end); +} + +void test_clear_cache_no_args() { + // AArch32 version of this is variadic (at least syntactically). + // However, on AArch64 GCC does not permit this call and the + // implementation I've seen would go disastrously wrong. + __clear_cache(); // expected-error {{too few arguments to function call}} +} diff --git a/test/Sema/captured-statements.c b/test/Sema/captured-statements.c new file mode 100644 index 0000000..9285a78 --- /dev/null +++ b/test/Sema/captured-statements.c @@ -0,0 +1,78 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks + +void test_gotos() { + goto L1; // expected-error {{use of undeclared label 'L1'}} + goto L3; // OK + #pragma clang __debug captured + { +L1: + goto L2; // OK +L2: + goto L3; // expected-error {{use of undeclared label 'L3'}} + } +L3: ; +} + +void test_break_continue() { + while (1) { + #pragma clang __debug captured + { + break; // expected-error {{'break' statement not in loop or switch statement}} + continue; // expected-error {{'continue' statement not in loop statement}} + } + } +} + +void test_return() { + while (1) { + #pragma clang __debug captured + { + return; // expected-error {{cannot return from default captured statement}} + } + } +} + +void test_nest() { + int x; + #pragma clang __debug captured + { + int y; + #pragma clang __debug captured + { + int z; + #pragma clang __debug captured + { + x = z = y; // OK + } + } + } +} + +void test_nest_block() { + __block int x; + int y; + ^{ + int z; + #pragma clang __debug captured + { + x = y; // OK + y = z; // expected-error{{variable is not assignable (missing __block type specifier)}} + z = y; // OK + } + }(); + + __block int a; + int b; + #pragma clang __debug captured + { + __block int c; + int d; + ^{ + a = b; // OK + a = c; // OK + b = d; // OK - Consistent with block inside a lambda + c = a; // OK + d = b; // expected-error{{variable is not assignable (missing __block type specifier)}} + }(); + } +} diff --git a/test/Sema/crash-invalid-array.c b/test/Sema/crash-invalid-array.c index a3bc03b..eeac391 100644 --- a/test/Sema/crash-invalid-array.c +++ b/test/Sema/crash-invalid-array.c @@ -15,3 +15,10 @@ int main() p[i][i] = i; } } + +// rdar://13705391 +void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}} +void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}} +void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}} +void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}} +void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}} diff --git a/test/Sema/extern-redecl.c b/test/Sema/extern-redecl.c index 9a085de..e9a4c57 100644 --- a/test/Sema/extern-redecl.c +++ b/test/Sema/extern-redecl.c @@ -33,3 +33,32 @@ void test3declarer() { extern int test3_array[]; int x = sizeof(test3_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} } + +void test4() { + extern int test4_array[]; + { + extern int test4_array[100]; + int x = sizeof(test4_array); // fine + } + int x = sizeof(test4_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} +} + +// Test that invalid local extern declarations of library +// builtins behave reasonably. +extern void abort(void); // expected-note 2 {{previous declaration is here}} +extern float *calloc(); // expected-warning {{incompatible redeclaration of library function}} expected-note {{is a builtin}} expected-note 2 {{previous declaration is here}} +void test5a() { + int abort(); // expected-error {{conflicting types}} + float *malloc(); // expected-warning {{incompatible redeclaration of library function}} expected-note 2 {{is a builtin}} + int *calloc(); // expected-error {{conflicting types}} +} +void test5b() { + int abort(); // expected-error {{conflicting types}} + float *malloc(); // expected-warning {{incompatible redeclaration of library function}} + int *calloc(); // expected-error {{conflicting types}} +} +void test5c() { + void (*_abort)(void) = &abort; + void *(*_malloc)() = &malloc; + float *(*_calloc)() = &calloc; +} diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c index 3ee8763..561f7fa 100644 --- a/test/Sema/function-redecl.c +++ b/test/Sema/function-redecl.c @@ -62,7 +62,7 @@ void test2() { // <rdar://problem/6127293> int outer1(int); // expected-note{{previous declaration is here}} struct outer3 { }; -int outer4(int); +int outer4(int); // expected-note{{previous declaration is here}} int outer5; // expected-note{{previous definition is here}} int *outer7(int); @@ -70,7 +70,7 @@ void outer_test() { int outer1(float); // expected-error{{conflicting types for 'outer1'}} int outer2(int); // expected-note{{previous declaration is here}} int outer3(int); // expected-note{{previous declaration is here}} - int outer4(int); // expected-note{{previous declaration is here}} + int outer4(int); int outer5(int); // expected-error{{redefinition of 'outer5' as different kind of symbol}} int* outer6(int); // expected-note{{previous declaration is here}} int *outer7(int); diff --git a/test/Sema/function.c b/test/Sema/function.c index 1b0dc2a..bbf81a5 100644 --- a/test/Sema/function.c +++ b/test/Sema/function.c @@ -92,3 +92,14 @@ void t20(int i...) { } // expected-error {{requires a comma}} int n; void t21(int n, int (*array)[n]); + +int func_e(int x) { + int func_n(int y) { // expected-error {{function definition is not allowed here}} + if (y > 22) { + return y+2; + } else { + return y-2; + } + } + return x + 3; +} diff --git a/test/Sema/no-documentation-warn-tagdecl-specifier.c b/test/Sema/no-documentation-warn-tagdecl-specifier.c new file mode 100644 index 0000000..a0702ad --- /dev/null +++ b/test/Sema/no-documentation-warn-tagdecl-specifier.c @@ -0,0 +1,85 @@ +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s +// rdar://12390371 + +/** @return s Test*/ +struct s* f(void); +struct s; + +struct s1; +/** @return s1 Test 1*/ +struct s1* f1(void); + +struct s2; +/** @return s2 Test 2*/ +struct s2* f2(void); +struct s2; + +// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}} +/** @return s3 Test 3 - expected warning here */ +struct s3; +struct s3* f3(void); + +/** @return s4 Test 4 */ +struct s4* f4(void); +struct s4 { int is; }; + +// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}} +/** @return s5 Test 5 - expected warning here */ +struct s5 { int is; }; +struct s5* f5(void); + +// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}} +/** @return s6 Test 6 - expected warning here */ +struct s6 *ps6; +struct s6* f6(void); + +// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}} +/** @return s7 Test 7 - expected warning here */ +struct s7; +struct s7* f7(void); + +struct s8 { int is8; }; +/** @return s8 Test 8 */ +struct s4 *f8(struct s8 *p); + + +/** @return e Test*/ +enum e* g(void); +enum e; + +enum e1; +/** @return e1 Test 1*/ +enum e1* g1(void); + +enum e2; +/** @return e2 Test 2*/ +enum e2* g2(void); +enum e2; + +// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}} +/** @return e3 Test 3 - expected warning here */ +enum e3; +enum e3* g3(void); + +/** @return e4 Test 4 */ +enum e4* g4(void); +enum e4 { one }; + +// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}} +/** @return e5 Test 5 - expected warning here */ +enum e5 { two }; +enum e5* g5(void); + +// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}} +/** @return e6 Test 6 - expected warning here */ +enum e6 *pe6; +enum e6* g6(void); + +// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}} +/** @return e7 Test 7 - expected warning here */ +enum e7; +enum e7* g7(void); + +enum e8 { three }; +/** @return e8 Test 8 */ +enum e4 *g8(enum e8 *p); diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c index c3b3aa7..300e585 100644 --- a/test/Sema/parentheses.c +++ b/test/Sema/parentheses.c @@ -1,25 +1,44 @@ // RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s -// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror - +// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s // Test the various warnings under -Wparentheses void if_assign(void) { int i; if (i = 4) {} // expected-warning {{assignment as a condition}} \ - // expected-note{{use '==' to turn this assignment into an equality comparison}} \ - // expected-note{{place parentheses around the assignment to silence this warning}} + // expected-note{{place parentheses around the assignment to silence this warning}} \ + // expected-note{{use '==' to turn this assignment into an equality comparison}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:7-[[@LINE-3]]:7}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:12-[[@LINE-4]]:12}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:9-[[@LINE-5]]:10}:"==" + if ((i = 4)) {} } void bitwise_rel(unsigned i) { (void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} \ - // expected-note{{place parentheses around the & expression to evaluate it first}} \ - // expected-note{{place parentheses around the '==' expression to silence this warning}} + // expected-note{{place parentheses around the '==' expression to silence this warning}} \ + // expected-note{{place parentheses around the & expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:14-[[@LINE-3]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:22-[[@LINE-4]]:22}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:17-[[@LINE-6]]:17}:")" + (void)(0 == i & 0x2); // expected-warning {{& has lower precedence than ==}} \ - // expected-note{{place parentheses around the & expression to evaluate it first}} \ - // expected-note{{place parentheses around the '==' expression to silence this warning}} + // expected-note{{place parentheses around the '==' expression to silence this warning}} \ + // expected-note{{place parentheses around the & expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:22-[[@LINE-6]]:22}:")" + (void)(i & 0xff < 30); // expected-warning {{& has lower precedence than <}} \ - // expected-note{{place parentheses around the & expression to evaluate it first}} \ - // expected-note{{place parentheses around the '<' expression to silence this warning}} + // expected-note{{place parentheses around the '<' expression to silence this warning}} \ + // expected-note{{place parentheses around the & expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:14-[[@LINE-3]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:23-[[@LINE-4]]:23}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:18-[[@LINE-6]]:18}:")" + (void)((i & 0x2) == 0); (void)(i & (0x2 == 0)); // Eager logical op @@ -28,19 +47,33 @@ void bitwise_rel(unsigned i) { (void)(i & i | i); // expected-warning {{'&' within '|'}} \ // expected-note {{place parentheses around the '&' expression to silence this warning}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")" (void)(i | i & i); // expected-warning {{'&' within '|'}} \ // expected-note {{place parentheses around the '&' expression to silence this warning}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:14-[[@LINE-2]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:19-[[@LINE-3]]:19}:")" (void)(i || i && i); // expected-warning {{'&&' within '||'}} \ - // expected-note {{place parentheses around the '&&' expression to silence this warning}} + // expected-note {{place parentheses around the '&&' expression to silence this warning}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:14-[[@LINE-2]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")" + (void)(i || i && "w00t"); // no warning. (void)("w00t" && i || i); // no warning. + (void)(i || i && "w00t" || i); // expected-warning {{'&&' within '||'}} \ // expected-note {{place parentheses around the '&&' expression to silence this warning}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:26-[[@LINE-3]]:26}:")" + (void)(i || "w00t" && i || i); // expected-warning {{'&&' within '||'}} \ // expected-note {{place parentheses around the '&&' expression to silence this warning}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:26-[[@LINE-3]]:26}:")" + (void)(i && i || 0); // no warning. (void)(0 || i && i); // no warning. } @@ -49,25 +82,41 @@ _Bool someConditionFunc(); void conditional_op(int x, int y, _Bool b) { (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '+' expression to silence this warning}} + // expected-note {{place parentheses around the '+' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:33-[[@LINE-4]]:33}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:41-[[@LINE-6]]:41}:")" (void)((x + someConditionFunc()) ? 1 : 2); // no warning (void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '-' expression to silence this warning}} + // expected-note {{place parentheses around the '-' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:15-[[@LINE-4]]:15}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:23-[[@LINE-6]]:23}:")" (void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '*' expression to silence this warning}} + // expected-note {{place parentheses around the '*' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:22-[[@LINE-4]]:22}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:30-[[@LINE-6]]:30}:")" (void)(x / !x ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '/'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '/' expression to silence this warning}} + // expected-note {{place parentheses around the '/' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:24-[[@LINE-6]]:24}:")" (void)(x % 2 ? 1 : 2); // no warning } -// RUN: %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s -// CHECK: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses] +// RUN: %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG +// CHECK-FLAG: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses] diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp index da37dd3..ac2694f 100644 --- a/test/Sema/parentheses.cpp +++ b/test/Sema/parentheses.cpp @@ -1,20 +1,32 @@ // RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s -// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror - +// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s bool someConditionFunc(); void conditional_op(int x, int y, bool b) { (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '+' expression to silence this warning}} + // expected-note {{place parentheses around the '+' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:33-[[@LINE-4]]:33}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:41-[[@LINE-6]]:41}:")" (void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '-' expression to silence this warning}} + // expected-note {{place parentheses around the '-' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:15-[[@LINE-4]]:15}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:23-[[@LINE-6]]:23}:")" (void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '*' expression to silence this warning}} + // expected-note {{place parentheses around the '*' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:22-[[@LINE-4]]:22}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:30-[[@LINE-6]]:30}:")" } class Stream { @@ -28,8 +40,28 @@ public: void f(Stream& s, bool b) { (void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '<<' expression to silence this warning}} + // expected-note {{place parentheses around the '<<' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:32-[[@LINE-6]]:32}:")" + + (void)(s << 5 == 1); // expected-warning {{overloaded operator << has lower precedence than comparison operator}} \ + // expected-note {{place parentheses around the '<<' expression to silence this warning}} \ + // expected-note {{place parentheses around comparison expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")" + + (void)(s >> 5 == 1); // expected-warning {{overloaded operator >> has lower precedence than comparison operator}} \ + // expected-note {{place parentheses around the '>>' expression to silence this warning}} \ + // expected-note {{place parentheses around comparison expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")" } struct S { @@ -39,8 +71,12 @@ struct S { void test(S *s, bool (S::*m_ptr)()) { (void)(*s + true ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '+'}} \ - // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ - // expected-note {{place parentheses around the '+' expression to silence this warning}} + // expected-note {{place parentheses around the '+' expression to silence this warning}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:19-[[@LINE-4]]:19}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:35-[[@LINE-6]]:35}:")" (void)((*s + true) ? "foo" : "bar"); // No warning. @@ -51,11 +87,19 @@ void test(S *s, bool (S::*m_ptr)()) { void test(int a, int b, int c) { (void)(a >> b + c); // expected-warning {{operator '>>' has lower precedence than '+'; '+' will be evaluated first}} \ expected-note {{place parentheses around the '+' expression to silence this warning}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")" + (void)(a - b << c); // expected-warning {{operator '<<' has lower precedence than '-'; '-' will be evaluated first}} \ expected-note {{place parentheses around the '-' expression to silence this warning}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")" + Stream() << b + c; Stream() >> b + c; // expected-warning {{operator '>>' has lower precedence than '+'; '+' will be evaluated first}} \ expected-note {{place parentheses around the '+' expression to silence this warning}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"(" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")" } namespace PR15628 { diff --git a/test/Sema/pragma-arc-cf-code-audited.c b/test/Sema/pragma-arc-cf-code-audited.c index b646e89..c1aa804 100644 --- a/test/Sema/pragma-arc-cf-code-audited.c +++ b/test/Sema/pragma-arc-cf-code-audited.c @@ -13,6 +13,6 @@ #include "Inputs/pragma-arc-cf-code-audited.h" // expected-error {{cannot #include files inside '#pragma clang arc_cf_code_audited'}} // This is actually on the #pragma line in the header. -// expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}} +// expected-error@Inputs/pragma-arc-cf-code-audited.h:16 {{'#pragma clang arc_cf_code_audited' was not ended within this file}} #pragma clang arc_cf_code_audited begin // expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}} diff --git a/test/Sema/return.c b/test/Sema/return.c index e231e81..7e7c8b7 100644 --- a/test/Sema/return.c +++ b/test/Sema/return.c @@ -197,8 +197,14 @@ int test29() { exit(1); } -#include <setjmp.h> +// Include these declarations here explicitly so we don't depend on system headers. +typedef struct __jmp_buf_tag{} jmp_buf[1]; + +extern void longjmp (struct __jmp_buf_tag __env[1], int __val) __attribute__ ((noreturn)); +extern void _longjmp (struct __jmp_buf_tag __env[1], int __val) __attribute__ ((noreturn)); + jmp_buf test30_j; + int test30() { if (j) longjmp(test30_j, 1); diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c index 8c40fcd..9d516e8 100644 --- a/test/Sema/thread-specifier.c +++ b/test/Sema/thread-specifier.c @@ -1,30 +1,110 @@ -// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DGNU +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DGNU +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DC11 -D__thread=_Thread_local +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DCXX11 -D__thread=thread_local -std=c++11 +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++11 + +#ifdef __cplusplus +// In C++, we define __private_extern__ to extern. +#undef __private_extern__ +#endif __thread int t1; -__thread extern int t2; // expected-warning {{'__thread' before 'extern'}} -__thread static int t3; // expected-warning {{'__thread' before 'static'}} +__thread extern int t2; +__thread static int t3; +#ifdef GNU +// expected-warning@-3 {{'__thread' before 'extern'}} +// expected-warning@-3 {{'__thread' before 'static'}} +#endif + __thread __private_extern__ int t4; -struct t5 { __thread int x; }; // expected-error {{type name does not allow storage class to be specified}} -__thread int t6(); // expected-error {{'__thread' is only allowed on variable declarations}} +struct t5 { __thread int x; }; +#ifdef __cplusplus +// expected-error-re@-2 {{'(__thread|_Thread_local|thread_local)' is only allowed on variable declarations}} +#else +// FIXME: The 'is only allowed on variable declarations' diagnostic is better here. +// expected-error@-5 {{type name does not allow storage class to be specified}} +#endif -int f(__thread int t7) { // expected-error {{'__thread' is only allowed on variable declarations}} - __thread int t8; // expected-error {{'__thread' variables must have global storage}} +__thread int t6(); +#if defined(GNU) +// expected-error@-2 {{'__thread' is only allowed on variable declarations}} +#elif defined(C11) +// expected-error@-4 {{'_Thread_local' is only allowed on variable declarations}} +#else +// expected-error@-6 {{'thread_local' is only allowed on variable declarations}} +#endif + +int f(__thread int t7) { // expected-error {{' is only allowed on variable declarations}} + __thread int t8; +#if defined(GNU) + // expected-error@-2 {{'__thread' variables must have global storage}} +#elif defined(C11) + // expected-error@-4 {{'_Thread_local' variables must have global storage}} +#endif extern __thread int t9; static __thread int t10; __thread __private_extern__ int t11; - __thread auto int t12; // expected-error {{'__thread' variables must have global storage}} - __thread register int t13; // expected-error {{'__thread' variables must have global storage}} +#if __cplusplus < 201103L + __thread auto int t12a; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local)' declaration specifier}} + auto __thread int t12b; // expected-error {{cannot combine with previous 'auto' declaration specifier}} +#elif !defined(CXX11) + __thread auto t12a = 0; // expected-error-re {{'_Thread_local' variables must have global storage}} + auto __thread t12b = 0; // expected-error-re {{'_Thread_local' variables must have global storage}} +#endif + __thread register int t13a; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}} + register __thread int t13b; // expected-error {{cannot combine with previous 'register' declaration specifier}} } -__thread typedef int t14; // expected-error {{'__thread' is only allowed on variable declarations}} -__thread int t15; // expected-note {{previous definition is here}} -int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}} -int t16; // expected-note {{previous definition is here}} +__thread typedef int t14; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}} +__thread int t15; // expected-note {{previous declaration is here}} +extern int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}} +extern int t16; // expected-note {{previous declaration is here}} __thread int t16; // expected-error {{thread-local declaration of 't16' follows non-thread-local declaration}} +#ifdef CXX11 +extern thread_local int t17; // expected-note {{previous declaration is here}} +_Thread_local int t17; // expected-error {{thread-local declaration of 't17' with static initialization follows declaration with dynamic initialization}} +extern _Thread_local int t18; // expected-note {{previous declaration is here}} +thread_local int t18; // expected-error {{thread-local declaration of 't18' with dynamic initialization follows declaration with static initialization}} +#endif + // PR13720 __thread int thread_int; -int *thread_int_ptr = &thread_int; // expected-error{{initializer element is not a compile-time constant}} +int *thread_int_ptr = &thread_int; +#ifndef __cplusplus +// expected-error@-2 {{initializer element is not a compile-time constant}} +#endif void g() { int *p = &thread_int; // This is perfectly fine, though. } +#if __cplusplus >= 201103L +constexpr int *thread_int_ptr_2 = &thread_int; // expected-error {{must be initialized by a constant expression}} +#endif + +int non_const(); +__thread int non_const_init = non_const(); +#if !defined(__cplusplus) +// expected-error@-2 {{initializer element is not a compile-time constant}} +#elif !defined(CXX11) +// expected-error@-4 {{initializer for thread-local variable must be a constant expression}} +#if __cplusplus >= 201103L +// expected-note@-6 {{use 'thread_local' to allow this}} +#endif +#endif + +#ifdef __cplusplus +struct S { + ~S(); +}; +__thread S s; +#if !defined(CXX11) +// expected-error@-2 {{type of thread-local variable has non-trivial destruction}} +#if __cplusplus >= 201103L +// expected-note@-4 {{use 'thread_local' to allow this}} +#endif +#endif +#endif + +__thread int aggregate[10] = {0}; diff --git a/test/Sema/var-redecl.c b/test/Sema/var-redecl.c index f7576b6..363458b 100644 --- a/test/Sema/var-redecl.c +++ b/test/Sema/var-redecl.c @@ -4,7 +4,7 @@ int outer1; // expected-note{{previous definition is here}} extern int outer2; // expected-note{{previous definition is here}} int outer4; int outer4; // expected-note{{previous definition is here}} -int outer5; +int outer5; // expected-note{{previous definition is here}} int outer6(float); // expected-note{{previous definition is here}} int outer7(float); @@ -13,7 +13,7 @@ void outer_test() { extern float outer2; // expected-error{{redefinition of 'outer2' with a different type}} extern float outer3; // expected-note{{previous definition is here}} double outer4; - extern int outer5; // expected-note{{previous definition is here}} + extern int outer5; extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}} int outer7; extern int outer8; // expected-note{{previous definition is here}} diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index 0132ef2..b3ab019 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -892,10 +892,10 @@ typedef const struct test_nocrash7 * test_nocrash8; // We used to crash on this. +// expected-warning@+1 {{unknown command tag name}} /// aaa \unknown aaa \unknown aaa int test_nocrash9; - // We used to crash on this. PR15068 // expected-warning@+2 {{empty paragraph passed to '@param' command}} diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m index 1e3acf1..0737a8d 100644 --- a/test/Sema/warn-documentation.m +++ b/test/Sema/warn-documentation.m @@ -149,6 +149,7 @@ struct S; @class NSArray; @interface NSArray @end +// expected-warning@+3 {{unknown command tag name}} /*! @interface NSMutableArray @super NSArray diff --git a/test/Sema/warn-duplicate-enum.c b/test/Sema/warn-duplicate-enum.c index 239f6f1..f108b3a 100644 --- a/test/Sema/warn-duplicate-enum.c +++ b/test/Sema/warn-duplicate-enum.c @@ -90,3 +90,12 @@ enum { NMax = N2, NCount = NMax + 1 }; + +// PR15693 +enum enum1 { + VALUE // expected-note{{previous definition is here}} +}; + +enum enum2 { + VALUE // expected-error{{redefinition of enumerator 'VALUE'}} +}; |