[cfe-commits] r39649 - in /cfe/cfe/trunk/Sema: Sema.h SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Wed Jul 11 09:46:38 PDT 2007
Author: snaroff
Date: Wed Jul 11 11:46:38 2007
New Revision: 39649
URL: http://llvm.org/viewvc/llvm-project?rev=39649&view=rev
Log:
Bug #:
Submitted by:
Reviewed by:
Fixed typechecking bugs wrt UsualUnaryConversions. Includes two distinct fixes:
#1: Call UsualUnaryConversions in CheckRelationalOperands/CheckEqualityOperands.
#2: UsualArithmeticConversions arguments are now output parameters. This insures
the implicit conversion is seen by clients (and fixes bugs in CheckAdditionOperands
and CheckSubtractionOperands when doing pointer arithmetic).
~
Modified:
cfe/cfe/trunk/Sema/Sema.h
cfe/cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.h?rev=39649&r1=39648&r2=39649&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.h (original)
+++ cfe/cfe/trunk/Sema/Sema.h Wed Jul 11 11:46:38 2007
@@ -274,7 +274,7 @@
// operators (C99 6.3.1.8). If both operands aren't arithmetic, this
// routine returns the first non-arithmetic type found. The client is
// responsible for emitting appropriate error diagnostics.
- QualType UsualArithmeticConversions(QualType t1, QualType t2);
+ QualType UsualArithmeticConversions(QualType &t1, QualType &t2);
// DefaultFunctionArrayConversion - converts functions and arrays
// to their respective pointers (C99 6.3.2.1). If the type isn't a function
// or array, this routine simply returns the input type (unmodified).
Modified: cfe/cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaExpr.cpp?rev=39649&r1=39648&r2=39649&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaExpr.cpp Wed Jul 11 11:46:38 2007
@@ -592,9 +592,9 @@
/// binary operators (C99 6.3.1.8). If both operands aren't arithmetic, this
/// routine returns the first non-arithmetic type found. The client is
/// responsible for emitting appropriate error diagnostics.
-QualType Sema::UsualArithmeticConversions(QualType t1, QualType t2) {
- QualType lhs = UsualUnaryConversions(t1);
- QualType rhs = UsualUnaryConversions(t2);
+QualType Sema::UsualArithmeticConversions(QualType &lhs, QualType &rhs) {
+ lhs = UsualUnaryConversions(lhs);
+ rhs = UsualUnaryConversions(rhs);
// If both types are identical, no conversion is needed.
if (lhs == rhs)
@@ -736,7 +736,8 @@
inline QualType Sema::CheckMultiplyDivideOperands(
Expr *lex, Expr *rex, SourceLocation loc)
{
- QualType resType = UsualArithmeticConversions(lex->getType(), rex->getType());
+ QualType lhsType = lex->getType(), rhsType = rex->getType();
+ QualType resType = UsualArithmeticConversions(lhsType, rhsType);
if (resType->isArithmeticType())
return resType;
@@ -747,7 +748,8 @@
inline QualType Sema::CheckRemainderOperands(
Expr *lex, Expr *rex, SourceLocation loc)
{
- QualType resType = UsualArithmeticConversions(lex->getType(), rex->getType());
+ QualType lhsType = lex->getType(), rhsType = rex->getType();
+ QualType resType = UsualArithmeticConversions(lhsType, rhsType);
if (resType->isIntegerType())
return resType;
@@ -793,7 +795,8 @@
{
// FIXME: Shifts don't perform usual arithmetic conversions. This is wrong
// for int << longlong -> the result type should be int, not long long.
- QualType resType = UsualArithmeticConversions(lex->getType(), rex->getType());
+ QualType lhsType = lex->getType(), rhsType = rex->getType();
+ QualType resType = UsualArithmeticConversions(lhsType, rhsType);
if (resType->isIntegerType())
return resType;
@@ -804,7 +807,8 @@
inline QualType Sema::CheckRelationalOperands( // C99 6.5.8
Expr *lex, Expr *rex, SourceLocation loc)
{
- QualType lType = lex->getType(), rType = rex->getType();
+ QualType lType = UsualUnaryConversions(lex->getType());
+ QualType rType = UsualUnaryConversions(rex->getType());
if (lType->isRealType() && rType->isRealType())
return Context.IntTy;
@@ -823,7 +827,8 @@
inline QualType Sema::CheckEqualityOperands( // C99 6.5.9
Expr *lex, Expr *rex, SourceLocation loc)
{
- QualType lType = lex->getType(), rType = rex->getType();
+ QualType lType = UsualUnaryConversions(lex->getType());
+ QualType rType = UsualUnaryConversions(rex->getType());
if (lType->isArithmeticType() && rType->isArithmeticType())
return Context.IntTy;
@@ -841,7 +846,8 @@
inline QualType Sema::CheckBitwiseOperands(
Expr *lex, Expr *rex, SourceLocation loc)
{
- QualType resType = UsualArithmeticConversions(lex->getType(), rex->getType());
+ QualType lhsType = lex->getType(), rhsType = rex->getType();
+ QualType resType = UsualArithmeticConversions(lhsType, rhsType);
if (resType->isIntegerType())
return resType;
@@ -948,7 +954,8 @@
}
QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) {
- QualType resType = UsualArithmeticConversions(op->getType(), Context.IntTy);
+ QualType lhsType = op->getType(), rhsType = Context.IntTy;
+ QualType resType = UsualArithmeticConversions(lhsType, rhsType);
assert(!resType.isNull() && "no type for increment/decrement expression");
// C99 6.5.2.4p1
More information about the cfe-commits
mailing list