public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fortran: Fix up hash table usage in gfc_trans_use_stmts [PR108451]
@ 2023-02-03 19:03 Jakub Jelinek
  2023-02-03 20:20 ` Steve Kargl
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2023-02-03 19:03 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.jj	2023-01-16 11:52:16.146733136 +0100
+++ gcc/fortran/trans-decl.cc	2023-02-03 14:41:40.503322954 +0100
@@ -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)

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fortran: Fix up hash table usage in gfc_trans_use_stmts [PR108451]
  2023-02-03 19:03 [PATCH] fortran: Fix up hash table usage in gfc_trans_use_stmts [PR108451] Jakub Jelinek
@ 2023-02-03 20:20 ` Steve Kargl
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Kargl @ 2023-02-03 20:20 UTC (permalink / raw)
  To: Jakub Jelinek via Fortran; +Cc: gcc-patches

On Fri, Feb 03, 2023 at 08:03:36PM +0100, Jakub Jelinek via Fortran wrote:
> Hi!
> 
> 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.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 

Yes.

See my comment in the PR about the testcases being invalid Fortran.

-- 
Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-03 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 19:03 [PATCH] fortran: Fix up hash table usage in gfc_trans_use_stmts [PR108451] Jakub Jelinek
2023-02-03 20:20 ` Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).