]> granicus.if.org Git - clang/commitdiff
fix rdar://7446395, a crash on invalid, by fixing a broken assertion.
authorChris Lattner <sabre@nondot.org>
Sat, 5 Dec 2009 05:40:13 +0000 (05:40 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 5 Dec 2009 05:40:13 +0000 (05:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90647 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/exprs.c

index da1fe3d44d706d35625d23d2683c3eb27c1a6631..bb040b2ee45abd94cc9ca80528c76e1a70233b01 100644 (file)
@@ -5014,6 +5014,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
                                     unsigned OpaqueOpc, bool isRelational) {
   BinaryOperator::Opcode Opc = (BinaryOperator::Opcode)OpaqueOpc;
 
+  // Handle vector comparisons separately.
   if (lex->getType()->isVectorType() || rex->getType()->isVectorType())
     return CheckVectorCompareOperands(lex, rex, Loc, isRelational);
 
@@ -5091,17 +5092,15 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
   }
 
   // The result of comparisons is 'bool' in C++, 'int' in C.
-  QualType ResultTy = getLangOptions().CPlusPlus? Context.BoolTy :Context.IntTy;
+  QualType ResultTy = getLangOptions().CPlusPlus ? Context.BoolTy:Context.IntTy;
 
   if (isRelational) {
     if (lType->isRealType() && rType->isRealType())
       return ResultTy;
   } else {
     // Check for comparisons of floating point operands using != and ==.
-    if (lType->isFloatingType()) {
-      assert(rType->isFloatingType());
+    if (lType->isFloatingType() && rType->isFloatingType())
       CheckFloatComparison(Loc,lex,rex);
-    }
 
     if (lType->isArithmeticType() && rType->isArithmeticType())
       return ResultTy;
index 299b0a267dc25b850928acf8c6a31c83dbaafc31..10fcde6e757697d697d82142877673d2585ea4e9 100644 (file)
@@ -111,4 +111,6 @@ test15_t test15(void) {
   return (test15_t)0 + (test15_t)0;  // expected-error {{invalid operands to binary expression ('test15_t' (aka 'unsigned long *') and 'test15_t')}}
 }
 
+// rdar://7446395
+void test16(float x) { x == ((void*) 0); }  // expected-error {{invalid operands to binary expression}}