diff mbox series

[COMMITTED,17/31] ada: Fix oversight in previous change

Message ID 20240521073035.314024-17-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/31] ada: Add new Mingw task priority mapping | expand

Commit Message

Marc Poulhiès May 21, 2024, 7:30 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

In rare cases, types using structural equality may reach relate_alias_sets.

gcc/ada/

	* gcc-interface/utils.cc (relate_alias_sets): Restore previous code
	when the type uses structural equality.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/gcc-interface/utils.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index b628481335d..ae520542ace 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -1867,8 +1867,11 @@  relate_alias_sets (tree new_type, tree old_type, enum alias_set_op op)
 		      && TYPE_NONALIASED_COMPONENT (new_type)
 			 != TYPE_NONALIASED_COMPONENT (old_type)));
 
-      /* The alias set always lives on the TYPE_CANONICAL.  */
-      TYPE_ALIAS_SET (TYPE_CANONICAL (new_type)) = get_alias_set (old_type);
+      /* The alias set is a property of the TYPE_CANONICAL if it exists.  */
+      if (TYPE_STRUCTURAL_EQUALITY_P (new_type))
+	TYPE_ALIAS_SET (new_type) = get_alias_set (old_type);
+      else
+	TYPE_ALIAS_SET (TYPE_CANONICAL (new_type)) = get_alias_set (old_type);
       break;
 
     case ALIAS_SET_SUBSET: