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 <luo...@linux.vnet.ibm.com>

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  <luo...@linux.ibm.com>

        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  <luo...@linux.ibm.com>

        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 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 ffa12a8..6df3bc6 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" } */


Reply via email to