From: Xiong Hu Luo Date: Fri, 31 May 2019 18:46:02 +0000 (+0000) Subject: re PR c/43673 (Incorrect warning: use of 'D' length modifier with 'a' type character) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2c2c4e30200463abd0ff1677daf16d49ad4f122;p=gcc.git re PR c/43673 (Incorrect warning: use of 'D' length modifier with 'a' type character) PR c/43673 * c-format.c (print_char_table, scanf_char_table): Replace BADLEN with TEX_D32, TEX_D64 or TEX_D128. PR c/43673 * gcc.dg/format-dfp-printf-1.c: New test. * gcc.dg/format-dfp-scanf-1.c: Likewise. From-SVN: r271820 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 832ec727959..29c8ecca5cf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-05-31 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. + 2019-05-31 Marc Glisse * match.pd (~(vec?cst1:cst2)): New transformation. diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index a7f76c1c01d..b10599f9982 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/ChangeLog b/gcc/testsuite/ChangeLog index 31edc62cdcd..9dc9cbc3d32 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-05-31 Xiong Hu Luo + + PR c/43673 + * gcc.dg/format-dfp-printf-1.c: New test. + * gcc.dg/format-dfp-scanf-1.c: Likewise. + 2019-05-31 Marc Glisse * g++.dg/tree-ssa/cprop-vcond.C: New file. diff --git a/gcc/testsuite/gcc.dg/format/dfp-printf-1.c b/gcc/testsuite/gcc.dg/format/dfp-printf-1.c index e92f1610c34..a290895c2b7 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 of %H" } */ printf ("%He\n", y); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%HE\n", y); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%Hg\n", y); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%HG\n", y); /* { dg-warning "expects argument" "bad use of %H" } */ + printf ("%Ha\n", z); /* { dg-warning "expects argument" "bad use of %H" } */ + printf ("%HA\n", z); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%Hf\n", z); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%HF\n", z); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%He\n", z); /* { dg-warning "expects argument" "bad use of %H" } */ @@ -56,12 +66,16 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, printf ("%Hg\n", z); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%HG\n", z); /* { dg-warning "expects argument" "bad use of %H" } */ + printf ("%Da\n", x); /* { dg-warning "expects argument" "bad use of %D" } */ + printf ("%DA\n", x); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%Df\n", x); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%DF\n", x); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%De\n", x); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%DE\n", x); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%Dg\n", x); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%DG\n", x); /* { dg-warning "expects argument" "bad use of %D" } */ + printf ("%Da\n", z); /* { dg-warning "expects argument" "bad use of %D" } */ + printf ("%DA\n", z); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%Df\n", z); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%DF\n", z); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%De\n", z); /* { dg-warning "expects argument" "bad use of %D" } */ @@ -69,12 +83,16 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, printf ("%Dg\n", z); /* { dg-warning "expects argument" "bad use of %D" } */ printf ("%DG\n", z); /* { dg-warning "expects argument" "bad use of %D" } */ + printf ("%DDa\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */ + printf ("%DDA\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDf\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDF\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDe\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDE\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDg\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDG\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */ + printf ("%DDa\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */ + printf ("%DDA\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDf\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDF\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */ printf ("%DDe\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */ @@ -90,8 +108,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, printf ("%Hu\n", j); /* { dg-warning "length" "bad use of %H" } */ printf ("%Hx\n", j); /* { dg-warning "length" "bad use of %H" } */ printf ("%HX\n", j); /* { dg-warning "length" "bad use of %H" } */ - printf ("%Ha\n", d); /* { dg-warning "length" "bad use of %H" } */ - printf ("%HA\n", d); /* { dg-warning "length" "bad use of %H" } */ + printf ("%Ha\n", d); /* { dg-warning "expects argument" "bad use of %H" } */ + printf ("%HA\n", d); /* { dg-warning "expects argument" "bad use of %H" } */ printf ("%Hc\n", i); /* { dg-warning "length" "bad use of %H" } */ printf ("%Hs\n", p); /* { dg-warning "length" "bad use of %H" } */ printf ("%Hp\n", p); /* { dg-warning "length" "bad use of %H" } */ @@ -100,6 +118,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, /* Sanity checks for flags, field width, and precision in formats for DFP types. */ + printf ("%-Ha\n", x); + printf ("%+HA\n", x); printf ("%-Hf\n", x); printf ("%+HF\n", x); printf ("% He\n", x); @@ -107,6 +127,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, printf ("%0Hg\n", x); printf ("%#0HG\n", x); + printf ("%0#Da\n", y); + printf ("%0DA\n", y); printf ("%0#Df\n", y); printf ("%0DF\n", y); printf ("%#De\n", y); @@ -114,6 +136,8 @@ foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j, printf ("%-#0Dg\n", y); /* { dg-warning "flag ignored" "ignore flag" } */ printf ("%0+ DG\n", y); /* { dg-warning "flag ignored" "ignore flag" } */ + printf ("%DDa\n", z); + printf ("%0DDA\n", z); printf ("%DDf\n", z); printf ("%0DDF\n", z); printf ("%#0DDe\n", z); diff --git a/gcc/testsuite/gcc.dg/format/dfp-scanf-1.c b/gcc/testsuite/gcc.dg/format/dfp-scanf-1.c index ffa12a803ec..6df3bc60ea5 100644 --- a/gcc/testsuite/gcc.dg/format/dfp-scanf-1.c +++ b/gcc/testsuite/gcc.dg/format/dfp-scanf-1.c @@ -17,6 +17,8 @@ voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j, /* Check lack of warnings for valid usage. */ + scanf ("%Ha", x); + scanf ("%HA", x); scanf ("%Hf", x); scanf ("%HF", x); scanf ("%He", x); @@ -24,6 +26,8 @@ voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j, scanf ("%Hg", x); scanf ("%HG", x); + scanf ("%Da", y); + scanf ("%DA", y); scanf ("%Df", y); scanf ("%DF", y); scanf ("%De", y); @@ -31,6 +35,8 @@ voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j, scanf ("%Dg", y); scanf ("%DG", y); + scanf ("%DDa", z); + scanf ("%DDA", z); scanf ("%DDf", z); scanf ("%DDF", z); scanf ("%DDe", z); @@ -43,12 +49,16 @@ voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j, /* Check warnings for type mismatches. */ + scanf ("%Ha", y); /* { dg-warning "expects argument" "bad use of %H" } */ + scanf ("%HA", y); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%Hf", y); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%HF", y); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%He", y); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%HE", y); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%Hg", y); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%HG", y); /* { dg-warning "expects argument" "bad use of %H" } */ + scanf ("%Ha", z); /* { dg-warning "expects argument" "bad use of %H" } */ + scanf ("%HA", z); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%Hf", z); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%HF", z); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%He", z); /* { dg-warning "expects argument" "bad use of %H" } */ @@ -56,12 +66,16 @@ voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j, scanf ("%Hg", z); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%HG", z); /* { dg-warning "expects argument" "bad use of %H" } */ + scanf ("%Da", x); /* { dg-warning "expects argument" "bad use of %D" } */ + scanf ("%DA", x); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%Df", x); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%DF", x); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%De", x); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%DE", x); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%Dg", x); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%DG", x); /* { dg-warning "expects argument" "bad use of %D" } */ + scanf ("%Da", z); /* { dg-warning "expects argument" "bad use of %D" } */ + scanf ("%DA", z); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%Df", z); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%DF", z); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%De", z); /* { dg-warning "expects argument" "bad use of %D" } */ @@ -69,12 +83,16 @@ voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j, scanf ("%Dg", z); /* { dg-warning "expects argument" "bad use of %D" } */ scanf ("%DG", z); /* { dg-warning "expects argument" "bad use of %D" } */ + scanf ("%DDa", x); /* { dg-warning "expects argument" "bad use of %DD" } */ + scanf ("%DDA", x); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDf", x); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDF", x); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDe", x); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDE", x); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDg", x); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDG", x); /* { dg-warning "expects argument" "bad use of %DD" } */ + scanf ("%DDa", y); /* { dg-warning "expects argument" "bad use of %DD" } */ + scanf ("%DDA", y); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDf", y); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDF", y); /* { dg-warning "expects argument" "bad use of %DD" } */ scanf ("%DDe", y); /* { dg-warning "expects argument" "bad use of %DD" } */ @@ -90,8 +108,8 @@ voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j, scanf ("%Hu\n", j); /* { dg-warning "length" "bad use of %H" } */ scanf ("%Hx\n", j); /* { dg-warning "length" "bad use of %H" } */ scanf ("%HX\n", j); /* { dg-warning "length" "bad use of %H" } */ - scanf ("%Ha\n", d); /* { dg-warning "length" "bad use of %H" } */ - scanf ("%HA\n", d); /* { dg-warning "length" "bad use of %H" } */ + scanf ("%Ha\n", d); /* { dg-warning "expects argument" "bad use of %H" } */ + scanf ("%HA\n", d); /* { dg-warning "expects argument" "bad use of %H" } */ scanf ("%Hc\n", i); /* { dg-warning "length" "bad use of %H" } */ scanf ("%Hs\n", p); /* { dg-warning "length" "bad use of %H" } */ scanf ("%Hp\n", p); /* { dg-warning "length" "bad use of %H" } */