Commit Graph

162748 Commits

Author SHA1 Message Date
Jonathan Wakely 20b47be02c PR libstdc++/86537 remove less<shared_ptr<T>> partial specialization
The standard doesn't specify this partial specialization (it was
required after the changes in N2637 but then should have been removed
following LWG 1262). Its presence is observable because it causes
different results when operator< has been overloaded for a shared_ptr
specialization.

	PR libstdc++/86537
	* include/bits/shared_ptr.h (less<shared_ptr<_Tp>>): Remove
	non-standard partial specialization.
	* include/bits/shared_ptr_base.h (_Sp_less): Remove class definition.
	(less<__shared_ptr<_Tp, _Lp>): Remove partial specialization.
	* testsuite/20_util/shared_ptr/comparison/86537.cc: New test.

From-SVN: r262739
2018-07-16 18:13:41 +01:00
Kelvin Nilsen 2ee1228ecd extend.texi (PowerPC AltiVec Built-in Functions): Alphabetize prototypes of built-in functions...
gcc/ChangeLog:

2018-07-16  Kelvin Nilsen  <kelvin@gcc.gnu.org>

	* doc/extend.texi (PowerPC AltiVec Built-in Functions):
	Alphabetize prototypes of built-in functions, separating out
	built-in functions that are listed in this section but should be
	described elsewhere.

From-SVN: r262737
2018-07-16 15:22:28 +00:00
Uros Bizjak f4eafec9bc re PR middle-end/86511 (Traps are generated for non-trapping compares)
PR target/86511
	* expmed.c (emit_store_flag): Do not emit setcc followed by a
	conditional move when trapping comparison was split to a
	non-trapping one (and vice versa).

From-SVN: r262736
2018-07-16 17:11:57 +02:00
Andreas Krebbel e2144dde6e Fix ChangeLog.
From-SVN: r262735
2018-07-16 14:46:10 +00:00
Ilya Leoshkevich 79c2f6d7de S/390: Implement -mnop-mcount
On i386 the profiler call sequence always consists of 1 call
instruction, so -mnop-mcount generates a single nop with the same
length as a call. For S/390 longer sequences may be used in some
cases, so -mnop-mcount generates the corresponding amount of nops.

2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>

	* config/s390/s390.c (s390_function_profiler): Generate nops
	instead of profiler call sequences.
	* config/s390/s390.opt: Add the new option.

2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>

	* gcc.target/s390/mnop-mcount-m31-fpic.c: New testcase.
	* gcc.target/s390/mnop-mcount-m31-mzarch.c: New testcase.
	* gcc.target/s390/mnop-mcount-m31.c: New testcase.
	* gcc.target/s390/mnop-mcount-m64-mfentry.c: New testcase.
	* gcc.target/s390/mnop-mcount-m64.c: New testcase.

From-SVN: r262734
2018-07-16 14:41:57 +00:00
Ilya Leoshkevich 605090dc79 S/390: Implement -mrecord-mcount
This is the counterpart of the i386 feature introduced by
39a5a6a4: Add direct support for Linux kernel __fentry__ patching.

2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>

	* config/s390/s390.c (s390_function_profiler): Generate
	__mcount_loc section.
	* config/s390/s390.opt: Add the new option.

2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>

	* testsuite/gcc.target/s390/mrecord-mcount.c: New testcase.

From-SVN: r262733
2018-07-16 14:36:21 +00:00
Ilya Leoshkevich 6902799c8d S/390: Add direct support for Linux kernel __fentry__ patching.
On i386, the difference between mcount and fentry is that fentry
comes before the prolog. On s390 mcount already comes before the
prolog, but takes 4 instructions. This patch introduces the more
efficient implementation (just 1 instruction) and puts it under
-mfentry flag.

The produced code is compatible only with newer glibc versions,
which provide the __fentry__ symbol and do not clobber %r0 when
resolving lazily bound functions. Because 31-bit PLT stubs assume
%r12 contains GOT address, which is not the case when the code runs
before the prolog, -mfentry is allowed only for 64-bit code.

