Eli points out that we really must diagnose "void* > 0" as an extension.
Explicitly add it as an EXTENSION instead of an EXTWARN so that it only
comes out with -pedantic. Thanks Eli!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79791 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index f9ec6af..5920291 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4358,10 +4358,16 @@
}
}
if (lType->isAnyPointerType() && rType->isIntegerType()) {
- if (!RHSIsNull) {
- unsigned DiagID = isRelational
- ? diag::ext_typecheck_ordered_comparison_of_pointer_integer
- : diag::ext_typecheck_comparison_of_pointer_integer;
+ unsigned DiagID = 0;
+ if (RHSIsNull) {
+ if (isRelational)
+ DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
+ } else if (isRelational)
+ DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
+ else
+ DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
+
+ if (DiagID) {
Diag(Loc, DiagID)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
}
@@ -4369,11 +4375,16 @@
return ResultTy;
}
if (lType->isIntegerType() && rType->isAnyPointerType()) {
- if (!LHSIsNull) {
- unsigned DiagID = isRelational
- ? diag::ext_typecheck_ordered_comparison_of_pointer_integer
- : diag::ext_typecheck_comparison_of_pointer_integer;
+ unsigned DiagID = 0;
+ if (LHSIsNull) {
+ if (isRelational)
+ DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
+ } else if (isRelational)
+ DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
+ else
+ DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
+ if (DiagID) {
Diag(Loc, DiagID)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
}