]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 years agoDaily bump.
GCC Administrator [Tue, 19 Oct 2021 00:18:06 +0000 (00:18 +0000)] 
Daily bump.

3 years agoi386: Fix ICE in ix86_print_opreand_address [PR 102761]
Uros Bizjak [Mon, 18 Oct 2021 15:03:28 +0000 (17:03 +0200)] 
i386: Fix ICE in ix86_print_opreand_address [PR 102761]

2021-10-18  Uroš Bizjak  <ubizjak@gmail.com>

PR target/102761

gcc/ChangeLog:

* config/i386/i386.c (ix86_print_operand_address):
Error out for non-address_operand asm operands.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr102761.c: New test.

3 years ago[PR/target 100316] Allow constant address for __builtin___clear_cache.
Kito Cheng [Thu, 7 Oct 2021 08:17:13 +0000 (16:17 +0800)] 
[PR/target 100316] Allow constant address for __builtin___clear_cache.

__builtin___clear_cache was able to accept constant address for the
argument, but it seems no longer accept recently, and it even not
accept constant address which is hold in variable when optimization is
enable:

```
void foo3(){
  void *yy = (void*)0x1000;
  __builtin___clear_cache(yy, yy);
}
```

So this patch make BEGIN and END accept VOIDmode, like cselib_lookup_mem did per
Jim Wilson's suggestion.

```
static cselib_val *
cselib_lookup_mem (rtx x, int create)
{
  ...
  addr_mode = GET_MODE (XEXP (x, 0));
  if (addr_mode == VOIDmode)
    addr_mode = Pmode;
```

Changes v2 -> v3:
- Use gcc_assert rather than error, maybe_emit_call_builtin___clear_cache is
internal use only, and we already checked the type in other place.

Changes v1 -> v2:
- Check is CONST_INT intead of cehck mode, no new testcase, since
  constant value with other type like CONST_DOUBLE will catched by
  front-end.
e.g.
Code:
```c
void foo(){
  __builtin___clear_cache(1.11, 0);
}
```
Error message:
```
clearcache-double.c: In function 'foo':
clearcache-double.c:2:27: error: incompatible type for argument 1 of '__builtin___clear_cache'
    2 |   __builtin___clear_cache(1.11, 0);
      |                           ^~~~
      |                           |
      |                           double
clearcache-double.c:2:27: note: expected 'void *' but argument is of type 'double'
```

gcc/ChangeLog:

PR target/100316
* builtins.c (maybe_emit_call_builtin___clear_cache): Allow
CONST_INT for BEGIN and END, and use gcc_assert rather than
error.

gcc/testsuite/ChangeLog:

PR target/100316
* gcc.c-torture/compile/pr100316.c: New.

(cherry picked from commit 4e5bc4e4506a7ae7bb88fc925a425652a1da6b2d)

3 years agoopenmp: Fix up handling of OMP_PLACES=threads(1)
Jakub Jelinek [Fri, 15 Oct 2021 14:25:25 +0000 (16:25 +0200)] 
openmp: Fix up handling of OMP_PLACES=threads(1)

When writing the places-*.c tests, I've noticed that we mishandle threads
abstract name with specified num-places if num-places isn't a multiple of
number of hw threads in a core.  It then happily ignores the maximum count
and overwrites for the remaining hw threads in a core further places that
haven't been allocated.

2021-10-15  Jakub Jelinek  <jakub@redhat.com>

* config/linux/affinity.c (gomp_affinity_init_level_1): For level 1
after creating count places clean up and return immediately.
* testsuite/libgomp.c/places-6.c: New test.
* testsuite/libgomp.c/places-7.c: New test.
* testsuite/libgomp.c/places-8.c: New test.

(cherry picked from commit 4764049dd620affcd3e2658dc7f03a6616370a29)

3 years agoamdgcn: fix up offload debug linking with LLVM 13
Andrew Stubbs [Wed, 13 Oct 2021 10:53:42 +0000 (11:53 +0100)] 
amdgcn: fix up offload debug linking with LLVM 13

Between LLVM 9 and LLVM 13 the attribute works differently in several ways,
and this needs to be allowed for in GCC and mkoffload independently.

This patch fixes up mkoffload when debug info is enabled, which is made more
complicated because the configure tests checks whether the attribute option
is accepted silently, but does not check if the assembler actually sets the
ELF flags for that attribute, and mkoffload needs to mimick that behaviour
exactly. The patch therefore removes some of the conditionals.

gcc/ChangeLog:

* config/gcn/gcn-hsa.h (S_FIJI): Set unconditionally.
(S_900): Likewise.
(S_906): Likewise.
* config/gcn/gcn.c: Hard code SRAM ECC settings for old architectures.
* config/gcn/mkoffload.c (ELFABIVERSION_AMDGPU_HSA): Rename to ...
(ELFABIVERSION_AMDGPU_HSA_V3): ... this.
(ELFABIVERSION_AMDGPU_HSA_V4): New.
(SET_SRAM_ECC_UNSUPPORTED): New.
(copy_early_debug_info): Create elf flags to match the other objects.
(main): Just let the attribute flags pass through.

(cherry picked from commit f3d64372d777d7d6068df8167b6751c289963e85)

3 years agoamdgcn: Fix assembler version incompatibility
Andrew Stubbs [Thu, 30 Sep 2021 16:50:33 +0000 (17:50 +0100)] 
amdgcn: Fix assembler version incompatibility

This is another case of the global_load instruction format changing in LLVM
(because they fixed a bug).  The configure test is already in place to detect
what is needed.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (gather<mode>_insn_2offsets<exec>): Apply
HAVE_GCN_ASM_GLOBAL_LOAD_FIXED.
(scatter<mode>_insn_2offsets<exec_scatter>): Likewise.

(cherry picked from commit 81c362c7c2bccd72d798bf7ea6c74d4b1cc3931f)

3 years agoamdgcn: Implement -msram-ecc=any
Andrew Stubbs [Tue, 28 Sep 2021 15:26:09 +0000 (16:26 +0100)] 
amdgcn: Implement -msram-ecc=any

The option was already there, but just an alias for -msram-ecc=on.  Now that
LLVM13 supports HSACOv4 and the new ELF flags I can implement the option
properly.

The "any" option is the default in order to ensure that library files work
whichever way the user wants, which means we won't need multilibs to support
the different SRAM ECC hardware configurations.

gcc/ChangeLog:

* config/gcn/gcn-hsa.h (SRAMOPT): Include the whole option string.
Adjust for new -msram-ecc=any behaviour.
(ASM_SPEC): Adjust -mxnack and -msram-ecc usage.
* config/gcn/gcn.c (output_file_start): Implement -msram-ecc=any.
* config/gcn/mkoffload.c (EF_AMDGPU_XNACK): Rename to ...
(EF_AMDGPU_XNACK_V3): ... this.
(EF_AMDGPU_SRAM_ECC): Rename to ...
(EF_AMDGPU_SRAM_ECC_V3): ... this.
(EF_AMDGPU_FEATURE_XNACK_V4): New.
(EF_AMDGPU_FEATURE_XNACK_UNSUPPORTED_V4): New.
(EF_AMDGPU_FEATURE_XNACK_ANY_V4): New.
(EF_AMDGPU_FEATURE_XNACK_OFF_V4): New.
(EF_AMDGPU_FEATURE_XNACK_ON_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_UNSUPPORTED_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_ANY_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_OFF_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_ON_V4): New.
(SET_XNACK_ON): New.
(SET_XNACK_OFF): New.
(TEST_XNACK): New.
(SET_SRAM_ECC_ON): New.
(SET_SRAM_ECC_ANY): New.
(SET_SRAM_ECC_OFF): New.
(TEST_SRAM_ECC_ANY): New.
(TEST_SRAM_ECC_ON): New.
(main): Implement HSACOv4 and -msram-ecc=any.

(cherry picked from commit 205dafb6edeca08419f4a5976be79bf7c86fd9a1)

3 years agoamdgcn: Support LLVM 13 assembler syntax
Andrew Stubbs [Sat, 16 Oct 2021 16:41:39 +0000 (18:41 +0200)] 
amdgcn: Support LLVM 13 assembler syntax

