]> granicus.if.org Git - clang/commitdiff
Tweak a recent fix to UsualArithmeticConversions (made by Chris - r43113). The benefi...
authorSteve Naroff <snaroff@apple.com>
Thu, 18 Oct 2007 18:55:53 +0000 (18:55 +0000)
committerSteve Naroff <snaroff@apple.com>
Thu, 18 Oct 2007 18:55:53 +0000 (18:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43142 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExpr.cpp

index 12897ea291ccf7a0d8ef8a9b77cdf07e0f7b82b1..28c68568622f5e9416e7bdae0353003326cb5f31 100644 (file)
@@ -867,12 +867,14 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr,
     UsualUnaryConversions(lhsExpr);
     UsualUnaryConversions(rhsExpr);
   }
-  QualType lhs = lhsExpr->getType();
-  QualType rhs = rhsExpr->getType();
+  // For conversion purposes, we ignore any qualifiers. 
+  // For example, "const float" and "float" are equivalent.
+  QualType lhs = lhsExpr->getType().getUnqualifiedType();
+  QualType rhs = rhsExpr->getType().getUnqualifiedType();
   
   // If both types are identical, no conversion is needed.
-  if (lhs.getTypePtr() == rhs.getTypePtr())
-    return lhs.getQualifiedType(0);
+  if (lhs == rhs)
+    return lhs;
   
   // If either side is a non-arithmetic type (e.g. a pointer), we are done.
   // The caller can deal with this (e.g. pointer + int).