Also, code compiled with -mfentry cannot be used for the nested C
functions, since they both use %r0. In this case instrumentation is
not insterted, and a new warning is issued for each affected nested
function.

2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>

	* common.opt: Add the new warning.
	* config/s390/s390.c (s390_function_profiler): Emit "brasl
	%r0,__fentry__" when -mfentry is specified.
	(s390_option_override_internal): Disallow -mfentry for 31-bit
	CPUs.
	* config/s390/s390.opt: Add the new option.

2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>

	* gcc.target/s390/mfentry-m64.c: New testcase.

From-SVN: r262732
2018-07-16 14:29:08 +00:00
Hristian Kirtchev 96e4fda582 [Ada] Missing error on hidden state in instantiation
This patch modifies the analysis of package contracts to split processing
which is specific to package instantiations on its own. As a result, the
lack of indicator Part_Of can now be properly assessed.

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

--  gen_pack.ads

generic
package Gen_Pack is
   Pack_Var : Integer := 1;
end Gen_Pack;

--  gen_wrap.ads

with Gen_Pack;

generic
package Gen_Wrap is
   Wrap_Var : Integer := 1;

   package Inst is new Gen_Pack;
end Gen_Wrap;

--  pack.ads

with Gen_Pack;
with Gen_Wrap;

package Pack
  with SPARK_Mode     => On,
       Abstract_State => State
is
   procedure Force_Body;

private
   package OK_Inst_1 is new Gen_Pack                                 --  OK
     with Part_Of => State;                                          --  OK

   package OK_Inst_2 is new Gen_Pack;                                --  OK
   pragma Part_Of (State);                                           --  OK

   package OK_Inst_3 is new Gen_Wrap                                 --  OK
     with Part_Of => State;                                          --  OK

   package OK_Inst_4 is new Gen_Wrap;                                --  OK
   pragma Part_Of (State);

   package Error_Inst_1 is new Gen_Pack;                             --  Error
   package Error_Inst_2 is new Gen_Wrap;                             --  Error
end Pack;

--  pack.adb

package body Pack
  with SPARK_Mode    => On,
       Refined_State =>
         (State => (OK_Inst_1.Pack_Var, OK_Inst_2.Pack_Var,
                    OK_Inst_3.Wrap_Var, OK_Inst_3.Inst.Pack_Var,
                    OK_Inst_4.Wrap_Var, OK_Inst_4.Inst.Pack_Var))
is
   procedure Force_Body is null;
end Pack;

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

$ gcc -c pack.adb
pack.ads:23:12: indicator Part_Of is required in this context (SPARK RM
  7.2.6(2))
pack.ads:23:12: "Error_Inst_1" is declared in the private part of package
  "Pack"
pack.ads:24:12: indicator Part_Of is required in this context (SPARK RM
  7.2.6(2))
pack.ads:24:12: "Error_Inst_2" is declared in the private part of package
  "Pack"

2018-07-16  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* contracts.adb (Analyze_Contracts): Add specialized processing for
	package instantiation contracts.
	(Analyze_Package_Contract): Remove the verification of a missing
	Part_Of indicator.
	(Analyze_Package_Instantiation_Contract): New routine.
	* contracts.ads (Analyze_Package_Contract): Update the comment on
	usage.
	* sem_prag.adb (Check_Missing_Part_Of): Ensure that the entity of the
	instance is being examined when trying to determine whether a package
	instantiation needs a Part_Of indicator.

From-SVN: r262731
2018-07-16 14:12:33 +00:00
Hristian Kirtchev 400ad4e950 [Ada] Minor reformatting
2018-07-16  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* einfo.adb, exp_ch7.adb, exp_ch9.adb, exp_unst.adb, inline.adb,
	sem.adb, sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_eval.adb,
	sem_util.adb: Minor reformatting.

From-SVN: r262730
2018-07-16 14:12:28 +00:00
Arnaud Charlet 4af4c79a53 [Ada] Only unnest subprograms if no previous errors were detected
2018-07-16  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* frontend.adb: Only unnest subprograms if no previous errors were
	 detected.

