platform/upstream/gcc.git
3 years agocontrib/mklog.py: Improve PR handling
Tobias Burnus [Mon, 21 Jun 2021 13:17:22 +0000 (15:17 +0200)]
contrib/mklog.py: Improve PR handling

Co-authored-by: Martin Sebor <msebor@redhat.com>
contrib/ChangeLog:

* mklog.py (bugzilla_url): Fetch also component.
(pr_filename_regex): New.
(get_pr_titles): Update PR string with correct format and component.
(generate_changelog): Take additional PRs; extract PR from the
filename.
(__main__): Add -b/--pr-numbers argument.
* test_mklog.py (EXPECTED4): Update to expect a PR for the new file.

3 years agotree-optimization/101120 - fix compile-time issue with SLP groups
Richard Biener [Fri, 18 Jun 2021 12:07:00 +0000 (14:07 +0200)]
tree-optimization/101120 - fix compile-time issue with SLP groups

This places two hacks to avoid an old compile-time issue when
vectorizing large permuted SLP groups with gaps where we end up
emitting loads and IV adjustments for the gap as well and those
have quite a high cost until they are eventually cleaned up.

The first hack is to fold the auto-inc style IV updates early
in the vectorizer rather than in the next forwprop pass which
shortens the SSA use-def chains of the used IV.

The second hack is to remove the unused loads after we've picked
all that we possibly use.

2021-06-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101120
* tree-vect-data-refs.c (bump_vector_ptr): Fold the
built increment.
* tree-vect-slp.c (vect_transform_slp_perm_load): Add
DR chain DCE capability.
* tree-vectorizer.h (vect_transform_slp_perm_load): Adjust.
* tree-vect-stmts.c (vectorizable_load): Remove unused
loads in the DR chain for SLP.

3 years agoc++: REF_PARENTHESIZED_P wrapper inhibiting NRVO [PR67302]
Patrick Palka [Mon, 21 Jun 2021 11:54:29 +0000 (07:54 -0400)]
c++: REF_PARENTHESIZED_P wrapper inhibiting NRVO [PR67302]

Here, in C++14 or later, we remember the parentheses around 'a' in the
return statement by using a REF_PARENTHESIZED_P wrapper, which ends up
inhibiting NRVO because we don't look through this wrapper before
checking the conditions for NRVO.  This patch fixes this by calling
maybe_undo_parenthesized_ref sooner in check_return_expr.

PR c++/67302

gcc/cp/ChangeLog:

* typeck.c (check_return_expr): Call maybe_undo_parenthesized_ref
sooner, before the NRVO handling.

gcc/testsuite/ChangeLog:

* g++.dg/opt/nrv21.C: New test.

3 years agoc++: conversion to base of vbase in NSDMI [PR80431]
Patrick Palka [Mon, 21 Jun 2021 11:54:26 +0000 (07:54 -0400)]
c++: conversion to base of vbase in NSDMI [PR80431]

The delayed processing of conversions to a virtual base in an NSDMI
assumes the target base type is a (possibly indirect) virtual base of
the current class, but the target base type could also be a base of a
virtual base, as in the testcase below.  Since such a base isn't a part
of CLASSTYPE_VBASECLASSES, we end up miscompiling the testcase due to
the call to build_base_path (with binfo=NULL_TREE) silently returning
error_mark_node.  Fix this by using convert_to_base to build the
conversion instead.

PR c++/80431

gcc/cp/ChangeLog:

* tree.c (bot_replace): Use convert_to_base to build the
conversion to the (morally) virtual base.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nsdmi-virtual1a.C: New test.

3 years agoinline-asm: Fix ICE with bitfields in "m" operands [PR100785]
Jakub Jelinek [Mon, 21 Jun 2021 11:30:42 +0000 (13:30 +0200)]
inline-asm: Fix ICE with bitfields in "m" operands [PR100785]

Bitfields, while they live in memory, aren't something inline-asm can easily
operate on.
For C and "=m" or "+m", we were diagnosing bitfields in the past in the
FE, where c_mark_addressable had:
      case COMPONENT_REF:
        if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
          {
            error
              ("cannot take address of bit-field %qD", TREE_OPERAND (x, 1));
            return false;
          }
but that check got moved in GCC 6 to build_unary_op instead and now we
emit an error during expansion and ICE afterwards (i.e. error-recovery).
For "m" it used to be diagnosed in c_mark_addressable too, but since
GCC 6 it is ice-on-invalid.
For C++, this was never diagnosed in the FE, but used to be diagnosed
in the gimplifier and/or during expansion before 4.8.

The following patch does multiple things:
1) diagnoses it in the FEs
2) stops emitting a redundant diagnostic in the gimplifier using the
   usual way, if we already see error_mark_node, we assume error has
   been emitted already and only diagnose if it wasn't error_mark_node;
   this helps diagnosing the same bug with multiple different
   errors
3) simplifies during expansion the inline asm if any errors have been
   reported (similarly how e.g. vregs pass if it detects errors on
   inline-asm either deletes them or simplifies to bare minimum -
   just labels), so that we don't have error-recovery ICEs there

2021-06-11  Jakub Jelinek  <jakub@redhat.com>

PR inline-asm/100785
gcc/
* gimplify.c (gimplify_asm_expr): Don't diagnose errors if
output or input operands were already error_mark_node.
* cfgexpand.c (expand_asm_stmt): If errors are emitted,
remove all inputs, outputs and clobbers from the asm and
set template to "".
gcc/c/
* c-typeck.c (c_mark_addressable): Diagnose trying to make
bit-fields addressable.
gcc/cp/
* typeck.c (cxx_mark_addressable): Diagnose trying to make
bit-fields addressable.
gcc/testsuite/
* c-c++-common/pr100785.c: New test.
* gcc.dg/pr48552-1.c: Don't expect invalid lvalue errors.
* gcc.dg/pr48552-2.c: Likewise.

3 years ago[Ada] Implement fixed-lower-bound consistency checks for qualified_expressions
Gary Dismukes [Tue, 6 Apr 2021 23:07:39 +0000 (19:07 -0400)]
[Ada] Implement fixed-lower-bound consistency checks for qualified_expressions

gcc/ada/

* checks.adb (Selected_Range_Checks): In the case of a
qualified_expression where the qualifying subtype is an
unconstrained array subtype with fixed lower bounds for some of
its indexes, generate tests to check that those bounds are equal
to the corresponding lower bounds of the qualified array object.

3 years ago[Ada] Optimization of System.Value_N
Bob Duff [Tue, 6 Apr 2021 14:27:26 +0000 (10:27 -0400)]
[Ada] Optimization of System.Value_N

gcc/ada/

* libgnat/s-valuen.ads (Value_Enumeration,
Valid_Enumeration_Value): Inline.
(Value_Enumeration_Pos): Add Pure_Function.

3 years ago[Ada] INOX: prototype "when" constructs
Justin Squirek [Mon, 29 Mar 2021 14:06:55 +0000 (10:06 -0400)]
[Ada] INOX: prototype "when" constructs

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst: Document new
feature under pragma Extensions_Allowed.
* gnat_rm.texi: Regenerate.
* errout.adb, errout.ads (Error_Msg_GNAT_Extension): Created to
issue errors when parsing extension only constructs.
* exp_ch11.adb, exp_ch11.ads (Expand_N_Raise_When_Statement):
Created to expand raise ... when constucts.
* exp_ch5.adb, exp_ch5.ads (Expand_N_Goto_When_Statement):
Created to expand goto ... when constructs.
* exp_ch6.adb, exp_ch6.ads (Expand_N_Return_When_Statement):
Created to expand return ... when constructs.
* expander.adb (Expand): Add case entries for "when" constructs.
* gen_il-gen-gen_nodes.adb, gen_il-types.ads: Add entries for
"when" constructs.
* par-ch11.adb (P_Raise_Statement): Add processing for raise ...
when.
* par-ch5.adb (Missing_Semicolon_On_Exit): Renamed to
Missing_Semicolon_On_When and moved to par-util.adb.
* par-ch6.adb (Get_Return_Kind): Renamed from Is_Simple and
processing added for "return ... when" return kind.
(Is_Simple): Renamed to Get_Return_Kind.
(P_Return_Statement): Add case for return ... when variant of
return statement.
* par-util.adb, par.adb (Missing_Semicolon_On_When): Added to
centeralize parsing of "when" keywords in the context of "when"
constructs.
* sem.adb (Analyze): Add case for "when" constructs.
* sem_ch11.adb, sem_ch11.ads (Analyze_Raise_When_Statement):
Created to analyze raise ... when constructs.
* sem_ch5.adb, sem_ch5.ads (Analyzed_Goto_When_Statement):
Created to analyze goto ... when constructs.
* sem_ch6.adb, sem_ch6.ads (Analyze_Return_When_Statement):
Created to analyze return ... when constructs.
* sprint.adb (Sprint_Node_Actual): Add entries for new "when"
nodes.

3 years ago[Ada] Add Ada.Strings.Text_Buffers and replace uses of Ada.Strings.Text_Output
Steve Baird [Tue, 30 Mar 2021 00:09:31 +0000 (17:09 -0700)]
[Ada] Add Ada.Strings.Text_Buffers and replace uses of Ada.Strings.Text_Output

gcc/ada/

