platform/upstream/gcc.git
6 years ago[Ada] Ineffective use warning is suppressed when performing verification
Justin Squirek [Thu, 24 May 2018 13:05:20 +0000 (13:05 +0000)]
[Ada] Ineffective use warning is suppressed when performing verification

This patch fixes an issue whereby the compiler incorrectly marked use clauses
as effective due to code generated for verification referencing certain types
leading to missing use clause warnings.

No reasonably small testcase available.

2018-05-24  Justin Squirek  <squirek@adacore.com>

gcc/ada/

* sem_res.adb (Resolve_Entity_Name): Add guard to protect against
marking use clauses as effective when the reference appears within
generated code.

From-SVN: r260652

6 years ago[Ada] Fix typos in documentation
Cyrille Comar [Thu, 24 May 2018 13:05:14 +0000 (13:05 +0000)]
[Ada] Fix typos in documentation

2018-05-24  Cyrille Comar  <comar@adacore.com>

gcc/ada/

* doc/gnat_rm/the_gnat_library.rst: Fix typos.
* gnat_rm.texi: Regenerate.

From-SVN: r260651

6 years ago[Ada] Memory leak mixing limited and nonlimited functions
Bob Duff [Thu, 24 May 2018 13:05:08 +0000 (13:05 +0000)]
[Ada] Memory leak mixing limited and nonlimited functions

This patch fixes a memory leak. If a build-in-place function with a result
whose size is not known at the call site is called, and that function calls a
non-build-in-place function that allocates on the secondary stack, the
secondary stack was not necessarily cleaned up, which caused a memory leak.

The following program should print:
"Current allocated space :  0 bytes"
(among other things) in the loop.

./bip_leak-main > log
grep 'Current allocated' log
  Current allocated space :  0 bytes
  Current allocated space :  0 bytes
  Current allocated space :  0 bytes

with Ada.Finalization;
package BIP_Leak is
   subtype Limited_Controlled is Ada.Finalization.Limited_Controlled;

   type Nonlim_Controlled is new Ada.Finalization.Controlled with null record;
   type Needs_Fin is record
      X : Nonlim_Controlled;
   end record;

   type Lim_Controlled is new Limited_Controlled with null record;

   function Return_Lim_Controlled (Source : Boolean)
                       return Lim_Controlled;

   procedure Dump_SS;

end BIP_Leak;

with Ada.Text_IO;
pragma Warnings (Off);
with System.Secondary_Stack;
pragma Warnings (On);
package body BIP_Leak is
   function Transform (X : Needs_Fin) return Lim_Controlled is
   begin
      return (Limited_Controlled with null record);
   end;

   function Return_Needs_Fin (I : Boolean) return Needs_Fin is
     THR : Needs_Fin;
   begin
      return THR;
   end;

   function Return_Lim_Controlled (Source : Boolean)
                       return Lim_Controlled is
   begin
      return Transform (Return_Needs_Fin (Source));
   end Return_Lim_Controlled;

   procedure Dump_SS_Instance is
     new System.Secondary_Stack.SS_Info (Ada.Text_IO.Put_Line);
   procedure Dump_SS renames Dump_SS_Instance;

end BIP_Leak;

procedure BIP_Leak.Main is
begin
   for Count in 1 .. 350_000 loop
      declare
         Msg : constant Lim_Controlled := Return_Lim_Controlled (True);
      begin
         if Count mod 100_000 = 0 then
            Dump_SS;
         end if;
      end;
   end loop;
end BIP_Leak.Main;

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

gcc/ada/

* exp_ch7.adb (Expand_Cleanup_Actions): Create a mark unconditionally
for build-in-place functions with a caller-unknown-size result.
(Create_Finalizer): For build-in-place functions with a
caller-unknown-size result, check at run time whether we need to
release the secondary stack.

From-SVN: r260650

6 years ago[Ada] Spurious error on pragma Independent_Components
Hristian Kirtchev [Thu, 24 May 2018 13:05:03 +0000 (13:05 +0000)]
[Ada] Spurious error on pragma Independent_Components

This patch modifies the analysis of pragma Independent_Components to account
for a side effect from handling of self-referential records which render the
pragma illegal.

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

--  pack.ads

package Pack is
   type OK is record
      Comp_1 : Integer;
      Comp_2 : access OK;
   end record;
   pragma Independent_Components (OK);

   type Error;
   pragma Independent_Components (Error);
   type Error is record
      Comp : Integer;
   end record;
end Pack;

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

$ gcc -c pack.ads
pack.ads:9:04: representation item must be after full type declaration

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

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Use the full view of an internally
generated incomplete type.

From-SVN: r260649

6 years ago[Ada] Fix crash on formal containers
Hristian Kirtchev [Thu, 24 May 2018 13:04:52 +0000 (13:04 +0000)]
[Ada] Fix crash on formal containers

This patch modifies several mechanisms in the compiler:

1) The handling of Ghost regions now records the start of the outermost ignored
   Ghost region which is currently in effect.

2) Generation of freeze actions for an arbitrary entity now inserts the actions
   prior to the start of the outermost ignored Ghost region when the freezing
   takes effect within an ignored Ghost region, but the entity being frozen is
   "living". This ensures that any freeze actions associated with the living
   entity will not be eliminated from the tree once ignored Ghost code is
   stripped away.

3) The Default_Initial_Condition and Invariant procedures are not treated as
   primitives even when they apply to tagged types. These procedures already
   employ class-wide precondition-like semantics to handle inheritance and
   overriding. In addition, the procedures cannot be invoked from source and
   should not be targets of dispatching calls.

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

gcc/ada/

* expander.adb (Expand): Update the save and restore of the Ghost
region.
* exp_ch3.adb (Freeze_Type): Likewise.
* exp_disp.adb (Make_DT): Likewise.
* exp_util.adb (Build_DIC_Procedure_Body): Likewise.
(Build_DIC_Procedure_Declaration): Likewise.
(Build_Invariant_Procedure_Body): Likewise.
(Build_Invariant_Procedure_Declaration): Likewise.
(Make_Predicate_Call): Likewise.
* freeze.adb (Add_To_Result): Insert the freeze action of a living
entity prior to the start of the enclosing ignored Ghost region.
(Freeze_Entity): Update the save and restore of the Ghost region.
* ghost.adb (Install_Ghost_Mode): Reimplemented.
(Install_Ghost_Region): New routine.
(Mark_And_Set_Ghost_Assignment): Install a region rather than a mode.
(Mark_And_Set_Ghost_Body): Likewise.
(Mark_And_Set_Ghost_Completion): Likewise.
(Mark_And_Set_Ghost_Declaration): Likewise.
(Mark_And_Set_Ghost_Instantiation): Likewise.
(Mark_And_Set_Ghost_Procedure_Call): Likewise.
(Name_To_Ghost_Mode): New routine.
(Restore_Ghost_Region): New routine.
* ghost.ads (Install_Ghost_Region): New routine.
(Restore_Ghost_Region): New routine.
* opt.ads: Add new global variable Ignored_Ghost_Region.
* rtsfind.adb (Load_RTU): Update the save and restore of the Ghost
region. Install a clean region.
* sem.adb (Analyze): Likewise.
(Do_Analyze): Likewise.
* sem_ch3.adb (Analyze_Object_Declaration): Likewise
(Derive_Progenitor_Subprograms): Use local variable Iface_Alias to
capture the ultimate alias of the current primitive.
(Process_Full_View): Update the save and restore of the Ghost region.
Do not inherit DIC and invariant procedures.
* sem_ch5.adb (Analyze_Assignment): Update the save and restore of the
Ghost region.
* sem_ch6.adb (Analyze_Procedure_Call): Likewise.
(Analyze_Subprogram_Body_Helper): Likewise.
* sem_ch7.adb (Analyze_Package_Body_Helper): Likewise.
* sem_ch12.adb (Analyze_Package_Instantiation): Likewise.
(Analyze_Subprogram_Instantiation): Likewise.
(Instantiate_Package_Body): Likewise.
(Instantiate_Subprogram_Body): Likewise.
* sem_ch13.adb (Build_Predicate_Functions): Likewise.
(Build_Predicate_Function_Declaration): Likewise.
* sem_disp.adb
(Add_Dispatching_Operation): Do not consider DIC and invariant
procedures.
(Check_Dispatching_Operation): Use Add_Dispatching_Operation to collect
a dispatching subprogram.
(Check_Operation_From_Private_View): Likewise.
(Override_Dispatching_Operation): Likewise.
* sem_prag.adb (Analyze_Contract_Cases_In_Decl_Part): Update the save
and restore of the Ghost region.
(Analyze_Initial_Condition_In_Decl_Part): Likewise.
(Analyze_Pragma): Update the save and restore of the Ghost region.
(Analyze_Pre_Post_Condition_In_Decl_Part): Likewise.
* sem_util.adb (Is_Suitable_Primitive): New routine.
* sem_util.ads (Is_Suitable_Primitive): New routine.
* sinfo.ads: Update the section of Ghost regions.