From-SVN: r262729
2018-07-16 14:12:23 +00:00
Ed Schonberg 4aba11eeb3 [Ada] Fix expansion of blocks in loops inside elaboration code
2018-07-16  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_ch7.adb (Check_Unnesting_Elaboration_Code): Handle loops that
	contain blocks in the elaboration code for a package body. Create the
	elaboration subprogram wrapper only if there is a subprogram
	declaration in a block or loop.

From-SVN: r262728
2018-07-16 14:12:18 +00:00
Ed Schonberg afe9c53918 [Ada] Deep copy operands of membership operations for unnesting
2018-07-16  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_Set_Membership): Use New_Copy_Tree to perform a
	deep copy of the left operand when building each conjuct of the
	expanded membership operation, to avoid sharing nodes between them.
	This sharing interferes with the unnesting machinery and is generally
	undesirable.

From-SVN: r262727
2018-07-16 14:12:13 +00:00
Ed Schonberg 4dd2ed1495 [Ada] Unnesting: handle 'Address references that are calls
2018-07-16  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_unst.adb (Visit_Node): Handle 'Address references that are
	calls.

From-SVN: r262726
2018-07-16 14:12:09 +00:00
Ed Schonberg fa42563af9 [Ada] Unnesting: handle the semantic of Storage_Pool field
2018-07-16  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_unst.adb (Visit_Node): Handle the semantic of Storage_Pool field
	in relevant nodes: Allocate, Free, and return statements.

From-SVN: r262725
2018-07-16 14:12:03 +00:00
Ed Schonberg dbe5b438d2 [Ada] Fix Default_Storage_Pool aspect handling in generic instantiations
2018-07-16  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch12.adb (Analyze_Package_Instantiation): Handle properly an
	instance that carries an aspect Default_Storage_Pool that overrides a
	default storage pool that applies to the generic unit. The aspect in
	the generic unit was removed before copying it in the instance, rather
	than removing it from the copy of the aspects that are appended to the
	aspects in the instance.

From-SVN: r262724
2018-07-16 14:11:58 +00:00
Ed Schonberg ccc2a61390 [Ada] Major code cleanup
2018-07-16  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* einfo.adb (Set_Is_Uplevel_Referenced_Entity): Flag can appear on
	loop parameters.
	* exp_ch7.adb (Check_Unnesting_Elaboration_Code): Handle subprogram
	bodies.
	* exp_ch9.adb (Reset_Scopes_To): Set the scopes of entities local to an
	entry body to be the corresponding generated subprogram, for correct
	analysis of uplevel references.
	* exp_unst.adb (Visit_Node): Handle properly binary and unary operators
	Ignore pragmas, fix component associations.
	(Register_Subprograms): Subprograms in synchronized types must be
	treated as reachable.

From-SVN: r262723
2018-07-16 14:11:52 +00:00
Hristian Kirtchev 93bc357b34 [Ada] Spurious error with null Abstract_State
This patch corrects the mechanism which ensures that a package with a null
Abstract_State does not introduce hidden state, by ignoring internal states
and variables because they do not represent the "source" hidden state.

2018-07-16  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* sem_util.adb (Check_No_Hidden_State): Ignore internally-generated
	states and variables.

gcc/testsuite/

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

From-SVN: r262722
2018-07-16 14:11:47 +00:00
Piotr Trojanek 7da8b07f30 [Ada] Deconstruct unused Withed_Body filed of N_With_Clause node
The Withed_Body field was added to N_With_Clause node to help the
Walk_Library_Items routine, which was created for the CodePeer backend
and later adopted by the GNATprove.

This routine is meant to traverse all library units, such that declarations
are visited before references. However, for complex units (in particular,
with generics and child packages) it never worked reliably and backends
developed their own workarounds. This patch deconstructs the field, as it
hasn't been used for years.

Semantics unaffected; no test provided.

2018-07-16  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* sinfo.ads, sinfo.adb (Withed_Body): Remove.
	(Set_Withed_Body): Remove.

