This is the mail archive of the gcc-cvs@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]

r262785 - in /trunk/gcc/ada: ChangeLog exp_ch13...


Author: pmderodat
Date: Tue Jul 17 08:07:52 2018
New Revision: 262785

URL: https://gcc.gnu.org/viewcvs?rev=262785&root=gcc&view=rev
Log:
[Ada] Crash processing abstract state aspect of a package

The compiler may crash processing an aspect Part_Of used in a
package spec which has also an Initial_Condition aspect. After
this patch the following test compiles fine.

package P
with
  SPARK_Mode => On,
  Abstract_State => (Count_State),
  Initial_Condition => (Get_Count = 0)              -- Test
is
   type Count_Type is range 0 .. 16;

   function Get_Count return Count_Type;

   procedure Dummy;

private
   C: Count_Type := 0 with Part_Of => Count_State;  -- Test

   function Get_Count return Count_Type is (C);
end P;

package body P
with
  SPARK_Mode => On,
  Refined_State => (Count_State => C)
is
  procedure Dummy is null;
end P;

Command: gcc -c p.adb

2018-07-17  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* exp_ch13.adb (Expand_N_Freeze_Entity): Handle subtype declared for an
	iterator.
	* freeze.adb (Freeze_Expression): Handle freeze of an entity defined
	outside of a subprogram body. This case was previously handled during
	preanalysis; the frozen entities were remembered and left pending until
	we continued freezeing entities outside of the subprogram. Now, when
	climbing the parents chain to locate the correct placement for the
	freezeing node, we check if the entity can be frozen and only when no
	enclosing node is marked as Must_Not_Freeze the entity is frozen.
	* sem_ch3.ads (Preanalyze_Default_Expression): Declaration moved to the
	package body.
	* sem_ch3.adb (Preanalyze_Default_Expression): Code adjusted to invoke
	the new subprogram Preanalyze_With_Freezing_And_Resolve.
	* sem_ch6.adb (Preanalyze_Formal_Expression): New subprogram.
	(Analyze_Expression_Function, Process_Formals): Invoke
	Preanalyze_Formal_Expression instead of Preanalyze_Spec_Expression
	since the analysis of the formals may freeze entities.
	(Analyze_Subprogram_Body_Helper): Skip building the body of the
	class-wide clone for eliminated subprograms.
	* sem_res.ads, sem_res.adb (Preanalyze_And_Resolve): New subprogram.
	Its code is basically the previous version of this routine but extended
	with an additional parameter which is used to specify if during
	preanalysis we are allowed to freeze entities.  If the new parameter is
	True then the subtree root node is marked as Must_Not_Freeze and no
	entities are frozen during preanalysis.
	(Preanalyze_And_Resolve): Invokes the internal version of
	Preanalyze_And_Resolve without entity freezing.
	(Preanalyze_With_Freezing_And_Resolve): Invokes the internal version of
	Prenalyze_And_Resolve with freezing enabled.

Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/exp_ch13.adb
    trunk/gcc/ada/freeze.adb
    trunk/gcc/ada/sem_ch3.adb
    trunk/gcc/ada/sem_ch3.ads
    trunk/gcc/ada/sem_ch6.adb
    trunk/gcc/ada/sem_res.adb
    trunk/gcc/ada/sem_res.ads


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