diff mbox

[Ada] Crash on illegal program with -gnatf.

Message ID 20151016123307.GA23992@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 16, 2015, 12:33 p.m. UTC
This patch fixes a crash in the compiler when reporting an error on an illegal
prefixed call whose prefix is overloaded, one of its interpretations has
an untagged type, and All_Errors_Mode is set.

No short example available.

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

2015-10-16  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch4.adb (Try_Object_Operation, Try_One_Interpretation):
	Do not reset the Obj_Type of the prefix if an interpretation
	involves an untagged type, to prevent a crash when analyzing an
	illegal program in All_Errors mode.
diff mbox

Patch

Index: sem_ch4.adb
===================================================================
--- sem_ch4.adb	(revision 228864)
+++ sem_ch4.adb	(working copy)
@@ -8135,6 +8135,12 @@ 
       -----------------------------------
 
       procedure Try_One_Prefix_Interpretation (T : Entity_Id) is
+
+         --  If the interpretation does not have a valid candidate type,
+         --  preserve current value of Obj_Type for subsequent errors.
+
+         Prev_Obj_Type : constant Entity_Id := Obj_Type;
+
       begin
          Obj_Type := T;
 
@@ -8167,6 +8173,10 @@ 
          if not Is_Tagged_Type (Obj_Type)
            or else Is_Incomplete_Type (Obj_Type)
          then
+
+            --  Restore previous type if current one is not legal candidate.
+
+            Obj_Type := Prev_Obj_Type;
             return;
          end if;