Following test-case does not report warning: $ cat /tmp/gimplify.ii int asan_poison_variables () { return (asan_poison_variables && # 6 "gimplify.cpp" 3 4 __null ); } ./xgcc -B. /tmp/gimplify.ii -Wall -c [nothing] While: cat /tmp/gimplify.ii int asan_poison_variables () { return (asan_poison_variables && __null ); } $ ./xgcc -B. /tmp/gimplify.ii -Wall -c /tmp/gimplify.ii: In function ‘int asan_poison_variables()’: /tmp/gimplify.ii:5:31: warning: the address of ‘int asan_poison_variables()’ will never be NULL [-Waddress] __null ^~~~~~ It's somehow related to the location if *.ii file, but I don't know how. Thanks
Looks like -Wsystem-headers in action again. NULL is a macro defined in a system header...
Dunno if we don't want to special case macros in system headers that expand to a single token or what other heuristics to use.
Looking at the PRs you filed about the locations (PR78987 and PR78988), perhaps the best approach here is for the location of the warning to be either this: return (asan_poison_variables && ~~~~~~~~~~~~~~~~~~~~~~^~ # 6 "gimplify.cpp" 3 4 __null ~~~~~~ ); or this: return (asan_poison_variables && ~~~~~~~~~~~~~~~~~~~~~~~~ # 6 "gimplify.cpp" 3 4 __null ^~~~~~ ); i.e. for the location to be a range starting at the LHS start, finishing at the RHS finish, with the caret at either the && or the RHS... ...and then for in_system_header_at to only reject the warning if *all* of the range of the location is fully within a system header, rather than just partially within a header?
...or to use a rich location to send two locations for the warning, giving: return (asan_poison_variables && ^~ # 6 "gimplify.cpp" 3 4 __null ~~~~~~ ); and for the logic that uses diagnostic_report_warnings_p to check all locations in the rich location, requiring all to be within a system header for the warning to be rejected.
Isn't there a dup somewhere? I Know this was filed before.
I suspect PR 77513 can be considered the dup.
(In reply to Andrew Pinski from comment #6) > I suspect PR 77513 can be considered the dup. As in, that's the dup of this, or this is the dup of that?
Confirmed there's no change in GCC 9.0.
GCC 12 (and prior, down to 10) warns for the test case: $ cat pr78989.ii && gcc -S -Wall pr78989.ii int asan_poison_variables () { return (asan_poison_variables && # 6 "gimplify.cpp" 3 4 __null ); } pr78989.ii: In function ‘int asan_poison_variables()’: pr78989.ii:4:10: warning: the address of ‘int asan_poison_variables()’ will never be NULL [-Waddress] 4 | return (asan_poison_variables && | ^~~~~~~~~~~~~~~~~~~~~ pr78989.ii:2:1: note: ‘int asan_poison_variables()’ declared here 2 | asan_poison_variables () | ^~~~~~~~~~~~~~~~~~~~~