summaryrefslogtreecommitdiffstats
path: root/lib/Sema/JumpDiagnostics.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erikjv@me.com>2012-12-25 14:51:39 +0000
committerErik Verbruggen <erikjv@me.com>2012-12-25 14:51:39 +0000
commit65d78312ce026092cb6e7b1d4d06f05e18d02aa0 (patch)
tree165233da9770e9d2bf6b5d46af36b1303d7db11d /lib/Sema/JumpDiagnostics.cpp
parent38980086c0f791e8c23cc882574f18e5b4a87db6 (diff)
Fix for PR12222.
Changed getLocStart() and getLocEnd() to be required for Stmts, and make getSourceRange() optional. The default implementation for getSourceRange() is build the range by calling getLocStart() and getLocEnd(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171067 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/JumpDiagnostics.cpp')
-rw-r--r--lib/Sema/JumpDiagnostics.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Sema/JumpDiagnostics.cpp b/lib/Sema/JumpDiagnostics.cpp
index b02800f732..01a4afb980 100644
--- a/lib/Sema/JumpDiagnostics.cpp
+++ b/lib/Sema/JumpDiagnostics.cpp
@@ -511,8 +511,14 @@ void JumpScopeChecker::VerifyJumps() {
for (SwitchCase *SC = SS->getSwitchCaseList(); SC;
SC = SC->getNextSwitchCase()) {
assert(LabelAndGotoScopes.count(SC) && "Case not visited?");
- CheckJump(SS, SC, SC->getLocStart(),
- diag::err_switch_into_protected_scope, 0,
+ SourceLocation Loc;
+ if (CaseStmt *CS = dyn_cast<CaseStmt>(SC))
+ Loc = CS->getLocStart();
+ else if (DefaultStmt *DS = dyn_cast<DefaultStmt>(SC))
+ Loc = DS->getLocStart();
+ else
+ Loc = SC->getLocStart();
+ CheckJump(SS, SC, Loc, diag::err_switch_into_protected_scope, 0,
diag::warn_cxx98_compat_switch_into_protected_scope);
}
}