aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-05-09 13:37:13 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-07 05:26:53 -0400
commit1948dcab167efef1d00117d71c440aff0319dbda (patch)
treed0ff22c096f3c334f13efe550a32ae934afd3736 /gcc
parent62226c35545bcda44ae97630658d1ad8129ab0c6 (diff)
downloadgcc-1948dcab167efef1d00117d71c440aff0319dbda.zip
gcc-1948dcab167efef1d00117d71c440aff0319dbda.tar.gz
gcc-1948dcab167efef1d00117d71c440aff0319dbda.tar.bz2
[Ada] Spurious elaboration warnings with -gnatc and null procedures
gcc/ada/ * sem_elab.adb (Is_Guaranteed_ABE): Take into account null procedures.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_elab.adb19
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb
index 50f0feb..e17e927 100644
--- a/gcc/ada/sem_elab.adb
+++ b/gcc/ada/sem_elab.adb
@@ -9246,6 +9246,7 @@ package body Sem_Elab is
Target_Decl : Node_Id;
Target_Body : Node_Id) return Boolean
is
+ Spec : Node_Id;
begin
-- Avoid cascaded errors if there were previous serious infractions.
-- As a result the scenario will not be treated as a guaranteed ABE.
@@ -9266,12 +9267,20 @@ package body Sem_Elab is
return Earlier_In_Extended_Unit (N, Target_Body);
-- Otherwise the body has not been encountered yet. The scenario
- -- is a guaranteed ABE since the body will appear later. It is
- -- assumed that the caller has already ensured that the scenario
- -- is ABE-safe because optional bodies are not considered here.
+ -- is a guaranteed ABE since the body will appear later, unless
+ -- this is a null specification, which can occur if expansion is
+ -- disabled (e.g. -gnatc or GNATprove mode). It is assumed that
+ -- the caller has already ensured that the scenario is ABE-safe
+ -- because optional bodies are not considered here.
else
- return True;
+ Spec := Specification (Target_Decl);
+
+ if Nkind (Spec) /= N_Procedure_Specification
+ or else not Null_Present (Spec)
+ then
+ return True;
+ end if;
end if;
end if;
@@ -9574,7 +9583,7 @@ package body Sem_Elab is
Error_Msg_N ("\Program_Error will be raised at run time", Call);
end if;
- -- Mark the call as a guarnateed ABE
+ -- Mark the call as a guaranteed ABE
Set_Is_Known_Guaranteed_ABE (Call);