diff options
author | Raphaël AMIARD <amiard@adacore.com> | 2024-09-04 08:24:26 +0000 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-10-25 11:08:59 +0200 |
commit | a8bfc4dede003c76123f44eaafb374cb6dbcc1ec (patch) | |
tree | e99ad07596fce48e8be90b9121325f51474dcd14 /gcc | |
parent | 1c298fc41512a1062f348eb54d54d01697a66ffc (diff) | |
download | gcc-a8bfc4dede003c76123f44eaafb374cb6dbcc1ec.zip gcc-a8bfc4dede003c76123f44eaafb374cb6dbcc1ec.tar.gz gcc-a8bfc4dede003c76123f44eaafb374cb6dbcc1ec.tar.bz2 |
ada: Inspect deferred constant completions in missing contexts
Namely declare expressions and statement lists, which can have object
declarations in -gnatX mode.
gcc/ada/ChangeLog:
* sem_util.ads: Introduce Inspect_Deferred_Constant_Completion
on a single object declaration, to better factorize the code
* sem_util.adb: Introduce aforementioned overload
* sem_ch4.adb (Analyze_Expression_With_Actions): Check deferred
constant completions
* sem_ch5.adb (Analyze_Statements): Check deferred constant
completions
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_ch4.adb | 2 | ||||
-rw-r--r-- | gcc/ada/sem_ch5.adb | 2 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 16 | ||||
-rw-r--r-- | gcc/ada/sem_util.ads | 5 |
4 files changed, 19 insertions, 6 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 9afaa89..2d91777 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -2414,6 +2414,8 @@ package body Sem_Ch4 is case Nkind (A) is when N_Object_Declaration => + Inspect_Deferred_Constant_Completion (A); + if Nkind (Object_Definition (A)) = N_Access_Definition then Error_Msg_N ("anonymous access type not allowed in declare_expression", diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 30fee6e..131195a 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -4255,6 +4255,8 @@ package body Sem_Ch5 is ("implicit label declaration for & is hidden#", Identifier (S)); end if; + else + Inspect_Deferred_Constant_Completion (S); end if; Next (S); diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ac64b1c..12437cc 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -14811,13 +14811,8 @@ package body Sem_Util is -- Inspect_Deferred_Constant_Completion -- ------------------------------------------ - procedure Inspect_Deferred_Constant_Completion (Decls : List_Id) is - Decl : Node_Id; - + procedure Inspect_Deferred_Constant_Completion (Decl : Node_Id) is begin - Decl := First (Decls); - while Present (Decl) loop - -- Deferred constant signature if Nkind (Decl) = N_Object_Declaration @@ -14838,6 +14833,15 @@ package body Sem_Util is Defining_Identifier (Decl)); end if; + end Inspect_Deferred_Constant_Completion; + + procedure Inspect_Deferred_Constant_Completion (Decls : List_Id) is + Decl : Node_Id; + + begin + Decl := First (Decls); + while Present (Decl) loop + Inspect_Deferred_Constant_Completion (Decl); Next (Decl); end loop; end Inspect_Deferred_Constant_Completion; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index eccbd43..22ee23a 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1718,6 +1718,11 @@ package Sem_Util is -- prefix is an access type, rewrite the access type node N (which is the -- prefix, e.g. of an indexed component) as an explicit dereference. + procedure Inspect_Deferred_Constant_Completion (Decl : Node_Id); + -- If Decl is a constant object declaration without a default value, check + -- whether it has been completed by a full constant declaration or an + -- Import pragma. Emit an error message if that is not the case. + procedure Inspect_Deferred_Constant_Completion (Decls : List_Id); -- Examine all deferred constants in the declaration list Decls and check -- whether they have been completed by a full constant declaration or an |