This is the mail archive of the
gcc-cvs@gcc.gnu.org
mailing list for the GCC project.
r186972 - in /trunk/gcc: ChangeLog cp/ChangeLog...
- From: dodji at gcc dot gnu dot org
- To: gcc-cvs at gcc dot gnu dot org
- Date: Mon, 30 Apr 2012 11:42:38 -0000
- Subject: r186972 - in /trunk/gcc: ChangeLog cp/ChangeLog...
Author: dodji
Date: Mon Apr 30 11:42:38 2012
New Revision: 186972
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186972
Log:
Make conversion warnings work on NULL with -ftrack-macro-expansion
There are various conversion related warnings that trigger on
potentially dangerous uses of NULL (or __null). NULL is defined as a
macro in a system header, so calling warning or warning_at on a
virtual location of NULL yields no diagnostic. So the test
accompanying this patch (as well as others), was failling when run
with -ftrack-macro-expansion.
I think it's necessary to use the location of NULL that is in the main
source code (instead of, e.g, the spelling location that is in the
system header where the macro is defined) in those cases. Note that
for __null, we don't have the issue.
I have augmented the test of this patch to check that we don't regress
when handling __null.
Tested on x86_64-unknown-linux-gnu against trunk.
Note that the bootstrap with -ftrack-macro-expansion exhibits other
separate issues that are addressed in subsequent patches. This patch
just fixes one class of problems.
The patch does pass bootstrap with -ftrack-macro-expansion turned off,
though.
gcc/
* input.h (expansion_point_location_if_in_system_header): Declare
new function.
* input.c (expansion_point_location_if_in_system_header): Define it.
gcc/cp/
* call.c (conversion_null_warnings): Use the new
expansion_point_location_if_in_system_header.
* cvt.c (build_expr_type_conversion): Likewise.
* typeck.c (cp_build_binary_op): Likewise.
gcc/testsuite/
* g++.dg/warn/Wconversion-null-2.C: Add testing for __null,
alongside the previous testing for NULL.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/cvt.c
trunk/gcc/cp/typeck.c
trunk/gcc/input.c
trunk/gcc/input.h
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/warn/Wconversion-null-2.C