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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org
             Blocks|                            |87403

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
I modified the testcase a bit to include the suggested fix as its own line:

$ cat 101125.c
struct s { int a, b; };
void f (int);
#define F(X) f(X)
void g (void)
{
  f ((struct s){0,1}.a); /* dg-warning "" */
  F ((struct s){0,1}.a); /* dg-error "passed 2 arguments, but takes just 1" */
  F (((struct s){0,1}.a)); /* dg-bogus "passed 2 arguments, but takes just 1"
*/
}
$

I get the following diagnostics from it:

$ /usr/local/bin/gcc -c -Wall -Wextra -Wtraditional -pedantic -Wc++-compat
101125.c
101125.c: In function 'g':
101125.c:4:6: warning: traditional C rejects ISO C style function definitions
[-Wtraditional]
    4 | void g (void)
      |      ^
101125.c:6:14: warning: traditional C rejects automatic aggregate
initialization [-Wtraditional]
    6 |   f ((struct s){0,1}.a); /* dg-warning "" */
      |              ^
101125.c:7:23: error: macro "F" passed 2 arguments, but takes just 1
    7 |   F ((struct s){0,1}.a); /* dg-error "passed 2 arguments, but takes
just 1" */
      |                       ^
101125.c:3:9: note: macro "F" defined here
    3 | #define F(X) f(X)
      |         ^
101125.c:7:23: warning: function-like macro "F" must be used with arguments in
traditional C [-Wtraditional]
    7 |   F ((struct s){0,1}.a); /* dg-error "passed 2 arguments, but takes
just 1" */
      |                       ^
101125.c:7:3: error: 'F' undeclared (first use in this function)
    7 |   F ((struct s){0,1}.a); /* dg-error "passed 2 arguments, but takes
just 1" */
      |   ^
101125.c:7:3: note: each undeclared identifier is reported only once for each
function it appears in
101125.c:8:15: warning: traditional C rejects automatic aggregate
initialization [-Wtraditional]
    8 |   F (((struct s){0,1}.a)); /* dg-bogus "passed 2 arguments, but takes
just 1" */
      |               ^
101125.c:3:16: note: in definition of macro 'F'
    3 | #define F(X) f(X)
      |                ^
$


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning

Reply via email to