diff mbox series

[COMMITTED,20/30] ada: Further refine 'Super attribute

Message ID 20240610090747.1557638-20-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/30] ada: Refactor checks for Refined_Global in generic instances | expand

Commit Message

Marc Poulhiès June 10, 2024, 9:07 a.m. UTC
From: Justin Squirek <squirek@adacore.com>

This patch adds the restriction on 'Super such that it cannot apply to objects
whose parent type is an interface.

gcc/ada/

	* sem_attr.adb (Analyze_Attribute): Add check for interface parent
	types.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_attr.adb | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 4fd270aeae9..2fd95f36d65 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -6683,6 +6683,12 @@  package body Sem_Attr is
             elsif Depends_On_Private (P_Type) then
                Error_Attr_P ("prefix type of % is a private extension");
 
+            --  Disallow view conversions to interfaces in order to avoid
+            --  depending on whether an interface type is used as a parent
+            --  or progenitor type.
+
+            elsif Is_Interface (Node (First_Elmt (Parents))) then
+               Error_Attr_P ("type of % cannot be an interface");
             end if;
 
             --  Generate a view conversion and analyze it