summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-06-29 23:25:20 +0000
committerDouglas Gregor <dgregor@apple.com>2010-06-29 23:25:20 +0000
commit5823da3ab0fc48547ac0289d5ba9cbf9f7524d36 (patch)
tree1aa1373080249d74d05e8b7080e41341c4796a04 /clang/lib/Sema
parentf4ea725d38cc52d34512a11bc0d40a3e9bfffaec (diff)
downloadbcm5719-llvm-5823da3ab0fc48547ac0289d5ba9cbf9f7524d36.tar.gz
bcm5719-llvm-5823da3ab0fc48547ac0289d5ba9cbf9f7524d36.zip
Re-improve recovery when the condition of a switch statement does not
have integral or enumeration type, so that we still check the contents of the switch body. My previous patch made this worse; now we're back to where we were previously. llvm-svn: 107223
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp8
-rw-r--r--clang/lib/Sema/SemaStmt.cpp8
2 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index af28d46b5fe..86724f9a92f 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -3106,7 +3106,7 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
if (!RecordTy || !getLangOptions().CPlusPlus) {
Diag(Loc, NotIntDiag)
<< T << From->getSourceRange();
- return ExprError();
+ return move(FromE);
}
// We must have a complete class type.
@@ -3190,14 +3190,12 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
Diag(Conv->getLocation(), AmbigNote)
<< ConvTy->isEnumeralType() << ConvTy;
}
- return ExprError();
+ return move(FromE);
}
- if (!From->getType()->isIntegralOrEnumerationType()) {
+ if (!From->getType()->isIntegralOrEnumerationType())
Diag(Loc, NotIntDiag)
<< From->getType() << From->getSourceRange();
- return ExprError();
- }
return move(FromE);
}
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index fed30e4e560..efd74e3c255 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -486,11 +486,11 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
// be represented by the promoted type. Therefore we need to find
// the pre-promotion type of the switch condition.
if (!CondExpr->isTypeDependent()) {
- if (!CondType->isIntegerType()) { // C99 6.8.4.2p1
- Diag(SwitchLoc, diag::err_typecheck_statement_requires_integer)
- << CondType << CondExpr->getSourceRange();
+ // We have already converted the expression to an integral or enumeration
+ // type, when we started the switch statement. If we don't have an
+ // appropriate type now, just return an error.
+ if (!CondType->isIntegralOrEnumerationType())
return StmtError();
- }
if (CondExpr->isKnownToHaveBooleanValue()) {
// switch(bool_expr) {...} is often a programmer error, e.g.
OpenPOWER on IntegriCloud