diff options
author | Bob Duff <duff@adacore.com> | 2019-12-16 10:34:03 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-12-16 10:34:03 +0000 |
commit | dce1ef7a34b2b80d02e36ebc464e642a84b15f2d (patch) | |
tree | 0670c227bf249f7ff2ee409f30a58a5ad98c5954 /gcc | |
parent | 9c9535f974cb9a348fd99a90d0ab08a32583d337 (diff) | |
download | gcc-dce1ef7a34b2b80d02e36ebc464e642a84b15f2d.zip gcc-dce1ef7a34b2b80d02e36ebc464e642a84b15f2d.tar.gz gcc-dce1ef7a34b2b80d02e36ebc464e642a84b15f2d.tar.bz2 |
[Ada] Better error message for "is null" subunit
2019-12-16 Bob Duff <duff@adacore.com>
gcc/ada/
* sem_ch10.adb (Analyze_Subunit): Give an error if the subunit
is not a proper body. This hides the confusing "duplicate body"
message that was previously given.
From-SVN: r279424
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/sem_ch10.adb | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 2151a4e..88732bd 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-12-16 Bob Duff <duff@adacore.com> + + * sem_ch10.adb (Analyze_Subunit): Give an error if the subunit + is not a proper body. This hides the confusing "duplicate body" + message that was previously given. + 2019-12-16 Eric Botcazou <ebotcazou@adacore.com> * exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Document diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index ae8bca7..ee18b37 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -2433,6 +2433,20 @@ package body Sem_Ch10 is Install_Elaboration_Model (Par_Unit); + -- The syntax rules require a proper body for a subprogram subunit + + if Nkind (Proper_Body (Sinfo.Unit (N))) = N_Subprogram_Declaration then + if Null_Present (Specification (Proper_Body (Sinfo.Unit (N)))) then + Error_Msg_N + ("null procedure not allowed as subunit", + Proper_Body (Unit (N))); + else + Error_Msg_N + ("subprogram declaration not allowed as subunit", + Defining_Unit_Name (Specification (Proper_Body (Unit (N))))); + end if; + end if; + Analyze (Proper_Body (Unit (N))); Remove_Context (N); |