https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92167

--- Comment #1 from Andrew Church <achurch+gcc at achurch dot org> ---
A similar problem occurs when passing the wrong number of arguments to a
function which has been renamed with a macro -- the diagnostic is associated
with the renaming macro instead of the original source line:

-----------------------------
$ cat test3.c
#define RENAME(x) foo_##x
#define a RENAME(a)
extern int a(int);
int b(void) {return a();}
$ gcc-9.2.0 -c test3.c
test.c: In function 'b':
test.c:1:19: error: too few arguments to function 'foo_a'
    1 | #define RENAME(x) foo_##x
      |                   ^~~~
test.c:2:11: note: in expansion of macro 'RENAME'
    2 | #define a RENAME(a)
      |           ^~~~~~
test.c:4:21: note: in expansion of macro 'a'
    4 | int b(void) {return a();}
      |                     ^
test.c:1:19: note: declared here
    1 | #define RENAME(x) foo_##x
      |                   ^~~~
test.c:2:11: note: in expansion of macro 'RENAME'
    2 | #define a RENAME(a)
      |           ^~~~~~
test.c:3:12: note: in expansion of macro 'a'
    3 | extern int a(int);
      |            ^
-----------------------------

In this case as well, Clang associates the diagnostic with the original source
line, though in this case it does not show the macro chain:

-----------------------------
$ clang-9 -c test3.c
test.c:4:23: error: too few arguments to function call, expected 1, have 0
int b(void) {return a();}
                    ~ ^
test.c:3:1: note: 'foo_a' declared here
extern int a(int);
^
-----------------------------

Reply via email to