This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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


Steven Bosscher wrote:
> 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.
> 

My patch does not change the existing behavior.  Notice that
if is_init is set, decl is returned several lines above.  The lines
that you quoted are dead code, this is why I removed them.

> 
> 
>>   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?

In theory, it may and should be reported in the front end.
In practice, it is inconvenient. There are several errors
in this area that are reported just like that --
grep trans-common.c for gfc_error to see more examples. So
this particular error message does not  make the situation
any worse than it used to be.

I understand that Tobi has a patch to the front end that
will handle this once he gets his copyright assignment. It
seems to me the right way to procede.

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

Agreed.

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

It is never used in gcc/fortran directory, and I am trying to
follow the example.

> 
> 
>>+          /* 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

Okay.



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