diff mbox

[Ada] Crash on ambiguous allocator expression

Message ID 20170427090657.GA79821@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet April 27, 2017, 9:06 a.m. UTC
This patch corrects a crash that was produced when comparing "null" to an
allocator due to type Any_Access being improperly setup with no designated
type. Because both operands require a specific type from context such a case
will now emit the proper "ambiguous operands" error.

------------
-- Source --
------------

--  forty_two.adb

with Ada.Text_IO; use Ada.Text_IO;
procedure Forty_Two is
   type R is record
      A : Boolean;
   end record;
   B : Boolean;
begin
   B := (null = new R);
end;

----------------------------
-- Compilation and output --
----------------------------

& gnatmake -q forty_two.adb
forty_two.adb:8:14: ambiguous operands for equality
gnatmake: "forty_two.adb" compilation error

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

2017-04-27  Justin Squirek  <squirek@adacore.com>

	* cstand.adb (Create_Standard): Correctly set
	Directly_Designated_Type for Any_Access.
	* sem_type.adb (Covers): Minor grammar fixes.
diff mbox

Patch

Index: cstand.adb
===================================================================
--- cstand.adb	(revision 247293)
+++ cstand.adb	(working copy)
@@ -1194,6 +1194,7 @@ 
       Set_Etype             (Any_Access, Any_Access);
       Init_Size             (Any_Access, System_Address_Size);
       Set_Elem_Alignment    (Any_Access);
+      Set_Directly_Designated_Type (Any_Access, Any_Type);
 
       Any_Character := New_Standard_Entity ("a character type");
       Set_Ekind             (Any_Character, E_Enumeration_Type);
Index: sem_type.adb
===================================================================
--- sem_type.adb	(revision 247293)
+++ sem_type.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2016, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2017, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -802,8 +802,8 @@ 
    --  Start of processing for Covers
 
    begin
-      --  If either operand missing, then this is an error, but ignore it (and
-      --  pretend we have a cover) if errors already detected, since this may
+      --  If either operand is missing, then this is an error, but ignore it
+      --  and pretend we have a cover if errors already detected since this may
       --  simply mean we have malformed trees or a semantic error upstream.
 
       if No (T1) or else No (T2) then