[Ada] Wrong membership test computation for interface type

Message ID 20210504095222.GA90297@adacore.com
State New
Headers show
  • [Ada] Wrong membership test computation for interface type
Related show

Commit Message

Pierre-Marie de Rodat May 4, 2021, 9:52 a.m.
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


	* 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,