diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-06-23 19:16:49 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-06-23 19:16:49 +0000 |
commit | b130fe7d316efb01870e99912d58ea7c5a11a329 (patch) | |
tree | 4c4b0d9f45a07ef00c65f01b8a375ab693c7be77 /clang/lib/Sema/JumpDiagnostics.cpp | |
parent | fe1397b97716de33571563c6e7b3bdf2d7a28148 (diff) | |
download | bcm5719-llvm-b130fe7d316efb01870e99912d58ea7c5a11a329.tar.gz bcm5719-llvm-b130fe7d316efb01870e99912d58ea7c5a11a329.zip |
Implement p0292r2 (constexpr if), a likely C++1z feature.
llvm-svn: 273602
Diffstat (limited to 'clang/lib/Sema/JumpDiagnostics.cpp')
-rw-r--r-- | clang/lib/Sema/JumpDiagnostics.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp index 500e761bf16..bd541397e1a 100644 --- a/clang/lib/Sema/JumpDiagnostics.cpp +++ b/clang/lib/Sema/JumpDiagnostics.cpp @@ -319,6 +319,37 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, Jumps.push_back(S); break; + case Stmt::IfStmtClass: { + IfStmt *IS = cast<IfStmt>(S); + if (!IS->isConstexpr()) + break; + + if (VarDecl *Var = IS->getConditionVariable()) + BuildScopeInformation(Var, ParentScope); + + // Cannot jump into the middle of the condition. + unsigned NewParentScope = Scopes.size(); + Scopes.push_back(GotoScope(ParentScope, + diag::note_protected_by_constexpr_if, 0, + IS->getLocStart())); + BuildScopeInformation(IS->getCond(), NewParentScope); + + // Jumps into either arm of an 'if constexpr' are not allowed. + NewParentScope = Scopes.size(); + Scopes.push_back(GotoScope(ParentScope, + diag::note_protected_by_constexpr_if, 0, + IS->getLocStart())); + BuildScopeInformation(IS->getThen(), NewParentScope); + if (Stmt *Else = IS->getElse()) { + NewParentScope = Scopes.size(); + Scopes.push_back(GotoScope(ParentScope, + diag::note_protected_by_constexpr_if, 0, + IS->getLocStart())); + BuildScopeInformation(Else, NewParentScope); + } + return; + } + case Stmt::CXXTryStmtClass: { CXXTryStmt *TS = cast<CXXTryStmt>(S); { |