summaryrefslogtreecommitdiff
path: root/gcc/input.h
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2012-04-30 11:42:38 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2012-04-30 13:42:38 +0200
commit70dc395a5098e9ae3958e1a317e202358095ed97 (patch)
treec28481505ac75c540fcd6de15af56c57a92ccb41 /gcc/input.h
parent2d48bdcadfe34cc00ffc7b26687700017b5410c9 (diff)
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. From-SVN: r186972
Diffstat (limited to 'gcc/input.h')
-rw-r--r--gcc/input.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/input.h b/gcc/input.h
index ea19e077797..d811255c9f4 100644
--- a/gcc/input.h
+++ b/gcc/input.h
@@ -40,6 +40,7 @@ extern char builtins_location_check[(BUILTINS_LOCATION
extern expanded_location expand_location (source_location);
extern const char * location_get_source_line(expanded_location xloc);
extern expanded_location expand_location_to_spelling_point (source_location);
+extern source_location expansion_point_location_if_in_system_header (source_location);
/* Historically GCC used location_t, while cpp used source_location.
This could be removed but it hardly seems worth the effort. */