Make sure a variable with a C++ direct initializer triggers jump scope checking. Fixes PR10620 / <rdar://problem/9958362> .

llvm-svn: 150204
This commit is contained in:
Eli Friedman 2012-02-09 20:13:14 +00:00
parent 1fba8711b0
commit 25b0742603
2 changed files with 16 additions and 0 deletions

View File

@ -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)) {

View File

@ -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:
;
}
}