diff mbox

[Ada] Full views of private subtypes with unknown discriminants.

Message ID 20131014125244.GA12415@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 14, 2013, 12:52 p.m. UTC
A private subtype with unknown discriminants may have a full view that is
a constrained discriminated subtype. The Is_Constrained flag must be properly
set for this full view, to prevent spurious errors when the subtype is used
in an object declaration with a dynamically tagged expression.

The execution of:

     gnatmake -q -gna05 extra_class_main.adb
     extra_class_main

must yield:

    FALSE
     123
diff mbox

Patch

Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb	(revision 203522)
+++ sem_ch3.adb	(working copy)
@@ -10393,6 +10393,14 @@ 
             Set_First_Entity (Full, First_Entity (Full_Base));
             Set_Last_Entity  (Full, Last_Entity (Full_Base));
 
+            --  If the underlying base type is constrained, we know that the
+            --  full view of the subtype is constrained as well (the converse
+            --  is not necessarily true).
+
+            if Is_Constrained (Full_Base) then
+               Set_Is_Constrained (Full);
+            end if;
+
          when others =>
             Copy_Node (Full_Base, Full);