diff mbox series

[Ada] Fix continuation message without a prior error

Message ID 20220519141618.GA3723435@adacore.com
State New
Headers show
Series [Ada] Fix continuation message without a prior error | expand

Commit Message

Pierre-Marie de Rodat May 19, 2022, 2:16 p.m. UTC
When resolution of an expanded name fails, we call routine
Error_Missing_With_Of_Known_Unit which emits an error continuation
message (i.e. an error string starting with \\). However, for error
continuations to work properly there must be some prior error, because
continuation itself doesn't set flags like Serious_Errors_Detected.

Without these flags the problematic statement is not marked with
Error_Posted, which in turn is needed to prevent cascaded errors.

In particular, when unresolved procedure call uses a direct name or an
extended name with an unknown prefix, e.g.:

  Unknown (1, 2, 3);
  Unknown.Call (1, 2, 3);

then the N_Procedure_Call statements are marked with Error_Posted. But
when a call uses an extended name with a known prefix we failed to flag
the N_Procedure_Call with Error_Posted.

Found while improving the robustness of a feature that detects
uninitialized scalar objects.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_ch8.adb (Find_Expanded_Name): Emit a main error message
	before adding a continuation with the call to
	Error_Missing_With_Of_Known_Unit.
diff mbox series

Patch

diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -6995,6 +6995,8 @@  package body Sem_Ch8 is
                                            Standard_Standard)
                then
                   if not Error_Posted (N) then
+                     Error_Msg_NE
+                       ("& is not a visible entity of&", Prefix (N), Selector);
                      Error_Missing_With_Of_Known_Unit (Prefix (N));
                   end if;