summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-18 03:50:33 +0000
committerChris Lattner <sabre@nondot.org>2007-10-18 03:50:33 +0000
commitfac7ac41305750e97df8abfd75117bfb2c7bcfbb (patch)
tree92c9b1f4e11cae862b833523aed58d14ab7d566f
parent8569d7734906b2e3823300cc306c44720f946135 (diff)
downloadbcm5719-llvm-fac7ac41305750e97df8abfd75117bfb2c7bcfbb.tar.gz
bcm5719-llvm-fac7ac41305750e97df8abfd75117bfb2c7bcfbb.zip
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 llvm-svn: 43113
-rw-r--r--clang/Sema/SemaExpr.cpp4
-rw-r--r--clang/test/Sema/usual-float.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp
index 6aebd1626ac..f3381b8148f 100644
--- a/clang/Sema/SemaExpr.cpp
+++ b/clang/Sema/SemaExpr.cpp
@@ -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/clang/test/Sema/usual-float.c b/clang/test/Sema/usual-float.c
new file mode 100644
index 00000000000..81e9e6d04b3
--- /dev/null
+++ b/clang/test/Sema/usual-float.c
@@ -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);
+}
OpenPOWER on IntegriCloud