diff options
Diffstat (limited to 'gcc/ada/sem_ch4.adb')
-rw-r--r-- | gcc/ada/sem_ch4.adb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 3931957..a03c465 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -881,12 +881,24 @@ package body Sem_Ch4 is S : Entity_Id; begin + -- Do not perform the check while preanalyzing the enclosing context + -- because the call is not in its final place. Premature attempts to + -- verify the placement lead to bogus errors. + + if In_Spec_Expression then + return; + -- The ghost subprogram appears inside an assertion expression + -- which is one of the allowed cases. - if In_Assertion_Expression (N) then + elsif In_Assertion_Expression (N) then return; + -- Otherwise see if it inside another ghost subprogram + else + -- Loop to climb scopes + S := Current_Scope; while Present (S) and then S /= Standard_Standard loop @@ -898,11 +910,14 @@ package body Sem_Ch4 is S := Scope (S); end loop; - end if; - Error_Msg_N - ("call to ghost subprogram must appear in assertion expression or " - & "another ghost subprogram", N); + -- If we fall through the loop it was not within another + -- ghost subprogram, so we have bad placement. + + Error_Msg_N + ("call to ghost subprogram must appear in assertion expression " + & "or another ghost subprogram", N); + end if; end Check_Ghost_Subprogram_Call; -------------------------------------------------- |