Don't do jump-scope checking when code completion is enabled. It's

both a waste of time, and prone to crash due to the use of the
error-recovery path in parser. Fixes <rdar://problem/12103608>, which
has been driving me nuts.

llvm-svn: 162081
This commit is contained in:
Douglas Gregor 2012-08-17 05:12:08 +00:00
parent 8d9ccdc7a5
commit 5d944dbf1a
3 changed files with 6 additions and 4 deletions

View File

@ -7792,7 +7792,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
// Verify that gotos and switch cases don't jump into scopes illegally.
if (getCurFunction()->NeedsScopeChecking() &&
!dcl->isInvalidDecl() &&
!hasAnyUnrecoverableErrorsInThisFunction())
!hasAnyUnrecoverableErrorsInThisFunction() &&
!PP.isCodeCompletionEnabled())
DiagnoseInvalidJumps(Body);
if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(dcl)) {

View File

@ -9461,7 +9461,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
// If needed, diagnose invalid gotos and switches in the block.
if (getCurFunction()->NeedsScopeChecking() &&
!hasAnyUnrecoverableErrorsInThisFunction())
!hasAnyUnrecoverableErrorsInThisFunction() &&
!PP.isCodeCompletionEnabled())
DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
BSI->TheDecl->setBody(cast<CompoundStmt>(Body));

View File

@ -1,6 +1,6 @@
// Note: the run lines follow their respective tests, since line/column
// matter in this test.
struct X { X(); ~X(); };
enum class Color {
Red = 17,
Green,
@ -9,7 +9,7 @@ enum class Color {
int Greeby();
void f(Color color) {
switch (color) {
case Color::Green:
case Color::Green: { X x; }
case Color::Red;
}
}