[cfe-commits] r40999 - /cfe/trunk/Sema/SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Fri Aug 10 11:26:40 PDT 2007
Author: snaroff
Date: Fri Aug 10 13:26:40 2007
New Revision: 40999
URL: http://llvm.org/viewvc/llvm-project?rev=40999&view=rev
Log:
Make sure the arithmetic conversion are done for relation and equality operators.
This fixes the following...
eypedef short S;
int test(S X, long long Y) {
return X < Y;
}
Before...
(CompoundStmt 0x2905d00
(ReturnStmt 0x2905cf0
(BinaryOperator 0x2905cd0 'int' '<'
(ImplicitCastExpr 0x2905cc0 'int'
(DeclRefExpr 0x2905c80 'S':'short' Decl='X' 0x2905c20))
(DeclRefExpr 0x2905ca0 'long long' Decl='Y' 0x2905c50))))
After...
(CompoundStmt 0x2b05c30
(ReturnStmt 0x2b05c20
(BinaryOperator 0x2b05c00 'int' '<'
(ImplicitCastExpr 0x2b05bf0 'long long'
(DeclRefExpr 0x2b05bb0 'S':'short' Decl='X' 0x2b05b50))
(DeclRefExpr 0x2b05bd0 'long long' Decl='Y' 0x2b05b80))))
Modified:
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=40999&r1=40998&r2=40999&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Fri Aug 10 13:26:40 2007
@@ -1026,8 +1026,13 @@
inline QualType Sema::CheckRelationalOperands( // C99 6.5.8
Expr *&lex, Expr *&rex, SourceLocation loc)
{
- UsualUnaryConversions(lex);
- UsualUnaryConversions(rex);
+ // C99 6.5.8p3
+ if (lex->getType()->isArithmeticType() && rex->getType()->isArithmeticType())
+ UsualArithmeticConversions(lex, rex);
+ else {
+ UsualUnaryConversions(lex);
+ UsualUnaryConversions(rex);
+ }
QualType lType = lex->getType();
QualType rType = rex->getType();
@@ -1058,8 +1063,13 @@
inline QualType Sema::CheckEqualityOperands( // C99 6.5.9
Expr *&lex, Expr *&rex, SourceLocation loc)
{
- UsualUnaryConversions(lex);
- UsualUnaryConversions(rex);
+ // C99 6.5.9p4
+ if (lex->getType()->isArithmeticType() && rex->getType()->isArithmeticType())
+ UsualArithmeticConversions(lex, rex);
+ else {
+ UsualUnaryConversions(lex);
+ UsualUnaryConversions(rex);
+ }
QualType lType = lex->getType();
QualType rType = rex->getType();
More information about the cfe-commits
mailing list