[fortran,patch] Volatile variable in commons and equivalence groups

Tobias Burnus burnus@net-b.de
Tue Feb 5 15:01:00 GMT 2008


FX wrote:
> Patch below fixed PR35037, where we used not to mark as volatile the
> members of common or equivalence groups. This is straightforward and
> well contained, fixes a wrong-code PR, but it's not a regression
> AFAIK, so I'm asking it to be reviewed and for the reviewer to
> indicate whether it is suitable for inclusion in 4.3.
>
> Bootstrapped and regtested on x86_64-linux, will come with a testcase
> (based on -O3 simplification and scanning of the optimized tree dump,
> like is done in the PR).
>   
OK for 4.3.0. (The reason is that it is a wrong-code bug, the code is 
simple and the new code is only used if the variable is marked as VOLATILE.)

However, you really should add a test case for this. See 
gfortran.dg/volatile*.f90 and the PR to this bug (PR 35037) for examples.

Tobias


> 2008-02-05  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
>
>         PR fortran/35037
>         * trans-common.c (build_field): Mark fields as volatile when needed.
>
>
>
> Index: trans-common.c
> ===================================================================
> --- trans-common.c      (revision 132112)
> +++ trans-common.c      (working copy)
> @@ -318,6 +318,15 @@ build_field (segment_info *h, tree union
>        GFC_DECL_ASSIGN_ADDR (field) = pushdecl_top_level (addr);
>      }
>
> +  /* If this field is volatile, mark it.  */
> +  if (h->sym->attr.volatile_)
> +    {
> +      tree new;
> +      TREE_THIS_VOLATILE (field) = 1;
> +      new = build_qualified_type (TREE_TYPE (field), TYPE_QUAL_VOLATILE);
> +      TREE_TYPE (field) = new;
> +    }
> +
>    h->field = field;
>  }
>
>
>
>   



More information about the Fortran mailing list