sem_prag.adb (Default_Initial_Condition): If the desired type declaration is a derive...
authorEd Schonberg <schonberg@adacore.com>
Mon, 23 Jan 2017 13:31:43 +0000 (13:31 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 23 Jan 2017 13:31:43 +0000 (14:31 +0100)
2017-01-23  Ed Schonberg  <schonberg@adacore.com>

* sem_prag.adb (Default_Initial_Condition): If the desired type
declaration is a derived type declaration with discriminants,
it is rewritten as a private type declaration.
* sem_ch13.adb (Replace_Type_References_Generic,
Visible_Component): A discriminated private type with descriminnts
has components that must be rewritten as selected components
if they appear as identifiers in an aspect expression such as
a Default_Initial_Condition.
* sem_util.adb (Defining_Entity): support N_Iterator_Specification
nodes.

From-SVN: r244809

gcc/ada/ChangeLog
gcc/ada/sem_ch13.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb

index b396520ced4cbb4d0589878d3f4ed4277f845b9e..53d4bc31e619808a797a02d107c9a5c76f9c7862 100644 (file)
@@ -1,3 +1,16 @@
+2017-01-23  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_prag.adb (Default_Initial_Condition): If the desired type
+       declaration is a derived type declaration with discriminants,
+       it is rewritten as a private type declaration.
+       * sem_ch13.adb (Replace_Type_References_Generic,
+       Visible_Component): A discriminated private type with descriminnts
+       has components that must be rewritten as selected components
+       if they appear as identifiers in an aspect expression such as
+       a Default_Initial_Condition.
+       * sem_util.adb (Defining_Entity): support N_Iterator_Specification
+       nodes.
+
 2017-01-23  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * ghost.ads, ghost.adb (Is_Ignored_Ghost_Unit): New routine.
index 5ac1c297a9140e11322fbd73f67dd999ac7534f9..ac1e02cfee3b9ce4a7dc5999c05b7dfb25110ba5 100644 (file)
@@ -12688,10 +12688,13 @@ package body Sem_Ch13 is
          E : Entity_Id;
 
       begin
-         if Ekind (T) /= E_Record_Type then
-            return Empty;
 
-         else
+         --  Types with nameable components are records and discriminated
+         --  private types.
+
+         if Ekind (T) = E_Record_Type
+           or else (Is_Private_Type (T) and then Has_Discriminants (T))
+         then
             E := First_Entity (T);
             while Present (E) loop
                if Comes_From_Source (E) and then Chars (E) = Comp then
@@ -12700,9 +12703,11 @@ package body Sem_Ch13 is
 
                Next_Entity (E);
             end loop;
-
-            return Empty;
          end if;
+
+         --  Nothing by that name, or type has no components.
+
+         return Empty;
       end Visible_Component;
 
    --  Start of processing for Replace_Type_References_Generic
index c44c2ab7ff27bb1dfd93aa4fcf3f35eaad2bfbc0..cae36e65caf7d31c5e3aa0a3f62c2447e74b5331 100644 (file)
@@ -13840,9 +13840,13 @@ package body Sem_Prag is
                      Error_Msg_N ("pragma % duplicates pragma declared#", N);
                   end if;
 
-               --  Skip internally generated code
+               --  Skip internally generated code. Note that derived type
+               --  declarations of untagged types with discriminants are
+               --  rewritten as private type declarations.
 
-               elsif not Comes_From_Source (Stmt) then
+               elsif not Comes_From_Source (Stmt)
+                 and then Nkind (Stmt) /= N_Private_Type_Declaration
+               then
                   null;
 
                --  The associated private type [extension] has been found, stop
index 40a72f7c9aebc73bac5a0b87336008858ce4a995..c5d5473c37e4e8814adf8f21e871872c882eb413 100644 (file)
@@ -5238,6 +5238,7 @@ package body Sem_Util is
             | N_Full_Type_Declaration
             | N_Implicit_Label_Declaration
             | N_Incomplete_Type_Declaration
+            | N_Iterator_Specification
             | N_Loop_Parameter_Specification
             | N_Number_Declaration
             | N_Object_Declaration