gcc/testsuite/

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

From-SVN: r260648

6 years ago[Ada] Fix inconsistent documentation for the Contract_Cases pragma
Piotr Trojanek [Thu, 24 May 2018 13:04:44 +0000 (13:04 +0000)]
[Ada] Fix inconsistent documentation for the Contract_Cases pragma

This patch propagates the renaming from "condition" to "case guard" in the
contract grammar to the paragraphs that describe the pragma semantics.

2018-05-24  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst (Contract_Cases):
Change "condition" to "case guard" after renaming in the contract
grammar.
* gnat_rm.texi: Regenerate.

From-SVN: r260647

6 years ago[Ada] Expansion of discrete choices
Hristian Kirtchev [Thu, 24 May 2018 13:04:39 +0000 (13:04 +0000)]
[Ada] Expansion of discrete choices

This patch does some minor bookkeeping to avoid a potential double expansion
of discrete choices where at least one of them is a subtype with predicates.
No change in behavior, no need for a test.

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

gcc/ada/

* exp_util.adb (Expand_Static_Predicates_In_Choices): Indicate that the
construct with discrete choices no longer contains a subtype with
predicates since the expansion already handled this case.

From-SVN: r260646

6 years ago[Ada] Spurious error on imported subprogram with precondition
Hristian Kirtchev [Thu, 24 May 2018 13:04:34 +0000 (13:04 +0000)]
[Ada] Spurious error on imported subprogram with precondition

This patch modifies the generation of wrappers for imported subprograms which
are subject to contracts. In the case of an imported function, the original
function is relocated within the wrapper, and the wrapper simply invokes the
imported subprogram, returning its value. When the result type of the imported
subprogram is anonymous access, the relocation creates a new anonymous access
type, but with a different accessibility level. Since both return types are
essentially the same type, eliminate the accessibility level inconsistency by
unchecked converting the result of calling the imported function to the return
type.

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

--  pack.ads

package Pack is
   type Integer_Ptr is access all Integer;
   type Typ is null record;

   function Predicate (Val : Typ) return Boolean is (True);

   function Imported_1 (Val : Typ) return access Integer
     with Pre => Predicate (Val), Import;

   function Imported_2 (Val : Typ) return Integer_Ptr
     with Pre => Predicate (Val), Import;
end Pack;

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

$ gcc -c pack.ads

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

gcc/ada/

* freeze.adb (Wrap_Imported_Subprogram): Generate an unchecked
conversion to the return type to avoid a side effect where an imported
relocated function generates a new anonymous access type, whose
accessibility level does not agree with with that of the wrapper.

From-SVN: r260645

6 years ago[Ada] Spurious error on private task derivation
Javier Miranda [Thu, 24 May 2018 13:04:29 +0000 (13:04 +0000)]
[Ada] Spurious error on private task derivation

The compiler reports a spurious error notifying a missing constraint in the
declaration of a private type with discriminants whose full view is a
derivation of a task type.

After this patch the following test compiles without errors.

package Types1 is
   type Parent (Discr1 : Boolean) is limited private;
private
   task type Parent (Discr1 : Boolean);
end Types1;

with Types1; use Types1;
package Types2 is
   type Child (Discr2 : Boolean) is limited private;
private
   type Child (Discr2 : Boolean) is       -- Test
     new Parent (Discr1 => Discr2);
end Types2;

Command: gcc -c types2.ads

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

gcc/ada/

* sem_util.adb (Abstract_Interface_List): Add missing support for
private types whose full view is a synchronized type.
* sem_ch3.adb (Build_Derived_Private_Type): Skip building the full
derivation of a private type parent type is a task type with
discriminants as gigi does not use such type directly.

From-SVN: r260644

6 years ago[Ada] Crash on compilation unit instance
Hristian Kirtchev [Thu, 24 May 2018 13:04:24 +0000 (13:04 +0000)]
[Ada] Crash on compilation unit instance

Do not generate a variable marker for a reference which appears within the
formal part of an instantiation which acts as a compilation unit because
there is no suitable insertion context.

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

--  gnat.adc

pragma SPARK_Mode (On);

--  gen.ads

generic
   Val_1 : Integer;
   Val_2 : Integer;
package Gen is
end Gen;

--  pack.ads

package Pack is
   Val : Integer := 123;

   function Get_Val return Integer;
end Pack;

--  inst.ads

with Gen;
with Pack; use Pack;

package Inst is new Gen (Val, Get_Val);

--  proc.adb

with Pack; use Pack;

procedure Proc (Val_1 : Integer := Val; Val_2 : Integer := Get_Val) is
begin null; end Proc;

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

$ gcc -c inst.ads
$ gcc -c inst.ads -gnatd.F
$ gcc -c proc.adb
$ gcc -c proc.adb -gnatd.F

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

gcc/ada/

* sem_elab.adb (Build_Variable_Reference_Marker): Do not create a
variable marker when the reference appears in the formal part of a
compilation unit instance because there is no place to insert it.
(In_Compilation_Instance_Formal_Part): New routine.

From-SVN: r260643

6 years ago[Ada] Fix references to Backend_Layout configuration parameter
Piotr Trojanek [Thu, 24 May 2018 13:04:16 +0000 (13:04 +0000)]
[Ada] Fix references to Backend_Layout configuration parameter

Apparently the Backend_Layout target configuration parameter was renamed to
Frontend_Layout a long time ago (and their meanings are opposite). However,
some comments were still referencing the no longer existing Backend_Layout.
This patch fixes such references.

No test provided, because only comments has been modified.

2018-05-24  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* layout.ads, repinfo.ads: Fix references to renamed Backend_Layout
configuration parameter.

From-SVN: r260642

6 years ago[Ada] Initial port of x86-lynx178elf runtimes
Doug Rupp [Thu, 24 May 2018 13:04:11 +0000 (13:04 +0000)]
[Ada] Initial port of x86-lynx178elf runtimes

2018-05-24  Doug Rupp  <rupp@adacore.com>

gcc/ada/

* argv-lynxos178-raven-cert.c: New file.
* libgnat/system-lynxos178-x86.ads: New file.

From-SVN: r260641

6 years agoRequire ifunc support in gcc.target/i386/pr85345.c
Rainer Orth [Thu, 24 May 2018 12:50:34 +0000 (12:50 +0000)]
Require ifunc support in gcc.target/i386/pr85345.c

* gcc.target/i386/pr85345.c: Require ifunc support.

From-SVN: r260640

6 years agoUse canonicalize_math_after_vectorization_p for FMA folds
Richard Sandiford [Thu, 24 May 2018 12:34:18 +0000 (12:34 +0000)]
Use canonicalize_math_after_vectorization_p for FMA folds

The folds in r260348 kicked in before vectorisation, which hurts
for two reasons:

(1) the current suboptimal handling of nothrow meant that we could
    drop the flag early and so prevent if-conversion

(2) some architectures provide more scalar forms than vector forms
    (true for Advanced SIMD)

(1) is a bug in itself that needs to be fixed eventually, but delaying
the folds is still needed for (2).

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

gcc/
* match.pd: Delay FMA folds until after vectorization.

gcc/testsuite/
* gcc.dg/vect/vect-fma-1.c: New test.

From-SVN: r260639

6 years agoFix dumpfile name in gcc.dg/tree-prof/update-loopch.c
Rainer Orth [Thu, 24 May 2018 12:27:01 +0000 (12:27 +0000)]
Fix dumpfile name in gcc.dg/tree-prof/update-loopch.c

* gcc.dg/tree-prof/update-loopch.c: Fix dumpfile name in
scan-tree-dump*.

From-SVN: r260638

6 years agoPR target/83009: Relax strict address checking for store pair lanes
Andre Vieira [Thu, 24 May 2018 08:53:39 +0000 (08:53 +0000)]
PR target/83009: Relax strict address checking for store pair lanes

The operand constraint for the memory address of store/load pair lanes was
enforcing strictly hardware registers be allowed as memory addresses.  We want
to relax that such that these patterns can be used by combine.  During register
allocation the register constraint will enforce the correct register is chosen.

gcc
2018-05-24  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR target/83009
* config/aarch64/predicates.md (aarch64_mem_pair_lanes_operand): Make
address check not strict.

gcc/testsuite
2018-05-24  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR target/83009
* gcc/target/aarch64/store_v2vec_lanes.c: Add extra tests.

From-SVN: r260635

6 years agoAdd a class to represent a gimple match result
Richard Sandiford [Thu, 24 May 2018 08:02:35 +0000 (08:02 +0000)]
Add a class to represent a gimple match result

Gimple match results are represented by a code_helper for the operation,
a tree for the type, and an array of three trees for the operands.
This patch wraps them up in a class so that they don't need to be
passed around individually.

