Commit Graph

169903 Commits

Author SHA1 Message Date
Jakub Jelinek
6f67abcdb0 omp-low.c (lower_rec_input_clauses): For lastprivate clauses in ctx->for_simd_scan_phase simd copy the outer var to...
* omp-low.c (lower_rec_input_clauses): For lastprivate clauses in
	ctx->for_simd_scan_phase simd copy the outer var to the privatized
	variable(s).  For conditional lastprivate look through outer
	GIMPLE_OMP_SCAN context.
	(lower_omp_1): For conditional lastprivate look through outer
	GIMPLE_OMP_SCAN context.

	* testsuite/libgomp.c/scan-19.c: New test.
	* testsuite/libgomp.c/scan-20.c: New test.

From-SVN: r273169
2019-07-06 23:58:01 +02:00
Jakub Jelinek
94e14f2e90 omp-low.c (struct omp_context): Rename combined_into_simd_safelen0 member to combined_into_simd_safelen1.
* omp-low.c (struct omp_context): Rename combined_into_simd_safelen0
	member to combined_into_simd_safelen1.
	(lower_rec_input_clauses, lower_omp_1): Adjust uses.
	(lower_lastprivate_clauses): Likewise.  For conditional lastprivate
	clauses if ctx->combined_into_simd_safelen1 put statements after the
	predicate conditionalized block rather than into it.

From-SVN: r273168
2019-07-06 23:56:46 +02:00
Jonathan Wakely
a10b664eb7 Fix recent regression in __atomic_add_dispatch
* include/ext/atomicity.h (__exchange_and_add, __atomic_add): Replace
	throw() with _GLIBCXX_NOTHROW.
	(__atomic_add_dispatch): Return after performing atomic increment.

From-SVN: r273167
2019-07-06 22:16:38 +01:00
Richard Sandiford
ef2df51671 [s390] Fix ambiguous .md attribute uses
This patch is part of a series that fixes ambiguous attribute
uses in .md files, i.e. cases in which attributes didn't use
<ITER:ATTR> to specify an iterator, and in which <ATTR> could
have different values depending on the iterator chosen.

The vx-builtins.md part changes the choice of <mode> from the
implicit <VFCMP:mode> to an explicit <VF_HW:mode> (i.e. from the
mode of the comparison result to the mode of the operands being
compared).  That seemed like the intended behaviour given later
patterns like vec_cmpeq<mode>_cc.

The use of BFP in the s390.md LNDFR pattern looks like a typo,
since the operand to (abs ...) has to have the same mode as the result.
The only effect before this series was to create some extra variants
that would never match, making it harmless apart from very minor code
bloat.

2019-07-06  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/s390/s390.md (*negabs<FP:mode>2_nocc): Use FP for
	operand 1.
	* config/s390/vx-builtins.md (*vec_cmp<insn_cmp><mode>_cconly):
	Make the choice of <mode> explicit, giving...
	(*vec_cmp<insn_cmp><VF_HW:mode>_cconly): ...this.

From-SVN: r273162
2019-07-06 08:26:44 +00:00
Richard Sandiford
a0cb70b7ea [i386] Fix ambiguous .md attribute uses
This patch is part of a series that fixes ambiguous attribute
uses in .md files, i.e. cases in which attributes didn't use
<ITER:ATTR> to specify an iterator, and in which <ATTR> could
have different values depending on the iterator chosen.

No behavioural change except for dropping the unused *andnot<mode>3_bcst
permutations.

2019-07-06  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/i386/i386.md (*fop_<X87MODEF:mode>_3_i387)
	(l<rounding_insn><MODEF:mode><SWI48:mode>2): Fix ambiguous uses
	of .md attributes.
	* config/i386/sse.md (*avx512pf_gatherpf<mode>sf_mask)
	(*avx512pf_gatherpf<mode>df_mask, *avx512pf_scatterpf<mode>sf_mask)
	(*avx512pf_scatterpf<mode>df_mask, *avx2_gathersi<mode>)
	(*avx2_gathersi<mode>_2, *avx2_gatherdi<mode>)
	(*avx2_gatherdi<mode>_2, *avx2_gatherdi<mode>_3): Likewise.
	(*avx2_gatherdi<mode>_4, *avx512f_gathersi<mode>): Likewise.
	(*avx512f_gathersi<mode>_2, *avx512f_gatherdi<mode>): Likewise.
	(*avx512f_gatherdi<mode>_2, *avx512f_scattersi<mode>): Likewise.
	(*avx512f_scatterdi<mode>): Likewise.
	(*andnot<mode>3_bcst): Fix VI/VI48_AVX512VL typo.

From-SVN: r273161
2019-07-06 08:26:33 +00:00
Richard Sandiford
212ecf90de [h8300] Fix ambiguous .md attribute uses
This patch is part of a series that fixes ambiguous attribute
uses in .md files, i.e. cases in which attributes didn't use
<ITER:ATTR> to specify an iterator, and in which <ATTR> could
have different values depending on the iterator chosen.

No behavioural change -- produces the same code as before.

2019-07-06  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/h8300/h8300.md (*push1_h8300hs_<mode>): Explicitly
	specify the mode iterator referenced by <mode>, giving...
	(*push1_h8300hs_<QHI:mode>): ...this.

From-SVN: r273160
2019-07-06 08:26:11 +00:00
Richard Sandiford
96eb1765a3 [amdgcn] Fix ambiguous .md attribute uses
This patch is part of a series that fixes ambiguous attribute
uses in .md files, i.e. cases in which attributes didn't use
<ITER:ATTR> to specify an iterator, and in which <ATTR> could
have different values depending on the iterator chosen.

I think this is a genuine bugfix for the case in which the 1REG_MODE
and 1REG_ALT are different, since previously we would use the 1REG_MODE
for both the comparison and the select, even though the operands being
compared are 1REG_ALT rather than 1REG_MODE.

2019-07-06  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/gcn/gcn-valu.md
	(vcond<VEC_1REG_MODE:mode><VEC_1REG_ALT:mode>): Use
	gen_vec_cmp<VEC_1REG_ALT:mode>di rather than (implicitly)
	gen_vec_cmp<VEC_1REG_MODE:mode>di.  Explicitly use
	gen_vcond_mask_<VEC_1REG_MODE:mode>di.
	(vcond<VEC_1REG_MODE:mode><VEC_1REG_ALT:mode>_exec): Likewise,
	but using the _exec comparison patterns.
	(vcondu<VEC_1REG_INT_MODE:mode><VEC_1REG_INT_ALT:mode>): Use
	gen_vec_cmp<VEC_1REG_INT_ALT:mode>di rather than (implicitly)
	gen_vec_cmp<VEC_1REG_INT_MODE:mode>di.  Explicitly use
	gen_vcond_mask_<VEC_1REG_INT_MODE:mode>di.
	(vcondu<VEC_1REG_INT_MODE:mode><VEC_1REG_INT_ALT:mode>_exec): Likewise,
	but using the _exec comparison patterns.

From-SVN: r273159
2019-07-06 08:26:02 +00:00
Richard Sandiford
193bee751a [arm] Fix ambiguous .md attribute uses
This patch is part of a series that fixes ambiguous attribute
uses in .md files, i.e. cases in which attributes didn't use
<ITER:ATTR> to specify an iterator, and in which <ATTR> could
have different values depending on the iterator chosen.

I think this is a genuine bugfix for Thumb-1, since previously the
LDREX width was taken from the SImode success result rather than the
memory mode:

