[PATCH] Fix PR88936

Richard Biener rguenther@suse.de
Fri Apr 12 13:25:00 GMT 2019


On Fri, 12 Apr 2019, Michael Matz wrote:

> Hi,
> 
> On Fri, 12 Apr 2019, Richard Biener wrote:
> 
> > @@ -332,6 +337,24 @@ struct obstack final_solutions_obstack;
> >     Indexed directly by variable info id.  */
> >  static vec<varinfo_t> varmap;
> >  
> > +/* Return whether VAR is an automatic variable.  */
> > +
> > +static bool
> > +auto_var_p (const_tree var)
> > +{
> > +  if (VAR_P (var))
> > +    {
> > +      tree context = DECL_CONTEXT (var);
> > +      if (context
> > +	  && TREE_CODE (context) == FUNCTION_DECL
> > +	  && ! DECL_EXTERNAL (var)
> > +	  && ! TREE_STATIC (var))
> > +	return true;
> > +    }
> > +  return false;
> > +}
> 
> You miss PARM_DECLs and RESULT_DECLs, i.e. it's probably better to factor 
> out tree.c:auto_var_in_fn_p and place the new auto_var_p in tree.c as 
> well.

Hmm, I left the above unchanged from a different variant of the patch
where for some reason I do not remember I explicitely decided
parameters and results are not affected...

Not so for parameters as the following testcase shows.

Will fix.

Richard.

void bar(int cnt)
{
  if (cnt == 0)
    {
      p = &cnt;
      bar (1);
      if (cnt != 1)
        __builtin_abort ();
    }
  else if (cnt == 1)
    *p = 1;
}
int main()
{
  bar (0);
  return 0;
}



More information about the Gcc-patches mailing list