[COMMITTED] a68: add explicative comment to are_packs_equivalent

Jose E. Marchesi jemarch@gnu.org
Sat Jan 17 20:57:50 GMT 2026


While fixing PR algol68/123653 I noticed that there was a struct mode
interned in the compiler with the form `struct (ref int)'.  This is
odd because fields are supposed to have names in struct modes.

Turns out that the culprit is:

    (void) a68_add_mode_to_pack (&z, M_REF_INT, NO_TEXT, NO_NODE);

    EQUIVALENT (M_SEMA) = a68_add_mode (&TOP_MOID (&A68_JOB),
                                        STRUCT_SYMBOL,
                                        a68_count_pack_members (z),
                                        NO_NODE, NO_MOID, z);

i.e. it is the standard mode `sema'.  The report says that it is a
struct that hold a reference to int within, but you are not allowed to
access it.

This patch adds a comment to are_packs_equivalent explaining why the
name of a pack may be NULL.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>

gcc/algol68/ChangeLog

	* a68-parser-moids-equivalence.cc (are_packs_equivalent): Add
	explicative comment.
---
 gcc/algol68/a68-parser-moids-equivalence.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/algol68/a68-parser-moids-equivalence.cc b/gcc/algol68/a68-parser-moids-equivalence.cc
index 260eb4209a6..f97dcafc694 100644
--- a/gcc/algol68/a68-parser-moids-equivalence.cc
+++ b/gcc/algol68/a68-parser-moids-equivalence.cc
@@ -49,6 +49,10 @@ are_packs_equivalent (PACK_T *s, PACK_T *t,
 	return false;
       if (compare_names)
 	{
+	  /* Note that a name in a pack of a struct may be NULL if the
+	     corresponding field is supposed to not be accessible by the user.
+	     There is at present one instance of this: the standard prelude
+	   */
 	  if (TEXT (s) != TEXT (t)
 	      && !(TEXT (s) != NO_TEXT
 		   && TEXT (t) != NO_TEXT
-- 
2.39.5



More information about the Algol68 mailing list