-#define HAVE_atomic_compare_and_swapt1qi_1 ((TARGET_HAVE_LDREX && TARGET_HAVE_MEMORY_BARRIER) && (TARGET_THUMB1))
-#define HAVE_atomic_compare_and_swapt1hi_1 ((TARGET_HAVE_LDREX && TARGET_HAVE_MEMORY_BARRIER) && (TARGET_THUMB1))
-#define HAVE_atomic_compare_and_swapt1di_1 ((TARGET_HAVE_LDREX && TARGET_HAVE_MEMORY_BARRIER) && (TARGET_THUMB1))
+#define HAVE_atomic_compare_and_swapt1qi_1 ((TARGET_HAVE_LDREXBH && TARGET_HAVE_MEMORY_BARRIER) && (TARGET_THUMB1))
+#define HAVE_atomic_compare_and_swapt1hi_1 ((TARGET_HAVE_LDREXBH && TARGET_HAVE_MEMORY_BARRIER) && (TARGET_THUMB1))
+#define HAVE_atomic_compare_and_swapt1di_1 ((TARGET_HAVE_LDREXD && ARM_DOUBLEWORD_ALIGN \
+       && TARGET_HAVE_MEMORY_BARRIER) && (TARGET_THUMB1))

The same goes for the predicate and constraints in
@atomic_compare_and_swapt1di_1, which previously used the
SI values from the success result.

2019-07-06  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/arm/sync.md
	(@atomic_compare_and_swap<CCSI:arch><NARROW:mode>_1): Use
	<NARROW:sync_predtab> instead of (implicitly) <CCSI:sync_predtab>.
	(@atomic_compare_and_swap<CCSI:arch><SIDI:mode>_1): Likewise
	<SIDI:sync_predtab>.  Use <SIDI:cas_cmp_operand> and
	<SIDI:cas_cmp_str>.

From-SVN: r273158
2019-07-06 08:25:26 +00:00
Jakub Jelinek
1f52d1a8b5 omp-low.c (struct omp_context): Add for_simd_scan_phase member.
* omp-low.c (struct omp_context): Add for_simd_scan_phase member.
	(maybe_lookup_ctx): Add forward declaration.
	(omp_find_scan): Likewise.  Walk into body of simd if composited
	with worksharing loop.
	(scan_omp_simd_scan): New function.
	(scan_omp_1_stmt): Call it.
	(lower_rec_simd_input_clauses): Don't create rvar nor rvar2 if
	ctx->for_simd_scan_phase.
	(lower_rec_input_clauses): Do much less work for inscan reductions
	in ctx->for_simd_scan_phase is_simd regions.
	(lower_omp_scan): Set is_simd also on simd constructs composited
	with worksharing loop, unless ctx->for_simd_scan_phase.  Never emit
	a sorry message.  Don't change GIMPLE_OMP_SCAN stmts into nops and
	emit their body after in simd constructs composited with worksharing
	loop.
	(lower_omp_for_scan): Handle worksharing loop composited with simd.

	* c-c++-common/gomp/scan-4.c: Don't expect sorry message.

	* testsuite/libgomp.c/scan-11.c: New test.
	* testsuite/libgomp.c/scan-12.c: New test.
	* testsuite/libgomp.c/scan-13.c: New test.
	* testsuite/libgomp.c/scan-14.c: New test.
	* testsuite/libgomp.c/scan-15.c: New test.
	* testsuite/libgomp.c/scan-16.c: New test.
	* testsuite/libgomp.c/scan-17.c: New test.
	* testsuite/libgomp.c/scan-18.c: New test.
	* testsuite/libgomp.c++/scan-9.C: New test.
	* testsuite/libgomp.c++/scan-10.C: New test.
	* testsuite/libgomp.c++/scan-11.C: New test.
	* testsuite/libgomp.c++/scan-12.C: New test.
	* testsuite/libgomp.c++/scan-13.C: New test.
	* testsuite/libgomp.c++/scan-14.C: New test.
	* testsuite/libgomp.c++/scan-15.C: New test.
	* testsuite/libgomp.c++/scan-16.C: New test.

From-SVN: r273157
2019-07-06 09:53:48 +02:00
Jakub Jelinek
5d1212877a re PR tree-optimization/91096 (Openmp vector max reduction incorrect)
PR tree-optimization/91096
	* gcc.dg/vect/vect-simd-10.c (FLT_MIN_VALUE): Define.
	(bar, main): Use it instead of -__builtin_inff ().
	* gcc.dg/vect/vect-simd-14.c (FLT_MIN_VALUE): Define.
	(bar, main): Use it instead of -__builtin_inff ().

From-SVN: r273156
2019-07-06 09:50:44 +02:00
Jakub Jelinek
2dcb0d5b59 omp-low.c (omp_find_scan): Make static.
* omp-low.c (omp_find_scan): Make static.
	(lower_omp_for_scan): Fix order of merge arguments in input phase of
	the second loop, var2 represents the first partial sum and so needs
	to go before rprivb[ivar].

From-SVN: r273155
2019-07-06 09:49:59 +02:00
GCC Administrator
e954337f3c Daily bump.
From-SVN: r273154
2019-07-06 00:16:36 +00:00
Jakub Jelinek
99e4ed7863 re PR c++/67184 (Missed optimization with C++11 final specifier)
PR c++/67184
	PR c++/69445
	* call.c (build_new_method_call_1): Remove set but not used variable
	binfo.

From-SVN: r273149
2019-07-05 22:51:44 +02:00
Iain Sandoe
9eb5f744ae [Darwin.PPC] Remove dead code.
TARGET_LINK_STACK is unused on Darwin, and only relevant to a processor on
which the port was never released.

2019-07-05  Iain Sandoe  <iain@sandoe.co.uk>

	* config/rs6000/rs6000-logue.c: Remove unused code.

From-SVN: r273148
2019-07-05 18:26:26 +00:00
Paolo Carlini
26f8363d85 PR c++/67184 (again)
/cp
2019-07-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67184 (again)
	PR c++/69445
	* call.c (build_over_call): Devirtualize user-defined operators
	coming from a base too.
	(build_new_method_call_1): Do not devirtualize here.

/testsuite
2019-07-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67184 (again)
	PR c++/69445
	* g++.dg/other/final4.C: New.

From-SVN: r273147
2019-07-05 18:03:05 +00:00
Eric Botcazou
131138d51d * tree-ssa-loop-manip.c (create_iv): Add missing guard for gsi_end_p.
From-SVN: r273145
2019-07-05 17:38:28 +00:00
Jonathan Wakely
0dc7adb037 Fix ODR violations in code using <ext/atomicity.h>
Because the inline versions of __exchange_and_add and __atomic_add are
also marked static, they cannot be used from templates or other inline
functions without ODR violations. This change gives them external
linkage, but adds the always_inline attribute.

    	* include/ext/atomicity.h [_GLIBCXX_ATOMIC_BUILTINS] (__atomic_add)
    	(__exchange_and_add): Replace static specifier with always_inline
    	attribute.
    	(__exchange_and_add_single, __atomic_add_single): Likewise.
    	(__exchange_and_add_dispatch, __atomic_add_dispatch): Likewise. Also
    	combine !__gthread_active_p() and !__GTHREADS branches.

From-SVN: r273144
2019-07-05 17:10:47 +01:00
Andrew Stubbs
6e158c5fd5 Tweak error message for mapped parameters.
2019-07-05  Andrew Stubbs  <ams@codesourcery.com>

	gcc/fortran/
	* openmp.c (resolve_omp_clauses): Add custom error messages for
	parameters in map clauses.

From-SVN: r273143
2019-07-05 16:00:46 +00:00
Marek Polacek
899a199767 DR 1813 PR c++/83374 - __is_standard_layout wrong for a class with repeated bases.
DR 1813
	PR c++/83374 - __is_standard_layout wrong for a class with repeated bases.
	* class.c (check_bases): Set CLASSTYPE_NON_STD_LAYOUT for a class if
	CLASSTYPE_REPEATED_BASE_P is true.

	* g++.dg/ext/is_std_layout3.C: New test.
	* g++.dg/ext/is_std_layout4.C: New test.

From-SVN: r273139
2019-07-05 14:45:30 +00:00
Sam Tebbs
2bdc7dcbbd [PATCH][GCC][AARCH64] PR target/90712 Fix gcc.dg/rtl/aarch64/subs_adds_sp.c regression
gcc/
2019-07-05  Sam Tebbs  <sam.tebbs@arm.com>

	PR target/90712
	* aarch64/aarch64.c (aarch64_post_cfi_startproc): Replace thunk check
	with a frame laid out check.

