diff options
| author | Alp Toker <alp@nuanti.com> | 2014-05-09 08:40:10 +0000 |
|---|---|---|
| committer | Alp Toker <alp@nuanti.com> | 2014-05-09 08:40:10 +0000 |
| commit | e265cf1a33f5b06fdc234bb801f20434c30c17d0 (patch) | |
| tree | 4cb0ac2013474a6c806ff9b89f2c20a6be2d0806 /clang/test | |
| parent | 370d5f808a0c83aa9700373f54d07b6898bd5ddd (diff) | |
| download | bcm5719-llvm-e265cf1a33f5b06fdc234bb801f20434c30c17d0.tar.gz bcm5719-llvm-e265cf1a33f5b06fdc234bb801f20434c30c17d0.zip | |
Add support for partial jump scope checking
This lets us diagnose and perform more complete semantic analysis when faced
with errors in the function body or declaration.
By recovering here we provide more consistent diagnostics, particularly during
interactive editing.
llvm-svn: 208394
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaCXX/scope-check.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/clang/test/SemaCXX/scope-check.cpp b/clang/test/SemaCXX/scope-check.cpp index c5fdb09f237..dc15dc8b3e6 100644 --- a/clang/test/SemaCXX/scope-check.cpp +++ b/clang/test/SemaCXX/scope-check.cpp @@ -1,6 +1,18 @@ // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fcxx-exceptions %s -Wno-unreachable-code // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fcxx-exceptions -std=gnu++11 %s -Wno-unreachable-code +namespace testInvalid { +Invalid inv; // expected-error {{unknown type name}} +// Make sure this doesn't assert. +void fn() +{ + int c = 0; + if (inv) +Here: ; + goto Here; +} +} + namespace test0 { struct D { ~D(); }; @@ -409,15 +421,23 @@ namespace PR18217 { } } -// This test must be last, because the error prohibits further jump diagnostics. -namespace testInvalid { -Invalid inv; // expected-error {{unknown type name}} -// Make sure this doesn't assert. -void fn() -{ - int c = 0; - if (inv) -Here: ; - goto Here; -} +namespace test_recovery { + // Test that jump scope checking recovers when there are unspecified errors + // in the function declaration or body. + + void test(nexist, int c) { // expected-error {{}} + nexist_fn(); // expected-error {{}} + goto nexist_label; // expected-error {{use of undeclared label}} + goto a0; // expected-error {{goto into protected scope}} + int a = 0; // expected-note {{jump bypasses variable initialization}} + a0:; + + switch (c) { + case $: // expected-error {{}} + case 0: + int x = 56; // expected-note {{jump bypasses variable initialization}} + case 1: // expected-error {{switch case is in protected scope}} + x = 10; + } + } } |

