This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Crash on transient classwide limited view on RHS of short-circuit


This change fixes a compiler crash that would occur in some cases where
an expression involving transient return values of a limited view of a
class-wide interface type occur on the right hand side of a short circuit
operator.

The following compilation must be accepted quietly:

$ gcc -c par-ed.adb
limited with Int2;
package Int1 is
   type Int1 is interface;
   type Ref_Int1 is access Int1'Class;
   type Ref_Int1_List is array (Positive range <>) of Ref_Int1;
   function F (This : Int1) return Int2.Int2'Class is abstract;
end Int1;
package Int2 is
   type Int2 is interface;
   function Fullname (This : Int2) return String is abstract;
end Int2;
with Int1;
with Int2;
package Par is end;
package body Par.Ed is

   function Find_Toplevel
     (X : Boolean;
      Tls : Int1.Ref_Int1_List;
      Tl : Int1.Int1'Class)
      return Natural
   is
      Res : Natural := 0;
      use type Int2.Int2'Class;
   begin
      for I in Tls'Range loop
         if X
           and then Tl.F.Fullname = Tls (I).all.F.Fullname
         then
            Res := I;
            exit;
         end if;
      end loop;
      return Res;
   end Find_Toplevel;
end;
package Par.Ed is

   function Find_Toplevel
     (X : Boolean;
      Tls : Int1.Ref_Int1_List;
      Tl : Int1.Int1'Class)
      return Natural;

end;

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

2014-07-16  Thomas Quinot  <quinot@adacore.com>

	* exp_ch4.adb (Find_Hook_Context): New subprogram, extracted
	from Process_Transient_Oject.
	* exp_ch4.ads: Ditto.
	* exp_ch9.adb (Build_Class_Wide_Master): Insert the _master
	declaration as an action on the topmost enclosing expression,
	not on a possibly conditional subexpreession.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]