This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix common_pointer_type for fn pointers where one has __attribute__((const)) and one does not (PR tree-optimization/32139)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 31 May 2007 20:57:12 +0000 (UTC)
- Subject: Re: [PATCH] Fix common_pointer_type for fn pointers where one has __attribute__((const)) and one does not (PR tree-optimization/32139)
- References: <20070531115739.GW4033@devserv.devel.redhat.com>
On Thu, 31 May 2007, Jakub Jelinek wrote:
> On FUNCTION_TYPE TREE_READONLY means the fn has __attribute__((const))
> and that should be merged IMHO conservatively, TREE_READONLY on the
> common fntype onlyl if both functions are __attribute__((const)),
> otherwise we can optimize out some invocations even when they have
> side-effects.
I think the same should apply to the volatile qualifier (used for
noreturn) as well; build_c_cast treats them the same for -Wcast-qual
warnings.
> --- gcc/testsuite/gcc.c-torture/execute/20070531-1.c.jj 2007-05-31 13:47:22.000000000 +0200
> +++ gcc/testsuite/gcc.c-torture/execute/20070531-1.c 2007-05-31 13:43:26.000000000 +0200
> @@ -0,0 +1,11 @@
> +/* PR tree-optimization/32139 */
> +int foo (void);
> +int bar (void) __attribute__ ((const));
> +
> +int
> +test (int x)
> +{
> + int a = (x == 10000 ? foo : bar) ();
> + int b = (x == 10000 ? foo : bar) ();
> + return a + b;
> +}
An execute testcase without a main() function seems odd.
--
Joseph S. Myers
joseph@codesourcery.com