Re: *Ping* Re: [PATCH] PR c/43673 - Incorrect warning in dfp printf.
On 5/23/19 4:26 PM, Joseph Myers wrote: > On Tue, 21 May 2019, Jeff Law wrote: > >> On 5/20/19 6:56 PM, luoxhu wrote: >>> Ping for GCC-10. >> I thought this was a NAK in its current form. >> >> See Ryan's c#1 in the BZ. > > I don't see that as relevant to this bug report. > > That comment is about the question of how GCC can know whether libc's > printf supports this feature at all (since in principle the warnings are > meant to relate to the features libc actually supports, unless you make a > particular format language explicit by specifying gnu_printf rather than > printf in the format attribute - though in practice it's only for MinGW > that GCC actually knows about a different set of formats supported by > default). That comment suggests a possible answer (testing predefined > macros after the implicit preinclusion of any implicitly preincluded > header; note that the macro in question is now __STDC_IEC_60559_DFP__, in > TS 18661-2 and C2X) - although, while glibc has supported stdc-predef.h > for some time, current libdfp does not provide such a header. > > This bug report is about an issue that, in the case where GCC is accepting > DFP printf formats, the set of such formats accepted is incomplete. A fix > for it should be independent of any fix for the other (harder) issue. (If > there is a printf implementation that does in fact support the same subset > of DFP formats supported by GCC's printf checking, but not the ones that > are the subject of this bug report, that would complicate things.) > So your position is that runtime support isn't a factor in whether or not we issue diagnostics for this stuff? I guess that makes sense. While we do have some checks for what the runtime& target support, they're geared more type compatibility & promotions. Targets can add additional things via TARGET_FORMAT_TYPES and friends. Jeff
Re: *Ping* Re: [PATCH] PR c/43673 - Incorrect warning in dfp printf.
On Tue, 21 May 2019, Jeff Law wrote: > On 5/20/19 6:56 PM, luoxhu wrote: > > Ping for GCC-10. > I thought this was a NAK in its current form. > > See Ryan's c#1 in the BZ. I don't see that as relevant to this bug report. That comment is about the question of how GCC can know whether libc's printf supports this feature at all (since in principle the warnings are meant to relate to the features libc actually supports, unless you make a particular format language explicit by specifying gnu_printf rather than printf in the format attribute - though in practice it's only for MinGW that GCC actually knows about a different set of formats supported by default). That comment suggests a possible answer (testing predefined macros after the implicit preinclusion of any implicitly preincluded header; note that the macro in question is now __STDC_IEC_60559_DFP__, in TS 18661-2 and C2X) - although, while glibc has supported stdc-predef.h for some time, current libdfp does not provide such a header. This bug report is about an issue that, in the case where GCC is accepting DFP printf formats, the set of such formats accepted is incomplete. A fix for it should be independent of any fix for the other (harder) issue. (If there is a printf implementation that does in fact support the same subset of DFP formats supported by GCC's printf checking, but not the ones that are the subject of this bug report, that would complicate things.) -- Joseph S. Myers jos...@codesourcery.com
Re: *Ping* Re: [PATCH] PR c/43673 - Incorrect warning in dfp printf.
On 5/20/19 6:56 PM, luoxhu wrote: > Ping for GCC-10. I thought this was a NAK in its current form. See Ryan's c#1 in the BZ. jeff
Re: *Ping* Re: [PATCH] PR c/43673 - Incorrect warning in dfp printf.
Ping for GCC-10. Thanks Xionghu On 2019/3/4 09:13, Xiong Hu Luo wrote: Ping: https://gcc.gnu.org/ml/gcc-patches/2019-02/msg01949.html Thanks Xionghu On 2019/2/26 AM9:13, luo...@linux.ibm.com wrote: From: Xiong Hu Luo dfp printf/scanf of Ha/HA, Da/DA and DDa/DDA is not set properly, cause incorrect warning happens: "use of 'D' length modifier with 'a' type character". Regression-tested on powerpc64le-linux, OK for trunk and gcc-8? gcc/c-family/ChangeLog: 2019-02-25 Xiong Hu Luo PR c/43673 * c-format.c (print_char_table, scanf_char_table): Replace BADLEN with TEX_D32, TEX_D64 or TEX_D128. gcc/testsuit/ChangeLog: 2019-02-25 Xiong Hu Luo PR c/43673 * gcc.dg/format-dfp-printf-1.c: New test. * gcc.dg/format-dfp-scanf-1.c: Likewise. --- gcc/c-family/c-format.c| 4 ++-- gcc/testsuite/gcc.dg/format/dfp-printf-1.c | 28 ++-- gcc/testsuite/gcc.dg/format/dfp-scanf-1.c | 22 -- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 9b48ee3..af33ef9 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -674,7 +674,7 @@ static const format_char_info print_char_table[] = { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, /* C99 conversion specifiers. */ { "F", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN, TEX_D32, TEX_D64, TEX_D128 }, "-wp0 +#'I", "", NULL }, - { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "", NULL }, + { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN, TEX_D32, TEX_D64, TEX_D128 }, "-wp0 +#", "", NULL }, /* X/Open conversion specifiers. */ { "C", 0, STD_EXT, { TEX_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w","", NULL }, { "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R", NULL }, @@ -847,7 +847,7 @@ static const format_char_info scan_char_table[] = { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, /* C99 conversion specifiers. */ { "F", 1, STD_C99, { T99_F, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN, TEX_D32, TEX_D64, TEX_D128 }, "*w'", "W", NULL }, - { "aA", 1, STD_C99, { T99_F, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, + { "aA", 1, STD_C99, { T99_F, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN, TEX_D32, TEX_D64, TEX_D128 }, "*w'", "W", NULL }, /* X/Open conversion specifiers. */ { "C", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*mw", "W", NULL }, { "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*amw", "W", NULL }, diff --git a/gcc/testsuite/gcc.dg/format/dfp-printf-1.c b/gcc/testsuite/gcc.dg/format/dfp-printf-1.c index e92f161..a290895 100644 --- a/gcc/testsuite/gcc.dg/format/dfp-printf-1.c +++ b/gcc/testsuite/gcc.dg/format/dfp-printf-1.c @@ -17,6 +17,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, /* Check lack of warnings for valid usage. */ + printf ("%Ha\n", x); + printf ("%HA\n", x); printf ("%Hf\n", x); printf ("%HF\n", x); printf ("%He\n", x); @@ -24,6 +26,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, printf ("%Hg\n", x); printf ("%HG\n", x); + printf ("%Da\n", y); + printf ("%DA\n", y); printf ("%Df\n", y); printf ("%DF\n", y); printf ("%De\n", y); @@ -31,6 +35,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, printf ("%Dg\n", y); printf ("%DG\n", y); + printf ("%DDa\n", z); + printf ("%DDA\n", z); printf ("%DDf\n", z); printf ("%DDF\n", z); printf ("%DDe\n", z); @@ -43,12 +49,16 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, /* Check warnings for type mismatches. */ + printf ("%Ha\n", y); /* { dg-warning "expects argument" "bad use of %H" } */ + printf ("%HA\n", y); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%Hf\n", y); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%HF\n", y); /* { dg-warning "expects argument" "bad use
*Ping* Re: [PATCH] PR c/43673 - Incorrect warning in dfp printf.
Ping: https://gcc.gnu.org/ml/gcc-patches/2019-02/msg01949.html Thanks Xionghu On 2019/2/26 AM9:13, luo...@linux.ibm.com wrote: > From: Xiong Hu Luo > > dfp printf/scanf of Ha/HA, Da/DA and DDa/DDA is not set properly, cause > incorrect warning happens: > "use of 'D' length modifier with 'a' type character". > > Regression-tested on powerpc64le-linux, OK for trunk and gcc-8? > > gcc/c-family/ChangeLog: > > 2019-02-25 Xiong Hu Luo > > PR c/43673 > * c-format.c (print_char_table, scanf_char_table): Replace BADLEN with > TEX_D32, TEX_D64 or TEX_D128. > > gcc/testsuit/ChangeLog: > > 2019-02-25 Xiong Hu Luo > > PR c/43673 > * gcc.dg/format-dfp-printf-1.c: New test. > * gcc.dg/format-dfp-scanf-1.c: Likewise. > --- > gcc/c-family/c-format.c| 4 ++-- > gcc/testsuite/gcc.dg/format/dfp-printf-1.c | 28 ++-- > gcc/testsuite/gcc.dg/format/dfp-scanf-1.c | 22 -- > 3 files changed, 48 insertions(+), 6 deletions(-) > > diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c > index 9b48ee3..af33ef9 100644 > --- a/gcc/c-family/c-format.c > +++ b/gcc/c-family/c-format.c > @@ -674,7 +674,7 @@ static const format_char_info print_char_table[] = >{ "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, > BADLEN, T99_SST, T99_PD, T99_IM, BADLEN, BADLEN, BADLEN }, "", > "W", NULL }, >/* C99 conversion specifiers. */ >{ "F", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, > T99_LD, BADLEN, BADLEN, BADLEN, TEX_D32, TEX_D64, TEX_D128 }, "-wp0 > +#'I", "", NULL }, > - { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, > T99_LD, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", > "", NULL }, > + { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, > T99_LD, BADLEN, BADLEN, BADLEN, TEX_D32, TEX_D64, TEX_D128 }, "-wp0 +#", > "", NULL }, >/* X/Open conversion specifiers. */ >{ "C", 0, STD_EXT, { TEX_WI, BADLEN, BADLEN, BADLEN, BADLEN, > BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", > "", NULL }, >{ "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, > BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", > "R", NULL }, > @@ -847,7 +847,7 @@ static const format_char_info scan_char_table[] = >{ "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, > BADLEN, T99_SST, T99_PD, T99_IM, BADLEN, BADLEN, BADLEN }, "", "W", > NULL }, >/* C99 conversion specifiers. */ >{ "F", 1, STD_C99, { T99_F, BADLEN, BADLEN, T99_D, BADLEN, > T99_LD, BADLEN, BADLEN, BADLEN, TEX_D32, TEX_D64, TEX_D128 }, "*w'", > "W", NULL }, > - { "aA", 1, STD_C99, { T99_F, BADLEN, BADLEN, T99_D, BADLEN, > T99_LD, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", > NULL }, > + { "aA", 1, STD_C99, { T99_F, BADLEN, BADLEN, T99_D, BADLEN, > T99_LD, BADLEN, BADLEN, BADLEN, TEX_D32, TEX_D64, TEX_D128 }, "*w'", > "W", NULL }, >/* X/Open conversion specifiers. */ >{ "C", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, > BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*mw", "W", > NULL }, >{ "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, > BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*amw", "W", > NULL }, > diff --git a/gcc/testsuite/gcc.dg/format/dfp-printf-1.c > b/gcc/testsuite/gcc.dg/format/dfp-printf-1.c > index e92f161..a290895 100644 > --- a/gcc/testsuite/gcc.dg/format/dfp-printf-1.c > +++ b/gcc/testsuite/gcc.dg/format/dfp-printf-1.c > @@ -17,6 +17,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, > unsigned int j, > >/* Check lack of warnings for valid usage. */ > > + printf ("%Ha\n", x); > + printf ("%HA\n", x); >printf ("%Hf\n", x); >printf ("%HF\n", x); >printf ("%He\n", x); > @@ -24,6 +26,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, > unsigned int j, >printf ("%Hg\n", x); >printf ("%HG\n", x); > > + printf ("%Da\n", y); > + printf ("%DA\n", y); >printf ("%Df\n", y); >printf ("%DF\n", y); >printf ("%De\n", y); > @@ -31,6 +35,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, > unsigned int j, >printf ("%Dg\n", y); >printf ("%DG\n", y); > > + printf ("%DDa\n", z); > + printf ("%DDA\n", z); >printf ("%DDf\n", z); >printf ("%DDF\n", z); >printf ("%DDe\n", z); > @@ -43,12 +49,16 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, > unsigned int j, > >/* Check warnings for type mismatches. */ > > + printf ("%Ha\n", y); /* { dg-warning "expects argument" "bad use of > %H" } */ > + printf ("%HA\n", y); /* { dg-warning "expects argument" "bad use of > %H" } */ >printf ("%Hf\n", y); /*