]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix internal error on comparison with access function parameter
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 22 Jun 2022 18:20:06 +0000 (20:20 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 13 Jul 2022 10:01:19 +0000 (10:01 +0000)
It comes from an overzealous assertion.

gcc/ada/

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

gcc/ada/gcc-interface/utils2.cc

index 0dcc9fff2a083d7cf2357138e8474a64212cbbf9..4dfe29dc7d9993485803687187b090e7c34d93a4 100644 (file)
@@ -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;
            }