From-SVN: r262721
2018-07-16 14:11:42 +00:00
Piotr Trojanek 1d6c206005 [Ada] Avoid crash when traversing units with -gnatd.WW debug switch
The debug switch -gnatd.WW enables extra info when traversing library units
with Walk_Library_Items, which is used in the CodePeer and GNATprove. This
routine was crashing when trying to print info about a unit with configuration
pragmas (typically an .adc file). Now fixed.

No test, as the crash only happens when a GNATprove backend is manually called
with -gnatd.WW switch. Frontend is not affected.

2018-07-16  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* sem.adb (Walk_Library_Items): Skip units with configuration pragmas
	when printing debug info.

From-SVN: r262720
2018-07-16 14:11:37 +00:00
Piotr Trojanek bf6ff5e5f5 [Ada] Trivial simplifications in in Walk_Library_Items
Cleanup only; semantics unaffected.

2018-07-16  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* sem.adb (Walk_Library_Items): Reuse local constant.
	(Is_Subunit_Of_Main): Turn condition to positive and flip the
	IF-THEN-ELSE branches; avoid potentially ineffective assignment to the
	Lib variable.

From-SVN: r262719
2018-07-16 14:11:30 +00:00
Piotr Trojanek feb7f36cad [Ada] Deconstruct always-false calls to Withed_Body in Walk_Library_Items
We previously removed the calls to Set_Withed_Body; this commit deconstructs
calls to Withed_Body, which always returned False.

The Set_Withed_Body/Withed_Body were helping the Walk_Library_Items routine
traverse the AST of several compilation units such that declarations are
visited before references. However, this never worked as it should and there is
no point to keep the code more complicated than necessary.

No test provided, because thie removed code was ineffective (and only used in
the non-compiler backends, i.e. CodePeer and GNATprove).

2018-07-16  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* sem.adb (Walk_Library_Items): Deconstruct dead code.

From-SVN: r262718
2018-07-16 14:11:25 +00:00
Ed Schonberg 9cd7bc5e00 [Ada] Use common routine Expand_Nonbinary_Modular_Op for XOR expressions
2018-07-16  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_N_Op_Xor): Use common routine
	Expand_Nonbinary_Modular_Op.  Needed for unnesting.

From-SVN: r262717
2018-07-16 14:11:20 +00:00
Ed Schonberg d2b73a3edb [Ada] Add a missing check for trivial predicates on non-discrete types
2018-07-16  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch3.adb (Inherit_Predicate_Flags): A non-discrete type may have a
	static predicate (for example True) but has no
	static_discrete_predicate.

From-SVN: r262716
2018-07-16 14:11:15 +00:00
Hristian Kirtchev f2f9cdad15 [Ada] Crash on Indefinite_Hashed_Maps with -gnata -gnateV
This patch corrects the generation of helper functions which verify the
validity of record type scalar discriminants and scalar components when
switches -gnata (assertions enabled) and -gnateV (validity checks on
subprogram parameters) are in effect.

2018-07-16  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_attr.adb (Build_Record_VS_Func): Handle corner cases dealing with
	class-wide types and record extensions.

gcc/testsuite/

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

From-SVN: r262715
2018-07-16 14:11:09 +00:00
Justin Squirek 721500abf2 [Ada] Spurious possible contraint error warning with No_Exception_Propagation
This patch corrects an issue whereby spurious unhandled exception warnings on
integer literals within static if and case expressions would be emitted when
the restriction No_Exception_Propagation is enabled.

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

--  gnat.adc

pragma Restrictions (No_Exception_Propagation);
pragma SPARK_Mode (On);

--  pack.ads

package Pack is
   procedure Filter (Ret : out Integer);
end Pack;

--  pack.adb

package body Pack is

   subtype Nat is Integer range 0 .. 10;

   Default       : constant Nat := 1;
   User_Override : constant Integer := -1;

   procedure Filter (Ret : out Integer) is
      Val : constant Nat :=
              (if User_Override in Nat then
                  User_Override
               else
                  Default);
   begin
      Ret := Val;
   end Filter;
end Pack;

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

& gcc -c -gnatp -gnatwa pack.adb

2018-07-16  Justin Squirek  <squirek@adacore.com>

