Richard Kenner [Tue, 14 Sep 2021 12:28:09 +0000 (08:28 -0400)]
[Ada] Note that -gnatd_t is used in CCG
gcc/ada/
* debug.adb: Add documentation for -gnatd_t.
Corentin Gay [Thu, 9 Sep 2021 09:57:06 +0000 (11:57 +0200)]
[Ada] Add case to consider ENODEV a "file not found error"
gcc/ada/
* sysdep.c (__gnat_is_file_not_found_error): Add else if case.
Piotr Trojanek [Fri, 10 Sep 2021 20:29:27 +0000 (22:29 +0200)]
[Ada] Rewrite operator entity in derived class-wide expressions
gcc/ada/
* exp_util.adb (Build_Class_Wide_Expression): Replace entities
of both identifiers and operator symbols.
Piotr Trojanek [Fri, 10 Sep 2021 20:27:20 +0000 (22:27 +0200)]
[Ada] Propagate Ghost status from parent to derived subprograms
gcc/ada/
* sem_ch3.adb (Derive_Subprogram): Copy ghost status from parent
to derived subprogram.
Joffrey Huguet [Fri, 10 Sep 2021 13:10:33 +0000 (15:10 +0200)]
[Ada] Add Default_Initial_Condition to type Unbounded_String
gcc/ada/
* libgnat/a-strunb.ads, libgnat/a-strunb__shared.ads: Add
Default_Initial_Condition to Unbounded_String.
Claire Dross [Fri, 10 Sep 2021 10:05:27 +0000 (12:05 +0200)]
[Ada] Disable contract cases on formal containers
gcc/ada/
* libgnat/a-cfdlli.ads: Use pragma Assertion_Policy to disable
contract cases at execution.
* libgnat/a-cfinve.ads: Idem.
* libgnat/a-cofove.ads: Idem.
* libgnat/a-cfhase.ads: Idem.
* libgnat/a-cfhama.ads: Idem.
* libgnat/a-cforse.ads: Idem.
* libgnat/a-cforma.ads: Idem.
Bob Duff [Thu, 9 Sep 2021 16:24:32 +0000 (12:24 -0400)]
[Ada] Improve message on missing all/for in pre-Ada-2022 modes
gcc/ada/
* par-ch4.adb (P_Iterated_Component_Association): Parse these
features the same way in all language versions. Move the call
to Error_Msg_Ada_2022_Feature into semantic analysis.
* sem_aggr.adb (Resolve_Iterated_Component_Association,
Resolve_Iterated_Association): Move the call to
Error_Msg_Ada_2022_Feature here from par-ch4.adb.
Yannick Moy [Thu, 9 Sep 2021 04:29:43 +0000 (06:29 +0200)]
[Ada] Improve error message on missing all/for in quantified expression
gcc/ada/
* sem_res.adb (Resolve): Recognize specially that case.
Yannick Moy [Thu, 2 Sep 2021 21:29:38 +0000 (23:29 +0200)]
[Ada] Proof of Ada.Strings.Maps
gcc/ada/
* libgnat/a-strmap.adb: Add ghost code for proof.
(To_Range): This is the most involved proof, as it requires
creating the result of the call to To_Domain as a ghost
variable, and show the unicity of this result in order to prove
the postcondition.
* libgnat/a-strmap.ads: (SPARK_Proof_Sorted_Character_Sequence):
New ghost function.
(To_Domain): Add postcondition regarding sorting of result.
(To_Range): Fix postcondition that should compare Length instead
of Last for the results of To_Domain and To_Range, as the value
of Last for an empty result is not specified in the Ada RM.
Yannick Moy [Tue, 31 Aug 2021 08:21:42 +0000 (10:21 +0200)]
[Ada] Proof of Ada.Characters.Handling
gcc/ada/
* libgnat/a-chahan.adb: Add loop invariants as needed to prove
subprograms. Also use extended return statements where
appropriate and not done already. Mark data with
Relaxed_Initialization where needed for initialization by parts.
Convert regular functions to expression functions where needed
for proof.
* libgnat/a-chahan.ads: Add postconditions.
* libgnat/a-strmap.ads (Model): New ghost function to create a
publicly visible model of the private data Character_Mapping,
needed in order to prove subprograms in Ada.Characters.Handling.
Richard Biener [Tue, 5 Oct 2021 06:35:17 +0000 (08:35 +0200)]
Adjust gfortran.dg/predict-2.f90
After teaching VN to handle internal functions we now optimize
the redundant inner loop preheader check of the testcase making
the dump scanning fail because there's nothing to predict left.
The following restores the inner preheader check by making it
not redundant.
2021-10-05 Richard Biener <rguenther@suse.de>
* gfortran.dg/predict-2.f90: Adjust to avoid redundant
inner loop preheader checking code.
GCC Administrator [Tue, 5 Oct 2021 00:16:29 +0000 (00:16 +0000)]
Daily bump.
Marek Polacek [Wed, 29 Sep 2021 15:45:24 +0000 (11:45 -0400)]
c-family: Implement -Warray-compare [PR97573]
This patch addresses one of my leftovers from GCC 11. C++20 introduced
[depr.array.comp]: "Equality and relational comparisons between two operands
of array type are deprecated." so this patch adds -Warray-compare. Since the
code in question is dubious (the comparison doesn't actually compare the array
elements), I've added this warning for C too, and enabled it in all C++ modes.
PR c++/97573
gcc/c-family/ChangeLog:
* c-common.h (do_warn_array_compare): Declare.
* c-warn.c (do_warn_array_compare): New.
* c.opt (Warray-compare): New option.
gcc/c/ChangeLog:
* c-typeck.c (parser_build_binary_op): Call do_warn_array_compare.
gcc/cp/ChangeLog:
* typeck.c (cp_build_binary_op): Call do_warn_array_compare.
gcc/ChangeLog:
* doc/invoke.texi: Document -Warray-compare.
gcc/testsuite/ChangeLog:
* c-c++-common/Warray-compare-1.c: New test.
* c-c++-common/Warray-compare-2.c: New test.
Richard Biener [Mon, 4 Oct 2021 12:24:07 +0000 (14:24 +0200)]
avoid hardreg autoinit
This avoids initializating "uninitialized" hardregs like SP.
2021-10-04 Richard Biener <rguenther@suse.de>
* gimplify.c (is_var_need_auto_init): DECL_HARD_REGISTER
variables are not to be initialized.
* gcc.dg/auto-init-hardreg-1.c: New testcase.
Iain Buclaw [Sun, 3 Oct 2021 14:02:24 +0000 (16:02 +0200)]
d: gdc driver ignores -static-libstdc++ when automatically linking libstdc++ library
Adds handling of `-static-libstc++' in the gdc driver, so that libstdc++
is appropriately linked if libstdc++ is either needed or seen on the
command-line.
PR d/102574
gcc/d/ChangeLog:
* d-spec.cc (lang_specific_driver): Link libstdc++ statically if
-static-libstdc++ was given on command-line.
Iain Buclaw [Sun, 3 Oct 2021 13:21:05 +0000 (15:21 +0200)]
d: Save target node before parsing optimize options in case it changes.
Fixes an ICE seen on PowerPC targets with the attr_optimize*.d tests in
the gdc.dg testsuite.
gcc/d/ChangeLog:
* d-attribs.cc (d_handle_optimize_attribute): Save target node before
calling parse_optimize_options in case it changes.
Richard Biener [Mon, 4 Oct 2021 09:34:27 +0000 (11:34 +0200)]
middle-end/102285 - refine .DEFERRED_INIT expansion
This refines the way we figure whether we are facing a register
that cannot be initialized by emitting a memset away from inspecting
expanded RTL of the LHS to using the predicates expand_assignment
is using to detect decls or MEM_REFs with non-memory DECL_RTL.
2021-10-04 Richard Biener <rguenther@suse.de>
* expr.h (non_mem_decl_p): Declare.
(mem_ref_refers_to_non_mem_p): Likewise.
* expr.c (non_mem_decl_p): Export.
(mem_ref_refers_to_non_mem_p): Likewise.
* internal-fn.c (expand_DEFERRED_INIT): Do not expand the LHS
but check the base with mem_ref_refers_to_non_mem_p
and non_mem_decl_p.
* c-c++-common/pr102285.c: New testcase.
Richard Biener [Mon, 4 Oct 2021 08:57:45 +0000 (10:57 +0200)]
tree-optimization/102570 - teach VN about internal functions
We're now using internal functions for a lot of stuff but there's
still missing VN support out of laziness. The following instantiates
support and adds testcases for FRE and PRE (hoisting).
2021-10-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/102570
* tree-ssa-sccvn.h (vn_reference_op_struct): Document
we are using clique for the internal function code.
* tree-ssa-sccvn.c (vn_reference_op_eq): Compare the
internal function code.
(print_vn_reference_ops): Print the internal function code.
(vn_reference_op_compute_hash): Hash it.
(copy_reference_ops_from_call): Record it.
(visit_stmt): Remove the restriction around internal function
calls.
(fully_constant_vn_reference_p): Use fold_const_call and handle
internal functions.
(vn_reference_eq): Compare call return types.
* tree-ssa-pre.c (create_expression_by_pieces): Handle
generating calls to internal functions.
(compute_avail): Remove the restriction around internal function
calls.
* gcc.dg/tree-ssa/ssa-fre-96.c: New testcase.
* gcc.dg/tree-ssa/ssa-pre-33.c: Likewise.
Jonathan Wakely [Mon, 4 Oct 2021 13:04:20 +0000 (14:04 +0100)]
libstdc++: Implement P1518R2 for container deduction guides
This implements the C++23 P1518R2 proposal "Stop overconstraining
allocators in container deduction guides" as a fix for C++17 and C++20
too.
The changes allow class template argument deduction to ignore the type
of a constructor argument that initializes an allocator_type parameter
if the type should be deducible only from the other arguments. So for
the constructor vector(const vector&, const allocator_type&) only the
first argument is used for deduction, allowing the second argument to be
anything that is implicitly convertible to argument_type. Previously
deduction would fail or an ill-formed type would be deduced if the
second argument wasn't of type allocator_type.
The unordered containers do not need changes, because their
allocator-extended constructors use the allocator_type alias, which
comes from the dependent base class so is already a non-deduced context.
libstdc++-v3/ChangeLog:
* include/bits/forward_list.h (forward_list): Use non-deduced
context for allocator parameter of allocator-extended copy and
move constructors.
* include/bits/stl_bvector.h (vector<bool>): Likewise.
* include/bits/stl_deque.h (deque): Likewise.
* include/bits/stl_list.h (list): Likewise.
* include/bits/stl_map.h (map): Likewise.
* include/bits/stl_multimap.h (multimap): Likewise.
* include/bits/stl_multiset.h (multiset): Likewise.
* include/bits/stl_set.h (set): Likewise.
* include/bits/stl_vector.h (vector): Likewise.
* include/bits/stl_queue.h (queue, priority_queue): Do not
constrain Allocator template parameter of deduction guides that
have a Container parameter.
* include/bits/stl_stack.h (stack): Likewise.
* include/debug/deque (__gnu_debug::deque): Use non-deduced
context for allocator parameter of allocator-extended copy and
move constructors.
* include/debug/list (__gnu_debug::list): Likewise.
* include/debug/map.h (__gnu_debug::map): Likewise.
* include/debug/multimap.h (__gnu_debug::multimap): Likewise.
* include/debug/multiset.h (__gnu_debug::multiset): Likewise.
* include/debug/set.h (__gnu_debug::set): Likewise.
* include/debug/vector (__gnu_debug::vector): Likewise.
* testsuite/23_containers/deque/cons/deduction.cc: Test class
template argument deduction with non-deduced allocator
arguments.
* testsuite/23_containers/forward_list/cons/deduction.cc:
Likewise.
* testsuite/23_containers/list/cons/deduction.cc: Likewise.
* testsuite/23_containers/map/cons/deduction.cc: Likewise.
* testsuite/23_containers/multimap/cons/deduction.cc: Likewise.
* testsuite/23_containers/multiset/cons/deduction.cc: Likewise.
* testsuite/23_containers/priority_queue/deduction.cc: Likewise.
* testsuite/23_containers/queue/deduction.cc: Likewise.
* testsuite/23_containers/set/cons/deduction.cc: Likewise.
* testsuite/23_containers/stack/deduction.cc: Likewise.
* testsuite/23_containers/unordered_map/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_set/cons/deduction.cc:
Likewise.
* testsuite/23_containers/vector/cons/deduction.cc: Likewise.
Jonathan Wakely [Mon, 4 Oct 2021 09:21:58 +0000 (10:21 +0100)]
libstdc++: Add missing noexcept to std::variant helper
libstdc++-v3/ChangeLog:
* include/std/variant (__detail::__variant::__as): Add missing
noexcept to first overload.
Jonathan Wakely [Fri, 1 Oct 2021 20:27:24 +0000 (21:27 +0100)]
libstdc++: Disable std::string{,_view} construction from nullptr (P2166R1)
Implement this C++23 feature. Because construction from a null pointer
is undefined, we can implement it for C++11 and up, turning undefined
behaviour into a compilation error.
libstdc++-v3/ChangeLog:
* include/bits/basic_string.h (basic_string(nullptr_t)): Define
as deleted.
(operator=(nullptr_t)): Likewise.
* include/bits/cow_string.h (basic_string(nullptr_t)): Likewise.
(operator=(nullptr_t)): Likewise.
* include/std/string_view (basic_string_view(nullptr_t)):
Likewise.
* testsuite/21_strings/basic_string/cons/char/nullptr.cc: New test.
* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc:
Change dg-warning to dg-error.
* testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc:
Likewise.
Aldy Hernandez [Sun, 3 Oct 2021 17:42:10 +0000 (19:42 +0200)]
Remove static marker for range in alloca pass.
The m_ranges[] field in int_range<N> are trees, so they live in GC
space. Since invalid_range is static, it must be marked with GTY
magic. However, calculating invalid_range is not particularly slow,
or on a critical path, so we can just put it in local scope and
recalculate every time.
Tested on x86-64 Linux.
gcc/ChangeLog:
PR tree-optimization/102560
* gimple-ssa-warn-alloca.c (alloca_call_type): Remove static
marker for invalid_range.
gcc/testsuite/ChangeLog:
* g++.dg/Walloca2.C: New test.
Richard Biener [Mon, 4 Oct 2021 08:02:39 +0000 (10:02 +0200)]
middle-end/102587 - avoid auto-init for VLA vectors
This avoids ICEing for VLA vector auto-init by not initializing.
2021-10-04 Richard Biener <rguenther@suse.de>
PR middle-end/102587
* internal-fn.c (expand_DEFERRED_INIT): Guard register
initialization path an avoid initializing VLA registers
with it.
* gcc.target/aarch64/sve/pr102587-1.c: New testcase.
* gcc.target/aarch64/sve/pr102587-2.c: Likewise.
Justin Squirek [Tue, 29 Jun 2021 22:38:09 +0000 (18:38 -0400)]
[Ada] Incremental patch for restriction No_Dynamic_Accessibility_Checks
gcc/ada/
* doc/gnat_rm/standard_and_implementation_defined_restrictions.rst:
Add new entry for No_Dynamic_Accessibility_Checks documenting
behavior.
* gnat_rm.texi: Regenerate.
* exp_ch4.adb (Expand_N_In): Perform special expansion for
membership tests when No_Dynamic_Accessibility_Checks is active.
* sem_attr.adb (Resolve_Attribute): Skip static accessibility
check on actuals for anonymous access type formal parameters,
and add constants for readability.
* sem_util.adb (Function_Call_Or_Allocator_Level): Use the
innermost master for determining the level for function calls
within the alternative accessibility model.
(Type_Access_Level): Properly get the level for anonymous access
function result types.
Piotr Trojanek [Mon, 6 Sep 2021 13:40:23 +0000 (15:40 +0200)]
[Ada] Document the current behaviour of -gnateA switch
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(gnateA): This switch no longer looks at the formal parameter
type being composite (as originally mandated by SPARK), but in
the parameter passing mechanism being not specified (as
currently mandated by Ada).
* gnat_ugn.texi: Regenerate.
Ed Schonberg [Sun, 5 Sep 2021 15:22:52 +0000 (11:22 -0400)]
[Ada] Handle properly user_defined literals given by operators.
gcc/ada/
* sem_ch6.adb (Analyze_Operator_Symbol): Recognize strings as
operator names when they are the value of one of the Ada2022
aspects for User_Defined_Literals.
* sem_ch13.adb (Analyze_One_Aspect): Handle an aspect value
given by an Operator_Name.
(Validate_Literal_Aspect): Call Analyze_Operator_Symbol when
needed.
Piotr Trojanek [Mon, 6 Sep 2021 11:30:43 +0000 (13:30 +0200)]
[Ada] Fix indentation in generated AST construction functions
gcc/ada/
* gen_il-gen.adb (Put_Make_Spec): Don't emit the LF character in
the middle of a string, because the Put routine won't indent it
properly.
Ghjuvan Lacambre [Tue, 17 Aug 2021 08:37:02 +0000 (10:37 +0200)]
[Ada] Implement CUDA_Device
gcc/ada/
* gnat_cuda.adb (Remove_CUDA_Device_Entities): New function.
(Expand_CUDA_Package): Call Remove_CUDA_Device_Entities.
* gnat_cuda.ads (Expand_CUDA_Package): Expand documentation.
* sem_prag.adb (Analyze_Pragma): Remove warning about
CUDA_Device not being implemented.
Gary Dismukes [Wed, 1 Sep 2021 23:58:14 +0000 (19:58 -0400)]
[Ada] Completion of support for AI12-0409 (attribute Preelaborable_Initialization)
gcc/ada/
* sem_ch7.adb (Analyze_Package_Specification): For types marked
as Must_Have_Preelab_Init, we now check for the presence of a
Preelaborable_Initialization aspect on the type, and pass the
aspect's expression (if any) on the call to
Has_Preelaborable_Initialization (or pass Empty if the type has
no such aspect or the aspect has no associated expression).
* sem_util.ads (Has_Preelaborable_Initialization): Change
Boolean formal parameter Formal_Types_Have_Preelab_Init to
instead be a formal of type Node_Id (named Preelab_Init_Expr),
to allow passing an expression that may be a conjunction of
Preelaborable_Initialization aspects. Revise spec comment
accordingly (and remove ??? comment).
* sem_util.adb (Type_Named_In_Preelab_Init_Expression): New
nested function with a result indicating whether a given type is
named as the prefix of a Preelaborable_Initialization attribute
in the expression of a corresponding P_I aspect.
(Has_Preelaborable_Initialization): For generic formal derived
and private types, test whether the type is named in the
expression Preelab_Init_Expr (by calling
Type_Named_In_Preelab_Init_Expression), and if so, treat the
formal type as having preelaborable initialization (returning
True).
* libgnat/a-cobove.ads (Vector): Replace pragma
Preelaborable_Initialization with the aspect, specifying its
value as Element_Type'Preelaborable_Initialization.
(Cursor): Replace pragma P_I with the aspect (defaulting to
True).
* libgnat/a-cbdlli.ads (List): Replace pragma
Preelaborable_Initialization with the aspect, specifying its
value as Element_Type'Preelaborable_Initialization.
(Cursor): Replace pragma P_I with the aspect (defaulting to
True).
* libgnat/a-cbhama.ads (Map): Replace pragma
Preelaborable_Initialization with the aspect, specifying its
value as (Element_Type'Preelaborable_Initialization and
Key_Type'Preelaborable_Initialization).
(Cursor): Replace pragma P_I with the aspect (defaulting to
True).
* libgnat/a-cborma.ads (Map): Replace pragma
Preelaborable_Initialization with the aspect, specifying its
value as (Element_Type'Preelaborable_Initialization and
Key_Type'Preelaborable_Initialization).
(Cursor): Replace pragma P_I with the aspect (defaulting to
True).
* libgnat/a-cbhase.ads (Set): Replace pragma
Preelaborable_Initialization with the aspect, specifying its
value as Element_Type'Preelaborable_Initialization.
(Cursor): Replace pragma P_I with the aspect (defaulting to
True).
* libgnat/a-cborse.ads (Set): Replace pragma
Preelaborable_Initialization with the aspect, specifying its
value as Element_Type'Preelaborable_Initialization.
(Cursor): Replace pragma P_I with the aspect (defaulting to
True).
* libgnat/a-cbmutr.ads (Tree): Replace pragma
Preelaborable_Initialization with the aspect, specifying its
value as Element_Type'Preelaborable_Initialization.
(Cursor): Replace pragma P_I with the aspect (defaulting to
True).
* libgnat/a-coboho.ads (Holder): Replace pragma
Preelaborable_Initialization with the aspect, specifying its
value as Element_Type'Preelaborable_Initialization.
(Cursor): Replace pragma P_I with the aspect (defaulting to
True).
Yannick Moy [Fri, 3 Sep 2021 07:19:49 +0000 (09:19 +0200)]
[Ada] Mark Ada.Text_IO in SPARK
gcc/ada/
* libgnat/a-textio.adb: Mark body out of SPARK.
* libgnat/a-textio.ads: Mark spec in SPARK and private part out
of SPARK.
* sem.adb (Semantics.Do_Analyze): Similar to ghost code
attributes, save and restore value of
Ignore_SPARK_Mode_Pragmas_In_Instance.
Bob Duff [Fri, 3 Sep 2021 13:25:46 +0000 (09:25 -0400)]
[Ada] Minor comment fix in System.Regpat
gcc/ada/
* libgnat/s-regpat.ads: Change Data_First to Data'First. Change
"still" to "always". Similar changes for Data_Last.
Piotr Trojanek [Fri, 3 Sep 2021 07:46:33 +0000 (09:46 +0200)]
[Ada] Refactor duplicate code for pretty-printing GNAT AST
gcc/ada/
* sprint.adb (Sprint_Node_Actual): Refactor code for generic
package and subprogram declarations.
Piotr Trojanek [Wed, 1 Sep 2021 10:55:13 +0000 (12:55 +0200)]
[Ada] Remove repeated calls to Prefix in resolution of array accesses
gcc/ada/
* sem_res.adb (Resolve_Indexed_Component, Resolve_Slice): Rename
the local constant Name to Pref; remove repeated calls to
Prefix.
Matthieu Eyraud [Fri, 2 Jul 2021 12:37:55 +0000 (14:37 +0200)]
[Ada] Emit specific SCOs for decisions of quantified expressions
gcc/ada/
* scos.ads: Extend the documentation.
* par_sco.adb (Process_Decisions): Emit specific SCOs for
quantified expressions.
Piotr Trojanek [Mon, 23 Aug 2021 11:34:22 +0000 (13:34 +0200)]
[Ada] Fix comment about expansion of slices
gcc/ada/
* checks.adb (Selected_Range_Checks): Fix style.
* exp_ch4.adb (Expand_N_Slice): Fix style and comment.
* sem_res.adb (Resolve_Indexed_Component): Fix style.
Yannick Moy [Tue, 27 Jul 2021 14:19:05 +0000 (16:19 +0200)]
[Ada] Add Ada RM description of Ada.Strings.Bounded as comments in the spec
gcc/ada/
* libgnat/a-strbou.ads: Add comments.
Piotr Trojanek [Tue, 31 Aug 2021 17:13:29 +0000 (19:13 +0200)]
[Ada] Fix for a static Leading_Part attribute raising constraint error
gcc/ada/
* sem_attr.adb (Eval_Attribute): Evaluation of attribute
Leading_Part with illegal second parameter is now similar to
evaluation of Remainder with its second parameter being zero.
Ed Schonberg [Mon, 30 Aug 2021 21:41:29 +0000 (17:41 -0400)]
[Ada] Fix resolution of Declare_Expressions involving transient scopes
gcc/ada/
* sem_res.adb (Resolve_Declare_Expression): Use tree traversals
to perform name capture of local entities in the expression of
the construct.
* exp_util.adb (Possible_Side_Effects_In_SPARK): Do not apply to
the prefix of an attribute reference Reduce when that prefix is
an aggregate, because it will be expanded into a loop, and has
no identifiable type.
Javier Miranda [Mon, 30 Aug 2021 12:25:50 +0000 (08:25 -0400)]
[Ada] Fix latent problem in Sem_Ch8.Build_Class_Wide_Wrapper
gcc/ada/
* sem_ch8.adb (Build_Class_Wide_Wrapper): Fix handling of
class-wide subtypes; required to handle chains of
instantiations. Adding also code to identify these wrappers and
properly resolve instantiations where the wrapper and a tagged
type primitive are visible.
* einfo.ads (Is_Class_Wide_Wrapper): Adding documentation.
* gen_il-fields.ads (Opt_Field_Enum): Adding
Is_Class_Wide_Wrapper.
* gen_il-gen-gen_entities.adb (Root_Entity_Type): Adding
semantic flag Is_Class_Wide_Wrapper.
Bob Duff [Sun, 29 Aug 2021 15:25:08 +0000 (11:25 -0400)]
[Ada] Declaration_Node for Itypes returns Empty or declaration
gcc/ada/
* einfo.ads (Declaration_Node): Document that Declaration_Node
for Itypes.
* einfo-utils.adb (Declaration_Node): Make it return Empty for
Itypes, or a proper type or subtype declaration.
* gen_il-gen.adb: Minor comment improvement.
Piotr Trojanek [Fri, 27 Aug 2021 15:48:15 +0000 (17:48 +0200)]
[Ada] Fix handling of slices with subtype names
gcc/ada/
* sem_res.adb (Resolve_Slice): Fix application of range checks
to slice range given as a subtype name.
Piotr Trojanek [Thu, 26 Aug 2021 15:35:27 +0000 (17:35 +0200)]
[Ada] Fix missing check on slice with a subtype indication
gcc/ada/
* sem_res.adb (Resolve_Slice): Handle range given as a subtype
indication.
Piotr Trojanek [Tue, 24 Aug 2021 21:58:40 +0000 (23:58 +0200)]
[Ada] Fix handling of 'Image acting as a prefix of a slice in CodePeer
gcc/ada/
* sem_res.adb (Resolve_Slice): Add custom handling of attribute
Image and similar in CodePeer mode. This complements the
existing custom handling of these attributes in
Expand_N_Attribute_Reference.
Justin Squirek [Mon, 19 Jul 2021 18:03:35 +0000 (14:03 -0400)]
[Ada] Spurious non-variable error on implicitly dereferenced in-mode formal
gcc/ada/
* sem_util.adb (Is_Variable): Add check for implicitly
dereferenced access types
(Is_Dependent_Component_Of_Mutable_Object): Set Prefix_Type when
not specified.
Eric Botcazou [Thu, 26 Aug 2021 13:42:05 +0000 (15:42 +0200)]
[Ada] Adjust documentation of -fdump-ada-spec in GNAT UG
gcc/ada/
* doc/gnat_ugn/the_gnat_compilation_model.rst (Binding generation):
Document specific behavior for /include/-ending paths and update.
* gnat_ugn.texi: Regenerate.
Arnaud Charlet [Thu, 26 Aug 2021 13:21:22 +0000 (09:21 -0400)]
[Ada] PR ada/102073
gcc/ada/
PR ada/102073
* socket.c (__gnat_gethostbyaddr, __gnat_inet_pton): Add missing
return statements.
Justin Squirek [Sat, 14 Aug 2021 11:32:17 +0000 (07:32 -0400)]
[Ada] Crash on allocator in alternative accessibility modes
gcc/ada/
* sem_util.adb (Function_Or_Allocator_Level): Properly handle
direct function calls in the default alternative accessibility
checking mode.
Javier Miranda [Thu, 26 Aug 2021 17:40:14 +0000 (13:40 -0400)]
[Ada] Entities in E_Loop scopes are not library-level entities
gcc/ada/
* sem_util.adb (Is_Library_Level_Entity): Return False for
entities defined in E_Loop scopes. This change is not required
by the frontend; it is required by tools that depend on the
frontend sources.
* einfo-utils.adb (Is_Dynamic_Scope): Code cleanup.
Justin Squirek [Wed, 18 Aug 2021 03:12:00 +0000 (23:12 -0400)]
[Ada] Spurious accessibility error on renamed expression
gcc/ada/
* sem_util.adb (Accessibility_Level): Add a case to handle
renamed subprograms in addition to renamed objects.
Doug Rupp [Fri, 20 Aug 2021 15:26:58 +0000 (08:26 -0700)]
[Ada] VxWorks inconsistent use of return type Fixup
gcc/ada/
* libgnarl/s-osinte__vxworks.ads (tlsKeyCreate): Return int.
* libgnarl/s-tpopsp__vxworks-rtp.adb (ERROR): Declare from
System.VxWorks.Ext.ERROR.
(Initialize): Declare IERR. Assert it.
* libgnarl/s-tpopsp__vxworks.adb (ERROR): Declare from
System.VxWorks.Ext.ERROR.
(Is_Valid_Task): Declare IERR. Test return.
* libgnarl/s-vxwext__kernel.adb (semDelete): Return STATUS.
Eric Botcazou [Mon, 23 Aug 2021 16:16:05 +0000 (18:16 +0200)]
[Ada] Emit debugging information for TSD object
gcc/ada/
* exp_disp.adb (Make_DT): Copy the Needs_Debug_Info flag from the
type onto the TSD object.
Steve Baird [Tue, 17 Aug 2021 17:01:11 +0000 (10:01 -0700)]
[Ada] Fix compiler internal error
gcc/ada/
* sem_util.adb (Is_Repeatedly_Evaluated): Handle the case of an
Old attribute reference that occurs within what was originally a
quantified expression but which expansion has transformed into
an Expression_With_Actions.
Steve Baird [Mon, 16 Aug 2021 23:41:40 +0000 (16:41 -0700)]
[Ada] Improve checking for invalid index values when accessing array elements
gcc/ada/
* exp_ch4.adb (Expand_N_Indexed_Component): The two improvements
described above.
Tobias Burnus [Mon, 4 Oct 2021 07:38:43 +0000 (09:38 +0200)]
Fortran: Avoid var initialization in interfaces [PR54753]
Intent(out) implies deallocation/default initialization; however, it is
pointless to do this for dummy-arguments symbols of procedures which are
inside an INTERFACE block. – This also fixes a bogus error for the attached
included testcase, but fixing the non-interface version still has to be done.
PR fortran/54753
gcc/fortran/ChangeLog:
* resolve.c (can_generate_init, resolve_fl_variable_derived,
resolve_symbol): Only do initialization with intent(out) if not
inside of an interface block.
Eric Botcazou [Mon, 4 Oct 2021 07:16:19 +0000 (09:16 +0200)]
Remove dead code in config/rs6000/vxworks.h
These lines were added last year:
/* Initialize library function table. */
#undef TARGET_INIT_LIBFUNCS
#define TARGET_INIT_LIBFUNCS rs6000_vxworks_init_libfuncs
but TARGET_INIT_LIBFUNCS is #undef-ed in config/rs6000/rs6000.c and
rs6000_vxworks_init_libfuncs is nowhere defined in any case.
gcc/
* config/rs6000/vxworks.h (TARGET_INIT_LIBFUNCS): Delete.
GCC Administrator [Mon, 4 Oct 2021 00:16:22 +0000 (00:16 +0000)]
Daily bump.
Patrick McGehearty [Sun, 3 Oct 2021 22:07:06 +0000 (18:07 -0400)]
Fix for powerpc64 long double complex divide failure
- - - -
New in version 6: Due to an oversight (i.e. coding error), version 5
changed the use of __LIBGCC_TF_EPSILON__ to __LIBGCC_DF_EPSILON__ but
not the other LIBGCC_TF values. For correct execution of the long
double test case it is necessary to also switch to using
__LIBGCC_DF_MIN__. For consistency we also switch to using
__LIBGCC_DF_MAX__. LDBL_MIN is 2**53 times as larger than DBL_MIN.
The larger value causes the code to switch the order of computation
when it is not optimal, resulting in failure for one of the values
in the cdivchk_ld.c test. Using DBL_MIN does not cause that failure..
There may be opportunity for further refinement of IBM128 format
Long Double complex divide, but that's beyond the scope of this
patch.
- - - -
This revision adds a test in libgcc/libgcc2.c for when
"__LIBGCC_TF_MANT_DIG__ == 106" to use __LIBGCC_DF_EPSILON__ instead
of __LIBGCC_TF_EPSILON__. That is specific to IBM 128-bit format long
doubles where EPSILON is very, very small and 1/EPSILON oveflows to
infinity. This change avoids the overflow without affecting any other
platform. Discussion in the patch is adjusted to reflect this
limitation.
It does not make any changes to .../rs6000/_divkc3.c, leaving it to
use __LIBGCC_KF__*. That means the upstream gcc will not build in
older IBM environments that do not recognize the KF floating point
mode properly. Environments that do not need IBM longdouble support
do build cleanly.
- - - -
This patch addresses the failure of powerpc64 long double complex divide
in native ibm long double format after the patch "Practical improvement
to libgcc complex divide".
The new code uses the following macros which are intended to be mapped
to appropriate values according to the underlying hardware representation.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101104
RBIG a value near the maximum representation
RMIN a value near the minimum representation
(but not in the subnormal range)
RMIN2 a value moderately less than 1
RMINSCAL the inverse of RMIN2
RMAX2 RBIG * RMIN2 - a value to limit scaling to not overflow
When "long double" values were not using the IEEE 128-bit format but
the traditional IBM 128-bit, the previous code used the LDBL values
which caused overflow for RMINSCAL. The new code uses the DBL values.
RBIG LDBL_MAX = 0x1.fffffffffffff800p+1022
DBL_MAX = 0x1.fffffffffffff000p+1022
RMIN LDBL_MIN = 0x1.0000000000000000p-969
RMIN DBL_MIN = 0x1.0000000000000000p-1022
RMIN2 LDBL_EPSILON = 0x0.0000000000001000p-1022 = 0x1.0p-1074
RMIN2 DBL_EPSILON = 0x1.0000000000000000p-52
\e[ORMINSCAL 1/LDBL_EPSILON = inf (1.0p+1074 does not fit in IBM 128-bit).
1/DBL_EPSILON = 0x1.0000000000000000p+52
RMAX2 = RBIG * RMIN2 = 0x1.fffffffffffff800p-52
RBIG * RMIN2 = 0x1.fffffffffffff000p+970
The MAX and MIN values have only modest changes since the maximum and
minimum values are about the same as for double precision. The
EPSILON field is considerably different. Due to how very small values
can be represented in the lower 64 bits of the IBM 128-bit floating
point, EPSILON is extremely small, so far beyond the desired value
that inversion of the value overflows and even without the overflow,
the RMAX2 is so small as to eliminate most usage of the test.
The change has been tested on gcc135.fsffrance.org and gains the
expected improvements in accuracy for long double complex divide.
libgcc/
PR target/101104
* libgcc2.c (RMIN2, RMINSCAL, RMAX2):
Use more correct values for native IBM 128-bit.
Iain Sandoe [Sat, 2 Oct 2021 15:15:38 +0000 (16:15 +0100)]
coroutines: Fail with a sorry when presented with a VLA [PR 101765].
We do not support this yet.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/101765
gcc/cp/ChangeLog:
* coroutines.cc (register_local_var_uses): Emit a sorry if
we encounter a VLA in the coroutine local variables.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr101765.C: New test.
Iain Sandoe [Sat, 2 Oct 2021 13:43:39 +0000 (14:43 +0100)]
coroutines: Await expressions are not allowed in handlers [PR 99710].
C++20 [expr.await] / 2
An await-expression shall appear only in a potentially-evaluated expression
within the compound-statement of a function-body outside of a handler.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/99710
gcc/cp/ChangeLog:
* coroutines.cc (await_statement_walker): Report an error if
an await expression is found in a handler body.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr99710.C: New test.
John Eivind Helset [Fri, 21 May 2021 23:53:22 +0000 (01:53 +0200)]
coroutines: Fix ICE with an invalid await_suspend type [PR100673].
The reported ICE occurs when an invalid (non-template) type is found
as the return for an await_suspend.
Fixed by amending build_co_await to ensure that await_suspend return-
type is a template-instantiation before checking to see if it is a
valid coroutine handle type.
Signed-off-by: John Eivind Helset <jehelset@gmail.com>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/100673
gcc/cp/ChangeLog:
* coroutines.cc (build_co_await): Guard against NULL
await_suspend types.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr100673.C: New test.
Iain Sandoe [Sat, 2 Oct 2021 12:40:09 +0000 (13:40 +0100)]
coroutines: Ensure co_await_exprs have TREE_SIDE_EFFECTS set [PR 101133].
Although it is not immediately evident from the symptoms, the PR is
caused by a variable having a DECL_INITIAL() containing a co_await.
This is not correct, since such expressions have side-effects.
We were marking the overall co_await expression correctly, but if a
consumer of that expression stripped out the underlying co_await_expr
then the latter would not be properly marked.
Fixed by marking both the underlying and any containing await expr
with TREE_SIDE_EFFECTS. Also mark type-dependent co_await expressions.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/101133
gcc/cp/ChangeLog:
* coroutines.cc (build_co_await): Mark co_await_expr trees
with TREE_SIDE_EFFECTS, also mark any containing expression.
(finish_co_await_expr): Mark type-dependent co_await_expr
trees with TREE_SIDE_EFFECTS.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr101133.C: New test.
Iain Sandoe [Sat, 2 Oct 2021 11:44:01 +0000 (12:44 +0100)]
coroutines: Look through NOPs for awaiter variables [PR 99575].
There was a missing STRIP_NOPS which meant that, in some cases,
an awaiter variable could be hidden by a view-convert-expr.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/99575
gcc/cp/ChangeLog:
* coroutines.cc (build_co_await): Strip NOPs from
candidate awaiter expressions before testing to see
if they need a temporary.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr99575.C: New test.
Martin Liska [Sun, 3 Oct 2021 12:25:11 +0000 (14:25 +0200)]
options: check for CL_OPTIMIZATION only for cl_options.
gcc/ChangeLog:
* toplev.c (toplev::main): Check opt_index if it is a part
of cl_options.
GCC Administrator [Sun, 3 Oct 2021 00:16:17 +0000 (00:16 +0000)]
Daily bump.
Jonathan Wakely [Sat, 2 Oct 2021 20:18:19 +0000 (21:18 +0100)]
libstdc++: Fix typos in std::filesystem code
There were a couple of typos in r12-4070 and r12-4071 which don't show
up when building for POSIX targets.
libstdc++-v3/ChangeLog:
* src/c++17/fs_ops.cc (create_directory): Fix typo in enum name.
* src/filesystem/ops-common.h (__last_system_error): Add
explicit cast to avoid narrowing conversion.
(do_space): Fix type in function name.
Aldy Hernandez [Sat, 2 Oct 2021 14:59:26 +0000 (16:59 +0200)]
[PR102563] Do not clobber range in operator_lshift::op1_range.
We're clobbering the final range before we're done calculating it.
Tested on x86-64 Linux.
gcc/ChangeLog:
PR tree-optimization/102563
* range-op.cc (operator_lshift::op1_range): Do not clobber
range.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr102563.c: New test.
Martin Liska [Sat, 2 Oct 2021 11:30:28 +0000 (13:30 +0200)]
contrib: filter out mmx.md file.
contrib/ChangeLog:
* filter-clang-warnings.py: Filter out -Wtautological-compare
for the file.
Tobias Burnus [Sat, 2 Oct 2021 09:29:35 +0000 (11:29 +0200)]
Add libgomp.fortran/order-reproducible-*.f90
libgomp/ChangeLog:
* testsuite/libgomp.fortran/order-reproducible-1.f90: New test
based on libgomp.c-c++-common/order-reproducible-1.c.
* testsuite/libgomp.fortran/order-reproducible-2.f90: Likewise.
* testsuite/libgomp.fortran/my-usleep.c: New test.
Martin Liska [Sat, 2 Oct 2021 07:31:46 +0000 (09:31 +0200)]
options: fix ASAN issue during saving of opt. options
gcc/ChangeLog:
* toplev.c (toplev::main): save_decoded_options[0] is program
name and so it should be skipped.
Iain Sandoe [Sat, 2 Oct 2021 08:19:24 +0000 (09:19 +0100)]
c-family: Fix bootstrap for targets defining TARGET_FORMAT_TYPES.
A recent improvement in Waddress causes a bootstrap failure on
targets that define TARGET_FORMAT_TYPES since it cannot be NULL
if defined to an address.
There is no default for this target macro, and it would seem no
purpose to defining it to NULL, so the warning appears reasonable.
Fixed by removing the pointless test.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/c-family/ChangeLog:
* c-format.c: Remove a test of TARGET_FORMAT_TYPES with
NULL, this is not needed.
H.J. Lu [Sat, 2 Oct 2021 02:26:08 +0000 (19:26 -0700)]
Use unsigned long long in asm-x86-linux-rdmsr.c
Use unsigned long long for 64-bit integer since unsigned long is 32 bits
for x32.
* gcc.dg/analyzer/torture/asm-x86-linux-rdmsr.c (DECLARE_ARGS):
Use unsigned long long for x86-64.
GCC Administrator [Sat, 2 Oct 2021 00:16:31 +0000 (00:16 +0000)]
Daily bump.
Aldy Hernandez [Fri, 1 Oct 2021 11:05:36 +0000 (13:05 +0200)]
[PR102546] X << Y being non-zero implies X is also non-zero.
This patch teaches this to range-ops.
Tested on x86-64 Linux.
gcc/ChangeLog:
PR tree-optimization/102546
* range-op.cc (operator_lshift::op1_range): Teach range-ops that
X << Y is non-zero implies X is also non-zero.
Przemyslaw Wirkus [Fri, 1 Oct 2021 21:40:13 +0000 (22:40 +0100)]
aarch64: enable cortex-x2 CPU
Patch is adding 'cortex-x2' to -mcpu command line option.
gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (AARCH64_CORE): New
Cortex-X2 core.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Update docs.
Przemyslaw Wirkus [Fri, 1 Oct 2021 21:39:53 +0000 (22:39 +0100)]
aarch64: enable cortex-a710 CPU
Patch is adding 'cortex-a710' to -mcpu command line option.
gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (AARCH64_CORE): New
Cortex-A710 core.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Update docs.
Przemyslaw Wirkus [Fri, 1 Oct 2021 21:39:32 +0000 (22:39 +0100)]
aarch64: enable cortex-a510 CPU
Patch is adding 'cortex-a510' to -mcpu command line option.
gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (AARCH64_CORE): New
Cortex-A510 core.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Update docs.
Jonathan Wakely [Fri, 1 Oct 2021 14:55:57 +0000 (15:55 +0100)]
libstdc++: Restore printing of assertion messages [PR102100]
My changes for PR 101429 broke the _-replacement_assert function,
because we now always just abort without printing anything. That's
because I added checks for _GLIBCXX_HOSTED and _GLIBCXX_VERBOSE, but the
checks are done before those get defined.
This adds a new macro which is set
by the sed command in include/Makefile, once the HOSTED and VERBOSE
macros have been set by the configure script.
libstdc++-v3/ChangeLog:
PR libstdc++/102100
* include/Makefile.am (c++config.h): Define
_GLIBCXX_VERBOSE_ASSERT based on configure output.
* include/Makefile.in: Regenerate.
* include/bits/c++config: Fix condition for verbose assertions.
Jonathan Wakely [Fri, 1 Oct 2021 19:37:02 +0000 (20:37 +0100)]
libstdc++: Reduce header dependencies for C++20 std::erase [PR92546]
This reduces the preprocessed size of <deque>, <string> and <vector> by
not including <bits/stl_algo.h> for std::remove and std::remove_if.
Also unwrap iterators using __niter_base, to avoid redundant debug mode
checks.
PR libstdc++/92546
* include/bits/erase_if.h (__erase_nodes_if): Use __niter_base to
unwrap debug iterators.
* include/bits/refwrap.h: Do not error if included in C++03.
* include/bits/stl_algo.h (__remove_if): Move to ...
* include/bits/stl_algobase.h (__remove_if): ... here.
* include/std/deque (erase, erase_if): Use __remove_if instead of
remove and remove_if.
* include/std/string (erase, erase_if): Likewise.
* include/std/vector (erase, erase_if): Likewise.
Jonathan Wakely [Tue, 25 May 2021 13:33:15 +0000 (14:33 +0100)]
libstdc++: Allow stateful allocators in std::list::sort [PR 66742]
The temporary lists used by std::list::sort are default constructed,
which means they use default constructed allocators. The sort operation
is defined in terms of merge and splice operations, which have undefined
behaviour (and abort) if the allocators do not compare equal. This means
it is not possible to sort a list that uses an allocator that compares
unequal to an default constructed allocator.
The solution is to avoid using temporary std::list objects at all. We do
not need to be able to allocate memory because no nodes are allocated,
only spliced from one list to another. That means the temporary lists
don't need an allocator at all, so whether it would compare equal
doesn't matter.
Instead of temporary std::list objects, we can just use a collection of
_List_node_base objects that nodes can be spliced onto as needed. Those
objects are wrapped in a _Scratch_list type that implements the splicing
and merging operations used by list::sort.
We also don't need to update the list size during the sort, because
sorting doesn't alter the number of nodes. Although we move nodes in and
out of the scratch lists, at the end of the function all nodes are back
in the original std::list and the scratch lists are empty. So for the
cxx11 ABI we can avoid the _M_size modifications usually done when
splicing nodes.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/66742
* include/bits/list.tcc (list::sort()): Use _Scratch_list
objects for splicing and merging.
(list::sort(StrictWeakOrdering)): Likewise.
* include/bits/stl_list.h (__detail::_Scratch_list): New type.
* src/c++98/list.cc (_List_node_base::_M_transfer): Add
assertion for --enable-libstdcxx-debug library.
* testsuite/23_containers/list/operations/66742.cc: New test.
Jonathan Wakely [Thu, 20 May 2021 21:36:16 +0000 (22:36 +0100)]
libstdc++: Make std::jthread support pointers to member functions [PR 100612]
This adds a non-standard extension to support initializing a
std::jthread with a pointer to a member function that expects a
stop_token to be added to the arguments. That use case is not supported
by C++20, because the stop_token would get added as the first argument,
which is where the object argument needs to be to invoke a pointer to
member function.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/100612
* include/std/thread (__pmf_expects_stop_token): New variable
template to detect a pointer to member function that needs a
stop_token to be added to the arguments.
(jthread::__S_create): Use __pmf_expects_stop_token.
(jthread::__S_create_pmf): New function.
* testsuite/30_threads/jthread/100612.cc: New test.
Jonathan Wakely [Thu, 13 May 2021 15:16:26 +0000 (16:16 +0100)]
libstdc++: Add container adaptor constructors taking iterators (P1425R4)
This adds a feature that was recently added to the C++23 working draft.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/stl_queue.h
(__cpp_lib_adaptor_iterator_pair_constructor): Define for C++23, as
per P1425R4.
(queue(InputIterator, InputIterator)): Likewise.
(queue(InputIterator, InputIterator, const Alloc&)): Likewise.
* include/bits/stl_stack.h
(__cpp_lib_adaptor_iterator_pair_constructor): Likewise.
(stack(InputIterator, InputIterator)): Likewise.
(stack(InputIterator, InputIterator, const Alloc&)): Likewise.
* include/std/version (__cpp_lib_adaptor_iterator_pair_constructor):
Define.
* testsuite/23_containers/queue/cons_from_iters.cc: New test.
* testsuite/23_containers/stack/cons_from_iters.cc: New test.
Jonathan Wakely [Thu, 13 May 2021 13:30:26 +0000 (14:30 +0100)]
libstdc++: Implement LWG 3506 for std::priority_queue
The LWG 3506 issue ads allocator-extended versions of the constructors
that take iterator arguments.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/stl_queue.h (priority_queue): Add
allocator-extended overloads for constructors taking iterator.
* testsuite/23_containers/priority_queue/lwg3506.cc: New test.
Jonathan Wakely [Thu, 13 May 2021 13:30:26 +0000 (14:30 +0100)]
libstdc++: Implement LWG 3529 for std::priority_queue
The LWG 3529 issue changes to use two overloads instead of one with a
default argument, so that the sequence can be initialized directly with
the iterator range when no sequence argument is provided.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/stl_queue.h (priority_queue): Construct sequence
from iterators when no sequence argument is present (LWG 3529).
* testsuite/23_containers/priority_queue/lwg3529.cc: New test.
Jonathan Wakely [Thu, 13 May 2021 13:30:26 +0000 (14:30 +0100)]
libstdc++: Implement LWG 3522 for std::priority_queue
The LWG 3522 issue constrains all constructors of container adaptors
that have InputIterator parameters.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/stl_queue.h (priority_queue): Constrain
constructors with InputIterator parameters (LWG 3522).
* testsuite/23_containers/priority_queue/lwg3522.cc: New test.
Jonathan Wakely [Tue, 1 Jun 2021 13:22:38 +0000 (14:22 +0100)]
libstdc++: Implement LWG 3392 for std::ranges::distance
libstdc++-v3/ChangeLog:
* include/bits/ranges_base.h (ranges::distance): Split overload
into two (LWG 3392).
* testsuite/24_iterators/range_operations/lwg3392.cc: New test.
Jonathan Wakely [Mon, 24 May 2021 17:32:22 +0000 (18:32 +0100)]
libstdc++: Remove unary_function base classes from std::thread tests
std::thread does not care if a function object is adaptable, so there is
no need to derive from the deprecated std::unary_function class in these
tests.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* testsuite/30_threads/thread/cons/3.cc: Remove derivation from
std::unary_function.
* testsuite/30_threads/thread/cons/4.cc: Likewise.
* testsuite/30_threads/thread/cons/5.cc: Likewise.
Jonathan Wakely [Mon, 24 May 2021 17:27:16 +0000 (18:27 +0100)]
libstdc++: Remove useless base classes in pb_db tests
These function objects do not need to be adaptable, so stop deriving
from deprecated classes. Also the 'inline' keyword is redundant on
member functions defined in the class body.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* testsuite/ext/pb_ds/example/basic_multimap.cc: Remove
unnecesary derivation from std::unary_function.
* testsuite/ext/pb_ds/example/erase_if.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_illegal_resize.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_initial_size.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_load_set_change.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_mod.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_resize.cc: Likewise.
* testsuite/ext/pb_ds/example/hash_shift_mask.cc: Likewise.
* testsuite/ext/pb_ds/example/priority_queue_dijkstra.cc:
Likewise.
* testsuite/ext/pb_ds/example/ranged_hash.cc: Likewise.
* testsuite/ext/pb_ds/example/store_hash.cc: Likewise.
Jonathan Wakely [Thu, 20 May 2021 17:13:00 +0000 (18:13 +0100)]
libstdc++: Simplify __throw_out_of_range_fmt for freestanding
There is no point expanding the format string if we're just going to
abort instead of throw an exception. And for freestanding or non-verbose
builds we shouldn't do it either, to reduce the binary size.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* src/c++11/functexcept.cc (__throw_out_of_range_fmt): Do not
expand the format string for freestanding, or non-vebose, or if
we're just going to abort anyway.
* src/c++11/snprintf_lite.cc: Remove unused header and
declaration.
Jonathan Wakely [Thu, 20 May 2021 17:04:16 +0000 (18:04 +0100)]
libstdc++: Fix narrowing conversion in std::visit
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/std/variant (__do_visit): Use variant_npos instead of
literal -1 that requires a narrowing conversion.
Jonathan Wakely [Tue, 11 May 2021 17:47:18 +0000 (18:47 +0100)]
libstdc++: Avoid unconditional use of errc::not_supported [PR 99327]
The errc::not_supported constant is only defined if ENOTSUP is defined,
which is not true for all targets. Many uses of errc::not_supported in
the filesystem library do not actually match the intended meaning of
ENOTSUP described by POSIX. They should be using ENOSYS instead
(i.e. errc::function_not_supported).
This change ensures that appropriate error codes are used by the
filesystem library. The remaining uses of errc::not_supported are
replaced with a call to a new helper function so that an alternative
value will be used on targets that don't support errc::not_supported.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/99327
* src/filesystem/ops-common.h (__unsupported): New function to
return a suitable error code for missing functionality.
(posix::off_t): New typedef.
(posix::*): Set errno to ENOSYS instead of ENOTSUP for no-op
fallback implementations.
(do_copy_file): Replace uses of errc::not_supported.
* src/c++17/fs_ops.cc (fs::copy, fs::copy_file, create_dir)
(fs::create_directory, fs::create_directory_symlink)
(fs::create_hard_link, fs::create_symlink, fs::current_path)
(fs::equivalent, do_stat, fs::file_size, fs::hard_link_count)
(fs::last_write_time, fs::permissions, fs::read_symlink):
Replace uses of errc::not_supported.
(fs::resize_file): Qualify off_t.
* src/filesystem/ops.cc (fs::copy, fs::copy_file, create_dir)
(fs::create_directory, fs::create_directory_symlink)
(fs::create_hard_link, fs::create_symlink, fs::current_path)
(fs::equivalent, do_stat, fs::file_size, fs::last_write_time)
(fs::permissions, fs::read_symlink, fs::system_complete):
Replace uses of errc::not_supported.
(fs::resize_file): Qualify off_t and enable unconditionally.
* testsuite/19_diagnostics/system_error/cons-1.cc: Likewise.
Jonathan Wakely [Wed, 10 Feb 2021 18:00:00 +0000 (18:00 +0000)]
libstdc++: Add utility for creating std::error_code from OS errors
This adds a helper function to encapsulate obtaining an error code for
errors from OS calls. For Windows we want to use GetLastError() and the
system error category, but otherwise just use errno and the generic
error category.
This should not be used to replace existing uses of
ec.assign(errno, generic_category()) because in those cases we really do
want to get the value of errno, not a system-specific error. Only the
cases that currently use GetLastError() are replace by this new
function.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* src/filesystem/ops-common.h (last_error): New helper function.
(filesystem::do_space): Use last_error().
* src/c++17/fs_ops.cc (fs::absolute, fs::create_hard_link)
(fs::equivalent, fs::remove, fs::temp_directory_path): Use
last_error().
* src/filesystem/ops.cc (fs::create_hard_link)
(fs::remove, fs::temp_directory_path): Likewise.
Jonathan Wakely [Thu, 6 May 2021 15:26:21 +0000 (16:26 +0100)]
libstdc++: Add std::__conditional_t alias template
This change is inspired by the suggestion in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1715r0.html
The new std::__conditional_t alias template is functionally equivalent
to std::conditional_t but should be more efficient to compile, due to
only ever instantiating two specializations (std::__conditional<true>
and std::__conditional<false>) rather than a new specialization for
every use of std::conditional.
The new alias template is also available in C++11, unlike the C++14
std::conditional_t alias.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/std/type_traits (__conditional): New class template
for internal uses of std::conditional.
(__conditional_t): New alias template to replace conditional_t.
(__and_, __or_, __result_of_memfun, __result_of_memobj): Use
__conditional_t instead of conditional::type.
* include/bits/atomic_base.h (__atomic_impl::_Diff): Likewise.
* include/bits/hashtable.h (_Hashtable): Likewise.
* include/bits/hashtable_policy.h (_Node_iterator, _Insert_base)
(_Local_iterator): Likewise. Replace typedefs with
using-declarations.
* include/bits/move.h (move_if_noexcept): Use __conditional_t.
* include/bits/parse_numbers.h (_Select_int_base): Likewise.
* include/bits/ptr_traits.h (__make_not_void): Likewise.
* include/bits/ranges_algobase.h (__copy_or_move_backward)
(__copy_or_move): Likewise.
* include/bits/ranges_base.h (borrowed_iterator_t): Likewise.
* include/bits/ranges_util.h (borrowed_subrange_t): Likewise.
* include/bits/regex_compiler.h (_BracketMatcher): Use
__conditional_t. Replace typedefs with using-declarations.
* include/bits/shared_ptr_base.h (__shared_count): Use
__conditional_t.
* include/bits/stl_algobase.h (__copy_move, __copy_move_backward):
Likewise.
* include/bits/stl_iterator.h (__detail::__clamp_iter_cat)
(reverse_iterator::iterator_concept)
(__make_move_if_noexcept_iterator)
(iterator_traits<common_iterator<_It, _Sent>>)
(iterator_traits<counted_iterator<_It>>): Likewise.
* include/bits/stl_pair.h (_PCC, pair::operator=): Likewise.
* include/bits/stl_tree.h (_Rb_tree::insert_return_type)
(_Rb_tree::_M_clone_node): Likewise.
* include/bits/unique_ptr.h (unique_ptr(unique_ptr<U,E>&&)):
Likewise.
* include/bits/uses_allocator.h (__uses_alloc): Likewise.
(__is_uses_allocator_predicate): Likewise.
* include/debug/functions.h (__foreign_iterator_aux2): Likewise.
* include/experimental/any (any::_Manager, __any_caster):
Likewise.
* include/experimental/executor (async_completion): Likewise.
* include/experimental/functional (__boyer_moore_base_t):
Likewise.
* include/std/any (any::_Manager): Likewise.
* include/std/functional (__boyer_moore_base_t): Likewise.
* include/std/ranges (borrowed_iterator_t)
(borrowed_subrange_t, __detail::__maybe_present_t)
(__detail::__maybe_const_t, split_view): Likewise.
* include/std/tuple (__empty_not_final, tuple::operator=):
Likewise.
* include/std/variant (__detail::__variant::__get_t): Likewise.
Jonathan Wakely [Tue, 4 May 2021 22:31:48 +0000 (23:31 +0100)]
libstdc++: Optimize std::visit for the common case [PR 78113]
GCC does not do a good job of optimizing the table of function pointers
used for variant visitation. This avoids using the table for the common
case of visiting a single variant with a small number of alternative
types. Instead we use:
switch(v.index())
{
case 0: return visitor(get<0>(v));
case 1: return visitor(get<1>(v));
...
}
It's not quite that simple, because get<1>(v) is ill-formed if the
variant only has one alternative, and similarly for each get<N>. We
need to ensure each case only applies the visitor if the index is in
range for the actual type we're dealing with, and tell the compiler that
the case is unreachable otherwise. We also need to invoke the visitor
via the __gen_vtable_impl::__visit_invoke function, to handle the raw
visitation cases used to implement std::variant assignments and
comparisons.
Because that gets quite verbose and repetitive, a macro is used to stamp
out the cases.
We also need to handle the valueless_by_exception case, but only for raw
visitation, because std::visit already checks for it before calling
__do_visit.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/78113
* include/std/variant (__do_visit): Use a switch when we have a
single variant with a small number of alternatives.
Jonathan Wakely [Mon, 19 Apr 2021 13:49:12 +0000 (14:49 +0100)]
libstdc++: Allow visiting inherited variants [PR 90943]
Implement the changes from P2162R2 (as a DR for C++17).
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/90943
* include/std/variant (__cpp_lib_variant): Update value.
(__detail::__variant::__as): New helpers implementing the
as-variant exposition-only function templates.
(visit, visit<R>): Use __as to upcast the variant parameters.
* include/std/version (__cpp_lib_variant): Update value.
* testsuite/20_util/variant/visit_inherited.cc: New test.
Jonathan Wakely [Thu, 6 May 2021 12:44:36 +0000 (13:44 +0100)]
libstdc++: Simplify __normal_iterator converting constructor
This uses C++11 features to simplify the definition of the
__normal_iterator constructor that allows converting from iterator to
const_iterator. The previous definition relied on _Container::pointer
which is present in std::vector and std::basic_string, but is not
actually part of the container requirements.
Removing the use of _Container::pointer and defining it in terms of
is_convertible allows __normal_iterator to be used with new container
types which do not define a pointer member. Specifically, this will
allow it to be used in std::basic_stacktrace.
In theory this will enable some conversions which were not previously
permitted, for example __normal_iterator<volatile T*, vector<T>> can
now be converted to __normal_iterator<const volatile T*, vector<T>>.
In practice this doesn't matter because the library never uses such
types. In any case, allowing those conversions is consistent with
the corresponding constructors of std::reverse_iterator and
std::move_iterator.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h (__normal_iterator): Simplify
converting constructor and do not require _Container::pointer.
Jonathan Wakely [Fri, 30 Apr 2021 14:04:34 +0000 (15:04 +0100)]
libstdc++: Make move ctor noexcept for fully-dynamic string
The move constructor for the "fully-dynamic" COW string is not noexcept,
because it allocates a new empty string rep for the moved-from string.
However, there is no need to do that, because the moved-from string does
not have to be left empty. Instead, implement move construction for the
fully-dynamic case as a reference count increment, so the string is
shared.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/cow_string.h [_GLIBCXX_FULLY_DYNAMIC_STRING]
(basic_string(basic_string&&)): Add noexcept and avoid
allocation, by sharing rep with the rvalue string.
Jonathan Wakely [Fri, 30 Apr 2021 13:43:54 +0000 (14:43 +0100)]
libstdc++: Add noexcept to common_iterator proxy operators
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h (common_iterator::__arrow_proxy)
(common_iterator::__postfix_proxy): Add noexcept.
Jonathan Wakely [Wed, 28 Apr 2021 10:40:47 +0000 (11:40 +0100)]
libstdc++: Use conditional noexcept in std::reverse_iterator [PR 94418]
This adds a noexcept-specifier to each constructor and assignment
operator of std::reverse_iterator so that they are noexcept when the
corresponding operation on the underlying iterator is noexcept.
The std::reverse_iterator class template already requires that the
operations on the underlying type are valid, so we don't need to use the
std::is_nothrow_xxx traits to protect against errors when the expression
isn't even valid. We can just use a noexcept operator to test if the
expression can throw, without the overhead of redundantly checking if
the initialization/assignment would be valid.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/94418
* include/bits/stl_iterator.h (reverse_iterator): Use
conditional noexcept on constructors and assignment operators.
* testsuite/24_iterators/reverse_iterator/noexcept.cc: New test.
Jonathan Wakely [Tue, 20 Apr 2021 15:16:13 +0000 (16:16 +0100)]
libstdc++: Do not allocate a zero-size vector<bool> [PR 100153]
The vector<bool>::shrink_to_fit() implementation will allocate new
storage even if the vector is empty. That then leads to the
end-of-storage pointer being non-null and equal to the _M_start._M_p
pointer, which means that _M_end_addr() has undefined behaviour.
The fix is to stop doing a useless zero-sized allocation in
shrink_to_fit(), so that _M_start._M_p and _M_end_of_storage are both
null after an empty vector shrinks.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/100153
* include/bits/vector.tcc (vector<bool>::_M_shrink_to_fit()):
When size() is zero just deallocate and reset.
Jonathan Wakely [Sat, 17 Apr 2021 21:34:09 +0000 (22:34 +0100)]
libstdc++: Implement std::clamp with std::min and std::max [PR 96733]
The compiler doesn't know about the precondition of std::clamp that
(hi < lo) is false, and so can't optimize as well as we'd like. By using
std::min and std::max we help the compiler.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/96733
* include/bits/stl_algo.h (clamp): Use std::min and std::max.