The LLVM devs have changed the assembler architecture attribute names on both
CLI and in the ".amdgcn_target" directive, and changed the attribute syntax
inside the directive, without keeping any backwards compatibility. :-(

This patch improves our configure tests to detect what dialect to use, what
attributes are valid, and adjusts the specs to match.

gcc/ChangeLog:

* config.in: Regenerate.
* config/gcn/gcn-hsa.h (X_FIJI): New macro.
(X_900): New macro.
(X_906): New macro.
(X_908): New macro.
(A_FIJI): Rename to ...
(S_FIJI): ... this.
(A_900): Rename to ...
(S_900): ... this.
(A_906): Rename to ...
(S_906): ... this.
(A_908): Rename to ...
(S_908): ... this.
(SRAMOPT): New macro.
(ASM_SPEC): Adjust xnack option usage.
* config/gcn/gcn.c (output_file_start): Adjust amdgcn_target usage.
* configure: Regenerate.
* configure.ac: Detect LLVM assembler dialect.

(cherry picked from commit 6ca03ca35a58ebf9792aa8a08adf00b6fd3e0015)

3 years agoamdgcn: Mark s_mulk_i32 as clobbering SCC
Julian Brown [Mon, 28 Jun 2021 13:58:52 +0000 (06:58 -0700)] 
amdgcn: Mark s_mulk_i32 as clobbering SCC

The s_mulk_i32 instruction sets the SCC status register according to
whether the multiplication overflows, but that is not currently modelled
in the GCN backend.  AFAIK this is a latent bug and hasn't been noticed
"in the wild", but it should be fixed.

2021-06-29  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn.md (mulsi3): Make s_mulk_i32 variant clobber SCC.

(cherry picked from commit 5c127c4cac308429cba483a2ac4e175c2ab26165)

3 years agoamdgcn: Fix attributes for LLVM-12 [PR 100208]
Andrew Stubbs [Tue, 27 Jul 2021 14:40:21 +0000 (15:40 +0100)] 
amdgcn: Fix attributes for LLVM-12 [PR 100208]

This should work for a wider range of LLVM 12 variants now.
More work required for LLVM 13 though.

gcc/ChangeLog:

PR target/100208
* config.in: Regenerate.
* config/gcn/gcn-hsa.h (A_FIJI): New define.
(A_900): New define.
(A_906): New define.
(A_908): New define.
(ASM_SPEC): Use A_FIJI, A_900, A_906 and A_908.
* config/gcn/gcn.c (output_file_start): Adjust attributes according
to the assembler capabilities.
* config/gcn/mkoffload.c (main): Likewise.
* configure: Regenerate.
* configure.ac: Add tests for LLVM assembler attribute features.

3 years agoamdgcn: Add -mxnack and -msram-ecc [PR 100208]
Andrew Stubbs [Thu, 8 Jul 2021 14:47:53 +0000 (15:47 +0100)] 
amdgcn: Add -mxnack and -msram-ecc [PR 100208]

gcc/ChangeLog:

PR target/100208
* config/gcn/gcn-hsa.h (DRIVER_SELF_SPECS): New.
(ASM_SPEC): Set -mattr for xnack and sram-ecc.
* config/gcn/gcn-opts.h (enum sram_ecc_type): New.
* config/gcn/gcn-valu.md: Add a warning comment.
* config/gcn/gcn.c (gcn_option_override): Add "sorry" for -mxnack.
(output_file_start): Add xnack and sram-ecc state to ".amdgcn_target".
* config/gcn/gcn.md: Add a warning comment.
* config/gcn/gcn.opt: Add -mxnack and -msram-ecc.
* config/gcn/mkoffload.c (EF_AMDGPU_MACH_AMDGCN_GFX908): Remove
SRAM-ECC flag.
(EF_AMDGPU_XNACK): New.
(EF_AMDGPU_SRAM_ECC): New.
(elf_flags): New.
(copy_early_debug_info): Use elf_flags.
(main): Handle -mxnack and -msram-ecc options.
* doc/invoke.texi: Document -mxnack and -msram-ecc.

gcc/testsuite/ChangeLog:

PR target/100208
* gcc.target/gcn/sram-ecc-1.c: New test.
* gcc.target/gcn/sram-ecc-2.c: New test.
* gcc.target/gcn/sram-ecc-3.c: New test.
* gcc.target/gcn/sram-ecc-4.c: New test.
* gcc.target/gcn/sram-ecc-5.c: New test.
* gcc.target/gcn/sram-ecc-6.c: New test.
* gcc.target/gcn/sram-ecc-7.c: New test.
* gcc.target/gcn/sram-ecc-8.c: New test.

(cherry picked from commit aad32a00b7d2b64ae158b2b167768a9ae3e20f6e)

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.

(cherry picked from commit cfa1f8226f275447015e2cb3fb0d876133e6509b)

3 years agoDaily bump.
GCC Administrator [Mon, 18 Oct 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

3 years agoFortran: fix order of checks for the SHAPE intrinsic
Harald Anlauf [Thu, 14 Oct 2021 18:18:14 +0000 (20:18 +0200)] 
Fortran: fix order of checks for the SHAPE intrinsic

gcc/fortran/ChangeLog:

PR fortran/102716
* check.c (gfc_check_shape): Reorder checks so that invalid KIND
arguments can be detected.

gcc/testsuite/ChangeLog:

PR fortran/102716
* gfortran.dg/shape_10.f90: New test.

(cherry picked from commit 1b115daf62d94337b3d0b2962b0bbbf005a450e0)

3 years agoDaily bump.
GCC Administrator [Sun, 17 Oct 2021 00:17:54 +0000 (00:17 +0000)] 
Daily bump.

3 years agoDaily bump.
GCC Administrator [Sat, 16 Oct 2021 00:17:58 +0000 (00:17 +0000)] 
Daily bump.

3 years agoConsistently use "rG" constraint for copy instruction in move patterns
John David Anglin [Fri, 15 Oct 2021 14:51:22 +0000 (14:51 +0000)] 
Consistently use "rG" constraint for copy instruction in move patterns

2021-10-15  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.md: Consistently use "rG" constraint for copy
instruction in move patterns.

3 years agoDaily bump.
GCC Administrator [Fri, 15 Oct 2021 00:18:36 +0000 (00:18 +0000)] 
Daily bump.

3 years ago[PR102627] Use at least natural mode during splitting hard reg live range
Vladimir N. Makarov [Fri, 8 Oct 2021 14:16:09 +0000 (10:16 -0400)] 
[PR102627] Use at least natural mode during splitting hard reg live range

In the PR test case SImode was used to split live range of cx on x86-64
because it was the biggest mode for this hard reg in the function.  But
all 64-bits of cx contain structure members.  We need always to use at least
natural mode of hard reg in splitting to fix this problem.

gcc/ChangeLog:

PR rtl-optimization/102627
* lra-constraints.c (split_reg): Use at least natural mode of hard reg.

gcc/testsuite/ChangeLog:

PR rtl-optimization/102627
* gcc.target/i386/pr102627.c: New test.

3 years agolibstdc++: Fix non-default constructors for hash containers [PR101583]
Jonathan Wakely [Thu, 22 Jul 2021 17:49:57 +0000 (18:49 +0100)] 
libstdc++: Fix non-default constructors for hash containers [PR101583]

When I added the new mixin to _Hashtable, I forgot to explicitly
construct it in each non-default constructor. That means you can't
use any constructors unless all three of the hash function, equality
function, and allocator are all default constructible.

libstdc++-v3/ChangeLog:

PR libstdc++/101583
* include/bits/hashtable.h (_Hashtable): Replace mixin with
_Enable_default_ctor. Construct it explicitly in all
non-forwarding, non-defaulted constructors.
* testsuite/23_containers/unordered_map/cons/default.cc: Check
non-default constructors can be used.
* testsuite/23_containers/unordered_set/cons/default.cc:
Likewise.

(cherry picked from commit 8ed6cfbbee74ec9e03f2558b9c36f61dd7d4dcfd)

3 years agoFix TARGET_SOFT_FLOAT patterns in pa.md
John David Anglin [Thu, 14 Oct 2021 00:58:33 +0000 (00:58 +0000)] 
Fix TARGET_SOFT_FLOAT patterns in pa.md

2021-10-13  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.md (cbranchsf4): Disable if TARGET_SOFT_FLOAT.
(cbranchdf4): Likewise.
Add missing move patterns for TARGET_SOFT_FLOAT.

3 years agoDaily bump.
GCC Administrator [Thu, 14 Oct 2021 00:18:17 +0000 (00:18 +0000)] 
Daily bump.

3 years agolibstdc++: Rename files with the wrong extensions
Jonathan Wakely [Wed, 13 Oct 2021 21:31:51 +0000 (22:31 +0100)] 
libstdc++: Rename files with the wrong extensions

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/path/construct/102592.C: Moved to...
* testsuite/27_io/filesystem/path/construct/102592.cc: ...here.
* testsuite/28_regex/match_results/102667.C: Moved to...
* testsuite/28_regex/match_results/102667.cc: ...here.

(cherry picked from commit ce55693604813c5be7d23260f1fd276cf5a48f8f)

3 years agolibstdc++: Fix dangling string_view in filesystem::path [PR102592]
Jonathan Wakely [Wed, 13 Oct 2021 16:02:59 +0000 (17:02 +0100)] 
libstdc++: Fix dangling string_view in filesystem::path [PR102592]

When creating a path from a pair of non-contiguous iterators we pass the
iterators to _S_convert(Iter, Iter). That function passes the iterators
to __string_from_range to get a contiguous sequence of characters, and
then calls _S_convert(const C*, const C*) to perform the encoding
conversions. If the value type, C, is char8_t, then no conversion is
needed and the _S_convert<char8_t>(const char8_t*, const char8_t*)
specialization casts the pointer to const char* and returns a
std::string_view that refs to the char8_t sequence. However, that
sequence is owned by the std::u8string rvalue returned by
__string_from_range, which goes out of scope when _S_convert(Iter, Iter)
returns. That means the std::string_view is dangling and we get
undefined behaviour when parsing it as a path.

The same problem does not exist for the path members taking a "Source"
argument, because those functions all convert a non-contiguous range
into a basic_string<C> immediately, using __effective_range(__source).
That means that the rvalue string returned by that function is still in
scope for the full expression, so the string_view does not dangle.

The solution for the buggy functions is to do the same thing, and call
__string_from_range immediately, so that the returned rvalue is still in
scope for the lifetime of the string_view returned by _S_convert. To
avoid reintroducing the same problem, remove the _S_convert(Iter, Iter)
overload that calls __string_from_range and returns a dangling view.

libstdc++-v3/ChangeLog:

PR libstdc++/102592
* include/bits/fs_path.h (path::path(Iter, Iter, format))
(path::append(Iter, Iter), path::concat(Iter, Iter)): Call
__string_from_range directly, instead of two-argument overload
of _S_convert.
(path::_S_convert(Iter, Iter)): Remove.
* testsuite/27_io/filesystem/path/construct/102592.C: New test.

(cherry picked from commit 85b24e32dc27ec2e70b853713e0713cbc1ff08c3)

3 years agolibstdc++: Add noexcept-specifier to basic_string_view(It, End)
Jonathan Wakely [Wed, 14 Jul 2021 10:03:17 +0000 (11:03 +0100)] 
libstdc++: Add noexcept-specifier to basic_string_view(It, End)

This adds a conditional noexcept to the C++20 constructor. The
std::to_address call cannot throw, so only taking the difference of the
two iterators can throw.

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

* include/std/string_view (basic_string_view(It, End)): Add
noexcept-specifier.
* testsuite/21_strings/basic_string_view/cons/char/range.cc:
Check noexcept-specifier. Also check construction without CTAD.

(cherry picked from commit f9c2ce1dae270d8d5dc261a57a21f96a1da5ea2d)

3 years agoDarwin, X86, config: Adjust 'as' command lines [PR100340].
Iain Sandoe [Sat, 31 Jul 2021 15:29:03 +0000 (16:29 +0100)] 
Darwin, X86, config: Adjust 'as' command lines [PR100340].

Versions of the assembler using clang from XCode 12.5/12.5.1
have a bug which produces different code layout between debug and
non-debug input, leading to a compare fail for default configure
parameters.

This is a workaround fix to disable the optimisation that is
responsible for the bug.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR target/100340 - Bootstrap fails with Clang 12.0.5 (XCode 12.5)

PR target/100340

gcc/ChangeLog:

* config.in: Regenerate.
* config/i386/darwin.h (EXTRA_ASM_OPTS): New
(ASM_SPEC): Pass options to disable branch shortening where
needed.
* configure: Regenerate.
* configure.ac: Detect versions of 'as' that support the
optimisation which has the bug.

(cherry picked from commit 743b8dd6fd757e997eb060d70fd4ae8e04fb56cd)

3 years agoAdd support for 32-bit hppa targets in muldi3 expander
John David Anglin [Wed, 13 Oct 2021 15:45:39 +0000 (15:45 +0000)] 
Add support for 32-bit hppa targets in muldi3 expander

2021-10-13  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.md (muldi3): Add support for inlining 64-bit
multiplication on 32-bit PA 1.1 and 2.0 targets.

3 years agolibstdc++: Fix various bugs in ranges_algo.h [PR100187, ...]
Patrick Palka [Wed, 28 Apr 2021 03:21:19 +0000 (23:21 -0400)] 
libstdc++: Fix various bugs in ranges_algo.h [PR100187, ...]

This fixes some bugs with our ranges algorithms in uncommon situations,
such as when the return type of a predicate is a non-copyable class type
that's implicitly convertible to bool (PR100187), when a comparison
predicate isn't invocable as an rvalue (PR100237), and when the return
type of a projection function is non-copyable (PR100249).

This also fixes PR100287, which reports that we're moving __first twice
when constructing with it an empty subrange in ranges::partition.

libstdc++-v3/ChangeLog:

PR libstdc++/100187
PR libstdc++/100237
PR libstdc++/100249
PR libstdc++/100287
* include/bits/ranges_algo.h (__search_n_fn::operator()): Give
the __value_comp lambda an explicit bool return type.
(__is_permutation_fn::operator()): Give the __proj_scan local
variable auto&& return type.  Give the __comp_scan lambda an
explicit bool return type.
(__remove_fn::operator()): Give the __pred lambda an explicit
bool return type.
(__partition_fn::operator()): Don't std::move __first twice
when returning an empty subrange.
(__min_fn::operator()): Don't std::move __comp.
(__max_fn::operator()): Likewise.
(__minmax_fn::operator()): Likewise.

(cherry picked from commit d91e7eab3a2c3957c2220ad71e62d9fc78cccb9b)

3 years agoDarwin, D: Fix bootstrap when target does not support -Bstatic/dynamic.
Iain Sandoe [Tue, 5 Oct 2021 18:54:30 +0000 (19:54 +0100)] 
Darwin, D: Fix bootstrap when target does not support -Bstatic/dynamic.

This fixes a bootstrap fail because saw_static_libcxx was unused for
targets without support for -Bstatic/dynamic.

The fix applied pushes the -static-libstdc++ back onto the command
line, which allows a target to substitute a static version of the
c++ standard library using specs.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/d/ChangeLog:

* d-spec.cc (lang_specific_driver): Push the -static-libstdc++
option back onto the command line for targets without support
for -Bstatic/dynamic.

(cherry picked from commit e24760533b62bb7068e63eb8da49dbca2837d38d)

3 years agoDaily bump.
GCC Administrator [Wed, 13 Oct 2021 00:18:09 +0000 (00:18 +0000)] 
Daily bump.

3 years agolibstdc++: Fix ip::tcp::resolver test failure on Solaris
Jonathan Wakely [Tue, 31 Aug 2021 12:08:23 +0000 (13:08 +0100)] 
libstdc++: Fix ip::tcp::resolver test failure on Solaris

Solaris 11 does not have "http" in /etc/services, which causes this test
to fail. Try some other services until we find one that works.

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

* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
Try other service if "http" fails.

(cherry picked from commit 48b20d46f9597a4b1e19e0e2d4a0c68d056d7662)

3 years agolibstdc++: Make Networking TS headers more portable [PR100285]
Jonathan Wakely [Thu, 26 Aug 2021 11:06:55 +0000 (12:06 +0100)] 
libstdc++: Make Networking TS headers more portable [PR100285]

Add more preprocessor conditions to check for constants being defined
before using them, so that the Networking TS headers can be compiled on
a wider range of platforms.

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

PR libstdc++/100285
* configure.ac: Check for O_NONBLOCK.
* configure: Regenerate.
* include/experimental/internet: Include <ws2tcpip.h> for
Windows.  Use preprocessor conditions around more constants.
* include/experimental/socket: Use preprocessor conditions
around more constants.
* testsuite/experimental/net/internet/resolver/base.cc: Only use
constants when the corresponding C macro is defined.
* testsuite/experimental/net/socket/basic_socket.cc: Likewise.
* testsuite/experimental/net/socket/socket_base.cc: Likewise.
Make preprocessor checks more fine-grained.

3 years agolibstdc++: fix is_default_constructible for hash containers [PR 100863]
Jonathan Wakely [Tue, 20 Jul 2021 14:20:41 +0000 (15:20 +0100)] 
libstdc++: fix is_default_constructible for hash containers [PR 100863]

The recent change to _Hashtable_ebo_helper for this PR broke the
is_default_constructible trait for a hash container with a non-default
constructible allocator. That happens because the constructor needs to
be user-provided in order to initialize the member, and so is not
defined as deleted when the type is not default constructible.

By making _Hashtable derive from _Enable_special_members we can ensure
that the default constructor for the std::unordered_xxx containers is
deleted when it would be ill-formed. This makes the trait give the
correct answer.

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

PR libstdc++/100863
* include/bits/hashtable.h (_Hashtable): Conditionally delete
default constructor by deriving from _Enable_special_members.
* testsuite/23_containers/unordered_map/cons/default.cc: New test.
* testsuite/23_containers/unordered_set/cons/default.cc: New test.

(cherry picked from commit 89ec3b67dbe856a447d068b053bc19559f136f43)

3 years agolibstdc++: Value-initialize objects held by EBO helpers [PR 100863]
Jonathan Wakely [Wed, 2 Jun 2021 11:34:48 +0000 (12:34 +0100)] 
libstdc++: Value-initialize objects held by EBO helpers [PR 100863]

The allocator, hash function and equality function should all be
value-initialized by the default constructor of an unordered container.
Do it in the EBO helper, so we don't have to get it right in multiple
places.

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

PR libstdc++/100863
PR libstdc++/65816
* include/bits/hashtable_policy.h (_Hashtable_ebo_helper):
Value-initialize subobject.
* testsuite/23_containers/unordered_map/allocator/default_init.cc:
Remove XFAIL.
* testsuite/23_containers/unordered_set/allocator/default_init.cc:
Remove XFAIL.

(cherry picked from commit f8f0193b5b83f6e85d65015e79c803295baf5166)

3 years agolibstdc++: Allow lualatex to be used for Doxygen PDF
Jonathan Wakely [Fri, 14 May 2021 13:19:50 +0000 (14:19 +0100)] 
libstdc++: Allow lualatex to be used for Doxygen PDF

This allows the Doxygen PDF to be built using lualatex instead of
pdflatex, which solves a problem with pdflatex running out of memory
sometimes. This is done by adding a --latex_cmd option to the
run_doxygen script, which then sets the specified command in the
generated user.cfg file used by Doxygen. The makefile is adjusted to
pass --latex_cmd=$(LATEX_CMD) to the script, so using running make with
LATEX_CMD=lualatex will override the default.

Additionally, this does some refactoring of the doc/Makefile.am rules
and the run_doxygen script.

libstdc++-v3/ChangeLog:

* doc/Makefile.am: Simplify doxygen recipes and use --latex_cmd.
* doc/Makefile.in: Regenerate.
* doc/doxygen/user.cfg.in (LATEX_CMD_NAME): Add placeholder
value.
* scripts/run_doxygen (print_usage): Always print to stdout and
do not exit.
(fail): New function for exiting on error.
(parse_options): Handle --latex_cmd. Do not treat --help the
same as errors. Simplify handling of required arguments.

(cherry picked from commit e3b6d3a887fc0df09ea742c9c5a5acbc27c11ea7)

3 years agolibstdc++: Reduce output of 'make doc-pdf-doxygen'
Jonathan Wakely [Wed, 28 Apr 2021 13:49:28 +0000 (14:49 +0100)] 
libstdc++: Reduce output of 'make doc-pdf-doxygen'

Use '@' to prevent Make from echoing the recipe, so that users don't see
this every time:

  if [ -f ${doxygen_pdf} ]; then
    mv ${doxygen_pdf} ${api_pdf} ;
    echo ":: PDF file is ${api_pdf}";
  else
    echo "... error";
    grep -F 'LaTeX Error' ${doxygen_outdir}/latex/refman.log;
    grep -F 'TeX capacity exceeded, sorry' ${doxygen_outdir}/latex/refman.log;
    exit 12;
  fi

The presence of the "error" strings in the output makes it look like an
error happened. By suppressing the echoing user's will only see "error"
if the 'else' branch is taken.

libstdc++-v3/ChangeLog:

* doc/Makefile.am (stamp-pdf-doxygen): Improve comment about
dealing with errors. Use '@' to prevent shell command being
echoed.
* doc/Makefile.in: Regenerate.

(cherry picked from commit 43a35b26e2fd2fab9c0c3ebac67e3a6c439daef4)

3 years agolibstdc++: Add warnings for some C++23 deprecations
Jonathan Wakely [Wed, 9 Jun 2021 09:11:00 +0000 (10:11 +0100)] 
libstdc++: Add warnings for some C++23 deprecations

LWG 3036 deprecates std::pmr::polymorphic_allocator<T>::destroy in
favour of the equivalent member of std::allocator_traits.

LWG 3170 deprecates std::allocator<T>::is_always_equal in favour of
the equivalent member of std::allocator_traits.

This also updates a comment to note that we support the LWG 3541 change
(even before the issue was opened).

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

* include/bits/allocator.h (allocator::is_always_equal): Deprecate.
* include/bits/iterator_concepts.h (indirectly_readable_traits):
Add LWG issue number to comment.
* include/std/memory_resource (polymorphic_allocator::release):
Deprecate.
* testsuite/20_util/allocator/requirements/typedefs.cc: Add
dg-warning for deprecation. Also check std::allocator<void>.

(cherry picked from commit 5bfcfe3087eb05b76395c9efbfc1abbf3f9e1a03)

3 years agolibstdc++: Fix 17_intro/names.cc failures on Solaris
Jonathan Wakely [Tue, 31 Aug 2021 09:25:53 +0000 (10:25 +0100)] 
libstdc++: Fix 17_intro/names.cc failures on Solaris

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

* testsuite/17_intro/names.cc: Undefine some more names used
by Solaris system headers.

(cherry picked from commit 69b09c5599b201ac039db564c303f7b20d87e0df)

3 years agolibstdc++: Remove __gnu_cxx::rope::erase(size_type) [PR102048]
Jonathan Wakely [Wed, 25 Aug 2021 15:42:49 +0000 (16:42 +0100)] 
libstdc++: Remove __gnu_cxx::rope::erase(size_type) [PR102048]

This function claims to remove a single character at index p, but it
actually removes p+1 characters beginning at p. So r.erase(0) removes
the first character, but r.erase(1) removes the second and third, and
r.erase(2) removes the second, third and fourth. This is not a useful
API.

The overload is present in the SGI STL <stl_rope.h> header that we
imported, but it isn't documented in the API reference. The erase
overloads that are documented are:

erase(const iterator& p)
erase(const iterator& f, const iterator& l)
erase(size_type i, size_type n);

Having an erase(size_type p) overload that erases a single character (as
the comment says it does) might be useful, but would be inconsistent
with std::basic_string::erase(size_type p = 0, size_type n = npos),
which erases from p to the end of the string when called with a single
argument.

Since the function isn't part of the documented API, doesn't do what it
claims to do (or anything useful) and "fixing" it would leave it
inconsistent with basic_string, I'm just removing that overload.

libstdc++-v3/ChangeLog:

PR libstdc++/102048
* include/ext/rope (rope::erase(size_type)): Remove broken
function.

(cherry picked from commit 2cd229dec8d6716938de5052479d059d306969da)

3 years agolibstdc++: Skip filesystem tests that depend on permissions [PR90787]
Jonathan Wakely [Fri, 20 Aug 2021 13:51:06 +0000 (14:51 +0100)] 
libstdc++: Skip filesystem tests that depend on permissions [PR90787]

Tests that depend on filesystem permissions FAIL if run on Windows or as
root. Add a helper function to detect those cases, so the tests can skip
those checks gracefully.

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

PR libstdc++/90787
* testsuite/27_io/filesystem/iterators/directory_iterator.cc:
Use new __gnu_test::permissions_are_testable() function.
* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
Likewise.
* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
* testsuite/27_io/filesystem/operations/remove.cc: Likewise.
* testsuite/27_io/filesystem/operations/remove_all.cc: Likewise.
* testsuite/27_io/filesystem/operations/status.cc: Likewise.
* testsuite/27_io/filesystem/operations/symlink_status.cc:
Likewise.
* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
Likewise.
* testsuite/experimental/filesystem/iterators/directory_iterator.cc:
Likewise.
* testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc:
Likewise.
* testsuite/experimental/filesystem/operations/exists.cc:
Likewise.
* testsuite/experimental/filesystem/operations/is_empty.cc:
Likewise.
* testsuite/experimental/filesystem/operations/remove.cc:
Likewise.
* testsuite/experimental/filesystem/operations/remove_all.cc:
Likewise.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Likewise.
* testsuite/util/testsuite_fs.h (__gnu_test::permissions_are_testable):
New function to guess whether testing permissions will work.

(cherry picked from commit 29b2fd371f18169141e20b90effa7205db68fb11)

3 years agolibstdc++: Add missing std::move to ranges::copy/move/reverse_copy [PR101599]
Patrick Palka [Mon, 2 Aug 2021 19:30:15 +0000 (15:30 -0400)] 
libstdc++: Add missing std::move to ranges::copy/move/reverse_copy [PR101599]

In passing, this also renames the template parameter _O2 to _Out2 in
ranges::partition_copy and uglifies two of its function parameters,
out_true and out_false.

PR libstdc++/101599

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__reverse_copy_fn::operator()):
Add missing std::move in return statement.
(__partition_copy_fn::operator()): Rename templtae parameter
_O2 to _Out2.  Uglify function parameters out_true and out_false.
* include/bits/ranges_algobase.h (__copy_or_move): Add missing
std::move to recursive call that unwraps a __normal_iterator
output iterator.
* testsuite/25_algorithms/copy/constrained.cc (test06): New test.
* testsuite/25_algorithms/move/constrained.cc (test05): New test.

(cherry picked from commit 14d8a5ae472ca5743016f37da2dd4770d83dea21)

3 years agolibstdc++: Fix up implementation of LWG 3533 [PR101589]
Patrick Palka [Mon, 2 Aug 2021 19:30:13 +0000 (15:30 -0400)] 
libstdc++: Fix up implementation of LWG 3533 [PR101589]

In r12-569 I accidentally applied the LWG 3533 change to
elements_view::iterator::base instead to elements_view::base.

This patch corrects this, and also applies the corresponding LWG 3533
change to lazy_split_view::inner-iter::base now that we implement P2210.

PR libstdc++/101589

libstdc++-v3/ChangeLog:

* include/std/ranges (lazy_split_view::_InnerIter::base): Make
the const& overload unconstrained and return a const reference
as per LWG 3533.  Make unconditionally noexcept.
(elements_view::base): Revert accidental r12-569 change.
(elements_view::_Iterator::base): Make the const& overload
unconstrained and return a const reference as per LWG 3533.
Make unconditionally noexcept.

(cherry picked from commit 4414057186b227edf5b5efa527732bfcdf39d575)

3 years agolibstdc++: Add missing std::move to join_view::iterator ctor [PR101483]
Patrick Palka [Mon, 2 Aug 2021 19:30:10 +0000 (15:30 -0400)] 
libstdc++: Add missing std::move to join_view::iterator ctor [PR101483]

PR libstdc++/101483

libstdc++-v3/ChangeLog:

* include/std/ranges (join_view::_Iterator::_Iterator): Add
missing std::move.

(cherry picked from commit 0e1bb3c88c7bd624bc34d6cebe3df9532f1858f0)

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.

(cherry picked from commit 85a594f7dc8ea5c765e136f162debb668139ebd4)

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.

(cherry picked from commit bc046a60cfdd7145fd1e644184ced04d89feb871)

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.

(cherry picked from commit 15736576df739fdcc5e795961dae30c7b0c87967)

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.

(cherry picked from commit 4123650bd0ae53153142949ab5305eb48ec86390)

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.

(cherry picked from commit 83faf7eacd2081a373afb6069fd923c2dc497271)

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.

(cherry picked from commit 2786064d91f46cbdb35a543a883155a3982b9478)

3 years agolibstdc++: Implement LWG 3490 change to drop_while_view::begin()
Patrick Palka [Fri, 21 May 2021 04:05:18 +0000 (00:05 -0400)] 
libstdc++: Implement LWG 3490 change to drop_while_view::begin()

libstdc++-v3/ChangeLog:

PR libstdc++/100606
* include/std/ranges (drop_while_view::begin): Assert the
precondition added by LWG 3490.

(cherry picked from commit 11784fe27d879a10dc8a79212c37f50d4f7146f3)

3 years agolibstdc++: Fix test that fails for C++20
Jonathan Wakely [Tue, 12 Oct 2021 14:39:18 +0000 (15:39 +0100)] 
libstdc++: Fix test that fails for C++20

Restore the test for 'a < a' that was removed by r12-2537 because
it is ill-formed. We still want to test operator< for tuple, we just
need to not use std::nullptr_t in that tuple type.

libstdc++-v3/ChangeLog:

* testsuite/20_util/tuple/comparison_operators/overloaded.cc:
Restore test for operator<.

(cherry picked from commit 727137d6ca6d3d401a0c1b4df6b9aae8b97dacd5)

3 years agolibstdc++: Fix move construction of std::tuple with array elements [PR101960]
Jonathan Wakely [Tue, 12 Oct 2021 14:09:50 +0000 (15:09 +0100)] 
libstdc++: Fix move construction of std::tuple with array elements [PR101960]

The r12-3022 commit only fixed the case where an array is the last
element of the tuple. This fixes the other cases too. We can just define
the move constructor as defaulted, which does the right thing. Changing
the move constructor to be trivial would be an ABI break, but since the
last base class still has a non-trivial move constructor, defining the
derived ones as defaulted doesn't change anything.

libstdc++-v3/ChangeLog:

PR libstdc++/101960
* include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Define as
defauled.
* testsuite/20_util/tuple/cons/101960.cc: Check tuples with
array elements before the last element.

(cherry picked from commit 7481021364e75ba583972e15ed421a53988368ea)

3 years agolibstdc++: Fix testcase for newly-implemented C++20 semantics [PR102535]
Jonathan Wakely [Tue, 5 Oct 2021 08:32:11 +0000 (09:32 +0100)] 
libstdc++: Fix testcase for newly-implemented C++20 semantics [PR102535]

libstdc++-v3/ChangeLog:

PR c++/102535
* testsuite/20_util/is_trivially_constructible/value.cc: Adjust
expected value for C++20.

(cherry picked from commit 7646847df71e57edca5ec5b8c3c3dc4550dcb49d)

3 years agolibstdc++: Move test that depends on wchar_t I/O to wchar_t sub-directory
Jonathan Wakely [Fri, 8 Oct 2021 23:50:04 +0000 (00:50 +0100)] 
libstdc++: Move test that depends on wchar_t I/O to wchar_t sub-directory

This fixes a FAIL when --disable-wchar_t is used.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/close/81256.cc: Moved to...
* testsuite/27_io/basic_filebuf/close/wchar_t/81256.cc: ...here.

(cherry picked from commit cfeff094e6410844d2324193610cb7a512d67713)

3 years agolibstdc++: Ensure std::span and std::string_view are trivially copyable (P2251R1)
Jonathan Wakely [Tue, 5 Oct 2021 15:38:42 +0000 (16:38 +0100)] 
libstdc++: Ensure std::span and std::string_view are trivially copyable (P2251R1)

The recently approved P2251R1 paper requires these types to be trivially
copyable. They always have been in libstdc++, but add tests to check it.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string_view/requirements/trivially_copyable.cc:
New test.
* testsuite/23_containers/span/trivially_copyable.cc: New test.

(cherry picked from commit 1f51e9af7b615838424214e6aaea0de793cb10fe)

3 years agolibstdc++: Fix std::numeric_limits::lowest() test for strict modes
Jonathan Wakely [Mon, 11 Oct 2021 12:28:32 +0000 (13:28 +0100)] 
libstdc++: Fix std::numeric_limits::lowest() test for strict modes

This test uses std::is_integral to decide whether we are testing an
integral or floating-point type. But that fails for __int128 because
is_integral<__int128> is false in strict modes. By using
numeric_limits::is_integer instead we get the right answer for all types
that have a numeric_limits specialization.

We can also simplify the test by removing the unnecessary tag
dispatching.

libstdc++-v3/ChangeLog:

* testsuite/18_support/numeric_limits/lowest.cc: Use
numeric_limits<T>::is_integer instead of is_integral<T>::value.

(cherry picked from commit 45ba5426c129993704a73e6ace4016eaa950d7ee)

3 years agolibstdc++: Fix move construction of std::tuple with array elements [PR101960]
Jonathan Wakely [Thu, 19 Aug 2021 10:48:40 +0000 (11:48 +0100)] 
libstdc++: Fix move construction of std::tuple with array elements [PR101960]

An array member cannot be direct-initialized in a ctor-initializer-list,
so use the base class' move constructor, which does the right thing for
both arrays and non-arrays.

This constructor could be defaulted, but that would make it trivial for
some specializations, which would change the argument passing ABI. Do
that for the versioned namespace only.

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

PR libstdc++/101960
* include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Use base
class' move constructor. Define as defaulted for versioned
namespace.
* testsuite/20_util/tuple/cons/101960.cc: New test.

(cherry picked from commit 0187e0d7360f327f88d8b2294668669306ae4630)

3 years agolibstdc++: Fix CTAD for debug sequence containers
Jonathan Wakely [Tue, 17 Aug 2021 17:19:27 +0000 (18:19 +0100)] 
libstdc++: Fix CTAD for debug sequence containers

This fixes some 23_containers/*/cons/deduction.cc failures seen with
-std=c++17/-D_GLIBCXX_DEBUG, caused by non-immediate errors when
substituting template arguments into an incorrect specialization of the
std::__cxx1998 base class. This happens because the size_type member of
the debug container is _Base_type::size_type, so is non-deducible, and
the deduced types get substituted into _Base_type, triggering the
static_assert that checks the allocator's value_type matches the
container's.

The solution is to make the C(size_type, const T&, const Alloc&)
constructors of the debug sequence containers non-deducible. In order to
make CTAD work again deduction guides that use std::size_t for the first
argument are added.

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

* include/debug/deque (deque(size_type, const T&, const A&)):
Prevent class template argument deduction and replace with a
deduction guide.
* include/debug/forward_list (forward_list(size_type, const T&, const A&)):
Likewise.
* include/debug/list (list(size_type, const T&, const A&)):
Likewise.
* include/debug/vector (vector(size_type, const T&, const A&)):
Likewise.

(cherry picked from commit 085c2f8f0e13d7c1515ce86755a52a31faf0cf47)

3 years agolibstdc++: Install GDB pretty printers for debug library
Jonathan Wakely [Thu, 12 Aug 2021 18:56:14 +0000 (19:56 +0100)] 
libstdc++: Install GDB pretty printers for debug library

The additional libraries installed by --enable-libstdcxx-debug are built
without optimization to aid debugging, but the Python pretty printers
are not installed alongside them. This means that you can step through
the unoptimized library code, but at the expense of pretty printing the
library types.

This remedies the situation by installing another copy of the GDB hooks
alongside the debug version of libstdc++.so.

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

* python/Makefile.am [GLIBCXX_BUILD_DEBUG] (install-data-local):
Install another copy of the GDB hook.
* python/Makefile.in: Regenerate.

(cherry picked from commit db853ff78a34fef25bc16133e0367a64526f9f4e)

3 years agolibstdc++: Add additional overload of std::lerp [PR101870]
Jonathan Wakely [Thu, 12 Aug 2021 16:35:25 +0000 (17:35 +0100)] 
libstdc++: Add additional overload of std::lerp [PR101870]

The [cmath.syn] p1 wording about additional overloads sufficient to
handle any arithmetic types also applies to std::lerp. This adds a new
overload of std::lerp that does the required promotions to support
arguments of arbitrary arithmetic types.

A new __promoted_t alias template is added, which the C++17 function
templates std::hypot and std::lerp can use to avoid instantiating the
__promote_3 class template.

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

PR libstdc++/101870
* include/c_global/cmath (hypot): Use __promoted_t.
(lerp): Add new overload accepting any arithmetic types.
* include/ext/type_traits.h (__promoted_t): New alias template.
* testsuite/26_numerics/lerp.cc: Moved to...
* testsuite/26_numerics/lerp/1.cc: ...here.
* testsuite/26_numerics/lerp/constexpr.cc: New test.
* testsuite/26_numerics/lerp/version.cc: New test.

(cherry picked from commit 9017326e19fe278d5f62898cca4682b17f8e8e07)

3 years agolibstdc++: Add pretty printer for std::error_code and std::error_condition
Jonathan Wakely [Mon, 16 Aug 2021 16:41:50 +0000 (17:41 +0100)] 
libstdc++: Add pretty printer for std::error_code and std::error_condition

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

* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Define.
(build_libstdcxx_dictionary): Register printer for
std::error_code and std::error_condition.
* testsuite/libstdc++-prettyprinters/cxx11.cc: Test it.

(cherry picked from commit 2db38d9fcacf522fe9b98ba847e79ba33abdcadc)

3 years agolibstdc++: Optimize std::function move constructor [PR101923]
Jonathan Wakely [Tue, 17 Aug 2021 10:30:56 +0000 (11:30 +0100)] 
libstdc++: Optimize std::function move constructor [PR101923]

PR 101923 points out that the unconditional swap in the std::function
move constructor makes it slower than copying an empty std::function.
The copy constructor has to check for the empty case before doing
anything, and that makes it very fast for the empty case.

Adding the same check to the move constructor avoids copying the
_Any_data POD when we don't need to. We can also inline the effects of
swap, by copying each member and then zeroing the pointer members.

This makes moving an empty object at least as fast as copying an empty
object.

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

PR libstdc++/101923
* include/bits/std_function.h (function(function&&)): Check for
non-empty parameter before doing any work.

(cherry picked from commit 0808b0df9c4d31f4c362b9c85fb538b6aafcb517)

3 years agolibstdc++: std::system_category should know meaning of zero [PR102425]
Jonathan Wakely [Wed, 22 Sep 2021 10:58:20 +0000 (11:58 +0100)] 
libstdc++: std::system_category should know meaning of zero [PR102425]

Although 0 is not an errno value, it should still be recognized as
corresponding to a value belonging to the generic_category().

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

PR libstdc++/102425
* src/c++11/system_error.cc
(system_error_category::default_error_condition): Add 0 to
switch.
* testsuite/19_diagnostics/error_category/102425.cc: New test.

(cherry picked from commit ce01e2e64c340dadb55a8a24c545a13e654804d4)

3 years agolibstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761]
Thomas Rodgers [Thu, 16 Sep 2021 21:42:58 +0000 (14:42 -0700)] 
libstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761]

Remove UB in atomic_ref/wait_notify test.

Signed-off-by: Thomas Rodgers <trodgers@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/101761
* testsuite/29_atomics/atomic_ref/wait_notify.cc (test): Use
va and vb as arguments to wait/notify, remove unused bb local.

(cherry picked from commit f9f1a6efaaeeec06d5c07378734cb8eb47b976a7)

3 years agolibstdc++: Remove non-deducible parameter for std::advance overload
Jonathan Wakely [Thu, 16 Sep 2021 12:35:24 +0000 (13:35 +0100)] 
libstdc++: Remove non-deducible parameter for std::advance overload

This was just a copy and paste error.

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

* include/bits/fs_path.h (advance): Remove non-deducible
template parameter.

(cherry picked from commit 21c760510d31253074577a14021fdc6ad44084b6)

3 years agolibstdc++: Fix inefficiency in filesystem::absolute [PR99876]
Jonathan Wakely [Fri, 27 Aug 2021 09:59:54 +0000 (10:59 +0100)] 
libstdc++: Fix inefficiency in filesystem::absolute [PR99876]

When the path is already absolute, the call to current_path() is
wasteful, because operator/ will ignore the left operand anyway.

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

PR libstdc++/99876
* src/c++17/fs_ops.cc (fs::absolute): Call non-throwing form,
to avoid unnecessary current_path() call.

(cherry picked from commit 07b990ee23e0c7a92d362dbb25fd5d57d95eb8be)

3 years agolibstdc++: Add missing return for atomic timed wait [PR102074]
Jonathan Wakely [Tue, 31 Aug 2021 15:50:17 +0000 (16:50 +0100)] 
libstdc++: Add missing return for atomic timed wait [PR102074]

This adds a missing return statement to the non-futex wait-until
operation.

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

PR libstdc++/102074
* include/bits/atomic_timed_wait.h (__timed_waiter_pool)
[!_GLIBCXX_HAVE_PLATFORM_TIMED_WAIT]: Add missing return.

(cherry picked from commit 763eb1f19239ebb19c0f87590a4f02300c02c52b)

3 years agolibstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270]
Jonathan Wakely [Fri, 17 Sep 2021 11:27:02 +0000 (12:27 +0100)] 
libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270]

Also rename the test so it actually runs.

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

PR libstdc++/102270
* include/std/tuple (_Tuple_impl): Add constexpr to constructor
missed in previous patch.
* testsuite/20_util/tuple/cons/102270.C: Moved to...
* testsuite/20_util/tuple/cons/102270.cc: ...here.
* testsuite/util/testsuite_allocator.h (SimpleAllocator): Add
constexpr to constructor so it can be used for C++20 tests.

(cherry picked from commit 1fa2c5a695bb962ffcf8abed49f69cdcc59d0e61)

3 years agolibstdc++: Add missing 'constexpr' to std::tuple [PR102270]
Jonathan Wakely [Wed, 15 Sep 2021 20:53:35 +0000 (21:53 +0100)] 
libstdc++: Add missing 'constexpr' to std::tuple [PR102270]

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

PR libstdc++/102270
* include/std/tuple (_Head_base, _Tuple_impl): Add
_GLIBCXX20_CONSTEXPR to allocator-extended constructors.
(tuple<>::swap(tuple&)): Add _GLIBCXX20_CONSTEXPR.
* testsuite/20_util/tuple/cons/102270.C: New test.

(cherry picked from commit 734b2c2eedca50d966e22540fc136158c3633393)

3 years agolibstdc++: Rename tests with incorrect extension
Jonathan Wakely [Fri, 17 Sep 2021 11:25:40 +0000 (12:25 +0100)] 
libstdc++: Rename tests with incorrect extension

The libstdc++ testsuite only runs .cc files, so these two old tests have
never been run.

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

* testsuite/26_numerics/valarray/dr630-3.C: Moved to...
* testsuite/26_numerics/valarray/dr630-3.cc: ...here.
* testsuite/27_io/basic_iostream/cons/16251.C: Moved to...
* testsuite/27_io/basic_iostream/cons/16251.cc: ...here.

(cherry picked from commit 749c31b345c2a37106b57ce805ea46a6d4765e09)

3 years agolibstdc++: Add missing constraint to std::span deduction guide [PR102280]
Jonathan Wakely [Wed, 15 Sep 2021 20:49:29 +0000 (21:49 +0100)] 
libstdc++: Add missing constraint to std::span deduction guide [PR102280]

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

PR libstdc++/102280
* include/std/span (span(Range&&)): Add constraint to deduction
guide.

(cherry picked from commit e67917f5df9d84f5aed3513b3931a82870d25135)

3 years agolibstdc++: Add missing header to test
Jonathan Wakely [Fri, 1 Oct 2021 11:55:53 +0000 (12:55 +0100)] 
libstdc++: Add missing header to test

We need to include <iterator> (or one of the containers) to get a
definition for std::begin.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/is_permutation/2.cc: Include <iterator>.

(cherry picked from commit 94311bf34704ebecf745043fe2df03df201052fe)

3 years agolibstdc++: Add test for std::cmp_greater
Jonathan Wakely [Tue, 5 Oct 2021 09:38:03 +0000 (10:38 +0100)] 
libstdc++: Add test for std::cmp_greater

This was omitted from the commit that added these comparisons.

libstdc++-v3/ChangeLog:

* testsuite/20_util/integer_comparisons/greater.cc: New test.

(cherry picked from commit 824e0855732c601e0866d0e8a9264a85f758213e)

3 years agolibstdc++: Fix std::match_results::end() for failed matches [PR102667]
Jonathan Wakely [Mon, 11 Oct 2021 08:07:15 +0000 (09:07 +0100)] 
libstdc++: Fix std::match_results::end() for failed matches [PR102667]

The end() function needs to consider whether the underlying vector is
empty, not whether the match_results object is empty. That's because the
underlying vector will always contain at least three elements for a
match_results object that is "ready". It contains three extra elements
which are stored in the vector but are not considered part of sequence,
and so should not be part of the [begin(),end()) range.

libstdc++-v3/ChangeLog:

PR libstdc++/102667
* include/bits/regex.h (match_result::empty()): Optimize by
calling the base function directly.
(match_results::end()): Check _Base_type::empty() not empty().
* testsuite/28_regex/match_results/102667.C: New test.

(cherry picked from commit 84088dc4bb6a546c896a068dc201463493babf43)

3 years agoFix PR target/102588
Eric Botcazou [Tue, 12 Oct 2021 09:20:42 +0000 (11:20 +0200)] 
Fix PR target/102588

We need a 32-byte wide integer mode (OImode) in order to handle structure
returns in the 64-bit ABI.

gcc/
PR target/102588
* config/sparc/sparc-modes.def (OI): New integer mode.

3 years agoDaily bump.
GCC Administrator [Tue, 12 Oct 2021 00:18:26 +0000 (00:18 +0000)] 
Daily bump.

3 years agotree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0"
Andrew Pinski [Sun, 10 Oct 2021 01:28:59 +0000 (01:28 +0000)] 
tree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0"

Since the problem was already fixed on this branch, we just want to add the
testcase so it does not regress there.

PR tree-optimization/102622

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/bitfld-10.c: New test.

(cherry picked from commit 882d806c1a8f9d2d2ade1133de88d63e5d4fe40c)

3 years agodoc: improve -fsanitize=undefined description
Diane Meirowitz [Wed, 15 Sep 2021 21:03:00 +0000 (21:03 +0000)] 
doc: improve -fsanitize=undefined description

gcc/ChangeLog:
* doc/invoke.texi: Add link to UndefinedBehaviorSanitizer
documentation, mention UBSAN_OPTIONS, similar to what is done
for AddressSanitizer.

(cherry picked from commit 1c0a83eff7bb5b1db997a9726ae6542aec893baa)

3 years agoDaily bump.
GCC Administrator [Mon, 11 Oct 2021 00:17:58 +0000 (00:17 +0000)] 
Daily bump.

3 years agovar-tracking: Fix a wrong-debug issue caused by my r10-7665 var-tracking change ...
Jakub Jelinek [Sun, 10 Oct 2021 10:13:22 +0000 (12:13 +0200)] 
var-tracking: Fix a wrong-debug issue caused by my r10-7665 var-tracking change [PR102441]

Since my r10-7665-g33c45e51b4914008064d9b77f2c1fc0eea1ad060 change, we get
wrong-debug on e.g. the following testcase at -O2 -g on x86_64-linux for the
x parameter:
void bar (int *r);
int
foo (int x)
{
  int r = 0;
  bar (&r);
  return r;
}
At the start of function, we have
        subq    $24, %rsp
        leaq    12(%rsp), %rdi
instructions.  The x parameter is passed in %rdi, but isn't used in the
function and so the leaq instruction overwrites %rdi without remembering
%rdi anywhere.  Before the r10-7665 change (which was trying to fix a large
(3% for 32-bit, 1% for 64-bit x86-64) debug info/loc growth introduced with
r10-7515), the leaq insn above resulted in a MO_VAL_SET micro-operation that
said that the value of sp + 12, a cselib_sp_derived_value_p, is stored into
the %rdi register.  The r10-7665 change added a change to add_stores that
added no micro-operation for the leaq store, with the rationale that the sp
based values can be and will be always computable some other more compact
and primarily more stable way (cfa based expression like DW_OP_fbreg, that
is the same in the whole function).  That is true.  But by throwing the
micro-operation on the floor, we miss another important part of the
MO_VAL_SET, in particular that the destination of the store, %rdi in this
case, now has a different value from what it had before, so the vt_*
dataflow code thinks that even after the leaq instruction %rdi still holds
the x argument value (and changes it to DW_OP_entry_value (%rdi) only in the
middle of the call to bar).  Previously and with the patches below,
the location for x changes already at the end of leaq instruction to
DW_OP_entry_value (%rdi).

My first attempt to fix this was instead of dropping the MO_VAL_SET add
a MO_CLOBBER operation:
--- gcc/var-tracking.c.jj       2021-05-04 21:02:24.196799586 +0200
+++ gcc/var-tracking.c  2021-09-24 19:23:16.420154828 +0200
@@ -6133,7 +6133,9 @@ add_stores (rtx loc, const_rtx expr, voi
     {
       if (preserve)
        preserve_value (v);
-      return;
+      mo.type = MO_CLOBBER;
+      mo.u.loc = loc;
+      goto log_and_return;
     }

   nloc = replace_expr_with_values (oloc);
so don't track that the value lives in the loc destination, but track
that the previous value doesn't live there anymore.  That failed bootstrap
miserably, the vt_* code isn't prepared to see MO_CLOBBER of a MEM that
isn't tracked (e.g. has MEM_EXPR on it that the var-tracking code wants
to track, i.e. track_p in add_stores).  On the other side, thinking about
it more, in the most common case where a cselib_sp_derived_value_p value
is stored into the sp register (and which is the reason why PR94495
testcase got larger), dropping the micro-operation on the floor is the
right thing, because we have that cselib_sp_derived_value_p tracking, any
reads from the sp hard register will be treated as
cselib_sp_derived_value_p.
Then I've tried 3 different patches described below and in the end
what is committed is patch2.
Additionally, I've gathered statistics from cc1plus by always reverting the
var-tracking.c change after finished bootstrap/regtest and rebuilding the
stage3 var-tracking.o and cc1plus, such that it would be comparable.
dwlocstat and .debug_{info,loclists} section sizes detailed below.
patch3 uses MO_VAL_SET (i.e. essentially reversion of the r10-7665
change) when destination is not a REG_P and !track_p, otherwise if
destination is sp drops the micro-operation on the floor (i.e. no change),
otherwise adds a MO_CLOBBER.
patch1 is similar, except it checks for destination not equal to sp and
!track_p, i.e. for !track_p REG_P destinations other than sp it will use
MO_VAL_SET rather than MO_CLOBBER.
Finally, patch2, the shortest patch, uses MO_VAL_SET whenever destination
is not sp and otherwise drops the micro-operation on the floor.
All the 3 patches don't affect the PR94495 testcase, all the changes
there were caused by stores of sp based values into %rsp.

While the patch2 (and patch1 which results in exactly the same sizes)
causes the largest debug loclists/info growth from the 3, it is still quite
minor (0.651% on 64-bit and 0.114% on 32-bit) compared
to the 1% and 3% PR94495 was trying to solve, and I actually think it is the
best thing to do.  Because, if we have say
  int q[10];
  int *p = &q[0];
or similar and we load the &q[0] sp based value into some hard register,
by noting in the debug info that p lives in some hard reg for some part
of the function and a user is trying to change the p var in the debugger,
if we say it lives in some register or memory, there is some chance that
the changing of the value could work successfully (of course, nothing
is guaranteed, we don't have tracking of where each var lives at which
moment for changing purposes (i.e. what register, memory or else you need
to change in order to change behavior of the code)), while if we just say
that p's location is DW_OP_fbreg 16 DW_OP_stack_value, that is a read-only
value one can just print but not change.  Now, for stores of variable
values into the sp register, I don't think we have such an issue, you don't
want debugger to change your stack pointer when user asks to change value
of some variable whose value lives in the stack pointer, that would pretty
much always result in misbehavior of the program.
So, my preference from these 3 is patch2 and that is being committed.

64-bit cc1plus
==============
vanilla
cov%    samples cumul
0..10   1064665/37%     1064665/37%
11..20  35972/1%        1100637/38%
21..30  47969/1%        1148606/40%
31..40  45787/1%        1194393/42%
41..50  57529/2%        1251922/44%
51..60  53974/1%        1305896/46%
61..70  112055/3%       1417951/50%
71..80  79420/2%        1497371/52%
81..90  126225/4%       1623596/57%
91..100 1206682/42%     2830278/100%
  [34] .debug_info       PROGBITS        0000000000000000 2f1c74c a44949f 00      0   0  1
  [38] .debug_loclists   PROGBITS        0000000000000000 ff5d046 506e947 00      0   0  1
patch1 (same as patch2)
cov%    samples cumul
0..10   1064685/37%     1064685/37%
11..20  36011/1%        1100696/38%
21..30  47975/1%        1148671/40%
31..40  45799/1%        1194470/42%
41..50  57566/2%        1252036/44%
51..60  54011/1%        1306047/46%
61..70  112068/3%       1418115/50%
71..80  79421/2%        1497536/52%
81..90  126171/4%       1623707/57%
91..100 1206571/42%     2830278/100%
  [34] .debug_info       PROGBITS        0000000000000000 2f1c74c a448f27 00      0   0  1
  [38] .debug_loclists   PROGBITS        0000000000000000 ff608bc 52070dd 00      0   0  1
patch3
cov%    samples cumul
0..10   1064698/37%     1064698/37%
11..20  36018/1%        1100716/38%
21..30  47977/1%        1148693/40%
31..40  45804/1%        1194497/42%
41..50  57562/2%        1252059/44%
51..60  54018/1%        1306077/46%
61..70  112071/3%       1418148/50%
71..80  79424/2%        1497572/52%
81..90  126172/4%       1623744/57%
91..100 1206534/42%     2830278/100%
  [34] .debug_info       PROGBITS        0000000000000000 2f1c74c a449548 00      0   0  1
  [38] .debug_loclists   PROGBITS        0000000000000000 ff5df39 507acd8 00      0   0  1
So, size of .debug_info+.debug_loclists grows for vanilla -> patch1 (or patch2) by
0.651% and for vanilla -> patch3 by 0.020%.

32-bit cc1plus
==============
vanilla
cov%    samples cumul
0..10   1061892/37%     1061892/37%
11..20  34002/1%        1095894/39%
21..30  43513/1%        1139407/40%
31..40  41667/1%        1181074/42%
41..50  59144/2%        1240218/44%
51..60  47009/1%        1287227/45%
61..70  105069/3%       1392296/49%
71..80  72990/2%        1465286/52%
81..90  125988/4%       1591274/56%
91..100 1208726/43%     2800000/100%
  [33] .debug_info       PROGBITS        00000000 351ab10 8b1c83d 00      0   0  1
  [37] .debug_loclists   PROGBITS        00000000 ebc816e 3fe44fd 00      0   0  1
patch1 (same as patch2)
cov%    samples cumul
0..10   1061999/37%     1061999/37%
11..20  34065/1%        1096064/39%
21..30  43557/1%        1139621/40%
31..40  41690/1%        1181311/42%
41..50  59191/2%        1240502/44%
51..60  47143/1%        1287645/45%
61..70  105045/3%       1392690/49%
71..80  73021/2%        1465711/52%
81..90  125885/4%       1591596/56%
91..100 1208404/43%     2800000/100%
  [33] .debug_info       PROGBITS        00000000 351ab10 8b1c597 00      0   0  1
  [37] .debug_loclists   PROGBITS        00000000 ebca915 401ffad 00      0   0  1
patch3
cov%    samples cumul
0..10   1062006/37%     1062006/37%
11..20  34073/1%        1096079/39%
21..30  43559/1%        1139638/40%
31..40  41693/1%        1181331/42%
41..50  59189/2%        1240520/44%
51..60  47142/1%        1287662/45%
61..70  105054/3%       1392716/49%
71..80  73027/2%        1465743/52%
81..90  125874/4%       1591617/56%
91..100 1208383/43%     2800000/100%
  [33] .debug_info       PROGBITS        00000000 351ab10 8b1c690 00      0   0  1
  [37] .debug_loclists   PROGBITS        00000000 ebca40a 4020a6e 00      0   0  1
So, size of .debug_info+.debug_loclists grows for vanilla -> patch1 (or patch2) by
0.114% and for vanilla -> patch3 by 0.116%.

2021-10-10  Jakub Jelinek  <jakub@redhat.com>

PR debug/102441
* var-tracking.c (add_stores): For cselib_sp_derived_value_p values
use MO_VAL_SET if loc is not sp.

(cherry picked from commit 9583b26f3701ea0456405d84f9a898451a2f7452)

3 years agoDaily bump.
GCC Administrator [Sun, 10 Oct 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

3 years agoDaily bump.
GCC Administrator [Sat, 9 Oct 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

3 years agoopenmp: Fix up declare target handling for vars with DECL_LOCAL_DECL_ALIAS [PR102640]
Jakub Jelinek [Fri, 8 Oct 2021 08:58:56 +0000 (10:58 +0200)] 
openmp: Fix up declare target handling for vars with DECL_LOCAL_DECL_ALIAS [PR102640]

The introduction of DECL_LOCAL_DECL_ALIAS and push_local_extern_decl_alias
in r11-3699-g4e62aca0e0520e4ed2532f2d8153581190621c1a broke the following
testcase.  The following patch fixes it by treating similarly not just
the variable to or link clause is put on, but also its DECL_LOCAL_DECL_ALIAS
if any.  If it hasn't been created yet, when it is created it will copy
attributes and therefore should get it for free, and as it is an extern,
nothing more than attributes is needed for it.

2021-10-08  Jakub Jelinek  <jakub@redhat.com>

PR c++/102640
gcc/cp/
* parser.c (handle_omp_declare_target_clause): New function.
(cp_parser_omp_declare_target): Use it.
gcc/testsuite/
* c-c++-common/gomp/pr102640.c: New test.

(cherry picked from commit db3d7270b42fe27fb05664c4fdf524ab7ad13a75)

3 years agoDaily bump.
GCC Administrator [Fri, 8 Oct 2021 00:17:59 +0000 (00:17 +0000)] 
Daily bump.

3 years agoc++: variadic ttp constraint subsumption [PR99904]
Patrick Palka [Thu, 7 Oct 2021 14:02:54 +0000 (10:02 -0400)] 
c++: variadic ttp constraint subsumption [PR99904]

Here we're crashing when level-lowering the variadic constraint C<Ts...>
on the template template parameter TT because tsubst_pack_expansion expects
processing_template_decl to be set during a partial substitution.

PR c++/99904

gcc/cp/ChangeLog:

* pt.c (is_compatible_template_arg): Set processing_template_decl
around tsubst_constraint_info.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ttp4.C: New test.

(cherry picked from commit 2e6e0d86a06389056d0e7fecc99c547420ad787a)

3 years agoDaily bump.
GCC Administrator [Thu, 7 Oct 2021 00:18:08 +0000 (00:18 +0000)] 
Daily bump.

3 years agoc++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]
Patrick Palka [Tue, 5 Oct 2021 19:35:21 +0000 (15:35 -0400)] 
c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]

Here during partial ordering of the two partial specializations we end
up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly
thereafter because uses_template_parms(parms) calls potential_const_expr
which doesn't handle NONTYPE_ARGUMENT_PACK.

This patch fixes this by extending potential_constant_expression to handle
NONTYPE_ARGUMENT_PACK appropriately.

PR c++/102547

gcc/cp/ChangeLog:

* constexpr.c (potential_constant_expression_1): Handle
NONTYPE_ARGUMENT_PACK.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-partial2.C: New test.
* g++.dg/cpp0x/variadic-partial2a.C: New test.

(cherry picked from commit d4c470c376b4cb82c9a0b7e8a4b88c44d5e4289d)

3 years agoc++: __is_trivially_xible and multi-arg aggr paren init [PR102535]
Patrick Palka [Thu, 30 Sep 2021 21:54:17 +0000 (17:54 -0400)] 
c++: __is_trivially_xible and multi-arg aggr paren init [PR102535]

is_xible_helper assumes only 0- and 1-argument ctors can be trivial, but
C++20 aggregate paren init means multi-arg ctors can now be trivial too.
This patch relaxes the relevant early exit check accordingly.

PR c++/102535

gcc/cp/ChangeLog:

* method.c (is_xible_helper): Don't exit early for multi-arg
ctors in C++20.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_trivially_constructible7.C: New test.

(cherry picked from commit 9845c52db38f15740861435f38f7e5ad8a8de2ec)

3 years agoc++: defaulted comparisons and vptr fields [PR95567]
Patrick Palka [Thu, 30 Sep 2021 21:29:05 +0000 (17:29 -0400)] 
c++: defaulted comparisons and vptr fields [PR95567]

We need to explicitly skip over vptr fields when synthesizing a
defaulted comparison operator, because next_initializable_field
doesn't do so for us.

PR c++/95567

gcc/cp/ChangeLog:

* method.c (build_comparison_op): Skip DECL_VIRTUAL_P fields.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-virtual1.C: New test.

(cherry picked from commit b6bca2e631b54f992c058ca8e445b45e9816690b)

3 years agoreal: fix encoding of negative IEEE double/quad values [PR98216]
Patrick Palka [Fri, 24 Sep 2021 16:36:26 +0000 (12:36 -0400)] 
real: fix encoding of negative IEEE double/quad values [PR98216]

In encode_ieee_double/quad, the assignment

  unsigned long WORD = r->sign << 31;

is intended to set the 31st bit of WORD whenever the sign bit is set.
But on LP64 hosts it also unintentionally sets the upper 32 bits of WORD,
because r->sign gets promoted from unsigned:1 to int and then the result
of the shift (equal to INT_MIN) gets sign extended from int to long.

In the C++ frontend, this bug causes incorrect mangling of negative
floating point values because the output of real_to_target called from
write_real_cst unexpectedly has the upper 32 bits of this word set,
which the caller doesn't mask out.

This patch fixes this by avoiding the unwanted sign extension.  Note
that r0-53976 fixed the same bug in encode_ieee_single long ago.

PR c++/98216
PR c++/91292

gcc/ChangeLog:

* real.c (encode_ieee_double): Avoid unwanted sign extension.
(encode_ieee_quad): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-float2.C: New test.

(cherry picked from commit 34947d4e97ee72b26491cfe5ff4fa8258fadbe95)

3 years agoc++: concept-ids and value-dependence [PR102412]
Patrick Palka [Wed, 22 Sep 2021 15:16:53 +0000 (11:16 -0400)] 
c++: concept-ids and value-dependence [PR102412]

The problem here is that uses_template_parms returns true for all
concept-ids (even those with non-dependent arguments), so when a concept-id
is used as a default template argument then during deduction the default
argument is considered dependent even after substituting into it, which
leads to deduction failure (from type_unification_real).

This patch fixes this by implementing the resolution of CWG 2446 which
says a concept-id is dependent only if its arguments are.

DR 2446
PR c++/102412

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_constant_expression)
<case TEMPLATE_ID_EXPR>: Check value_dependent_expression_p
instead of processing_template_decl.
* pt.c (value_dependent_expression_p) <case TEMPLATE_ID_EXPR>:
Return true only if any_dependent_template_arguments_p.
(instantiation_dependent_r) <case CALL_EXPR>: Remove this case.
<case TEMPLATE_ID_EXPR>: Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-nondep2.C: New test.
* g++.dg/cpp2a/concepts-nondep3.C: New test.

(cherry picked from commit 9329344a6d81a6a5e3bd171167ebc7b158bb44f4)

3 years agoc++: constrained variable template issues [PR98486]
Patrick Palka [Thu, 16 Sep 2021 19:03:55 +0000 (15:03 -0400)] 
c++: constrained variable template issues [PR98486]

This fixes some issues with constrained variable templates:

  - Constraints aren't checked when explicitly specializing a variable
    template.
  - Constraints aren't attached to a static data member template at
    parse time.
  - Constraints don't get propagated when (partially) instantiating a
    static data member template, so we need to make sure to look up
    constraints using the most general template during satisfaction.

PR c++/98486

gcc/cp/ChangeLog:

* constraint.cc (get_normalized_constraints_from_decl): Always
look up constraints using the most general template.
* decl.c (grokdeclarator): Set constraints on a static data
member template.
* pt.c (determine_specialization): Check constraints on a
variable template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-var-templ1.C: New test.
* g++.dg/cpp2a/concepts-var-templ1a.C: New test.
* g++.dg/cpp2a/concepts-var-templ1b.C: New test.

(cherry picked from commit 2e2e65a46d2674bed53afd211493876ee2b79453)

3 years agoc++: empty union member activation during constexpr [PR102163]
Patrick Palka [Tue, 14 Sep 2021 15:22:12 +0000 (11:22 -0400)] 
c++: empty union member activation during constexpr [PR102163]

Here, the union's constructor is defined to activate its empty data
member _M_rest, but during constexpr evaluation of this constructor the
subobject constructor call O::O(&_M_rest, 42) doesn't produce a side
effect that actually activates the member, so the union still appears
uninitialized after its constructor has run.  This patch fixes this by
using a dummy MODIFY_EXPR in this situation, whose evaluation ensures
the member gets activated.

PR c++/102163

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_call_expression): After evaluating a
subobject constructor call for an empty union member, produce a
side effect that makes sure the member gets activated.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty17.C: New test.

(cherry picked from commit de07cff96abd43f6f65dcf333958899c2ec42598)

3 years agoc++: aggregate CTAD and brace elision [PR101344]
Patrick Palka [Wed, 18 Aug 2021 12:37:45 +0000 (08:37 -0400)] 
c++: aggregate CTAD and brace elision [PR101344]

Here the problem is ultimately that collect_ctor_idx_types always
recurses into an eligible sub-CONSTRUCTOR regardless of whether the
corresponding pair of braces was elided in the original initializer.
This causes us to reject some completely-braced forms of aggregate
CTAD as in the first testcase below, because collect_ctor_idx_types
effectively assumes that the original initializer is always minimally
braced (and so the aggregate deduction candidate is given a function
type that's incompatible with the original completely-braced initializer).

In order to fix this, collect_ctor_idx_types needs to somehow know the
shape of the original initializer when iterating over the reshaped
initializer.  To that end this patch makes reshape_init flag sub-ctors
that were built to undo brace elision in the original ctor, so that
collect_ctor_idx_types that determine whether to recurse into a sub-ctor
by simply inspecting this flag.

This happens to also fix PR101820, which is about aggregate CTAD using
designated initializers, for much the same reasons.

A curious case is the "intermediately-braced" initialization of 'e3'
(which we reject) in the first testcase below.  It seems to me we're
behaving as specified here (according to [over.match.class.deduct]/1)
because the initializer element x_1={1, 2, 3, 4} corresponds to the
subobject e_1=E::t, hence the type T_1 of the first function parameter
of the aggregate deduction candidate is T(&&)[2][2], but T can't be
deduced from x_1 using this parameter type (as opposed to say T(&&)[4]).

PR c++/101344
PR c++/101803

gcc/cp/ChangeLog:

* cp-tree.h (CONSTRUCTOR_BRACES_ELIDED_P): Define.
* decl.c (reshape_init_r): Set it.
* pt.c (collect_ctor_idx_types): Recurse into a sub-CONSTRUCTOR
iff CONSTRUCTOR_BRACES_ELIDED_P.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-aggr11.C: New test.
* g++.dg/cpp2a/class-deduction-aggr12.C: New test.

(cherry picked from commit be4a4fb516688d7cfe28a80a4aa333f4ecf0b518)

3 years agoc++: ignore explicit dguides during NTTP CTAD [PR101883]
Patrick Palka [Wed, 18 Aug 2021 12:37:42 +0000 (08:37 -0400)] 
c++: ignore explicit dguides during NTTP CTAD [PR101883]

Since (template) argument passing is a copy-initialization context,
we mustn't consider explicit deduction guides when deducing a CTAD
placeholder type of an NTTP.

PR c++/101883

gcc/cp/ChangeLog:

* pt.c (convert_template_argument): Pass LOOKUP_IMPLICIT to
do_auto_deduction.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class49.C: New test.

(cherry picked from commit a6b3db3e8625a3cba1240f0b5e1a29bd6c68b8ca)

3 years agoFortran: Fix deprecate warning with parameter
Tobias Burnus [Wed, 6 Oct 2021 06:47:40 +0000 (08:47 +0200)] 
Fortran: Fix deprecate warning with parameter

Only warn with !GCC$ ATTRIBUTES DEPRECATED if
deprecated PARMETERS are actually used.

gcc/fortran/ChangeLog:

* resolve.c (resolve_values): Only show
deprecated warning if attr.referenced.

gcc/testsuite/ChangeLog:

* gfortran.dg/attr_deprecated-2.f90: New test.

(cherry picked from commit ece8b0fce6bbfb1e531de8164da47eeed80d3cf1)

3 years agoDaily bump.
GCC Administrator [Wed, 6 Oct 2021 00:18:08 +0000 (00:18 +0000)] 
Daily bump.

3 years agoc++: Fix apply_identity_attributes [PR102548]
Jakub Jelinek [Tue, 5 Oct 2021 20:28:38 +0000 (22:28 +0200)] 
c++: Fix apply_identity_attributes [PR102548]

The following testcase ICEs on x86_64-linux with -m32 due to a bug in
apply_identity_attributes.  The function is being smart and attempts not
to duplicate the chain unnecessarily, if either there are no attributes
that affect type identity or there is possibly empty set of attributes
that do not affect type identity in the chain followed by attributes
that do affect type identity, it reuses that attribute chain.

The function mishandles the cases where in the chain an attribute affects
type identity and is followed by one or more attributes that don't
affect type identity (and then perhaps some further ones that do).

There are two bugs.  One is that when we notice first attribute that
doesn't affect type identity after first attribute that does affect type
identity (with perhaps some further such attributes in the chain after it),
we want to put into the new chain just attributes starting from
(inclusive) first_ident and up to (exclusive) the current attribute a,
but the code puts into the chain all attributes starting with first_ident,
including the ones that do not affect type identity and if e.g. we have
doesn't0 affects1 doesn't2 affects3 affects4 sequence of attributes, the
resulting sequence would have
affects1 doesn't2 affects3 affects4 affects3 affects4
attributes, i.e. one attribute that shouldn't be there and two attributes
duplicated.  That is fixed by the a2 -> a2 != a change.

The second one is that we ICE once we see second attribute that doesn't
affect type identity after an attribute that affects it.  That is because
first_ident is set to error_mark_node after handling the first attribute
that doesn't affect type identity (i.e. after we've copied the
[first_ident, a) set of attributes to the new chain) to denote that from
that time on, each attribute that affects type identity should be copied
whenever it is seen (the if (as && as->affects_type_identity) code does
that correctly).  But that condition is false and first_ident is
error_mark_node, we enter else if (first_ident) and use TREE_PURPOSE
/TREE_VALUE/TREE_CHAIN on error_mark_node, which ICEs.  When
first_ident is error_mark_node and a doesn't affect type identity,
we want to do nothing.  So that is the && first_ident != error_mark_node
chunk.

2021-10-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/102548
* tree.c (apply_identity_attributes): Fix handling of the
case where an attribute in the list doesn't affect type
identity but some attribute before it does.

* g++.target/i386/pr102548.C: New test.

(cherry picked from commit 737f95bab557584d876f02779ab79fe3cfaacacf)

3 years agoubsan: Use -fno{,-}sanitize=float-divide-by-zero for float division by zero recovery...
Jakub Jelinek [Fri, 1 Oct 2021 12:27:32 +0000 (14:27 +0200)] 
ubsan: Use -fno{,-}sanitize=float-divide-by-zero for float division by zero recovery [PR102515]

We've been using
-f{,no-}sanitize-recover=integer-divide-by-zero to decide on the float
-fsanitize=float-divide-by-zero instrumentation _abort suffix.
This patch fixes it to use -f{,no-}sanitize-recover=float-divide-by-zero
for it instead.

2021-10-01  Jakub Jelinek  <jakub@redhat.com>
    Richard Biener  <rguenther@suse.de>

PR sanitizer/102515
gcc/c-family/
* c-ubsan.c (ubsan_instrument_division): Check the right
flag_sanitize_recover bit, depending on which sanitization
is done.
gcc/testsuite/
* c-c++-common/ubsan/float-div-by-zero-2.c: New test.

(cherry picked from commit 9c1a633d96926357155d4702b66f8a0ec856a81f)

3 years agoc++: Fix handling of __thread/thread_local extern vars declared at function scope...
Jakub Jelinek [Fri, 1 Oct 2021 08:30:16 +0000 (10:30 +0200)] 
c++: Fix handling of __thread/thread_local extern vars declared at function scope [PR102496]

The introduction of push_local_extern_decl_alias in
r11-3699-g4e62aca0e0520e4ed2532f2d8153581190621c1a
broke tls vars, while the decl they are created for has the tls model
set properly, nothing sets it for the alias that is actually used,
so accesses to it are done as if they were normal variables.
This is then diagnosed at link time if the definition of the extern
vars is __thread/thread_local.

2021-10-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/102496
* name-lookup.c (push_local_extern_decl_alias): Return early even for
tls vars with non-dependent type when processing_template_decl.  For
CP_DECL_THREAD_LOCAL_P vars call set_decl_tls_model on alias.

* g++.dg/tls/pr102496-1.C: New test.
* g++.dg/tls/pr102496-2.C: New test.

(cherry picked from commit 701075864ac4d1c6cec936d10f9cfc2aeb8c1699)