From-SVN: r273138
2019-07-05 13:16:55 +00:00
Richard Biener
66076dcb60 tree-ssa-sccvn.c (vn_reference_lookup_3): Valueize RHS when comparing against a store with possibly the same value.
2019-07-05  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.c (vn_reference_lookup_3): Valueize RHS
	when comparing against a store with possibly the same value.

	* gcc.dg/tree-ssa/ssa-fre-77.c: New testcase.

From-SVN: r273136
2019-07-05 12:53:19 +00:00
Richard Biener
fb4697e30b re PR tree-optimization/91091 ([missed optimization] Missing optimization in unaliased pointers)
2019-07-05  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91091
	* tree-ssa-alias.h (get_continuation_for_phi): Add tbaa_p parameter.
	(walk_non_aliased_vuses): Likewise.
	* tree-ssa-alias.c (maybe_skip_until): Pass down tbaa_p.
	(get_continuation_for_phi): New tbaa_p parameter and pass
	it down.
	(walk_non_aliased_vuses): Likewise.
	* ipa-prop.c (determine_known_aggregate_parts): Adjust.
	* tree-ssa-pre.c (translate_vuse_through_block): Likewise.
	* tree-ssa-scopedtables.c (avail_exprs_stack::lookup_avail_expr):
	Likewise.
	* tree-ssa-sccvn.c (struct vn_walk_cb_data): Add tbaa_p flag.
	(adjust_offsets_for_equal_base_address): New function.
	(vn_reference_lookup_3): Use it to catch more base equivalences.
	Handle and pass down tbaa_p flag.
	(vn_reference_lookup_pieces): Adjust.
	(vn_reference_lookup): Remove alias-set altering, instead pass
	down false as tbaa_p.

	* gcc.dg/tree-ssa/pr91091-2.c: New testcase.
	* gcc.dg/tree-ssa/ssa-fre-70.c: Likewise.
	* gcc.dg/tree-ssa/ssa-fre-71.c: Likewise.
	* gcc.dg/tree-ssa/ssa-fre-72.c: Likewise.

From-SVN: r273135
2019-07-05 12:50:45 +00:00
Richard Biener
75fad0a989 re PR tree-optimization/91091 ([missed optimization] Missing optimization in unaliased pointers)
2019-07-05  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91091
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Overlap of
	accesses can happen with -fno-strict-aliasing.

	* gcc.dg/tree-ssa/pr91091-1.c: New testcase.
	* gcc.dg/tree-ssa/ssa-fre-61.c: Adjust.

From-SVN: r273134
2019-07-05 12:48:42 +00:00
Jan Hubicka
1d77635313 tree-ssa-alias.c (alias_stats): Add nonoverlapping_component_refs_since_match_p_must_overlap.
* tree-ssa-alias.c (alias_stats): Add
	nonoverlapping_component_refs_since_match_p_must_overlap.
	(dump_alias_stats): Print it.
	(nonoverlapping_component_refs_since_match_p): Add early exit.
	(nonoverlapping_component_refs_p): Do not account early exit.

From-SVN: r273133
2019-07-05 09:25:45 +00:00
Eric Botcazou
4500f75103 except.c (emit_to_new_bb_before): Make sure to put a location on SEQ.
* except.c (emit_to_new_bb_before): Make sure to put a location on SEQ.
	* tree-eh.c (replace_goto_queue_1) <GIMPLE_GOTO>: Propagate location.
	(emit_eh_dispatch): Delete.
	(lower_catch): Emit the eh_dispatch manually and set the location of
	the first catch statement onto it.
	(lower_eh_filter): Emit the eh_dispatch manually and set location.
	(lower_eh_dispatch): Propagate location.
	* tree-outof-ssa.c (set_location_for_edge): Handle EH edges specially.
	(eliminate_build): Likewise.

From-SVN: r273132
2019-07-05 08:39:13 +00:00
Eric Botcazou
ffdc40a90f tree-cfg.c (gimple_make_forwarder_block): Propagate location info on phi nodes if possible.
* tree-cfg.c (gimple_make_forwarder_block): Propagate location info on
	phi nodes if possible.
	* tree-scalar-evolution.c (final_value_replacement_loop): Propagate
	location info on the newly created statement.
	* tree-ssa-loop-manip.c (create_iv): Propagate location info on the
	newly created increment if needed.

From-SVN: r273131
2019-07-05 08:28:36 +00:00
Justin Squirek
8d21ff6025 [Ada] Incorrect accessibility check
This patch fixes an issue whereby anonymous access result types were
treated as having the same accessibility level as typed results instead
of having the level determined by the "master of the call" as per RM
3.10.2 (10).

------------
-- Source --
------------

--  main.adb

with Pack_12; use Pack_12;
with Pack_05; use Pack_05;

procedure Main is
   Obj : aliased Integer;