gcc/ada/

	* sem_eval.adb (Eval_Integer_Literal): Add exception for avoiding
	checks on expanded literals within if and case expressions.

From-SVN: r262714
2018-07-16 14:11:04 +00:00
Hristian Kirtchev 3c820aca55 [Ada] Segmentation_Fault with Integer'Wide_Wide_Value
This patch updates the routines which produce Wide_String and Wide_Wide_String
from a String to construct a result of the proper maximum size which is later
sliced.

2018-07-16  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* libgnat/s-wchwts.adb (Wide_String_To_String): Use the appropriate
	longest sequence factor. Code clean up.
	(Wide_Wide_String_To_String): Use the appropriate longest sequence
	factor.  Code clean up.

gcc/testsuite/

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

From-SVN: r262713
2018-07-16 14:10:58 +00:00
Javier Miranda 2588c36c2e [Ada] Bit_Order cannot be defined for record extensions
This patch allows the compiler to report an error on Bit_Order when
defined for a record extension.

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

gcc/ada/

	* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Report an error
	on Bit_Order when defined for a record extension.

gcc/testsuite/

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

From-SVN: r262712
2018-07-16 14:10:53 +00:00
Arnaud Charlet d7925fd3cd [Ada] System.Object_Reader: minor code clean-up
2018-07-16  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* libgnat/s-objrea.ads: Minor code clean up.

From-SVN: r262711
2018-07-16 14:10:47 +00:00
Piotr Trojanek 94b105618c [Ada] Adjust reference to renumbered SPARK RM rule
Rules in SPARK RM 7.1.3 were renumbered when adding support for tasking,
but references in the comments were not updated. Now fixed.

2018-07-16  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* sem_ch3.adb (Process_Discriminants): Adjust reference to the SPARM RM
	rule.

From-SVN: r262710
2018-07-16 14:10:42 +00:00
Arnaud Charlet 192d0b1583 [Ada] adaint.c: minor code cleanup
2018-07-16  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* adaint.c (__gnat_set_file_time_name): Code clean up.

From-SVN: r262709
2018-07-16 14:10:37 +00:00
Javier Miranda 3ac5f7de34 [Ada] Code cleanup on functions inlining
This patch is preventive: it improves checks on inline functions that
return unconstrained type. It does not change the functionality of
the compiler.

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

gcc/ada/

	* inline.adb (Build_Body_To_Inline): Minor code reorganization that
	ensures that calls to function Has_Single_Return() pass a decorated
	tree.
	(Has_Single_Return.Check_Return): Peform checks on entities (instead on
	relying on their characters).

From-SVN: r262708
2018-07-16 14:10:32 +00:00
Javier Miranda a3b7645bff [Ada] Crash processing sources under GNATprove debug mode
Processing sources under -gnatd.F the frontend may crash on
an iterator of the form 'for X of ...' over an array if the
iterator is located in an inlined subprogram.

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

gcc/ada/

	* exp_ch5.adb (Expand_Iterator_Loop_Over_Array): Code cleanup. Required
	to avoid generating an ill-formed tree that confuses gnatprove causing
	it to blowup.

gcc/testsuite/

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

From-SVN: r262707
2018-07-16 14:10:27 +00:00
Yannick Moy c4ea29786f [Ada] Inline: rewrap comment
2018-07-16  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* inline.adb (Has_Single_Return): Rewrap comment.

From-SVN: r262706
2018-07-16 14:10:22 +00:00
Eric Botcazou 3e752e1fc7 [Ada] Einfo: minor tweak in comment
2018-07-16  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* einfo.ads: Minor tweak in comment.

From-SVN: r262705
2018-07-16 14:10:18 +00:00
Javier Miranda 9f46106ade [Ada] Sem_Ch4: minor code cleanup
2018-07-16  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* sem_ch4.adb (Analyze_Membership_Op): Code cleanup.

