aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2018-05-25 09:05:04 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-25 09:05:04 +0000
commit25409c3c63b151f27bd77fb92c8b62af8681d777 (patch)
treed26a019e5cfaf745e6caebd74e8f607218e03454 /gcc/ada
parent1f6237e3ddfba881d87d9c62d0b806717a71fbe5 (diff)
downloadgcc-25409c3c63b151f27bd77fb92c8b62af8681d777.zip
gcc-25409c3c63b151f27bd77fb92c8b62af8681d777.tar.gz
gcc-25409c3c63b151f27bd77fb92c8b62af8681d777.tar.bz2
[Ada] Membership test of class-wide interface
The compiler rejects the use of a membership test when the left operand is a class-wide interface type object and the right operand is not a class-wide type. 2018-05-25 Javier Miranda <miranda@adacore.com> gcc/ada/ * sem_res.adb (Resolve_Membership_Op): Allow the use of the membership test when the left operand is a class-wide interface and the right operand is not a class-wide type. * exp_ch4.adb (Tagged_Membership): Adding support for interface as the left operand. gcc/testsuite/ * gnat.dg/interface7.adb: New testcase. From-SVN: r260738
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/exp_ch4.adb2
-rw-r--r--gcc/ada/sem_res.adb1
3 files changed, 9 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index dfe117a..d20be7e 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,11 @@
+2018-05-25 Javier Miranda <miranda@adacore.com>
+
+ * sem_res.adb (Resolve_Membership_Op): Allow the use of the membership
+ test when the left operand is a class-wide interface and the right
+ operand is not a class-wide type.
+ * exp_ch4.adb (Tagged_Membership): Adding support for interface as the
+ left operand.
+
2018-05-25 Ed Schonberg <schonberg@adacore.com>
* exp_aggr.adb (Flatten): A quantified expression cannot be duplicated
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 3378580..65de38e 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -13891,7 +13891,7 @@ package body Exp_Ch4 is
Selector_Name =>
New_Occurrence_Of (First_Tag_Component (Left_Type), Loc));
- if Is_Class_Wide_Type (Right_Type) then
+ if Is_Class_Wide_Type (Right_Type) or else Is_Interface (Left_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,
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 6329d92..a71e583 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -9032,7 +9032,6 @@ package body Sem_Res is
elsif Ada_Version >= Ada_2005
and then Is_Class_Wide_Type (Etype (L))
and then Is_Interface (Etype (L))
- and then Is_Class_Wide_Type (Etype (R))
and then not Is_Interface (Etype (R))
then
return;