[cfe-commits] r74513 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/compare.c

Benjamin Kramer benny.kra at googlemail.com
Wed Jul 1 04:11:57 PDT 2009


Chris Lattner wrote:
> Log:
> Implement PR4175, catching some questionable comparisons.  Patch by
> David Majnemer!

> +    if (((!LHSIsNull || isRelational) && LCanPointeeTy->isVoidType()) !=
> +        ((!RHSIsNull || isRelational) && RCanPointeeTy->isVoidType())) {
> +      Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
> +        << lType << rType << lex->getSourceRange() << rex->getSourceRange();
> +    }

this causes bogus warnings for some NULL comparisons



$ cat t.c
#include <stddef.h>
int main() {
        void *foo;
        return foo == NULL;
}

$ clang t.c
t.c:4:13: warning: comparison of distinct pointer types ('void *' and 'void *')
        return foo == NULL;
               ~~~ ^  ~~~~
1 diagnostic generated.




More information about the cfe-commits mailing list