From-SVN: r262704
2018-07-16 14:10:13 +00:00
Javier Miranda 97710dc731 [Ada] Fix expansion of 'Count in protected types
2018-07-16  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* exp_attr.adb (Expand_N_Attribute_Reference ['Count]): Do not
	transform 'Count into a function call if the current scope has been
	eliminated.

From-SVN: r262703
2018-07-16 14:10:08 +00:00
Javier Miranda 4bde5d8c90 [Ada] Sem_Utils: make Has_Prefix public
2018-07-16  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* sem_util.ads, sem_util.adb (Has_Prefix): Move this function to the
	public part of this package.

From-SVN: r262702
2018-07-16 14:10:03 +00:00
Yannick Moy ffafd2ab07 [Ada] Adjust inlining in GNATprove mode for predicate/invariant/DIC
The frontend generates special functions for checking subtype predicates,
type invariants and Default_Initial_Condition aspect. These are translated
as predicates in GNATprove, and as such should no call inside these
functions should be inlined. This is similar to the existing handling of
calls inside expression functions.

There is no impact on compilation.

2018-07-16  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* sem_res.adb (Resolve_Call): Do not inline calls inside
	compiler-generated functions translated as predicates in GNATprove.

From-SVN: r262701
2018-07-16 14:09:58 +00:00
Gary Dismukes b3181992f5 [Ada] Violation of No_Standard_Allocators_After_Elaboration not detected
The compiler fails to generate a call to detect allocators executed after
elaboration in cases where the allocator is associated with Global_Pool_Object.
The fix is to test for this associated storage pool as part of the condition
for generating a call to System.Elaboration_Allocators.Check_Standard_Alloctor.
Also, the exception Storage_Error is now generated instead of Program_Error
for such a run-time violation, as required by the Ada RM in D.7.

The following test must compile and execute quietly:

-- Put the pragma in gnat.adc:
pragma Restrictions (No_Standard_Allocators_After_Elaboration);

package Pkg_With_Allocators is

   type Priv is private;

   procedure Allocate
     (Use_Global_Allocator : Boolean;
      During_Elaboration   : Boolean);

private

   type Rec is record
      Int : Integer;
   end record;

   type Priv is access Rec;

end Pkg_With_Allocators;

package body Pkg_With_Allocators is

   Ptr : Priv;

   procedure Allocate
     (Use_Global_Allocator : Boolean;
      During_Elaboration   : Boolean)
   is
      type Local_Acc is access Rec;

      Local_Ptr : Local_Acc;

   begin
      if Use_Global_Allocator then
         Ptr := new Rec;  -- Raise Storage_Error if after elaboration
         Ptr.Int := 1;
      else
         Local_Ptr := new Rec;  -- Raise Storage_Error if after elaboration
         Local_Ptr.Int := 1;
      end if;

      if not During_Elaboration then
         raise Program_Error;  -- No earlier exception: FAIL
      end if;

   exception
      when Storage_Error =>
         if During_Elaboration then
            raise Program_Error;  -- No exception expected: FAIL
         else
            null;                 -- Expected Storage_Error: PASS
         end if;
      when others =>
         raise Program_Error;  -- Unexpected exception: FAIL
   end Allocate;

begin
   Allocate (Use_Global_Allocator => True, During_Elaboration => True);

   Allocate (Use_Global_Allocator => False, During_Elaboration => True);
end Pkg_With_Allocators;

with Pkg_With_Allocators;

procedure Alloc_Restriction_Main is
begin
   Pkg_With_Allocators.Allocate
     (Use_Global_Allocator => True,
      During_Elaboration   => False);

   Pkg_With_Allocators.Allocate
     (Use_Global_Allocator => False,
      During_Elaboration   => False);
end Alloc_Restriction_Main;

2018-07-16  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_N_Allocator): Test for Storage_Pool being RTE in
	addition to the existing test for no Storage_Pool as a condition
	enabling generation of the call to Check_Standard_Allocator when the
	restriction No_Standard_Allocators_After_Elaboration is active.
	* libgnat/s-elaall.ads (Check_Standard_Allocator): Correct comment to
	say that Storage_Error will be raised (rather than Program_Error).
	* libgnat/s-elaall.adb (Check_Standard_Allocator): Raise Storage_Error
	rather than Program_Error when Elaboration_In_Progress is False.

From-SVN: r262700
2018-07-16 14:09:53 +00:00
Gary Dismukes d3bbfc5936 [Ada] Fix spelling for compile-time-known
2018-07-16  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

	* sem_eval.adb: Fix spelling for compile-time-known.

From-SVN: r262699
2018-07-16 14:09:49 +00:00
Hristian Kirtchev 705bcbfeec [Ada] Illegal deferred constant causes stack overflow
This patch prevents the compiler from entering infinite recursion when
processing an illegal deferred constant.

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

--  types.ads

package Types is
   type Enum is (One, Two);
end Types;

--  types2.ads

with Types;

package Types2 is
   type Enum is private;
   One : constant Enum;
   Two : constant Enum;

private
   type Enum is new Types.Enum;
   One : constant Enum := One;
   Two : constant Enum := Two;

end Types2;

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

$ gcc -c types2.ads
types2.ads:10:04: full constant declaration appears too late
types2.ads:11:04: full constant declaration appears too late

2018-07-16  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* sem_eval.adb (Compile_Time_Known_Value): Add a guard which prevents
	the compiler from entering infinite recursion when trying to determine
	whether a deferred constant has a compile time known value, and the
	initialization expression of the constant is a reference to the
	constant itself.

From-SVN: r262698
2018-07-16 14:09:44 +00:00
Nicolas Roche e05a1ce711 [Ada] Adjust growth factor from 1/32 to 1/2 for Unbounded_String
This will reduce significantly the number of allocations done when
doing consecutive append operations.

2018-07-16  Nicolas Roche  <roche@adacore.com>

gcc/ada/

	* libgnat/a-strunb.adb, libgnat/a-strunb__shared.adb: Adjust growth
	factor from 1/32 to 1/2 for Unbounded_String.

From-SVN: r262697
2018-07-16 14:08:27 +00:00
Richard Biener 0150d9a1cd re PR debug/86523 (ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560)
2018-07-16  Richard Biener  <rguenther@suse.de>

	PR lto/86523
	* dwarf2out.c (dwarf2out_register_external_die): Assign DIE parents
	for function-local FUNCTION_DECL and RESULT_DECL immediately.

	* g++.dg/lto/pr86523-1_0.C: New testcase.
	* g++.dg/lto/pr86523-2_0.C: Likewise.

From-SVN: r262696
2018-07-16 13:57:32 +00:00
Martin Liska c4d0acf8f7 Revert one more symbol_summary::get to ::get_create (PR ipa/86529).
2018-07-16  Martin Liska  <mliska@suse.cz>

        PR ipa/86529
	* ipa-pure-const.c (malloc_candidate_p): Revert ::get
        to ::get_create.
2018-07-16  Martin Liska  <mliska@suse.cz>

        PR ipa/86529
	* g++.dg/ipa/pr86529.C: New test.

From-SVN: r262695
2018-07-16 13:33:23 +00:00
Claudiu Zissulescu 325a4c6e11 [ARC] Update ARCHS scheduling rules.
2017-07-16  Claudiu Zissulescu  <claziss@synopsys.com>

	* config/arc/arcHS.md: Update ARCHS scheduling rules.

From-SVN: r262689
2018-07-16 12:12:47 +02:00
Claudiu Zissulescu 43bb0fc221 [ARC] Add support for HS4x cpus.
gcc/
2017-03-10  Claudiu Zissulescu  <claziss@synopsys.com>

        * config/arc/arc-arch.h (arc_tune_attr): Add new tune parameters
        for ARCHS4x.
        * config/arc/arc-cpus.def (hs4x): New cpu.
        (hs4xd): Likewise.
        * config/arc/arc-tables.opt: Regenerate.
        * config/arc/arc.c (arc_sched_issue_rate): New function.
        (TARGET_SCHED_ISSUE_RATE): Define.
        (TARGET_SCHED_EXPOSED_PIPELINE): Likewise.
        * config/arc/arc.md (attr type): Add fpu_fuse, fpu_sdiv, fpu_ddiv,
        fpu_cvt.
        (attr tune): Add ARCHS4x tune values.
        (attr tune_dspmpy): Define.
        (*tst): Correct instruction type.
        * config/arc/arcHS.md: Don't use this automaton for ARCHS4x cpus.
        * config/arc/arcHS4x.md: New file.
        * config/arc/fpu.md: Update instruction type attributes.
        * config/arc/t-multilib: Regenerate.

From-SVN: r262688
2018-07-16 12:12:32 +02:00
Tom de Vries 8c0e07e384 [debug] Fix pre_dec handling in vartrack
When compiling test-case gcc.target/i386/vartrack-1.c with -O1 -g, register bx
is pushed in the prologue and popped in the epilogue:
...
(insn/f 26 3 27 2
  (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0  S8 A8])
       (reg:DI 3 bx))
   "vartrack-1.c":10 61 {*pushdi2_rex64}
   (expr_list:REG_DEAD (reg:DI 3 bx) (nil)))
  ...
