This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Untabified and resubmitted: Patch to gfortran PR13742


On Wednesday 05 May 2004 09:42, Victor Leikehman wrote:

> @@ -179,13 +180,18 @@ static tree
>  build_equiv_decl (tree union_type, bool is_init)
>  {
>    tree decl;
> +
> +  if (is_init)
> +    {
> +      decl = gfc_create_var (union_type, "equiv");
> +      TREE_STATIC (decl) = 1;
> +      return decl;
> +    }
> +
>    decl = build_decl (VAR_DECL, NULL, union_type);
>    DECL_ARTIFICIAL (decl) = 1;
>
> -  if (is_init)
> -    DECL_COMMON (decl) = 0;
> -  else
> -    DECL_COMMON (decl) = 1;
> +  DECL_COMMON (decl) = 1;

This put all EQUIVALENCE decls in '.common', I doubt we really want that.


>    if (sym)
> -    decl = build_common_decl (sym, union_type, is_init);
> +    {
> +      if (is_init)
> +        gfc_error ("Variables in COMMON block should not"
> +                   " have initializers");

Is there a way to get this error to the front end?

The idea always was to have the front end handle all errors/warnings,
and have the backend generate code iff no errors were found.


> +              if (h->sym->value)
> +                {
> +                  if (h->offset < offset)
> +                    gfc_error ("Unsupported form of initialization"
> +                               " of EQUIVALENCEd variables");

This should use sorry().


> +          /* Sanity check */
> +          for (t = CONSTRUCTOR_ELTS (ctor); t; t = TREE_CHAIN (t))
> +            {
> +              tree field = TREE_PURPOSE (t);
> +              assert (TREE_CODE (field) == FIELD_DECL);
> +            }

This can be wrapped in #ifdef ENABLE_CHECKING/#endif.

Gr.
Steven



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]