aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Moy <moy@adacore.com>2022-04-01 16:58:19 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-18 08:41:03 +0000
commitba89624e938a9309a0a8a672b2753159cf0a8a78 (patch)
tree31a0380c18e1f65638611218c53c69cbcc717d00
parent8e4f37024ada46dafe1f8fd8464f0be118c6b961 (diff)
downloadgcc-ba89624e938a9309a0a8a672b2753159cf0a8a78.zip
gcc-ba89624e938a9309a0a8a672b2753159cf0a8a78.tar.gz
gcc-ba89624e938a9309a0a8a672b2753159cf0a8a78.tar.bz2
[Ada] Spurious error on freezing of tagged types in SPARK
SPARK RM 7.7(8) mandates that the freezing point of a tagged type must occur within the so-called early call region of all its primitives. This check may lead to spurious errors due to generated constructs being considered in the search for the start of the early call region. gcc/ada/ * sem_elab.adb (Is_Suitable_Construct): Fix for generated constructs.
-rw-r--r--gcc/ada/sem_elab.adb12
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb
index caebb17..068402a 100644
--- a/gcc/ada/sem_elab.adb
+++ b/gcc/ada/sem_elab.adb
@@ -7346,7 +7346,7 @@ package body Sem_Elab is
-- is a byproduct of the parser. Such a null statement should be
-- excluded from the early call region because it carries the
-- source location of the "end" keyword, and may lead to confusing
- -- diagnistics.
+ -- diagnostics.
if Nkind (N) = N_Null_Statement
and then not Comes_From_Source (N)
@@ -7354,6 +7354,16 @@ package body Sem_Elab is
and then Nkind (Context) = N_Handled_Sequence_Of_Statements
then
return False;
+
+ -- Similarly, internally-generated objects and types may have
+ -- out-of-order source locations that confuse diagnostics, e.g.
+ -- source locations in the body for objects/types generated in
+ -- the spec.
+
+ elsif Nkind (N) in N_Full_Type_Declaration | N_Object_Declaration
+ and then not Comes_From_Source (N)
+ then
+ return False;
end if;
-- Otherwise only constructs which correspond to pure Ada