Commit Graph

161507 Commits

Author SHA1 Message Date
Jason Merrill
a6b2922160 * system.h: #include <new> earlier.
From-SVN: r260620
2018-05-23 13:13:30 -04:00
Marek Polacek
3d76db63cd Implement P0614R1, Range-based for statements with initializer.
* parser.c (cp_parser_range_based_for_with_init_p): New.
	(cp_parser_init_statement): Use it.  Parse the optional init-statement
	for a range-based for loop.
	(cp_parser_skip_to_closing_parenthesis_1): Handle balancing ?:.

	* g++.dg/cpp2a/range-for1.C: New test.
	* g++.dg/cpp2a/range-for2.C: New test.
	* g++.dg/cpp2a/range-for3.C: New test.
	* g++.dg/cpp2a/range-for4.C: New test.
	* g++.dg/cpp2a/range-for5.C: New test.
	* g++.dg/cpp2a/range-for6.C: New test.
	* g++.dg/cpp2a/range-for7.C: New test.

From-SVN: r260619
2018-05-23 16:39:47 +00:00
Luis Machado
d2ff35c091 [Patch 02/02] Introduce prefetch-dynamic-strides option
The following patch adds an option to control software prefetching of memory
references with non-constant/unknown strides.

Currently we prefetch these references if the pass thinks there is benefit to
doing so. But, since this is all based on heuristics, it's not always the case
that we end up with better performance.

For Falkor there is also the problem of conflicts with the hardware prefetcher,
so we need to be more conservative in terms of what we issue software prefetch
hints for.

This also aligns GCC with what LLVM does for Falkor.

Similarly to the previous patch, the defaults guarantee no change in behavior
for other targets and architectures.

gcc/ChangeLog:

2018-05-23  Luis Machado  <luis.machado@linaro.org>

	* config/aarch64/aarch64-protos.h (cpu_prefetch_tune)
	<prefetch_dynamic_strides>: New const bool field.
	* config/aarch64/aarch64.c (generic_prefetch_tune): Update to include
	prefetch_dynamic_strides.
	(exynosm1_prefetch_tune): Likewise.
	(thunderxt88_prefetch_tune): Likewise.
	(thunderx_prefetch_tune): Likewise.
	(thunderx2t99_prefetch_tune): Likewise.
	(qdf24xx_prefetch_tune): Likewise. Set prefetch_dynamic_strides to
	false.
	(aarch64_override_options_internal): Update to set
	PARAM_PREFETCH_DYNAMIC_STRIDES.
	* doc/invoke.texi (prefetch-dynamic-strides): Document new option.
	* params.def (PARAM_PREFETCH_DYNAMIC_STRIDES): New.
	* params.h (PARAM_PREFETCH_DYNAMIC_STRIDES): Define.
	* tree-ssa-loop-prefetch.c (should_issue_prefetch_p): Account for
	prefetch-dynamic-strides setting.

From-SVN: r260618
2018-05-23 16:23:11 +00:00
Luis Machado
59100dfc42 [Patch 01/02] Introduce prefetch-minimum stride option
This patch adds a new option to control the minimum stride, for a memory
reference, after which the loop prefetch pass may issue software prefetch
hints for. There are two motivations:

* Make the pass less aggressive, only issuing prefetch hints for bigger strides
that are more likely to benefit from prefetching. I've noticed a case in cpu2017
where we were issuing thousands of hints, for example.

* For processors that have a hardware prefetcher, like Falkor, it allows the
loop prefetch pass to defer prefetching of smaller (less than the threshold)
strides to the hardware prefetcher instead. This prevents conflicts between
the software prefetcher and the hardware prefetcher.

I've noticed considerable reduction in the number of prefetch hints and
slightly positive performance numbers. This aligns GCC and LLVM in terms of
prefetch behavior for Falkor.

The default settings should guarantee no changes for existing targets. Those
are free to tweak the settings as necessary.

gcc/ChangeLog:

2018-05-23  Luis Machado  <luis.machado@linaro.org>

	* config/aarch64/aarch64-protos.h (cpu_prefetch_tune)
	<minimum_stride>: New const int field.
	* config/aarch64/aarch64.c (generic_prefetch_tune): Update to include
	minimum_stride field defaulting to -1.
	(exynosm1_prefetch_tune): Likewise.
	(thunderxt88_prefetch_tune): Likewise.
	(thunderx_prefetch_tune): Likewise.
	(thunderx2t99_prefetch_tune): Likewise.
	(qdf24xx_prefetch_tune) <minimum_stride>: Set to 2048.
	<default_opt_level>: Set to 3.
	(aarch64_override_options_internal): Update to set
	PARAM_PREFETCH_MINIMUM_STRIDE.
	* doc/invoke.texi (prefetch-minimum-stride): Document new option.
	* params.def (PARAM_PREFETCH_MINIMUM_STRIDE): New.
	* params.h (PARAM_PREFETCH_MINIMUM_STRIDE): Define.
	* tree-ssa-loop-prefetch.c (should_issue_prefetch_p): Return false if
	stride is constant and is below the minimum stride threshold.

From-SVN: r260617
2018-05-23 16:20:30 +00:00
Jonathan Wakely
cf290ea325 Fix handling of an empty filename at end of a path
The C++17 std::filesystem::path grammar allows an empty filename as the
last component (to signify a trailing slash). The existing code does not
handle this consistently, sometimes an empty filename has type _Multi
and sometimes it has type _Filename. This can result in a non-empty
iterator range for an empty filename component.

