diff options
author | Javier Miranda <miranda@adacore.com> | 2018-07-17 08:07:52 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-07-17 08:07:52 +0000 |
commit | e4d29736249cc9c5e62b0f8b3ecfed1a93b6d73d (patch) | |
tree | aeecc5fc02b7b37f8899912235c025e22763fc8e /gcc/ada/adadecode.c | |
parent | 52afb18645d8ee2d2426d318aa078fbc9f4bcb87 (diff) | |
download | gcc-e4d29736249cc9c5e62b0f8b3ecfed1a93b6d73d.zip gcc-e4d29736249cc9c5e62b0f8b3ecfed1a93b6d73d.tar.gz gcc-e4d29736249cc9c5e62b0f8b3ecfed1a93b6d73d.tar.bz2 |
[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.
From-SVN: r262785
Diffstat (limited to 'gcc/ada/adadecode.c')
0 files changed, 0 insertions, 0 deletions