begin
   Test_Alloc
     (new Rec_T'(Disc => Id_A (Obj'Access))); --  OK

   Id_A (Obj'Access).all := 0;                --  OK
   Id_B (Obj'Access).all := 0;                --  OK
   Id_C (Obj'Access).all := 0;                --  ERROR
end Main;

--  pack_12.ads

pragma Ada_2012;

with Ada.Unchecked_Conversion;

package Pack_12 is
   function Id_A (I : access Integer)
     return access Integer
     is (I);

   type Obj_Ptr is access all Integer;

   function Id_C (I : access Integer)
     return Obj_Ptr
     is (I.all'Access);

   type Rec_T (Disc : access Integer) is null record;

   procedure Test_Alloc (Access_Param : access Rec_T);
end Pack_12;

--  pack_12.adb

package body Pack_12 is
   Dummy : Integer;

   procedure Test_Alloc (Access_Param : access Rec_T) is
   begin
      Dummy := Access_Param.Disc.all;
   end Test_Alloc;
end Pack_12;

--  pack_05.ads

pragma Ada_2005;

with Pack_12; use Pack_12;

package Pack_05 is
   function Id_B (I : access Integer)
     return access Integer
     renames Id_A;
end Pack_05;

-----------------
-- Compilation --
-----------------

$ gnatmake -q main.adb
$ main
raised PROGRAM_ERROR : pack_12.ads:14 accessibility check failed

2019-07-05  Justin Squirek  <squirek@adacore.com>

gcc/ada/

	* checks.adb (Apply_Accessibility_Check): Add logic to fetch the
	function result accessibility level if one is required within
	the generated check.
	* exp_ch6.adb (Needs_Result_Accessibility_Level): Modify
	controlling elsif block to handle more cases such as anonymous
	access results and disable checking for coextensions.

From-SVN: r273130
2019-07-05 07:03:58 +00:00
Ed Schonberg
76e716d761 [Ada] Compiler loop on illegal nested accept statement
This patch fixes a "Compilation abandoned" message in a compiler built
with assertions, or a compiler loop otherwise, when an accept statement
contains an illegal accept statement for the same entry.

Compiling accept_in_accept.adb must yield:

accept_in_accept.adb:12:13:
          duplicate accept statement for same entry (RM 9.5.2 (15))

----
procedure accept_in_accept is

   task a_in_a is
      entry a (i : Integer);
   end a_in_a;

   task body a_in_a is
   begin
      select
         accept a (i : Integer) do
            null;
            accept a (i : integer) do
              null;
            end a;
         end a;
      or
         terminate;
      end select;
   end a_in_a;

begin
   a_in_a.a (1);
end accept_in_accept;

2019-07-05  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch9.adb (Analyze_Accept_Statement): If this is an illegal
	accept statement for an enclosing entry abandon analysis to
	prevent scope mismatches and potential infinite loops in
	compiler.

From-SVN: r273129
2019-07-05 07:03:54 +00:00
Hristian Kirtchev
3eb5e54a4a [Ada] Stabilization of Elaboration order v4.0
This patch introduces several changes to the new elaboration order
mechanism:

   * Instantiations processed in the context of invocation graph
     encoding now yield a relation which is later transformed into an
     invocation edge. This ensures that the unit where the instantiation
     resides properly depends on the unit where the body of the generic
     is.

   * The diagnostics of cycles that involve invocation edges now use a
     set to avoid infinite recursion when visiting paths that represent
     recursive code.

   * Various diagnostics that suggest the use of switches have been
     updated to indicate which tool the switches apply to.

   * Bindo can now output the dependencies of various units that specify
     why a predecessor unit must be elaborated prior to a successor
     unit. This functionality implements binder switch -e (output
     complete list of elaboration order dependencies).

   * The output of the elaboration order is now identical to that
     emitted by Binde.

   * The nature of the invocation graph encoding is now recorded in the
     ALI record rather than the Unit record of a unit. This ensures that
     both the spec and body share the same encoding kind.

   * A section on debugging elaboration order issues is now available in
     Bindo.

2019-07-05  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* ali.adb (For_Each_Invocation_Construct,
	For_Each_Invocation_Relation): New version.
	(Scan_ALI): Initialize field Invocation_Graph_Encoding.
	(Set_Invocation_Graph_Encoding): Update the setting of the
	invocation graph encoding.
	* ali.ads: Move field Invocation_Graph_Encoding from Unit_Record
	to ALI_Record because the encoding applies to the whole ALI,
	rather than one of the units (spec or body) for which the ALI
	file was created.
	(For_Each_Invocation_Construct, For_Each_Invocation_Relation):
	New version.
	* bindo.adb: Update the section on switches.  Complete the
	section of debugging elaboration order issues.
	(Find_Elaboration_Order): Prepare the routine for the switch
	from the old to the new elaboration order mechanism.
	* bindo-diagnostics.adb (Find_And_Output_Invocation_Paths):
	Manage a visited set used by Visit_Vertex.
	(Output_All_Cycles_Suggestions,
	Output_Dynamic_Model_Suggestions): Clarify the nature of the
	suggested switch.
	(Output_Elaborate_Body_Transition): Update the diagnostic to
	emit a better message.
	(Output_Forced_Suggestions, Output_Full_Encoding_Suggestions):
	Clarify the nature of the suggested switch.
	(Visit_Vertex): Update the parameter profile to add a set of
	invokers visited during the transition. This set prevents
	infinite exploration of the graph in case the invocations are
	recursive.
	* bindo-elaborators.adb: Add a use clause for
	Bindo.Writers.Dependency_Writers.
	(Elaborate_Units_Common): Output the library graph after it has
	been augmented with invocation edges. Output just the components
	instead of outputting the whole library graph again.
	(Elaborate_Units_Dynamic, Elaborate_Units_Static): Output the
	dependencies as expressed in the library graph.
	* bindo-units.adb (Invocation_Graph_Encoding): Update the
	extraction of the invocation graph encoding.
	* bindo-writers.adb: Add with and use clauses for Binderr and
	Butil.
	(palgc, plgc): New debug routine.
	(Write_Components): Moved to the spec. Add a header for the
	output.
	(Write_Dependencies, Write_Dependencies_Of_Vertex,
	Write_Dependency_Edge): New routine.
	(Write_Elaboration_Order): Update the logic to follow the format
	of Binde's order output.
	(Write_Library_Graph): Do not output the components every time
	the graph is written.
	(Write_Unit): Output the invocation graph encoding of the unit.
	Output the invocation constructs and relations for the unit
	only.
	* bindo-writers.ads (Write_Components): Moved from the body.
	(Write_Dependencies): New routine.
	* bindusg.adb: Prepare the routine for the switch from the old
	to the new elaboration order mechanism.
	* debug.adb: Binder switch -d_O is now not associated with any
	functionality.
	* einfo.adb (Is_Elaboration_Target): The attribute applies to
	packages, as specified by the comment on the attribute usage.
	* opt.ads: Add a global flag which controls the choice between
	the new and the legacy elaboration order mechanism.
	* sem_elab.adb: Add Package_Target to type Target_Kind.
	(Build_Elaborate_Body_Procedure, Build_Elaborate_Procedure,
	Build_Elaborate_Spec_Procedure, Check_Elaboration_Scenarios,
	Check_SPARK_Model_In_Effect): Use Main_Unit_Entity to obtain the
	entity of the main unit.
	(Create_Package_Rep): New routine.
	(Create_Target_Rep): Add processing for packages.
	(Declaration_Placement_Of_Node, Has_Prior_Elaboration): Use
	Main_Unit_Entity to obtain the entity of the main
	 unit.
	(Invocation_Graph_Recording_OK): Prepare the routine for the
	switch from the old to the new elaboration order mechanism.
	(Main_Unit_Entity): New routine.
	(Meet_Elaboration_Requirement,
	Process_Conditional_ABE_Variable_Reference): Use
	Main_Unit_Entity to obtain the entity of the main unit.
	(Process_Invocation_Instantiation): New routine.
	(Process_Invocation_Scenario): Add processing for
	instantiations.
	* switch-b.adb (Scan_Binder_Switches): Prepare the routine for
	the switch from the old to the new elaboration order mechanism.

From-SVN: r273128
2019-07-05 07:03:49 +00:00
Joffrey Huguet
2ff7c60437 [Ada] Add contracts to Ada.Text_IO for SPARK
This change removes the warnings returned when using Ada.Text_IO library
in SPARK. An abstract state and global contracts were added to modelize
the action of Text_IO procedures and function on the memory and the
files.

2019-07-05  Joffrey Huguet  <huguet@adacore.com>

gcc/ada/

	* libgnat/a-textio.adb: Add abstract state refinment.
	* libgnat/a-textio.ads: Add File_System abstract state.  Add
	global contracts, contract cases, preconditions and
	postconditions to procedures and functions.
	(Set_Input, Set_Output, Set_Error, Standard_Input,
	Standard_Output, Standard_Error, Current_Input, Current_Output,
	Current_Error): Turn SPARK_Mode off.
	(Get_Line): Turn SPARK_Mode off on Get_Line functions.
	* libgnat/a-tideio.ads, libgnat/a-tienio.ads,
	libgnat/a-tifiio.ads, libgnat/a-tiflio.ads,
	libgnat/a-tiinio.ads, libgnat/a-timoio.ads: Add global
	contracts, contract cases, preconditions and postconditions to
	procedures and functions.

From-SVN: r273127
2019-07-05 07:03:44 +00:00
Arnaud Charlet
b7469acf1c [Ada] GNAT UGN: refresh doc on installing from the cmd line on Windows
2019-07-05  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* doc/gnat_ugn/platform_specific_information.rst: Refresh doc on
	installing from the command line on Windows.  Remove obsolete
	part.
	* gnat_ugn.texi: Regenerate.

From-SVN: r273126
2019-07-05 07:03:39 +00:00
Vasiliy Fofanov
1e70cf2eba [Ada] Ada.Wide_Wide_Characters.Handling: fix comments
2019-07-05  Vasiliy Fofanov  <fofanov@adacore.com>

gcc/ada/

	* libgnat/a-wichha.ads (Is_Alphanumeric): Replace comment with
	the correct one.  Also capitalize references to False
	throughout.

From-SVN: r273125
2019-07-05 07:03:35 +00:00
Eric Botcazou
d21328a0d4 [Ada] Fix internal error on packed array In/Out actual parameter
This fixes an issue introduced in Ada 2012 for calls to functions taking
an In/Out parameter and for which the actual is the component of a
packed array.  In this case, the front-end needs to create a temporary
for the actual, initialize it before the call and assign it back after
it, because operations on bit-packed arrays are converted into
mask-and-shift sequences.

2019-07-05  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_N_Indexed_Component): Do not expand actual
	parameters of function calls here either.

gcc/testsuite/

	* gnat.dg/pack23.adb, gnat.dg/pack23_pkg.ads: New testcase.

From-SVN: r273124
2019-07-05 07:03:30 +00:00
Hristian Kirtchev
6d0289b1ec [Ada] Minor reformatting
2019-07-05  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* bindo-units.adb, checks.adb, exp_attr.adb, exp_ch3.adb,
	exp_ch4.adb, exp_pakd.adb, lib-writ.adb, libgnat/g-traceb.adb,
	libgnat/g-traceb.ads, libgnat/s-stratt.ads, sem_aux.ads,
	sem_util.adb: Minor reformatting.

From-SVN: r273123
2019-07-05 07:03:25 +00:00
Ed Schonberg
c365eb26e8 [Ada] Fix position of subprogram body generated for static predicate
2019-07-05  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch13.adb (Build_Predicate_Functions): If a subtype that
	carries a static predicate aspect is frozen immediately after
	its declaration, ensure that the generated function body created
	for predicate checking is inserted after the corresponding
	subprogram declaration, which is created at the point the
	declaration is elaborated.

From-SVN: r273122
2019-07-05 07:03:20 +00:00
Hristian Kirtchev
9880061b34 [Ada] Crash on deallocating component with discriminated task
This patch modifies the generation of task deallocation code to examine
the underlying type for task components.

2019-07-05  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_ch7.adb (Cleanup_Record): Use the underlying type when
	checking for components with tasks.

gcc/testsuite/

	* gnat.dg/task3.adb, gnat.dg/task3.ads, gnat.dg/task3_pkg1.ads,
	gnat.dg/task3_pkg2.ads: New testcase.

From-SVN: r273121
2019-07-05 07:03:15 +00:00
Arnaud Charlet
d90eeca129 [Ada] System.OS_Interface: fix link order on Linux
2019-07-05  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* libgnarl/s-osinte__linux.ads: Link with -lrt before -lpthread.

From-SVN: r273120
2019-07-05 07:03:10 +00:00
Ed Schonberg
4f469dec55 [Ada] Missing range check on assignment to bit-packed array
This patch adds an explicit range check on an assignment to a component
of a bit-packed array, when the index type of the array is an
enumeration type with a non-standard representation,

Executing the following:

   gnatmake -f -gnata -q main
   ./main

must yield:

   1 is invalid
    4097 is invalid
    4116 is invalid
    4117 is invalid
    4118 is invalid
    4119 is invalid
    4120 is invalid
    4121 is invalid

----
with Example;     use Example;
with My_Types;    use My_Types;
with Text_IO; use Text_IO;

procedure main is
begin
   --We try to access an invalid array location.
    begin
     dummy(idx    => 1,    action => DISABLE);
    exception
       when others => Text_IO.Put_Line ("1 is invalid");
    end;

      for I in typ_uint32'(16#1000#) .. 16#101E#  loop
         declare
         begin
            --  Text_IO.Put_Line (typ_uint32'image(I) & " OK");
            Dummy (Idx => I, action => Enable);
        exception
            when others => put_line (typ_uint32'Image (I) & " is invalid");
         end;
      end loop;
end;
----
with Interfaces;     use Interfaces;

package My_Types is

   subtype typ_bool is boolean;

   type typ_uint32 is new Interfaces.Unsigned_32;
   subtype typ_uint16 is typ_uint32 range 0..2**16 - 1;

   type typ_dis_en is ( DISABLE, ENABLE );
   for typ_dis_en'size use 32;
   for typ_dis_en use ( DISABLE => 0, ENABLE  => 1 );

type typ_rid is
   (
      RID_0,
      RID_2,
      RID_3,
      RID_4,
      RID_5,
      RID_6,
      RID_7,
      RID_8,
      RID_9,
      RID_10,
      RID_11,
      RID_12,
      RID_13,
      RID_14,
      RID_15,
      RID_16,
      RID_17,
      RID_18,
      RID_19,
      RID_26,
      RID_27,
      RID_28,
      RID_29,
      RID_30
   );
for typ_rid use
   (
      RID_0   =>  16#1000#,
      RID_2   =>  16#1002#,
      RID_3   =>  16#1003#,
      RID_4   =>  16#1004#,
      RID_5   =>  16#1005#,
      RID_6   =>  16#1006#,
      RID_7   =>  16#1007#,
      RID_8   =>  16#1008#,
      RID_9   =>  16#1009#,
      RID_10  =>  16#100A#,
      RID_11  =>  16#100B#,
      RID_12  =>  16#100C#,
      RID_13  =>  16#100D#,
      RID_14  =>  16#100E#,
      RID_15  =>  16#100F#,
      RID_16  =>  16#1010#,
      RID_17  =>  16#1011#,
      RID_18  =>  16#1012#,
      RID_19  =>  16#1013#,
      RID_26  =>  16#101A#,
      RID_27  =>  16#101B#,
      RID_28  =>  16#101C#,
      RID_29  =>  16#101D#,
      RID_30  =>  16#101E#
   );
for typ_rid'size use 16;

end My_Types;

----
with My_Types;

package  Example is

procedure Check;
procedure dummy
   (
     idx        : in My_Types.typ_uint32;
     action     : in My_Types.typ_dis_en
   );

end Example;
----
with Text_IO; use Text_IO;
with Unchecked_Conversion;
with my_types; use my_types;
package body Example is

   type typ_rid_sts is array (My_Types.typ_rid)
      of My_Types.typ_bool;
   for typ_rid_sts'component_size use 1;

   is_rid_en : typ_rid_sts :=
      (TRUE, false, True, False, true, False, True, false, True, False,
      TRUE, false, True, False, true, False, True, false, True, False,
      TRUE, false, True, False);

   procedure Check is
   begin
     pragma Assert (for all I in is_rid_en'range => is_rid_en (I));
   end Check;

   function toRidEvt is new Unchecked_Conversion
      (
         -- Defining source and target types
         source => My_Types.typ_uint16,
         target => My_Types.typ_rid
      );

   procedure dummy (
     idx        : in My_Types.typ_uint32;
     action     : in My_Types.typ_dis_en)
   is
      rid_evt      : My_Types.typ_rid;

   begin

      rid_evt := toRidEvt(idx);

      if action = My_Types.ENABLE
      then
         is_rid_en(rid_evt) := TRUE;
      else
         is_rid_en(rid_evt) := FALSE;
      end if;

   end dummy;
end Example;

2019-07-05  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_pakd.adb (Expand_Bit_Packed_Element_Set): Add explicit
	range checks when the index type of the bit-packed array is an
	enumeration type with a non-standard representation,

From-SVN: r273119
2019-07-05 07:03:05 +00:00
Hristian Kirtchev
be0443c302 [Ada] Failure to detect trivial infinite recursion
This patch includes delay statements in the set of control flow
statements since their expressions may have side effects, which in turn
may affect an infinite recursion.

2019-07-05  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* sem_res.adb (Is_Control_Flow_Statement): Delay statements
	contain an expression, which in turn may have side effects and
	affect the infinite recursion. As a result, delay statements
	should not be treated specially.

From-SVN: r273118
2019-07-05 07:03:00 +00:00
Arnaud Charlet
fe04f57a81 [Ada] System.Linux: fix typos in comments
2019-07-05  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* libgnarl/s-linux.ads, libgnarl/s-linux__alpha.ads,
	libgnarl/s-linux__android.ads, libgnarl/s-linux__hppa.ads,
	libgnarl/s-linux__mips.ads, libgnarl/s-linux__riscv.ads,
	libgnarl/s-linux__sparc.ads: Fix typos in comments.

From-SVN: r273117
2019-07-05 07:02:56 +00:00
Hristian Kirtchev
60a38ae15c [Ada] Failure to detect trivial infinite recursion
This patch reimplements the detection of trivial infinite recursion to
remove the implicit assumptions concenring the structure and contents of
the enclosing subprogram statements.

------------
-- Source --
------------

--  infinite.adb

procedure Infinite with SPARK_Mode is
   function Func_1 (Val : Integer) return Integer;
   function Func_2 (Val : Integer) return Integer;
   function Func_3 (Val : Integer) return Integer;
   function Func_4 (Val : Integer) return Integer;
   function Func_5 (Val : Integer) return Integer;
   function Func_6 (Val : Integer) return Integer;
   function Func_7 (Val : Integer) return Integer;
   function Func_8 (Val_1 : Integer; Val_2 : Integer) return Integer;
   procedure Proc_1 (Val : Integer);

   function Func_1 (Val : Integer) return Integer is
   begin
      return Func_1 (Val);                                           --  WARN
   end Func_1;

   function Func_2 (Val : Integer) return Integer is
   begin
      return Func_2 (123);                                           --  none
   end Func_2;

   function Func_3 (Val : Integer) return Integer is
      Temp : Integer;
   begin
      Temp := Func_3 (Val);                                          --  WARN
      return Temp;
   end Func_3;

   function Func_4 (Val : Integer) return Integer is
      Temp : Integer;
   begin
      Temp := Func_4 (123);                                          --  none
      return Temp;
   end Func_4;

   function Func_5 (Val : Integer) return Integer is
   begin
      Proc_1 (Val);
      return Func_5 (Val);                                           --  none
   end Func_5;

   function Func_6 (Val : Integer) return Integer is
   begin
      Proc_1 (Val);
      return Func_6 (123);                                           --  none
   end Func_6;

   function Func_7 (Val : Integer) return Integer is
   begin
      raise Program_Error;
      return Func_7 (Val);                                           --  none
   end Func_7;

   function Func_8 (Val_1 : Integer; Val_2 : Integer) return Integer is
   begin
      return Func_8 (Val_1, 123);                                    --  none
   end Func_8;

   procedure Proc_1 (Val : Integer) is
   begin
      Proc_1 (Val);                                                  --  WARN
   end Proc_1;

begin null; end Infinite;

----------------------------
-- Compilation and output --
----------------------------

$ gcc -c infinite.adb
infinite.adb:14:14: infinite recursion
infinite.adb:14:14: Storage_Error would have been raised at run time
infinite.adb:25:15: infinite recursion
infinite.adb:25:15: Storage_Error would have been raised at run time
infinite.adb:61:07: infinite recursion
infinite.adb:61:07: Storage_Error would have been raised at run time

2019-07-05  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* sem_res.adb (Check_Infinite_Recursion): Reimplemented.
	(Enclosing_Declaration_Or_Statement,
	Invoked_With_Different_Arguments, Is_Conditional_Statement,
	Is_Control_Flow_Statement, Is_Immediately_Within_Body,
	Is_Raise_Idiom, Is_Raise_Statement, Is_Sole_Statement,
	Preceded_By_Control_Flow_Statement,
	Within_Conditional_Statement): New routines.

From-SVN: r273116
2019-07-05 07:02:51 +00:00
Javier Miranda
43fa58c26a [Ada] Wrong accessibility level under -gnat12
For an anonymous allocator whose type is that of a stand-alone object of
an anonymous access-to-object type, the accessibility level is that of
the declaration of the stand-alone object; however it was incorrectly
computed as being library level compiling under -gnat12 mode.

2019-07-05  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_N_Type_Conversion): Do not apply an
	accessibility check when the conversion is an access to
	class-wide interface type and it is an actual parameter.
	* exp_ch6.adb (Expand_Call_Helper): Add documentation on the
	accessibility level of an anonymous allocator defining the value
	of an access parameter.
	* sem_util.ads, sem_util.adb (Dynamic_Accessibility_Level): Add
	support for an anonymous allocator whose type is that of a
	stand-alone object of an anonymous access to object type.

gcc/testsuite/

	* gnat.dg/access6.adb: New testcase.

From-SVN: r273115
2019-07-05 07:02:46 +00:00
Piotr Trojanek
6cc8550483 [Ada] Typo fixes
2019-07-05  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* einfo.ads, sem_res.adb: Typo fixes in comments.

From-SVN: r273114
2019-07-05 07:02:41 +00:00
Bob Duff
adc81ec81d [Ada] Crash on exported build-in-place function
This patch fixes a bug where if a function is build-in-place, and is
exported, and contains an extended_return_statement whose object is
initialized with another build-in-place function call, then the compiler
will crash.

2019-07-05  Bob Duff  <duff@adacore.com>

gcc/ada/

	* exp_ch6.adb (Is_Build_In_Place_Function): Narrow the check for
	Has_Foreign_Convention to the imported case only.  If a
	build-in-place function is exported, and called from Ada code,
	build-in-place protocols should be used.

gcc/testsuite/

	* gnat.dg/bip_export.adb, gnat.dg/bip_export.ads: New testcase.

From-SVN: r273113
2019-07-05 07:02:37 +00:00
Ed Schonberg
7145d799a3 [Ada] Spurious error on aggregate with choice that is predicted subtype
This patch fixes a spurious error on a record aggregate for a variant
record when a choice in the aggregate is given by a subtype with a
static predicate. The same expansion mechanism for such a variant, used
in case statements, must be used here as well.

2019-07-05  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_util.adb (Encloing_Subprogram): If Enclosing_Dynamic_Scope
	is a loop, continue climbing the scope stack to find the
	enclosing subprogram.
	(Gather_Components): Handle properly a choice in a record
	aggregate that is given by a subtype with a static predicate.

gcc/testsuite/

	* gnat.dg/aggr25.adb, gnat.dg/aggr25.ads: New testcase.

From-SVN: r273112
2019-07-05 07:02:32 +00:00
Javier Miranda
de70d01f1a [Ada] Removing support for SCIL "contract-only" subprogram bodies
Remove support added for CodePeer (which was never enabled by default;
it was controlled by the -gnatd.K option) for generation of SCIL
"contract-only" subprogram bodies. These were intended for use when a
subprogram's "real" body is unavailable but the subprogram spec has
pre/post-conditions specified.

2019-07-05  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* debug.adb (-gnatd.K): Leave available this switch.
	* contracts.adb (Build_And_Analyze_Contract_Only_Subprograms):
	Remove.
	* scil_ll.ads, scil_ll.adb (Contract_Only_Body_Flag,
	Contract_Only_Body_Nodes, Get_Contract_Only_Body,
	Is_Contract_Only_Body, Set_Contract_Only_Body): Remove.

From-SVN: r273111
2019-07-05 07:02:28 +00:00
Pierre-Marie de Rodat
034a6629f4 [Ada] Import documentation from the RM for Ada.Strings.Unbounded
2019-07-05  Pierre-Marie de Rodat  <derodat@adacore.com>

gcc/ada/

	* libgnat/a-strunb.ads: Import documentation from the RM

From-SVN: r273110
2019-07-05 07:02:23 +00:00
Pierre-Marie de Rodat
13e8f0ed8e [Ada] Import documentation from the RM for Ada.Strings.Fixed
2019-07-05  Pierre-Marie de Rodat  <derodat@adacore.com>

gcc/ada/

	* libgnat/a-strfix.ads: Import documentation from the RM

From-SVN: r273109
2019-07-05 07:02:17 +00:00
Yannick Moy
9cbb5574cd [Ada] Accept compilation switches -Og/-Ofast in non-GCC backends
Tools like GNATprove built as GNAT backends rely on adabkend.adb to
handle generic switches like the optimisation switches -Oxxx.
This patch adds support for -Og and -Ofast that was missing.

There is no impact on compilation.

2019-07-05  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* adabkend.adb (Scan_Back_End_Switches): Accept -Og and -Ofast
	switches.

From-SVN: r273108
2019-07-05 07:02:13 +00:00
Hristian Kirtchev
9795b20366 [Ada] Diagnostics in Elaboration order v4.0
This patch introduces several changes to the new elaboration order
mechanism:

  * The library graph can now discover, store, and organize the various
    cycles it contains.

  * The elaboration order mechanism can now diagnose one or all cycles
    within the library graph. Diagnostics consist of describing the
    reason for the cycle, listing all units comprising the circuit, and
    offering suggestions on how to break the cycle.

The patch also modifies unit ALI to hide all invocation-related data
structures and several implementation-specific types by relocating them
in the body of the unit.

The patch cleans up most children of Bindo by using better names of
routines and formal parameters.

------------
-- Source --
------------

--  a.ads

with B; pragma Elaborate_All (B);
with C; pragma Elaborate_All (C);

package A is
end A;

--  b.ads

package B is
   procedure Force_Body;
end B;

--  b.adb

with D;

package body B is
   procedure Force_Body is null;

   Elab : constant Integer := D.Func;
end B;

--  c.ads

package C is
   procedure Force_Body;
end C;

--  c.adb

with E;

package body C is
   procedure Force_Body is null;
end C;

--  d.ads

package D is
   function Func return Integer;
end D;

--  d.adb

with A;

package body D is
   Local : Integer := 123;

   function Func return Integer is
   begin
      return Local;
   end Func;
end D;

--  e.ads

with A;

package E is
end E;

--  main.adb

with B;

--             Elaborate_All             Elaborate_All               with
--    C spec <--------------- A spec ---------------------> B spec <------ Main
--      ^                      ^  ^                           ^
--      |                      |  |                           |
--  sbb |                      |  |                           | sbb
--      |                      |  |                           |
--    C body -----------> E spec  |       D spec <--------- B body
--               with             |         ^       with      |
--                                |         |                 |
--                                |     sbb |                 |
--                                |         |                 |
--                                +------ D body <------------+
--                                  with           Invocation
--
--  The cycles are
--
--    A spec --> C spec --> E spec --> A spec
--               C body
--
--    A spec --> B spec --> D body --> A spec
--               B body

procedure Main is begin null; end Main;

----------------------------
-- Compilation and output --
----------------------------

$ gnatmake -q main.adb -bargs -d_C -d_N
error: Elaboration circularity detected
info:
info:    Reason:
info:
info:      unit "a (spec)" depends on its own elaboration
info:
info:    Circularity:
info:
info:      unit "a (spec)" has with clause and pragma Elaborate_All for unit
             "b (spec)"
info:      unit "b (body)" is in the closure of pragma Elaborate_All
info:      unit "b (body)" has with clause for unit "d (spec)"
info:      unit "d (body)" is in the closure of pragma Elaborate_All
info:      unit "d (body)" has with clause for unit "a (spec)"
info:
info:    Suggestions:
info:
info:      change pragma Elaborate_All for unit "b (spec)" to Elaborate in unit
             "a (spec)"
info:      remove pragma Elaborate_All for unit "b (spec)" in unit "a (spec)"
info:
error: Elaboration circularity detected
info:
info:    Reason:
info:
info:      unit "a (spec)" depends on its own elaboration
info:
info:    Circularity:
info:
info:      unit "a (spec)" has with clause and pragma Elaborate_All for unit
             "c (spec)"
info:      unit "c (body)" is in the closure of pragma Elaborate_All
info:      unit "c (body)" has with clause for unit "e (spec)"
info:      unit "e (spec)" has with clause for unit "a (spec)"
info:
info:    Suggestions:
info:
info:      change pragma Elaborate_All for unit "c (spec)" to Elaborate in unit
             "a (spec)"
info:      remove pragma Elaborate_All for unit "c (spec)" in unit "a (spec)"
info:
gnatmake: *** bind failed.

2019-07-05  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* ali.adb: Relocate types Invocation_Construct_Record,
	Invocation_Relation_Record, and Invocation_Signature_Record to
	the body of ALI.  Relocate tables Invocation_Constructs,
	Invocation_Relations, and Invocation_Signatures to the body of
	ALI.  Remove type Body_Placement_Codes.  Add new types
	Declaration_Placement_Codes, and
	Invocation_Graph_Encoding_Codes.  Update the literals of type
	Invocation_Graph_Line_Codes.
	(Add_Invocation_Construct): Update the parameter profile. Add an
	invocation construct built from all attributes provided.
	(Add_Invocation_Relation): Update the parameter profile. Add an
	invocation relation built from all attributes provided.
	(Body_Placement): New routine.
	(Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind):
	Removed.
	(Code_To_Declaration_Placement_Kind,
	Code_To_Invocation_Graph_Encoding_Kind, Column,
	Declaration_Placement_Kind_To_Code, Extra,
	For_Each_Invocation_Construct, For_Each_Invocation_Relation,
	Invocation_Graph_Encoding,
	Invocation_Graph_Encoding_Kind_To_Code, Invoker, Kind, Line,
	Locations, Name): New routine.
	(Scan_Invocation_Construct_Line): Reimplement the scanning
	mechanism.
	(Scan_Invocation_Graph_Attributes_Line): New routine.
	(Scan_Invocation_Graph_Line): Use a case statement to dispatch.
	(Scan_Invocation_Relation_Line): Reimplement the scanning
	mechanism.
	(Scope): New routine.
	(Set_Invocation_Graph_Encoding, Signature, Spec_Placement,
	Target): New routine.
	* ali.ads: Add new type Invocation_Graph_Encoding_Kind.  Add
	component Invocation_Graph_Encoding to type Unit_Record.
	Relocate various types and data structures to the body of ALI.
	(Add_Invocation_Construct, Add_Invocation_Relation): Update the
	parameter profile.
	(Body_Placement): New routine.
	(Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind):
	Removed.
	(Code_To_Declaration_Placement_Kind,
	Code_To_Invocation_Graph_Encoding_Kind, Column,
	Declaration_Placement_Kind_To_Code, Extra,
	For_Each_Invocation_Construct, For_Each_Invocation_Relation,
	Invocation_Graph_Encoding,
	Invocation_Graph_Encoding_Kind_To_Code, Invoker, Kind, Line,
	Locations, Name, Scope, Set_Invocation_Graph_Encoding,
	Signature, Spec_Placement, Target): New routine.
	* bindo.adb: Add with clause for Binde.  Add with and use
	clauses for Debug.  Update the documentation.  Add new switches.
	(Find_Elaboration_Order): Dispatch to the proper elaboration
	mechanism.
	* bindo-augmentors.adb:
	Remove with and use clauses for GNAT and GNAT.Sets.  Remove
	membership set VS.  Update the parameter profiles of most
	routines to use better parameter names.  Update the
	implementation of most routine to use the new parameter names.
	Remove various redundant assertions.
	* bindo-builders.adb: Use better names for instantiated data
	structures. Update all references to these names.  Update the
	parameter profiles of most routines to use better parameter
	names.  Update the implementation of most routine to use the new
	parameter names.
	(Build_Library_Graph): Update the parameter profile. Update the
	call to Create.
	(Create_Vertex): Reimplemented.
	(Declaration_Placement_Vertex): New routine.
	* bindo-builders.ads (Build_Library_Graph): Update the parameter
	profile and comment on usage.
	* bindo-diagnostics.adb: Almost a new unit.
	* bindo-diagnostics.ads: Add a use clause for
	Bindo.Graphs.Invocation_Graphs.  Remove package
	Cycle_Diagnostics.
	(Diagnose_Circularities): New routine.
	* bindo-elaborators.adb: Remove the with and use clauses for
	Binderr and GNAT.Sets.  Remove the use clause for
	Bindo.Diagnostics.Cycle_Diagnostics.  Remove membership set VS.
	Update the parameter profiles of most routines to use better
	parameter names.  Update the implementation of most routine to
	use the new parameter names.  (Elaborate_Units_Common): Update
	the parameter profile. Pass an infication to the library graph
	builder whether the dynamic model is in effect.
	(Elaborate_Units_Dynamic, Elaborate_Units_Static): Use
	Diagnose_Circularities to provide diagnostics.
	(Update_Successor): Use routine In_Same_Component to determine
	whether the predecessor and successor reside in different
	components.
	* bindo-graphs.adb: Add with and use clauses for Butil, Debug,
	Output, and Bindo.Writers.  Remove with and use clauses for
	GNAT.Lists.  Update the parameter profiles of most routines to
	use better parameter names.  Update the implementation of most
	routine to use the new parameter names.  Remove various
	redundant assertions.  Remove doubly linked list EL.  Add new
	type Precedence_Kind.
	(Add_Cycle): New routine.
	(Add_Vertex): Update the parameter profile. Update the creation
	of vertex attributes.
	(Add_Vertex_And_Complement, Body_Vertex, Column,
	Complementary_Vertex, Copy_Cycle_Path, Cycle_Kind_Of): New
	routines.
	(Destroy_Invocation_Graph_Edge, Destroy_Library_Graph_Cycle,
	Destroy_Library_Graph_Edge, Extra, File_Name,
	Find_All_Cycles_Through_Vertex, Find_All_Cycles_With_Edge,
	Find_Cycles, Find_First_Lower_Precedence_Cycle,
	Get_LGC_Attributes, Has_Next, Hash_Library_Graph_Cycle,
	Hash_Library_Graph_Cycle_Attributes, Highest_Precedence_Cycle,
	Highest_Precedence_Edge, In_Same_Component, Insert_And_Sort,
	Invocation_Edge_Count, Invocation_Graph_Encoding,
	Is_Cycle_Initiating_Edge, Is_Cyclic_Edge,
	Is_Cyclic_Elaborate_All_Edge, Is_Cyclic_Elaborate_Body_Edge,
	Is_Cyclic_Elaborate_Edge, Is_Cyclic_Forced_Edge,
	Is_Cyclic_Invocation_Edge, Is_Cyclic_With_Edge,
	Is_Dynamically_Elaborated, Is_Elaborate_All_Edge,
	Is_Elaborate_Body_Edge, Is_Elaborate_Edge: New routines.
	(Is_Existing_Predecessor_Successor_Relation): Removed.
	(Is_Forced_Edge, Is_Invocation_Edge, Is_Recorded_Cycle,
	Is_Recorded_Edge, Is_With_Edge, Iterate_Edges_Of_Cycle, Kind,
	Length): New routine.
	(Lib_Vertex): Removed.
	(Line, Links_Vertices_In_Same_Component,
	Maximum_Invocation_Edge_Count, Next, Normalize_And_Add_Cycle,
	Normalize_Cycle_Path, Number_Of_Cycles, Path, Precedence,
	Remove_Vertex_And_Complement, Sequence_Next_Cycle): New routines.
	(Sequence_Next_IGE_Id): Renamed to Sequence_Next_Edge.
	(Sequence_Next_IGV_Id): Renamed to Sequence_Next_Vertex.
	(Sequence_Next_LGE_Id): Renamed to Sequence_Next_Edge.
	(Sequence_Next_LGV_Id): Renamed to Sequence_Next_Vertex.
	(Set_Is_Existing_Predecessor_Successor_Relation): Removed.
	(Set_Is_Recorded_Cycle, Set_Is_Recorded_Edge,
	Set_LGC_Attributes, Spec_Vertex, Trace_Cycle, Trace_Edge,
	Trace_Eol, Trace_Vertex): New routines.
	* bindo-graphs.ads: Add with and use clauses for Types and
	GNAT.Lists.  Update the parameter profiles of most routines to
	use better parameter names.  Update the implementation of most
	routine to use the new parameter names.  Add the new
	instantiated data structures IGE_Lists, IGV_Sets, LGC_Lists,
	LGE_Lists, LGE_Sets, LGV_Sets, and RC_Sets.  Add new type
	Library_Graph_Cycle_Id along with an empty and initial value.
	Remove component Lib_Vertex and add new components Body_Vertex
	and Spec_Vertex to type Invocation_Graph_Vertex_Attributes.  Add
	new type Library_Graph_Cycle_Kind.  Add new iterators
	All_Cycle_Iterator and Edges_Of_Cycle_Iterator.  Add new type
	Library_Graph_Cycle_Attributes.  Add new components
	Cycle_Attributes, Cycles, and Dynamically_Elaborated to type
	Library_Graph_Attributes.
	(Body_Vertex, Column, Destroy_Invocation_Graph_Edge,
	Destroy_Library_Graph_Cycle_Attributes,
	Destroy_Library_Graph_Edge, Extra, File_Name, Find_Cycles,
	Has_Elaborate_All_Cycle, Has_Next, Hash_Library_Graph_Cycle,
	Hash_Library_Graph_Cycle_Attributes, Highest_Precedence_Cycle,
	In_Same_Component, Invocation_Edge_Count,
	Invocation_Graph_Encoding, Is_Dynamically_Elaborated,
	Is_Elaborate_All_Edge, Is_Elaborate_Body_Edge,
	Is_Elaborate_Edge, Is_Forced_Edge, Is_Invocation_Edge,
	Is_With_Edge, Iterate_All_Cycles, Iterate_Edges_Of_Cycle, Kind):
	New routines.
	(Length, Lib_Vertex, (Line, Next, Number_Of_Cycles, Present,
	Same_Library_Graph_Cycle_Attributes, Spec_Vertex): New routines.
	* bindo-units.adb (File_Name, Invocation_Graph_Encoding): New
	routines.
	* bindo-units.ads: Add new instantiated data structure
	Unit_Sets.
	(File_Name, Invocation_Graph_Encoding): New routine.
	* bindo-validators.adb: Remove with and use clauses for GNAT and
	GNAT.Sets.  Remove membership set US.  Update the parameter
	profiles of most routines to use better parameter names.  Update
	the implementation of most routine to use the new parameter
	names.
	(Validate_Cycle, Validate_Cycle_Path, Validate_Cycles,
	Validate_Invocation_Graph_Vertex): Remove the validation of
	component Lib_Vertex. Add the validation of components
	Body_Vertex and Spec_Vertex.
	(Write_Error): New routine.
	* bindo-validators.ads (Validate_Cycles): New routine.
	* bindo-writers.adb: Update the parameter profiles of most
	routines to use better parameter names.  Update the
	implementation of most routine to use the new parameter names.
	(Write_Cycle, Write_Cyclic_Edge, Write_Cycles): New routines.
	(Write_Invocation_Graph_Vertex): Remove the output of component
	Lib_Vertex. Add the output of components Body_Vertex and
	Spec_Vertex.
	* bindo-writers.ads (Write_Cycles): New routine.
	* debug.adb: Use binder switches -d_C and -d_P, add
	documentation on their usage.
	* gnatbind.adb: Remove with and use clauses for Binde.  Delegate
	the choice of elaboration mechanism to Bindo.
	* lib-writ.adb (Column, Extra, Invoker, Kind, Line, Locations,
	Name, Placement, Scope, Signature, Target): Removed.
	(Write_Invocation_Graph): Moved at the top level.
	(Write_Invocation_Graph_Attributes): New routine.
	(Write_Invocation_Relation, Write_Invocation_Signature): Moved
	at the top level.
	* lib-writ.ads: Add a documentation section on invocation graph
	attributes.
	* sem_elab.adb (Body_Placement_Of): New routine.
	(Declare_Invocation_Construct): Update the call to
	Add_Invocation_Construct.
	(Declaration_Placement_Of_Node): New routine.
	(Get_Invocation_Attributes): Correct the retrieval of the
	enclosing subprogram where the postcondition procedure lives.
	(Placement_Of, Placement_Of_Node): Removed.
	(Record_Invocation_Graph): Record the encoding format used.
	(Record_Invocation_Graph_Encoding): New routine.
	(Record_Invocation_Relation): Update the call to
	Add_Invocation_Relation.
	(Spec_Placement_Of): Removed.
	* libgnat/g-lists.ads, libgnat/g-lists.adb (Equal): New routine.

From-SVN: r273107
2019-07-05 07:02:08 +00:00