gcc/libcpp
David Malcolm 954ad1127e libcpp: show macro definition when used with wrong argument count
Consider:

demo.c: In function 'test':
demo.c:5:40: error: macro "LOG_2" requires 3 arguments, but only 2 given
5 |   LOG_2 ("loading file: %s\n", filename);
  |                                        ^

This patch adds a note showing the definition of the macro in
question, giving:

demo.c: In function 'test':
demo.c:5:40: error: macro "LOG_2" requires 3 arguments, but only 2 given
5 |   LOG_2 ("loading file: %s\n", filename);
  |                                        ^
In file included from demo.c:1:
logging.h:1: note: macro "LOG_2" defined here
1 | #define LOG_2(FMT, ARG0, ARG1) do { fprintf (stderr, (FMT), (ARG0), (ARG1)); }
  | 

gcc/testsuite/ChangeLog:
	* g++.dg/diagnostic/macro-arg-count.C: Move to...
	* c-c++-common/cpp/macro-arg-count-1.c: ...here, generalizing
	output for C vs C++.  Expect notes showing the definitions of the
	macros.
	* c-c++-common/cpp/macro-arg-count-2.c: New test, adapted from the
	above.

libcpp/ChangeLog:
	* macro.c (_cpp_arguments_ok): If the argument count is wrong, add
	a note showing the definition of the macro.

From-SVN: r265040
2018-10-11 13:21:28 +00:00
..
include [PATCH] A couple of line map fixes 2018-10-11 12:42:37 +00:00
po
aclocal.m4
ChangeLog libcpp: show macro definition when used with wrong argument count 2018-10-11 13:21:28 +00:00
ChangeLog.jit
charset.c Cleanup of libcpp diagnostic callbacks 2018-10-09 23:37:19 +00:00
config.in
configure
configure.ac
directives-only.c
directives.c Cleanup of libcpp diagnostic callbacks 2018-10-09 23:37:19 +00:00
errors.c Cleanup of libcpp diagnostic callbacks 2018-10-09 23:37:19 +00:00
expr.c
files.c
identifiers.c
init.c
internal.h
lex.c
line-map.c [PATCH] A couple of line map fixes 2018-10-11 12:42:37 +00:00
location-example.txt
macro.c libcpp: show macro definition when used with wrong argument count 2018-10-11 13:21:28 +00:00
Makefile.in
makeucnid.c
mkdeps.c
pch.c
symtab.c
system.h
traditional.c
ucnid.h
ucnid.tab