Am 14.02.2016 um 15:38 schrieb H.J. Lu:

It breaks bootstrap on x86:

../../../src-trunk/libgfortran/intrinsics/selected_int_kind.f90:28:40:

    integer :: _gfortran_selected_int_kind

I have fixed this in two parts:

a) reverted the patch (r233411).  I still managed to catch the revision
   immediately following r233410.  Thanks H.J. for the prompt report!

b) committed a fixed patch (r233413)

The problem was that there is no upcase equivalent for _, so the
test for a symbol with an upcase first letter found the symbol itself.
That fix was obvios, see attached patch.

I tested the new patch by regression-testing and by rebuilding
libgfortran.

I was unable to write a test case because I could not find a
set of options to allow a leading underscore in a function name.

So, should we do something differently?  There are only seven
non-generated *.f90 files in libgfortran.  The chances of
breaking bootstrap this way are relatively low, and patch
reversion is easy enough, so I don't think we should regularly
rebuild libgfortran for this.

Regards

        Thomas


2016-02-14  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/60526
        * decl.c (build_sym):  If the name has already been defined as a
        type, it has a symtree with an upper case letter at the beginning.
        If such a symtree exists, issue an error and exit.  Don't do
        this if there is no corresponding upper case letter.


2016-02-14  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/60526
        * gfortran.dg/type_decl_4.f90:  Reinstated.

Index: decl.c
===================================================================
--- decl.c	(Revision 233411)
+++ decl.c	(Arbeitskopie)
@@ -1215,10 +1215,38 @@ build_sym (const char *name, gfc_charlen *cl, bool
 {
   symbol_attribute attr;
   gfc_symbol *sym;
+  int upper;
 
   if (gfc_get_symbol (name, NULL, &sym))
     return false;
 
+  /* Check if the name has already been defined as a type.  The
+     first letter of the symtree will be in upper case then.  Of
+     course, this is only necessary if the upper case letter is
+     actually different.  */
+
+  upper = TOUPPER(name[0]);
+  if (upper != name[0])
+    {
+      char u_name[GFC_MAX_SYMBOL_LEN + 1];
+      gfc_symtree *st;
+      int nlen;
+
+      nlen = strlen(name);
+      gcc_assert (nlen <= GFC_MAX_SYMBOL_LEN);
+      strncpy (u_name, name, nlen + 1);
+      u_name[0] = upper;
+
+      st = gfc_find_symtree (gfc_current_ns->sym_root, u_name);
+
+      if (st != 0)
+	{
+	  gfc_error ("Symbol %qs at %C also declared as a type at %L", name,
+		     &st->n.sym->declared_at);
+	  return false;
+	}
+    }
+
   /* Start updating the symbol table.  Add basic type attribute if present.  */
   if (current_ts.type != BT_UNKNOWN
       && (sym->attr.implicit_type == 0

Reply via email to