diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-03 00:17:11 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-03 00:17:11 +0000 |
commit | f3fabd2cb5bdeb6396e0bad7023750eca2f67674 (patch) | |
tree | 67cf613bd85bda224b51a5e3802b690821ed377e /clang/lib/Sema/JumpDiagnostics.cpp | |
parent | 0bbe1b210e79e7b63d7b5c7c6cdf24e13b5493a1 (diff) | |
download | bcm5719-llvm-f3fabd2cb5bdeb6396e0bad7023750eca2f67674.tar.gz bcm5719-llvm-f3fabd2cb5bdeb6396e0bad7023750eca2f67674.zip |
Fix handling of pointers-to-members and comma expressions when
lifetime-extending temporaries in reference bindings.
llvm-svn: 183089
Diffstat (limited to 'clang/lib/Sema/JumpDiagnostics.cpp')
-rw-r--r-- | clang/lib/Sema/JumpDiagnostics.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp index 5f92cfffc6b..8e446f8b9bf 100644 --- a/clang/lib/Sema/JumpDiagnostics.cpp +++ b/clang/lib/Sema/JumpDiagnostics.cpp @@ -172,14 +172,19 @@ static ScopePair GetDiagForGotoScopeDecl(ASTContext &Context, const Decl *D) { if (EWC) Init = EWC->getSubExpr(); + // FIXME: Why are we looking through reference initialization? + // This causes us to incorrectly accept invalid code such as: + // struct S { int n; }; + // int f() { goto x; S &&s = S(); x: return x.n; } const MaterializeTemporaryExpr *M = NULL; Init = Init->findMaterializedTemporary(M); + SmallVector<const Expr *, 2> CommaLHSs; SmallVector<SubobjectAdjustment, 2> Adjustments; - Init = Init->skipRValueSubobjectAdjustments(Adjustments); + Init = Init->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); QualType QT = Init->getType(); - if (QT.isNull()) + if (QT.isNull() || !CommaLHSs.empty()) return ScopePair(diag::note_protected_by_variable_init, 0); const Type *T = QT.getTypePtr(); |