Add -Wsuggest-attribute=cold

Martin Sebor msebor@gmail.com
Mon Jul 24 22:58:00 GMT 2017


> +extern void do_something_interesting_and_never_return ();
> +
> +int
> +foo1(int a)
> +{ /* { dg-warning "cold" "detect cold candidate" { target *-*-* } "8" } */
> +  if (a)
> +    abort ();
> +  else
> +    abort ();
> +}

In this case it looks to me like with the patch GCC will actually
issue two suggestions: the new -Wsuggest-attribute=cold and the
existing -Wsuggest-attrribute=noreturn.

It's probably fine to have the same function annotated with both
attributes but I think it would be nice to give just one suggestion,
and recommend the optimal of the two (presumably noreturn).

Martin

> +
> +int
> +foo2(int a)
> +{
> +  if (a)
> +    do_something_interesting_and_never_return ();
> +  abort ();
> +}
>



More information about the Gcc-patches mailing list