[LLVMbugs] [Bug 13715] New: null-conversion warning needs to be suppressed in macro expansion

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Aug 28 10:25:10 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13715

             Bug #: 13715
           Summary: null-conversion warning needs to be suppressed in
                    macro expansion
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ehsan at mozilla.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Macros can accept pointer-like arguments which they would check for
non-null-ness using operator!.  Currently clang warns in those cases, but I
don't think that warning in macro expansion contexts makes a lot of sense.

ehsan at teenux:/tmp$ cat test.cpp 
#include <stdio.h>
#define foo(x) if (!(x)) printf("x");
int main() {
  int* p;
  foo(p);
  foo(NULL);
}
ehsan at teenux:/tmp$ clang -Wnull-conversion test.cpp 
test.cpp:6:3: warning: implicit conversion of NULL constant to 'bool'
[-Wnull-conversion]
  foo(NULL);
  ^~~~~~~~~
test.cpp:2:22: note: expanded from macro 'foo'
#define foo(x) if (!(x)) printf("x");
                   ~ ^
1 warning generated.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list