Hello,
This is a possible fix for Wnarrowing warning issues.
Bootstrapped on x86_64 Linux.

diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
   2   │ index 45edd180173..535f1bdfa3e 100644
   3   │ --- a/gcc/cp/typeck2.cc
   4   │ +++ b/gcc/cp/typeck2.cc
   5   │ @@ -1142,6 +1142,10 @@ check_narrowing (tree type, tree init,
tsubst_flags_t complain
       │ ,
   6   │    return ok;
   7   │  }
   8   │
   9   │ +/*pederror (loc, OPT_Wnarrowing,
  10   │ +       "narrowing conversion of constant expression from %qT to
%qT "
  11   │ +       "inside { }", ftype, ftype);
  12   │ +*/
  13   │  /* True iff TYPE is a C++20 "ordinary" character type.  */
  14   │
  15   │  bool
  16   │ diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
  17   │ index 07c76b6c652..457da185821 100644
  18   │ --- a/gcc/diagnostic.cc
  19   │ +++ b/gcc/diagnostic.cc
  20   │ @@ -112,6 +112,23 @@ get_terminal_width (void)
  21   │    return INT_MAX;
  22   │  }
  23   │
  24   │ +extern diagnostic_t pederror (location_t, int, const char *, )
  25   │ +   ATTRIBUTE_GCC_DIAG(3, 4);
  26   │ +
  27   │ +diagnostic_t
  28   │ +pederror (location_t loc, int opt, const char *gmsgid)
  29   │ +{
  30   │ +   va_list args;
  31   │ +   va_start (args, gmsgid);
  32   │ +   diagnostic_t result = diagnostic_report (loc, opt, gmsid,
args);
  33   │ +   va_end (args);
  34   │ +   if (result == DK_WARNING)
  35   │ +   {
  36   │ +       if (flag_pedantic_errors)
  37   │ +           return diagnostic_report (loc, opt, gmsgid, args);
  38   │ +   }
  39   │ +   return result;
  40   │ +}
  41   │  /* Set caret_max_width to value.  */
  42   │  void
  43   │  diagnostic_set_caret_max_width (diagnostic_context *context, int
value)

Reply via email to