aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-10-27 22:11:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-10-27 22:11:44 +0000
commit4f87062cb411d5a31cf39f1ac576bba4123930f2 (patch)
tree8f9051b28660777de6b6498b30c659a86356651f /lib/Sema/SemaStmt.cpp
parent2ce634dbb24c8325da0dd36479c3a68622660d72 (diff)
Fix some cases where a CK_IntegralCast was being used to convert an lvalue to an
rvalue. An assertion to catch this is in ImpCastExprToType will follow, but vector operations currently trip over this (due to omitting the usual arithmetic conversions). Also add an assert to catch missing lvalue-to-rvalue conversions on the LHS of ->. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index f35b359f57..6dcfbbab84 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -639,6 +639,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
// If the LHS is not the same type as the condition, insert an implicit
// cast.
+ // FIXME: In C++11, the value is a converted constant expression of the
+ // promoted type of the switch condition.
+ Lo = DefaultLvalueConversion(Lo).take();
Lo = ImpCastExprToType(Lo, CondType, CK_IntegralCast).take();
CS->setLHS(Lo);
@@ -716,8 +719,11 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
Hi->getLocStart(),
diag::warn_case_value_overflow);
- // If the LHS is not the same type as the condition, insert an implicit
+ // If the RHS is not the same type as the condition, insert an implicit
// cast.
+ // FIXME: In C++11, the value is a converted constant expression of the
+ // promoted type of the switch condition.
+ Hi = DefaultLvalueConversion(Hi).take();
Hi = ImpCastExprToType(Hi, CondType, CK_IntegralCast).take();
CR->setRHS(Hi);