diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-03-16 16:39:03 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-03-16 16:39:03 +0000 |
| commit | 46c04e74fba75b9b670834e61dec85db87068fb9 (patch) | |
| tree | 6e0aa079b1f212f9e3ae0528c1b2cb6f9680a77f /clang/test/SemaCXX/goto.cpp | |
| parent | 803adc1bcf05e08877e64cb13d16ed00203a436d (diff) | |
| download | bcm5719-llvm-46c04e74fba75b9b670834e61dec85db87068fb9.tar.gz bcm5719-llvm-46c04e74fba75b9b670834e61dec85db87068fb9.zip | |
When we're inserting a synthesized label declaration for a
forward-looking "goto" statement, make sure to insert it *after* the
last declaration in the identifier resolver's declaration chain that
is either outside of the function/block/method's scope or that is
declared in that function/block/method's specific scope. Previously,
we could end up inserting the label ahead of declarations in inner
scopes, confusing C++ name lookup.
Fixes PR9491/<rdar://problem/9140426> and <rdar://problem/9135994>.
Note that the crash-on-invalid PR9495 is *not* fixed. That's a
separate issue.
llvm-svn: 127737
Diffstat (limited to 'clang/test/SemaCXX/goto.cpp')
| -rw-r--r-- | clang/test/SemaCXX/goto.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/goto.cpp b/clang/test/SemaCXX/goto.cpp index 2db9d97fd8b..e8b7822c323 100644 --- a/clang/test/SemaCXX/goto.cpp +++ b/clang/test/SemaCXX/goto.cpp @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s - // PR9463 double *end; void f() { @@ -16,3 +15,32 @@ void f() { void g() { end = 1; // expected-error{{assigning to 'double *' from incompatible type 'int'}} } + +void h(int end) { + { + goto end; // expected-error{{use of undeclared label 'end'}} + } +} + +void h2(int end) { + { + __label__ end; + goto end; + + end: + ::end = 0; + } + end: + end = 1; +} + +class X { +public: + X(); +}; + +void rdar9135994() +{ +X: + goto X; +} |

