public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix PR ada/113195
@ 2024-01-09  9:23 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2024-01-09  9:23 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

This is a small regression present on the mainline and 13 branch, in the form 
of an internal error in gigi on anonymous access type equality.  We now need 
to also accept them too for anonymous access types that point to compatible 
object subtypes in the language sense.

Tested on SPARC64/Linux, applied on the mainline and 13 branch.


2024-01-09  Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/113195
	* gcc-interface/utils2.cc (build_binary_op) <EQ_EXPR>: Relax
	assertion for regular pointer types.


2024-01-09  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/specs/anon4.ads: New test.

-- 
Eric Botcazou

[-- Attachment #2: anon4.ads --]
[-- Type: text/x-adasrc, Size: 162 bytes --]

-- { dg-do compile }

package Anon4 is
   subtype I is Integer;
   A : access I;

   Acc : access Integer;

   function F return Boolean is (A = Acc);
end Anon4;

[-- Attachment #3: p.diff --]
[-- Type: text/x-patch, Size: 1119 bytes --]

diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc
index 6a951093ff8..df11eef2101 100644
--- a/gcc/ada/gcc-interface/utils2.cc
+++ b/gcc/ada/gcc-interface/utils2.cc
@@ -1142,14 +1142,10 @@ build_binary_op (enum tree_code op_code, tree result_type,
 	      tree left_ref_type = TREE_TYPE (left_base_type);
 	      tree right_ref_type = TREE_TYPE (right_base_type);
 
-	      /* Anonymous access types in Ada 2005 can point to different
-		 members of a tagged hierarchy or different function types.  */
-	      gcc_assert (TYPE_MAIN_VARIANT (left_ref_type)
-			  == TYPE_MAIN_VARIANT (right_ref_type)
-			  || (TYPE_ALIGN_OK (left_ref_type)
-			      && TYPE_ALIGN_OK (right_ref_type))
-			  || (TREE_CODE (left_ref_type) == FUNCTION_TYPE
-			      && TREE_CODE (right_ref_type) == FUNCTION_TYPE));
+	      /* Anonymous access types in Ada 2005 may point to compatible
+		 object subtypes or function types in the language sense.  */
+	      gcc_assert (FUNCTION_POINTER_TYPE_P (left_ref_type)
+			  == FUNCTION_POINTER_TYPE_P (right_ref_type));
 	      best_type = left_base_type;
 	    }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-09  9:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09  9:23 [Ada] Fix PR ada/113195 Eric Botcazou

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).