When the left expression of a membership test is an object implementing
an interface type, and the right operand of such membership test is a
non-class wide interface type, the compiler generates code that, instead
of comparing the actual tag of the left expression to the tag of the
right operand, erroneously generates a runtime call to the function
IW_Membership test.

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

gcc/ada/

        * exp_ch4.adb (Tagged_Membership): Remove wrong condition that
        is not consistent with the documentation of this subprogram.
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -15284,7 +15284,7 @@ package body Exp_Ch4 is
           Selector_Name =>
             New_Occurrence_Of (First_Tag_Component (Left_Type), Loc));
 
-      if Is_Class_Wide_Type (Right_Type) or else Is_Interface (Left_Type) then
+      if Is_Class_Wide_Type (Right_Type) then
 
          --  No need to issue a run-time check if we statically know that the
          --  result of this membership test is always true. For example,


Reply via email to