[Ada] Improve error on missing with clause
authorArnaud Charlet <charlet@adacore.com>
Tue, 8 Sep 2020 20:09:16 +0000 (16:09 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 26 Oct 2020 08:58:56 +0000 (04:58 -0400)
gcc/ada/

* sem_ch8.adb (Find_Direct_Name.Undefined): Handle known unit
names with 3 selectors.

gcc/ada/sem_ch8.adb

index 35c6f60..69430a6 100644 (file)
@@ -5551,9 +5551,25 @@ package body Sem_Ch8 is
               and then N = Prefix (Parent (N))
               and then Is_Known_Unit (Parent (N))
             then
-               Error_Msg_Node_2 := Selector_Name (Parent (N));
-               Error_Msg_N -- CODEFIX
-                 ("\\missing `WITH &.&;`", Prefix (Parent (N)));
+               declare
+                  P : Node_Id := Parent (N);
+               begin
+                  Error_Msg_Name_1 := Chars (N);
+                  Error_Msg_Name_2 := Chars (Selector_Name (P));
+
+                  if Nkind (Parent (P)) = N_Selected_Component
+                    and then Is_Known_Unit (Parent (P))
+                  then
+                     P := Parent (P);
+                     Error_Msg_Name_3 := Chars (Selector_Name (P));
+                     Error_Msg_N -- CODEFIX
+                       ("\\missing `WITH %.%.%;`", N);
+
+                  else
+                     Error_Msg_N -- CODEFIX
+                       ("\\missing `WITH %.%;`", N);
+                  end if;
+               end;
             end if;
 
             --  Now check for possible misspellings