This change ensures that empty paths always have type _Filename and will
yield an empty iterator range.

	* include/bits/fs_path.h (path::_M_type): Change default member
	initializer to _Filename.
	(path::begin): Create past-the-end iterator for empty path.
	* src/filesystem/std-path.cc (path::remove_filename()): Remove
	debugging check.
	(path::has_relative_path()): Return false for empty filenames.
	(path::_M_split_cmpts): Set _M_type to _Filename for empty paths.
	Fix offset of empty final component.
	* testsuite/27_io/filesystem/path/itr/components.cc: New.
	* testsuite/27_io/filesystem/path/itr/traversal.cc: Add new inputs.

From-SVN: r260616
2018-05-23 17:11:06 +01:00
Kyrylo Tkachov
7aa1325013 [arm] Remove mode26 feature bit
* config/arm/arm-cpus.in (mode26): Delete.
    (armv4): Delete mode26 reference.
    * config/arm/arm.c (arm_configure_build_target): Delete use of
    isa_bit_mode26.

From-SVN: r260615
2018-05-23 15:26:35 +00:00
Uros Bizjak
4b3f49649a i386.md (*floatuns<SWI48:mode><MODEF:mode>2_avx512): New insn pattern.
* config/i386/i386.md (*floatuns<SWI48:mode><MODEF:mode>2_avx512):
	New insn pattern.
	(floatunssi<mode>2): Also enable for AVX512F and TARGET_SSE_MATH.
	Rewrite expander pattern.  Emit gen_floatunssi<mode>2_i387_with_xmm
	for non-SSE modes.
	(floatunsdisf2): Rewrite expander pattern.  Hanlde TARGET_AVX512F.
	(floatunsdidf2): Ditto.

	* config/i386/i386.md (fixuns_trunc<mode>di2): New insn pattern.
	(fixuns_trunc<mode>si2_avx512f): Ditto.
	(*fixuns_trunc<mode>si2_avx512f_zext): Ditto.
	(fixuns_trunc<mode>si2): Also enable for AVX512F and TARGET_SSE_MATH.
	Emit fixuns_trunc<mode>si2_avx512f for AVX512F targets.

testsuite/ChangeLog:

	* gcc.target/i386/cvt-2.c: New test.

	* gcc.target/i386/cvt-3.c: New test.

From-SVN: r260614
2018-05-23 17:13:31 +02:00
Alexander Monakov
3f13154553 df-scan: remove ad-hoc handling of global regs in asms
PR rtl-optimization/79985
	* df-scan.c (df_insn_refs_collect): Remove special case for
	global registers and asm statements.

testsuite/
	* gcc.dg/pr79985.c: New testcase.

From-SVN: r260613
2018-05-23 18:01:28 +03:00
Alexander Monakov
8851a51161 extend.texi: update Global Register Variables section
* extend.texi (Global Register Variables): Rewrite the bullet list.
	Note that the register is available for allocation. Note that access
	via inline asm must use constraints. Add note about async-signal
	handlers. Remove paragraph about automagic register selection.

From-SVN: r260610
2018-05-23 17:44:10 +03:00
Richard Biener
52388096c2 tree-ssa-sccvn.c (vn_reference_lookup_3): Remove restriction of fixed offset from memset VN.
2018-05-23  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.c (vn_reference_lookup_3): Remove restriction
	of fixed offset from memset VN.

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

From-SVN: r260609
2018-05-23 14:01:36 +00:00
Bill Schmidt
d71dc99078 gimple-ssa-strength-reduction.c (struct slsr_cand_d): Add first_interp field.
2018-05-23  Bill Schmidt  <wschmidt@linux.ibm.com>

	* gimple-ssa-strength-reduction.c (struct slsr_cand_d): Add
	first_interp field.
	(alloc_cand_and_find_basis): Initialize first_interp field.
	(slsr_process_mul): Modify first_interp field.
	(slsr_process_add): Likewise.
	(slsr_process_cast): Modify first_interp field for each new
	interpretation.
	(slsr_process_copy): Likewise.
	(dump_candidate): Dump first_interp field.
	(replace_mult_candidate): Process all interpretations, not just
	subsequent ones.
	(replace_rhs_if_not_dup): Likewise.
	(replace_one_candidate): Likewise.

