summaryrefslogtreecommitdiffstats
path: root/clang/Sema
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-08-10 18:26:40 +0000
committerSteve Naroff <snaroff@apple.com>2007-08-10 18:26:40 +0000
commit47fea35e48970da9094ef22404f295726ee4aef9 (patch)
tree5cf7481821b909735f2fbb09e789678d65a8ff02 /clang/Sema
parentf417c2cc341c4232823eec3425c32660fd51e7a8 (diff)
downloadbcm5719-llvm-47fea35e48970da9094ef22404f295726ee4aef9.tar.gz
bcm5719-llvm-47fea35e48970da9094ef22404f295726ee4aef9.zip
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)))) llvm-svn: 40999
Diffstat (limited to 'clang/Sema')
-rw-r--r--clang/Sema/SemaExpr.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp
index 22f8805b6b2..8a3576aaf3a 100644
--- a/clang/Sema/SemaExpr.cpp
+++ b/clang/Sema/SemaExpr.cpp
@@ -1026,8 +1026,13 @@ inline QualType Sema::CheckShiftOperands( // C99 6.5.7
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::CheckRelationalOperands( // C99 6.5.8
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();
OpenPOWER on IntegriCloud