diff options
author | Steve Naroff <snaroff@apple.com> | 2007-11-10 19:45:54 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-11-10 19:45:54 +0000 |
commit | f68a63f9cf4d31bc009cc2831b4857fb13ee1a30 (patch) | |
tree | ffda6d8a6d03feb46849733b4822523a622c2b51 | |
parent | 39d0a27479a58549bc98b55a224d95fa5b09e971 (diff) |
Fix a basic bug (having to do with typedefs) in Sema::UsualArithmeticConversions().
This resuled in the following crash below.
Also modified the usual-float.c test case to capture this case.
[steve-naroffs-imac:clang/test/Sema] snaroff% ../../../../Debug/bin/clang usual-float.c
Assertion failed: (0 && "Sema::UsualArithmeticConversions(): illegal float comparison"), function UsualArithmeticConversions, file SemaExpr.cpp, line 960.
0 clang 0x001ef9b9 _ZN40_GLOBAL__N_Signals.cpp_00000000_4E6DAF8315PrintStackTraceEv + 45
1 clang 0x001efd5f _ZN40_GLOBAL__N_Signals.cpp_00000000_4E6DAF8313SignalHandlerEi + 323
2 libSystem.B.dylib 0x90c6297b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 libSystem.B.dylib 0x90cdb782 raise + 26
5 libSystem.B.dylib 0x90cead3f abort + 73
6 libSystem.B.dylib 0x90cdc923 __assert_rtn + 101
7 clang 0x00077316 _ZN5clang4Sema26UsualArithmeticConversionsERPNS_4ExprES3_b + 1004
8 clang 0x000803cf _ZN5clang4Sema27CheckMultiplyDivideOperandsERPNS_4ExprES3_NS_14SourceLocationEb + 181
9 clang 0x0007a8e8 _ZN5clang4Sema10ActOnBinOpENS_14SourceLocationENS_3tok9TokenKindEPvS4_ + 472
10 clang 0x000cf058 _ZN5clang6Parser26ParseRHSOfBinaryExpressionENS_6Action12ActionResultILj0EEEj + 1286
11 clang 0x000cf2de _ZN5clang6Parser25ParseAssignmentExpressionEv + 86
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43985 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaExpr.cpp | 4 | ||||
-rw-r--r-- | clang.xcodeproj/project.pbxproj | 1 | ||||
-rw-r--r-- | test/Sema/usual-float.c | 8 |
3 files changed, 10 insertions, 3 deletions
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index 111ddbaaad..47cbbcabf3 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -870,8 +870,8 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr, } // 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(); + QualType lhs = lhsExpr->getType().getCanonicalType().getUnqualifiedType(); + QualType rhs = rhsExpr->getType().getCanonicalType().getUnqualifiedType(); // If both types are identical, no conversion is needed. if (lhs == rhs) diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index ffe6580cb2..b9eb859d85 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -764,6 +764,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; + compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; diff --git a/test/Sema/usual-float.c b/test/Sema/usual-float.c index 81e9e6d04b..9c1977ff24 100644 --- a/test/Sema/usual-float.c +++ b/test/Sema/usual-float.c @@ -1,6 +1,12 @@ // RUN: clang %s -fsyntax-only +typedef float CGFloat; + +extern void func(CGFloat); void foo(int dir, int n, int tindex) { const float PI = 3.142; -float ang = (float) tindex * (-dir*2.0f*PI/n); + CGFloat cgf = 3.4; + + float ang = (float) tindex * (-dir*2.0f*PI/n); + func((CGFloat)cgf/65535.0f); } |