On Thu, Apr 20, 2017 at 04:09:20PM +0100, Jonathan Wakely wrote:
> --- a/gcc/cp/init.c
> +++ b/gcc/cp/init.c
> @@ -3128,11 +3128,14 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, 
> tree nelts,
>      {
>        warning (OPT_Waligned_new_, "%<new%> of type %qT with extended "
>              "alignment %d", elt_type, TYPE_ALIGN_UNIT (elt_type));
> -      inform (input_location, "uses %qD, which does not have an alignment "
> -           "parameter", alloc_fn);
> -      if (!aligned_new_threshold)
> -     inform (input_location, "use %<-faligned-new%> to enable C++17 "
> -                             "over-aligned new support");
> +      if (diagnostic_report_warnings_p (global_dc, input_location))
> +     {
> +       inform (input_location, "uses %qD, which does not have an alignment "
> +               "parameter", alloc_fn);
> +       if (!aligned_new_threshold)
> +         inform (input_location, "use %<-faligned-new%> to enable C++17 "
> +                                 "over-aligned new support");
> +     }
This looks weird.  I'd expect instead:
      if (warning (OPT_Waligned_new_, "%<new%> of type %qT with extended "
                   "alignment %d", elt_type, TYPE_ALIGN_UNIT (elt_type)))
        {
          inform (input_location, "uses %qD, which does not have an alignment "
                  "parameter", alloc_fn);
          if (!aligned_new_threshold)
            inform (input_location, "use %<-faligned-new%> to enable C++17 "
                                    "over-aligned new support");
        }
That is a standard idiom used if some inform or later warning/error depends
on whether earlier warning/error has been diagnosed.

If that works, this is ok for trunk and 7.1 (we don't have a rc1 yet, it is
ok now).

        Jakub

Reply via email to