diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-01-23 11:10:26 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-01-23 11:10:26 +0000 |
commit | 2fce988e86bc01829142e4362d4eff1af0925147 (patch) | |
tree | c69d3f4f13d508570bb5257a6aea735f88bdf09c /test/Sema | |
parent | a3fa5c7f1b5e2ba4d6ec033dc0e2376326b05824 (diff) | |
download | FreeBSD-src-2fce988e86bc01829142e4362d4eff1af0925147.zip FreeBSD-src-2fce988e86bc01829142e4362d4eff1af0925147.tar.gz |
Update clang to r94309.
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/block-literal.c | 3 | ||||
-rw-r--r-- | test/Sema/block-misc.c | 3 | ||||
-rw-r--r-- | test/Sema/compound-literal.c | 3 | ||||
-rw-r--r-- | test/Sema/scope-check.c | 11 | ||||
-rw-r--r-- | test/Sema/warn-unreachable.c | 82 |
5 files changed, 92 insertions, 10 deletions
diff --git a/test/Sema/block-literal.c b/test/Sema/block-literal.c index e9c2341..c303b84 100644 --- a/test/Sema/block-literal.c +++ b/test/Sema/block-literal.c @@ -33,7 +33,8 @@ void test2() { break; // expected-error {{'break' statement not in loop or switch statement}} continue; // expected-error {{'continue' statement not in loop statement}} while(1) break; // ok - goto foo; // expected-error {{goto not allowed}} + goto foo; // expected-error {{use of undeclared label 'foo'}} + a: goto a; // ok }); break; } diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c index 52cebfe..1109be6 100644 --- a/test/Sema/block-misc.c +++ b/test/Sema/block-misc.c @@ -87,8 +87,7 @@ int test7(void (^p)()) { void test8() { somelabel: - // FIXME: This should say "jump out of block not legal" when gotos are allowed. - ^{ goto somelabel; }(); // expected-error {{goto not allowed in block literal}} + ^{ goto somelabel; }(); // expected-error {{use of undeclared label 'somelabel'}} } void test9() { diff --git a/test/Sema/compound-literal.c b/test/Sema/compound-literal.c index a650d12..0c8ddd4 100644 --- a/test/Sema/compound-literal.c +++ b/test/Sema/compound-literal.c @@ -31,3 +31,6 @@ void IncompleteFunc(unsigned x) { (void){1,2,3}; // -expected-error {{variable has incomplete type}} (void(void)) { 0 }; // -expected-error{{illegal initializer type 'void (void)'}} } + +// PR6080 +int array[(sizeof(int[3]) == sizeof( (int[]) {0,1,2} )) ? 1 : -1]; diff --git a/test/Sema/scope-check.c b/test/Sema/scope-check.c index 4d3f6cb..74bc7c4 100644 --- a/test/Sema/scope-check.c +++ b/test/Sema/scope-check.c @@ -181,15 +181,14 @@ void test11(int n) { // TODO: When and if gotos are allowed in blocks, this should work. void test12(int n) { void *P = ^{ - goto L1; // expected-error {{goto not allowed in block literal}} + goto L1; L1: - goto L2; // expected-error {{goto not allowed in block literal}} + goto L2; L2: - goto L3; // expected-error {{goto not allowed in block literal}} - // todo-error {{illegal goto into protected scope}} - int Arr[n]; // todo-note {{jump bypasses initialization of variable length array}} + goto L3; // expected-error {{illegal goto into protected scope}} + int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}} L3: - goto L4; // expected-error {{goto not allowed in block literal}} + goto L4; L4: return; }; } diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c index 2c123d0..1eef637 100644 --- a/test/Sema/warn-unreachable.c +++ b/test/Sema/warn-unreachable.c @@ -1,4 +1,8 @@ -// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code +// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value + +int halt() __attribute__((noreturn)); +int live(); +int dead(); void test1() { goto c; @@ -18,3 +22,79 @@ void test1() { goto d; f: ; } + +void test2() { + int i; + switch (live()) { + case 1: + halt(), + dead(); // expected-warning {{will never be executed}} + + case 2: + live(), halt(), + dead(); // expected-warning {{will never be executed}} + + case 3: + live() + + // expected-warning {{will never be executed}} + halt(); + dead(); + + case 4: + a4: + live(), + halt(); + goto a4; // expected-warning {{will never be executed}} + + case 5: + goto a5; + c5: + dead(); // expected-warning {{will never be executed}} + goto b5; + a5: + live(), + halt(); + b5: + goto c5; + + case 6: + if (live()) + goto e6; + live(), + halt(); + d6: + dead(); // expected-warning {{will never be executed}} + goto b6; + c6: + dead(); + goto b6; + e6: + live(), + halt(); + b6: + goto c6; + case 7: + halt() + + // expected-warning {{will never be executed}} + dead(); + - // expected-warning {{will never be executed}} + halt(); + case 8: + i + += // expected-warning {{will never be executed}} + halt(); + case 9: + halt() + ? // expected-warning {{will never be executed}} + dead() : dead(); + case 10: + ( // expected-warning {{will never be executed}} + float)halt(); + case 11: { + int a[5]; + live(), + a[halt() + ]; // expected-warning {{will never be executed}} + } + } +} |