diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2012-02-09 20:13:14 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2012-02-09 20:13:14 +0000 |
| commit | 25b0742603808470660680f1d87c066ea1e5b59c (patch) | |
| tree | fbc4ee8e0df5155ad78da9a64cbd8fb8c4c1461a /clang | |
| parent | 1fba8711b0fc78ff6ee56cd640da2f2e770e4eb1 (diff) | |
| download | bcm5719-llvm-25b0742603808470660680f1d87c066ea1e5b59c.tar.gz bcm5719-llvm-25b0742603808470660680f1d87c066ea1e5b59c.zip | |
Make sure a variable with a C++ direct initializer triggers jump scope checking. Fixes PR10620 / <rdar://problem/9958362> .
llvm-svn: 150204
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/goto.cpp | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 8ba84fe86a5..ec92470ae1f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -16,6 +16,7 @@ #include "clang/Sema/Scope.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" +#include "clang/Sema/ScopeInfo.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTMutationListener.h" @@ -9223,6 +9224,9 @@ void Sema::AddCXXDirectInitializerToDecl(Decl *RealDecl, return; } + if (VDecl->hasLocalStorage()) + getCurFunction()->setHasBranchProtectedScope(); + bool IsDependent = false; for (unsigned I = 0, N = Exprs.size(); I != N; ++I) { if (DiagnoseUnexpandedParameterPack(Exprs.get()[I], UPPC_Expression)) { diff --git a/clang/test/SemaCXX/goto.cpp b/clang/test/SemaCXX/goto.cpp index d8d5ec51f6e..e55e8807239 100644 --- a/clang/test/SemaCXX/goto.cpp +++ b/clang/test/SemaCXX/goto.cpp @@ -103,3 +103,15 @@ void f() { exit: return; } + +namespace PR10620 { + struct S { + ~S() {} + }; + void g(const S& s) { + goto done; // expected-error {{goto into protected scope}} + const S s2(s); // expected-note {{jump bypasses variable initialization}} + done: + ; + } +} |

