diff options
author | John McCall <rjmccall@apple.com> | 2010-08-02 23:33:14 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-08-02 23:33:14 +0000 |
commit | 4a33fa95c014174b03bd56b357d05861e6379a37 (patch) | |
tree | ca2da287b12c419b0df6001ca119f5d49dc63f6f /clang/test/SemaCXX/scope-check.cpp | |
parent | 460a356bf6c795618f6c7f82abdb9ec54bff6817 (diff) | |
download | bcm5719-llvm-4a33fa95c014174b03bd56b357d05861e6379a37.tar.gz bcm5719-llvm-4a33fa95c014174b03bd56b357d05861e6379a37.zip |
Labels (and case statement) don't create independent scope parents for the
purposes of the jump checker. Also extend Ted's iteration fix to labels.
Fixes PR7789.
llvm-svn: 110082
Diffstat (limited to 'clang/test/SemaCXX/scope-check.cpp')
-rw-r--r-- | clang/test/SemaCXX/scope-check.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/scope-check.cpp b/clang/test/SemaCXX/scope-check.cpp index dd70d9744ac..cdc3868a7be 100644 --- a/clang/test/SemaCXX/scope-check.cpp +++ b/clang/test/SemaCXX/scope-check.cpp @@ -133,3 +133,21 @@ namespace test7 { return; } } + +// PR7789 +namespace test8 { + void test1(int c) { + switch (c) { + case 0: + int x = 56; // expected-note {{jump bypasses variable initialization}} + case 1: // expected-error {{switch case is in protected scope}} + x = 10; + } + } + + void test2() { + goto l2; // expected-error {{goto into protected scope}} + l1: int x = 5; // expected-note {{jump bypasses variable initialization}} + l2: x++; + } +} |