* Make-generated.in (GEN_IL_FLAGS): Keep only GNAT flags.
(ada/stamp-gen_il): Remove dependencies on libgnat/ sources.  Do not
copy libgnat/ sources locally and tidy up.
* Makefile.rtl: Include object files for new Text_Buffer units
in the GNATRTL_NONTASKING_OBJS list.
* exp_put_image.ads, exp_put_image.adb: Update Rtsfind calls to
match new specs. For example, calls to RE_Sink are replaced with
calls to RE_Root_Buffer_Type. Update comments and change
subprogram names accordingly (e.g., Preload_Sink is changed to
Preload_Root_Buffer_Type).
* impunit.adb: Add 6 new predefined units (Text_Buffers and 5
child units thereof).
* rtsfind.ads, rtsfind.adb: Add interfaces for accessing the
Ada.Strings.Text_Buffers package and declarations
therein (including the Unbounded child unit). Do not (yet)
delete interfaces for accessing the old Text_Output package.
* sem_attr.adb (Check_Put_Image_Attribute): Replace RE_Sink uses
with RE_Root_Buffer_Type and update comments accordingly.
* sem_ch10.adb (Analyze_Compilation_Unit): Update call to
reflect name change of callee (that is, the former Preload_Sink
is now Preload_Root_Buffer_Type).
* sem_ch13.adb (Has_Good_Profile): Replace RE_Sink use with
RE_Root_Buffer_Type.
(Build_Spec): Update comment describing a parameter type.
* gen_il.ads: Remove clauses for the old Text_Output package and
add them for Ada.Streams.Stream_IO.
(Sink): Declare.
(Create_File): Likewise.
(Increase_Indent): Likewise.
(Decrease_Indent): Likewise.
(Put): Likewise.
(LF): Likewise.
* gen_il.adb: Add clauses for Ada.Streams.Stream_IO.
(Create_File): New procedure.
(Increase_Indent): Likewise.
(Decrease_Indent): Likewise.
(Put): New procedures.
* gen_il-gen.adb: Add clauses for Ada.Text_IO.  Replace
Sink'Class with Sink throughout.  Use string concatenation and
LF marker instead of formatted strings and "\n" marker.  Update
Indent/Outdent calls to use new Increase_Indent/Decrease_Indent
names.
(Put_Membership_Query_Decl): Remove.
* gen_il-internals.ads: Replace Sink'Class with Sink throughout.
(Ptypes): Remove.
(Pfields): Likewise.
* gen_il-internals.adb: Remove clauses for GNAT.OS_Lib and
Ada.Strings.Text_Buffers.Files.  Replace Sink'Class with Sink
throughout.  Use string concatenation and LF marker instead of
formatted strings and "\n" marker.
(Stdout): Remove.
(Ptypes): Likewise.
(Pfields): Likewise.
* libgnarl/s-putaim.ads: Modify context clause, update
declaration of subtype Sink to refer to
Text_Buffers.Root_Buffer_Type instead of the old
Text_Output.Sink type.
* libgnarl/s-putaim.adb: Modify context clause and add use
clause to refer to Text_Buffers package.
* libgnat/a-cbdlli.ads, libgnat/a-cbdlli.adb,
libgnat/a-cbhama.ads, libgnat/a-cbhama.adb,
libgnat/a-cbhase.ads, libgnat/a-cbhase.adb,
libgnat/a-cbmutr.ads, libgnat/a-cbmutr.adb,
libgnat/a-cborma.ads, libgnat/a-cborma.adb,
libgnat/a-cborse.ads, libgnat/a-cborse.adb,
libgnat/a-cdlili.ads, libgnat/a-cdlili.adb,
libgnat/a-cidlli.ads, libgnat/a-cidlli.adb,
libgnat/a-cihama.ads, libgnat/a-cihama.adb,
libgnat/a-cihase.ads, libgnat/a-cihase.adb,
libgnat/a-cimutr.ads, libgnat/a-cimutr.adb,
libgnat/a-ciorma.ads, libgnat/a-ciorma.adb,
libgnat/a-ciormu.ads, libgnat/a-ciormu.adb,
libgnat/a-ciorse.ads, libgnat/a-ciorse.adb,
libgnat/a-coboho.ads, libgnat/a-coboho.adb,
libgnat/a-cobove.ads, libgnat/a-cobove.adb,
libgnat/a-cohama.ads, libgnat/a-cohama.adb,
libgnat/a-cohase.ads, libgnat/a-cohase.adb,
libgnat/a-coinho.ads, libgnat/a-coinho.adb,
libgnat/a-coinho__shared.ads, libgnat/a-coinho__shared.adb,
libgnat/a-coinve.ads, libgnat/a-coinve.adb,
libgnat/a-comutr.ads, libgnat/a-comutr.adb,
libgnat/a-convec.ads, libgnat/a-convec.adb,
libgnat/a-coorma.ads, libgnat/a-coorma.adb,
libgnat/a-coormu.ads, libgnat/a-coormu.adb,
libgnat/a-coorse.ads, libgnat/a-coorse.adb,
libgnat/a-nbnbin.ads, libgnat/a-nbnbin.adb,
libgnat/a-nbnbin__gmp.adb, libgnat/a-nbnbre.ads,
libgnat/a-nbnbre.adb, libgnat/a-strunb.ads,
libgnat/a-strunb.adb, libgnat/a-strunb__shared.ads,
libgnat/a-strunb__shared.adb, libgnat/s-rannum.ads,
libgnat/s-rannum.adb: Modify Put_Image procedure used in
Put_Image aspect specification to conform to Ada profile
rules (in particular, the first parameter shall be of type
Ada.Strings.Text_Buffers.Root_Buffer_Type'Class).
* libgnat/a-sttebu.ads, libgnat/a-sttebu.adb,
libgnat/a-stbubo.ads, libgnat/a-stbubo.adb,
libgnat/a-stbufi.ads, libgnat/a-stbufi.adb,
libgnat/a-stbufo.ads, libgnat/a-stbufo.adb,
libgnat/a-stbuun.ads, libgnat/a-stbuun.adb,
libgnat/a-stbuut.ads, libgnat/a-stbuut.adb: A new predefined
unit, Ada.Strings.Text_Buffers, and five child units.  Two of
the five are RM-defined: Bounded and Unbounded. The remaining
three are GNAT-defined: Files, Utils, and Formatting. The buffer
type corresponding to an output file, type Files.File_Buffer, is
simpler (and perhaps therefore slower) than its predecessor.
Caching similar to what was being done before could be added
later if that seems appropriate.
* libgnat/s-putima.ads: Modify context clause, update
declaration of subtype Sink to refer to
Text_Buffers.Root_Buffer_Type instead of the old
Text_Output.Sink type.
* libgnat/s-putima.adb: Modify context clause.  Update
Indent/Outdent calls to use new Increase_Indent/Decrease_Indent
names; ditto for "Put_String => Put" name change.
* libgnat/a-stteou__bootstrap.ads: Delete.

3 years ago[Ada] Adjust new fast bit-field copy path to big-endian platforms
Eric Botcazou [Sat, 3 Apr 2021 13:32:46 +0000 (15:32 +0200)]
[Ada] Adjust new fast bit-field copy path to big-endian platforms

gcc/ada/

* exp_ch5.adb (Expand_Assign_Array_Bitfield_Fast): If big-endian
ordering is in effect for the operands and they are small,
adjust the unchecked conversions done around them.

3 years ago[Ada] Add Return_Statement field
Richard Kenner [Thu, 1 Apr 2021 15:35:07 +0000 (11:35 -0400)]
[Ada] Add Return_Statement field

gcc/ada/

* einfo.ads (Return_Statement): Add documentation.
* exp_ch6.adb (Expand_N_Extended_Return_Statement): Set it.
* gen_il-fields.ads: Add it.
* gen_il-gen-gen_entities.adb: Add it.

3 years ago[Ada] Improve efficiency of small slice assignments of packed arrays
Bob Duff [Tue, 30 Mar 2021 11:15:39 +0000 (07:15 -0400)]
[Ada] Improve efficiency of small slice assignments of packed arrays

gcc/ada/

* rtsfind.ads, libgnat/s-bitfie.ads, libgnat/s-bituti.adb,
libgnat/s-bituti.ads (Fast_Copy_Bitfield): New run-time library
function to copy bit fields faster than Copy_Bitfield. Cannot be
called with zero-size bit fields.  Remove obsolete ??? comments
from s-bituti.adb; we already do "avoid calling this if
Forwards_OK is False".
* exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield,
Expand_Assign_Array_Bitfield_Fast): Generate calls to
Fast_Copy_Bitfield when appropriate.
* sem_util.adb, sem_util.ads (Get_Index_Bounds): Two new
functions for getting the index bounds. These are more
convenient than the procedure of the same name, because they can
be used to initialize constants.

3 years ago[Ada] Implementation of AI12-205: defaults for formal types
Ed Schonberg [Sun, 28 Mar 2021 03:28:29 +0000 (23:28 -0400)]
[Ada] Implementation of AI12-205: defaults for formal types

gcc/ada/

* gen_il-fields.ads: Add Default_Subtype_Mark to enumeration
type for fields.
* gen_il-gen-gen_nodes.adb: Add call to create new field for
Formal_Type_Declaration node.
* par-ch12.adb (P_Formal_Type_Declaration): in Ada_2022 mode,
recognize new syntax for default: "or use subtype_mark".
(P_Formal_Type_Definition): Ditto for the case of a formal
incomplete type.
* sinfo.ads: Add field Default_Subtype_Mark to
N_Formal_Type_Declaration.
* sem_ch12.adb (Validate_Formal_Type_Default): New procedure, to
apply legality rules to default subtypes in formal type
declarations. Some legality rules apply to all defaults, such as
the requirement that the default for a formal type that depends
on previous formal entities must itself be a previously declared
formal of the same unit. Other checks are kind- specific.
(Analyze_Associations): Use specified default if there is no
actual provided for a formal type in an instance.
(Analyze_Formal_Type_Declaration): Call
Validate_Formal_Type_Default when default subtype is present.

3 years ago[Ada] Implement 'Valid_Value attribute
Bob Duff [Wed, 31 Mar 2021 12:00:59 +0000 (08:00 -0400)]
[Ada] Implement 'Valid_Value attribute

gcc/ada/

