aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch8.adb
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2024-10-17 12:04:45 -0400
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-11-04 16:57:59 +0100
commit16007e34ef4019f7cba9c9b718f5e43cc045e920 (patch)
treec5ed4f4e1f4d3cd772a61edc2aef17e7493fa3f1 /gcc/ada/sem_ch8.adb
parentf6a8c07743d74430da761e3ca7a8516ac663ef94 (diff)
downloadgcc-16007e34ef4019f7cba9c9b718f5e43cc045e920.zip
gcc-16007e34ef4019f7cba9c9b718f5e43cc045e920.tar.gz
gcc-16007e34ef4019f7cba9c9b718f5e43cc045e920.tar.bz2
ada: Split Library_Unit using multiple wrappers
The Library_Unit field was used for all sorts of different purposes, which led to confusing code. This patch splits Library_Unit into much more specific wrapper subprograms that should be called instead of [Set_]Library_Unit. Predicates and pragmas Assert are used to catch misuses of these. We document the semantics, especially "surprising" cases (e.g. internally-generated with clauses can refer to package bodies). This change does not fix gigi, codepeer, spark, or llvm to use the new wrappers; so far, they are used only in the GNAT front end. gcc/ada/ChangeLog: * sinfo.ads (Library_Unit): Rewrite documentation. Note that the "??? not (always) true..." comment was not true; the Subunit_Parent never points to the spec. (N_Compilation_Unit): Improve documentation. The Aux_ node was not created to solve the mentioned problems; it was created because the size of nodes was limited. Misc doc improvements. * sinfo-utils.ads: Add new wrappers for Library_Unit field. Use subtypes with predicates for the parameters. (First_Real_Statement): Still used in codepeer. * sinfo-utils.adb: Add new wrappers for Library_Unit field, with suitable assertions. * sem_prag.adb: Use new field wrapper names. (Matching_Name): New name for Same_Name to avoid potential confusion with the other function with the same name (Sem_Util.Same_Name), which is also called in this same file. (Matching_Convention): Change Same_Convention to match Matching_Name. * sem_util.ads (Same_Name): Improve comments; the old comment implied that it works for all names, which was not true. * sem_util.adb: Use new field wrapper names. * gen_il-gen.adb: Rename N_Unit_Body to be N_Lib_Unit_Body. Plain "unit" is ambiguous in Ada (library unit, compilation unit, program unit, etc). Add new union types N_Lib_Unit_Declaration and N_Lib_Unit_Renaming_Declaration. * gen_il-gen-gen_nodes.adb (Compute_Ranges): Raise exception earlier (it is already raised later, in Verify_Type_Table). Add a comment explaining why it might be raised. * gen_il-types.ads: Rename N_Unit_Body to be N_Lib_Unit_Body, and add new N_Lib_Unit_Declaration and N_Lib_Unit_Renaming_Declaration. * einfo.ads: Fix obsolete comment (was left over from before the "variable-sized nodes"). * exp_ch7.adb: Use new field wrapper names. * exp_disp.adb: Use new field wrapper names. * exp_unst.adb: Use new field wrapper names. * exp_util.adb: Use new field wrapper names. * fe.h: Add new field wrapper names. These are currently not used in gigi, but this change prepares for using them in gigi. * inline.adb: Use new field wrapper names. * lib.adb: Use new field wrapper names. Comment improvements. * lib-load.adb: Use new field wrapper names. Minor cleanup. * lib-writ.adb: Use new field wrapper names. * live.adb: Use new field wrapper names. * par-load.adb: Use new field wrapper names. Comment improvements. Minor cleanup. * rtsfind.adb: Use new field wrapper names. * sem.adb: Use new field wrapper names. * sem_ch10.adb: Use new field wrapper names. Comment improvements. Minor cleanup. * sem_ch12.adb: Use new field wrapper names. * sem_ch7.adb: Use new field wrapper names. * sem_ch8.adb: Use new field wrapper names. * sem_elab.adb: Use new field wrapper names. Comment improvements. * errout.adb (Output_Source_Line): Fix blowup in some obscure cases, where List_Pragmas is not fully set up.
Diffstat (limited to 'gcc/ada/sem_ch8.adb')
-rw-r--r--gcc/ada/sem_ch8.adb5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 0c25c95..2007db3 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -9998,7 +9998,8 @@ package body Sem_Ch8 is
or else (Nkind (The_Unit) = N_Subprogram_Body
and then not Acts_As_Spec (Cunit (Current_Sem_Unit))))
then
- With_Sys := Find_System (Library_Unit (Cunit (Current_Sem_Unit)));
+ With_Sys :=
+ Find_System (Spec_Or_Body_Lib_Unit (Cunit (Current_Sem_Unit)));
end if;
if No (With_Sys) and then Present (N) then
@@ -10055,7 +10056,7 @@ package body Sem_Ch8 is
Set_Corresponding_Spec (Withn, System_Aux_Id);
Set_First_Name (Withn);
Set_Is_Implicit_With (Withn);
- Set_Library_Unit (Withn, Cunit (Unum));
+ Set_Withed_Lib_Unit (Withn, Cunit (Unum));
Insert_After (With_Sys, Withn);
Mark_Rewrite_Insertion (Withn);