This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add -Wsuggest-attribute=cold
- From: Martin Sebor <msebor at gmail dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 24 Jul 2017 16:58:45 -0600
- Subject: Re: Add -Wsuggest-attribute=cold
- Authentication-results: sourceware.org; auth=none
- References: <20170724185633.GA43541@kam.mff.cuni.cz>
+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 ();
+}