* libgnat/s-valuen.ads, libgnat/s-valuen.adb
(Value_Enumeration_Pos): New function to compute the 'Pos of the
enumeration literal for a given String.  Return a special value
instead of raising an exception on invalid input. Called by both
Valid_Enumeration_Image and Value_Enumeration.
(Valid_Enumeration_Image): Return a Boolean indicating whether
the String is a valid Image for the given enumeration type.
(Value_Enumeration): Implement in terms of
Value_Enumeration_Pos.
* libgnat/s-vaenu8.ads, libgnat/s-vaen16.ads,
libgnat/s-vaen32.ads: Rename Valid_Enumeration_Image from the
instances.
* libgnat/s-valuti.ads: Correct documentation (it was not true
for the null string).
* libgnat/s-valuti.adb (Normalize_String): Do not raise
Constraint_Error for the null string, nor strings containing
nothing but blanks, so that Valid_Enumeration_Image can return
False in these cases, rather than raising an exception.
* rtsfind.ads (RE_Value_Enumeration_8, RE_Value_Enumeration_16,
RE_Value_Enumeration_32): New functions.
(RTE_Available): Improve comment (E doesn't have to be a
subprogram, although that's the usual case).
* sem_attr.adb (nalid_Value): Semantic analysis for new
attribute.
* exp_attr.adb: Call Expand_Valid_Value_Attribute for new
attribute.
* exp_imgv.ads, exp_imgv.adb (Expand_Valid_Value_Attribute): New
procedure to expand Valid_Value into a call to
Valid_Enumeration_Image_NN.
(Expand_Value_Attribute): Misc code cleanups.  Remove two ???
mark comments. RTE_Available won't work here.  For one thing,
RTE_Available (X) shouldn't be called until the compiler has
decided to make use of X (see comments on RTE_Available), and in
this case we're trying to AVOID calling something.
* snames.ads-tmpl: New attribute name.
* doc/gnat_rm/implementation_defined_attributes.rst: Document
new attribute.
* gnat_rm.texi: Regenerate.

3 years ago[Ada] Export Opt.Assume_No_Invalid_Values for use in back-end
Eric Botcazou [Tue, 30 Mar 2021 08:36:55 +0000 (10:36 +0200)]
[Ada] Export Opt.Assume_No_Invalid_Values for use in back-end

gcc/ada/

* fe.h (Assume_No_Invalid_Values): Declare.
* opt.ads (Assume_No_Invalid_Values): Add warning comment.

3 years ago[Ada] Zero-size slices
Bob Duff [Fri, 26 Mar 2021 19:41:31 +0000 (15:41 -0400)]
[Ada] Zero-size slices

gcc/ada/

* libgnat/s-bituti.ads (Small_Size): Do not include 0 in this
type.
* libgnat/s-bituti.adb (Copy_Bitfield): Do nothing for 0-bit
bitfields.

3 years ago[Ada] Address ??? comments
Ghjuvan Lacambre [Sun, 28 Mar 2021 12:10:53 +0000 (14:10 +0200)]
[Ada] Address ??? comments

gcc/ada/

* exp_ch9.adb (Build_Simple_Entry_Call): Add comment.
* libgnat/s-rannum.adb (Random): Update comment.
* libgnat/s-rannum.ads (Generator): Update comment.

3 years ago[Ada] Fix unbalanced parens in documentation of Address clauses
Piotr Trojanek [Fri, 26 Mar 2021 22:23:01 +0000 (23:23 +0100)]
[Ada] Fix unbalanced parens in documentation of Address clauses

gcc/ada/

* doc/gnat_rm/representation_clauses_and_pragmas.rst (Address
Clauses): Fix unbalanced parens.
* gnat_rm.texi: Regenerate.

3 years ago[Ada] Minor reformattings
Ghjuvan Lacambre [Wed, 17 Mar 2021 18:13:17 +0000 (19:13 +0100)]
[Ada] Minor reformattings

gcc/ada/

* errout.adb (Handle_Serious_Error): Capitalize comment.
* exp_dbug.adb (Set_Entity_Name): Capitalize sentence.
* exp_dist.adb (Expand_All_Calls_Remote_Subprogram_Call): Fix
typo.
* sem_ch3.adb (Modular_Type_Declaration): Add space after comma.

3 years ago[Ada] Make -gnatU and -gnatw.d the default
Ghjuvan Lacambre [Wed, 10 Feb 2021 14:52:34 +0000 (15:52 +0100)]
[Ada] Make -gnatU and -gnatw.d the default

gcc/ada/

* debug.adb: Document -gnatd_U as taken.
* err_vars.ads (Warning_Doc_Switch): Set to True.
* errout.ads (Errout): Update documentation.
* gnat1drv.adb (Adjust_Global_Switches): React to -gnatd_U.
* hostparm.ads (Tag_Errors): Set to True.
* opt.ads (Unique_Error_Tag): Document -gnatd_U.

3 years ago[Ada] Fix invalid JSON real numbers generated with -gnatRj
Eric Botcazou [Fri, 26 Mar 2021 09:53:57 +0000 (10:53 +0100)]
[Ada] Fix invalid JSON real numbers generated with -gnatRj

gcc/ada/

* urealp.ads (UR_Write_To_JSON): Declare.
* urealp.adb (Decimal_Exponent_Hi): Treat numbers in base 10
specially and rewrite handling of numbers in other bases.
(Decimal_Exponent_Lo): Likewise.
(Normalize): Minor tweak.
(UR_Write_To_JSON): New wrapper procedure around UR_Write.
* repinfo.adb (List_Type_Info): When the output is to JSON, call
UR_Write_To_JSON instead of UR_Write.

3 years ago[Ada] Disable wrong computation of offsets within multidimensional arrays
Piotr Trojanek [Fri, 26 Mar 2021 08:36:49 +0000 (09:36 +0100)]
[Ada] Disable wrong computation of offsets within multidimensional arrays

gcc/ada/

* sem_util.adb (Indexed_Component_Bit_Offset): Return an unknown
offset for components within multidimensional arrays; remove
redundant parens.

3 years ago[Ada] Skip overlay checks on protected components with expansion disabled
Piotr Trojanek [Fri, 26 Mar 2021 08:02:33 +0000 (09:02 +0100)]
[Ada] Skip overlay checks on protected components with expansion disabled

gcc/ada/

* sem_util.adb (Find_Overlaid_Entity): Ignore references to
components and discriminants.

3 years ago[Ada] Compile s-mmap on aarch64-linux
Doug Rupp [Thu, 25 Mar 2021 19:44:23 +0000 (12:44 -0700)]
[Ada] Compile s-mmap on aarch64-linux

gcc/ada/

* Makefile.rtl (aarch64-linux) [LIBGNAT_TARGET_PAIRS]: Add
$(TRASYM_DWARF_UNIX_PAIRS).
[EXTRA_GNAT_RTL_NONTASKING_OBJS]: Add $(TRASYM_DWARF_UNIX_OBJS)

3 years ago[Ada] Compiler crash on sliding of fixed-lower-bound object in Loop_Invariant
Gary Dismukes [Thu, 25 Mar 2021 17:37:58 +0000 (13:37 -0400)]
[Ada] Compiler crash on sliding of fixed-lower-bound object in Loop_Invariant

gcc/ada/

* exp_util.adb (Expand_Sliding_Conversion): Only perform
expansion when Expander_Active is True. Add a comment about this
and refine existing comment regarding string literals.

3 years ago[Ada] Simplify detection of statically overlapping slices
Piotr Trojanek [Thu, 25 Mar 2021 12:17:40 +0000 (13:17 +0100)]
[Ada] Simplify detection of statically overlapping slices

gcc/ada/

* sem_util.adb (Denotes_Same_Object): Simplify handling of
slices.

3 years ago[Ada] Fix detection of overlapping actuals with renamings
Piotr Trojanek [Thu, 25 Mar 2021 12:15:30 +0000 (13:15 +0100)]
[Ada] Fix detection of overlapping actuals with renamings

gcc/ada/

* sem_util.adb (Is_Object_Renaming): Rename from Is_Renaming;
simplify; adapt callers.

3 years ago[Ada] powerpc64-wrs-vxworks7r2: build shared libgnat
Frederic Konrad [Fri, 6 Nov 2020 19:08:28 +0000 (20:08 +0100)]
[Ada] powerpc64-wrs-vxworks7r2: build shared libgnat

gcc/ada/

* Makefile.rtl: Compiles both static and dynamic libgnat for
powerpc64-wrs-vxworks7r2.

3 years agoarm/66791: Replace builtins in vceq_* (a, b) with a == b.
prathamesh.kulkarni [Mon, 21 Jun 2021 09:22:54 +0000 (14:52 +0530)]
arm/66791: Replace builtins in vceq_* (a, b) with a == b.

gcc/ChangeLog:
* config/arm/arm_neon.h (vceq_s8): Replace builtin with __a == __b.
(vceq_s16): Likewise.
(vceq_s32): Likewise.
(vceq_u8): Likewise.
(vceq_u16): Likewise.
(vceq_u32): Likewise.
(vceq_p8): Likewise.
(vceqq_s8): Likewise.
(vceqq_s16): Likewise.
(vceqq_s32): Likewise.
(vceqq_u8): Likewise.
(vceqq_u16): Likewise.
(vceqq_u32): Likewise.
(vceqq_p8): Likewise.
(vceq_f32): Gate __a == __b on __FAST_MATH__.
(vceqq_f32): Likewise.
(vceq_f16): Likewise.
(vceqq_f16): Likewise.

3 years agoarm/97906: Adjust neon_vca patterns to use GLTE instead of GTGE iterator.
prathamesh.kulkarni [Mon, 21 Jun 2021 09:08:32 +0000 (14:38 +0530)]
arm/97906: Adjust neon_vca patterns to use GLTE instead of GTGE iterator.

gcc/ChangeLog:
PR target/97906
* config/arm/iterators.md (NEON_VACMP): Remove.
* config/arm/neon.md (neon_vca<cmp_op><mode>): Use GLTE instead of GTGE
iterator.
(neon_vca<cmp_op><mode>_insn): Likewise.
(neon_vca<cmp_op_unsp><mode>_insn_unspec): Use NEON_VAGLTE instead of
NEON_VACMP.

gcc/testsuite/ChangeLog:
PR target/97906
* gcc.target/arm/simd/pr97906.c: New test.

3 years agotree-optimization/101121 - avoid infinite SLP build
Richard Biener [Mon, 21 Jun 2021 07:30:41 +0000 (09:30 +0200)]
tree-optimization/101121 - avoid infinite SLP build

The following plugs another hole where we cache a failed SLP build
attempt with an all-success 'matches'.  It also adds checking that
we don't do that.

2021-06-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101121
* tree-vect-slp.c (vect_build_slp_tree_2): To not fail fatally
when we just lack a stmt with the desired op when doing permutation.
(vect_build_slp_tree): When caching a failed SLP build attempt
assert that at least one lane is marked as not matching.

* gfortran.dg/pr101121.f: New testcase.

3 years agoDisparage slightly the mask register alternative for bitwise operations.
liuhongt [Tue, 15 Jun 2021 08:25:16 +0000 (16:25 +0800)]
Disparage slightly the mask register alternative for bitwise operations.

The avx512 supports bitwise operations with mask registers, but the
throughput of those instructions is much lower than that of the
corresponding gpr version, so we would additionally disparages
slightly the mask register alternative for bitwise operations in the
LRA.

Also when allocano cost of GENERAL_REGS is same as MASK_REGS, allocate
MASK_REGS first since it has already been disparaged.

gcc/ChangeLog:

PR target/101142
* config/i386/i386.md: (*anddi_1): Disparage slightly the mask
register alternative.
(*and<mode>_1): Ditto.
(*andqi_1): Ditto.
(*andn<mode>_1): Ditto.
(*<code><mode>_1): Ditto.
(*<code>qi_1): Ditto.
(*one_cmpl<mode>2_1): Ditto.
(*one_cmplsi2_1_zext): Ditto.
(*one_cmplqi2_1): Ditto.
* config/i386/i386.c (x86_order_regs_for_local_alloc): Change
the order of mask registers to be before general registers.

gcc/testsuite/ChangeLog:

PR target/101142
* gcc.target/i386/spill_to_mask-1.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-2.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-3.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-4.c: Adjust testcase.

3 years agoPR target/11877: Use xor to write zero to memory with -Os
Roger Sayle [Mon, 21 Jun 2021 07:54:50 +0000 (08:54 +0100)]
PR target/11877: Use xor to write zero to memory with -Os

The following patch attempts to resolve PR target/11877 (without
triggering PR/23102).  On x86_64, writing an SImode or DImode zero
to memory uses an instruction encoding that is larger than first
clearing a register (using xor) then writing that to memory.  Hence,
after reload, the peephole2 pass can determine if there's a suitable
free register, and if so, use that to shrink the code size with -Os.

To improve code size, and avoid inserting a large number of xor
instructions (PR target/23102), this patch makes use of peephole2's
efficient pattern matching to use a single temporary for a run of
consecutive writes.  In theory, one could do better still with a
new target-specific pass, gated on -Os, to shrink these instructions
(like stv), but that's probably overkill for the little remaining
space savings.

Evaluating this patch on the CSiBE benchmark (v2.1.1) results in a
0.26% code size improvement (3715273 bytes down to 3705477) on x86_64
with -Os [saving 1 byte every 400].  549 of 894 tests improve, two
tests grow larger.  Analysis of these 2 pathological cases reveals
that although peephole2's match_scratch prefers to use a call-clobbered
register (to avoid requiring a new stack frame), very rarely this
interacts with GCC's shrink wrapping optimization, which may previously
have avoided saving/restoring a call clobbered register, such as %eax,
in the calling function.

2021-06-21  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/11877
* config/i386/i386.md: New define_peephole2s to shrink writing
1, 2 or 4 consecutive zeros to memory when optimizing for size.

gcc/testsuite/ChangeLog
PR target/11877
* gcc.target/i386/pr11877.c: New test case.

3 years agoMAINTAINERS: Add myself as maintainer of the i386 vector extensions.
liuhongt [Mon, 21 Jun 2021 02:39:38 +0000 (10:39 +0800)]
MAINTAINERS: Add myself as maintainer of the i386 vector extensions.

ChangeLog:

* MAINTAINERS: Add myself as maintainer of the i386 vector
extensions.

3 years agoDaily bump.
GCC Administrator [Mon, 21 Jun 2021 00:16:25 +0000 (00:16 +0000)]
Daily bump.

3 years agolibstdc++: Implement new views::split as per P2210
Patrick Palka [Sun, 20 Jun 2021 16:47:18 +0000 (12:47 -0400)]
libstdc++: Implement new views::split as per P2210

This implements the new views::split from P2210R2 "Superior String
Splitting".

libstdc++-v3/ChangeLog:

* include/std/ranges (__non_propagating_cache::operator bool):
Define for split_view::begin().
(split_view): Define as per P2210.
(views::__detail::__can_split_view): Define.
(views::_Split, views::split): Define.
* testsuite/std/ranges/adaptors/100577.cc (test01, test02):
Test views::split.
* testsuite/std/ranges/adaptors/split.cc: New test.
* testsuite/std/ranges/p2325.cc (test08a): New test.
* testsuite/std/ranges/p2367.cc (test01): Test views::split.

3 years agolibstdc++: Implement P2210 changes to rename views::split to lazy_split
Patrick Palka [Sun, 20 Jun 2021 16:41:42 +0000 (12:41 -0400)]
libstdc++: Implement P2210 changes to rename views::split to lazy_split

This mostly mechanical patch renames split to lazy_split throughout.

libstdc++-v3/ChangeLog:

* include/std/ranges: Rename views::split to views::lazy_split,
split_view to lazy_split_view, etc. throughout.
* testsuite/std/ranges/*: Likewise.

3 years agolibstdc++: Implement P2210 changes to split_view resolving LWG 3478
Patrick Palka [Sun, 20 Jun 2021 16:38:43 +0000 (12:38 -0400)]
libstdc++: Implement P2210 changes to split_view resolving LWG 3478

This implements the part of P2210R2 "Superior String Splitting" that
resolves LWG 3478.

libstdc++-v3/ChangeLog:

* include/std/ranges (split_view::_OuterIter::__at_end):
Check _M_trailing_empty.
(split_view::_OuterIter::_M_trailing_empty): Define this
data member.
(split_view::_OuterIter::operator++): Set _M_trailing_empty
appropriately.
(split_view::_OuterIter::operator==): Compare
_M_trailing_empty.
* testsuite/std/ranges/adaptors/100479.cc (test03): Expect two
split parts instead of one.
* testsuite/std/ranges/adaptors/split.cc (test11): New test.

3 years agolibstdc++: Define split_view::_InnerIter::base as per P2210
Patrick Palka [Sun, 20 Jun 2021 16:38:35 +0000 (12:38 -0400)]
libstdc++: Define split_view::_InnerIter::base as per P2210

libstdc++-v3/ChangeLog:

* include/std/ranges (split_view::_InnerIter::base): Define as
per P2210.

3 years agoDaily bump.
GCC Administrator [Sun, 20 Jun 2021 00:16:21 +0000 (00:16 +0000)]
Daily bump.

3 years agolibstdc++: Implement LWG 3555 changes to transform/elements_view
Patrick Palka [Sat, 19 Jun 2021 00:33:31 +0000 (20:33 -0400)]
libstdc++: Implement LWG 3555 changes to transform/elements_view

libstdc++-v3/ChangeLog:

* include/std/ranges (transform_view::_Iterator::_S_iter_concept):
Consider _Base instead of _Vp as per LWG 3555.
(elements_view::_Iterator::_S_iter_concept): Likewise.

3 years agolibstdc++: Implement LWG 3553 changes to split_view
Patrick Palka [Sat, 19 Jun 2021 00:50:22 +0000 (20:50 -0400)]
libstdc++: Implement LWG 3553 changes to split_view

libstdc++-v3/ChangeLog:

* include/std/ranges (split_view::_OuterIter::value_type::begin):
Remove the non-const overload, and remove the copyable constraint
on the const overload as per LWG 3553.

3 years agolibstdc++: Implement LWG 3546 changes to common_iterator
Patrick Palka [Sat, 19 Jun 2021 00:50:13 +0000 (20:50 -0400)]
libstdc++: Implement LWG 3546 changes to common_iterator

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h
(__detail::__common_iter_use_postfix_proxy): Add
move_constructible constraint as per LWG 3546.
(common_iterator::__postfix_proxy): Adjust initializer of
_M_keep as per LWG 3546.

3 years agoDaily bump.
GCC Administrator [Sat, 19 Jun 2021 00:16:33 +0000 (00:16 +0000)]
Daily bump.

3 years agolibstdc++: Reduce ranges::minmax/minmax_element comparison complexity
Patrick Palka [Fri, 18 Jun 2021 23:33:39 +0000 (19:33 -0400)]
libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

This rewrites ranges::minmax and ranges::minmax_element so that it
performs at most 3*N/2 many comparisons, as required by the standard.
In passing, this also fixes PR100387 by avoiding a premature std::move
in ranges::minmax and in std::shift_right.

PR libstdc++/100387

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__minmax_fn::operator()): Rewrite
to limit comparison complexity to 3*N/2.
(__minmax_element_fn::operator()): Likewise.
(shift_right): Avoid premature std::move of __result.
* testsuite/25_algorithms/minmax/constrained.cc (test04, test05):
New tests.
* testsuite/25_algorithms/minmax_element/constrained.cc (test02):
Likewise.

3 years agoFix p10 fusion regtests
Aaron Sawdey [Fri, 18 Jun 2021 17:47:03 +0000 (12:47 -0500)]
Fix p10 fusion regtests

Update the count of matches for the fusion combine patterns after
the recent changes to them.  At Segher's request, used \m and \M
in the match patterns. Also I have grouped together all alternatives of
each fusion insn, which should hopefully make this test a little less
fragile.

gcc/testsuite/ChangeLog

* gcc.target/powerpc/fusion-p10-2logical.c: Update pattern
match counts.
* gcc.target/powerpc/fusion-p10-addadd.c: Update pattern match
counts.
* gcc.target/powerpc/fusion-p10-ldcmpi.c: Update pattern match
counts.
* gcc.target/powerpc/fusion-p10-logadd.c: Update pattern match
counts.

3 years ago[committed] More useless code elimination on the H8
Jeff Law [Fri, 18 Jun 2021 22:02:16 +0000 (18:02 -0400)]
[committed] More useless code elimination on the H8

gcc/
* config/h8300/h8300.c (h8300_select_cc_mode): Handle SYMBOL_REF.
* config/h8300/logical.md (<code><mode>3 logcial expander): Generate
more efficient code when the source can be trivially simplified.

3 years agoCalculate a global definition if one has not been registered.
Andrew MacLeod [Fri, 18 Jun 2021 16:52:10 +0000 (12:52 -0400)]
Calculate a global definition if one has not been registered.

With poor values gone, Pick up range restrictions from statements
by folding them with global cache values.

* gimple-range-cache.cc (ranger_cache::range_of_def):  Calculate
a range if global is not available.
(ranger_cache::entry_range): Fallback to range_of_def.
* gimple-range-cache.h (range_of_def): Adjust prototype.

3 years agoRemove poor value computations.
Andrew MacLeod [Fri, 18 Jun 2021 16:33:18 +0000 (12:33 -0400)]
Remove poor value computations.

Remove the old "poor value" approach which made callbacks into ranger
from the cache.  Use only the best available value for all propagation.

PR tree-optimization/101014
* gimple-range-cache.cc (ranger_cache::ranger_cache): Remove poor
value list.
(ranger_cache::~ranger_cache): Ditto.
(ranger_cache::enable_new_values): Delete.
(ranger_cache::push_poor_value): Delete.
(ranger_cache::range_of_def): Remove poor value processing.
(ranger_cache::entry_range): Ditto.
(ranger_cache::fill_block_cache): Ditto.
* gimple-range-cache.h (class ranger_cache): Remove poor value members.
* gimple-range.cc (gimple_ranger::range_of_expr): Remove call.
* gimple-range.h (class gimple_ranger): Adjust.

3 years agoMAINTAINERS: Add myself for write after approval
Antoni Boucher [Fri, 18 Jun 2021 20:49:20 +0000 (16:49 -0400)]
MAINTAINERS: Add myself for write after approval

ChangeLog:

2021-06-18  Antoni Boucher  <bouanto@zoho.com>

* MAINTAINERS (Write After Approval): Add myself.

3 years agoFortran - fix conversion to result type for the min/max intrinsic
Harald Anlauf [Fri, 18 Jun 2021 17:34:15 +0000 (19:34 +0200)]
Fortran - fix conversion to result type for the min/max intrinsic

gcc/fortran/ChangeLog:

PR fortran/100283
PR fortran/101123
* trans-intrinsic.c (gfc_conv_intrinsic_minmax): Unconditionally
convert result of min/max to result type.

gcc/testsuite/ChangeLog:

PR fortran/100283
PR fortran/101123
* gfortran.dg/min0_max0_1.f90: New test.
* gfortran.dg/min0_max0_2.f90: New test.

3 years agoanalyzer: fix issue with symbolic reads with concrete bindings
David Malcolm [Fri, 18 Jun 2021 17:24:19 +0000 (13:24 -0400)]
analyzer: fix issue with symbolic reads with concrete bindings

gcc/analyzer/ChangeLog:
* store.cc (binding_cluster::get_any_binding): Make symbolic reads
from a cluster with concrete bindings return unknown.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/symbolic-7.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years agolibstdc++: Implement LWG 3557 change to convertible_to
Patrick Palka [Fri, 18 Jun 2021 15:51:33 +0000 (11:51 -0400)]
libstdc++: Implement LWG 3557 change to convertible_to

libstdc++-v3/ChangeLog:

* include/std/concepts (convertible_to): Just use declval as per
LWG 3557.

3 years agoanalyzer: add region_model_manager::get_or_create_int_cst
David Malcolm [Fri, 18 Jun 2021 15:19:30 +0000 (11:19 -0400)]
analyzer: add region_model_manager::get_or_create_int_cst

gcc/analyzer/ChangeLog:
* region-model-manager.cc
(region_model_manager::get_or_create_int_cst): New.
(region_model_manager::maybe_undo_optimize_bit_field_compare): Use
it to simplify away a local tree.
* region-model.cc (region_model::on_setjmp): Likewise.
(region_model::on_longjmp): Likewise.
* region-model.h (region_model_manager::get_or_create_int_cst):
New decl.
* store.cc (binding_cluster::zero_fill_region): Use it to simplify
away a local tree.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years agoanalyzer: refactor custom_event, introducing precanned_custom_event class
David Malcolm [Fri, 18 Jun 2021 15:18:10 +0000 (11:18 -0400)]
analyzer: refactor custom_event, introducing precanned_custom_event class

I have followup work where a custom event's description would be better
handled via a vfunc rather that a precanned string, hence this
refactoring to make it easy to add custom_event subclasses.

gcc/analyzer/ChangeLog:
* checker-path.cc (class custom_event): Make abstract to allow for
custom vfuncs, splitting existing implementation into...
(class precanned_custom_event): New subclass.
(custom_event::get_desc): Move to...
(precanned_custom_event::get_desc): ...subclass.
* checker-path.h (class custom_event): Make abstract to allow for
custom vfuncs, splitting existing implementation into...
(class precanned_custom_event): New subclass.
* diagnostic-manager.cc (diagnostic_manager::add_events_for_eedge):
Use precanned_custom_event.
* engine.cc
(stale_jmp_buf::maybe_add_custom_events_for_superedge): Likewise.
* sm-signal.cc (signal_delivery_edge_info_t::add_events_to_path):
Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years agolibstdc++: Replace incorrect static assertion in std::reduce [PR95833]
Jonathan Wakely [Fri, 18 Jun 2021 13:46:58 +0000 (14:46 +0100)]
libstdc++: Replace incorrect static assertion in std::reduce [PR95833]

The standard does not require the iterator's value type to be
convertible to the result type, it only requires that the result of
dereferencing the iterator can be passed to the binary function.

libstdc++-v3/ChangeLog:

PR libstdc++/95833
* include/std/numeric (reduce(Iter, Iter, T, BinaryOp)): Replace
incorrect static_assert with ones matching the 'Mandates'
conditions in the standard.
* testsuite/26_numerics/reduce/95833.cc: New test.

3 years agoarm: Fix multilib mapping for CDE extensions [PR100856].
Srinath Parvathaneni [Fri, 18 Jun 2021 12:21:51 +0000 (13:21 +0100)]
arm: Fix multilib mapping for CDE extensions [PR100856].

On passing +cdecp[0-7] extension to the -march string in command line options,
multilib linking is failing as mentioned in PR100856. This patch fixes this issue by
generating a separate canonical string by removing compiler options which are not
required for multilib linking from march string and assign the new string to mlibarch
option. This mlibarch string is used for multilib comparison.

gcc/ChangeLog:

2021-06-10  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

PR target/100856
* common/config/arm/arm-common.c (arm_canon_arch_option_1): New function
derived from arm_canon_arch.
(arm_canon_arch_option): Call it.
(arm_canon_arch_multilib_option): New function.
* config/arm/arm-cpus.in (IGNORE_FOR_MULTILIB): New fgroup.
* config/arm/arm.h (arm_canon_arch_multilib_option): New prototype.
(CANON_ARCH_MULTILIB_SPEC_FUNCTION): New macro.
(MULTILIB_ARCH_CANONICAL_SPECS): New macro.
(DRIVER_SELF_SPECS): Add MULTILIB_ARCH_CANONICAL_SPECS.
* config/arm/arm.opt (mlibarch): New option.
* config/arm/t-rmprofile (MULTILIB_MATCHES): For armv8*-m, replace use
of march on RHS with mlibarch.

gcc/testsuite/ChangeLog:

2021-06-10  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

PR target/100856
* gcc.target/arm/acle/pr100856.c: New test.
* gcc.target/arm/multilib.exp: Add tests for cde options.

3 years agogcc/configure.ac: fix register issue for global_load assembler functions
Marcel Vollweiler [Fri, 18 Jun 2021 11:50:36 +0000 (04:50 -0700)]
gcc/configure.ac: fix register issue for global_load assembler functions

gcc/ChangeLog:

* config.in: Regenerate.
* config/gcn/gcn.c (print_operand_address): Fix for global_load assembler
functions.
* configure: Regenerate.
* configure.ac: Fix for global_load assembler functions.

3 years agotree-optimization/101112 - fix pattern stmt def lookup in SLP reassoc
Richard Biener [Fri, 18 Jun 2021 10:20:22 +0000 (12:20 +0200)]
tree-optimization/101112 - fix pattern stmt def lookup in SLP reassoc

This fixes the lookup of a pattern stmt def operand.

2021-06-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101112
* tree-vect-slp.c (vect_slp_linearize_chain): Fix condition
to lookup a pattern stmt def.

3 years agolibstdc++: Suppress -Wstringop-overread warning in test
Jonathan Wakely [Fri, 18 Jun 2021 10:08:19 +0000 (11:08 +0100)]
libstdc++: Suppress -Wstringop-overread warning in test

When compiled with -m32 -O2 -D_GLIBCXX_USE_CXX11_ABI=0 we get a warning
for 21_strings/basic_string/cons/char/1.cc:

bits/char_traits.h:409:56: warning: â€˜void* __builtin_memcpy(void*, const void*, unsigned int)’ reading 1073741821 bytes from a region of size 19 [-Wstringop-overread]

The warning is legitimate, even if that line cannot be reached because
we throw std::length_error before getting there. Since the invalid
length is deliberate (and mentioned in a comment) just suppress the
warning, so that the test can verify we get the exception.

Also remove an unused typedef that produces another warning.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string/cons/char/1.cc: Use
diagnostic pragma to suppress -Wstringop-overread error.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
3 years agostor-layout: Don't create DECL_BIT_FIELD_REPRESENTATIVE for QUAL_UNION_TYPE [PR101062]
Jakub Jelinek [Fri, 18 Jun 2021 09:20:40 +0000 (11:20 +0200)]
stor-layout: Don't create DECL_BIT_FIELD_REPRESENTATIVE for QUAL_UNION_TYPE [PR101062]

> The following patch does create them, but treats all such bitfields as if
> they were in a structure where the particular bitfield is the only field.

While the patch passed bootstrap/regtest on the trunk, when trying to
backport it to 11 branch the bootstrap failed with
atree.ads:3844:34: size for "Node_Record" too small
errors.  Turns out the error is not about size being too small, but actually
about size being non-constant, and comes from:
 /* In a FIELD_DECL of a RECORD_TYPE, this is a pointer to the storage
    representative FIELD_DECL.  */
 #define DECL_BIT_FIELD_REPRESENTATIVE(NODE) \
   (FIELD_DECL_CHECK (NODE)->field_decl.qualifier)

 /* For a FIELD_DECL in a QUAL_UNION_TYPE, records the expression, which
    if nonzero, indicates that the field occupies the type.  */
  #define DECL_QUALIFIER(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.qualifier)
so by setting up DECL_BIT_FIELD_REPRESENTATIVE in QUAL_UNION_TYPE we
actually set or modify DECL_QUALIFIER and then construct size as COND_EXPRs
with those bit field representatives (e.g. with array type) as conditions
which doesn't fold into constant.

The following patch fixes it by not creating DECL_BIT_FIELD_REPRESENTATIVEs
for QUAL_UNION_TYPE as there is nowhere to store them,

Shall we change tree.h to document that DECL_BIT_FIELD_REPRESENTATIVE
is valid also on UNION_TYPE?
I see:
tree-ssa-alias.c-  if (TREE_CODE (type1) == RECORD_TYPE
tree-ssa-alias.c:      && DECL_BIT_FIELD_REPRESENTATIVE (field1))
tree-ssa-alias.c:    field1 = DECL_BIT_FIELD_REPRESENTATIVE (field1);
tree-ssa-alias.c-  if (TREE_CODE (type2) == RECORD_TYPE
tree-ssa-alias.c:      && DECL_BIT_FIELD_REPRESENTATIVE (field2))
tree-ssa-alias.c:    field2 = DECL_BIT_FIELD_REPRESENTATIVE (field2);
Shall we change that to || == UNION_TYPE or do we assume all fields
are overlapping in a UNION_TYPE already?
At other spots (asan, ubsan, expr.c) it is unclear what will happen
if they see a QUAL_UNION_TYPE with a DECL_QUALIFIER (or does the Ada FE
lower that somehow)?

2021-06-18  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/101062
* stor-layout.c (finish_bitfield_layout): Don't add bitfield
representatives in QUAL_UNION_TYPE.

3 years ago[Ada] Additional error checking on index constraints with fixed-lower-bound ranges
Gary Dismukes [Tue, 23 Mar 2021 23:03:23 +0000 (19:03 -0400)]
[Ada] Additional error checking on index constraints with fixed-lower-bound ranges

gcc/ada/

* sem_ch3.adb (Constrain_Array): Add error checking for
fixed-lower-bound and constrained index ranges applied
inappropriately on subtypes of unconstrained and
fixed-lower-bound array types.
(Constrain_Index): Correct and refine comment related to
fixed-lower-bound index ranges.

3 years ago[Ada] Minor comment cleanups
Bob Duff [Tue, 23 Mar 2021 20:00:03 +0000 (16:00 -0400)]
[Ada] Minor comment cleanups

gcc/ada/

* gen_il-gen.adb: Improve comments.
* snames.ads-tmpl (Convention_Id): Remove "--  Plenty of space
for expansion", because that's irrelevant now that we are no
longer laying out node fields by hand.

3 years ago[Ada] Fix detection of overlapping slices indexed by characters
Piotr Trojanek [Tue, 23 Mar 2021 00:11:57 +0000 (01:11 +0100)]
[Ada] Fix detection of overlapping slices indexed by characters

gcc/ada/

* sem_util.adb (Denotes_Same_Object): Handle character literals
just like integer literals.

3 years ago[Ada] Fix detection of overlapping actuals with renamings
Piotr Trojanek [Tue, 23 Mar 2021 00:00:50 +0000 (01:00 +0100)]
[Ada] Fix detection of overlapping actuals with renamings

gcc/ada/

* sem_util.adb (Denotes_Same_Object): Explicitly test for node
kinds being the same; deal with renamings one-by-one; adjust
numbers in references to the Ada RM.

3 years ago[Ada] Make "gcc -gnatDGL" handle unterminated last lines properly
Bob Duff [Mon, 22 Mar 2021 20:22:49 +0000 (16:22 -0400)]
[Ada] Make "gcc -gnatDGL" handle unterminated last lines properly

gcc/ada/

* sprint.adb (Write_Source_Line): Check for EOF in
Line_Terminator loop.  Note that when a source file is read in,
an EOF character is added to the end.

3 years ago[Ada] Reuse Package_Specification in Is_Incomplete_Or_Private_Type
Piotr Trojanek [Mon, 22 Mar 2021 14:38:34 +0000 (15:38 +0100)]
[Ada] Reuse Package_Specification in Is_Incomplete_Or_Private_Type

gcc/ada/

* sem_aux.adb (Package_Specification): Add assertions to confirm
the kind of the of parameter and returned node.
* sem_ch12.adb (Remove_Parent): Reorder conditions; this change
appears to be semantically neutral, but is enough to avoid the
problematic call to Package_Specification.
* sem_util.adb (Is_Incomplete_Or_Private_Type): Replace loop
with a call to Package_Specification.

3 years ago[Ada] Avoid passing Enum_Lit'Size to the back end
Bob Duff [Mon, 22 Mar 2021 11:39:40 +0000 (07:39 -0400)]
[Ada] Avoid passing Enum_Lit'Size to the back end

gcc/ada/

* sem_attr.adb (Eval_Attribute): For Enum_Lit'Size, use
Enum_Type'Object_Size.

3 years ago[Ada] Fix inaccuracies in signal handler trampoline for aarch64-vxworks
Olivier Hainque [Sat, 20 Mar 2021 21:10:49 +0000 (21:10 +0000)]
[Ada] Fix inaccuracies in signal handler trampoline for aarch64-vxworks

gcc/ada/

* sigtramp-vxworks-target.inc (__aarch64__): Sync
REGNO_PC_OFFSET with the back-end DWARF_ALT_FRAME_RETURN_COLUMN.
In CFI_COMMON_REGS, leave r18 alone, VxWorks private.

3 years ago[Ada] Ada2020: AI12-0195 overriding class-wide pre/post conditions
Javier Miranda [Fri, 19 Mar 2021 20:01:40 +0000 (16:01 -0400)]
[Ada] Ada2020: AI12-0195 overriding class-wide pre/post conditions

gcc/ada/

* contracts.adb (Process_Spec_Postconditions): Add missing
support for aliased subprograms and handle wrappers of
class-wide pre/post conditions.
(Process_Inherited_Preconditions): Add missing support for
aliased subprograms and handle wrappers of class-wide pre/post
conditions.
* einfo.ads (Class_Wide_Clone): Fix typo.
(Is_Class_Wide_Clone): Removed since it is not referenced.
(Is_Wrapper): Documenting new flag.
(LSP_Subprogram): Documenting new attribute.
* exp_ch3.adb (Make_Controlling_Function_Wrappers): Decorate
wrapper as Is_Wrapper and adjust call to
Override_Dispatching_Operation.
* freeze.adb (Build_Inherited_Condition_Pragmas): Fix typo in
documentation.
(Check_Inherited_Conditions): Handle LSP wrappers; ensure
correct decoration of LSP wrappers.
* gen_il-fields.ads (Is_Class_Wide_Clone): Removed.
(Is_Wrapper): Added.
(LSP_Subprogram): Added.
* gen_il-gen-gen_entities.adb (Is_Class_Wide_Clone): Removed.
(Is_Wrapper): Added.
(LSP_Subprogram): Added.
* gen_il-internals.adb (Image): Adding uppercase image of
LSP_Subprogram.
* sem_ch6.adb (New_Overloaded_Entity): Fix decoration of LSP
wrappers.
* sem_disp.ads (Override_Dispatching_Operation): Remove
parameter Is_Wrapper; no longer needed.
* sem_disp.adb (Check_Dispatching_Operation): Adjust assertion.
(Override_Dispatching_Operation): Remove parameter Is_Wrapper;
no longer needed.
* treepr.adb (Image): Adding uppercase image of LSP_Subprogram.

3 years ago[Ada] Premature freezing of types
Arnaud Charlet [Fri, 19 Mar 2021 07:54:38 +0000 (03:54 -0400)]
[Ada] Premature freezing of types

gcc/ada/

* exp_ch4.adb (Expand_N_Quantified_Expression): Ensure the type
of the name of a "for of" loop is frozen.
* exp_disp.adb (Check_Premature_Freezing): Complete condition to
take into account a private type completed by another private
type now that the freezing rule are better implemented.
* freeze.adb (Freeze_Entity.Freeze_Profile): Do not perform an
early freeze on types if not in the proper scope. Special case
expression functions that requires access to the dispatch table.
(Should_Freeze_Type): New.
* sem_ch13.adb (Resolve_Aspect_Expressions): Prevent assert
failure in case of an invalid tree (previous errors detected).
* sem_res.adb (Resolve): Remove kludge related to entities
causing incorrect premature freezing.
* sem_util.adb (Ensure_Minimum_Decoration): Add protection
against non base types.

3 years ago[Ada] Missing check for assigning too-large array to fixed-lower-bound object
Gary Dismukes [Fri, 19 Mar 2021 23:28:38 +0000 (19:28 -0400)]
[Ada] Missing check for assigning too-large array to fixed-lower-bound object

gcc/ada/

* sem_ch3.adb (Constrain_Index): Set the High_Bound of a
fixed-lower-bound subtype's range to T (the subtype of the FLB
index being constrained) rather than Base_Type (T).

