[cfe-commits] r44047 - /cfe/trunk/Sema/SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Tue Nov 13 06:57:39 PST 2007
Author: snaroff
Date: Tue Nov 13 08:57:38 2007
New Revision: 44047
URL: http://llvm.org/viewvc/llvm-project?rev=44047&view=rev
Log:
Teach Sema::CheckCompareOperands() about "void *" (C99 6.5.9p2)
Modified:
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=44047&r1=44046&r2=44047&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Tue Nov 13 08:57:38 2007
@@ -1231,7 +1231,6 @@
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 @@
// 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,
More information about the cfe-commits
mailing list