Opening a bug to track the underlying issue that caused me to submit this patch: https://gcc.gnu.org/ml/gcc-patches/2017-05/msg00481.html https://gcc.gnu.org/ml/gcc-patches/2017-03/msg01325.html When compiling my fork of binutils-gdb, I get a lot of warnings like this one on one file: unwind-ia64.c:183:30: warning: macro argument "code" would be stringified in traditional C #define UNW_DEC_BAD_CODE(code) \ ^ To reduce it to a testcase, we can modify gcc.dg/pragma-diag-7.c to look like this: $ cat pragma-diag-7.c /* { dg-do compile } */ unsigned long ok = 0UL; #pragma GCC diagnostic push #pragma GCC diagnostic warning "-Wtraditional" unsigned long bad = 1UL; /* { dg-warning "suffix" } */ /* Note the extra space before the pragma on this next line: */ #pragma GCC diagnostic pop unsigned long ok_again = 2UL; /* { dg-bogus "suffix" } */ /* Redundant with the previous pop, but just shows that it fails to stop the * following warning with an unpatched GCC: */ #pragma GCC diagnostic ignored "-Wtraditional" /* { dg-bogus "would be stringified" .+1 } */ #define UNW_DEC_PROLOGUE(fmt, body, rlen, arg) \ do { \ unw_rlen = rlen; \ *(int *)arg = body; \ printf(" %s:%s(rlen=%lu)\n", \ fmt, (body ? "body" : "prologue"), (unsigned long)rlen); \ } while (0) $ /usr/local/bin/gcc -c pragma-diag-7.c pragma-diag-7.c:6:21: warning: traditional C rejects the "UL" suffix [-Wtraditional] unsigned long bad = 1UL; /* { dg-warning "suffix" } */ ^~~ pragma-diag-7.c:16:46: warning: macro argument "rlen" would be stringified in traditional C #define UNW_DEC_PROLOGUE(fmt, body, rlen, arg) \ ^ pragma-diag-7.c:16:46: warning: macro argument "body" would be stringified in traditional C $ To get rid of the unwanted warnings, all that is necessary is a 1-line patch to libcpp/macro.c to change a call to cpp_error with CPP_DL_WARNING into a call to cpp_warning with CPP_W_TRADITIONAL instead. The patch is already linked above.
Confirmed. Please keep pinging the patch weekly until it's reviewed.
Please can you turn it into a patch that contains both the fix *and* the new testcase? (e.g. gcc.dg/pragma-diag-8.c)
(In reply to David Malcolm from comment #2) > Please can you turn it into a patch that contains both the fix *and* the new > testcase? (e.g. gcc.dg/pragma-diag-8.c) I will once I get some issues with my email sorted out...
(In reply to Eric Gallager from comment #3) > (In reply to David Malcolm from comment #2) > > Please can you turn it into a patch that contains both the fix *and* the new > > testcase? (e.g. gcc.dg/pragma-diag-8.c) > > I will once I get some issues with my email sorted out... OK here you go: https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01107.html
Author: dmalcolm Date: Tue Nov 21 00:57:29 2017 New Revision: 254981 URL: https://gcc.gnu.org/viewcvs?rev=254981&root=gcc&view=rev Log: Use -Wtraditional for "would be stringified in traditional C" (PR preprocessor/81794) libcpp/ChangeLog: 2017-03-24 Eric Gallager <egall@gwmail.gwu.edu> PR preprocessor/81794 * macro.c (check_trad_stringification): Have warning be controlled by -Wtraditional. gcc/testsuite/ChangeLog: 2017-09-17 Eric Gallager <egall@gwmail.gwu.edu> PR preprocessor/81794 * gcc.dg/pragma-diag-7.c: Update to include check for stringification. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/pragma-diag-7.c trunk/libcpp/ChangeLog trunk/libcpp/macro.c
Should be fixed by r254981; marking as resolved.
(In reply to David Malcolm from comment #6) > Should be fixed by r254981; marking as resolved. Thank you!