3 years ago[Ada] Remove AAMP from compiler sources
Bob Duff [Thu, 18 Mar 2021 22:46:16 +0000 (18:46 -0400)]
[Ada] Remove AAMP from compiler sources

gcc/ada/

* ada_get_targ.adb, aspects.ads, checks.adb, cstand.adb,
einfo.ads, exp_attr.adb, freeze.adb, get_targ.adb,
libgnat/a-textio.ads, libgnat/g-memdum.ads,
libgnat/s-scaval__128.adb, libgnat/s-scaval.adb, make.adb,
osint.ads, par-prag.adb, sem_ch13.adb, sem_prag.adb,
sem_prag.ads, set_targ.adb, set_targ.ads, snames.ads-tmpl,
targparm.ads, types.ads: Remove AAMP-specific code.
* switch.ads: Minor reformatting.
* gen_il-fields.ads, gen_il-gen.adb,
gen_il-gen-gen_entities.adb, gen_il-types.ads, einfo-utils.adb,
einfo-utils.ads: Package Types now contains "type Float_Rep_Kind
is (IEEE_Binary);", which used to also have an enumeral AAMP.
Gen_IL can't handle fields of this type, which would be zero
sized. Therefore, we move the Float_Rep field into Einfo.Utils
as a synthesized attribute. (We do not delete the field
altogether, in case we want new floating-point representations
in the future.)
* doc/gnat_rm/implementation_defined_pragmas.rst,
doc/gnat_rm/implementation_defined_aspects.rst,
doc/gnat_ugn/building_executable_programs_with_gnat.rst,
doc/gnat_ugn/the_gnat_compilation_model.rst: Remove
AAMP-specific documentation.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.

