diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index 6aebd1626ac7..f3381b8148f9 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 000000000000..81e9e6d04b31 --- /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); +}