diff options
author | Dodji Seketeli <dodji@redhat.com> | 2012-04-30 11:42:25 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@gcc.gnu.org> | 2012-04-30 13:42:25 +0200 |
commit | 2d48bdcadfe34cc00ffc7b26687700017b5410c9 (patch) | |
tree | cf4e13328cba84e16a72f7c69d9cbeae7e7b0b42 /libcpp/init.c | |
parent | c4ca1a09618ff751220fd01d81b0ca62e6cdb735 (diff) | |
download | gcc-2d48bdcadfe34cc00ffc7b26687700017b5410c9.zip gcc-2d48bdcadfe34cc00ffc7b26687700017b5410c9.tar.gz gcc-2d48bdcadfe34cc00ffc7b26687700017b5410c9.tar.bz2 |
Fix -Wuninitialized for -ftrack-macro-expansion
Besides the warning emitted by warn_uninit, this function wants
to hint the user at where the uninitialized variable was declared, for
cases where the declaration location is outside the current function.
Now that expand_location expands to the location that is in the main
source file (even for -ftrack-macro-expansion) the hinting part was
not working well for cases where the variable is declared in a macro
(outside the function), which is then expanded in the function.
So I had to adjust warn_uninit a little bit to make it consider the
spelling location of the variable declaration.
I have fixed the test gcc.dg/cpp/pragma-diagnostic-2.c on which I
believe gcc shouldn't emit any error.
Here is the new output on that test:
=~=
gcc.dg/cpp/pragma-diagnostic-2.c: In function 'g':
gcc.dg/cpp/pragma-diagnostic-2.c:10:5: warning: 'a' is used uninitialized in this function [-Wuninitialized]
gcc.dg/cpp/pragma-diagnostic-2.c:9:7: note: 'a' was declared here
gcc.dg/cpp/pragma-diagnostic-2.c:9:7: note: in expansion of macro 'CODE_WITH_WARNING'
gcc.dg/cpp/pragma-diagnostic-2.c:17:3: note: expanded from here
gcc.dg/cpp/pragma-diagnostic-2.c: In function 'h':
gcc.dg/cpp/pragma-diagnostic-2.c:10:5: warning: 'a' is used uninitialized in this function [-Wuninitialized]
gcc.dg/cpp/pragma-diagnostic-2.c:9:7: note: 'a' was declared here
gcc.dg/cpp/pragma-diagnostic-2.c:9:7: note: in expansion of macro 'CODE_WITH_WARNING'
gcc.dg/cpp/pragma-diagnostic-2.c:27:3: note: expanded from here
=~=
Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk.
Note that the bootstrap with -ftrack-macro-expansion turned on
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/
* tree-ssa.c (warn_uninit): Use the spelling location of the
variable declaration. Use linemap_location_before_p for source
locations.
gcc/testsuite/
* gcc.dg/cpp/pragma-diagnostic-2.c: Fix this.
From-SVN: r186971
Diffstat (limited to 'libcpp/init.c')
0 files changed, 0 insertions, 0 deletions