3 years ago[Ada] Error issued on string literal assigned to fixed-lower-bound array
Gary Dismukes [Fri, 19 Mar 2021 00:23:04 +0000 (20:23 -0400)]
[Ada] Error issued on string literal assigned to fixed-lower-bound array

gcc/ada/

* exp_util.adb (Expand_Sliding_Conversion): Move test of
Is_Fixed_Lower_Bound_Subtype to an assertion. Exclude string
literals from sliding expansion.

3 years ago[Ada] Warn about overlapping actuals in all versions of Ada
Piotr Trojanek [Wed, 17 Mar 2021 12:36:50 +0000 (13:36 +0100)]
[Ada] Warn about overlapping actuals in all versions of Ada

gcc/ada/

* sem_warn.adb (Warn_On_Overlapping_Actuals): Cleanup conditions
related to Ada_Version.

3 years ago[Ada] Reuse First_Actual in Address_Value
Piotr Trojanek [Wed, 17 Mar 2021 16:21:48 +0000 (17:21 +0100)]
[Ada] Reuse First_Actual in Address_Value

gcc/ada/

* sem_util.adb (Address_Value): Simplify.

3 years ago[Ada] Correct A'First (N) where N is an object name
Bob Duff [Wed, 17 Mar 2021 16:14:12 +0000 (12:14 -0400)]
[Ada] Correct A'First (N) where N is an object name

