aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-07-06 20:14:23 +0000
committerDouglas Gregor <dgregor@apple.com>2009-07-06 20:14:23 +0000
commitf93343764765b24f53e389c7dd35f90901925451 (patch)
tree6296cc52719d8838b102cd39bcb8f0fbdf565a5b /lib
parent613410407c004533d65f3fbe883c8e60cc70e755 (diff)
Fix a problem with false diagnostics when comparing distinct NULL pointer types, from David Majnemer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74850 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaExpr.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index a5e5083964..d6e07bb6b3 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4110,17 +4110,23 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
QualType RCanPointeeTy =
Context.getCanonicalType(rType->getAsPointerType()->getPointeeType());
- if (rType->isFunctionPointerType() || lType->isFunctionPointerType()) {
- if (isRelational) {
+ if (isRelational) {
+ if (lType->isFunctionPointerType() || rType->isFunctionPointerType()) {
Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
}
+ if (LCanPointeeTy->isVoidType() != RCanPointeeTy->isVoidType()) {
+ Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
+ << lType << rType << lex->getSourceRange() << rex->getSourceRange();
+ }
+ } else {
+ if (lType->isFunctionPointerType() != rType->isFunctionPointerType()) {
+ if (!LHSIsNull && !RHSIsNull)
+ Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
+ << lType << rType << lex->getSourceRange() << rex->getSourceRange();
+ }
}
- if (((!LHSIsNull || isRelational) && LCanPointeeTy->isVoidType()) !=
- ((!RHSIsNull || isRelational) && RCanPointeeTy->isVoidType())) {
- Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
- << lType << rType << lex->getSourceRange() << rex->getSourceRange();
- }
+
// Simple check: if the pointee types are identical, we're done.
if (LCanPointeeTy == RCanPointeeTy)
return ResultTy;