https://gcc.gnu.org/g:2d1f1bc18a59c0f106c551304ac459ad7781a711

commit r17-5299-g2d1f1bc18a59c0f106c551304ac459ad7781a711
Author: Jose E. Marchesi <[email protected]>
Date:   Sun Oct 18 13:32:16 2026 +0200

    a68: compare types using TYPE_CANONICAL in a68_low_assignation [PR 
algol68/127977]
    
    The front-end shall compare types using TYPE_CANONICAL now that we
    emit typedefs.  Do not use SET_TYPE_STRUCTURAL_EQUALITY.
    
    Signed-off-by: Jose E. Marchesi <[email protected]>
    
    gcc/algol68/ChangeLog
    
            PR algol68/127977
            * a68-low.cc (a68_low_assignation): Compare types using
            TYPE_CANONICAL.
            * a68-low-moids.cc (lower_proc_mode): Do not
            SET_TYPE_STRUCTURAL_EQUALITY.
            (lower_union_mode): Likewise.
    
    gcc/testsuite/ChangeLog
    
            PR algol68/127977
            * algol68/compile/pr127977.a68: New test.

Diff:
---
 gcc/algol68/a68-low-moids.cc               |  3 ---
 gcc/algol68/a68-low.cc                     |  8 ++++----
 gcc/testsuite/algol68/compile/pr127977.a68 | 10 ++++++++++
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gcc/algol68/a68-low-moids.cc b/gcc/algol68/a68-low-moids.cc
index d9d63b9741d3..bc34dbc3d8e3 100644
--- a/gcc/algol68/a68-low-moids.cc
+++ b/gcc/algol68/a68-low-moids.cc
@@ -352,7 +352,6 @@ lower_proc_mode (MOID_T *m)
      build_function_type, which we cannot use, but such is life.  */
   TREE_TYPE (function_type) = ret_type; /* THIS */
   TYPE_ARG_TYPES (function_type) = fnargs;
-  SET_TYPE_STRUCTURAL_EQUALITY (function_type);
 
   if (!COMPLETE_TYPE_P (function_type))
     layout_type (function_type);
@@ -381,7 +380,6 @@ lower_union_mode (MOID_T *m)
   TYPE_NAME (c_union_type) = NULL_TREE;
   TYPE_FIELDS (c_union_type) = NULL_TREE;
   TYPE_CXX_ODR_P (c_union_type) = 0; // XXX otherwise lto complains.  why.
-  SET_TYPE_STRUCTURAL_EQUALITY (c_union_type);
 
   /* Add field declarations.  */
   chain_struct_fields (PACK (m), c_union_type);
@@ -443,7 +441,6 @@ lower_union_mode (MOID_T *m)
       TYPE_FORWARD_REFERENCES (union_type) = forward_refs;
     }
 
-  SET_TYPE_STRUCTURAL_EQUALITY (union_type);
   A68_UNION_TYPE_P (union_type) = 1;
   return union_type;
 }
diff --git a/gcc/algol68/a68-low.cc b/gcc/algol68/a68-low.cc
index 1c4ab2b2344e..376fa32023c0 100644
--- a/gcc/algol68/a68-low.cc
+++ b/gcc/algol68/a68-low.cc
@@ -1016,8 +1016,8 @@ a68_low_assignation (NODE_T *p,
             is performed.  XXX but bound checking in contained values may be
             necessary, ghost elements.  */
          if (POINTER_TYPE_P (TREE_TYPE (lhs))
-             && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (lhs)))
-                 == TYPE_MAIN_VARIANT (TREE_TYPE (rhs))))
+             && (TYPE_CANONICAL (TREE_TYPE (TREE_TYPE (lhs)))
+                 == TYPE_CANONICAL (TREE_TYPE (rhs))))
            {
              /* Make sure to not evaluate the expression yielding the pointer
                 more than once.  */
@@ -1097,8 +1097,8 @@ a68_low_assignation (NODE_T *p,
        rhs = a68_low_dup (rhs, true /* use_heap */);
 
       if (POINTER_TYPE_P (TREE_TYPE (lhs))
-         && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (lhs)))
-             == TYPE_MAIN_VARIANT (TREE_TYPE (rhs))))
+         && (TYPE_CANONICAL (TREE_TYPE (TREE_TYPE (lhs)))
+             == TYPE_CANONICAL (TREE_TYPE (rhs))))
        {
          /* If the left hand side is a pointer, deref it, but return the
             pointer.  Make sure to not evaluate the expression yielding the
diff --git a/gcc/testsuite/algol68/compile/pr127977.a68 
b/gcc/testsuite/algol68/compile/pr127977.a68
new file mode 100644
index 000000000000..335eef556130
--- /dev/null
+++ b/gcc/testsuite/algol68/compile/pr127977.a68
@@ -0,0 +1,10 @@
+begin
+      mode NP = struct(int value);
+      mode NPH = [3]ref NP;
+
+      NPH nph;
+      NP np;
+
+      nph := loc[3]ref NP;
+      nph[0] := np
+end

Reply via email to