]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a68: add explicative comment to are_packs_equivalent
authorJose E. Marchesi <jemarch@gnu.org>
Sat, 17 Jan 2026 20:56:20 +0000 (21:56 +0100)
committerJose E. Marchesi <jemarch@gnu.org>
Sat, 17 Jan 2026 20:56:20 +0000 (21:56 +0100)
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

index 260eb4209a6a9efd5297b10cc4c0177f30708626..f97dcafc694bd86cb4c857366a33f3fec5724129 100644 (file)
@@ -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