[cfe-commits] r43113 - in /cfe/trunk: Sema/SemaExpr.cpp test/Sema/usual-float.c
Chris Lattner
sabre at nondot.org
Wed Oct 17 20:50:34 PDT 2007
Author: lattner
Date: Wed Oct 17 22:50:33 2007
New Revision: 43113
URL: http://llvm.org/viewvc/llvm-project?rev=43113&view=rev
Log:
UsualArithmeticConversions is crashing with an assert
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
Added:
cfe/trunk/test/Sema/usual-float.c
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=43113&r1=43112&r2=43113&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Wed Oct 17 22:50:33 2007
@@ -868,8 +868,8 @@
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).
Added: cfe/trunk/test/Sema/usual-float.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/usual-float.c?rev=43113&view=auto
==============================================================================
--- cfe/trunk/test/Sema/usual-float.c (added)
+++ cfe/trunk/test/Sema/usual-float.c Wed Oct 17 22:50:33 2007
@@ -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);
+}
More information about the cfe-commits
mailing list