]> granicus.if.org Git - clang/commitdiff
UsualArithmeticConversions is crashing with an assert
authorChris Lattner <sabre@nondot.org>
Thu, 18 Oct 2007 03:50:33 +0000 (03:50 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Oct 2007 03:50:33 +0000 (03:50 +0000)
when comparing "float" and "const float".  This "fixes" the
issue, but may not be the right fix.  Steve, please review.

Testcase here: test/Sema/usual-float.c

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43113 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExpr.cpp
test/Sema/usual-float.c [new file with mode: 0644]

index 6aebd1626ac7a6780278b1ae0a20422e858a2d58..f3381b8148f9495e7f0c166a857098c44bb5c129 100644 (file)
@@ -868,8 +868,8 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr,
   QualType rhs = rhsExpr->getType();
   
   // If both types are identical, no conversion is needed.
-  if (lhs == rhs) 
-    return lhs;
+  if (lhs.getTypePtr() == rhs.getTypePtr())
+    return lhs.getQualifiedType(0);
   
   // 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).
diff --git a/test/Sema/usual-float.c b/test/Sema/usual-float.c
new file mode 100644 (file)
index 0000000..81e9e6d
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: clang %s -fsyntax-only
+
+void foo(int dir, int n, int tindex) {
+  const float PI = 3.142;
+float ang = (float) tindex * (-dir*2.0f*PI/n);
+}