Martin Liska [Tue, 17 Jul 2018 09:19:27 +0000 (11:19 +0200)]
Clean up of new format of -falign-FOO.
2018-07-17 Martin Liska <mliska@suse.cz>
* align.h: New file.
* config/alpha/alpha.c (alpha_align_insns_1): Use align_functions directly.
* config/i386/i386.c (ix86_avoid_jump_mispredicts): Use new return type
align_flags of label_to_alignment.
* config/m32r/m32r.h (LOOP_ALIGN): Wrap returned values into align_flags
class.
* config/m68k/m68k.c: Do not use removed align_labels_value and
align_loops_value.
* config/nds32/nds32.h (JUMP_ALIGN): Wrap result into align_flags class.
(LOOP_ALIGN): Likewise.
(LABEL_ALIGN): Likewise.
* config/powerpcspe/powerpcspe.c (TARGET_ASM_LOOP_ALIGN_MAX_SKIP):
Remove not used macro.
(rs6000_loop_align): Change return type to align_flags.
(rs6000_loop_align_max_skip): Remove.
* config/rs6000/rs6000-protos.h (rs6000_loop_align):
Change return type to align_flags.
* config/rs6000/rs6000.c (TARGET_ASM_LOOP_ALIGN_MAX_SKIP):
Remove not used macro.
(rs6000_loop_align): Change return type to align_flags.
(rs6000_loop_align_max_skip): Remove.
* config/rx/rx.h (JUMP_ALIGN): Wrap integer values
* config/rx/rx-protos.h (rx_align_for_label): Make it
static function.
* config/rx/rx.c (rx_align_for_label): Change return type
to align_flags.
(rx_max_skip_for_label): Remove TARGET_ASM_*_ALIGN_MAX_SKIP
macro definitions.
into align_flags class.
(LABEL_ALIGN): Likewise.
(LOOP_ALIGN): Likewise.
* config/s390/s390.c (s390_label_align): Use align_flags
class member.
(s390_asm_output_function_label): Likewise.
* config/sh/sh.c (sh_override_options_after_change):
Use align_flags class directly without macros.
(find_barrier): Likewise.
(barrier_align): Likewise.
(sh_loop_align): Likewise.
* config/spu/spu.c (spu_option_override):
Use align_flags_tuple::get_value instead of removed macros.
(spu_sched_init): Likewise.
* config/spu/spu.h (GTY): Likewise.
* config/visium/visium.c (visium_option_override):
Set "8" as default secondary alignment.
* config/visium/visium.h (SUBALIGN_LOG): Define to 3
in order to guarantee secondary alignment of 8.
* coretypes.h: Include align.h header file.
* doc/tm.texi: Remove TARGET_ASM_JUMP_ALIGN_MAX_SKIP,
TARGET_ASM_LOOP_ALIGN_MAX_SKIP, TARGET_ASM_LABEL_ALIGN_MAX_SKIP
and TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP macros.
* doc/tm.texi.in: Likewise.
* final.c (struct label_alignment): Remove not used structure.
(LABEL_ALIGN): Change type to align_flags.
(LOOP_ALIGN): Likewise.
(JUMP_ALIGN): Likewise.
(default_loop_align_max_skip): Remove.
(default_label_align_max_skip): Likewise.
(default_jump_align_max_skip): Likewise.
(default_label_align_after_barrier_max_skip):
(LABEL_TO_ALIGNMENT): Change to access label_align vector.
(LABEL_TO_MAX_SKIP): Remove.
(label_to_alignment): Return align_flags type instead of integer.
(label_to_max_skip): Remove.
(align_fuzz): Use align_flags type.
(compute_alignments): Use align_flags type and use align_flags::max
to combine multiple alignments.
(grow_label_align): Grow vec instead of C array.
(update_alignments): Assign just LABEL_TO_ALIGNMENT.
(shorten_branches): Use align_flags type and use align_flags::max
to combine multiple alignments.
(final_scan_insn_1): Remove usage of secondary alignment that comes
from label alignment, but instead use proper secondary alignment
which is computed in grow_label_align.
* flags.h (struct align_flags_tuple): Move to align.h.
(struct align_flags): Likewise.
(state_align_loops): Rename to align_loops.
(state_align_jumps): Rename to align_jumps.
(state_align_labels): Rename to align_labels.
(state_align_functions): Rename to align_functions.
(align_loops_log): Remove.
(align_jumps_log): Remove.
(align_labels_log): Remove.
(align_functions_log): Remove.
(align_loops_max_skip): Remove.
(align_jumps_max_skip): Remove.
(align_labels_max_skip): Remove.
(align_functions_max_skip): Remove.
(align_loops_value): Remove.
(align_jumps_value): Remove.
(align_labels_value): Remove.
(align_functions_value): Remove.
* output.h (label_to_alignment): Change return type to align_flags.
(label_to_max_skip): Remove.
* target.def: Remove loop_align_max_skip, label_align_max_skip,
jump_align_max_skip macros.
* targhooks.h (default_loop_align_max_skip): Remove.
(default_label_align_max_skip): Likewise.
(default_jump_align_max_skip): Likewise.
(default_label_align_after_barrier_max_skip): Remove.
* toplev.c (read_log_maxskip): Use ::normalize function.
(parse_N_M): Remove not used argument and also call ::normalize.
(parse_alignment_opts): Do not pass unused arguments.
* varasm.c (assemble_start_function): Use directly align_functions
instead of removed macros.
* system.h: Do not poison removed macros.
2018-07-17 Martin Liska <mliska@suse.cz>
Ed Schonberg [Tue, 17 Jul 2018 08:13:28 +0000 (08:13 +0000)]
[Ada] Spurious error on prefixed call in an instantiation
This patch fixes a spurious error on a prefixed call in an instance, when the
generic parameters include an interface type and an abstract operation of that
type, and the actuals in the instance include an interface type and a
corresponding abstract operation of it, with a different name than the
corresponding generic subprogram parameter. The patch also fixes a similar
error involving class-wide operations and generic private types.
2018-07-17 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch4.adb (Try_Object_Operation): Handle properly a prefixed call
in an instance, when the generic parameters include an interface type
and a abstract operation of that type, and the actuals in the instance
include an interface type and a corresponding abstract operation of it,
with a different name than the corresponding generic subprogram
parameter.
gcc/testsuite/
* gnat.dg/generic_call_cw.adb, gnat.dg/generic_call_iface.adb: New
testcase.
Ed Schonberg [Tue, 17 Jul 2018 08:12:14 +0000 (08:12 +0000)]
[Ada] Fix expansion of aggregates components rewritten to raise statements
2018-07-17 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_aggr.adb (Component_OK_For_Backend): If an array component of the
enclosing record has a bound that is out of range (and that has been
rewritten as a raise statement) the aggregate is not OK for any back
end, and should be expanded into individual assignments.
The pragma Default_Scalar_Storage_Order cannot reliably be used to set the
non-default scalar storage order for a program that declares tagged types, if
it also declares user-defined primitives.
This is fixed by making Make_Tags use the same base array type as Make_DT and
Make_Secondary_DT when accessing the array of user-defined primitives.
2018-07-17 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* exp_disp.adb (Make_Tags): When the type has user-defined primitives,
build the access type that is later used by Build_Get_Prim_Op_Address
as pointing to a subtype of Ada.Tags.Address_Array.
gcc/testsuite/
* gnat.dg/sso10.adb, gnat.dg/sso10_pkg.ads: New testcase.
Patrick Bernardi [Tue, 17 Jul 2018 08:11:37 +0000 (08:11 +0000)]
[Ada] Use standard version of s-memory.adb for mingw32
This patch switches mingw32 targets to use the standard version of s-memory.adb
as Windows now has the capability of limiting the amount of memory used by
process.
2018-07-17 Patrick Bernardi <bernardi@adacore.com>
gcc/ada/
* libgnat/s-memory__mingw.adb: Remove.
* Makefile.rtl: Remove s-memory.adb target pair from the Cygwin/Mingw32
section.
This patch ensures that removal of ignored Ghost code is the absolute last
operation performed on the tree. Previously the removal was performed prior to
issuing delayed warnings, however the warning mechanism may see a heavily
modified tree and fail.
[Ada] Configuration state not observed for instance bodies
This patch ensures that the processing of instantiated and inlined bodies uses
the proper configuration context available at the point of the instantiation or
inlining.
Previously configuration pragmas which appear prior to the context items of a
unit would lose their effect when a body is instantiated or inlined.
* frontend.adb (Frontend): Update the call to Register_Config_Switches.
* inline.ads: Add new component Config_Switches to record
Pending_Body_Info which captures the configuration state of the pending
body. Remove components Version, Version_Pragma, SPARK_Mode, and
SPARK_Mode_Pragma from record Pending_Body_Info because they are
already captured in component Config_Switches.
* opt.adb (Register_Opt_Config_Switches): Rename to
Register_Config_Switches.
(Restore_Opt_Config_Switches): Rename to Restore_Config_Switches.
(Save_Opt_Config_Switches): Rename to Save_Config_Switches. This
routine is now a function, and returns the saved configuration state as
an aggregate to avoid missing an attribute.
(Set_Opt_Config_Switches): Rename to Set_Config_Switches.
* opt.ads (Register_Opt_Config_Switches): Rename to
Register_Config_Switches.
(Restore_Opt_Config_Switches): Rename to Restore_Config_Switches.
(Save_Opt_Config_Switches): Rename to Save_Config_Switches. This
routine is now a function.
(Set_Opt_Config_Switches): Rename to Set_Config_Switches.
* par.adb (Par): Update the calls to configuration switch-related
subprograms.
* sem.adb (Semantics): Update the calls to configuration switch-related
subprograms.
* sem_ch10.adb (Analyze_Package_Body_Stub): Update the calls to
configuration switch-related subprograms.
(Analyze_Protected_Body_Stub): Update the calls to configuration
switch-related subprograms.
(Analyze_Subprogram_Body_Stub): Update calls to configuration
switch-related subprograms.
* sem_ch12.adb (Add_Pending_Instantiation): Update the capture of
pending instantiation attributes.
(Inline_Instance_Body): Update the capture of pending instantiation
attributes. It is no longer needed to explicitly manipulate the SPARK
mode.
(Instantiate_Package_Body): Update the restoration of the context
attributes.
(Instantiate_Subprogram_Body): Update the restoration of context
attributes.
(Load_Parent_Of_Generic): Update the capture of pending instantiation
attributes.
(Set_Instance_Env): Update the way relevant configuration attributes
are saved and restored.
gcc/testsuite/
* gnat.dg/config_pragma1.adb, gnat.dg/config_pragma1_pkg.ads: New testcase.
Eric Botcazou [Tue, 17 Jul 2018 08:10:04 +0000 (08:10 +0000)]
[Ada] Type mismatch warning for imported C++ class
2018-07-17 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* gcc-interface/ada-tree.h (TYPE_RETURN_BY_DIRECT_REF_P): Define for
METHOD_TYPE too.
(TYPE_RETURN_UNCONSTRAINED_P): Likewise.
(TYPE_CI_CO_LIST): Likewise.
* gcc-interface/gigi.h (is_cplusplus_method): Delete.
(fntype_same_flags_p): Adjust comment.
* gcc-interface/decl.c (Has_Thiscall_Convention): Delete.
(gnat_to_gnu_entity) <E_Subprogram_Type>: Do not set the "thiscall"
attribute directly.
(is_cplusplus_method): Make static and adjust head comment.
(gnat_to_gnu_param): Return a pointer for the "this" parameter of
C++ constructors.
(gnat_to_gnu_subprog_type): Turn imported C++ constructors into their
callable form. Generate a METHOD_TYPE node for imported C++ methods.
Set param_list at the very end of the processing.
(substitute_in_type) <METHOD_TYPE>: New case.
* gcc-interface/misc.c (gnat_print_type) <METHOD_TYPE>: Likewise.
(gnat_type_hash_eq): Accept METHOD_TYPE.
* gcc-interface/trans.c (Identifier_to_gnu): Deal with METHOD_TYPE.
(Attribute_to_gnu): Likewise.
(Call_to_gnu): Likewise.
(process_freeze_entity): Likewise.
* gcc-interface/utils.c (create_subprog_decl): Adjust head comment.
(fntype_same_flags_p): Likewise.
Eric Botcazou [Tue, 17 Jul 2018 08:09:54 +0000 (08:09 +0000)]
[Ada] Minor fix for imported C++ constructors
C++ constructors are imported as functions and then internally rewritten into
procedures taking the "this" pointer as first parameter. Now this parameter is
not of an access type but of the type directly, so it must be In/Out and not
just In.
2018-07-17 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* exp_disp.adb (Gen_Parameters_Profile): Make the _Init parameter an
In/Out parameter.
(Set_CPP_Constructors): Adjust comment accordingly.
Bob Duff [Tue, 17 Jul 2018 08:09:30 +0000 (08:09 +0000)]
[Ada] Assertion_Policy for class-wide precondition
This patch fixes the compiler to that class-wide preconditions on primitive
operations of interfaces are not checked at run time when the Assertion_Policy
indicates that they should be ignored. This is required by the RM.
2018-07-17 Bob Duff <duff@adacore.com>
gcc/ada/
* exp_disp.adb (Build_Class_Wide_Check): Return early if the
precondition is supposed to be ignored.
Ed Schonberg [Tue, 17 Jul 2018 08:09:14 +0000 (08:09 +0000)]
[Ada] Missing check on illegal equality operation in subprogram
In Ada2012 it is illegal to declare an equality operation on an untagged
type when the operation is primitive and the type is already frozem (see
RM 4.5.2 (9.8)). previously the test to detect this illegality only examined
declarations within a package. This patch covers the case where type and
operation are both declared within a subprogram body.
2018-07-17 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch6.adb (Check_Untagged_Equality): Extend check to operations
declared in the same scope as the operand type, when that scope is a
procedure.
Ed Schonberg [Tue, 17 Jul 2018 08:08:04 +0000 (08:08 +0000)]
[Ada] Unnesting: don't use Get_Actual_Subtype for record subtypes
2018-07-17 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_unst.adb (Unnest_Subprograms): Do nothing if the expander is not
active. Don't use Get_Actual_Subtype for record subtypes. Ignore
rewritten identifiers and uplevel references to bounds of types that
come from the original type reference.
Javier Miranda [Tue, 17 Jul 2018 08:07:52 +0000 (08:07 +0000)]
[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.
[Ada] Argument_String_To_List creates empty items from whitespace
This patch corrects an issue whereby leading whitespace in a non-quoted
argument list passed to Argument_String_To_List caused extraneous empty
arguments to be returned.
2018-07-17 Justin Squirek <squirek@adacore.com>
gcc/ada/
* libgnat/s-os_lib.adb (Argument_String_To_List): Fix trimming of
whitespace.
This patch modifies the verification of a missing Part_Of indicator to avoid
considering constants as visible state of a package instantiation because the
compiler cannot determine whether their values depend on variable input. This
diagnostic is left to GNATprove.
------------
-- Source --
------------
-- gnat.adc
pragma SPARK_Mode;
-- gen_pack.ads
generic
package Gen_Pack is
Val : constant Integer := 123;
end Gen_Pack;
-- pack.ads
with Gen_Pack;
package Pack
with Abstract_State => Pack_State
is
procedure Force_Body;
private
package Inst_1 is new Gen_Pack; -- OK
package Inst_2 is new Gen_Pack with Part_Of => Pack_State; -- OK
end Pack;
-- pack.adb
package body Pack
with Refined_State => (Pack_State => Inst_2.Val)
is
procedure Force_Body is null;
end Pack;
* sem_prag.adb (Has_Visible_State): Do not consider constants as
visible state because it is not possible to determine whether a
constant depends on variable input.
(Propagate_Part_Of): Add comment clarifying the behavior with respect
to constant.
[Ada] Avoid confusing warning on exception propagation in GNATprove mode
When compiling with the restriction No_Exception_Propagation, GNAT compiler
may issue a warning about exceptions not being propagated. This warning is
useless and confusing to users for GNATprove analysis, as GNATprove
precisely detects possible exceptions, so disable the warning in that mode.
2018-07-17 Yannick Moy <moy@adacore.com>
gcc/ada/
* gnat1drv.adb (Gnat1drv): Do not issue warning about exception not
being propagated in GNATprove mode.
Javier Miranda [Tue, 17 Jul 2018 08:07:00 +0000 (08:07 +0000)]
[Ada] Secondary stack leak in statements block located in a loop
When a loop iterator has a block declaration containing statements that invoke
functions whose result is returned on the secondary stack (such as a
string-returning function), the compiler fails to generate code to release the
allocated memory when the loop terminates.
After this patch the following test works fine.
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
pragma Warnings (Off);
with System.Secondary_Stack;
pragma Warnings (On);
procedure Small is
procedure Info is new System.Secondary_Stack.Ss_Info (Put_Line);
US : Unbounded_String;
begin
Info;
for J in 1 .. 100_000 loop
Leaky_Block : declare
begin
if (J mod 20000) = 0 then
Info;
end if;
Ada.Text_IO.Put_Line (To_String (US)); -- Test
if (J mod 20000) = 0 then
Info;
end if;
end Leaky_Block;
end loop;
Info;
end;
Command:
gnatmake small.adb; small | grep "Current allocated space :" | uniq
Output:
Current allocated space : 0 bytes
2018-07-17 Javier Miranda <miranda@adacore.com>
gcc/ada/
* exp_ch7.adb (Make_Transient_Block): When determining whether an
enclosing scope already handles the secondary stack, take into account
transient blocks nested in a block that do not manage the secondary
stack and are located within a loop.
Ed Schonberg [Tue, 17 Jul 2018 08:06:55 +0000 (08:06 +0000)]
[Ada] Fix Enclosing_Subprogram for protected entries and task entries
2018-07-17 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_util.adb (Enclosing_Subprogram): Protected entries and task
entries must be treated separately: task entries are within the
enclosing subprogram of the task type, while protected entries are
transformed into the corresponding Protected_Body_Subprogram, which is
the enclosing_subprogram of any subprogram declared within the entry
body.
Jakub Jelinek [Tue, 17 Jul 2018 08:06:25 +0000 (10:06 +0200)]
re PR middle-end/86539 (OpenMP wrong-code with taskloop and references)
PR middle-end/86539
* gimplify.c (gimplify_omp_for): Ensure taskloop firstprivatized init
and cond temporaries don't have reference type if iterator has
pointer type. For init use &for_pre_body instead of pre_p if
for_pre_body is non-empty.
This patch reimplements the mechanism which removes ignored Ghost code from the
tree.
The previous mechanism proved to be unreliable because it assumed that no new
scoping constructs would be created after some ignored Ghost code had already
notified its enclosing scoping constructs that they contain such code. The
assumption can be broken by having a call to an ignored Ghost procedure within
the extended return statement of a function. The procedure call would signal
the enclosing function that it contains ignored Ghost code, however the return
statement would introduce an extra block, effectively hiding the procedure call
from the ignored Ghost code elimination pass.
The new mechanism implemented in this patch forgoes directed tree pruning in
favor of storing the actual ignored Ghost code, and later directly eliminating
it from the tree.
For this approach to operate efficiently, only "top level" ignored Ghost
constructs are stored. The top level constructs are essentially nodes which can
appear within a declarative or statement list and be safely rewritten into null
statements. This ensures that only "root" ignored Ghost construct need to be
processed, as opposed to all ignored Ghost nodes within a subtree.
The approach has one drawback however. Due to the generation and analysis of
ignored Ghost code, a construct may be recorded multiple times (usually twice).
The mechanism simply deals with this artefact instead of employing expensive
solutions such as hash tables or a common flag shared by all nodes to eliminate
the duplicates.
------------
-- Source --
------------
-- main.adb
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
procedure Ghost_Proc with Ghost;
procedure Ghost_Proc is
begin
Put_Line ("ERROR: Ghost_Proc called");
end Ghost_Proc;
function Func return Integer is
begin
return Res : Integer := 123 do
Ghost_Proc;
end return;
end Func;
Val : Integer with Ghost;
begin
Val := Func;
end Main;
----------------------------
-- Compilation and output --
----------------------------
* alloc.ads: Update the allocation metrics of the ignored Ghost nodes
table.
* atree.adb: Add a soft link for a procedure which is invoked whenever
an ignored Ghost node or entity is created.
(Change_Node): Preserve relevant attributes which come from the Flags
table.
(Mark_New_Ghost_Node): Record a newly created ignored Ghost node or
entity.
(Rewrite): Preserve relevant attributes which come from the Flags
table.
(Set_Ignored_Ghost_Recording_Proc): New routine.
* atree.ads: Define an access-to-suprogram type for a soft link which
records a newly created ignored Ghost node or entity.
(Set_Ignored_Ghost_Recording_Proc): New routine.
* ghost.adb: Remove with and use clause for Lib. Remove table
Ignored_Ghost_Units. Add new table Ignored_Ghost_Nodes.
(Add_Ignored_Ghost_Unit): Removed.
(Initialize): Initialize the table which stores ignored Ghost nodes.
Set the soft link which allows Atree.Mark_New_Ghost_Node to record an
ignored Ghost node.
(Is_Ignored_Ghost_Unit): Use the ultimate original node when checking
an eliminated ignored Ghost unit.
(Lock): Release and lock the table which stores ignored Ghost nodes.
(Mark_And_Set_Ghost_Assignment): Record rather than propagate ignored
Ghost nodes.
(Mark_And_Set_Ghost_Procedure_Call): Record rather than propagate
ignored Ghost nodes.
(Mark_Ghost_Clause): Record rather than propagate ignored Ghost nodes.
(Mark_Ghost_Declaration_Or_Body): Record rather than propagate ignored
Ghost nodes.
(Mark_Ghost_Pragma): Record rather than propagate ignored Ghost nodes.
(Propagate_Ignored_Ghost_Code): Removed.
(Record_Ignored_Ghost_Node): New routine.
(Remove_Ignored_Ghost_Code): Reimplemented.
(Remove_Ignored_Ghost_Node): New routine.
(Ultimate_Original_Node): New routine.
* ghost.ads (Check_Ghost_Completion): Removed.
* sem_ch8.adb (Analyze_Use_Package): Remove obsolete code. Mark a use
package clause as ignored Ghost if applicable.
* sem_util.adb (Is_Body_Or_Package_Declaration): Reimplemented.
Javier Miranda [Tue, 17 Jul 2018 08:06:09 +0000 (08:06 +0000)]
[Ada] Secondary stack leak in loop iterator
When the evaluation of the loop iterator invokes a function whose
result relies on the secondary stack the compiler does not generate
code to release the consumed memory as soon as the loop terminates.
After this patch the following test works fine.
with Text_IO; use Text_IO;
pragma Warnings (Off);
with System.Secondary_Stack;
pragma Warnings (On);
procedure Sec_Stack_Leak is
function F (X : String) return Integer is
begin
return 10;
end F;
function G (X : Integer) return String is
begin
return (1 .. X => 'x');
end G;
procedure Info is new System.Secondary_Stack.Ss_Info (Put_Line);
procedure Nest is
begin
for I in Integer range 1 .. 100 loop
for J in Integer range 1 .. F (G (10_000)) loop
null;
end loop;
Info;
end loop;
Info;
end Nest;
begin
Info;
Nest;
Info;
end Sec_Stack_Leak;
Commands:
gnatmake -q sec_stack_leak.adb
sec_stack_leak | grep "Current allocated space :" | uniq
Output:
Current allocated space : 0 bytes
2018-07-17 Javier Miranda <miranda@adacore.com>
gcc/ada/
* sem_ch5.adb (Has_Call_Using_Secondary_Stack): Moved to library level
to reuse it.
(Analyze_Loop_Statement): Wrap the loop in a block when the evaluation
of the loop iterator relies on the secondary stack.
Piotr Trojanek [Tue, 17 Jul 2018 08:06:04 +0000 (08:06 +0000)]
[Ada] Fix Next_Actual when used on calls "inlined for proof"
The GNATprove backend needs to apply antialiasing checks to subprogram
calls that have been rewritten into null statements while "inlining for
proof". This requires the First_Actual/Next_Actual to use the Original_Node
and not the N_Null_Statement that rewriting leaves as a parent.
Only effective in GNATprove mode, so no frontend test provided.
2018-07-17 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sem_util.adb (Next_Actual): If the parent is a N_Null_Statement,
which happens for inlined calls, then fetch the next actual from the
original AST.
Piotr Trojanek [Tue, 17 Jul 2018 08:05:54 +0000 (08:05 +0000)]
[Ada] Attach the special GNATprove HEAP entity to the Standard package
In GNATprove mode we use frontend cross-references to synthesize the
Global contract of subprograms with SPARK_Mode => Off and represent
a read/write via a pointer as a read/write of a special entity called
HEAP. This entity is now attached to the Standard package, so that we can
safely check the Ekind of its Scope, which now happens in Scope_Within.
This only affects GNATprove, so no frontend test provided.
2018-07-17 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* lib-xref-spark_specific.adb (Create_Heap): Attach the HEAP entity to
the Standard package.
Ed Schonberg [Tue, 17 Jul 2018 08:05:29 +0000 (08:05 +0000)]
[Ada] Fix unnesting issues involving tasks
2018-07-17 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_util.adb (Enclosing_Subprogram): Handle properly entries, and
synchronized types that are completions of limited types or private
extensions.
(Scope_Within): Handle properly accept statements in task bodies.
[Ada] Spurious error on unused Part_Of constituent
This patch updates the analysis of indicator Part_Of (or the lack thereof), to
ignore generic formal parameters for purposes of determining the visible state
space because they are not visible outside the generic and related instances.
------------
-- Source --
------------
-- gen_pack.ads
generic
In_Formal : in Integer := 0;
In_Out_Formal : in out Integer;
package Pack
with Abstract_State => State
is
procedure Force_Body;
Val : Integer;
private
package OK_1 is
new Gen_Pack (In_Out_Formal => Val)
with Part_Of => State; -- OK
package OK_2 is
new Gen_Pack (In_Formal => 1, In_Out_Formal => Val)
with Part_Of => State; -- OK
package Error_1 is -- Error
new Gen_Pack (In_Out_Formal => Val);
package Error_2 is -- Error
new Gen_Pack (In_Formal => 2, In_Out_Formal => Val);
end Pack;
-- pack.adb
package body Pack
with Refined_State => -- Error
(State => (OK_1.Exported_In_Formal,
OK_1.Exported_In_Out_Formal))
is
procedure Force_Body is null;
end Pack;
-- gen_pack.ads
generic
In_Formal : in Integer := 0;
In_Out_Formal : in out Integer;
package Pack
with Abstract_State => State
is
procedure Force_Body;
Val : Integer;
private
package OK_1 is
new Gen_Pack (In_Out_Formal => Val)
with Part_Of => State; -- OK
package OK_2 is
new Gen_Pack (In_Formal => 1, In_Out_Formal => Val)
with Part_Of => State; -- OK
package Error_1 is -- Error
new Gen_Pack (In_Out_Formal => Val);
package Error_2 is -- Error
new Gen_Pack (In_Formal => 2, In_Out_Formal => Val);
end Pack;
-- pack.adb
package body Pack
with Refined_State => -- Error
(State => (OK_1.Exported_In_Formal,
OK_1.Exported_In_Out_Formal))
is
procedure Force_Body is null;
end Pack;
----------------------------
-- Compilation and output --
----------------------------
$ gcc -c pack.adb
pack.adb:3:11: state "State" has unused Part_Of constituents
pack.adb:3:11: constant "Exported_In_Formal" defined at gen_pack.ads:6,
instance at pack.ads:15
pack.adb:3:11: variable "Exported_In_Out_Formal" defined at gen_pack.ads:7,
instance at pack.ads:15
pack.ads:19:12: indicator Part_Of is required in this context (SPARK RM
7.2.6(2))
pack.ads:19:12: "Error_1" is declared in the private part of package "Pack"
pack.ads:21:12: indicator Part_Of is required in this context (SPARK RM
7.2.6(2))
pack.ads:21:12: "Error_2" is declared in the private part of package "Pack"
* sem_prag.adb (Has_Visible_State): Do not consider generic formals
because they are not part of the visible state space. Add constants to
the list of acceptable visible states.
(Propagate_Part_Of): Do not consider generic formals when propagating
the Part_Of indicator.
* sem_util.adb (Entity_Of): Do not follow renaming chains which go
through a generic formal because they are not visible for SPARK
purposes.
* sem_util.ads (Entity_Of): Update the comment on usage.
Ed Schonberg [Tue, 17 Jul 2018 08:03:49 +0000 (08:03 +0000)]
[Ada] Fix handling of inherited discriminant constraints
2018-07-17 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_util.adb (Gather_Components): A discriminant of an ancestor may
have been constrained by a later ancestor, so when looking for the
value of that hidden discriminant we must examine the stored constraint
of other ancestors than the immediate parent type.
gcc/testsuite/
* gnat.dg/discr54.adb, gnat.dg/discr54_pkg.ads: New testcase.
[Ada] Crash on case expression in build-in-place function
This patch modifies the recursive tree replication routine New_Copy_Tree to
create new entities and remap old entities to the new ones for constructs in
N_Expression_With_Actions nodes when requested by a caller. This in turn allows
the build-in-place mechanism to avoid sharing entities between the 4 variants
of returns it generates.
* exp_ch6.adb (Build_Heap_Or_Pool_Allocator): Ensure that scoping
constructs and entities within receive new entities when replicating a
tree.
(Expand_N_Extended_Return_Statement): Ensure that scoping constructs
and entities within receive new entities when replicating a tree.
* sem_util.adb (New_Copy_Tree): Add new formal Scopes_In_EWA_OK.
(Visit_Entity): Visit entities within scoping constructs inside
expression with actions nodes when requested by the caller. Add blocks,
labels, and procedures to the list of entities which need replication.
* sem_util.ads (New_Copy_Tree): Add new formal Scopes_In_EWA_OK. Update
the comment on usage.
gcc/testsuite/
* gnat.dg/bip_case_expr.adb, gnat.dg/bip_case_expr_pkg.ads: New testcase.
rs6000: Use correct names for some trunc/extend libcalls
The libcalls for trunc and extend of a decimal float to a binary float,
and vice versa, do not have "2" in the name, although all other such
conversions do.
* config/rs6000/rs6000.c (init_float128_ibm): Use the correct names
for conversions between IFmode and the decimal floating point modes.
(init_float128_ieee): Use the correct names for conversions between
KFmode and the decimal floating point modes.
rs6000: Use more correct names for some trunc/extend libcalls
They had source and destination swapped in the name.
* config/rs6000/rs6000.c (init_float128_ibm): Use more correct names
for the conversions between TDmode and IFmode.
(init_float128_ieee): Use more correct names for the conversions
between TDmode and KFmode.
Fritz Reese [Mon, 16 Jul 2018 18:24:50 +0000 (18:24 +0000)]
Fix handling of invalid assumed-shape/size arrays in legacy initializer lists.
2018-07-16 Fritz Reese <fritzoreese@gmail.com>
Fix handling of invalid assumed-shape/size arrays in legacy initializer
lists.
gcc/fortran/ChangeLog:
PR fortran/83184
* decl.c (match_old_style_init): Initialize locus of variable expr when
creating a data variable.
(match_clist_expr): Verify array is explicit shape/size before
attempting to allocate constant array constructor.
gcc/testsuite/ChangeLog:
PR fortran/83184
* gfortran.dg/assumed_rank_14.f90: New testcase.
* gfortran.dg/assumed_rank_15.f90: New testcase.
* gfortran.dg/dec_structure_8.f90: Update error messages.
* gfortran.dg/dec_structure_23.f90: Update error messages.
PR middle-end/86528
* builtins.c (check_access): Bail out if range[0] is no INTEGER_CST.
* expr.c (string_constant): Fix the element size of ARRAY_TYPE.
The standard doesn't specify this partial specialization (it was
required after the changes in N2637 but then should have been removed
following LWG 1262). Its presence is observable because it causes
different results when operator< has been overloaded for a shared_ptr
specialization.
extend.texi (PowerPC AltiVec Built-in Functions): Alphabetize prototypes of built-in functions...
gcc/ChangeLog:
2018-07-16 Kelvin Nilsen <kelvin@gcc.gnu.org>
* doc/extend.texi (PowerPC AltiVec Built-in Functions):
Alphabetize prototypes of built-in functions, separating out
built-in functions that are listed in this section but should be
described elsewhere.
re PR middle-end/86511 (Traps are generated for non-trapping compares)
PR target/86511
* expmed.c (emit_store_flag): Do not emit setcc followed by a
conditional move when trapping comparison was split to a
non-trapping one (and vice versa).
On i386 the profiler call sequence always consists of 1 call
instruction, so -mnop-mcount generates a single nop with the same
length as a call. For S/390 longer sequences may be used in some
cases, so -mnop-mcount generates the corresponding amount of nops.
2018-07-16 Ilya Leoshkevich <iii@linux.ibm.com>
* config/s390/s390.c (s390_function_profiler): Generate nops
instead of profiler call sequences.
* config/s390/s390.opt: Add the new option.
2018-07-16 Ilya Leoshkevich <iii@linux.ibm.com>
* gcc.target/s390/mnop-mcount-m31-fpic.c: New testcase.
* gcc.target/s390/mnop-mcount-m31-mzarch.c: New testcase.
* gcc.target/s390/mnop-mcount-m31.c: New testcase.
* gcc.target/s390/mnop-mcount-m64-mfentry.c: New testcase.
* gcc.target/s390/mnop-mcount-m64.c: New testcase.
S/390: Add direct support for Linux kernel __fentry__ patching.
On i386, the difference between mcount and fentry is that fentry
comes before the prolog. On s390 mcount already comes before the
prolog, but takes 4 instructions. This patch introduces the more
efficient implementation (just 1 instruction) and puts it under
-mfentry flag.
The produced code is compatible only with newer glibc versions,
which provide the __fentry__ symbol and do not clobber %r0 when
resolving lazily bound functions. Because 31-bit PLT stubs assume
%r12 contains GOT address, which is not the case when the code runs
before the prolog, -mfentry is allowed only for 64-bit code.
Also, code compiled with -mfentry cannot be used for the nested C
functions, since they both use %r0. In this case instrumentation is
not insterted, and a new warning is issued for each affected nested
function.
2018-07-16 Ilya Leoshkevich <iii@linux.ibm.com>
* common.opt: Add the new warning.
* config/s390/s390.c (s390_function_profiler): Emit "brasl
%r0,__fentry__" when -mfentry is specified.
(s390_option_override_internal): Disallow -mfentry for 31-bit
CPUs.
* config/s390/s390.opt: Add the new option.
[Ada] Missing error on hidden state in instantiation
This patch modifies the analysis of package contracts to split processing
which is specific to package instantiations on its own. As a result, the
lack of indicator Part_Of can now be properly assessed.
------------
-- Source --
------------
-- gen_pack.ads
generic
package Gen_Pack is
Pack_Var : Integer := 1;
end Gen_Pack;
-- gen_wrap.ads
with Gen_Pack;
generic
package Gen_Wrap is
Wrap_Var : Integer := 1;
package Inst is new Gen_Pack;
end Gen_Wrap;
-- pack.ads
with Gen_Pack;
with Gen_Wrap;
package Pack
with SPARK_Mode => On,
Abstract_State => State
is
procedure Force_Body;
private
package OK_Inst_1 is new Gen_Pack -- OK
with Part_Of => State; -- OK
package OK_Inst_2 is new Gen_Pack; -- OK
pragma Part_Of (State); -- OK
package OK_Inst_3 is new Gen_Wrap -- OK
with Part_Of => State; -- OK
package OK_Inst_4 is new Gen_Wrap; -- OK
pragma Part_Of (State);
package Error_Inst_1 is new Gen_Pack; -- Error
package Error_Inst_2 is new Gen_Wrap; -- Error
end Pack;
-- pack.adb
package body Pack
with SPARK_Mode => On,
Refined_State =>
(State => (OK_Inst_1.Pack_Var, OK_Inst_2.Pack_Var,
OK_Inst_3.Wrap_Var, OK_Inst_3.Inst.Pack_Var,
OK_Inst_4.Wrap_Var, OK_Inst_4.Inst.Pack_Var))
is
procedure Force_Body is null;
end Pack;
----------------------------
-- Compilation and output --
----------------------------
$ gcc -c pack.adb
pack.ads:23:12: indicator Part_Of is required in this context (SPARK RM
7.2.6(2))
pack.ads:23:12: "Error_Inst_1" is declared in the private part of package
"Pack"
pack.ads:24:12: indicator Part_Of is required in this context (SPARK RM
7.2.6(2))
pack.ads:24:12: "Error_Inst_2" is declared in the private part of package
"Pack"
* contracts.adb (Analyze_Contracts): Add specialized processing for
package instantiation contracts.
(Analyze_Package_Contract): Remove the verification of a missing
Part_Of indicator.
(Analyze_Package_Instantiation_Contract): New routine.
* contracts.ads (Analyze_Package_Contract): Update the comment on
usage.
* sem_prag.adb (Check_Missing_Part_Of): Ensure that the entity of the
instance is being examined when trying to determine whether a package
instantiation needs a Part_Of indicator.
Ed Schonberg [Mon, 16 Jul 2018 14:12:18 +0000 (14:12 +0000)]
[Ada] Fix expansion of blocks in loops inside elaboration code
2018-07-16 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_ch7.adb (Check_Unnesting_Elaboration_Code): Handle loops that
contain blocks in the elaboration code for a package body. Create the
elaboration subprogram wrapper only if there is a subprogram
declaration in a block or loop.
Ed Schonberg [Mon, 16 Jul 2018 14:12:13 +0000 (14:12 +0000)]
[Ada] Deep copy operands of membership operations for unnesting
2018-07-16 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_ch4.adb (Expand_Set_Membership): Use New_Copy_Tree to perform a
deep copy of the left operand when building each conjuct of the
expanded membership operation, to avoid sharing nodes between them.
This sharing interferes with the unnesting machinery and is generally
undesirable.
Ed Schonberg [Mon, 16 Jul 2018 14:11:58 +0000 (14:11 +0000)]
[Ada] Fix Default_Storage_Pool aspect handling in generic instantiations
2018-07-16 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch12.adb (Analyze_Package_Instantiation): Handle properly an
instance that carries an aspect Default_Storage_Pool that overrides a
default storage pool that applies to the generic unit. The aspect in
the generic unit was removed before copying it in the instance, rather
than removing it from the copy of the aspects that are appended to the
aspects in the instance.
Ed Schonberg [Mon, 16 Jul 2018 14:11:52 +0000 (14:11 +0000)]
[Ada] Major code cleanup
2018-07-16 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* einfo.adb (Set_Is_Uplevel_Referenced_Entity): Flag can appear on
loop parameters.
* exp_ch7.adb (Check_Unnesting_Elaboration_Code): Handle subprogram
bodies.
* exp_ch9.adb (Reset_Scopes_To): Set the scopes of entities local to an
entry body to be the corresponding generated subprogram, for correct
analysis of uplevel references.
* exp_unst.adb (Visit_Node): Handle properly binary and unary operators
Ignore pragmas, fix component associations.
(Register_Subprograms): Subprograms in synchronized types must be
treated as reachable.
This patch corrects the mechanism which ensures that a package with a null
Abstract_State does not introduce hidden state, by ignoring internal states
and variables because they do not represent the "source" hidden state.
Piotr Trojanek [Mon, 16 Jul 2018 14:11:42 +0000 (14:11 +0000)]
[Ada] Deconstruct unused Withed_Body filed of N_With_Clause node
The Withed_Body field was added to N_With_Clause node to help the
Walk_Library_Items routine, which was created for the CodePeer backend
and later adopted by the GNATprove.
This routine is meant to traverse all library units, such that declarations
are visited before references. However, for complex units (in particular,
with generics and child packages) it never worked reliably and backends
developed their own workarounds. This patch deconstructs the field, as it
hasn't been used for years.
Piotr Trojanek [Mon, 16 Jul 2018 14:11:37 +0000 (14:11 +0000)]
[Ada] Avoid crash when traversing units with -gnatd.WW debug switch
The debug switch -gnatd.WW enables extra info when traversing library units
with Walk_Library_Items, which is used in the CodePeer and GNATprove. This
routine was crashing when trying to print info about a unit with configuration
pragmas (typically an .adc file). Now fixed.
No test, as the crash only happens when a GNATprove backend is manually called
with -gnatd.WW switch. Frontend is not affected.
2018-07-16 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sem.adb (Walk_Library_Items): Skip units with configuration pragmas
when printing debug info.
Piotr Trojanek [Mon, 16 Jul 2018 14:11:30 +0000 (14:11 +0000)]
[Ada] Trivial simplifications in in Walk_Library_Items
Cleanup only; semantics unaffected.
2018-07-16 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sem.adb (Walk_Library_Items): Reuse local constant.
(Is_Subunit_Of_Main): Turn condition to positive and flip the
IF-THEN-ELSE branches; avoid potentially ineffective assignment to the
Lib variable.
Piotr Trojanek [Mon, 16 Jul 2018 14:11:25 +0000 (14:11 +0000)]
[Ada] Deconstruct always-false calls to Withed_Body in Walk_Library_Items
We previously removed the calls to Set_Withed_Body; this commit deconstructs
calls to Withed_Body, which always returned False.
The Set_Withed_Body/Withed_Body were helping the Walk_Library_Items routine
traverse the AST of several compilation units such that declarations are
visited before references. However, this never worked as it should and there is
no point to keep the code more complicated than necessary.
No test provided, because thie removed code was ineffective (and only used in
the non-compiler backends, i.e. CodePeer and GNATprove).
2018-07-16 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sem.adb (Walk_Library_Items): Deconstruct dead code.
[Ada] Crash on Indefinite_Hashed_Maps with -gnata -gnateV
This patch corrects the generation of helper functions which verify the
validity of record type scalar discriminants and scalar components when
switches -gnata (assertions enabled) and -gnateV (validity checks on
subprogram parameters) are in effect.
[Ada] Spurious possible contraint error warning with No_Exception_Propagation
This patch corrects an issue whereby spurious unhandled exception warnings on
integer literals within static if and case expressions would be emitted when
the restriction No_Exception_Propagation is enabled.
procedure Filter (Ret : out Integer) is
Val : constant Nat :=
(if User_Override in Nat then
User_Override
else
Default);
begin
Ret := Val;
end Filter;
end Pack;
----------------------------
-- Compilation and output --
----------------------------
& gcc -c -gnatp -gnatwa pack.adb
2018-07-16 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_eval.adb (Eval_Integer_Literal): Add exception for avoiding
checks on expanded literals within if and case expressions.
[Ada] Segmentation_Fault with Integer'Wide_Wide_Value
This patch updates the routines which produce Wide_String and Wide_Wide_String
from a String to construct a result of the proper maximum size which is later
sliced.
Javier Miranda [Mon, 16 Jul 2018 14:10:32 +0000 (14:10 +0000)]
[Ada] Code cleanup on functions inlining
This patch is preventive: it improves checks on inline functions that
return unconstrained type. It does not change the functionality of
the compiler.
2018-07-16 Javier Miranda <miranda@adacore.com>
gcc/ada/
* inline.adb (Build_Body_To_Inline): Minor code reorganization that
ensures that calls to function Has_Single_Return() pass a decorated
tree.
(Has_Single_Return.Check_Return): Peform checks on entities (instead on
relying on their characters).
Javier Miranda [Mon, 16 Jul 2018 14:10:27 +0000 (14:10 +0000)]
[Ada] Crash processing sources under GNATprove debug mode
Processing sources under -gnatd.F the frontend may crash on
an iterator of the form 'for X of ...' over an array if the
iterator is located in an inlined subprogram.
2018-07-16 Javier Miranda <miranda@adacore.com>
gcc/ada/
* exp_ch5.adb (Expand_Iterator_Loop_Over_Array): Code cleanup. Required
to avoid generating an ill-formed tree that confuses gnatprove causing
it to blowup.
gcc/testsuite/
* gnat.dg/iter2.adb, gnat.dg/iter2.ads: New testcase.
[Ada] Adjust inlining in GNATprove mode for predicate/invariant/DIC
The frontend generates special functions for checking subtype predicates,
type invariants and Default_Initial_Condition aspect. These are translated
as predicates in GNATprove, and as such should no call inside these
functions should be inlined. This is similar to the existing handling of
calls inside expression functions.
There is no impact on compilation.
2018-07-16 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_res.adb (Resolve_Call): Do not inline calls inside
compiler-generated functions translated as predicates in GNATprove.
Gary Dismukes [Mon, 16 Jul 2018 14:09:53 +0000 (14:09 +0000)]
[Ada] Violation of No_Standard_Allocators_After_Elaboration not detected
The compiler fails to generate a call to detect allocators executed after
elaboration in cases where the allocator is associated with Global_Pool_Object.
The fix is to test for this associated storage pool as part of the condition
for generating a call to System.Elaboration_Allocators.Check_Standard_Alloctor.
Also, the exception Storage_Error is now generated instead of Program_Error
for such a run-time violation, as required by the Ada RM in D.7.
The following test must compile and execute quietly:
-- Put the pragma in gnat.adc:
pragma Restrictions (No_Standard_Allocators_After_Elaboration);
procedure Allocate
(Use_Global_Allocator : Boolean;
During_Elaboration : Boolean)
is
type Local_Acc is access Rec;
Local_Ptr : Local_Acc;
begin
if Use_Global_Allocator then
Ptr := new Rec; -- Raise Storage_Error if after elaboration
Ptr.Int := 1;
else
Local_Ptr := new Rec; -- Raise Storage_Error if after elaboration
Local_Ptr.Int := 1;
end if;
if not During_Elaboration then
raise Program_Error; -- No earlier exception: FAIL
end if;
exception
when Storage_Error =>
if During_Elaboration then
raise Program_Error; -- No exception expected: FAIL
else
null; -- Expected Storage_Error: PASS
end if;
when others =>
raise Program_Error; -- Unexpected exception: FAIL
end Allocate;
begin
Allocate (Use_Global_Allocator => True, During_Elaboration => True);
Allocate (Use_Global_Allocator => False, During_Elaboration => True);
end Pkg_With_Allocators;
with Pkg_With_Allocators;
procedure Alloc_Restriction_Main is
begin
Pkg_With_Allocators.Allocate
(Use_Global_Allocator => True,
During_Elaboration => False);
Pkg_With_Allocators.Allocate
(Use_Global_Allocator => False,
During_Elaboration => False);
end Alloc_Restriction_Main;
2018-07-16 Gary Dismukes <dismukes@adacore.com>
gcc/ada/
* exp_ch4.adb (Expand_N_Allocator): Test for Storage_Pool being RTE in
addition to the existing test for no Storage_Pool as a condition
enabling generation of the call to Check_Standard_Allocator when the
restriction No_Standard_Allocators_After_Elaboration is active.
* libgnat/s-elaall.ads (Check_Standard_Allocator): Correct comment to
say that Storage_Error will be raised (rather than Program_Error).
* libgnat/s-elaall.adb (Check_Standard_Allocator): Raise Storage_Error
rather than Program_Error when Elaboration_In_Progress is False.
* sem_eval.adb (Compile_Time_Known_Value): Add a guard which prevents
the compiler from entering infinite recursion when trying to determine
whether a deferred constant has a compile time known value, and the
initialization expression of the constant is a reference to the
constant itself.