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] Fix wrong call to protected function returning VFA type


This is a small regression present on the mainline and 7 branch: the call to a 
protected function returning a composite type with Volatile_Full_Access aspect 
or pragma yields a segfault at run time.

Tested on x86-64/Linux, applied on the mainline and 7 branch.


2018-03-10  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (node_has_volatile_full_access) <N_Identifier>:
	Consider only entities for objects.


2018-03-10  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/prot3.adb: New test.
	* gnat.dg/prot3_pkg.ad[sb]: New helper.

-- 
Eric Botcazou
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 258411)
+++ gcc-interface/trans.c	(working copy)
@@ -4082,6 +4082,8 @@ node_has_volatile_full_access (Node_Id g
     case N_Identifier:
     case N_Expanded_Name:
       gnat_entity = Entity (gnat_node);
+      if (!Is_Object (gnat_entity))
+	break;
       return Is_Volatile_Full_Access (gnat_entity)
 	     || Is_Volatile_Full_Access (Etype (gnat_entity));
 
package body Prot3_Pkg is
   
   protected body Prot is
      function Fn (J : Short_Integer) return Rec
      is
      begin
	 return (V1 => J * J,
		 V2 => J);
      end;
      
      procedure Foo (J : Short_Integer) is
      begin
	 Val := Fn (J);
      end;
   end Prot;
   
end Prot3_Pkg;
package Prot3_Pkg is
   
   type Rec is record
      V1 : Short_Integer;
      V2 : Short_Integer;
   end record with Volatile_Full_Access;
   
   protected type Prot is
      procedure Foo (J : Short_Integer);
   private
      Val : Rec;
   end Prot;
   
   P : Prot;
   
end Prot3_Pkg;
--  { dg-do run }

with Prot3_Pkg; use Prot3_Pkg;

procedure Prot3 is
begin
   P.Foo (4);
end;

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