[Ada] Assert failure on incorrect code
authorArnaud Charlet <charlet@adacore.com>
Fri, 19 Jun 2020 13:50:34 +0000 (09:50 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 27 Jul 2020 08:05:21 +0000 (04:05 -0400)
gcc/ada/

* lib-xref.adb (Generate_Reference): Protect against malformed
tree in case of severe errors.
* sem_ch8.adb (Add_Implicit_Operator): Ditto.

gcc/ada/lib-xref.adb
gcc/ada/sem_ch8.adb

index ac59ccc094f6ee3c7eb11f4c65c80077ff73e623..ae4b4c7b744ce463f3ecccd742ed127ba67f6d9e 100644 (file)
@@ -595,7 +595,12 @@ package body Lib.Xref is
    --  Start of processing for Generate_Reference
 
    begin
-      pragma Assert (Nkind (E) in N_Entity);
+      --  May happen in case of severe errors
+
+      if Nkind (E) not in N_Entity then
+         return;
+      end if;
+
       Find_Actual (N, Formal, Call);
 
       if Present (Formal) then
index b0d91e25a683d8c2425bb10346ac65c9cb7d4967..3c10a9650c9b372c51be9f9dd345d2d1103bc5a0 100644 (file)
@@ -8212,11 +8212,13 @@ package body Sem_Ch8 is
                   else
                      Add_One_Interp (N, Predef_Op2, T);
                   end if;
-
                else
                   if not Is_Binary_Op then
                      Add_One_Interp (N, Predef_Op, T);
-                  else
+
+                  --  Predef_Op2 may be empty in case of previous errors
+
+                  elsif Present (Predef_Op2) then
                      Add_One_Interp (N, Predef_Op2, T);
                   end if;
                end if;