public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix internal error on comparison with access function parameter
@ 2022-07-13 10:03 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-07-13 10:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

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

It comes from an overzealous assertion.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* gcc-interface/utils2.cc (build_binary_op) <EQ_EXPR>: Also accept
	pointer-to-function types that are not variant of each other.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1213 bytes --]

diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc
--- a/gcc/ada/gcc-interface/utils2.cc
+++ b/gcc/ada/gcc-interface/utils2.cc
@@ -1134,12 +1134,17 @@ build_binary_op (enum tree_code op_code, tree result_type,
 	  else if (POINTER_TYPE_P (left_base_type)
 		   && POINTER_TYPE_P (right_base_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 type hierarchy.  */
-	      gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (left_base_type))
-			  == TYPE_MAIN_VARIANT (TREE_TYPE (right_base_type))
-			  || (TYPE_ALIGN_OK (TREE_TYPE (left_base_type))
-			      && TYPE_ALIGN_OK (TREE_TYPE (right_base_type))));
+		 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));
 	      best_type = left_base_type;
 	    }
 



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

only message in thread, other threads:[~2022-07-13 10:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 10:03 [Ada] Fix internal error on comparison with access function parameter Pierre-Marie de Rodat

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