gcc/ada/

* sem_attr.adb (Check_Array_Or_Scalar_Type): Use Expr_Value
instead of Intval, because the latter only exists in literals.
Remove Set_Etype on E1; setting the type is done elsewhere.

3 years ago[Ada] Fix asymmetries in detection of overlapping actuals
Piotr Trojanek [Tue, 16 Mar 2021 17:38:53 +0000 (18:38 +0100)]
[Ada] Fix asymmetries in detection of overlapping actuals

gcc/ada/

* sem_warn.adb (Warn_On_Overlapping_Actuals): Examine types of
both formal parameters; refactor a complex detection of
by-reference types.

3 years ago[Ada] Fix handling of gnat check/test commands
Arnaud Charlet [Wed, 17 Mar 2021 07:59:23 +0000 (03:59 -0400)]
[Ada] Fix handling of gnat check/test commands

gcc/ada/

* gnatcmd.adb: Fix handling of check and test commands.

3 years ago[Ada] Add documentation for the array fixed-lower-bound feature
Gary Dismukes [Mon, 15 Mar 2021 23:27:34 +0000 (19:27 -0400)]
[Ada] Add documentation for the array fixed-lower-bound feature

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst: Add
documentation for the array fixed-lower-bound feature.
* gnat_rm.texi: Regenerate.

3 years ago[Ada] New debug switch to disable large static aggregates
Bob Duff [Tue, 16 Mar 2021 19:45:48 +0000 (15:45 -0400)]
[Ada] New debug switch to disable large static aggregates

gcc/ada/

* debug.adb: Document switch.
* exp_aggr.adb: If -gnatd_g was given, then do not bump the
limit to 500_000.

3 years ago[Ada] Warn on 'in out' param containing access in private type
Bob Duff [Tue, 16 Mar 2021 18:56:09 +0000 (14:56 -0400)]
[Ada] Warn on 'in out' param containing access in private type

gcc/ada/

* sem_util.ads, sem_util.adb (Has_Access_Values): Remove
Include_Internal parameter that was added in previous change.
* sem_warn.adb (Warnings_Off_E1): Back out E_Out_Parameter ==>
Formal_Kind change made previously. Check Is_Private_Type to
avoid warnings on private types. Misc cleanup.
* sem_attr.adb (Attribute_Has_Access_Values): Remove
Include_Internal parameter.

3 years ago[Ada] Remove dead code for overlapping actuals in prefix notation
Piotr Trojanek [Mon, 15 Mar 2021 13:53:29 +0000 (14:53 +0100)]
[Ada] Remove dead code for overlapping actuals in prefix notation

gcc/ada/

* sem_warn.adb (Warn_On_Overlapping_Actuals): Remove dead branch
for overlapping actuals in prefix notation.

3 years ago[Ada] Do not clear Is_True_Constant flag on imported constants
Eric Botcazou [Tue, 16 Mar 2021 09:24:39 +0000 (10:24 +0100)]
[Ada] Do not clear Is_True_Constant flag on imported constants

gcc/ada/

* sem_prag.adb (Process_Import_Or_Interface): Do not
artificially record a possible modification for a constant.

3 years ago[Ada] Code cleanups in exp_ch6.adb
Arnaud Charlet [Sun, 14 Mar 2021 17:32:59 +0000 (13:32 -0400)]
[Ada] Code cleanups in exp_ch6.adb

gcc/ada/

* exp_ch6.adb (Expand_Call_Helper): Code cleanups.

3 years ago[Ada] Update comments related to TBD
Arnaud Charlet [Mon, 15 Mar 2021 10:01:38 +0000 (11:01 +0100)]
[Ada] Update comments related to TBD

gcc/ada/

* exp_aggr.adb, exp_dist.adb, exp_unst.adb, sa_messages.ads,
sem_ch13.adb, sem_ch3.adb, sem_ch5.adb, sem_eval.adb,
sem_util.adb, sem_util.ads, sinfo.ads: Update comments.

3 years ago[Ada] Implement basic support for -fdiagnostics-format=json
Ghjuvan Lacambre [Wed, 27 Jan 2021 08:53:26 +0000 (09:53 +0100)]
[Ada] Implement basic support for -fdiagnostics-format=json

gcc/ada/

* back_end.adb (Scan_Back_End_Switches): Set Opt.JSON_Output to
True if -fdiagnostics-format=json option is found.
* back_end.ads (Scan_Compiler_Arguments): Mention
Opt.JSON_Output.
* errout.adb (Output_JSON_Message): New procedure.
(Output_Messages): If Opt.JSON_Output is True, print messages
with new Output_JSON_Message procedure.
* opt.ads: Declare JSON_Output variable.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Mention new -fdiagnostics-format option.
* gnat_ugn.texi: Regenerate.

3 years ago[Ada] Relax null exclusion mismatch check in Relaxed_RM_Semantics mode
Arnaud Charlet [Mon, 15 Mar 2021 07:45:35 +0000 (03:45 -0400)]
[Ada] Relax null exclusion mismatch check in Relaxed_RM_Semantics mode

gcc/ada/

* sem_ch6.adb (Null_Exclusions_Match): Relax null exclusion
mismatch check when Relaxed_RM_Semantics is set.

3 years ago[Ada] Replace Opt.Extensions_Allowed by Ada_Version
Arnaud Charlet [Sun, 14 Mar 2021 19:49:39 +0000 (15:49 -0400)]
[Ada] Replace Opt.Extensions_Allowed by Ada_Version

gcc/ada/

* fe.h, opt.adb, opt.ads, par-prag.adb, sem_prag.adb,
switch-c.adb (Extensions_Allowed): Replace by a function.
(Ada_Version_Type): Add new value Ada_With_Extensions, to
replace setting of Extensions_Allowed.  Update setting of
Extensions_Allowed.

3 years ago[Ada] GNAT.Compiler_Version and LTO
Arnaud Charlet [Fri, 12 Mar 2021 12:57:03 +0000 (07:57 -0500)]
[Ada] GNAT.Compiler_Version and LTO

gcc/ada/

* bindgen.adb (Gen_Output_File_Ada): Generate a new constant
GNAT_Version_Address.
* libgnat/g-comver.adb (GNAT_Version_Address): New;
(GNAT_Version): Use GNAT_Version_Address to disable LTO warning.

3 years ago[Ada] Ada2020: Special handling of types derived from runtime
Javier Miranda [Sat, 13 Mar 2021 19:47:59 +0000 (14:47 -0500)]
[Ada] Ada2020: Special handling of types derived from runtime

gcc/ada/

* einfo.ads (Is_Ada_2022_Only): Adding documentation.
* gen_il-fields.ads (Is_Ada_2022_Only): New flag.
* gen_il-gen-gen_entities.adb (Is_Ada_2022_Only): New flag.
* itypes.adb (Create_Null_Excluding_Itype): Inherit
Is_Ada_2022_Only.
* sem_ch3.adb (Check_Abstract_Overriding): Skip reporting error
on Ada 2022 only subprograms that require overriding if we are
not in Ada 2022 mode.
(Derive_Subprogram): Inherit Is_Ada_2022_Only.
* sem_ch6.adb (Check_Overriding_Indicator): Inherit
Is_Ada_2022_Only.
(New_Overloaded_Entity): Inherit Is_Ada_2022_Only.
* sem_ch7.adb (Declare_Inherited_Private_Subprograms): Inherit
Is_Ada_2022_Only.
(Preserve_Full_Attributes): Inherit Is_Ada_2022_Only.
* sem_disp.adb (Find_Hidden_Overridden_Primitive): Inherit
Is_Ada_2022_Only.
(Override_Dispatching_Operation): Inherit Is_Ada_2022_Only.
* sem_prag.adb (Analyze_Pragma): Allow form with argument for
Ada 2022.
* sem_type.adb: (Disambiguate): Deal with Is_Ada_2022_Only
* lib-xref.adb (Generate_Reference): Error on static and
dispatching calls to Ada 2022 subprograms that require
overriding if we are not in Ada 2022 mode; warn on other
references to Ada 2022 entities when not in Ada 2022 mode.
* sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): Inherit
Ada_2020_Only.
* libgnat/a-cdlili.ads (Empty): Adding pragma Ada_2022.
* libgnat/a-cidlli.ads (Empty): Adding pragma Ada_2022.
* libgnat/a-ciorma.ads (Empty): Adding pragma Ada_2022.
* libgnat/a-cobove.ads (Empty): Adding pragma Ada_2022.
* libgnat/a-coorma.ads (Empty): Adding pragma Ada_2022.
(New_Vector): Adding pragma Ada_2022.
(Insert_Vector): Adding pragma Ada_2022.
(Prepend_Vector): Adding pragma Ada_2022.
(Append_Vector): Adding pragma Ada_2022.

3 years agoAdd statistics counting to PHI-OPT
Andrew Pinski [Thu, 10 Jun 2021 09:22:12 +0000 (02:22 -0700)]
Add statistics counting to PHI-OPT

This should have been done before I started to work on connecting
PHI-OPT to match-and-simplify to see quickly if we miss anything
but it is better late than never.
Anyways there was no statistics counting in PHI-OPT before so adding
it is the right thing to do.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* tree-ssa-phiopt.c (replace_phi_edge_with_variable):
Add counting of how many times it is done.
(factor_out_conditional_conversion): Likewise.
(match_simplify_replacement): Likewise.
(value_replacement): Likewise.
(spaceship_replacement): Likewise.
(cond_store_replacement): Likewise.
(cond_if_else_store_replacement_1): Likewise.
(hoist_adjacent_loads): Likewise.

3 years agoDisallow pointer and offset types on some gimple
Andrew Pinski [Sun, 6 Jun 2021 02:03:06 +0000 (19:03 -0700)]
Disallow pointer and offset types on some gimple

While debugging PR 100925, I found that the gimple verifiers
don't reject NEGATE on pointer or offset type.
This patch adds the check on some unary and binary gimple which
should not have operated on pointer/offset types.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

gcc/ChangeLog:

* tree-cfg.c (verify_gimple_assign_unary): Reject point and offset
types on NEGATE_EXPR, ABS_EXPR, BIT_NOT_EXPR, PAREN_EXPR and CNONJ_EXPR.
(verify_gimple_assign_binary): Reject point and offset types on
MULT_EXPR, MULT_HIGHPART_EXPR, TRUNC_DIV_EXPR, CEIL_DIV_EXPR,
FLOOR_DIV_EXPR, ROUND_DIV_EXPR, TRUNC_MOD_EXPR, CEIL_MOD_EXPR,
FLOOR_MOD_EXPR, ROUND_MOD_EXPR, RDIV_EXPR, and EXACT_DIV_EXPR.

3 years agolibstdc++: Move ranges algos used by <ranges> into ranges_util.h
Patrick Palka [Fri, 18 Jun 2021 02:44:41 +0000 (22:44 -0400)]
libstdc++: Move ranges algos used by <ranges> into ranges_util.h

The <ranges> header defines simplified copies of some ranges algorithms
in order to avoid including the entirety of ranges_algo.h.  A subsequent
patch is going to want to use ranges::search in <ranges> as well, and
that algorithm is more complicated compared to the other copied ones.

So rather than additionally copying ranges::search into <ranges>, this
patch splits out all the ranges algos used by <ranges> (including
ranges::search) from ranges_algo.h to ranges_util.h, and deletes the
simplified copies in <ranges>.  This seems like the best place to
put these algorithms, as ranges_util.h is currently included only from
<ranges> and ranges_algo.h.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__find_fn, find, __find_if_fn)
(find_if, __find_if_not_fn, find_if_not, _in_in_result)
(__mismatch_fn, mismatch, __search_fn, search): Move to ...
* include/bits/ranges_util.h: ... here.
* include/std/ranges (__detail::find, __detail::find_if)
(__detail::find_if_not, __detail::mismatch): Remove.
(filter_view): Use ranges::find_if instead.
(drop_while_view): Use ranges::find_if_not instead.
(split_view): Use ranges::find and ranges::mismatch instead.

3 years agolibstdc++: Implement P2325 changes to default-constructibility of views
Patrick Palka [Fri, 18 Jun 2021 02:29:03 +0000 (22:29 -0400)]
libstdc++: Implement P2325 changes to default-constructibility of views

This implements the wording changes of P2325R3 "Views should not be
required to be default constructible".  Changes are relatively
straightforward, besides perhaps those to __box (which now stands
for copyable-box instead of semiregular-box) and __non_propagating_cache.

For __box, this patch implements the recommended practice to also avoid
std::optional when the boxed type is nothrow_move/copy_constructible.

For __non_propagating_cache, now that it's used by split_view::_M_current,
we need to add assignment from a value of the underlying type to the
subset of the std::optional API implemented for the cache (needed by
split_view::begin()).  Hence the new __non_propagating_cache::operator=
overload.

In passing, this fixes the undesirable list-init in the constructors of
the partial specialization of __box as reported in PR100475 comment #7.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (weakly_incrementable): Remove
default_initializable requirement.
* include/bits/ranges_base.h (ranges::view): Likewise.
* include/bits/ranges_util.h (subrange): Constrain the default
ctor.
* include/bits/stl_iterator.h (back_insert_iterator): Remove the
default ctor.
(front_insert_iterator): Likewise.
(insert_iterator): Likewise.  Remove NSDMIs.
(common_iterator): Constrain the default ctor.
(counted_iterator): Likewise.
* include/bits/stream_iterator.h (ostream_iterator): Remove the
default ctor.
* include/std/ranges (__detail::__box::operator=): Handle
self-assignment in the primary template.
(__detail::__box): In the partial specialization: adjust
constraints as per P2325.  Add specialized operator= for the
case when the wrapped type is not copyable.  Constrain the
default ctor.  Avoid list-initialization.
(single_view): Constraint the default ctor.
(iota_view): Relax semiregular constraint to copyable.
Constrain the default ctor.
(iota_view::_Iterator): Constraint the default ctor.
(basic_istream_view): Remove the default ctor.  Remove NSDMIs.
Remove redundant checks for empty _M_stream.
(basic_istream_view::_Iterator): Likewise.
(ref_view): Remove the default ctor.  Remove NSDMIs.
(ref_view::_Iterator): Constrain the default ctor.
(__detail::__non_propagating_cache::operator=): Define overload
for assigning from a value of the underlying type.
(filter_view): Likewise.
(filter_view::_Iterator): Likewise.
(transform_view): Likewise.
(transform_view::_Iterator): Likewise.
(take_view): Likewise.
(take_view::_Iterator): Likewise.
(take_while_view): Likewise.
(take_while_view::_Iterator): Likewise.
(drop_while_view): Likewise.
(drop_while_view::_Iterator): Likewise.
(join_view): Likewise.
(split_view::_OuterIter::__current): Adjust after changing the
type of _M_current.
(split_view::_M_current): Wrap it in a __non_propagating_cache.
(split_view::split_view): Constrain the default ctor.
(common_view): Constrain the default ctor.
(reverse_view): Likewise.
(elements_view): Likewise.
* include/std/span (enable_view<span<_ElementType, _Extent>>):
Define this partial specialization to true unconditionally.
* include/std/version (__cpp_lib_ranges): Adjust value.
* testsuite/24_iterators/back_insert_iterator/constexpr.cc:
Don't attempt to default construct a back_insert_iterator.
* testsuite/24_iterators/front_insert_iterator/constexpr.cc:
Don't attempt to default construct a front_insert_iterator.
* testsuite/24_iterators/insert_iterator/constexpr.cc:
Don't attempt to default construct an insert_iterator.
* testsuite/24_iterators/ostream_iterator/requirements/constexpr.cc:
Remove this test for default constructibility of ostream_iterator.
* testsuite/std/ranges/97600.cc: Don't attempt to default
construct a basic_istream_view.
* testsuite/std/ranges/adaptors/detail/semiregular_box.cc:
Rename to ...
* testsuite/std/ranges/adaptors/detail/copyable_box.cc: ... this.
(test02): Adjust now that __box is copyable-box not
semiregular-box.
(test03): New test.
* testsuite/std/ranges/p2325.cc: New test.
* testsuite/std/ranges/single_view.cc (test06): New test.
* testsuite/std/ranges/view.cc: Adjust now that view doesn't
require default_initializable.

3 years agoAdd IEEE 128-bit min/max support on PowerPC.
Michael Meissner [Fri, 18 Jun 2021 02:05:16 +0000 (22:05 -0400)]
Add IEEE 128-bit min/max support on PowerPC.

This patch adds the support for the IEEE 128-bit floating point C minimum and
maximum instructions.  The next patch will add the support for using the
compare and set mask instruction to implement conditional moves.

This patch does not try to re-use the code used for SF/DF min/max
support.  It defines a separate insn for the IEEE 128-bit support.  It
uses the code iterator <minmax> to simplify adding both operations.

GCC will not convert ternary operations into using min/max instructions
provided in this patch unless the user uses -Ofast.  The next patch that adds
conditional move instructions will enable the ternary conversion in many cases.

gcc/
2021-06-17  Michael Meissner  <meissner@linux.ibm.com>

* config/rs6000/rs6000.c (rs6000_emit_minmax): Add support for ISA
3.1 IEEE 128-bit floating point xsmaxcqp/xsmincqp instructions.
* config/rs6000/rs6000.md (s<minmax><mode>3, IEEE128 iterator):
New insns.

gcc/testsuite/
2021-06-17  Michael Meissner  <meissner@linux.ibm.com>

* gcc.target/powerpc/float128-minmax-2.c: New test.

3 years agoDaily bump.
GCC Administrator [Fri, 18 Jun 2021 00:16:58 +0000 (00:16 +0000)]
Daily bump.

3 years agolibstdc++: Simplify constexpr checks in std::char_traits [PR 91488]
Jonathan Wakely [Thu, 17 Jun 2021 13:11:22 +0000 (14:11 +0100)]
libstdc++: Simplify constexpr checks in std::char_traits [PR 91488]

This removes the helper functions added by r8-1294 to detect whether the
char_traits member functions can be evaluated at compile time. Instead,
we can just use __builtin_constant_evaluated directly, which is well
supported by non-GCC compilers by now.

As a result, there is a chance that those members will no longer be
usable in constant expressions when using old versions of non-GCC
compilers. Make the relevant feature test macros depend on the
availability of __builtin_constant_evaluated, so they are defined only
when the feature is actualyl available.

The new testcase from the PR is added to the libitm testsuite, because
that's where we can be sure it's OK to use the -fgnu-tm option.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/91488

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (__cpp_lib_constexpr_string): Only
define when is_constant_evaluated is available.
* include/bits/char_traits.h (__cpp_lib_constexpr_char_traits):
Likewise.
(__constant_string_p, __constant_array_p): Remove.
(char_traits): Use is_constant_evaluated directly.
* include/std/version (__cpp_lib_constexpr_char_traits)
(__cpp_lib_constexpr_string): Only define when
is_constant_evaluated is available.

libitm/ChangeLog:

* testsuite/libitm.c++/libstdc++-pr91488.C: New test.

3 years agoc++: deleted after first declaration [PR101106]
Jason Merrill [Thu, 17 Jun 2021 19:31:15 +0000 (15:31 -0400)]
c++: deleted after first declaration [PR101106]

An explicitly deleted function must be deleted on its first declaration.  We
were diagnosing this error only with -Wpedantic, but always giving the
"previous declaration" note.  This patch removes the -Wpedantic dependency
and also makes the note depend on the previous diagnostic.

PR c++/101106

gcc/cp/ChangeLog:

* decl.c (duplicate_decls): Make 'deleted after first declaration'
pedwarn on by default.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/deleted15.C: New test.

3 years agomklog: add subject line skeleton
Jason Merrill [Wed, 16 Jun 2021 20:46:38 +0000 (16:46 -0400)]
mklog: add subject line skeleton

In the recent gcc-commit-mklog thread on gcc@ it occurred to me that the
command could also fill in part of the subject line.  If the first PR is
foo/1234, and the commit does not yet have a subject line, this will add

foo: [PR1234]

contrib/ChangeLog:

* mklog.py: Add an initial component: [PRnnnnn] line when
we have a PR.