aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-23 13:53:21 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-23 13:53:21 +0000
commitf21bac640870db0569e697a8a14f59f6ca069f80 (patch)
tree283d56514958cc2715da7769bf3af069b922c472 /lib/Sema/SemaStmt.cpp
parent84fb9c0be621c9e4ca4e56f67dae2a0bb6e44821 (diff)
Require a class type to be complete before probing its conversion
functions for a switch condition's conversion to integral or enumeration type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index b674a1738c..ad3376b9c8 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -391,6 +391,13 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
// conversion is used in place of the original condition for the remainder
// of this section. Integral promotions are performed.
if (!CondExpr->isTypeDependent()) {
+ // Make sure that the condition expression has a complete type,
+ // otherwise we'll never find any conversions.
+ if (RequireCompleteType(SwitchLoc, CondType,
+ PDiag(diag::err_switch_incomplete_class_type)
+ << CondExpr->getSourceRange()))
+ return StmtError();
+
llvm::SmallVector<CXXConversionDecl *, 4> ViableConversions;
llvm::SmallVector<CXXConversionDecl *, 4> ExplicitConversions;
if (const RecordType *RecordTy = CondType->getAs<RecordType>()) {