H.J. Lu [Thu, 24 May 2018 19:52:32 +0000 (19:52 +0000)]
libsanitizer: Use pre-computed size of struct ustat for Linux
Cherry-pick compiler-rt revision 333213:
<sys/ustat.h> has been removed from glibc 2.28 by:
commit
cf2478d53ad7071e84c724a986b56fe17f4f4ca7
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Sun Mar 18 11:28:59 2018 +0800
Deprecate ustat syscall interface
This patch uses pre-computed size of struct ustat for Linux.
PR sanitizer/85835
* sanitizer_common/sanitizer_platform_limits_posix.cc: Don't
include <sys/ustat.h> for Linux.
(SIZEOF_STRUCT_USTAT): New.
(struct_ustat_sz): Use SIZEOF_STRUCT_USTAT for Linux.
From-SVN: r260684
H.J. Lu [Thu, 24 May 2018 19:51:09 +0000 (19:51 +0000)]
Check ifunc_resolver only on FUNCTION_DECL
Since ifunc_resolver is only valid on FUNCTION_DECL, check ifunc_resolver
only on FUNCTION_DECL.
PR target/85900
PR target/85345
* varasm.c (assemble_alias): Check ifunc_resolver only on
FUNCTION_DECL.
From-SVN: r260683
Ville Voutilainen [Thu, 24 May 2018 19:05:46 +0000 (22:05 +0300)]
Pedwarn on a non-standard position of a C++ attribute.
From-SVN: r260682
Uros Bizjak [Thu, 24 May 2018 18:16:29 +0000 (20:16 +0200)]
re PR target/85903 (FAIL: gcc.target/i386/avx512dq-vcvtuqq2pd-2.c)
PR target/85903
* config/i386/sse.md (movdi_to_sse): Do not generate pseudo
when memory input operand is handled.
From-SVN: r260681
Maya Rashish [Thu, 24 May 2018 17:31:13 +0000 (17:31 +0000)]
PR target/85904 check for aligned_alloc on netbsd cross-compilation
2018-05-24 Maya Rashish <coypu@sdf.org>
PR target/85904
* crossconfig.m4: Test for aligned_alloc on netbsd.
* configure: Regenerate.
From-SVN: r260678
Paolo Carlini [Thu, 24 May 2018 17:20:01 +0000 (17:20 +0000)]
cp-tree.h (INDIRECT_TYPE_P): New.
2018-05-24 Paolo Carlini <paolo.carlini@oracle.com>
* cp-tree.h (INDIRECT_TYPE_P): New.
* call.c (build_trivial_dtor_call, maybe_warn_class_memaccess,
joust): Use it instead of POINTER_TYPE_P.
* class.c (update_vtable_entry_for_fn, find_flexarrays,
* fixed_type_or_null, resolves_to_fixed_type_p): Likewise.
* constexpr.c (cxx_eval_binary_expression, cxx_fold_indirect_ref,
* cxx_eval_increment_expression, potential_constant_expression_1):
Likewise.
* cp-gimplify.c (cp_gimplify_expr, cp_genericize_r): Likewise.
* cp-objcp-common.c (cxx_get_alias_set): Likewise.
* cp-ubsan.c (cp_ubsan_maybe_instrument_member_call,
cp_ubsan_maybe_instrument_downcast): Likewise.
* cvt.c (cp_convert_to_pointer, ocp_convert,
cp_get_fndecl_from_callee, maybe_warn_nodiscard, convert): Likewise.
* cxx-pretty-print.c (cxx_pretty_printer::abstract_declarator,
pp_cxx_offsetof_expression_1): Likewise.
* decl.c (grokparms, static_fn_type): Likewise.
* decl2.c (grokbitfield): Likewise.
* error.c (dump_expr): Likewise.
* except.c (initialize_handler_parm, check_noexcept_r): Likewise.
* init.c (warn_placement_new_too_small): Likewise.
* lambda.c (build_capture_proxy, add_capture): Likewise.
* parser.c (cp_parser_omp_for_loop): Likewise.
* pt.c (convert_nontype_argument, fn_type_unification,
uses_deducible_template_parms, check_cv_quals_for_unify,
dependent_type_p_r): Likewise.
* search.c (check_final_overrider): Likewise.
* semantics.c (handle_omp_array_sections, finish_omp_clauses,
finish_omp_for): Likewise.
* tree.c (cp_build_qualified_type_real): Likewise.
* typeck.c (build_class_member_access_expr,
finish_class_member_access_expr, build_x_indirect_ref,
cp_build_indirect_ref_1, cp_build_binary_op, build_const_cast_1):
Likewise.
From-SVN: r260677
Jonathan Wakely [Thu, 24 May 2018 15:28:26 +0000 (16:28 +0100)]
Implement P0558R2 changes to std::atomic
The restrictions forbidding arithmetic on atomic pointer types are only
enabled for C++17 and later, retaining the GNU extension for older
standards. The new nested typedefs and changes to prevent scalar
parameters participating in template argument deduction are enabled
unconditionally.
PR libstdc++/69769
PR libstdc++/85886
* include/bits/atomic_base.h (__atomic_base::value_type)
(__atomic_base::difference_type): Add new typedefs.
* include/std/atomic (atomic<bool>::value_type, atomic<T>::value_type)
(atomic<T*>::value_type, atomic<T*>::difference_type): Likewise.
(atomic<T*>::operator++, atomic<T*>::operator--)
(atomic<T*>::operator+=, atomic<T*>::operator-=)
(atomic<T*>::fetch_add, atomic<T*>::fetch_sub): Add static assertion
to enforce C++17 requirement on pointer arithmetic.
(__atomic_val_t, __atomic_diff_t): New alias templates.
(atomic_init, atomic_store_explicit, atomic_exchange_explicit)
(atomic_compare_exchange_weak_explicit)
(atomic_compare_exchange_strong_explicit, atomic_store)
(atomic_exchange, atomic_compare_exchange_weak)
(atomic_compare_exchange_strong): Use __atomic_val_t to make
scalar parameters be non-deduced contexts.
(atomic_fetch_add_explicit, atomic_fetch_sub_explicit)
(atomic_fetch_add, atomic_fetch_sub): Change first parameter to be
atomic instead of __atomic_base, and use __atomic_diff_t for scalar
parameters.
(atomic_fetch_and_explicit, atomic_fetch_or_explicit)
(atomic_fetch_xor_explicit, atomic_fetch_and, atomic_fetch_or)
(atomic_fetch_xor): Use __atomic_val_t for scalar parameters.
(atomic_fetch_add_explicit, atomic_fetch_sub_explicit)
(atomic_fetch_add, atomic_fetch_sub): Remove overloads for atomic
address types.
* testsuite/29_atomics/atomic/60695.cc: Adjust dg-error lineno.
* testsuite/29_atomics/atomic/69769.cc: New test.
* testsuite/29_atomics/atomic/nonmembers.cc: New test.
* testsuite/29_atomics/atomic/operators/pointer_partial_void.cc:
Disable test for C++17 and later.
* testsuite/29_atomics/atomic/requirements/typedefs.cc: New test.
* testsuite/29_atomics/atomic_integral/nonmembers.cc: New test.
* testsuite/29_atomics/atomic_integral/requirements/typedefs.cc: New
test.
From-SVN: r260676
Luis Machado [Thu, 24 May 2018 14:37:21 +0000 (14:37 +0000)]
[AArch64, Falkor] Falkor address costs tuning
Switch from using generic address costs to using Falkor-specific ones, which
give Falkor better results overall.
gcc/ChangeLog:
2018-05-24 Luis Machado <luis.machado@linaro.org>
* config/aarch64/aarch64.c (qdf24xx_addrcost_table): New static
global.
(qdf24xx_tunings) <addr_costs>: Set to qdf24xx_addrcost_table.
From-SVN: r260675
Jason Merrill [Thu, 24 May 2018 14:27:10 +0000 (10:27 -0400)]
PR c++/85864 - literal template and default template arg.
* pt.c (instantiation_dependent_r): Handle NONTYPE_ARGUMENT_PACK.
From-SVN: r260672
Marek Polacek [Thu, 24 May 2018 13:36:21 +0000 (13:36 +0000)]
re PR c++/85847 (unexpected expression of kind template_id_expr)
PR c++/85847
* init.c (build_new_1): Use fold_non_dependent_expr. Use a dedicated
variable for its result. Fix a condition.
(build_new): Use fold_non_dependent_expr. Tweak a condition.
* g++.dg/cpp0x/new3.C: New test.
From-SVN: r260671
Piotr Trojanek [Thu, 24 May 2018 13:07:11 +0000 (13:07 +0000)]
[Ada] Simplify routines with a local Result variable
Local variable Result that is modified inside IF statements makes a seemingly
trivial code slightly hard to understand. This patch rewrites such a pattern.
Semantics unaffected.
2018-05-24 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sem_elab.adb (Non_Private_View): Simplify by removing a local Result
variable.
* sem_prag.adb (Get_Base_Subprogram): Same as above.
From-SVN: r260670
Eric Botcazou [Thu, 24 May 2018 13:07:06 +0000 (13:07 +0000)]
[Ada] Fix irregular output with -gnatR3
This fixes a long-standing quirk present in the layout information for record
types displayed by the -gnatR3 switch: when a component has a variable
(starting) position, its corresponding line in the output has an irregular and
awkward format. After this change, the format is the same as in all the other
cases.
For the following record:
type R (m : natural) is record
s : string (1 .. m);
r : natural;
b : boolean;
end record;
for R'alignment use 4;
pragma Pack (R);
the output of -gnatR3 used to be:
for R'Object_Size use
17179869248;
for R'Value_Size use ((#1 + 8) * 8);
for R'Alignment use 4;
for R use record
m at 0 range 0 .. 30;
s at 4 range 0 .. ((#1 * 8)) - 1;
r at bit offset (((#1 + 4) * 8)) size in bits = 31
b at bit offset ((((#1 + 7) * 8) + 7)) size in bits = 1
end record;
and is changed into:
for R'Object_Size use
17179869248;
for R'Value_Size use ((#1 + 8) * 8);
for R'Alignment use 4;
for R use record
m at 0 range 0 .. 30;
s at 4 range 0 .. ((#1 * 8)) - 1;
r at (#1 + 4) range 0 .. 30;
b at (#1 + 7) range 7 .. 7;
end record;
2018-05-24 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* fe.h (Set_Normalized_First_Bit): Declare.
(Set_Normalized_Position): Likewise.
* repinfo.adb (List_Record_Layout): Do not use irregular output for a
variable position. Fix minor spacing issue.
* gcc-interface/decl.c (annotate_rep): If a field has a variable
offset, compute the normalized position and annotate it in addition to
the bit offset.
From-SVN: r260669
Eric Botcazou [Thu, 24 May 2018 13:07:00 +0000 (13:07 +0000)]
[Ada] Minor clean-ups in gigi
2018-05-24 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu):
Constify and rename variables. Fix formatting.
(gnat_to_gnu) <N_Exception_Handler>: Minor tweak.
<N_Raise_Statement>: Likewise.
From-SVN: r260668
Javier Miranda [Thu, 24 May 2018 13:06:47 +0000 (13:06 +0000)]
[Ada] Wrong renaming of variant record equality
For a renaming of the equality operator of a variant record the compiler
erroneously generates code that compares all the record component (thus
computing wrong results).
After this patch the following test provides the correct results.
package Types is
type Data (Bool : Boolean := False) is record
case Bool is
when False =>
null;
when True =>
Val1 : Integer range 0 .. 2 ** 23 - 1;
Val2 : Float;
end case;
end record;
function IsEqual (Left, Right : Data) return Boolean renames "=";
end Types;
with Types;
with Ada.Text_IO;
procedure Main is
A : Types.Data := Types.Data'(Bool => True,
Val1 => 16#05A5A5#,
Val2 =>
999999999.0);
B : Types.Data := Types.Data'(Bool => True,
Val1 => 16#0A5A5A#,
Val2 =>
6666666666.0);
use type Types.Data;
begin
A := (Bool => False); -- Test
B := (Bool => False); -- Test
if Types.IsEqual (A, B) then -- Test
Ada.Text_IO.Put_Line ("OK");
else
Ada.Text_IO.Put_Line ("ERROR");
end if;
end Main;
Command: gnatmake main; ./main
Output: OK
2018-05-24 Javier Miranda <miranda@adacore.com>
gcc/ada/
* exp_ch8.adb (Build_Body_For_Renaming): Adding support to build the
body of a variant record equality renaming.
(Expand_N_Subprogram_Renaming_Declaration): Adapt the code to the new
implementation of Build_Body_For_Renaming.
* exp_ch3.ads (Build_Variant_Record_Equality): New library level
function that factorizes the functionality needed by
Build_Body_For_Renaming and Expand_Freeze_Record_Type to build the body
of a variant record equality subprogram.
* exp_ch3.adb (Build_Variant_Record_Equality): New subprogram.
(Build_Variant_Record_Equality): New local procedure of
Expand_Freeze_Record_Type containing all the code specific for freezing
the record type that cannot be place in the new library level function.
From-SVN: r260667
Ed Schonberg [Thu, 24 May 2018 13:06:40 +0000 (13:06 +0000)]
[Ada] Add a new Is_Activation_Record flag on IN parameters
2018-05-24 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* einfo.ads, einfo.adb (Is_Activation_Record): New flag on
in_parameters, used when unesting subprograms for LLVM, to indicate
that a generated parameter carries the activation record from the
enclosing subprogram.
* exp_unst.adb (Check_Static_Type): Handle array attributes of types
whose bounds may contain up-level references that need to be added to
an activation recoord.
(Add_Extra_Formal): Set Is_Activation_Record on new formal.
From-SVN: r260666
Yannick Moy [Thu, 24 May 2018 13:06:34 +0000 (13:06 +0000)]
[Ada] Improve GNATprove messages on unproved checks
GNATprove messages may point out to part of an assertion as not being proved,
and in such a case it displays the sub-expression. This code relies on
Pprint.Expression_Image, which is improved here to display better some kinds of
expressions.
There is no impact on compilation.
2018-05-24 Yannick Moy <moy@adacore.com>
gcc/ada/
* pprint.adb (Expression_Image): Improve the printing of expressions,
by taking more cases into account, in particular qualified expressions
and aggregates. Also count more the number of parentheses to close
after the expression.
From-SVN: r260665
Javier Miranda [Thu, 24 May 2018 13:06:28 +0000 (13:06 +0000)]
[Ada] Missing error on illegal access to discriminant
The compiler does not report an error on the illegal access to a renamed
discriminant when the actual object is a parameter of a subprogram.
2018-05-24 Javier Miranda <miranda@adacore.com>
gcc/ada/
* sem_ch3.adb (Is_Visible_Component): For untagged types add missing
check for renamed discriminants.
* sem_ch4.adb (Analyze_Overloaded_Selected_Component,
Analyze_Selected_Component, Check_Misspelled_Selector): For calls to
Is_Visible_Component pass the associated selector node to allow
checking renamed discriminants on untagged types.
gcc/testsuite/
* gnat.dg/discr52.adb: New testcase.
From-SVN: r260664
Ed Schonberg [Thu, 24 May 2018 13:06:21 +0000 (13:06 +0000)]
[Ada] Infinite loop in the compiler when warning on redundant constructs
This patch fixes an infinite loop in the compiler when warnings on redundant
constructs are enabled (-gnatwr) and the constructs are use_type clauses
that appear (redundantly) in a parent unit and a child unit.
The following command:
gcc -c -gnatwr root-child.ads
must yield:
root-child.ads:2:01: warning: "Pack.Typ" is already use-visible through
previous use_type_clause at root.ads:2
The following must compile quietly:
gcc -c -gnatwr root-child-grand.ads
----
package Pack is
type Typ is new Integer;
end Pack;
----
with Pack;
use type Pack.Typ;
package Root is
Thing1 : Pack.Typ;
end Root;
----
with pack;
use type pack.typ;
package Root.Child is
Thing2 : Pack.Typ := Root.Thing1 * 3;
end;
----
with Pack;
use type Pack.Typ;
package Root.Child.Grand is
Thing3 : Pack.Typ := Thing1 + Thing2;
end;
2018-05-24 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch8.adb (Analyze_Use_Type): Do not assign the Prev_Use_Clause
link to a use_type clause if this would cause an infinite loop in the
machinery that detects redundant use clauses. This may happen when the
redundant clauses appear in the context of a child unit and the context
of its parent.
From-SVN: r260663
Piotr Trojanek [Thu, 24 May 2018 13:06:16 +0000 (13:06 +0000)]
[Ada] Minor fix grammar in comment of N_Defining_Identifier
2018-05-24 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sinfo.ads: Fix grammar in comment.
From-SVN: r260662
Justin Squirek [Thu, 24 May 2018 13:06:11 +0000 (13:06 +0000)]
[Ada] Quadratic compile time with tagged types
This patch is an incremental commit which focuses on the optimization of entity
chain navigation by adding an additional field (Prev_Entity) to all nodes in
order to greaty speed up compilation of sources making heavy use of tagged
derivations by effectly making the entity chain from a singly-linked list into
a doubly-linked one.
This is only a performance improvement: no compilation result change
expected.
2018-05-24 Justin Squirek <squirek@adacore.com>
gcc/ada/
* einfo.ads, einfo.adb (Append_Entity): Modified to use Link_Entities
and manage doubly-linked entity chain.
(Nested_Scenarios): Removed entity field used for optimization during
elaboration to make room for the new field Prev_Entity.
(Link_Entities): Added to replace redundant calls to Set_Next_Entity
and Set_Prev_Entity as well as centralize changes to the entity chain.
(Predicated_Parent): Modified to use Node38.
(Prev_Entity): Added to fetch new node field Prev_Entity in all entity
types.
(Remove_Entity): Moved from sem_util.
(Set_Nested_Scenarios): Deleted.
(Set_Predicated_Parent): Modified to use Node38.
(Set_Prev_Entity): Added to set Prev_Entity field.
(Set_Validated_Object): Modified to use Node38.
(Unlink_Next_Entity): Added to process Prev_Entity when an unlinking
action is required.
(Validated_Object): Modified to use Node38.
(Write_Field36_Name): Remove Nested_Scenarios, Validated_Object, and
predicated parent cases.
(Write_Field38_Name): Add predicated parent and Validated_Object cases.
* sem_ch3.adb (Process_Subtype): Add guard to protect against
inappropriate marking of Predicated_Parent to non-itype subtypes.
(Make_Class_Wide_Type): Preserve Prev_Entity field and set in new type.
(Copy_And_Swap): Add setting of Prev_Entity.
(Build_derived_Record_Type): Replace Set_Next_Entity w/ Link_Entities.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Replace Set_Next_Entity
w/ Link_Entities.
(New_Overloaded_Entity): Remove block created to search for previous
entities in the entity chain with relevant calls to Prev_Entity as well
as replace duplicated code from Remove_Entity_And_Homonym with a call
to that subprogram.
* sem_ch7.adb (Exchange_Declarations): Replace Set_Next_Entity w/
Link_Entities.
* sem_elab.adb (Find_And_Process_Nested_Scenarios): Remove global and
initial subprogram declarations related to Nested_Scenarios.
(Process_Nested_Scenarios): Deleted.
(Save_Scenario): Deleted.
(Traverse_Body): Remove optimization for Nested_Scenarios so as to free
node space in the entity tree.
* sem_util.adb, sem_util.ads (Remove_Entity): Moved to einfo.
(Remove_Entity_And_Homonym): Added to separate functionality of
Remove_Entity from the homonym chain directly.
* exp_attr.adb (Expand_N_Attribute_Reference): Replace Set_Next_Entity
w/ Link_Entities and Unlink_Next_Entity.
* exp_ch3.adb (Expand_N_Object_Declaration): Replace Set_Next_Entity w/
Link_Entities.
* exp_ch6.adb (Replace_Renaming_Declaration_Id): Replace
Set_Next_Entity w/ Link_Entities.
* exp_disp.adb (Expand_Dispatching_Call): Replace Set_Next_Entity w/
Link_Entities and Unlink_Next_Entity.
* exp_spark.adb (Expand_SPARK_N_Object_Renaming_Declaration): Replace
call to Remove_Entity with its new incarnation.
* exp_util.adb (New_Class_Wide_Subtype): Add setting of Prev_Entity.
* freeze.adb (Freeze_Record_Type): Replace Set_Next_Entity w/
Link_Entities.
From-SVN: r260661
Hristian Kirtchev [Thu, 24 May 2018 13:06:05 +0000 (13:06 +0000)]
[Ada] Spurious error due to lingering limited view
This patch modifies the mechanism which manages [private] with clauses to
uninstall a limited with clause if a non-limited with clause is given for
the same package.
The management of with clauses already prevents the installation of a limited
with clause if the related package is already withed though a non-limited with
clause. The timing of parent unit with clause processing is such that the non-
limited clauses of the child unit are first installed, followed by the clauses
of the parent. This order prevents a limited with clause from "overriding" a
non-limited with clause.
Private with clauses however break this model because they are processed when
the private part of a package is entered. Since private with clauses are non-
limited with clauses, they must "override" the effects of any limited clauses
which import the same packages. This effect is now correctly achieved by
uninstalling the limited with clauses when private with clauses are activated.
------------
-- Source --
------------
-- server.ads
package Server is
type Root is tagged private;
private
type Root is tagged null record;
end Server;
-- parent.ads
limited with Server;
package Parent is end Parent;
-- parent-client.ads
private with Server;
package Parent.Client is
type Deriv is tagged private;
private
type Deriv is new Server.Root with null record;
end Parent.Client;
-----------------
-- Compilation --
-----------------
$ gcc -c parent-client.ads
2018-05-24 Hristian Kirtchev <kirtchev@adacore.com>
gcc/ada/
* sem_ch10.adb (Expand_Limited_With_Clause): Update the call to
Install_Limited_Withed_Unit.
(Expand_With_Clause): Update the call to Install_Withed_Unit.
(Implicit_With_On_Parent): Update the call to Install_Withed_Unit.
(Install_Context_Clauses): Update the call to Install_Withed_Unit.
(Install_Limited_Context_Clauses): Update the calls to
Install_Limited_Withed_Unit.
(Install_Limited_Withed_Unit): Renamed to better illustrate its
purpose.
(Install_Private_With_Clauses): Update the calls to Install_Withed_Unit
and Install_Limited_Withed_Unit.
(Install_With_Clause): Uninstall a limited with clause if a [private]
with clause is given for the same package.
(Install_Withed_Unit): Renamed to better illustrate its purpose.
(Remove_Limited_With_Unit): New routine.
From-SVN: r260660
Eric Botcazou [Thu, 24 May 2018 13:05:59 +0000 (13:05 +0000)]
[Ada] Handle version 2 of Windows unwinding information structures
2018-05-24 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* raise-gcc.c (__gnat_SEH_error_handler): Remove prototype.
(__gnat_personality_seh0): Adjust and beef up comments, and
fix formatting throughout.
(__gnat_adjust_context): Deal minimally with version 2.
* seh_init.c (__gnat_map_SEH): Fix formatting.
(_gnat_SEH_error_handler): Adjust comments.
(__gnat_install_SEH_handler): Fix formatting.
From-SVN: r260659
Hristian Kirtchev [Thu, 24 May 2018 13:05:54 +0000 (13:05 +0000)]
[Ada] Minor reformatting
2018-05-24 Hristian Kirtchev <kirtchev@adacore.com>
gcc/ada/
* exp_ch7.adb, sem_ch3.adb, sem_res.adb: Minor reformatting.
From-SVN: r260658
Ed Schonberg [Thu, 24 May 2018 13:05:49 +0000 (13:05 +0000)]
[Ada] Add warning on redundant others_clause in array aggregate
This patch adds a warning on a redundant others_clause in an array aggregate
when all index positions are already specified in previous positional or named
associations. The warning is emitted when Warn_On_Redundant_Constructs is
enabled.
2018-05-24 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_aggr.adb (Flatten): Add a warning on an others clause in an array
aggregate with static bounds when named associations cover all index
positions and the others clause is redundant.
gcc/testsuite/
* gnat.dg/others1.adb: New testcase.
From-SVN: r260657
Raphael Amiard [Thu, 24 May 2018 13:05:43 +0000 (13:05 +0000)]
[Ada] Update Ada.Containers.Hashed_Maps documentation with Ada RM doc.
2018-05-24 Raphael Amiard <amiard@adacore.com>
gcc/ada/
* libgnat/a-cohama.ads: Add documentation.
From-SVN: r260656
Raphael Amiard [Thu, 24 May 2018 13:05:38 +0000 (13:05 +0000)]
[Ada] Add documentation from the Ada RM to Ada.Containers.Vector
2018-05-24 Raphael Amiard <amiard@adacore.com>
gcc/ada/
* libgnat/a-convec.ads: Add documentation.
From-SVN: r260655
Justin Squirek [Thu, 24 May 2018 13:05:32 +0000 (13:05 +0000)]
[Ada] Crash on return of raise expression
This patch fixes an issue whereby the compiler regarded assignments to limited
that consisted of raise expressions to be a compile-time error during
expansion.
2018-05-24 Justin Squirek <squirek@adacore.com>
gcc/ada/
* exp_ch3.adb (Expand_N_Object_Declaration): Ignore raising an error in
expansion for limited tagged types when the node to be expanded is a
raise expression due to it not representing a valid object.
* exp_ch5.adb (Expand_N_Assignment_Statement): Add exception to error
message regarding assignments to limited types to ignore genereated
code.
gcc/testsuite/
* gnat.dg/raise_expr.adb: New testcase.
From-SVN: r260654
Hristian Kirtchev [Thu, 24 May 2018 13:05:26 +0000 (13:05 +0000)]
[Ada] Crash on function in Ghost subunit
This patch modifies the creation of class-wide subtypes to preserve vital
attributes related to Ghost code. The subtype is created by copying the
contents of a class-wide type into a newly created itype. When the itype
is created within a Ghost region, the act of copying destroys Ghost code
related attributes. As a result, if the now living class-wide subtype is
frozen within an ignored Ghost region, its freeze node is hoisted prior
to the start of the region, howeve the subtype is still eliminated from
the tree.
------------
-- Source --
------------
-- pack.ads
with Ada.Finalization; use Ada.Finalization;
package Pack is
type Ctrl is new Controlled with null record;
function Make_Ctrl return Ctrl;
package Nested with Ghost is
procedure Proc;
end Nested;
end Pack;
-- pack.adb
package body Pack is
function Make_Ctrl return Ctrl is
begin
return Result : Ctrl;
end Make_Ctrl;
package body Nested is separate;
end Pack;
-- pack-nested.adb
separate (Pack)
package body Nested is
procedure Proc is
Res : constant Ctrl'Class := Make_Ctrl;
begin null; end Proc;
end Nested;
-----------------
-- Compilation --
-----------------
$ gcc -c pack.adb
2018-05-24 Hristian Kirtchev <kirtchev@adacore.com>
gcc/ada/
* exp_util.adb (New_Class_Wide_Subtype): Capture and restore relevant
Ghost-related attributes of the class-wide subtype because the copy
clobbers them.
From-SVN: r260653
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
GCC Administrator [Thu, 24 May 2018 00:16:44 +0000 (00:16 +0000)]
Daily bump.
From-SVN: r260633
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
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
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
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
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
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
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
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
Jason Merrill [Wed, 23 May 2018 17:13:30 +0000 (13:13 -0400)]
* system.h: #include <new> earlier.
From-SVN: r260620
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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