diff options
author | Ed Schonberg <schonberg@adacore.com> | 2017-01-23 13:31:43 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-01-23 14:31:43 +0100 |
commit | d268147dea8efee7a66e409e7cba492ab4679f29 (patch) | |
tree | cd6a7a5446c06599bb38427f0ad658fcfda1bae7 /gcc | |
parent | dafe11cd1851fecb7b7bc780410be394fc99142a (diff) | |
download | gcc-d268147dea8efee7a66e409e7cba492ab4679f29.zip gcc-d268147dea8efee7a66e409e7cba492ab4679f29.tar.gz gcc-d268147dea8efee7a66e409e7cba492ab4679f29.tar.bz2 |
sem_prag.adb (Default_Initial_Condition): If the desired type declaration is a derived type declaration with discriminants...
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/ada/sem_ch13.adb | 15 | ||||
-rw-r--r-- | gcc/ada/sem_prag.adb | 8 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 1 |
4 files changed, 30 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index b396520..53d4bc3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -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. diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 5ac1c29..ac1e02c 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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 diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index c44c2ab..cae36e6 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -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 diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 40a72f7..c5d5473 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -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 |