[cfe-commits] r43985 - in /cfe/trunk: Sema/SemaExpr.cpp clang.xcodeproj/project.pbxproj test/Sema/usual-float.c

Steve Naroff snaroff at apple.com
Sat Nov 10 11:45:55 PST 2007


Author: snaroff
Date: Sat Nov 10 13:45:54 2007
New Revision: 43985

URL: http://llvm.org/viewvc/llvm-project?rev=43985&view=rev
Log:

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


Modified:
    cfe/trunk/Sema/SemaExpr.cpp
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/test/Sema/usual-float.c

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43985&r1=43984&r2=43985&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sat Nov 10 13:45:54 2007
@@ -870,8 +870,8 @@
   }
   // 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)

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=43985&r1=43984&r2=43985&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sat Nov 10 13:45:54 2007
@@ -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 = "";

Modified: cfe/trunk/test/Sema/usual-float.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/usual-float.c?rev=43985&r1=43984&r2=43985&view=diff

==============================================================================
--- cfe/trunk/test/Sema/usual-float.c (original)
+++ cfe/trunk/test/Sema/usual-float.c Sat Nov 10 13:45:54 2007
@@ -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);
 }





More information about the cfe-commits mailing list