diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-04-12 23:44:09 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-04-12 23:44:09 +0000 |
commit | b0cc1e5343e914ff0286d5608947274c62c3b448 (patch) | |
tree | 6207beaff213a6b74ad72a649609313b2fdda17c /gcc/expr.c | |
parent | bc436e10e0b892b6953e19776367170cd982367c (diff) | |
download | gcc-b0cc1e5343e914ff0286d5608947274c62c3b448.zip gcc-b0cc1e5343e914ff0286d5608947274c62c3b448.tar.gz gcc-b0cc1e5343e914ff0286d5608947274c62c3b448.tar.bz2 |
Prevent erroneous "macro had not yet been defined" messages (PR c++/85385)
PR c++/85385 reports an issue where we emit bogus "macro had not yet been
defined" notes when a macro is mis-used:
$ cat test.c
#define MACRO(X,Y)
void test ()
{
MACRO(42);
}
$ ./xg++ -B. -c test.c
test.c:5:11: error: macro "MACRO" requires 2 arguments, but only 1 given
MACRO(42);
^
test.c: In function ‘void test()’:
test.c:5:3: error: ‘MACRO’ was not declared in this scope
MACRO(42);
^~~~~
test.c:5:3: note:
test.c:1: note: it was later defined here
#define MACRO(X,Y)
The macro *had* been defined, it was merely misused.
This patch fixes the issue by only issuing the note if the use location
is before the definition location (using linemap_location_before_p).
gcc/cp/ChangeLog:
PR c++/85385
* name-lookup.c (macro_use_before_def::maybe_make): New function,
checking that the use is indeed before the definition.
(macro_use_before_def::macro_use_before_def): Make private.
(macro_use_before_def::~macro_use_before_def): Make private. Move
check for UNKNOWN_LOCATION to macro_use_before_def::maybe_make.
(lookup_name_fuzzy): Call macro_use_before_def::maybe_make rather
than using new directly.
gcc/testsuite/ChangeLog:
PR c++/85385
* g++.dg/diagnostic/macro-arg-count.C: New test.
From-SVN: r259360
Diffstat (limited to 'gcc/expr.c')
0 files changed, 0 insertions, 0 deletions