r260734 - in /trunk/gcc/ada: ChangeLog sem_ch6....

pmderodat@gcc.gnu.org pmderodat@gcc.gnu.org
Fri May 25 09:04:00 GMT 2018


Author: pmderodat
Date: Fri May 25 09:04:42 2018
New Revision: 260734

URL: https://gcc.gnu.org/viewcvs?rev=260734&root=gcc&view=rev
Log:
[Ada] Crash on classwide precondition on subprogram with stub

This patch allows the compiler to handle properly a classwide precondition
on a primitive operation whose body is a stub and a separate subunit.

Executing:

   gnatmake -gnata -q check
   ./check

must yield:

   precondition violated

----
with Text_IO;
with Msg_Data_Block_Decoder; use Msg_Data_Block_Decoder;
procedure Check is
   Thing : T_Msg_Data_Block_Decoder;
   Value : Integer;
begin
   begin
      Value := Get_Long_Term_Corrections (Thing);
   exception
      when others => Text_IO.Put_Line ("precondition violated");
   end;
end Check;
----
package Msg_Data_Block_Decoder is
   pragma Preelaborate;
   type T_Msg_Data_Block_Decoder is Tagged Limited null record;

   type T_Msg_Data_Block_Decoder_Class_Access is
       access all T_Msg_Data_Block_Decoder'Class;

   function Get_Decoded_Data (This : in T_Msg_Data_Block_Decoder)
      return Integer;

   function Get_Long_Term_Corrections
     (This : in T_Msg_Data_Block_Decoder) return Integer  with
       Pre'
        Class => Get_Decoded_Data (T_Msg_Data_Block_Decoder'Class (This)) = 2;

end Msg_Data_Block_Decoder;
----
package body Msg_Data_Block_Decoder is

   function Get_Long_Term_Corrections (This : in T_Msg_Data_Block_Decoder)
   return Integer is separate;

   function Get_Decoded_Data (This : in T_Msg_Data_Block_Decoder)
     return Integer is
   begin
     return 0;
   end Get_Decoded_Data;

end Msg_Data_Block_Decoder;
----
separate (Msg_Data_Block_Decoder)
function Get_Long_Term_Corrections (This : in T_Msg_Data_Block_Decoder)
   return Integer is
begin
  return 0;
end Get_Long_Term_Corrections;

2018-05-25  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not create
	Class_Wide_Clone_Body when analyzing a subprogram_body_stub: the clone
	is created when the proper body of the stub is analyzed.
	* sem_util.adb (ZBuild_Class_Wide_Clone_Body): If the subprogram body
	is the proper body of a subunit, the cloned body must be inserted in
	the declarative list that contains the stub.

Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/sem_ch6.adb
    trunk/gcc/ada/sem_util.adb



More information about the Gcc-cvs mailing list