]> granicus.if.org Git - clang/commitdiff
Teach Sema::CheckCompareOperands() about "void *" (C99 6.5.9p2)
authorSteve Naroff <snaroff@apple.com>
Tue, 13 Nov 2007 14:57:38 +0000 (14:57 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 13 Nov 2007 14:57:38 +0000 (14:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44047 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExpr.cpp

index 87b3d081daced81f89cd3b9159063722d6a55d9b..2981d4a0541820a6fe421aa5bc203142522b5c9a 100644 (file)
@@ -1231,7 +1231,6 @@ inline QualType Sema::CheckCompareOperands( // C99 6.5.8
   QualType lType = lex->getType();
   QualType rType = rex->getType();
   
-  
   // For non-floating point types, check for self-comparisons of the form
   // x == x, x != x, x < x, etc.  These always evaluate to a constant, and
   // often indicate logic errors in the program.
@@ -1275,7 +1274,10 @@ inline QualType Sema::CheckCompareOperands( // C99 6.5.8
   // when handling null pointer constants. One day, we can consider making them
   // errors (when -pedantic-errors is enabled).
   if (lType->isPointerType() && rType->isPointerType()) { // C99 6.5.8p2
-    if (!LHSIsNull && !RHSIsNull &&
+                                                        
+    if (!LHSIsNull && !RHSIsNull &&                       // C99 6.5.9p2
+        !lType->getAsPointerType()->getPointeeType()->isVoidType() &&
+        !rType->getAsPointerType()->getPointeeType()->isVoidType() &&
         !Context.pointerTypesAreCompatible(lType.getUnqualifiedType(),
                                            rType.getUnqualifiedType())) {
       Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,