(insn/f 29 28 30 2
  (set (reg:DI 3 bx)
       (mem:DI (post_inc:DI (reg/f:DI 7 sp)) [0  S8 A8]))
   "vartrack-1.c":15 71 {*popdi1}
   (expr_list:REG_CFA_ADJUST_CFA
     (set (reg/f:DI 7 sp)
          (plus:DI (reg/f:DI 7 sp)
                   (const_int 8 [0x8]))) (nil)))
...

However, when we adjust those insns in vartrack to eliminate the pre_dec and
post_inc, the frame location for the push is at argp - 24, while the one for the
pop is at argp - 16:
...
(insn/f 26 3 27 2
  (parallel [
    (set (mem:DI (plus:DI (reg/f:DI 16 argp)
                          (const_int -24 [0xffffffffffffffe8])) [0  S8 A8])
         (reg:DI 3 bx))
    (set (reg/f:DI 7 sp)
         (plus:DI (reg/f:DI 16 argp)
                  (const_int -24 [0xffffffffffffffe8])))
  ])
  "vartrack-1.c":10 61 {*pushdi2_rex64}
  (expr_list:REG_DEAD (reg:DI 3 bx) (nil)))
  ...
(insn/f 29 28 30 2
  (parallel [
    (set (reg:DI 3 bx)
         (mem:DI (plus:DI (reg/f:DI 16 argp)
                          (const_int -16 [0xfffffffffffffff0])) [0  S8 A8]))
    (set (reg/f:DI 7 sp)
         (plus:DI (reg/f:DI 16 argp)
                  (const_int -8 [0xfffffffffffffff8])))
  ])
  "vartrack-1.c":15 71 {*popdi1}
  (expr_list:REG_CFA_ADJUST_CFA
    (set (reg/f:DI 7 sp)
         (plus:DI (reg/f:DI 7 sp)
                  (const_int 8 [0x8]))) (nil)))
