This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug preprocessor/81794] New: "would be stringified in traditional C" warning should be controlled by -Wtraditional
- From: "egallager at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 10 Aug 2017 11:39:34 +0000
- Subject: [Bug preprocessor/81794] New: "would be stringified in traditional C" warning should be controlled by -Wtraditional
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81794
Bug ID: 81794
Summary: "would be stringified in traditional C" warning should
be controlled by -Wtraditional
Product: gcc
Version: 8.0
URL: https://gcc.gnu.org/ml/gcc-patches/2017-03/msg01325.ht
ml
Status: UNCONFIRMED
Keywords: diagnostic, easyhack, patch
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: egallager at gcc dot gnu.org
CC: dmalcolm at gcc dot gnu.org
Target Milestone: ---
Host: i386-apple-darwin9.8.0
Target: i386-apple-darwin9.8.0
Build: i386-apple-darwin9.8.0
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.