bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 10/11] quote consistently and make tests pass with new quotin


From: Akim Demaille
Subject: Re: [PATCH 10/11] quote consistently and make tests pass with new quoting from gnulib
Date: Mon, 23 Jan 2012 17:42:56 +0100

Le 23 janv. 2012 à 16:17, Jim Meyering a écrit :

> Hi Akim,

Thanks Jim for pointing me to this.

> Is this explanation enough?
> 
>  http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
> 
> ---------------------
> -Wsuggest-attribute=[pure|const|noreturn]
>    Warn for cases where adding an attribute may be beneficial. The attributes 
> currently supported are listed below.
> 
>    -Wsuggest-attribute=pure
>    -Wsuggest-attribute=const
>    -Wsuggest-attribute=noreturn
>        Warn about functions which might be candidates for attributes
>        pure, const or noreturn. The compiler only warns for functions
>        visible in other compilation units or (in the case of pure and
>        const) if it cannot prove that the function returns normally. A
>        function returns normally if it doesn't contain an infinite
>        loop nor returns abnormally by throwing, calling abort() or
>        trapping. This analysis requires option -fipa-pure-const, which
>        is enabled by default at -O and higher. Higher optimization
>        levels improve the accuracy of the analysis.

OK, it explains that the warning will be issued for
functions that do not return properly, but still it
does not say "do not use this attribute for functions that
do not return normally".

The warning comes from revision 158803 in GCC, and there is indeed
a test case whose message is clearer on this regard (the one you had I guess):
it does say _not_ to do it for functions that do not return
normally.

address@hidden ~/src/gcc $ g++-mp-4.6 -O2 -Wsuggest-attribute=pure -c -o 
/tmp/foo.o gcc/testsuite/gcc.dg/pure-2.c
gcc/testsuite/gcc.dg/pure-2.c: In function 'int foo3(int)':
gcc/testsuite/gcc.dg/pure-2.c:38:1: warning: function might be candidate for 
attribute 'pure' if it is known to return normally [-Wsuggest-attribute=pure]
gcc/testsuite/gcc.dg/pure-2.c: In function 'int foo1(int)':
gcc/testsuite/gcc.dg/pure-2.c:9:1: warning: function might be candidate for 
attribute 'pure' [-Wsuggest-attribute=pure]
gcc/testsuite/gcc.dg/pure-2.c: In function 'int foo2(int)':
gcc/testsuite/gcc.dg/pure-2.c:16:1: warning: function might be candidate for 
attribute 'pure' [-Wsuggest-attribute=pure]
gcc/testsuite/gcc.dg/pure-2.c: In function 'int foo4(int)':
gcc/testsuite/gcc.dg/pure-2.c:48:1: warning: function might be candidate for 
attribute 'pure' if it is known to return normally [-Wsuggest-attribute=pure]
gcc/testsuite/gcc.dg/pure-2.c: In function 'int foo5(int)':
gcc/testsuite/gcc.dg/pure-2.c:54:1: warning: function might be candidate for 
attribute 'pure' [-Wsuggest-attribute=pure]

Still I think some clarification of the documentation (of the attribute
itself) is needed.  And maybe GCC should complain about violating 
specifications.

address@hidden /tmp $ cat /tmp/bar.c
#include <stdlib.h>

__attribute__((pure))
int
foo()
{
  abort();
}
address@hidden /tmp $ gcc-mp-4.6 -O2 -Wsuggest-attribute=pure -c /tmp/bar.c 
-Wall -Wextra
address@hidden /tmp $




reply via email to

[Prev in Thread] Current Thread [Next in Thread]