From-SVN: r260608
2018-05-23 13:26:05 +00:00
Wilco Dijkstra
d6cb6d6a1c [AArch64] Simplify frame pointer logic
Simplify frame pointer logic.  Add aarch64_needs_frame_chain to
decide when to emit the frame chain using clearer logic.
Introduce aarch64_use_frame_pointer which contains the value of
-fno-omit-frame-pointer (flag_omit_frame_pointer is set to a magic
value so that the mid-end won't force the frame pointer in all
cases, and leaf frame pointer emission can't be supported). 

    gcc/
	* config/aarch64/aarch64.c (aarch64_use_frame_pointer):
	Add new boolean.
	(aarch64_needs_frame_chain): New function.
	(aarch64_parse_override_string): Set aarch64_use_frame_pointer.

From-SVN: r260606
2018-05-23 12:28:43 +00:00
Sudakshina Das
675d044c85 [AArch64][PR target/84882] Add mno-strict-align
*** gcc/ChangeLog ***

2018-05-23  Sudakshina Das  <sudi.das@arm.com>

	PR target/84882
	* common/config/aarch64/aarch64-common.c (aarch64_handle_option):
	Check val before adding MASK_STRICT_ALIGN to opts->x_target_flags.
	* config/aarch64/aarch64.opt (mstrict-align): Remove RejectNegative.
	* config/aarch64/aarch64.c (aarch64_attributes): Mark allow_neg
	as true for strict-align.
	(aarch64_can_inline_p): Perform checks even when callee has no
	attributes to check for strict alignment.
	* doc/extend.texi (AArch64 Function Attributes): Document
	no-strict-align.
	* doc/invoke.texi: (AArch64 Options): Likewise.

*** gcc/testsuite/ChangeLog ***

2018-05-23  Sudakshina Das  <sudi.das@arm.com>

	PR target/84882
	* gcc.target/aarch64/pr84882.c: New test.
	* gcc.target/aarch64/target_attr_18.c: Likewise.

From-SVN: r260604
2018-05-23 11:33:09 +00:00
Florian Weimer
cb3c90cc42 x86: libatomic: Do not assume ELF constructors run before IFUNC resolvers
PR libgcc/60790
	x86: Do not assume ELF constructors run before IFUNC resolvers.
	* config/x86/host-config.h (libat_feat1_ecx, libat_feat1_edx):
	Remove declarations.
	(__libat_feat1, __libat_feat1_init): Declare.
	(FEAT1_REGISTER): Define.
	(load_feat1): New function.
	(IFUNC_COND_1): Adjust.
	* config/x86/init.c (libat_feat1_ecx, libat_feat1_edx)
	(init_cpuid): Remove definitions.
	(__libat_feat1): New variable.
	(__libat_feat1_init): New function.

From-SVN: r260603
2018-05-23 13:13:05 +02:00
Richard Sandiford
159440699b Fix SLP def type when computing masks (PR85853)
In this PR, SLP failed to include a comparison node in the SLP
tree and so marked the node as external.  It then went on to call
vect_is_simple_use on the comparison with its STMT_VINFO_DEF_TYPE
still claiming that it was an internal definition.

We already avoid that for vect_analyze_stmt by temporarily copying
the node's definition type to each STMT_VINFO_DEF_TYPE.  This patch
extends that to the vector type calculation.  The easiest thing
seemed to be to split the analysis of the root node out into
a subroutine, so that it's possible to return false early without
awkward control flow.

2018-05-23  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	PR tree-optimization/85853
	* tree-vect-slp.c (vect_slp_analyze_node_operations): Split out
	the handling of the root of the node to...
	(vect_slp_analyze_node_operations_1): ...this new function,
	and run the whole thing with the child nodes' def types
	set according to their SLP node's def type.

gcc/testsuite/
	PR tree-optimization/85853
	* gfortran.dg/vect/pr85853.f90: New test.

From-SVN: r260601
2018-05-23 10:32:16 +00:00
Hristian Kirtchev
162ea0d372 [Ada] Minor reformattings
2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_disp.adb, freeze.adb, gnat1drv.adb, sem_ch5.adb, sem_spark.adb:
	Minor reformattings.

From-SVN: r260600
2018-05-23 10:24:27 +00:00
Pascal Obry
cd742f4a16 [Ada] Fix memory leak in win32_wait error handling
2018-05-23  Pascal Obry  <obry@adacore.com>

gcc/ada/

	* adaint.c (win32_wait): Properly free the handle/pid lists when
	WaitForMultipleObjects fails (return WAIT_FAILED).

From-SVN: r260599
2018-05-23 10:24:04 +00:00
Pascal Obry
c2d2963d2c [Ada] Fix computation of handle/pid lists in win32_wait
An obvious mistake due to missing parentheses was not properly computing the
size of the handle and pid list passed to WaitForMultipleObjects(). This
resulted in a memory corruption.

2018-05-23  Pascal Obry  <obry@adacore.com>

gcc/ada/

	* adaint.c (win32_wait): Add missing parentheses.

From-SVN: r260598
2018-05-23 10:23:59 +00:00
Hristian Kirtchev
7f4b58c258 [Ada] Spurious Storage_Error on imported array
This patch moves the check which verifies that a large modular array is created
from expansion to freezing in order to take interfacing pragmas in account. The
check is no longer performed on imported objects because no object is created
in that case.

2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_ch3.adb (Check_Large_Modular_Array): Moved to Freeze.
	(Expand_N_Object_Declaration): Do not check for a large modular array
	here.
	* freeze.adb (Check_Large_Modular_Array): Moved from Exp_Ch3.
	(Freeze_Object_Declaration): Code cleanup. Check for a large modular
	array.
	* sem_ch3.adb: Minor reformatting.

gcc/testsuite/

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

From-SVN: r260597
2018-05-23 10:23:54 +00:00
Ed Schonberg
ffdd524878 [Ada] Spurious error on instantiation with type with unknown discriminants
This patch fixes a spurious error when instantiating an indefinite container
with a private type with unknown discriminants, when its full view is an
unconstrained array type. It also cleans up the inheritance of dynamic
predicates inherited by anonymous subtypes of array types.

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

gcc/ada/

	* einfo.ads: New attribute on types: Predicated_Parent, to simplify the
	retrieval of the applicable predicate function to an itype created for
	a constrained array component.
	* einfo.adb: Subprograms for Predicated_Parent.
	(Predicate_Function): Use new attribute.
	* exp_util.adb (Make_Predicate_Call): If the predicate function is not
	available for a subtype, retrieve it from the base type, which may have
	been frozen after the subtype declaration and not captured by the
	subtype declaration.
	* sem_aggr.adb (Resolve_Array_Aggregate): An Others association is
	legal within a generated initiqlization procedure, as may happen with a
	predicate check on a component, when the predicate function applies to
	the base type of the component.
	* sem_ch3.adb (Analyze_Subtype_Declaration): Clean up inheritance of
	predicates for subtype declarations and for subtype indications in
	other contexts.
	(Process_Subtype): Likewise. Handle properly the case of a private type
	with unknown discriminants whose full view is an unconstrained array.
	Use Predicated_Parent to indicate source of predicate function on an
	itype whose parent is itself an itype.
	(Complete_Private_Subtype): If the private view has unknown
	discriminants and the full view is an unconstrained array, set base
	type of completion to the full view of parent.
	(Inherit_Predicate_Flags): Prevent double assignment of predicate
	function and flags.
	(Build_Subtype): For a constrained array component, propagate predicate
	information from original component type declaration.

gcc/testsuite/

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

From-SVN: r260596
2018-05-23 10:23:48 +00:00
Boris Yakobowski
39a4daf955 [Ada] Fix faulty preconditions for trigonometric functions
2018-05-23  Boris Yakobowski  <yakobowski@adacore.com>

gcc/ada/

	* libgnat/a-ngelfu.ads (Arctanh, Arccoth): Fix faulty preconditions.

From-SVN: r260595
2018-05-23 10:23:43 +00:00
Arnaud Charlet
bc3fb397fd [Ada] Fix various defects found by static analysis
2018-05-23  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* checks.adb (Minimize_Eliminate_Overflows): Default initialize Lo and
	Hi.
	* sem_elab.adb: Make "out" parameters instead of "in out" when
	relevant.

From-SVN: r260594
2018-05-23 10:23:39 +00:00
Bob Duff
b77c24b8c0 [Ada] gnatbind: do not list No_Implementation_Restrictions
When the gnatbind -r switch is used, do not list
No_Implementation_Restrictions, because after using the new restriction list,
No_Implementation_Restrictions will cause an error.

2018-05-23  Bob Duff  <duff@adacore.com>

gcc/ada/

	* gnatbind.adb (List_Applicable_Restrictions): Add
	No_Implementation_Restrictions to the list of restrictions not to list.
	Remove double negative "not No_Restriction_List".  Comment the
	commentary that is output, so it won't cause errors if used directly in
	a gnat.adc.

From-SVN: r260593
2018-05-23 10:23:34 +00:00
Ed Schonberg
b30f86de98 [Ada] Implementation of AI12-0131: legality of class-wide precondition
This patch refines the legality check on a class-wide precondition on a type
extension when ancestor does not have a class-wide precondition. Previously the
compiler accepted such a precondition when the ancestor had a class-wide
postcondition.

Compiling pck.ads must yield:

  pck.ads:7:04: illegal class-wide precondition on overriding operation

----
package Pck is
   type Parent is tagged null record;
   procedure Init (P : Parent) with Post'Class => True;

   type Child is new Parent with null record;
   overriding procedure Init (C : Child) with
   Pre'Class => True;
end Pck;

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

gcc/ada/

	* sem_prag.adb (Inherit_Class_Wide_Pre): Refine legality check on
	class-wide precondition on a type extension when ancestor does not have
	a class-wide precondition.  Previously the compiler accepted such a
	precondition when the ancestor had a class-wide postcondition.

From-SVN: r260592
2018-05-23 10:23:29 +00:00
Javier Miranda
026733d84e [Ada] Crash processing Valid_Scalars whose evaluation is always true
The compiler blows up generating code associated with occurrences of attribute
Valid_Scalars whose evaluation is always true. After this patch the following
test compiles fine.

2018-05-23  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* sem_attr.adb (Valid_Scalars): Do not invoke Error_Attr_P to report
	the warning on occurrences of this attribute whose evaluation is always
	true (since that subprogram aborts processing the attribute). In
	addition, replace the node by its boolean result 'True' (required
	because the backend has no knowledge of this attribute).

gcc/testsuite/

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

From-SVN: r260591
2018-05-23 10:23:24 +00:00
Bob Duff
aeaa0347e9 [Ada] Vectors: spurious error in -gnatwE mode
This patch fixes a bug in which if Ada.Containers.Vectors is instantiated with
an Index_Type such that Index_Type'Base'Last is less than Count_Type'Last, and
the -gnatwE switch is used, the compiler gives spurious error messages.

The following test should compile quietly with -gnatwE:

gnatmake short_vectors.ads -gnatwa -gnatwE -gnatf

with Ada.Containers.Vectors;
package Short_Vectors is

   type Index_Type is range 1 .. 256;

   package Map_Pkg is new Ada.Containers.Vectors
     (Index_Type => Index_Type,
      Element_Type => Integer);

end Short_Vectors;

2018-05-23  Bob Duff  <duff@adacore.com>

gcc/ada/

	* libgnat/a-convec.adb: (Insert, Insert_Space): Suppress warnings. The
	code in question is not reachable in the case where Count_Type'Last is
	out of range.

From-SVN: r260590
2018-05-23 10:23:19 +00:00
Yannick Moy
5e1c231ec7 [Ada] Clarify meaning of local pragma Warnings Off without On
A local use of pragma Warnings Off to suppress specific messages, when
not followed by a matching pragma Warnings On, extends until the end of
the file.

2018-05-23  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* doc/gnat_rm/implementation_defined_pragmas.rst: Clarify meaning of
	local pragma Warnings Off without On.
	* gnat_rm.texi: Regenerate.

From-SVN: r260589
2018-05-23 10:23:14 +00:00
Olivier Hainque
b682fcf0d9 [Ada] Add a Is_Foreign_Exception predicate to GNAT.Exception_Actions
Useful to check if an occurrence caught by a "when others" choice originates
from a foreign language, e.g. C++.

2018-05-23  Olivier Hainque  <hainque@adacore.com>

gcc/ada/

	* libgnat/g-excact.ads (Is_Foreign_Exception): New predicate.
	* libgnat/g-excact.adb: Implement.

From-SVN: r260588
2018-05-23 10:23:09 +00:00
Ed Schonberg
ac450fb2ab [Ada] Missing legality check on iterator over formal container
This patch adds a check on an iterator over a GNAT-specific formal container,
when the iterator specification includes a subtype indication that must be
compatible with the element type of the container.

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

gcc/ada/

	* sem_ch5.adb (Analyze_Iterator_Specification): If a subtype indication
	is present, verify its legality when the domain of iteration is a
	GNAT-specific formal container, as is already done for arrays and
	predefined containers.

gcc/testsuite/

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

From-SVN: r260587
2018-05-23 10:23:02 +00:00
Yannick Moy
fd82aeff6d [Ada] Fix implementation of utility for finding enclosing declaration
This utility is used in GNATprove to find when a node is inside a named
number declaration, and this case was not properly handled. Now fixed.
There is no impact on compilation.

2018-05-23  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* sem_util.adb (Enclosing_Declaration): Fix the case of a named number
	declaration, which was not taken into account.

From-SVN: r260586
2018-05-23 10:22:57 +00:00
Hristian Kirtchev
0c9849e18b [Ada] Suspension and elaboration warnings/checks
This patch modifies the static elaboration model to stop the inspection of
a task body when it contains a synchronous suspension call and restriction
No_Entry_Calls_In_Elaboration_Code or switch -gnatd_s is in effect.

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

--  suspension.ads

package Suspension is
   procedure ABE;

   task type Barrier_Task_1;
   task type Barrier_Task_2;
   task type Object_Task_1;
   task type Object_Task_2;
end Suspension;

--  suspension.adb

with Ada.Synchronous_Barriers;     use Ada.Synchronous_Barriers;
with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control;

package body Suspension is
   Bar : Synchronous_Barrier (Barrier_Limit'Last);
   Obj : Suspension_Object;

   task body Barrier_Task_1 is
      OK : Boolean;
   begin
      Wait_For_Release (Bar, OK);
      ABE;
   end Barrier_Task_1;

   task body Barrier_Task_2 is
      procedure Block is
         OK : Boolean;
      begin
         Wait_For_Release (Bar, OK);
      end Block;
   begin
      Block;
      ABE;
   end Barrier_Task_2;

   task body Object_Task_1 is
   begin
      Suspend_Until_True (Obj);
      ABE;
   end Object_Task_1;

   task body Object_Task_2 is
      procedure Block is
      begin
         Suspend_Until_True (Obj);
      end Block;
   begin
      Block;
      ABE;
   end Object_Task_2;

   function Elaborator return Boolean is
      BT_1 : Barrier_Task_1;
      BT_2 : Barrier_Task_2;
      OT_1 : Object_Task_1;
      OT_2 : Object_Task_2;
   begin
      return True;
   end Elaborator;

   Elab : constant Boolean := Elaborator;

   procedure ABE is begin null; end ABE;
end Suspension;

--  main.adb

with Suspension;

procedure Main is begin null; end Main;

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

$ gnatmake -q -gnatd_s main.adb
suspension.adb:23:07: warning: cannot call "ABE" before body seen
suspension.adb:23:07: warning: Program_Error may be raised at run time
suspension.adb:23:07: warning:   body of unit "Suspension" elaborated
suspension.adb:23:07: warning:   function "Elaborator" called at line 51
suspension.adb:23:07: warning:   local tasks of "Elaborator" activated
suspension.adb:23:07: warning:   procedure "ABE" called at line 23
suspension.adb:39:07: warning: cannot call "ABE" before body seen
suspension.adb:39:07: warning: Program_Error may be raised at run time
suspension.adb:39:07: warning:   body of unit "Suspension" elaborated
suspension.adb:39:07: warning:   function "Elaborator" called at line 51
suspension.adb:39:07: warning:   local tasks of "Elaborator" activated
suspension.adb:39:07: warning:   procedure "ABE" called at line 39

2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* debug.adb: Switch -gnatd_s is now used to stop elaboration checks on
	synchronized suspension.
	* rtsfind.ads: Add entries for units Ada.Synchronous_Barriers and
	Ada.Synchronous_Task_Control and routines Suspend_Until_True and
	Wait_For_Release.
	* sem_elab.adb: Document switch -gnatd_s.
	(In_Task_Body): New routine.
	(Is_Potential_Scenario): Code cleanup. Stop the traversal of a task
	body when the current construct denotes a synchronous suspension call,
	and restriction No_Entry_Calls_In_Elaboration_Code or switch -gnatd_s
	is in effect.
	(Is_Synchronous_Suspension_Call): New routine.
	* switch-c.adb (Scan_Front_End_Switches): Switch -gnatJ now sets switch
	-gnatd_s.

From-SVN: r260585
2018-05-23 10:22:52 +00:00
Javier Miranda
51ab2a39e9 [Ada] Restrict initialization of External_Tag and Expanded_Name
2018-05-23  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* exp_disp.adb (Make_DT): Restrict the initialization of
	External_Tag and Expanded_Name to an empty string to the case where
	both pragmas apply (i.e. No_Tagged_Streams and Discard_Names), since
	restricted runtimes are compiled with pragma Discard_Names.
	* doc/gnat_rm/implementation_defined_pragmas.rst,
	doc/gnat_rm/implementation_defined_characteristics.rst: Add
	documentation.
	* gnat_rm.texi: Regenerate.

From-SVN: r260584
2018-05-23 10:22:47 +00:00
Maroua Maalej
6734617ced [Ada] Fix of some permission rules of pointers in SPARK
This commit fixes bugs in the code that implements the rules for safe pointers
in SPARK. This only affects SPARK tools, not compilation.

  * Global variables should be handled differently compared
    to parameters. The whole tree of an in global variable has the
    permission Read-Only. In contrast, an in parameter has the
    permission Read-Only for the first level and Read-Write permission
    for suffixes.
  * The suffix X of Integer'image(X) was not analyzed correctly.
  * The instruction X'img was not dealt with.
  * Shallow aliased types which are not initialized are now allowed
    and analyzed.

Dealing with function inlining is not handled correctly yet.

2018-05-23  Maroua Maalej  <maalej@adacore.com>

gcc/ada/

	* sem_spark.adb: Fix of some permission rules of pointers in SPARK.

From-SVN: r260583
2018-05-23 10:22:41 +00:00
Ed Schonberg
a0fa549732 [Ada] Crash on predicate involving qualified expression in instance
This patch inhibits the generation of freeze nodes when pre-analyzing the
domain of iteration of an Ada2012 loop that appears as a quantified
expression in a predicate for an array type. This prevents a back-end
abort on an invisible freeze node that would otherwise appear in an
unexpanded code sequence.

The following must compile quietly:

----
with Id_Manager;

package My_Id_Manager is new Id_Manager (Max_Id_Type   => 100_000,
                                         Max_Key_Count => 100);
----
generic
   Max_Id_Type   : Positive;
   Max_Key_Count : Positive;

package Id_Manager is
   type Unique_Id_Type is new Integer range 0 .. Max_Id_Type;

   Undefined_Id : constant Unique_Id_Type := 0;

   type Key_Count is new Integer range 0 .. Max_Key_Count;
   subtype Key_Index is Key_Count range 1 .. Key_Count'Last;

   type Key_Array is array (Key_Index range <>) of Unique_Id_Type
     with Predicate => Key_Array'First = 1;

   type Id_Manager_State (Capacity : Key_Count) is private;

   procedure Display_Objects (TheObject : Id_Manager_State);

private
   type Id_Manager_State (Capacity : Key_Count) is record
      Id_Key   : Key_Array (1 .. Capacity) := (others => Undefined_Id);
      Key_Size : Key_Count                 := 0;
   end record;
end Id_Manager;
----
package body Id_Manager is
   procedure Display_Objects (TheObject : Id_Manager_State) is
   begin
      for Item of TheObject.Id_Key loop
         null;
      end loop;
   end Display_Objects;
end Id_Manager;

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

gcc/ada/

	* sem_ch5.adb (Preanalyze_Range): The pre-analysis of the domain of
	iteration of an Ada2012 loop is performed to determine the type of the
	domain, but full analysis is performed once the loop is rewritten as a
	while-loop during expansion. The pre-analysis suppresses expansion; it
	must also suppress the generation of freeze nodes, which may otherwise
	appear in the wrong scope before rewritting.

From-SVN: r260582
2018-05-23 10:22:35 +00:00
Hristian Kirtchev
a0f3668cde [Ada] Suppression of elaboration-related warnings
This patch updates the documentation section on suppressing elaboration
warnings. No change in behavior, no need for a test.

2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* sem_elab.adb: Update the section on suppressing elaboration warnings.

From-SVN: r260581
2018-05-23 10:22:30 +00:00
Hristian Kirtchev
4868853418 [Ada] Suppression of elaboration-related warnings
This patch modifies the effects of pragma Warnings (Off, ...) to suppress
elaboration warnings related to an entity.

2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* einfo.adb (Is_Elaboration_Checks_OK_Id): Use predicate
	Is_Elaboration_Target.
	(Is_Elaboration_Target): New routine.
	(Is_Elaboration_Warnings_OK_Id): Use predicate Is_Elaboration_Target.
	(Set_Is_Elaboration_Checks_OK_Id): Use predicate Is_Elaboration_Target.
	(Set_Is_Elaboration_Warnings_OK_Id): Use predicate
	Is_Elaboration_Target.
	* einfo.ads: Add new synthesized attribute Is_Elaboration_Target along
	with occurrences in nodes.
	(Is_Elaboration_Target): New routine.
	* sem_prag.adb (Analyze_Pragma): Suppress elaboration warnings when an
	elaboration target is subject to pragma Warnings (Off, ...).

gcc/testsuite/

	* gnat.dg/elab5.adb, gnat.dg/elab5_pkg.adb, gnat.dg/elab5_pkg.ads: New
	testcase.

From-SVN: r260580
2018-05-23 10:22:25 +00:00
Eric Botcazou
6e6e00ffd2 [Ada] Remove obsolete stuff from repinfo.adb
2018-05-23  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* repinfo.adb (List_Type_Info): Remove obsolete stuff.

From-SVN: r260579
2018-05-23 10:22:20 +00:00
Hristian Kirtchev
162ed06fb3 [Ada] Suppression of elaboration-related warnings
This patch changes the behavior of elaboration-related warnings as follows:

   * If a scenario or a target has [elaboration] warnings suppressed, then
     any further elaboration-related warnings along the paths rooted at the
     scenario are also suppressed.

   * Elaboration-related warnings related to task activation can now be
     suppressed when either the task object, task type, or the activation
     call have [elaboration] warnings suppressed.

   * Elaboration-related warnings related to calls can now be suppressed when
     either the target or the call have [elaboration] warnings suppressed.

   * Elaboration-related warnings related to instantiations can now be
     suppressed when the instantiation has [elaboration] warnings suppressed.

The patch also cleans up the way the state of the Processing phase is updated
with each new node along a path. It is now preferable to update the state in
routines

   Process_Conditional_ABE_Activation_Impl
   Process_Conditional_ABE_Call
   Process_Conditional_ABE_Instantiation

rather than within their language-specific versions.

2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* einfo.adb: Flag304 is now Is_Elaboration_Warnings_OK_Id.
	(Is_Elaboration_Warnings_OK_Id): New routine.
	(Set_Is_Elaboration_Warnings_OK_Id): New routine.
	(Write_Entity_Flags): Output Flag304.
	* einfo.ads: Add new attribute Is_Elaboration_Warnings_OK_Id along with
	occurrences in entities.
	(Is_Elaboration_Warnings_OK_Id): New routine along with pragma Inline.
	(Set_Is_Elaboration_Warnings_OK_Id): New routine along with pragma
	Inline.
	* sem_attr.adb (Analyze_Access_Attribute): Capture the state of
	elaboration warnings.
	* sem_ch3.adb (Analyze_Object_Declaration): Capture the state of
	elaboration warnings.
	* sem_ch6.adb (Analyze_Abstract_Subprogram_Declaration): Capture the
	state of elaboration warnings.
	(Analyze_Subprogram_Body_Helper): Capture the state of elaboration
	warnings.
	(Analyze_Subprogram_Declaration): Capture the state of elaboration
	warnings.
	* sem_ch9.adb (Analyze_Entry_Declaration): Capture the state of
	elaboration warnings.
	(Analyze_Single_Task_Declaration): Capture the state of elaboration
	warnings.
	(Analyze_Task_Type_Declaration): Capture the state of elaboration
	warnings.
	* sem_ch12.adb (Analyze_Generic_Package_Declaration): Capture the state
	of elaboration warnings.
	(Analyze_Generic_Subprogram_Declaration): Capture the state of
	elaboration warnings.
	* sem_elab.adb: Add a section on suppressing elaboration warnings.
	Type Processing_Attributes includes component Suppress_Warnings
	intended to suppress any elaboration warnings along a path in the
	graph.  Update Initial_State to include a value for this component.
	Types Target_Attributes and Task_Attriutes include component
	Elab_Warnings_OK to indicate whether the target or task has elaboration
	warnings enabled.  component Elab_Warnings_OK.
	(Build_Access_Marker): Propagate attribute
	Is_Elaboration_Warnings_OK_Node from the attribute to the generated
	call marker.
	(Extract_Instantiation_Attributes): Set the value for Elab_Warnings_OK.
	(Extract_Target_Attributes): Set the value for Elab_Warnings_OK.
	(Extract_Task_Attributes): Set the value for Elab_Warnings_OK.
	(Process_Conditional_ABE_Access): Suppress futher elaboration warnings
	when already in this mode or when the attribute or target have warnings
	suppressed.
	(Process_Conditional_ABE_Activation_Impl): Do not emit any diagnostics
	if warnings are suppressed.
	(Process_Conditional_ABE_Call): Suppress further elaboration warnings
	when already in this mode, or the target or call have warnings
	suppressed.
	(Process_Conditional_ABE_Call_Ada): Do not emit any diagnostics if
	warnings are suppressed.
	(Process_Conditional_ABE_Call_SPARK): Do not emit any diagnostics if
	warnings are suppressed.
	(Process_Conditional_ABE_Instantiation): Suppress further elaboration
	warnings when already in this mode or when the instantiation has
	warnings suppressed.
	(Process_Conditional_ABE_Instantiation_Ada): Do not emit any
	diagnostics if warnings are suppressed.
	(Process_Conditional_ABE_Variable_Assignment_Ada): Use the more
	specific Is_Elaboration_Warnings_OK_Id rather than Warnings_Off.
	(Process_Conditional_ABE_Variable_Assignment_SPARK): Use the more
	specific Is_Elaboration_Warnings_OK_Id rather than Warnings_Off.
	(Process_Task_Object): Suppress further elaboration warnings when
	already in this mode, or when the object, activation call, or task type
	have warnings suppressed. Update the processing state to indicate that
	the path goes through a task body.
	* sinfo.adb (Is_Elaboration_Warnings_OK_Node): Accept attribute
	references.
	(Set_Is_Elaboration_Warnings_OK_Node): Accept attribute references.
	* sinfo.ads: Attribute Is_Elaboration_Warnings_OK_Node now applies to
	attribute references.

gcc/testsuite/

	* gnat.dg/elab4.adb, gnat.dg/elab4_pkg.adb, gnat.dg/elab4_pkg.ads: New
	testcase.

From-SVN: r260578
2018-05-23 10:22:15 +00:00
Piotr Trojanek
53b30c7357 [Ada] Minor reformatting
2018-05-23  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* einfo.ads: Minor reformatting.

From-SVN: r260577
2018-05-23 10:22:08 +00:00
Ed Schonberg
728fedc29c [Ada] Compiler fails to reject illegal store of anonymous_access_to_subprogram
GNAT properly rejects an attempt to assign an access_to_subprogram formal
to a local variable, according to accessibiiity rules. This patch forces the
same behavior on the use of such a formal in an object declaration.

Compiling store_anon.adb must yield:

  store_anon.adb:7:35: illegal attempt to store anonymous access to subprogram
  store_anon.adb:7:35: value has deeper accessibility than any master
   (RM 3.10.2 (13))
 store_anon.adb:7:35: use named access type for "P" instead of access parameter

----
package Store_Anon is
   procedure Store (P : not null access procedure);

   procedure Invoke;
end Store_Anon;
----
package body Store_Anon is
   type P_Ptr is access procedure;

   Stored : P_Ptr;

   procedure Store (P : not null access procedure) is
      Illegal : constant P_Ptr := P;
   begin -- Store
      Stored := Illegal;
   end Store;

   procedure Invoke is
      -- Empty
   begin -- Invoke
      Stored.all;
   end Invoke;
end Store_Anon;

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

gcc/ada/

	* sem_ch3.adb (Analyze_Object_Declaration): If expression is an
	anonymous_access_to_ subprogram formal, apply a conversion to force an
	accsssibility check that will fail statically, enforcing 3.10.2 (13).

From-SVN: r260576
2018-05-23 10:22:03 +00:00
Daniel Mercier
87843c8388 [Ada] Turn off length expansion in CodePeer mode
2018-05-23  Daniel Mercier  <mercier@adacore.com>

gcc/ada/

	* gnat1drv.adb: Turn off length expansion in CodePeer mode.

From-SVN: r260575
2018-05-23 10:21:58 +00:00
Bob Duff
326776548e [Ada] Build-in-place aggregates and Address clauses
This patch fixes a bug in which if a limited volatile variable with
an Address aspect is initialized with a build-in-place aggregate
containing build-in-place function calls, the compiler can crash.

2018-05-23  Bob Duff  <duff@adacore.com>

gcc/ada/

	* freeze.adb: (Check_Address_Clause): Deal with build-in-place
	aggregates in addition to build-in-place calls.

gcc/testsuite/

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

From-SVN: r260574
2018-05-23 10:21:53 +00:00
Bob Duff
95872381f0 [Ada] Minor reformatting
2018-05-23  Bob Duff  <duff@adacore.com>

gcc/ada/

	* einfo.ads: Minor reformatting.
	* sem_ch3.adb: Likewise.
	* sinfo.ads: Likewise.

From-SVN: r260573
2018-05-23 10:21:47 +00:00
Hristian Kirtchev
40016fa77f [Ada] Initialize_Scalars optimization causes spurious runtime check failure
This patch suppresses the optimization of scalar arrays when pragma
Initialize_Scalars is in effect if the component type is subject to
predicates. Since the scalar array is initialized with invalid values,
these values may violate the predicate or a validity check within the
predicate.

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

--  gnat.adc

pragma Initialize_Scalars;

--  types.ads

with System; use System;

package Types is
   type Byte is mod System.Storage_Unit;

   subtype Inter_Byte is Byte;

   function Always_OK (B : Inter_Byte) return Boolean is (True);
   function Is_OK     (B : Inter_Byte) return Boolean is (Always_OK (B));

   subtype Final_Byte is Byte with Predicate => Is_OK (Final_Byte);

   type Bytes is array (1 .. 5) of Final_Byte;

   Obj : Bytes;
end Types;

--  main.adb

with Types; use Types;

procedure Main is begin null; end Main;

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

$ gnatmake -q -gnata -gnatVa main.adb
$ ./main

2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_ch3.adb (Default_Initialize_Object): Do not optimize scalar array
	initialization when the component type has predicates.
	* exp_ch4.adb (Expand_N_Allocator): Do not optimize scalar array
	allocation when the component type has predicates.

From-SVN: r260572
2018-05-23 10:21:42 +00:00
Hristian Kirtchev
3d58177769 [Ada] Minor reformatting
2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* einfo.adb, exp_disp.adb, sem_ch3.adb, sem_ch6.adb, sem_prag.adb:
	Minor reformatting.

From-SVN: r260571
2018-05-23 10:21:37 +00:00
Richard Biener
72cfbeae2b re PR middle-end/85874 (gcc points to wrong location when displaying warning for strict overflow warning)
2018-05-23  Richard Biener  <rguenther@suse.de>

	PR middle-end/85874
	* tree-data-ref.c (create_runtime_alias_checks): Defer
	and ignore overflow warnings.

	* gcc.dg/Wstrict-overflow-27.c: New testcase.

From-SVN: r260569
2018-05-23 09:06:01 +00:00
Yury Gribov
ad4f3f5d4e re PR tree-optimization/85822 (Maybe wrong code in VRP since r249150)
PR tree-optimization/85822

From-SVN: r260566
2018-05-23 07:40:43 +00:00
Richard Biener
b72feab889 tree-ssa-sccvn.c (vn_reference_lookup_3): Handle arbitrary memset constants via native_interpret_expr.
2018-05-23  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.c (vn_reference_lookup_3): Handle arbitrary
	memset constants via native_interpret_expr.

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

From-SVN: r260565
2018-05-23 07:08:43 +00:00
Jason Merrill
3423a64d46 PR c++/81420 - not extending temporary lifetime.
* call.c (extend_ref_init_temps_1): Handle ARRAY_REF.
	* class.c (build_base_path): Avoid redundant move of an rvalue.

From-SVN: r260563
2018-05-22 23:52:56 -04:00
Jason Merrill
0d2e69cb3c PR c++/85866 - error with .* in default template arg.
* pt.c (tsubst_copy_and_build): Handle partial instantiation.

From-SVN: r260562
2018-05-22 23:52:49 -04:00