diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-10-10 15:25:03 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-10-10 15:25:03 +0000 |
commit | 55160f6c7c838a2e35895cb741fff5ea237b1260 (patch) | |
tree | 0fbb4523c1bef3d0f99b078aa3af3a452efc8a3f | |
parent | dfdd3de1238531889e65fc4c5498a3a5f28ff570 (diff) | |
download | gcc-55160f6c7c838a2e35895cb741fff5ea237b1260.zip gcc-55160f6c7c838a2e35895cb741fff5ea237b1260.tar.gz gcc-55160f6c7c838a2e35895cb741fff5ea237b1260.tar.bz2 |
[Ada] Spurious visibility error on formal package with Abstract_State
2019-10-10 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch12.adb (Analyze_Formal_Package_Declaration): Propagate
an aspect specification for Abstract_State from generic package
to formal package, so that it is available when analyzing the
constructed formal.
From-SVN: r276829
-rw-r--r-- | gcc/ada/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/sem_ch12.adb | 38 |
2 files changed, 43 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 449c0ab..c5e3f82 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,6 @@ -2019-10-10 Eric Botcazou <ebotcazou@adacore.com> +2019-10-10 Ed Schonberg <schonberg@adacore.com> - * sem_ch6.adb (Set_Actual_Subtypes): Put the freeze node of the - actual subtype after its declaration when the type of the formal - has a predicate.
\ No newline at end of file + * sem_ch12.adb (Analyze_Formal_Package_Declaration): Propagate + an aspect specification for Abstract_State from generic package + to formal package, so that it is available when analyzing the + constructed formal.
\ No newline at end of file diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 4e74f9a..d9fa255 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -2925,6 +2925,41 @@ package body Sem_Ch12 is Set_Ekind (Formal, E_Package); Set_Etype (Formal, Standard_Void_Type); Set_Inner_Instances (Formal, New_Elmt_List); + + -- It is unclear that any aspects can apply to a formal package + -- declaration, given that they look like a hidden comformance + -- requirement on the corresponding actual. However, Abstract_State + -- must be treated specially because it generates declarations that + -- must appear before other declarations in the specification and + -- must be analyzed at once. + + if Present (Aspect_Specifications (Gen_Decl)) then + if No (Aspect_Specifications (N)) then + Set_Aspect_Specifications (N, New_List); + Set_Has_Aspects (N); + end if; + + declare + ASN : Node_Id := First (Aspect_Specifications (Gen_Decl)); + New_A : Node_Id; + + begin + while Present (ASN) loop + if Get_Aspect_Id (ASN) = Aspect_Abstract_State then + New_A := + Copy_Generic_Node (ASN, Empty, Instantiating => True); + Set_Entity (New_A, Formal); + Set_Analyzed (New_A, False); + Append (New_A, Aspect_Specifications (N)); + Analyze_Aspect_Specifications (N, Formal); + exit; + end if; + + Next (ASN); + end loop; + end; + end if; + Push_Scope (Formal); -- Manually set the SPARK_Mode from the context because the package @@ -3023,6 +3058,9 @@ package body Sem_Ch12 is <<Leave>> if Has_Aspects (N) then + -- Unclear that any other aspects may appear here, snalyze them + -- for completion, given that the grammar allows their appearance. + Analyze_Aspect_Specifications (N, Pack_Id); end if; |