...

This patch fixes that by moving the stack_adjust modification after
adjust_insn in vt_initialize.

Bootstrapped and reg-tested on x86_64.

2018-07-16  Tom de Vries  <tdevries@suse.de>

	PR debug/86455
	* var-tracking.c (vt_initialize): Fix pre_dec handling.

	* gcc.target/i386/vartrack-1.c: New test.

From-SVN: r262687
2018-07-16 09:18:51 +00:00
Ramana Radhakrishnan 1d896f48fa [Patch AArch64] Add early clobber for aarch64_store_exclusive.
From-SVN: r262686
2018-07-16 09:03:48 +00:00
Eric Botcazou 5e5ef52c23 re PR tree-optimization/86514 (wrong manipulation of 2-dimensional packed array at -O)
PR tree-optimization/86514
	* tree-ssa-reassoc.c (init_range_entry) <CASE_CONVERT>: Return for a
	conversion to a boolean type from a type with greater precision.

From-SVN: r262684
2018-07-16 08:59:09 +00:00
Andreas Krebbel f030b30e32 Adjust email addresses.
2018-07-16  Andreas Krebbel  <krebbel@linux.ibm.com>

	* MAINTAINERS: Adjust email address for me and my colleague Robin
	Dapp.

From-SVN: r262683
2018-07-16 08:13:12 +00:00