[cfe-commits] r89864 - /cfe/trunk/lib/Sema/SemaStmt.cpp
Douglas Gregor
dgregor at apple.com
Wed Nov 25 07:17:37 PST 2009
Author: dgregor
Date: Wed Nov 25 09:17:36 2009
New Revision: 89864
URL: http://llvm.org/viewvc/llvm-project?rev=89864&view=rev
Log:
Fix a thinko where we weren't always performing unary conversions on the switch condition, fixing PR5612
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=89864&r1=89863&r2=89864&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Nov 25 09:17:36 2009
@@ -501,10 +501,12 @@
QualType CondTypeBeforePromotion =
GetTypeBeforeIntegralPromotion(CondExpr);
- if (getLangOptions().CPlusPlus &&
+ if (getLangOptions().CPlusPlus &&
CheckCXXSwitchCondition(*this, SwitchLoc, CondExpr))
- return StmtError();
+ return StmtError();
+ // C99 6.8.4.2p5 - Integer promotions are performed on the controlling expr.
+ UsualUnaryConversions(CondExpr);
QualType CondType = CondExpr->getType();
SS->setCond(CondExpr);
@@ -522,8 +524,6 @@
return StmtError();
}
- UsualUnaryConversions(CondExpr);
-
if (CondTypeBeforePromotion->isBooleanType()) {
// switch(bool_expr) {...} is often a programmer error, e.g.
// switch(n && mask) { ... } // Doh - should be "n & mask".
More information about the cfe-commits
mailing list