diff options
author | Erik Verbruggen <erikjv@me.com> | 2012-12-25 14:51:39 +0000 |
---|---|---|
committer | Erik Verbruggen <erikjv@me.com> | 2012-12-25 14:51:39 +0000 |
commit | 65d78312ce026092cb6e7b1d4d06f05e18d02aa0 (patch) | |
tree | 165233da9770e9d2bf6b5d46af36b1303d7db11d /lib/Sema | |
parent | 38980086c0f791e8c23cc882574f18e5b4a87db6 (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')
-rw-r--r-- | lib/Sema/JumpDiagnostics.cpp | 10 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 10 |
2 files changed, 13 insertions, 7 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); } } diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index a40bf9fd8e..2dbefdbc3b 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -1632,8 +1632,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, StructuredList = IsFirstDesignator? SyntacticToSemantic.lookup(IList) : getStructuredSubobjectInit(IList, Index, CurrentObjectType, StructuredList, StructuredIndex, - SourceRange(D->getStartLocation(), - DIE->getSourceRange().getEnd())); + SourceRange(D->getLocStart(), + DIE->getLocEnd())); assert(StructuredList && "Expected a structured initializer list"); } @@ -1801,10 +1801,10 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, if (!VerifyOnly) { DesignatedInitExpr::Designator *NextD = DIE->getDesignator(DesigIdx + 1); - SemaRef.Diag(NextD->getStartLocation(), + SemaRef.Diag(NextD->getLocStart(), diag::err_designator_into_flexible_array_member) - << SourceRange(NextD->getStartLocation(), - DIE->getSourceRange().getEnd()); + << SourceRange(NextD->getLocStart(), + DIE->getLocEnd()); SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member) << *Field; } |