]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: Fix up hash table usage in gfc_trans_use_stmts [PR108451]
authorJakub Jelinek <jakub@redhat.com>
Fri, 3 Feb 2023 20:37:27 +0000 (21:37 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 3 Feb 2023 20:38:41 +0000 (21:38 +0100)
The first testcase in the PR (which I haven't included in the patch because
it is unclear to me if it is supposed to be valid or not) ICEs since extra
hash table checking has been added recently.  The problem is that
gfc_trans_use_stmts does
          tree *slot = entry->decls->find_slot_with_hash (rent->use_name, hash,
                                                          INSERT);
          if (*slot == NULL)
and later on doesn't store anything into *slot and continues.  Another spot
a few lines later correctly clears the slot if it decides not to use the
slot, so the following patch does the same.

2023-02-03  Jakub Jelinek  <jakub@redhat.com>

PR fortran/108451
* trans-decl.cc (gfc_trans_use_stmts): Call clear_slot before
doing continue.

gcc/fortran/trans-decl.cc

index 633300708f4386ad1113e112f9d8158398086570..7a07780191997fa38c0ea61ef1939fac4e1cb5ab 100644 (file)
@@ -5350,7 +5350,11 @@ gfc_trans_use_stmts (gfc_namespace * ns)
              /* Sometimes, generic interfaces wind up being over-ruled by a
                 local symbol (see PR41062).  */
              if (!st->n.sym->attr.use_assoc)
-               continue;
+               {
+                 *slot = error_mark_node;
+                 entry->decls->clear_slot (slot);
+                 continue;
+               }
 
              if (st->n.sym->backend_decl
                  && DECL_P (st->n.sym->backend_decl)