The main reason for doing this is to make it easier to increase the
number of operands (for calls) or to support more complicated kinds
of operation.  But passing around fewer operands also helps to reduce
the size of gimple-match.o (about 7% for development builds and 4% for
release builds).

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

gcc/
* gimple-match.h (gimple_match_op): New class.
(mprts_hook): Replace parameters with a gimple_match_op *.
(maybe_build_generic_op): Likewise.
(gimple_simplified_result_is_gimple_val): Replace parameters with
a const gimple_match_op *.
(gimple_simplify): Replace code_helper * and tree * parameters with
a gimple_match_op * parameter.
(gimple_resimplify1): Replace code_helper *, tree and tree *
parameters with a gimple_match_op * parameter.
(gimple_resimplify2): Likewise.
(gimple_resimplify3): Likewise.
(maybe_push_res_to_seq): Replace code_helper, tree and tree *
parameters with a gimple_match_op * parameter.
* gimple-match-head.c (gimple_simplify): Change prototypes of
auto-generated functions to take a gimple_match_op * instead of
separate code_helper * and tree * parameters.  Make the same
change in the top-level overload and update calls to the
gimple_resimplify routines.  Update calls to the auto-generated
functions and to maybe_push_res_to_seq in the publicly-facing
operation-specific gimple_simplify overloads.
(gimple_match_op::MAX_NUM_OPS): Define.
(gimple_resimplify1): Replace rcode and ops with a single res_op
parameter.  Update call to gimple_simplify.
(gimple_resimplify2): Likewise.
(gimple_resimplify3): Likewise.
(mprts_hook): Replace parameters with a gimple_match_op *.
(maybe_build_generic_op): Likewise.
(build_call_internal): Replace type, nargs and ops with
a gimple_match_op *.
(maybe_push_res_to_seq): Replace res_code, type and ops parameters
with a single gimple_match_op *.  Update calls to mprts_hook,
build_call_internal and gimple_simplified_result_is_gimple_val.
Factor out code that is common to the tree_code and combined_fn cases.
* genmatch.c (expr::gen_transform): Replace tem_code and
tem_ops with a gimple_match_op called tem_op.  Update calls
to the gimple_resimplify functions and maybe_push_res_to_seq.
(dt_simplify::gen_1): Manipulate res_op instead of res_code and
res_ops.  Update call to the gimple_resimplify functions.
(dt_simplify::gen): Pass res_op instead of res_code and res_ops.
(decision_tree::gen): Make the functions take a gimple_match_op *
called res_op instead of separate res_code and res_ops parameters.
Update call accordingly.
* gimple-fold.c (replace_stmt_with_simplification): Replace rcode
and ops with a single res_op parameter.  Update calls to
maybe_build_generic_op and maybe_push_res_to_seq.
(fold_stmt_1): Update calls to gimple_simplify and
replace_stmt_with_simplification.
(gimple_fold_stmt_to_constant_1): Update calls to gimple_simplify
and gimple_simplified_result_is_gimple_val.
* tree-cfgcleanup.c (cleanup_control_expr_graph): Update call to
gimple_simplify.
* tree-ssa-sccvn.c (vn_lookup_simplify_result): Replace parameters
with a gimple_match_op *.
(vn_nary_build_or_lookup): Likewise.  Update call to
vn_nary_build_or_lookup_1.
(vn_nary_build_or_lookup_1): Replace rcode, type and ops with a
gimple_match_op *.  Update calls to the gimple_resimplify routines
and to gimple_simplified_result_is_gimple_val.
(vn_nary_simplify): Update call to vn_nary_build_or_lookup_1.
Use gimple_match_op::MAX_NUM_OPS instead of a hard-coded 3.
(vn_reference_lookup_3): Update call to vn_nary_build_or_lookup.
(visit_nary_op): Likewise.
(visit_reference_op_load): Likewise.

From-SVN: r260634

