This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Return false for DECL_EXTERNAL VAR_DECLs from auto_var_in_fn_p (PR debug/43942)
- From: Richard Guenther <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 Apr 2010 12:39:07 +0200 (CEST)
- Subject: Re: [PATCH] Return false for DECL_EXTERNAL VAR_DECLs from auto_var_in_fn_p (PR debug/43942)
- References: <20100430102623.GM2817@tyan-ft48-01.lab.bos.redhat.com>
On Fri, 30 Apr 2010, Jakub Jelinek wrote:
> Hi!
>
> At least tree-tailcall wasn't expecting auto_var_in_fn_p to return
> true for DECL_EXTERNAL VAR_DECLs (externs declared inside of a function).
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.
> No effect on the generated debug info size on gcc/*.o (appart from tree.o
> obviously) nor on the generated code (H.J. changed the one occurrence where
> this would trigger last night).
>
> Ok for trunk?
Ok.
Thanks,
Richard.
> 2010-04-30 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/43942
> * tree.c (auto_var_in_fn_p): Return false for DECL_EXTERNAL vars.
>
> * c-c++-common/pr43942.c: New test.
>
> --- gcc/tree.c.jj 2010-04-30 11:14:41.000000000 +0200
> +++ gcc/tree.c 2010-04-30 12:05:26.000000000 +0200
> @@ -7936,7 +7936,8 @@ bool
> auto_var_in_fn_p (const_tree var, const_tree fn)
> {
> return (DECL_P (var) && DECL_CONTEXT (var) == fn
> - && (((TREE_CODE (var) == VAR_DECL || TREE_CODE (var) == PARM_DECL)
> + && ((((TREE_CODE (var) == VAR_DECL && ! DECL_EXTERNAL (var))
> + || TREE_CODE (var) == PARM_DECL)
> && ! TREE_STATIC (var))
> || TREE_CODE (var) == LABEL_DECL
> || TREE_CODE (var) == RESULT_DECL));
> --- gcc/testsuite/c-c++-common/pr43942.c.jj 2010-04-30 12:03:34.000000000 +0200
> +++ gcc/testsuite/c-c++-common/pr43942.c 2010-04-30 11:59:26.000000000 +0200
> @@ -0,0 +1,33 @@
> +/* PR debug/43942 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fcompare-debug" } */
> +
> +extern int f1 (int);
> +
> +int
> +f2 (int x)
> +{
> + extern int v;
> + return f1 (x);
> +}
> +
> +void
> +f3 (void)
> +{
> + f2 (0);
> +}
> +
> +static inline int
> +f4 (int x)
> +{
> + extern int w;
> + if (w)
> + return f1 (x);
> + return 0;
> +}
> +
> +void
> +f5 (void)
> +{
> + f4 (0);
> +}
>
> Jakub
>
>
--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex