]> gcc.gnu.org Git - gcc.git/log
gcc.git
21 months agoaarch64: fix off-by-one in reading cpuinfo
Philipp Tomsich [Mon, 3 Oct 2022 19:59:50 +0000 (21:59 +0200)]
aarch64: fix off-by-one in reading cpuinfo

Fixes: 341573406b39
Don't subtract one from the result of strnlen() when trying to point
to the first character after the current string.  This issue would
cause individual characters (where the 128 byte buffers are stitched
together) to be lost.

gcc/ChangeLog:

* config/aarch64/driver-aarch64.c (readline): Fix off-by-one.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/cpunative/info_18: New test.
* gcc.target/aarch64/cpunative/native_cpu_18.c: New test.

(cherry picked from commit b1cfbccc41de6aec950c0f662e7e85ab34bfff8a)

21 months agoDaily bump.
GCC Administrator [Wed, 26 Oct 2022 00:20:05 +0000 (00:20 +0000)]
Daily bump.

21 months agoIBM zSystems: Fix function_ok_for_sibcall [PR106355]
Stefan Schulze Frielinghaus [Tue, 25 Oct 2022 08:37:19 +0000 (10:37 +0200)]
IBM zSystems: Fix function_ok_for_sibcall [PR106355]

For a parameter with BLKmode we cannot use REG_NREGS in order to
determine the number of consecutive registers.  Streamlined this with
the implementation of s390_function_arg.

Fix some indentation whitespace, too.

gcc/ChangeLog:

PR target/106355
* config/s390/s390.c (s390_call_saved_register_used): For a
parameter with BLKmode fix determining number of consecutive
registers.

gcc/testsuite/ChangeLog:

* gcc.target/s390/pr106355.h: Common code for new tests.
* gcc.target/s390/pr106355-1.c: New test.
* gcc.target/s390/pr106355-2.c: New test.
* gcc.target/s390/pr106355-3.c: New test.

(cherry picked from commit cb994acc08b67f26a54e7c5dc1f4995a2ce24d98)

21 months agoi386: fix pedantic warning
Martin Liska [Tue, 25 Oct 2022 04:16:03 +0000 (06:16 +0200)]
i386: fix pedantic warning

PR target/107364

gcc/ChangeLog:

* common/config/i386/i386-cpuinfo.h (enum processor_vendor):
Fix pedantic warning.

(cherry picked from commit f3f000b7689ce9eb6364808072025672af1e4e1b)

21 months agox86: fix VENDOR_MAX enum value
Martin Liska [Mon, 24 Oct 2022 13:34:39 +0000 (15:34 +0200)]
x86: fix VENDOR_MAX enum value

PR target/107364

gcc/ChangeLog:

* common/config/i386/i386-cpuinfo.h (enum processor_vendor):
  Reorder enum values as BUILTIN_VENDOR_MAX should not point
  in the middle of the valid enum values.

(cherry picked from commit f751bf4c5d1aaa1aacfcbdec62881c5ea1175dfb)

21 months agoDaily bump.
GCC Administrator [Tue, 25 Oct 2022 00:20:38 +0000 (00:20 +0000)]
Daily bump.

21 months agoc++: Fix ICE with -Wmismatched-tags [PR105725]
Marek Polacek [Fri, 27 May 2022 14:51:30 +0000 (10:51 -0400)]
c++: Fix ICE with -Wmismatched-tags [PR105725]

Here we ICE with -Wmismatched-tags on something like

  template <class T>
  bool B<T, enable_if_t<is_class_v<class T::foo>>>;

Specifically, the "class T::foo" bit.  There, class_decl_loc_t::add gets
a TYPENAME_TYPE as TYPE, rather than a class/union type, so checking
TYPE_BEING_DEFINED will crash.  I think it's OK to allow a TYPENAME_TYPE to
slip into that function; we just shouldn't consider the 'class' tag redundant
(which works as a 'typename').  In fact, every other compiler *requires* it.

PR c++/105725

gcc/cp/ChangeLog:

* parser.c (class_decl_loc_t::add): Check CLASS_TYPE_P.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wmismatched-tags-10.C: New test.

(cherry picked from commit d822f4bbd714c6595f70cc68888dcebecfb6662d)

21 months agoDaily bump.
GCC Administrator [Mon, 24 Oct 2022 00:19:17 +0000 (00:19 +0000)]
Daily bump.

21 months agoFortran: error recovery with references of bad array constructors [PR105633]
Harald Anlauf [Wed, 19 Oct 2022 20:37:56 +0000 (22:37 +0200)]
Fortran: error recovery with references of bad array constructors [PR105633]

gcc/fortran/ChangeLog:

PR fortran/105633
* expr.c (find_array_section): Move check for NULL pointers so
that both subscript triplets and vector subscripts are covered.

gcc/testsuite/ChangeLog:

PR fortran/105633
* gfortran.dg/pr105633.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit ecb20df4fa6d99daa635c7fb662dc0554610777e)

21 months agoDaily bump.
GCC Administrator [Sun, 23 Oct 2022 00:19:49 +0000 (00:19 +0000)]
Daily bump.

21 months agoDaily bump.
GCC Administrator [Sat, 22 Oct 2022 00:19:41 +0000 (00:19 +0000)]
Daily bump.

21 months agoDaily bump.
GCC Administrator [Fri, 21 Oct 2022 00:20:10 +0000 (00:20 +0000)]
Daily bump.

21 months agoaarch64: Prevent generation of /M BRKAS and BRKBS
Richard Sandiford [Thu, 20 Oct 2022 22:33:39 +0000 (23:33 +0100)]
aarch64: Prevent generation of /M BRKAS and BRKBS

Bit of a brown-paper-bag bug, but: GCC was generating
non-existent merging forms of BRKAS and BRKBS.  Those
instructions only support zero predication (although
BRKA and BRKB support both).

gcc/
* config/aarch64/aarch64-sve.md (*aarch64_brk<brk_op>_cc): Remove
merging alternative.
(*aarch64_brk<brk_op>_ptest): Likewise.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/brka_1.c: Expect a separate
PTEST instruction.
* gcc.target/aarch64/sve/acle/general/brkb_1.c: Likewise.

(cherry picked from commit 57675c7f92a3bd3ca8dae1faac7f2f51d40e0f9e)

21 months agoaarch64: Fix matching of BRKNS
Richard Sandiford [Thu, 20 Oct 2022 22:33:38 +0000 (23:33 +0100)]
aarch64: Fix matching of BRKNS

Unlike other flag-setting SVE instructions, BRKNS sets the flags
based on an all-true governing predicate, rather than the GP operand.

gcc/
* config/aarch64/iterators.md (SVE_BRKP): New iterator.
* config/aarch64/aarch64-sve.md (*aarch64_brkn_cc): New pattern.
(*aarch64_brkn_ptest): Likewise.
(*aarch64_brk<brk_op>_cc): Restrict to SVE_BRKP.
(*aarch64_brk<brk_op>_ptest): Likewise.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/brkn_1.c: Expect separate
PTEST instructions.
* gcc.target/aarch64/sve/acle/general/brkn_2.c: New test.

(cherry picked from commit 6bec66640597e2604f51fc1642c7d279164cd442)

21 months agoaarch64: Define __ARM_FEATURE_RCPC
Richard Sandiford [Thu, 20 Oct 2022 22:33:38 +0000 (23:33 +0100)]
aarch64: Define __ARM_FEATURE_RCPC

https://github.com/ARM-software/acle/pull/199 adds a new feature
macro for RCPC, for use in things like inline assembly.  This patch
adds the associated support to GCC.

Also, RCPC is required for Armv8.3-A and later, but the armv8.3-a
entry didn't include it.  This was probably harmless in practice
since GCC simply ignored the extension until now.  (The GAS
definition is OK.)

gcc/
* config/aarch64/aarch64.h (AARCH64_FL_FOR_ARCH8_3): Add
AARCH64_FL_RCPC.
(AARCH64_ISA_RCPC): New macro.
* config/aarch64/aarch64-cores.def (thunderx3t110, zeus, neoverse-v1)
(neoverse-512tvb, saphira): Remove RCPC from these Armv8.3-A+ cores.
* config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Define
__ARM_FEATURE_RCPC when appropriate.

gcc/testsuite/
* gcc.target/aarch64/pragma_cpp_predefs_1.c: Add RCPC tests.

21 months agoDaily bump.
GCC Administrator [Thu, 20 Oct 2022 00:22:16 +0000 (00:22 +0000)]
Daily bump.

21 months agors6000: Fix the condition with frame_pointer_needed_indeed [PR96072]
Kewen Lin [Mon, 26 Sep 2022 05:33:18 +0000 (00:33 -0500)]
rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]

As PR96072 shows, the code adding REG_CFA_DEF_CFA reg note
makes one assumption that we have emitted one insn which
restores the frame pointer previously.  That part of code
was guarded with flag frame_pointer_needed before, it was
consistent, but it was replaced with flag
frame_pointer_needed_indeed since commit r10-7981.  It
caused ICE due to unexpected NULL insn.

PR target/96072

gcc/ChangeLog:

* config/rs6000/rs6000-logue.c (rs6000_emit_epilogue): Update the
condition for adding REG_CFA_DEF_CFA reg note with
frame_pointer_needed_indeed.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr96072.c: New test.

(cherry picked from commit 5be0950d22209f5ba69d244387228e12389a8470)

21 months agoDaily bump.
GCC Administrator [Wed, 19 Oct 2022 00:21:28 +0000 (00:21 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Tue, 18 Oct 2022 00:19:47 +0000 (00:19 +0000)]
Daily bump.

22 months agoFix register count when not splitting Complex IEEE 128-bit args.
Pat Haugen [Mon, 17 Oct 2022 20:11:42 +0000 (15:11 -0500)]
Fix register count when not splitting Complex IEEE 128-bit args.

For ABI_V4, we do not split complex args. This created a problem because
even though an arg would be passed in two VSX regs, we were only advancing the
function arg counter by one VSX register. Fixed with this patch.

(backported commit 2ee68beee709e48fce85b8892ff9985acc6a91a8)

gcc/
PR target/99685
* config/rs6000/rs6000-call.c (rs6000_function_arg_advance_1): Bump
register count when not splitting IEEE 128-bit Complex.

22 months agotree-optimization/106934 - avoid BIT_FIELD_REF of bitfields
Richard Biener [Wed, 14 Sep 2022 07:00:35 +0000 (09:00 +0200)]
tree-optimization/106934 - avoid BIT_FIELD_REF of bitfields

The following avoids creating BIT_FIELD_REF of bitfields in
update-address-taken.  The patch doesn't implement punning to
a full precision integer type but leaves a comment according to
that.

PR tree-optimization/106934
* tree-ssa.c (non_rewritable_mem_ref_base): Avoid BIT_FIELD_REFs
of bitfields.
(maybe_rewrite_mem_ref_base): Likewise.

* gfortran.dg/pr106934.f90: New testcase.

(cherry picked from commit 05f5c42cb42c5088187d44cc45a5f671d19ad8c5)

22 months agotree-optimization/106892 - avoid invalid pointer association in predcom
Richard Biener [Fri, 9 Sep 2022 10:06:38 +0000 (12:06 +0200)]
tree-optimization/106892 - avoid invalid pointer association in predcom

When predictive commoning builds a reference for iteration N it
prematurely associates a constant offset into the MEM_REF offset
operand which can be invalid if the base pointer then points
outside of an object which alias-analysis does not consider valid.

PR tree-optimization/106892
* tree-predcom.c (ref_at_iteration): Do not associate the
constant part of the offset into the MEM_REF offset
operand, across a non-zero offset.

* gcc.dg/torture/pr106892.c: New testcase.

(cherry picked from commit a8b0b13da7379feb31950a9d2ad74b98a29c547f)

22 months agotree-optimization/106189 - avoid division by zero exception
Richard Biener [Mon, 25 Jul 2022 15:24:57 +0000 (17:24 +0200)]
tree-optimization/106189 - avoid division by zero exception

The diagnostic code can end up with zero sized array elements
with T[][0] and the wide-int code nicely avoids exceptions when
dividing by zero in one codepath but not in another.  The following
fixes the exception by using wide-int in both paths.

PR tree-optimization/106189
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref):
Divide using offset_ints.

* gcc.dg/pr106189.c: New testcase.

(cherry picked from commit bb04f9f23ac0dee2c003118c85372ece50a52220)

22 months agoDaily bump.
GCC Administrator [Mon, 17 Oct 2022 00:19:43 +0000 (00:19 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 16 Oct 2022 00:19:13 +0000 (00:19 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sat, 15 Oct 2022 00:20:42 +0000 (00:20 +0000)]
Daily bump.

22 months agoaarch64: Implement ACLE Data Intrinsics
Andre Vieira [Fri, 14 Oct 2022 15:06:33 +0000 (16:06 +0100)]
aarch64: Implement ACLE Data Intrinsics

This patch adds support for the ACLE Data Intrinsics to the AArch64 port.

gcc/ChangeLog:

2022-07-25  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* config/aarch64/aarch64.md (rbit<mode>2): Rename this ...
(@aarch64_rbit<mode>): ... to this and change it in...
(ffs<mode>2,ctz<mode>2): ... here.
(@aarch64_rev16<mode>): New.
* config/aarch64/aarch64-builtins.c: (aarch64_builtins):
Define the following enum AARCH64_REV16, AARCH64_REV16L,
AARCH64_REV16LL, AARCH64_RBIT, AARCH64_RBITL, AARCH64_RBITLL.
(aarch64_init_data_intrinsics): New.
(aarch64_general_init_builtins): Add call to
aarch64_init_data_intrinsics.
(aarch64_expand_builtin_data_intrinsic): New.
(aarch64_general_expand_builtin): Add call to
aarch64_expand_builtin_data_intrinsic.
* config/aarch64/arm_acle.h (__clz, __clzl, __clzll, __cls, __clsl,
__clsll, __rbit, __rbitl, __rbitll, __rev, __revl, __revll, __rev16,
__rev16l, __rev16ll, __ror, __rorl, __rorll, __revsh): New.

gcc/testsuite/ChangeLog:

2022-07-25  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* gcc.target/aarch64/acle/data-intrinsics.c: New test.

(cherry picked from commit eb966d393dfdfd2c80994e4bfcc0dddf85828a73)

22 months agoFix PR target/107248
Eric Botcazou [Fri, 14 Oct 2022 09:52:04 +0000 (11:52 +0200)]
Fix PR target/107248

This is the infamous PR rtl-optimization/38644 rearing its ugly head for
leaf functions on SPARC more than a decade later...  Richard E.'s generic
solution has never been implemented so let's do as other RISC back-ends did.

gcc/
PR target/107248
* config/sparc/sparc.c (sparc_expand_prologue): Emit a frame
blockage for leaf functions.
(sparc_flat_expand_prologue): Emit frame instead of full blockage.
(sparc_expand_epilogue): Emit a frame blockage for leaf functions.
(sparc_flat_expand_epilogue): Emit frame instead of full blockage.

22 months agoDaily bump.
GCC Administrator [Fri, 14 Oct 2022 00:20:07 +0000 (00:20 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Thu, 13 Oct 2022 00:21:48 +0000 (00:21 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Wed, 12 Oct 2022 00:19:41 +0000 (00:19 +0000)]
Daily bump.

22 months agolto/106540 - fix LTO tree input wrt dwarf2out_register_external_die
Richard Biener [Mon, 8 Aug 2022 07:07:23 +0000 (09:07 +0200)]
lto/106540 - fix LTO tree input wrt dwarf2out_register_external_die

I've revisited the earlier two workarounds for dwarf2out_register_external_die
getting duplicate entries.  It turns out that r11-525-g03d90a20a1afcb
added dref_queue pruning to lto_input_tree but decl reading uses that
to stream in DECL_INITIAL even when in the middle of SCC streaming.
When that SCC then gets thrown away we can end up with debug nodes
registered which isn't supposed to happen.  The following adjusts
the DECL_INITIAL streaming to go the in-SCC way, using lto_input_tree_1,
since no SCCs are expected at this point, just refs.

PR lto/106540
PR lto/106334
* lto-streamer-in.c (lto_read_tree_1): Use lto_input_tree_1
to input DECL_INITIAL, avoiding to commit drefs.

(cherry picked from commit 4769ac6c5dfde2810a0266fe388211edc644e623)

22 months agotree-optimization/106513 - fix mistake in bswap symbolic number shifts
Richard Biener [Wed, 10 Aug 2022 13:45:22 +0000 (15:45 +0200)]
tree-optimization/106513 - fix mistake in bswap symbolic number shifts

This fixes a mistake in typing a local variable in the symbolic
shift routine.

PR tree-optimization/106513
* gimple-ssa-store-merging.c (do_shift_rotate): Use uint64_t
for head_marker.

* gcc.dg/torture/pr106513.c: New testcase.

(cherry picked from commit f675afa4eeac9910a2c085a95aa04d6d9f2fd8d6)

22 months agomiddle-end/106331 - fix mem attributes for string op arguments
Richard Biener [Tue, 19 Jul 2022 07:57:22 +0000 (09:57 +0200)]
middle-end/106331 - fix mem attributes for string op arguments

get_memory_rtx tries hard to come up with a MEM_EXPR to record
in the memory attributes but in the last fallback fails to properly
account for an unknown offset and thus, as visible in this testcase,
incorrect alignment computed from set_mem_attributes.  The following
rectifies both parts.

PR middle-end/106331
* builtins.c (get_memory_rtx): Compute alignment from
the original address and set MEM_OFFSET to unknown when
we create a MEM_EXPR from the base object of the address.

* gfortran.dg/pr106331.f90: New testcase.

(cherry picked from commit e4ff11a8f2e80adb8ada69bf35ee6a1ab18a9c85)

22 months agotree-optimization/106131 - wrong code with FRE rewriting
Richard Biener [Thu, 30 Jun 2022 08:33:40 +0000 (10:33 +0200)]
tree-optimization/106131 - wrong code with FRE rewriting

The following makes sure to not use the original TBAA type for
looking up a value across an aggregate copy when we had to offset
the read.

2022-06-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/106131
* tree-ssa-sccvn.c (vn_reference_lookup_3): Force alias-set
zero when offsetting the read looking through an aggregate
copy.

* g++.dg/torture/pr106131.C: New testcase.

(cherry picked from commit 9701432ff79926a5dd3303be3417e0bd0c24140b)

22 months agotree-optimization/106112 - fix CSE from wider operation
Richard Biener [Tue, 28 Jun 2022 11:57:29 +0000 (13:57 +0200)]
tree-optimization/106112 - fix CSE from wider operation

The following fixes a mistake in looking up an extended operand
in the CSE of a truncated operation.

2022-06-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/106112
* tree-ssa-sccvn.c (valueized_wider_op): Properly extend
a constant operand according to its type.

* gcc.dg/torture/pr106112.c: New testcase.

(cherry picked from commit 2dbb45d6dc0d20dc159b3d8e27ebb6825074827a)

22 months agomiddle-end/106027 - fix types in needle folding
Richard Biener [Mon, 20 Jun 2022 11:40:50 +0000 (13:40 +0200)]
middle-end/106027 - fix types in needle folding

The fold_to_nonsharp_ineq_using_bound folding ends up creating invalid
typed IL which confuses later foldings.  The following fixes that.

2022-06-20  Richard Biener  <rguenther@suse.de>

PR middle-end/106027
* fold-const.c (fold_to_nonsharp_ineq_using_bound): Use the
type of the prevailing comparison for the new comparison type.
(fold_binary_loc): Use proper types for the A < X && A + 1 > Y
to A < X && A >= Y folding.

* gcc.dg/pr106027.c: New testcase.

(cherry picked from commit 713f2fd923442b1be620a44240ddf786ae0ab476)

22 months agoDaily bump.
GCC Administrator [Tue, 11 Oct 2022 00:19:38 +0000 (00:19 +0000)]
Daily bump.

22 months agofortran: Move clobbers after evaluation of all arguments [PR106817]
Mikael Morin [Sat, 3 Sep 2022 09:58:47 +0000 (11:58 +0200)]
fortran: Move clobbers after evaluation of all arguments [PR106817]

For actual arguments whose dummy is INTENT(OUT), we used to generate
clobbers on them at the same time we generated the argument reference
for the function call.  This was wrong if for an argument coming
later, the value expression was depending on the value of the just-
clobbered argument, and we passed an undefined value in that case.

With this change, clobbers are collected separatedly and appended
to the procedure call preliminary code after all the arguments have been
evaluated.

PR fortran/106817

gcc/fortran/ChangeLog:

* trans-expr.c (gfc_conv_procedure_call): Collect all clobbers
to their own separate block.  Append the block of clobbers to
the procedure preliminary block after the argument evaluation
codes for all the arguments.

gcc/testsuite/ChangeLog:

* gfortran.dg/intent_optimize_4.f90: New test.

(cherry picked from commit 29919bf3b6449bafd02e795abbb1966e3990c1fc)

22 months agofortran: Fix invalid function decl clobber ICE [PR105012]
Mikael Morin [Mon, 29 Aug 2022 09:19:29 +0000 (11:19 +0200)]
fortran: Fix invalid function decl clobber ICE [PR105012]

The fortran frontend, as result symbol for a function without
declared result symbol, uses the function symbol itself.  This caused
an invalid clobber of a function decl to be emitted, leading to an
ICE, whereas the intended behaviour was to clobber the function result
variable.  This change fixes the problem by getting the decl from the
just-retrieved variable reference after the call to
gfc_conv_expr_reference, instead of copying it from the frontend symbol.

PR fortran/105012

gcc/fortran/ChangeLog:

* trans-expr.c (gfc_conv_procedure_call): Retrieve variable
from the just calculated variable reference.

gcc/testsuite/ChangeLog:

* gfortran.dg/intent_out_15.f90: New test.

(cherry picked from commit edaf1e005c90b311c39b46d85cea17befbece112)

22 months agofortran: Move the clobber generation code
Mikael Morin [Wed, 31 Aug 2022 09:00:45 +0000 (11:00 +0200)]
fortran: Move the clobber generation code

This change inlines the clobber generation code from
gfc_conv_expr_reference to the single caller from where the add_clobber
flag can be true, and removes the add_clobber argument.

What motivates this is the standard making the procedure call a cause
for a variable to become undefined, which translates to a clobber
generation, so clobber generation should be closely related to procedure
call generation, whereas it is rather orthogonal to variable reference
generation.  Thus the generation of the clobber feels more appropriate
in gfc_conv_procedure_call than in gfc_conv_expr_reference.

Behaviour remains unchanged.

gcc/fortran/ChangeLog:

* trans.h (gfc_conv_expr_reference): Remove add_clobber
argument.
* trans-expr.c (gfc_conv_expr_reference): Ditto. Inline code
depending on add_clobber and conditions controlling it ...
(gfc_conv_procedure_call): ... to here.

(cherry picked from commit 2b393f6f83903cb836676bbd042c1b99a6e7e6f7)

22 months agoDaily bump.
GCC Administrator [Mon, 10 Oct 2022 00:19:26 +0000 (00:19 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 9 Oct 2022 00:20:41 +0000 (00:20 +0000)]
Daily bump.

22 months agoFortran: Fix ICE and wrong code for assumed-rank arrays [PR100029, PR100040]
José Rui Faustino de Sousa [Sun, 25 Sep 2022 20:48:55 +0000 (22:48 +0200)]
Fortran: Fix ICE and wrong code for assumed-rank arrays [PR100029, PR100040]

gcc/fortran/ChangeLog:

PR fortran/100040
PR fortran/100029
* trans-expr.c (gfc_conv_class_to_class): Add code to have
assumed-rank arrays recognized as full arrays and fix the type
of the array assignment.
(gfc_conv_procedure_call): Change order of code blocks such that
the free of ALLOCATABLE dummy arguments with INTENT(OUT) occurs
first.

gcc/testsuite/ChangeLog:

PR fortran/100029
* gfortran.dg/PR100029.f90: New test.

PR fortran/100040
* gfortran.dg/PR100040.f90: New test.

(cherry picked from commit 5299155bb80e90df822e1eebc9f9a0c8e4505a46)

22 months agoDaily bump.
GCC Administrator [Sat, 8 Oct 2022 00:21:12 +0000 (00:21 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Fri, 7 Oct 2022 00:20:02 +0000 (00:20 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Thu, 6 Oct 2022 09:34:06 +0000 (09:34 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Wed, 5 Oct 2022 13:05:54 +0000 (13:05 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Tue, 4 Oct 2022 09:18:22 +0000 (09:18 +0000)]
Daily bump.

22 months agogcc/config/t-i386: add build dependencies on i386-builtin-types.inc
Sergei Trofimovich [Fri, 16 Sep 2022 17:33:11 +0000 (18:33 +0100)]
gcc/config/t-i386: add build dependencies on i386-builtin-types.inc

i386-builtin-types.inc is included indirectly via i386-builtins.h
into 4 files: i386.cc i386-builtins.cc i386-expand.cc i386-features.cc

Only i386.cc dependency was present in gcc/config/t-i386 makefile.

As a result parallel builds occasionally fail as:

    g++ ... -o i386-builtins.o ... ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc
    In file included from ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc:92:
    ../../gcc-13-20220911/gcc/config/i386/i386-builtins.h:25:10:
     fatal error: i386-builtin-types.inc: No such file or directory
       25 | #include "i386-builtin-types.inc"
          |          ^~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    make[3]: *** [../../gcc-13-20220911/gcc/config/i386/t-i386:54: i386-builtins.o]
      Error 1 shuffle=1663349189

gcc/
PR target/107064
* config/i386/t-i386: Add build-time dependencies against
i386-builtin-types.inc to i386-builtins.o, i386-expand.o,
i386-features.o.

(cherry picked from commit ef3165736d9daafba88adb2db65b2e8ebf0024ca)

22 months agoDaily bump.
GCC Administrator [Mon, 3 Oct 2022 00:20:26 +0000 (00:20 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 2 Oct 2022 00:20:38 +0000 (00:20 +0000)]
Daily bump.

22 months agoFortran: Fix function attributes [PR100132]
José Rui Faustino de Sousa [Mon, 19 Sep 2022 20:00:45 +0000 (22:00 +0200)]
Fortran: Fix function attributes [PR100132]

gcc/fortran/ChangeLog:

PR fortran/100132
* trans-types.c (create_fn_spec): Fix function attributes when
passing polymorphic pointers.

gcc/testsuite/ChangeLog:

PR fortran/100132
* gfortran.dg/PR100132.f90: New test.

(cherry picked from commit be60aa5b608b5f09fadfeff852a46589ac311a42)

22 months agoDaily bump.
GCC Administrator [Sat, 1 Oct 2022 00:20:32 +0000 (00:20 +0000)]
Daily bump.

22 months agoFortran: error recovery while simplifying intrinsic UNPACK [PR107054]
Harald Anlauf [Tue, 27 Sep 2022 18:54:28 +0000 (20:54 +0200)]
Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]

gcc/fortran/ChangeLog:

PR fortran/107054
* simplify.c (gfc_simplify_unpack): Replace assert by condition
that terminates simplification when there are not enough elements
in the constructor of argument VECTOR.

gcc/testsuite/ChangeLog:

PR fortran/107054
* gfortran.dg/pr107054.f90: New test.

(cherry picked from commit 78bc6497fc61bbdacfb416ee0246a775360d9af6)

22 months agoFortran: fix ICE in generate_coarray_sym_init [PR82868]
Harald Anlauf [Wed, 21 Sep 2022 17:55:30 +0000 (19:55 +0200)]
Fortran: fix ICE in generate_coarray_sym_init [PR82868]

gcc/fortran/ChangeLog:

PR fortran/82868
* trans-decl.c (generate_coarray_sym_init): Skip symbol
if attr.associate_var.

gcc/testsuite/ChangeLog:

PR fortran/82868
* gfortran.dg/associate_26a.f90: New test.

(cherry picked from commit bc71318a91286b5f00e88f07aab818ac82510692)

22 months agoFortran: NULL pointer dereference in invalid simplification [PR106985]
Harald Anlauf [Tue, 20 Sep 2022 20:23:43 +0000 (22:23 +0200)]
Fortran: NULL pointer dereference in invalid simplification [PR106985]

gcc/fortran/ChangeLog:

PR fortran/106985
* expr.c (gfc_simplify_expr): Avoid NULL pointer dereference.

gcc/testsuite/ChangeLog:

PR fortran/106985
* gfortran.dg/pr106985.f90: New test.

(cherry picked from commit 8dbb15bc2d019488240c1e69d93121b0347ac092)

22 months agoFortran: improve error recovery while simplifying size of bad array [PR103694]
Harald Anlauf [Tue, 23 Aug 2022 20:16:14 +0000 (22:16 +0200)]
Fortran: improve error recovery while simplifying size of bad array [PR103694]

gcc/fortran/ChangeLog:

PR fortran/103694
* simplify.c (simplify_size): The size expression of an array cannot
be simplified if an error occurs while resolving the array spec.

gcc/testsuite/ChangeLog:

PR fortran/103694
* gfortran.dg/pr103694.f90: New test.

(cherry picked from commit 55d8c5409325001c89c35c3d04d425dec9127146)

22 months agoDaily bump.
GCC Administrator [Fri, 30 Sep 2022 00:21:52 +0000 (00:21 +0000)]
Daily bump.

22 months agoi386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256
H.J. Lu [Tue, 27 Sep 2022 23:19:11 +0000 (16:19 -0700)]
i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256

encodekey128 and encodekey256 operations clear XMM4-XMM6.  But it is
documented that XMM4-XMM6 are reserved for future usages and software
should not rely upon them being zeroed.  Change encodekey128 and
encodekey256 to clobber XMM4-XMM6.

gcc/

PR target/107061
* config/i386/predicates.md (encodekey128_operation): Check
XMM4-XMM6 as clobbered.
(encodekey256_operation): Likewise.
* config/i386/sse.md (encodekey128u32): Clobber XMM4-XMM6.
(encodekey256u32): Likewise.

gcc/testsuite/

PR target/107061
* gcc.target/i386/keylocker-encodekey128.c: Don't check
XMM4-XMM6.
* gcc.target/i386/keylocker-encodekey256.c: Likewise.

(cherry picked from commit db288230db55dc1ff626f46c708b555847013a41)

22 months agoDaily bump.
GCC Administrator [Thu, 29 Sep 2022 00:19:52 +0000 (00:19 +0000)]
Daily bump.

22 months agoaarch64: Add support for -mcpu=neoverse-v2
Kyrylo Tkachov [Wed, 28 Sep 2022 15:44:02 +0000 (16:44 +0100)]
aarch64: Add support for -mcpu=neoverse-v2

This is a GCC 11 version of https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602105.html
There are no tuning structures to rename so the patch is (even) smaller than the GCC 12 and trunk
versions.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (neoverse-v2): New entry.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi (AArch64 Options): Document neoverse-v2.

22 months agoDaily bump.
GCC Administrator [Wed, 28 Sep 2022 00:20:10 +0000 (00:20 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Tue, 27 Sep 2022 00:20:32 +0000 (00:20 +0000)]
Daily bump.

22 months agoFortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986]
Harald Anlauf [Tue, 20 Sep 2022 20:41:48 +0000 (22:41 +0200)]
Fortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986]

gcc/fortran/ChangeLog:

PR fortran/106986
* simplify.c (gfc_simplify_findloc): Do not try to simplify
intrinsic FINDLOC when the ARRAY argument has a NULL shape.

gcc/testsuite/ChangeLog:

PR fortran/106986
* gfortran.dg/pr106986.f90: New test.

(cherry picked from commit 5976fbf9d5dd9542fcb82eebb2185886fd52d000)

22 months agoDaily bump.
GCC Administrator [Mon, 26 Sep 2022 00:20:22 +0000 (00:20 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 25 Sep 2022 00:20:19 +0000 (00:20 +0000)]
Daily bump.

22 months agoFortran: Fix ICE with automatic reallocation [PR100245]
José Rui Faustino de Sousa [Fri, 2 Sep 2022 19:35:22 +0000 (21:35 +0200)]
Fortran: Fix ICE with automatic reallocation [PR100245]

gcc/fortran/ChangeLog:

PR fortran/100245
* trans-expr.c (trans_class_assignment): Add if clause to handle
derived type in the LHS.

gcc/testsuite/ChangeLog:

PR fortran/100245
* gfortran.dg/PR100245.f90: New test.

(cherry picked from commit 504424f33771be0405454e7845219d5df1bb88bb)

22 months agoDaily bump.
GCC Administrator [Sat, 24 Sep 2022 00:20:24 +0000 (00:20 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Fri, 23 Sep 2022 00:20:37 +0000 (00:20 +0000)]
Daily bump.

22 months agoFortran: catch NULL pointer dereferences while simplifying PACK [PR106857]
Harald Anlauf [Thu, 15 Sep 2022 20:39:24 +0000 (22:39 +0200)]
Fortran: catch NULL pointer dereferences while simplifying PACK [PR106857]

gcc/fortran/ChangeLog:

PR fortran/106857
* simplify.c (gfc_simplify_pack): Check for NULL pointer dereferences
while walking through constructors (error recovery).

gcc/testsuite/ChangeLog:

PR fortran/106857
* gfortran.dg/pr106857.f90: New test.

(cherry picked from commit 2b75d5f533b9d6b39f4055949aff64ed0d22dd24)

22 months agoDaily bump.
GCC Administrator [Thu, 22 Sep 2022 00:21:39 +0000 (00:21 +0000)]
Daily bump.

22 months agoaarch64: Fix GTY markup for arm_sve.h [PR106491]
Richard Sandiford [Wed, 21 Sep 2022 13:17:15 +0000 (14:17 +0100)]
aarch64: Fix GTY markup for arm_sve.h [PR106491]

It turns out that GTY(()) markers in definitions like:

  GTY(()) tree scalar_types[NUM_VECTOR_TYPES];

are not effective and are silently ignored.  The GTY(()) has
to come after an extern or static.

The externs associated with the SVE ACLE GTY variables are in
aarch64-sve-builtins.h.  This file is not in tm_include_list because
we don't want every target-facing file to include it.  It therefore
isn't in the list of GC header files either.

In this case that's a blessing in disguise, since the variables
belong to a namespace and gengtype doesn't understand namespaces.
I think the fix is instead to add an extra extern before each
variable declaration, similarly to varasm.cc and vtable-verify.cc.
(This works due to a "using namespace" at the end of the file.)

gcc/
PR target/106491
* config/aarch64/aarch64-sve-builtins.cc (scalar_types)
(acle_vector_types, acle_svpattern, acle_svprfop): Add GTY
markup to (new) extern declarations instead of to the main
definition.

(cherry picked from commit 6bf5a704d36243c4c04b17a9408ebe881beb0051)

22 months agoDaily bump.
GCC Administrator [Wed, 21 Sep 2022 00:22:00 +0000 (00:22 +0000)]
Daily bump.

22 months agoDaily bump.
GCC Administrator [Tue, 20 Sep 2022 00:20:16 +0000 (00:20 +0000)]
Daily bump.

22 months agoFix PR target/99184: Wrong cast from double to 16-bit and 32-bit ints
Georg-Johann Lay [Mon, 19 Sep 2022 07:46:58 +0000 (09:46 +0200)]
Fix PR target/99184: Wrong cast from double to 16-bit and 32-bit ints

this patch fixed PR target/99184 which incorrectly rounded during 64-bit
(long) double to 16-bit and 32-bit integers.

The patch just removes the respective roundings from
libf7-asm.sx::to_integer and ::to_unsigned.  Luckily, LibF7 does nowhere
use respective functions internally, the only user is in libf7.c::f7_exp

which reads

   f7_round (qq, qq);
   int16_t q = f7_get_s16 (qq);

so that f7_get_s16() operates on an already rounded value, and therefore
this code works unaltered with or without rounding in to_integer.

PR target/99184
libgcc/config/avr/libf7/
* libf7-asm.sx (to_integer, to_unsigned): Don't round 16-bit
and 32-bit integers.

(cherry picked from commit 0b5b8ac5cb7fe92dd17ae8bd7de84640daa59e84)

22 months agoDaily bump.
GCC Administrator [Mon, 19 Sep 2022 00:20:27 +0000 (00:20 +0000)]
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 18 Sep 2022 00:20:16 +0000 (00:20 +0000)]
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 17 Sep 2022 00:21:56 +0000 (00:21 +0000)]
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 16 Sep 2022 00:19:19 +0000 (00:19 +0000)]
Daily bump.

23 months agoDaily bump.
GCC Administrator [Thu, 15 Sep 2022 00:21:23 +0000 (00:21 +0000)]
Daily bump.

23 months ago[nvptx] Add uniform_warp_check insn
Tom de Vries [Fri, 28 Jan 2022 09:28:59 +0000 (10:28 +0100)]
[nvptx] Add uniform_warp_check insn

On a GT 1030, with driver version 470.94 and -mptx=3.1 I run into:
...
FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/parallel-dims.c \
  -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none \
  -O2 execution test
...
which minimizes to the same test-case as listed in commit "[nvptx]
Update default ptx isa to 6.3".

The problem is again that the first diverging branch is not handled as such in
SASS, which causes problems with a subsequent shfl insn, but given that we
have -mptx=3.1 we can't use the bar.warp.sync insn.

Given that the default is now -mptx=6.3, and consequently -mptx=3.1 is of a
lesser importance, implement the next best thing: abort when detecting
non-convergence using this insn:
...
  { .reg.b32 act;
    vote.ballot.b32 act,1;
    .reg.pred uni;
    setp.eq.b32 uni,act,0xffffffff;
    @ !uni trap;
    @ !uni exit;
  }
...

Interestingly, the effect of this is that rather than aborting, the test-case
now passes.

Tested on x86_64 with nvptx accelerator.

gcc/ChangeLog:

2022-01-31  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.c (nvptx_single): Use nvptx_uniform_warp_check.
* config/nvptx/nvptx.md (define_c_enum "unspecv"): Add
UNSPECV_UNIFORM_WARP_CHECK.
(define_insn "nvptx_uniform_warp_check"): New define_insn.

(cherry picked from commit f32f74c2e8cef5fe37af6d4e8d7e8f6b4c8ae9a8)

23 months ago[nvptx] Add bar.warp.sync
Tom de Vries [Thu, 27 Jan 2022 14:03:59 +0000 (15:03 +0100)]
[nvptx] Add bar.warp.sync

On a GT 1030 (sm_61), with driver version 470.94 I run into:
...
FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/parallel-dims.c \
  -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none \
  -O2 execution test
...
which minimizes to the same test-case as listed in commit "[nvptx] Update
default ptx isa to 6.3".

The first divergent branch looks like:
...
  {
    .reg .u32 %x;
    mov.u32 %x,%tid.x;
    setp.ne.u32 %r59,%x,0;
  }
  @ %r59 bra $L15;
  mov.u64 %r48,%ar0;
  mov.u32 %r22,2;
  ld.u64 %r53,[%r48];
  mov.u32 %r55,%r22;
  mov.u32 %r54,1;
 $L15:
...
and when inspecting the generated SASS, the branch is not setup as a divergent
branch, but instead as a regular branch.

This causes us to execute a shfl.sync insn in divergent mode, which is likely
to cause trouble given a remark in the ptx isa version 6.3, which mentions
that for .target sm_6x or below, all threads must excute the same
shfl.sync instruction in convergence.

Fix this by placing a "bar.warp.sync 0xffffffff" at the desired convergence
point (in the example above, after $L15).

Tested on x86_64 with nvptx accelerator.

gcc/ChangeLog:

2022-01-31  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.c (nvptx_single): Use nvptx_warpsync.
* config/nvptx/nvptx.md (define_c_enum "unspecv"): Add
UNSPECV_WARPSYNC.
(define_insn "nvptx_warpsync"): New define_insn.

(cherry picked from commit bba61d403d05202deb698b352a4faef3feb1f04d)

23 months agonvptx: Define (dummy) 'TARGET_PTX_6_0'
Thomas Schwinge [Tue, 13 Sep 2022 15:26:33 +0000 (17:26 +0200)]
nvptx: Define (dummy) 'TARGET_PTX_6_0'

'TARGET_PTX_*' not applicable before GCC 12, but makes it easier to cherry-pick
patches.

gcc/
* config/nvptx/nvptx.h (TARGET_PTX_6_0): '#define' to 'false'.

23 months agoDaily bump.
GCC Administrator [Wed, 14 Sep 2022 00:21:39 +0000 (00:21 +0000)]
Daily bump.

23 months agors6000/test: Fix empty TU in some cases of effective targets [PR106345]
Kewen Lin [Wed, 7 Sep 2022 01:37:57 +0000 (20:37 -0500)]
rs6000/test: Fix empty TU in some cases of effective targets [PR106345]

As the failure of test case gcc.target/powerpc/pr92398.p9-.c in
PR106345 shows, some test sources for some powerpc effective
targets use empty translation unit wrongly.  The test sources
could go with options like "-ansi -pedantic-errors", then those
effective target checkings will fail unexpectedly with the
error messages like:

  error: ISO C forbids an empty translation unit [-Wpedantic]

This patch is to fix empty TUs with one dummy function definition
accordingly.

PR testsuite/106345

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_powerpc_sqrt): Add
a function definition to avoid pedwarn about empty translation unit.
(check_effective_target_has_arch_pwr5): Likewise.
(check_effective_target_has_arch_pwr6): Likewise.
(check_effective_target_has_arch_pwr7): Likewise.
(check_effective_target_has_arch_pwr8): Likewise.
(check_effective_target_has_arch_pwr9): Likewise.
(check_effective_target_has_arch_pwr10): Likewise.
(check_effective_target_has_arch_ppc64): Likewise.
(check_effective_target_ppc_float128): Likewise.
(check_effective_target_ppc_float128_insns): Likewise.
(check_effective_target_powerpc_vsx): Likewise.

(cherry picked from commit 7a43e52a48b6403a99d3e8ab3105869b4b3c081e)

23 months agoDaily bump.
GCC Administrator [Tue, 13 Sep 2022 00:20:42 +0000 (00:20 +0000)]
Daily bump.

23 months agors6000: Don't ICE when we disassemble an MMA variable [PR101322]
Peter Bergner [Thu, 1 Sep 2022 02:14:36 +0000 (21:14 -0500)]
rs6000: Don't ICE when we disassemble an MMA variable [PR101322]

When we expand an MMA disassemble built-in with C++ using a pointer that
is cast to a valid MMA type, the type isn't passed down to the expand
machinery and we end up using the base type of the pointer which leads to
an ICE.  This patch enforces we always use the correct MMA type regardless
of the pointer type being used.

2022-08-31  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR target/101322
* config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin):
Enforce the use of a valid MMA pointer type.

gcc/testsuite/
PR target/101322
* g++.target/powerpc/pr101322.C: New test.

(cherry picked from commit 2985049049f12b0aa3366ca244d387820385b9e8)

23 months agoDaily bump.
GCC Administrator [Mon, 12 Sep 2022 00:20:10 +0000 (00:20 +0000)]
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 11 Sep 2022 00:19:49 +0000 (00:19 +0000)]
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 10 Sep 2022 00:20:00 +0000 (00:20 +0000)]
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 9 Sep 2022 00:20:28 +0000 (00:20 +0000)]
Daily bump.

23 months agoRTEMS: Add -mvrsave multilibs
Sebastian Huber [Thu, 1 Sep 2022 08:22:47 +0000 (10:22 +0200)]
RTEMS: Add -mvrsave multilibs

gcc/ChangeLog:

* config/rs6000/rtems.h (CPP_OS_DEFAULT_SPEC): Define __PPC_VRSAVE__ if
-mvrsave is present.
* config/rs6000/t-rtems: Add -mvrsave multilib variants for
-mcpu=e6500.

23 months agoDaily bump.
GCC Administrator [Thu, 8 Sep 2022 00:21:37 +0000 (00:21 +0000)]
Daily bump.

23 months agolibstdc++: Fix feature test macros in <version> for freestanding
Jonathan Wakely [Tue, 22 Mar 2022 21:29:56 +0000 (21:29 +0000)]
libstdc++: Fix feature test macros in <version> for freestanding

Some C++17 and C++20 feature test macros are only defined in <version>
for hosted builds, even though the features are supported for
freestanding.

libstdc++-v3/ChangeLog:

* include/std/version [!_GLIBCXX_HOSTED]
(__cpp_lib_bit_cast): Define for freestanding.
(__cpp_lib_string_contains): Do not define for freestanding.
(__cpp_lib_to_underlying): Likewise.

23 months agolibstdc++: Check for overflow in regex back-reference [PR106607]
Jonathan Wakely [Mon, 22 Aug 2022 14:16:16 +0000 (15:16 +0100)]
libstdc++: Check for overflow in regex back-reference [PR106607]

Currently we fail to notice integer overflow when parsing a
back-reference expression, or when converting the parsed result from
long to int. This changes the result to be int, so no conversion is
needed, and uses the overflow-checking built-ins to detect an
out-of-range back-reference.

libstdc++-v3/ChangeLog:

PR libstdc++/106607
* include/bits/regex_compiler.tcc (_Compiler::_M_cur_int_value):
Use built-ins to check for integer overflow in back-reference
number.
* testsuite/28_regex/basic_regex/106607.cc: New test.

(cherry picked from commit 1b09eea33f2bf9d1eae73b25cc25efb05ea1dc3f)

23 months agolibstdc++: Fix for explicit copy ctors in <thread> and <future> [PR106695]
Jonathan Wakely [Mon, 22 Aug 2022 14:42:17 +0000 (15:42 +0100)]
libstdc++: Fix for explicit copy ctors in <thread> and <future> [PR106695]

When I changed std::thread and std::async to avoid unnecessary move
construction of temporaries, I introduced a regression where types with
an explicit copy constructor could not be passed to std::thread or
std::async. The fix is to add a constructor instead of using aggregate
initialization of an unnamed temporary.

libstdc++-v3/ChangeLog:

PR libstdc++/106695
* include/bits/std_thread.h (thread::_State_impl): Forward
individual arguments to _Invoker constructor.
(thread::_Invoker): Add constructor. Delete copies.
* include/std/future (__future_base::_Deferred_state): Forward
individual arguments to _Invoker constructor.
(__future_base::_Async_state_impl): Likewise.
* testsuite/30_threads/async/106695.cc: New test.
* testsuite/30_threads/thread/106695.cc: New test.

(cherry picked from commit 5abe0657553580bd1b7488dd84d55138a8d9f23c)

23 months agolibstdc++: Check for EOF if extraction avoids buffer overflow [PR106248]
Jonathan Wakely [Tue, 12 Jul 2022 10:18:47 +0000 (11:18 +0100)]
libstdc++: Check for EOF if extraction avoids buffer overflow [PR106248]

In r11-2581-g17abcc77341584 (for LWG 2499) I added overflow checks to
the pre-C++20 operator>>(istream&, char*) overload.  Those checks can
cause extraction to stop after filling the buffer, where previously it
would have tried to extract another character and stopped at EOF. When
that happens we no longer set eofbit in the stream state, which is
consistent with the behaviour of the new C++20 overload, but is an
observable and unexpected change in the C++17 behaviour. What makes it
worse is that the behaviour change is dependent on optimization, because
__builtin_object_size is used to detect the buffer size and that only
works when optimizing.

To avoid the unexpected and optimization-dependent change in behaviour,
set eofbit manually if we stopped extracting because of the buffer size
check, but had reached EOF anyway. If the stream's rdstate() != goodbit
or width() is non-zero and smaller than the buffer, there's nothing to
do. Otherwise, we filled the buffer and need to check for EOF, and maybe
set eofbit.

The new check is guarded by #ifdef __OPTIMIZE__ because otherwise
__builtin_object_size is useless. There's no point compiling and
emitting dead code that can't be eliminated because we're not
optimizing.

We could add extra checks that the next character in the buffer is not
whitespace, to detect the case where we stopped early and prevented a
buffer overflow that would have happened otherwise. That would allow us
to assert or set badbit in the stream state when undefined behaviour was
prevented. However, those extra checks would increase the size of the
function, potentially reducing the likelihood of it being inlined, and
so making the buffer size detection less reliable. It seems preferable
to prevent UB and silently truncate, rather than miss the UB and allow
the overflow to happen.

libstdc++-v3/ChangeLog:

PR libstdc++/106248
* include/std/istream [C++17] (operator>>(istream&, char*)):
Set eofbit if we stopped extracting at EOF.
* testsuite/27_io/basic_istream/extractors_character/char/pr106248.cc:
New test.
* testsuite/27_io/basic_istream/extractors_character/wchar_t/pr106248.cc:
New test.

(cherry picked from commit 5ae74944af1de032d4a27fad4a2287bd3a2163fd)

23 months agolibstdc++: Tweak common_iterator::operator-> return type [PR104443]
Jonathan Wakely [Thu, 28 Jul 2022 19:55:51 +0000 (20:55 +0100)]
libstdc++: Tweak common_iterator::operator-> return type [PR104443]

This adjusts the return type to match the resolution of LWG 3672. There
is no functional difference, because decltype(auto) always deduced a
value anyway, but this makes it simpler and consistent with the working
draft.

libstdc++-v3/ChangeLog:

PR libstdc++/104443
* include/bits/stl_iterator.h (common_iterator::operator->):
Change return type to just auto.

(cherry picked from commit b5f5d1b36edbcd7d923f2e2653e54e52637c715b)

23 months agoDaily bump.
GCC Administrator [Wed, 7 Sep 2022 00:19:56 +0000 (00:19 +0000)]
Daily bump.

This page took 0.104082 seconds and 5 git commands to generate.