6 years agoDaily bump.
GCC Administrator [Thu, 24 May 2018 00:16:44 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r260633

6 years agoFix bootstrap breakage on i686
Luis Machado [Wed, 23 May 2018 22:49:34 +0000 (22:49 +0000)]
Fix bootstrap breakage on i686

gcc/ChangeLog:

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

* tree-ssa-loop-prefetch.c (should_issue_prefetch_p): Use correct type
modifier for printing the step amount.

From-SVN: r260629

6 years agoRefactor path construction from null terminated iterator ranges
Jonathan Wakely [Wed, 23 May 2018 22:48:51 +0000 (23:48 +0100)]
Refactor path construction from null terminated iterator ranges

Move duplicated code to new _S_string_from_iter function and fix
constraints to accept iterators with const value type.

* include/bits/fs_path.h (path::__is_encoded_char): Change from class
template to alias template.
(path::__value_type_is_char): Use remove_const_t.
(path:_S_string_from_iter): New helper function.
(path::_S_convert(InputIter, __null_terminated))
(path::_S_convert_loc(InputIter, __null_terminated, const locale&)):
Use _S_string_from_iter.
(path::string<_CharT, _Allocator>(const _Allocator&)): Allow sharing
rep for COW strings.
* include/experimental/bits/fs_path.h (path::__is_encoded_char):
Change from class template to alias template.
(path::__value_type_is_char): Use remove_const.
(path:_S_string_from_iter): New helper function.
(path::_S_convert(InputIter, __null_terminated))
(path::_S_convert_loc(InputIter, __null_terminated, const locale&)):
Use _S_string_from_iter.
* testsuite/27_io/filesystem/path/append/source.cc: Test appending
wide strings.
* testsuite/27_io/filesystem/path/concat/strings.cc: Check for exact
string equality, not path equivalence.
* testsuite/27_io/filesystem/path/construct/format.cc: Check
construction from std::string and std::wstring and input iterators.
* testsuite/27_io/filesystem/path/construct/locale.cc: Check
construction from iterators.
* testsuite/experimental/filesystem/path/concat/strings.cc: Check for
exact string equality, not path equivalence.
* testsuite/experimental/filesystem/path/construct/locale.cc: Check
construction from iterators.

From-SVN: r260628

6 years agore PR target/78849 (ICE on initialization of global struct containing __int20 array...
Jeff Law [Wed, 23 May 2018 22:33:36 +0000 (16:33 -0600)]
re PR target/78849 (ICE on initialization of global struct containing __int20 array at varasm.c:4968)

PR target/78849
* gcc/tree.c (build_common_tree_nodes): Dont set TYPE_SIZE for __intN
types.

PR target/78849
* gcc.target/msp430/msp430.exp: Remove -pedantic-errors from
DEFAULT_CFLAGS.
* gcc.target/msp430/pr78849.c: New test.

From-SVN: r260627

6 years agolb1sf68.S (Laddsf$nf): Fix sign bit handling in path to Lf$finfty.
Kalamatee [Wed, 23 May 2018 22:29:01 +0000 (22:29 +0000)]
lb1sf68.S (Laddsf$nf): Fix sign bit handling in path to Lf$finfty.

2018-05-23  Kalamatee  <kalamatee@gmail.com>

* config/m68k/lb1sf68.S (Laddsf$nf): Fix sign bit handling in
path to Lf$finfty.

From-SVN: r260626

6 years agorange-for8.C: New test.
Marek Polacek [Wed, 23 May 2018 19:06:36 +0000 (19:06 +0000)]
range-for8.C: New test.

* g++.dg/cpp2a/range-for8.C: New test.
* g++.dg/cpp2a/range-for9.C: New test.
* g++.dg/cpp2a/range-for10.C: New test.

From-SVN: r260625

6 years agotestsuite: Introduce be/le selectors
Segher Boessenkool [Wed, 23 May 2018 17:31:05 +0000 (19:31 +0200)]
testsuite: Introduce be/le selectors

This patch creates "be" and "le" selectors, which can be used by all
architectures, similar to ilp32 and lp64.

* doc/sourcebuild.texi (Endianness): New subsubsection.

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_be): New.
(check_effective_target_le): New.

From-SVN: r260623

6 years agoFix cast to rvalue reference from prvalue.
Jason Merrill [Wed, 23 May 2018 17:21:39 +0000 (13:21 -0400)]
Fix cast to rvalue reference from prvalue.

* cvt.c (diagnose_ref_binding): Handle rvalue reference.
* rtti.c (build_dynamic_cast_1): Don't try to build a reference to
non-class type.  Handle xvalue argument.
* typeck.c (build_reinterpret_cast_1): Allow cast from prvalue to
rvalue reference.
* semantics.c (finish_compound_literal): Do direct-initialization,
not cast, to initialize a reference.

From-SVN: r260622

6 years agoCWG 616, 1213 - value category of subobject references.
Jason Merrill [Wed, 23 May 2018 17:21:22 +0000 (13:21 -0400)]
CWG 616, 1213 - value category of subobject references.

* tree.c (lvalue_kind): A reference to a subobject of a prvalue is
an xvalue.
* typeck2.c (build_m_component_ref): Likewise.
* typeck.c (cp_build_addr_expr_1, lvalue_or_else): Remove diagnostic
distinction between temporary and xvalue.

From-SVN: r260621

6 years ago* system.h: #include <new> earlier.
Jason Merrill [Wed, 23 May 2018 17:13:30 +0000 (13:13 -0400)]
* system.h: #include <new> earlier.

From-SVN: r260620

6 years agoImplement P0614R1, Range-based for statements with initializer.
Marek Polacek [Wed, 23 May 2018 16:39:47 +0000 (16:39 +0000)]
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

6 years ago[Patch 02/02] Introduce prefetch-dynamic-strides option
Luis Machado [Wed, 23 May 2018 16:23:11 +0000 (16:23 +0000)]
[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

6 years ago[Patch 01/02] Introduce prefetch-minimum stride option
Luis Machado [Wed, 23 May 2018 16:20:30 +0000 (16:20 +0000)]
[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

6 years agoFix handling of an empty filename at end of a path
Jonathan Wakely [Wed, 23 May 2018 16:11:06 +0000 (17:11 +0100)]
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

6 years ago[arm] Remove mode26 feature bit
Kyrylo Tkachov [Wed, 23 May 2018 15:26:35 +0000 (15:26 +0000)]
[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

6 years agoi386.md (*floatuns<SWI48:mode><MODEF:mode>2_avx512): New insn pattern.
Uros Bizjak [Wed, 23 May 2018 15:13:31 +0000 (17:13 +0200)]
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

6 years agodf-scan: remove ad-hoc handling of global regs in asms
Alexander Monakov [Wed, 23 May 2018 15:01:28 +0000 (18:01 +0300)]
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

6 years agoextend.texi: update Global Register Variables section
Alexander Monakov [Wed, 23 May 2018 14:44:10 +0000 (17:44 +0300)]
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

6 years agotree-ssa-sccvn.c (vn_reference_lookup_3): Remove restriction of fixed offset from...
Richard Biener [Wed, 23 May 2018 14:01:36 +0000 (14:01 +0000)]
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

6 years agogimple-ssa-strength-reduction.c (struct slsr_cand_d): Add first_interp field.
Bill Schmidt [Wed, 23 May 2018 13:26:05 +0000 (13:26 +0000)]
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

6 years ago[AArch64] Simplify frame pointer logic
Wilco Dijkstra [Wed, 23 May 2018 12:28:43 +0000 (12:28 +0000)]
[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

6 years ago[AArch64][PR target/84882] Add mno-strict-align
Sudakshina Das [Wed, 23 May 2018 11:33:09 +0000 (11:33 +0000)]
[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

6 years agox86: libatomic: Do not assume ELF constructors run before IFUNC resolvers
Florian Weimer [Wed, 23 May 2018 11:13:05 +0000 (13:13 +0200)]
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

6 years agoFix SLP def type when computing masks (PR85853)
Richard Sandiford [Wed, 23 May 2018 10:32:16 +0000 (10:32 +0000)]
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

6 years ago[Ada] Minor reformattings
Hristian Kirtchev [Wed, 23 May 2018 10:24:27 +0000 (10:24 +0000)]
[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

6 years ago[Ada] Fix memory leak in win32_wait error handling
Pascal Obry [Wed, 23 May 2018 10:24:04 +0000 (10:24 +0000)]
[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

6 years ago[Ada] Fix computation of handle/pid lists in win32_wait
Pascal Obry [Wed, 23 May 2018 10:23:59 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Spurious Storage_Error on imported array
Hristian Kirtchev [Wed, 23 May 2018 10:23:54 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Spurious error on instantiation with type with unknown discriminants
Ed Schonberg [Wed, 23 May 2018 10:23:48 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Fix faulty preconditions for trigonometric functions
Boris Yakobowski [Wed, 23 May 2018 10:23:43 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Fix various defects found by static analysis
Arnaud Charlet [Wed, 23 May 2018 10:23:39 +0000 (10:23 +0000)]
[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

6 years ago[Ada] gnatbind: do not list No_Implementation_Restrictions
Bob Duff [Wed, 23 May 2018 10:23:34 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Implementation of AI12-0131: legality of class-wide precondition
Ed Schonberg [Wed, 23 May 2018 10:23:29 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Crash processing Valid_Scalars whose evaluation is always true
Javier Miranda [Wed, 23 May 2018 10:23:24 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Vectors: spurious error in -gnatwE mode
Bob Duff [Wed, 23 May 2018 10:23:19 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Clarify meaning of local pragma Warnings Off without On
Yannick Moy [Wed, 23 May 2018 10:23:14 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Add a Is_Foreign_Exception predicate to GNAT.Exception_Actions
Olivier Hainque [Wed, 23 May 2018 10:23:09 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Missing legality check on iterator over formal container
Ed Schonberg [Wed, 23 May 2018 10:23:02 +0000 (10:23 +0000)]
[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

6 years ago[Ada] Fix implementation of utility for finding enclosing declaration
Yannick Moy [Wed, 23 May 2018 10:22:57 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Suspension and elaboration warnings/checks
Hristian Kirtchev [Wed, 23 May 2018 10:22:52 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Restrict initialization of External_Tag and Expanded_Name
Javier Miranda [Wed, 23 May 2018 10:22:47 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Fix of some permission rules of pointers in SPARK
Maroua Maalej [Wed, 23 May 2018 10:22:41 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Crash on predicate involving qualified expression in instance
Ed Schonberg [Wed, 23 May 2018 10:22:35 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Suppression of elaboration-related warnings
Hristian Kirtchev [Wed, 23 May 2018 10:22:30 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Suppression of elaboration-related warnings
Hristian Kirtchev [Wed, 23 May 2018 10:22:25 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Remove obsolete stuff from repinfo.adb
Eric Botcazou [Wed, 23 May 2018 10:22:20 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Suppression of elaboration-related warnings
Hristian Kirtchev [Wed, 23 May 2018 10:22:15 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Minor reformatting
Piotr Trojanek [Wed, 23 May 2018 10:22:08 +0000 (10:22 +0000)]
[Ada] Minor reformatting

2018-05-23  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* einfo.ads: Minor reformatting.

From-SVN: r260577

6 years ago[Ada] Compiler fails to reject illegal store of anonymous_access_to_subprogram
Ed Schonberg [Wed, 23 May 2018 10:22:03 +0000 (10:22 +0000)]
[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

6 years ago[Ada] Turn off length expansion in CodePeer mode
Daniel Mercier [Wed, 23 May 2018 10:21:58 +0000 (10:21 +0000)]
[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

6 years ago[Ada] Build-in-place aggregates and Address clauses
Bob Duff [Wed, 23 May 2018 10:21:53 +0000 (10:21 +0000)]
[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

6 years ago[Ada] Minor reformatting
Bob Duff [Wed, 23 May 2018 10:21:47 +0000 (10:21 +0000)]
[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

6 years ago[Ada] Initialize_Scalars optimization causes spurious runtime check failure
Hristian Kirtchev [Wed, 23 May 2018 10:21:42 +0000 (10:21 +0000)]
[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

6 years ago[Ada] Minor reformatting
Hristian Kirtchev [Wed, 23 May 2018 10:21:37 +0000 (10:21 +0000)]
[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

6 years agore PR middle-end/85874 (gcc points to wrong location when displaying warning for...
Richard Biener [Wed, 23 May 2018 09:06:01 +0000 (09:06 +0000)]
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

6 years agore PR tree-optimization/85822 (Maybe wrong code in VRP since r249150)
Yury Gribov [Wed, 23 May 2018 07:40:43 +0000 (07:40 +0000)]
re PR tree-optimization/85822 (Maybe wrong code in VRP since r249150)

PR tree-optimization/85822

From-SVN: r260566

6 years agotree-ssa-sccvn.c (vn_reference_lookup_3): Handle arbitrary memset constants via nativ...
Richard Biener [Wed, 23 May 2018 07:08:43 +0000 (07:08 +0000)]
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

6 years agoPR c++/81420 - not extending temporary lifetime.
Jason Merrill [Wed, 23 May 2018 03:52:56 +0000 (23:52 -0400)]
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

6 years agoPR c++/85866 - error with .* in default template arg.
Jason Merrill [Wed, 23 May 2018 03:52:49 +0000 (23:52 -0400)]
PR c++/85866 - error with .* in default template arg.

* pt.c (tsubst_copy_and_build): Handle partial instantiation.

From-SVN: r260562

6 years agoDaily bump.
GCC Administrator [Wed, 23 May 2018 00:16:19 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r260561

6 years agore PR fortran/85841 ([F2018] reject deleted features)
Janus Weil [Tue, 22 May 2018 20:05:53 +0000 (22:05 +0200)]
re PR fortran/85841 ([F2018] reject deleted features)

2018-05-22  Janus Weil  <janus@gcc.gnu.org>

PR fortran/85841
* gfortran.dg/pr30667.f: Add option "-std=legacy".

From-SVN: r260555

6 years agoPR middle-end/85359 - duplicate -Wstringop-overflow for a strcmp call with a nonstrin...
Martin Sebor [Tue, 22 May 2018 19:37:48 +0000 (19:37 +0000)]
PR middle-end/85359 - duplicate -Wstringop-overflow for a strcmp call with a nonstring pointer

gcc/ChangeLog:

PR middle-end/85359
* builtins.c (expand_builtin_strcpy): Call maybe_warn_nonstring_arg
only when expasion succeeds.
(expand_builtin_strcmp): Same.
(expand_builtin_strncmp): Same.

gcc/testsuite/ChangeLog:

PR middle-end/85359
* gcc.dg/attr-nonstring.c: New test.

From-SVN: r260550

6 years agoDon't mark IFUNC resolver as only called directly
H.J. Lu [Tue, 22 May 2018 19:10:34 +0000 (19:10 +0000)]
Don't mark IFUNC resolver as only called directly

Since IFUNC resolver is called indirectly, don't mark IFUNC resolver as
only called directly.  This patch adds ifunc_resolver to cgraph_node,
sets ifunc_resolver for ifunc attribute and checks ifunc_resolver
instead of looking up ifunc attribute.

gcc/

PR target/85345
* cgraph.h (cgraph_node::create): Set ifunc_resolver for ifunc
attribute.
(cgraph_node::create_alias): Likewise.
(cgraph_node::get_availability): Check ifunc_resolver instead
of looking up ifunc attribute.
* cgraphunit.c (maybe_diag_incompatible_alias): Likewise.
* varasm.c (do_assemble_alias): Likewise.
(assemble_alias): Likewise.
(default_binds_local_p_3): Likewise.
* cgraph.h (cgraph_node): Add ifunc_resolver.
(cgraph_node::only_called_directly_or_aliased_p): Return false
for IFUNC resolver.
* lto-cgraph.c (input_node): Set ifunc_resolver for ifunc
attribute.
* symtab.c (symtab_node::verify_base): Verify that ifunc_resolver
is equivalent to lookup_attribute ("ifunc", DECL_ATTRIBUTES (decl)).
(symtab_node::binds_to_current_def_p): Check ifunc_resolver
instead of looking up ifunc attribute.

gcc/testsuite/

PR target/85345
* gcc.target/i386/pr85345.c: New test.

From-SVN: r260547

6 years ago[AArch64] Recognize a missed usage of a sbfiz instruction
Luis Machado [Tue, 22 May 2018 18:35:15 +0000 (18:35 +0000)]
[AArch64] Recognize a missed usage of a sbfiz instruction

A customer reported the following missed opportunities to combine a couple
instructions into a sbfiz.

int sbfiz32 (int x)
{
  return x << 29 >> 10;
}

long sbfiz64 (long x)
{
  return x << 58 >> 20;
}

This gets converted to the following pattern:

(set (reg:SI 98)
    (ashift:SI (sign_extend:SI (reg:HI 0 x0 [ xD.3334 ]))
        (const_int 6 [0x6])))

Currently, gcc generates the following:

sbfiz32:
  lsl x0, x0, 29
  asr x0, x0, 10
  ret

sbfiz64:
  lsl x0, x0, 58
  asr x0, x0, 20
  ret

It could generate this instead:

sbfiz32:
  sbfiz   w0, w0, 19, 3
  ret

sbfiz64::
  sbfiz   x0, x0, 38, 6
  ret

The unsigned versions already generate ubfiz for the same code, so the lack of
a sbfiz pattern may have been an oversight.

This particular sbfiz pattern shows up in both CPU2006 (~ 80 hits) and
CPU2017 (~ 280 hits). It's not a lot, but seems beneficial in any case. No
significant performance differences, probably due to the small number of
occurrences or cases outside hot areas.

gcc/ChangeLog:

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

gcc/
* config/aarch64/aarch64.md (*ashift<mode>_extv_bfiz): New pattern.

gcc/testsuite/ChangeLog:

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

gcc/testsuite/
* gcc.target/aarch64/lsl_asr_sbfiz.c: New test.

From-SVN: r260546

6 years agore PR fortran/85841 ([F2018] reject deleted features)
Janus Weil [Tue, 22 May 2018 18:22:29 +0000 (20:22 +0200)]
re PR fortran/85841 ([F2018] reject deleted features)

2018-05-22  Janus Weil  <janus@gcc.gnu.org>

PR fortran/85841
* gfortran.dg/gomp/appendix-a/a.6.1.f90: Replace dg-options by
dg-additional-options.
* gfortran.dg/graphite/block-2.f: Ditto.
* gfortran.dg/graphite/id-19.f: Ditto.
* gfortran.dg/vect/Ofast-pr50414.f90: Ditto.
* gfortran.dg/vect/cost-model-pr34445a.f: Ditto.
* gfortran.dg/vect/pr52580.f: Ditto.

From-SVN: r260544

6 years agoFix typo in a comment.
Martin Sebor [Tue, 22 May 2018 17:51:16 +0000 (17:51 +0000)]
Fix typo in a comment.

From-SVN: r260543

6 years agoPR c/85623 - strncmp() warns about attribute 'nonstring' incorrectly in -Wstringop...
Martin Sebor [Tue, 22 May 2018 17:45:35 +0000 (17:45 +0000)]
PR c/85623 - strncmp() warns about attribute 'nonstring' incorrectly in -Wstringop-overflow

gcc/ChangeLog:

PR c/85623
* calls.c (maybe_warn_nonstring_arg): Use string length to set
or ajust the presumed bound on an operation to avoid unnecessary
warnings.

gcc/testsuite/ChangeLog:

PR c/85623
* c-c++-common/attr-nonstring-3.c: Adjust.
* c-c++-common/attr-nonstring-4.c: Adjust.
* c-c++-common/attr-nonstring-6.c: New test.

From-SVN: r260541

6 years ago[AArch64, patch] Refactor of aarch64-ldpstp
Jackson Woodruff [Tue, 22 May 2018 15:37:11 +0000 (15:37 +0000)]
[AArch64, patch] Refactor of aarch64-ldpstp

This patch removes a lot of duplicated code in aarch64-ldpstp.md.

The patterns that did not previously generate a base register now
do not check for aarch64_mem_pair_operand in the pattern. This has
been extracted to a check in aarch64_operands_ok_for_ldpstp.

All patterns in the file used to have explicit switching code to
swap loads and stores that were in the wrong order.

This has been extracted into aarch64_operands_ok_for_ldpstp
as a final operation after all the checks have been performed.

2018-05-22  Jackson Woodruff  <jackson.woodruff@arm.com>
            Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* config/aarch64/aarch64-ldpstp.md: Replace uses of
aarch64_mem_pair_operand with memory_operand and delete operand swapping
code.
* config/aarch64/aarch64.c (aarch64_operands_ok_for_ldpstp):
Add check for legitimate_address.
(aarch64_gen_adjusted_ldpstp): Swap operands where appropriate.
(aarch64_swap_ldrstr_operands): New.
* config/aarch64/aarch64-protos.h (aarch64_swap_ldrstr_operands):
Define prototype.

Co-Authored-By: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
From-SVN: r260539

6 years ago[AArch64] Merge stores of D-register values with different modes
Jackson Woodruff [Tue, 22 May 2018 15:35:06 +0000 (15:35 +0000)]
[AArch64] Merge stores of D-register values with different modes

This patch merges loads and stores from D-registers that are of different modes.

Code like this:

    typedef int __attribute__((vector_size(8))) vec;
    struct pair
    {
      vec v;
      double d;
    }

Now generates a store pair instruction:

    void
    assign (struct pair *p, vec v)
    {
      p->v = v;
      p->d = 1.0;
    }

Whereas previously it generated two `str` instructions.

This patch also merges storing of double zero values with
long integer values:

    struct pair
    {
      long long l;
      double d;
    }

    void
    foo (struct pair *p)
    {
      p->l = 10;
      p->d = 0.0;
    }

Now generates a single store pair instruction rather than two `str` instructions.

The patch basically generalises the mode iterators on the patterns in aarch64.md
and the peepholes in aarch64-ldpstp.md to take all combinations of pairs of modes
so, while it may be a large-ish patch, it does fairly mechanical stuff.

2018-05-22  Jackson Woodruff  <jackson.woodruff@arm.com>
            Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* config/aarch64/aarch64.md: New patterns to generate stp
and ldp.
(store_pair_sw, store_pair_dw): New patterns to generate stp for
single words and double words.
(load_pair_sw, load_pair_dw): Likewise.
(store_pair_sf, store_pair_df, store_pair_si, store_pair_di):
Delete.
(load_pair_sf, load_pair_df, load_pair_si, load_pair_di):
Delete.
* config/aarch64/aarch64-ldpstp.md: Modify peephole
for different mode ldpstp and add peephole for merged zero stores.
Likewise for loads.
* config/aarch64/aarch64.c (aarch64_operands_ok_for_ldpstp):
Add size check.
(aarch64_gen_store_pair): Rename calls to match new patterns.
(aarch64_gen_load_pair): Rename calls to match new patterns.
* config/aarch64/aarch64-simd.md (load_pair<mode>): Rename to...
(load_pair<DREG:mode><DREG2:mode>): ... This.
(store_pair<mode>): Rename to...
(vec_store_pair<DREG:mode><DREG2:mode>): ... This.
* config/aarch64/iterators.md (DREG, DREG2, DX2, SX, SX2, DSX):
New mode iterators.
(V_INT_EQUIV): Handle SImode.
* config/aarch64/predicates.md (aarch64_reg_zero_or_fp_zero):
New predicate.

* gcc.target/aarch64/ldp_stp_6.c: New.
* gcc.target/aarch64/ldp_stp_7.c: New.
* gcc.target/aarch64/ldp_stp_8.c: New.

Co-Authored-By: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
From-SVN: r260538

6 years agoPR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on
Martin Sebor [Tue, 22 May 2018 15:22:16 +0000 (15:22 +0000)]
PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on

PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on
   a variable-length struct

gcc/ChangeLog:

PR tree-optimization/85826
* gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Avoid
assuming that a DECL necesarily has a constant size.

gcc/testsuite/ChangeLog:

PR tree-optimization/85826
* gcc.dg/Wrestrict-17.c: New test.

From-SVN: r260537

6 years agopr85862.c: Rename to...
Richard Sandiford [Tue, 22 May 2018 15:11:45 +0000 (15:11 +0000)]
pr85862.c: Rename to...

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

gcc/testsuite/
* gcc.dg/torture/pr85862.c: Rename to...
* gcc.dg/torture/pr85852.c: ...this.

From-SVN: r260536

6 years ago[Ada] Missing warning for unreferenced formals in expression functions
Justin Squirek [Tue, 22 May 2018 13:27:14 +0000 (13:27 +0000)]
[Ada] Missing warning for unreferenced formals in expression functions

This patch fixes an issue whereby the compiler failed to properly warn against
unreferenced formal parameters when analyzing expression functions.

2018-05-22  Justin Squirek  <squirek@adacore.com>

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Propagate flags from the
original function spec into the generated function spec due to
expansion of expression functions during analysis.
(Analyze_Subprogram_Body_Helper): Modify check on formal parameter
references from the body to the subprogram spec in the case of
expression functions because of inconsistances related to having a
generated body.
* libgnarl/s-osinte__android.ads: Flag parameters as unused.
* libgnarl/s-osinte__lynxos178e.ads: Likewise.
* libgnarl/s-osinte__qnx.adb: Likewise.
* libgnarl/s-osinte__qnx.ads: Likewise.

gcc/testsuite/

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

From-SVN: r260535

6 years ago[Ada] Don't define HAVE_ADJUST_CONTEXT_FOR_RAISE on VxWorks7 for AArch64
Doug Rupp [Tue, 22 May 2018 13:27:06 +0000 (13:27 +0000)]
[Ada] Don't define HAVE_ADJUST_CONTEXT_FOR_RAISE on VxWorks7 for AArch64

2018-05-22  Doug Rupp  <rupp@adacore.com>

gcc/ada/

* init.c (HAVE_ADJUST_CONTEXT_FOR_RAISE): Don't define on VxWorks7 for
AArch64.

From-SVN: r260534

6 years ago[Ada] Fix Reraise_Occurrence of Foreign_Exception
Olivier Hainque [Tue, 22 May 2018 13:27:01 +0000 (13:27 +0000)]
[Ada] Fix Reraise_Occurrence of Foreign_Exception

In a sequence like

(d)            (c)                 (b)              (a)
c++ raises <-- Ada calls c++,  <-- c++ call Ada <-- Ada calls
exception      others handler      and handles      c++
               gets foreign        c++ exception
               exception and
               re-raises

the original exception raised on the C++ world at (d) couldn't be caught
as a regular c++ exception at (b) when the re-raise performed at (c) is
done with an explicit call to Ada.Exceptions.Reraise_Occurrence.

Indeed, the latter just re-crafted a new Ada-ish occurence and the
nature and contents of the original exception object were lost.

This patch fixes this by refining Reraise_Occurrence to be more careful
with exceptions in the course of a propagation, just resuming propagation
of the original object.

From the set of soures below, compilation and execution with:

  g++ -c bd.cc && gnatmake -f -g a.adb -largs bd.o --LINK=g++ && ./a

is expected to output:

foreign exception caught, reraising ...
b() caught x = 5

----

// bd.cc

extern "C" {
  extern void c();

  void b ();
  void d ();
}

void b ()
{
  try {
    c();
  } catch (int x) {
    printf ("b() caught x = %d\n", x);
  }
}

void d ()
{
  throw (5);
}

-- a.adb

with C;
procedure A is
   procedure B;
   pragma Import (Cpp, B);
begin
   B;
end;

-- c.ads

procedure C;
pragma Export (C, C, "c");

-- c.adb

with Ada.Exceptions; use Ada.Exceptions;
with System.Standard_Library;
with Ada.Unchecked_Conversion;

with Ada.Text_IO; use Ada.Text_IO;

procedure C is
   package SSL renames System.Standard_Library;
   use type SSL.Exception_Data_Ptr;

   function To_Exception_Data_Ptr is new
     Ada.Unchecked_Conversion (Exception_Id, SSL.Exception_Data_Ptr);

   procedure D;
   pragma Import (Cpp, D);

   Foreign_Exception : aliased SSL.Exception_Data;
   pragma Import
     (Ada, Foreign_Exception, "system__exceptions__foreign_exception");
begin
   D;
exception
   when E : others =>
      if To_Exception_Data_Ptr (Exception_Identity (E))
        = Foreign_Exception'Unchecked_access
      then
         Put_Line ("foreign exception caught, reraising ...");
         Reraise_Occurrence (E);
      end if;
end;

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

gcc/ada/

* libgnat/a-except.adb (Exception_Propagation.Propagate_Exception):
Expect an Exception_Occurence object, not an Access.
(Complete_And_Propagate_Occurrence): Adjust accordingly.
(Raise_From_Signal_Handler): Likewise.
(Reraise_Occurrence_No_Defer): If we have a Machine_Occurrence
available in the provided occurrence object, just re-propagate the
latter as a bare "raise;" would do.
* libgnat/a-exexpr.adb (Propagate_Exception): Adjust to spec change.
* libgnat/a-exstat.adb (String_To_EO): Initialize X.Machine_Occurrence
to null, to mark that the occurrence we're crafting from the stream
contents is not being propagated (yet).

From-SVN: r260533

6 years ago[Ada] Crash on partial initialization of controlled component
Hristian Kirtchev [Tue, 22 May 2018 13:26:55 +0000 (13:26 +0000)]
[Ada] Crash on partial initialization of controlled component

This patch modifies the late expansion of record aggregates to ensure that the
generated code which handles a controlled component initialized by a function
call is inserted in line with the rest of the initialization code, rather than
before the record aggregate. This way the function call has proper access to
the discriminants of the object being created.

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

gcc/ada/

* exp_aggr.adb (Initialize_Ctrl_Record_Component): Insert the generated
code for a transient component in line with the rest of the
initialization code, rather than before the aggregate. This ensures
that the component has proper visibility of the discriminants.

gcc/testsuite/

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

From-SVN: r260532

6 years ago[Ada] Fix retrieval of number of CPUs on QNX
Jerome Lambourg [Tue, 22 May 2018 13:26:49 +0000 (13:26 +0000)]
[Ada] Fix retrieval of number of CPUs on QNX

Although the sysconf SC_NPROCESSORS_ONLN is also defined by the API, the
only documented way to retrieve the number of CPUs is by using the syspage.

This also better organise the QNX-specific macros in adaint.c

2018-05-22  Jerome Lambourg  <lambourg@adacore.com>

gcc/ada/

* adaint.c: Reorganize QNX-specific macros, use syspage to retreive the
number of CPUs.

From-SVN: r260531

6 years ago[Ada] Fix the signal trampoline on QNX
Jerome Lambourg [Tue, 22 May 2018 13:26:33 +0000 (13:26 +0000)]
[Ada] Fix the signal trampoline on QNX

The trampoline now properly restores the link register as well as the stack
pointer. As a minor optimisation, now only callee-saved registers are
restored: the scratch registers don't need that.

2018-05-22  Jerome Lambourg  <lambourg@adacore.com>

gcc/ada/

* sigtramp-qnx.c: Properly restore link register in signal trampoline.

From-SVN: r260530

6 years ago[Ada] In-place initialization for Initialize_Scalars
Hristian Kirtchev [Tue, 22 May 2018 13:26:28 +0000 (13:26 +0000)]
[Ada] In-place initialization for Initialize_Scalars

This patch optimizes the initialization and allocation of scalar array objects
when pragma Initialize_Scalars is in effect. The patch also extends the syntax
and semantics of pragma Initialize_Scalars to allow for the specification of
invalid values pertaining to families of scalar types. The new syntax is as
follows:

   pragma Initialize_Scalars
     [ ( TYPE_VALUE_PAIR {, TYPE_VALUE_PAIR} ) ];

   TYPE_VALUE_PAIR ::=
     SCALAR_TYPE => static_EXPRESSION

   SCALAR_TYPE :=
     Short_Float
   | Float
   | Long_Float
   | Long_Long_Flat
   | Signed_8
   | Signed_16
   | Signed_32
   | Signed_64
   | Unsigned_8
   | Unsigned_16
   | Unsigned_32
   | Unsigned_64

Depending on the value specified by pragma Initialize_Scalars, the backend may
optimize the creation of the scalar array object into a fast memset.

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

--  gnat.adc

pragma Initialize_Scalars
  (Short_Float     => 0.0,
   Float           => 0.0,
   Long_Float      => 0.0,
   Long_Long_Float => 0.0,
   Signed_8        => 0,
   Signed_16       => 0,
   Signed_32       => 0,
   Signed_64       => 0,
   Unsigned_8      => 0,
   Unsigned_16     => 0,
   Unsigned_32     => 0,
   Unsigned_64     => 0);

--  types.ads

with System;

package Types is
   Max : constant := 10_000;
   subtype Big is Integer range 1 .. Max;

   type Byte is range 0 .. 255;
   for Byte'Size use System.Storage_Unit;

   type Byte_Arr_1 is array (1 .. Max) of Byte;
   type Byte_Arr_2 is array (Big) of Byte;
   type Byte_Arr_3 is array (Integer range <>) of Byte;
   type Byte_Arr_4 is array (Integer range <>,
                             Integer range <>) of Byte;
   type Constr_Arr_1 is array (1 .. Max) of Integer;
   type Constr_Arr_2 is array (Big) of Integer;
   type Constr_Arr_3 is array (1 .. Max, 1 .. Max) of Integer;
   type Constr_Arr_4 is array (Big, Big) of Integer;

   type Unconstr_Arr_1 is array (Integer range <>) of Integer;
   type Unconstr_Arr_2 is array (Integer range <>,
                                 Integer range <>) of Integer;

   subtype Subt_Arr_1 is Unconstr_Arr_1 (1 .. Max);
   subtype Subt_Arr_2 is Unconstr_Arr_1 (Big);
   subtype Subt_Arr_3 is Unconstr_Arr_2 (1 .. Max, 1 .. Max);
   subtype Subt_Arr_4 is Unconstr_Arr_2 (Big, Big);

   subtype Subt_Str_1 is String (1 .. Max);
   subtype Subt_Str_2 is String (Big);

   type Byte_Arr_1_Ptr     is access Byte_Arr_1;
   type Byte_Arr_2_Ptr     is access Byte_Arr_2;
   type Byte_Arr_3_Ptr     is access Byte_Arr_3;
   type Byte_Arr_4_Ptr     is access Byte_Arr_4;
   type Constr_Arr_1_Ptr   is access Constr_Arr_1;
   type Constr_Arr_2_Ptr   is access Constr_Arr_2;
   type Constr_Arr_3_Ptr   is access Constr_Arr_3;
   type Constr_Arr_4_Ptr   is access Constr_Arr_4;
   type Unconstr_Arr_1_Ptr is access Unconstr_Arr_1;
   type Unconstr_Arr_2_Ptr is access Unconstr_Arr_2;
   type Subt_Arr_1_Ptr     is access Subt_Arr_1;
   type Subt_Arr_2_Ptr     is access Subt_Arr_2;
   type Subt_Arr_3_Ptr     is access Subt_Arr_3;
   type Subt_Arr_4_Ptr     is access Subt_Arr_4;
   type Str_Ptr            is access String;
   type Subt_Str_1_Ptr     is access Subt_Str_1;
   type Subt_Str_2_Ptr     is access Subt_Str_2;
end Types;

--  main.adb

with Types; use Types;

procedure Main is
   Byte_Arr_1_Obj     : Byte_Arr_1;
   Byte_Arr_2_Obj     : Byte_Arr_2;
   Byte_Arr_3_Obj     : Byte_Arr_3 (1 .. Max);
   Byte_Arr_4_Obj     : Byte_Arr_3 (Big);
   Byte_Arr_5_Obj     : Byte_Arr_4 (1 .. Max, 1 .. Max);
   Byte_Arr_6_Obj     : Byte_Arr_4 (Big, Big);
   Constr_Arr_1_Obj   : Constr_Arr_1;
   Constr_Arr_2_Obj   : Constr_Arr_2;
   Constr_Arr_3_Obj   : Constr_Arr_3;
   Constr_Arr_4_Obj   : Constr_Arr_4;
   Unconstr_Arr_1_Obj : Unconstr_Arr_1 (1 .. Max);
   Unconstr_Arr_2_Obj : Unconstr_Arr_1 (Big);
   Unconstr_Arr_3_Obj : Unconstr_Arr_2 (1 .. Max, 1 .. Max);
   Unconstr_Arr_4_Obj : Unconstr_Arr_2 (Big, Big);
   Subt_Arr_1_Obj     : Subt_Arr_1;
   Subt_Arr_2_Obj     : Subt_Arr_2;
   Subt_Arr_3_Obj     : Subt_Arr_3;
   Subt_Arr_4_Obj     : Subt_Arr_4;
   Str_1_Obj          : String (1 .. Max);
   Str_2_Obj          : String (Big);
   Subt_Str_1_Obj     : Subt_Str_1;
   Subt_Str_2_Obj     : Subt_Str_2;

   Byte_Arr_1_Ptr_Obj     : Byte_Arr_1_Ptr     := new Byte_Arr_1;
   Byte_Arr_2_Ptr_Obj     : Byte_Arr_2_Ptr     := new Byte_Arr_2;
   Byte_Arr_3_Ptr_Obj     : Byte_Arr_3_Ptr     := new Byte_Arr_3 (1 .. Max);
   Byte_Arr_4_Ptr_Obj     : Byte_Arr_3_Ptr     := new Byte_Arr_3 (Big);
   Byte_Arr_5_Ptr_Obj     : Byte_Arr_4_Ptr     :=
                              new Byte_Arr_4 (1 .. Max, 1 .. Max);
   Byte_Arr_6_Ptr_Obj     : Byte_Arr_4_Ptr     := new Byte_Arr_4 (Big, Big);
   Constr_Arr_1_Ptr_Obj   : Constr_Arr_1_Ptr   := new Constr_Arr_1;
   Constr_Arr_2_Ptr_Obj   : Constr_Arr_2_Ptr   := new Constr_Arr_2;
   Constr_Arr_3_Ptr_Obj   : Constr_Arr_3_Ptr   := new Constr_Arr_3;
   Constr_Arr_4_Ptr_Obj   : Constr_Arr_4_Ptr   := new Constr_Arr_4;
   Unconstr_Arr_1_Ptr_Obj : Unconstr_Arr_1_Ptr :=
                              new Unconstr_Arr_1 (1 .. Max);
   Unconstr_Arr_2_Ptr_Obj : Unconstr_Arr_1_Ptr := new Unconstr_Arr_1 (Big);
   Unconstr_Arr_3_Ptr_Obj : Unconstr_Arr_2_Ptr :=
                              new Unconstr_Arr_2 (1 .. Max, 1 .. Max);
   Unconstr_Arr_4_Ptr_Obj : Unconstr_Arr_2_Ptr :=
                              new Unconstr_Arr_2 (Big, Big);
   Subt_Arr_1_Ptr_Obj     : Subt_Arr_1_Ptr     := new Subt_Arr_1;
   Subt_Arr_2_Ptr_Obj     : Subt_Arr_2_Ptr     := new Subt_Arr_2;
   Subt_Arr_3_Ptr_Obj     : Subt_Arr_3_Ptr     := new Subt_Arr_3;
   Subt_Arr_4_Ptr_Obj     : Subt_Arr_4_Ptr     := new Subt_Arr_4;
   Str_Ptr_1_Obj          : Str_Ptr            := new String (1 .. Max);
   Str_Ptr_2_Obj          : Str_Ptr            := new String (Big);
   Subt_Str_1_Ptr_Obj     : Subt_Str_1_Ptr     := new Subt_Str_1;
   Subt_Str_2_Ptr_Obj     : Subt_Str_2_Ptr     := new Subt_Str_2;
begin null; end Main;

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

$ gcc -c -S -gnatDG -gnatws main.adb
$ grep -c "others => types__TbyteB!(0));" main.adb.dg
$ grep -c "others => integer!(0));" main.adb.dg
$ grep -c "others => character!(0));" main.adb.dg
$ grep -c "others => types__TbyteB!(0));" main.adb.dg
$ grep -c "memset" main.s
8
12
8
8
44

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

gcc/ada/

* exp_aggr.adb (Aggr_Assignment_OK_For_Backend): Strip away any
conversions before extracting the value of the expression.
* exp_ch3.adb (Default_Initialize_Object): Optimize the default
initialization of an array of scalars.
(Get_Simple_Init_Val): Add processing for array types. Remove the
processing of strings because this case is already handled by the array
case.
(Needs_Simple_Initialization): Moved to Sem_Util.
(Simple_Init_Array_Type): New routine.
(Simple_Init_Initialize_Scalars_Type): Reimplemented to use the new
facilities from Sem_Util.
(Simple_Initialization_OK): New routine.
* exp_ch3.ads (Needs_Simple_Initialization): Moved to Sem_Util.
* exp_ch4.adb (Expand_N_Allocator): Optimize the default allocation of
an array of scalars.
* sem_prag.adb (Analyze_Float_Value): New routine.
(Analyze_Integer_Value): New routine.
(Analyze_Pragma): Reimplement the analysis of pragma Initialize_Scalars
to handled the extended form of the pragma.
(Analyze_Type_Value_Pair): New routine.
* sem_util.adb: Add invalid value-related data structures.
(Examine_Array_Bounds): New routine.
(Has_Static_Array_Bounds): Reimplemented.
(Has_Static_Non_Empty_Array_Bounds): New routine.
(Invalid_Scalar_Value): New routine.
(Needs_Simple_Initialization): Moved from Exp_Ch3.
(Set_Invalid_Scalar_Value): New routines.
* sem_util.ads (Has_Static_Non_Empty_Array_Bounds): New routine.
(Invalid_Scalar_Value): New routine.
(Needs_Simple_Initialization): Moved from Exp_Ch3.
(Set_Invalid_Scalar_Value): New routines.
* snames.ads-tmpl: Add names for the salar type families used by pragma
Initialize_Scalars.

From-SVN: r260529

6 years ago[Ada] Disable name generation for External_Tag and Expanded_Name
Javier Miranda [Tue, 22 May 2018 13:26:23 +0000 (13:26 +0000)]
[Ada] Disable name generation for External_Tag and Expanded_Name

In order to avoid exposing internal names of tagged types in the
binary code generated by the compiler this enhancement facilitates
initializes the External_Tag of a tagged type with an empty string
when pragma No_Tagged_Streams is applicable to the tagged type, and
facilitates initializes its Expanded_Name with an empty string when
pragma Discard_Names is applicable to the tagged type.

This enhancement can be verified by means of the following small
test:

package Library_Level_Test is
   type Typ_01 is tagged null record;    --  Case 1: No pragmas

   type Typ_02 is tagged null record;    --  Case 2: Discard_Names
   pragma Discard_Names (Typ_02);

   pragma No_Tagged_Streams;
   type Typ_03 is tagged null record;    --  Case 3: No_Tagged_Streams

   type Typ_04 is tagged null record;    --  Case 4: Both pragmas
   pragma Discard_Names (Typ_04);
end;

Commands:
  gcc -c -gnatD library_level_test.ads
  grep "\.TYP_" library_level_test.ads.dg

Output:
     "LIBRARY_LEVEL_TEST.TYP_01["00"]";
     "LIBRARY_LEVEL_TEST.TYP_02["00"]";
     "LIBRARY_LEVEL_TEST.TYP_03["00"]";

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

gcc/ada/

* exp_disp.adb (Make_DT): Initialize the External_Tag with an empty
string when pragma No_Tagged_Streams is applicable to the tagged type,
and initialize the Expanded_Name with an empty string when pragma
Discard_Names is applicable to the tagged type.

From-SVN: r260528

6 years ago[Ada] Better error message on illegal 'Access on formal subprogram
Ed Schonberg [Tue, 22 May 2018 13:26:17 +0000 (13:26 +0000)]
[Ada] Better error message on illegal 'Access on formal subprogram

This patch improves on the error message for an attempt to apply 'Access
to a formal subprogram. It also applies the check to a renaming of a formal
subprogram.

Compiling p.adb must yield:

p.adb:15:18: not subtype conformant with declaration at line 2
p.adb:15:18: formal subprograms are not subtype conformant (RM 6.3.1 (17/3))
p.adb:16:18: not subtype conformant with declaration at line 2
p.adb:16:18: formal subprograms are not subtype conformant (RM 6.3.1 (17/3))

----
package body P is
  procedure Non_Generic (P : access procedure (I : Integer)) is
  begin
    P.all (5);
  end Non_Generic;

  procedure G is
    procedure Local (I : Integer) is
    begin
      Action (I);
    end;
    procedure Local_Action (I : Integer) renames Action;
  begin
    Non_Generic (Local'access);
    Non_Generic (Local_Action'access);
    Non_Generic (Action'access);
    -- p.adb:15:18: not subtype conformant with declaration at line 2
    -- p.adb:15:18: formal subprograms not allowed
  end G;
end P;
----
package P is
  generic
    with procedure Action (I : Integer);
  procedure G;
end P;

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

gcc/ada/

* sem_ch6.adb (Check_Conformance): Add RM reference for rule that a
formal subprogram is never subtype conformqnt, and thus cannot be the
prefix of 'Access.  Reject as well the attribute when applied to a
renaming of a formal subprogram.

From-SVN: r260527

6 years ago[Ada] In-place initialization for Initialize_Scalars
Hristian Kirtchev [Tue, 22 May 2018 13:26:11 +0000 (13:26 +0000)]
[Ada] In-place initialization for Initialize_Scalars

This patch cleans up the implementation of routine Get_Simple_Init_Val. It also
eliminates potentially large and unnecessary tree replications in the context
of object default initialization.

No change in behavior, no test needed.

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

gcc/ada/

* exp_ch3.adb (Build_Array_Init_Proc): Update the call to
Needs_Simple_Initialization.
(Build_Init_Statements): Update the call to Get_Simple_Init_Val.
(Check_Subtype_Bounds): Renamed to Extract_Subtype_Bounds. Update the
profile and comment on usage.
(Default_Initialize_Object): Do not use New_Copy_Tree to set the proper
Sloc of a value obtained from aspect Default_Value because this could
potentially replicate large trees. The proper Sloc is now set in
Get_Simple_Init_Val.
(Get_Simple_Init_Val): Reorganized by breaking the various cases into
separate routines. Eliminate the use of global variables.
(Init_Component): Update the call to Get_Simple_Init_Val.
(Needs_Simple_Initialization): Update the parameter profile and all
uses of T.
(Simple_Init_Defaulted_Type): Copy the value of aspect Default_Value
and set the proper Sloc.
* exp_ch3.ads (Get_Simple_Init_Val): Update the parameter profile and
comment on usage.
(Needs_Simple_Initialization): Update the parameter profile.

From-SVN: r260526

6 years ago[Ada] Fix compiler abort on invalid discriminant constraint
Patrick Bernardi [Tue, 22 May 2018 13:26:05 +0000 (13:26 +0000)]
[Ada] Fix compiler abort on invalid discriminant constraint

This patch fixes a compiler abort on a discriminant constraint when the
constraint is a subtype indication.

2018-05-22  Patrick Bernardi  <bernardi@adacore.com>

gcc/ada/

* sem_ch3.adb (Build_Discriminant_Constraints): Raise an error if the
user tries to use a subtype indication as a discriminant constraint.

gcc/testsuite/

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

From-SVN: r260525

6 years ago[Ada] Ada2020: Reduction expressions
Ed Schonberg [Tue, 22 May 2018 13:25:22 +0000 (13:25 +0000)]
[Ada] Ada2020: Reduction expressions

This patch dismantles the prototype implementation of the first proposal
for Reduction expressions, one of the important potentially parallel
constructs for Ada2020. The ARG is going in a different direction with
a simpler syntax.

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

gcc/ada/

* exp_ch4.ads, exp_ch4.adb, exp_util.adb, expander.adb: Remove mention
of N_Reduction_Expression and N_Reduction_Expression_Parameter.
* par-ch4.adb: Remove parsing routines for reduction expressions.
* sem.adb, sinfo.ads, sinfo.adb, sem_ch4.ads, sem_ch4.adb, sem_res.adb,
sem_spark.adb, sprint.adb: Remove analysis routines for reduction
expressions.

From-SVN: r260524