]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
21 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.cc (lto_read_tree_1): Use lto_input_tree_1
to input DECL_INITIAL, avoiding to commit drefs.

(cherry picked from commit 2a1448f2763a72c83e2ec496f78243a975b0d44e)

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

21 months agolibgccjit.h: Uncomment macro definition for testing gcc_jit_context_new_bitcast support
Vibhav Pant [Tue, 9 Aug 2022 23:06:43 +0000 (19:06 -0400)] 
libgccjit.h: Uncomment macro definition for testing gcc_jit_context_new_bitcast support

(cherry-picked from r13-2004-g9385cd9c74cf66)

The macro definition for LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
was earlier located in the documentation comment for
gcc_jit_context_new_bitcast, making it unavailable to code that
consumed libgccjit.h. This commit moves the definition out of the
comment, making it effective.

gcc/jit/ChangeLog:
* libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast): Move
definition out of comment.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
21 months agod: Fix undefined reference to pragma(inline) symbol (PR106563)
Iain Buclaw [Tue, 9 Aug 2022 10:48:14 +0000 (12:48 +0200)] 
d: Fix undefined reference to pragma(inline) symbol (PR106563)

Functions that are declared `pragma(inline)' should be treated as if
they are defined in every translation unit they are referenced from,
regardless of visibility protection.  Ensure they always get
DECL_ONE_ONLY linkage, and start emitting them into other modules that
import them.

PR d/106563

gcc/d/ChangeLog:

* decl.cc (DeclVisitor::visit (FuncDeclaration *)): Set semanticRun
before generating its symbol.
(function_defined_in_root_p): New function.
(function_needs_inline_definition_p): New function.
(maybe_build_decl_tree): New function.
(get_symbol_decl): Call maybe_build_decl_tree before returning symbol.
(start_function): Use function_defined_in_root_p instead of inline
test for locally defined symbols.
(set_linkage_for_decl): Check for inline functions before private or
protected symbols.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/torture.exp (srcdir): New proc.
* gdc.dg/torture/imports/pr106563math.d: New test.
* gdc.dg/torture/imports/pr106563regex.d: New test.
* gdc.dg/torture/imports/pr106563uni.d: New test.
* gdc.dg/torture/pr106563.d: New test.

(cherry picked from commit 04284176d549ff2565406406a6d53ab4ba8e507d)

21 months agoDaily bump.
GCC Administrator [Tue, 9 Aug 2022 00:19:21 +0000 (00:19 +0000)] 
Daily bump.

21 months agod: Fix ICE in in add_stack_var, at cfgexpand.cc:476
Iain Buclaw [Mon, 8 Aug 2022 13:17:47 +0000 (15:17 +0200)] 
d: Fix ICE in in add_stack_var, at cfgexpand.cc:476

The type that triggers the ICE never got completed by the semantic
analysis pass.  Checking for size forces it to be done, or issue a
compile-time error.

PR d/106555

gcc/d/ChangeLog:

* d-target.cc (Target::isReturnOnStack): Check for return type size.

gcc/testsuite/ChangeLog:

* gdc.dg/imports/pr106555.d: New test.
* gdc.dg/pr106555.d: New test.

(cherry picked from commit 4b0253b019943abf2cc5f4db0b7ed67caedffe4a)

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

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

22 months agoDaily bump.
GCC Administrator [Sat, 6 Aug 2022 00:19:27 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDo not enable -mblock-ops-vector-pair.
Michael Meissner [Fri, 5 Aug 2022 22:54:33 +0000 (18:54 -0400)] 
Do not enable -mblock-ops-vector-pair.

Testing has shown that using the load vector pair and store vector pair
instructions for block moves has some performance issues on power10.

A patch on June 11th modified the code so that GCC would not set
-mblock-ops-vector-pair by default if we are tuning for power10, but it would
set the option if we were tuning for a different machine and have load and store
vector pair instructions enabled.

This patch eliminates the code setting -mblock-ops-vector-pair.  If you want to
generate load vector pair and store vector pair instructions for block moves,
you must use -mblock-ops-vector-pair.

2022-08-05   Michael Meissner  <meissner@linux.ibm.com>

gcc/

* config/rs6000/rs6000.cc (rs6000_option_override_internal): Remove code
setting -mblock-ops-vector-pair.  Back port patch from trunk on 8/3.

22 months agolibstdc++: Make std::string_view(Range&&) constructor explicit
Jonathan Wakely [Thu, 4 Aug 2022 12:08:00 +0000 (13:08 +0100)] 
libstdc++: Make std::string_view(Range&&) constructor explicit

The P2499R0 paper was recently approved for C++23.

libstdc++-v3/ChangeLog:

* include/std/string_view (basic_string_view(Range&&)): Add
explicit as per P2499R0.
* testsuite/21_strings/basic_string_view/cons/char/range_c++20.cc:
Adjust implicit conversions. Check implicit conversions fail.
* testsuite/21_strings/basic_string_view/cons/wchar_t/range_c++20.cc:
Likewise.

(cherry picked from commit 2678386df2cc3505da85e95643327aa928e66a8e)

22 months agolibstdc++: Rename data members of std::unexpected and std::bad_expected_access
Jonathan Wakely [Thu, 4 Aug 2022 09:20:18 +0000 (10:20 +0100)] 
libstdc++: Rename data members of std::unexpected and std::bad_expected_access

The P2549R1 paper was accepted for C++23. I already implemented it for
our <expected>, but I didn't rename the private daata members, only the
public member functions. This renames the data members for consistency
with the working draft.

libstdc++-v3/ChangeLog:

* include/std/expected (unexpected::_M_val): Rename to _M_unex.
(bad_expected_access::_M_val): Likewise.

(cherry picked from commit 07c7ee4d2d42f4728928556dbbe0700f9a13db90)

22 months agolibstdc++: Update value of __cpp_lib_ios_noreplace macro
Jonathan Wakely [Thu, 4 Aug 2022 09:18:23 +0000 (10:18 +0100)] 
libstdc++: Update value of __cpp_lib_ios_noreplace macro

My P2467R1 proposal was accepted for C++23 so there's an official value
for this macro now.

libstdc++-v3/ChangeLog:

* include/bits/ios_base.h (__cpp_lib_ios_noreplace): Update
value to 202207L.
* include/std/version (__cpp_lib_ios_noreplace): Likewise.
* testsuite/27_io/basic_ofstream/open/char/noreplace.cc: Check
for new value.
* testsuite/27_io/basic_ofstream/open/wchar_t/noreplace.cc:
Likewise.

(cherry picked from commit 3e9bd6b2b1782891639fa5d49b7d2a933b8e85cd)

22 months agoDaily bump.
GCC Administrator [Fri, 5 Aug 2022 00:19:14 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Thu, 4 Aug 2022 00:19:28 +0000 (00:19 +0000)] 
Daily bump.

22 months agolibstdc++: Improve directory iterator abstractions for openat
Jonathan Wakely [Mon, 27 Jun 2022 13:43:54 +0000 (14:43 +0100)] 
libstdc++: Improve directory iterator abstractions for openat

Currently the _Dir::open_subdir function decides whether to construct a
_Dir_base with just a pathname, or a file descriptor and pathname. But
that means it is tightly coupled to the implementation of
_Dir_base::openat, which is what actually decides whether to use a file
descriptor or not. If the derived class passes a file descriptor and
filename, but the base class expects a full path and ignores the file
descriptor, then recursive_directory_iterator cannot recurse.

This change introduces a new type that provides the union of all the
information available to the derived class (the full pathname, as well
as a file descriptor for a directory and another pathname relative to
that directory). This allows the derived class to be agnostic to how the
base class will use that information.

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (_Dir::dir_and_pathname):: Replace with
current() returning _At_path.
(_Dir::_Dir, _Dir::open_subdir, _Dir::do_unlink): Adjust.
* src/filesystem/dir-common.h (_Dir_base::_At_path): New class.
(_Dir_base::_Dir_Base, _Dir_base::openat): Use _At_path.
* src/filesystem/dir.cc (_Dir::dir_and_pathname): Replace with
current() returning _At_path.
(_Dir::_Dir, _Dir::open_subdir): Adjust.

(cherry picked from commit 198781144f33b0ef17dd2094580b5c77ad97d6e8)

22 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)

22 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)

22 months agolibstdc++: Add nodiscard attribute to filesystem operations
Jonathan Wakely [Fri, 1 Jul 2022 10:40:29 +0000 (11:40 +0100)] 
libstdc++: Add nodiscard attribute to filesystem operations

Some of these are not truly "pure" because they access the file system,
e.g. exists and file_size, but they do not modify anything and are only
useful for the return value.

If you really want to use one of those functions just to check whether
an error is reported (either via an exception or an error_code&
argument) you can still do so, but you need to cast the discarded result
to void.  Several tests need such a change, because they were indeed
only calling the functions to check for expected errors.

libstdc++-v3/ChangeLog:

* include/bits/fs_ops.h: Add nodiscard to all pure functions.
* include/experimental/bits/fs_ops.h: Likewise.
* testsuite/27_io/filesystem/operations/all.cc: Do not discard
results of absolute and canonical.
* testsuite/27_io/filesystem/operations/absolute.cc: Cast
discarded result to void.
* testsuite/27_io/filesystem/operations/canonical.cc: Likewise.
* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
* testsuite/27_io/filesystem/operations/read_symlink.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/operations/canonical.cc:
Likewise.
* testsuite/experimental/filesystem/operations/exists.cc:
Likewise.
* testsuite/experimental/filesystem/operations/is_empty.cc:
Likewise.
* testsuite/experimental/filesystem/operations/read_symlink.cc:
Likewise.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Likewise.

(cherry picked from commit f7a148304a71f3d3ad6845b7966fdc3af88c9e45)

22 months agolibstdc++: Support constexpr global std::string for size < 15 [PR105995]
Jonathan Wakely [Thu, 16 Jun 2022 13:57:32 +0000 (14:57 +0100)] 
libstdc++: Support constexpr global std::string for size < 15 [PR105995]

I don't think this is required by the standard, but it's easy to
support.

libstdc++-v3/ChangeLog:

PR libstdc++/105995
* include/bits/basic_string.h (_M_use_local_data): Initialize
the entire SSO buffer.
* testsuite/21_strings/basic_string/cons/char/105995.cc: New test.

(cherry picked from commit 98a0d72a610a87e8e383d366e50253ddcc9a51dd)

22 months agolibstdc++: Fix indentation in allocator base classes
Jonathan Wakely [Tue, 14 Jun 2022 13:50:49 +0000 (14:50 +0100)] 
libstdc++: Fix indentation in allocator base classes

libstdc++-v3/ChangeLog:

* include/bits/new_allocator.h: Fix indentation.
* include/ext/malloc_allocator.h: Likewise.

(cherry picked from commit 29da01709facbcc7efef4fd6767660d417f44531)

22 months agolibstdc++: Check for size overflow in constexpr allocation [PR105957]
Jonathan Wakely [Tue, 14 Jun 2022 13:37:25 +0000 (14:37 +0100)] 
libstdc++: Check for size overflow in constexpr allocation [PR105957]

libstdc++-v3/ChangeLog:

PR libstdc++/105957
* include/bits/allocator.h (allocator::allocate): Check for
overflow in constexpr allocation.
* testsuite/20_util/allocator/105975.cc: New test.

(cherry picked from commit 0a9af7b4ef1b8aa85cc8820acf54d41d1569fc10)

22 months agolibstdc++: Make std::lcm and std::gcd detect overflow [PR105844]
Jonathan Wakely [Fri, 10 Jun 2022 13:39:13 +0000 (14:39 +0100)] 
libstdc++: Make std::lcm and std::gcd detect overflow [PR105844]

When I fixed PR libstdc++/92978 I introduced a regression whereby
std::lcm(INT_MIN, 1) and std::lcm(50000, 49999) would no longer produce
errors during constant evaluation. Those calls are undefined, because
they violate the preconditions that |m| and the result can be
represented in the return type (which is int in both those cases). The
regression occurred because __absu<unsigned>(INT_MIN) is well-formed,
due to the explicit casts to unsigned in that new helper function, and
the out-of-range multiplication is well-formed, because unsigned
arithmetic wraps instead of overflowing.

To fix 92978 I made std::gcm and std::lcm calculate |m| and |n|
immediately, yielding a common unsigned type that was used to calculate
the result. That was partly correct, but there's no need to use an
unsigned type. Doing so only suppresses the overflow errors so the
compiler can't detect them. This change replaces __absu with __abs_r
that returns the common type (not its corresponding unsigned type). This
way we can detect overflow in __abs_r when required, while still
supporting the most-negative value when it can be represented in the
result type. To detect LCM results that are out of range of the result
type we still need explicit checks, because neither constant evaluation
nor UBsan will complain about unsigned wrapping for cases such as
std::lcm(500000u, 499999u). We can detect those overflows efficiently by
using __builtin_mul_overflow and asserting.

libstdc++-v3/ChangeLog:

PR libstdc++/105844
* include/experimental/numeric (experimental::gcd): Simplify
assertions. Use __abs_r instead of __absu.
(experimental::lcm): Likewise. Remove use of __detail::__lcm so
overflow can be detected.
* include/std/numeric (__detail::__absu): Rename to __abs_r and
change to allow signed result type, so overflow can be detected.
(__detail::__lcm): Remove.
(gcd): Simplify assertions. Use __abs_r instead of __absu.
(lcm): Likewise. Remove use of __detail::__lcm so overflow can
be detected.
* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines.
* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
* testsuite/26_numerics/gcd/105844.cc: New test.
* testsuite/26_numerics/lcm/105844.cc: New test.

(cherry picked from commit 671970a5621e18e7079b4ca113e56434c858db66)

22 months agolibfortran: Fix up boz_15.f90 on powerpc64le with -mabi=ieeelongdouble [PR106079]
Jakub Jelinek [Mon, 1 Aug 2022 06:26:03 +0000 (08:26 +0200)] 
libfortran: Fix up boz_15.f90 on powerpc64le with -mabi=ieeelongdouble [PR106079]

The boz_15.f90 test FAILs on powerpc64le-linux when -mabi=ieeelongdouble
is used (either default through --with-long-double-format=ieee or
when used explicitly).
The problem is that the read/write transfer routines are called with
BT_REAL (or BT_COMPLEX) type and kind 17 which is magic we use to say
it is the IEEE quad real(kind=16) rather than the IBM double double
real(kind=16).  For the floating point input/output we then handle kind
17 specially, but for B/O/Z we just treat the bytes of the floating point
value as binary blob and using 17 in that case results in unexpected
behavior, for write it means we don't estimate right how many chars we'll
need and print ******************** etc. rather than what we should, and
even with explicit size we'd print one further byte than intended.
For read it would even mean overwriting some unrelated byte after the
floating point object.

Fixed by using 16 instead of 17 in the read_radix and write_{b,o,z} calls.

2022-08-01  Jakub Jelinek  <jakub@redhat.com>

PR libfortran/106079
* io/transfer.c (formatted_transfer_scalar_read,
formatted_transfer_scalar_write): For type BT_REAL with kind 17
change kind to 16 before calling read_radix or write_{b,o,z}.

(cherry picked from commit 82ac4cd213867be939aedee15347e8fd3f200b6a)

22 months agoDaily bump.
GCC Administrator [Wed, 3 Aug 2022 00:19:18 +0000 (00:19 +0000)] 
Daily bump.

22 months agors6000: Adjust -mdejagnu-cpu to filter out -mtune [PR106345]
Peter Bergner [Mon, 25 Jul 2022 05:51:44 +0000 (00:51 -0500)] 
rs6000: Adjust -mdejagnu-cpu to filter out -mtune [PR106345]

As PR106345 shows, when configuring compiler with an explicit
option --with-tune=<value>, it would cause some test cases to
fail if their test points are sensitive to tune setting, such
as: group_ending_nop, loop align etc.  It doesn't help that
even to specify one explicit -mcpu=.

This patch is to adjust the behavior of -mdejagnu-cpu by
filtering out all -mcpu= and -mtune= options, then test cases
would use <cpu> as tune as the one specified by -mdejagnu-cpu.

2022-07-25  Peter Bergner  <bergner@linux.ibm.com>
    Kewen Lin  <linkw@linux.ibm.com>

PR testsuite/106345

gcc/ChangeLog:

* config/rs6000/rs6000.h (DRIVER_SELF_SPECS): Adjust -mdejagnu-cpu
to filter out all -mtune options.

(cherry picked from commit 75d20d6c84c12bedd65a904e462f02f0b9eb3f77)

22 months agors6000: Preserve REG_EH_REGION when replacing load/store [PR106091]
Kewen Lin [Tue, 26 Jul 2022 02:29:14 +0000 (21:29 -0500)] 
rs6000: Preserve REG_EH_REGION when replacing load/store [PR106091]

As test case in PR106091 shows, rs6000 specific pass swaps
doesn't preserve the reg_note REG_EH_REGION when replacing
some load insn at the end of basic block, it causes the
flow info verification to fail unexpectedly.  Since memory
reference rtx may trap, this patch is to ensure we copy
REG_EH_REGION reg_note while replacing swapped aligned load
or store.

PR target/106091

gcc/ChangeLog:

* config/rs6000/rs6000-p8swap.cc (replace_swapped_aligned_store): Copy
REG_EH_REGION when replacing one store insn having it.
(replace_swapped_aligned_load): Likewise.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit f4286601933406142b46693660f7f4b682cb50a5)

22 months agoDaily bump.
GCC Administrator [Tue, 2 Aug 2022 00:19:17 +0000 (00:19 +0000)] 
Daily bump.

22 months agoc: Fix location for _Pragma tokens [PR97498]
Lewis Hyatt [Sat, 9 Jul 2022 20:12:21 +0000 (16:12 -0400)] 
c: Fix location for _Pragma tokens [PR97498]

The handling of #pragma GCC diagnostic uses input_location, which is not always
as precise as needed; in particular the relative location of some tokens and a
_Pragma directive will crucially determine whether a given diagnostic is enabled
or suppressed in the desired way. PR97498 shows how the C frontend ends up with
input_location pointing to the beginning of the line containing a _Pragma()
directive, resulting in the wrong behavior if the diagnostic to be modified
pertains to some tokens found earlier on the same line. This patch fixes that by
addressing two issues:

    a) libcpp was not assigning a valid location to the CPP_PRAGMA token
    generated by the _Pragma directive.
    b) C frontend was not setting input_location to something reasonable.

With this change, the C frontend is able to change input_location to point to
the _Pragma token as needed.

This is just a two-line fix (one for each of a) and b)), the testsuite changes
were needed only because the location on the tested warnings has been somewhat
improved, so the tests need to look for the new locations.

gcc/c/ChangeLog:

PR preprocessor/97498
* c-parser.cc (c_parser_pragma): Set input_location to the
location of the pragma, rather than the start of the line.

libcpp/ChangeLog:

PR preprocessor/97498
* directives.cc (destringize_and_run): Override the location of
the CPP_PRAGMA token from a _Pragma directive to the location of
the expansion point, as is done for the tokens lexed from it.

gcc/testsuite/ChangeLog:

PR preprocessor/97498
* c-c++-common/pr97498.c: New test.
* c-c++-common/gomp/pragma-3.c: Adapt for improved warning locations.
* c-c++-common/gomp/pragma-5.c: Likewise.
* gcc.dg/pragma-message.c: Likewise.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-c-c++-common/reduction-5.c: Adapt for
improved warning locations.
* testsuite/libgomp.oacc-c-c++-common/vred2d-128.c: Likewise.

(cherry picked from commit 0587cef3d7962a8b0f44779589ba2920dd3d71e5)

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

22 months agoDaily bump.
GCC Administrator [Sun, 31 Jul 2022 00:19:07 +0000 (00:19 +0000)] 
Daily bump.

22 months agoopenmp: Fix up handling of non-rectangular simd loops with pointer type iterators...
Jakub Jelinek [Fri, 29 Jul 2022 07:49:11 +0000 (09:49 +0200)] 
openmp: Fix up handling of non-rectangular simd loops with pointer type iterators [PR106449]

There were 2 issues visible on this new testcase, one that we didn't have
special POINTER_TYPE_P handling in a few spots of expand_omp_simd - for
pointers we need to use POINTER_PLUS_EXPR and need to have the non-pointer
part in sizetype, for non-rectangular loop on the other side we can rely on
multiplication factor 1, pointers can't be multiplied, without those changes
we'd ICE.  The other issue was that we put n2 expression directly into a
comparison in a condition and regimplified that, for the &a[512] case that
and with gimplification being destructed that unfortunately meant modification
of original fd->loops[?].n2.  Fixed by unsharing the expression.  This was
causing a runtime failure on the testcase.

2022-07-29  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/106449
* omp-expand.cc (expand_omp_simd): Fix up handling of pointer
iterators in non-rectangular simd loops.  Unshare fd->loops[i].n2
or n2 before regimplifying it inside of a condition.

* testsuite/libgomp.c-c++-common/pr106449.c: New test.

(cherry picked from commit 97d32048c04e9787fccadc4bae1c042754503e34)

22 months agocgraphunit: Don't emit asm thunks for -dx [PR106261]
Jakub Jelinek [Wed, 27 Jul 2022 10:06:22 +0000 (12:06 +0200)] 
cgraphunit: Don't emit asm thunks for -dx [PR106261]

When -dx option is used (didn't know we have it and no idea what is it
useful for), we just expand functions to RTL and then omit all further
RTL passes, so the normal functions aren't actually emitted into assembly,
just variables.
The following testcase ICEs, because we don't emit the methods, but do
emit thunks pointing to that and those thunks have unwind info and rely on
at least some real functions to be emitted (which is normally the case,
thunks are only emitted for locally defined functions) because otherwise
there are no CIEs, only FDEs and dwarf2out is upset about it.

The following patch fixes that by not emitting assembly thunks for -dx
either.

2022-07-27  Jakub Jelinek  <jakub@redhat.com>

PR debug/106261
* cgraphunit.cc (cgraph_node::assemble_thunks_and_aliases): Don't
output asm thunks for -dx.

* g++.dg/debug/pr106261.C: New test.

(cherry picked from commit f9671b60f9395cb1dca128b92f5dd215f5aeaae1)

22 months agowide-int: Fix up wi::shifted_mask [PR106144]
Jakub Jelinek [Fri, 1 Jul 2022 09:17:41 +0000 (11:17 +0200)] 
wide-int: Fix up wi::shifted_mask [PR106144]

As the following self-test testcase shows, wi::shifted_mask sometimes
doesn't create canonicalized wide_ints, which then fail to compare equal
to canonicalized wide_ints with the same value.
In particular, wi::mask (128, false, 128) gives { -1 } with len 1 and prec 128,
while wi::shifted_mask (0, 128, false, 128) gives { -1, -1 } with len 2
and prec 128.
The problem is that the code is written with the assumption that there are
3 bit blocks (or 2 if start is 0), but doesn't consider the possibility
where there are 2 bit blocks (or 1 if start is 0) where the highest block
isn't present.  In that case, there is the optional block of negate ? 0 : -1
elts, followed by just one elt (either one from the if (shift) or just
negate ? -1 : 0) and the rest is implicit sign-extension.
Only if end < prec there is 1 or more bits above it that have different bit
value and so we need to emit all the elts till end and then one more elt.

if (end == prec) would work too, because we have:
  if (width > prec - start)
    width = prec - start;
  unsigned int end = start + width;
so end is guaranteed to be end <= prec, dunno what is preferred.

2022-07-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/106144
* wide-int.cc (wi::shifted_mask): If end >= prec, return right after
emitting element for shift or if shift is 0 first element after start.
(wide_int_cc_tests): Add tests for equivalency of wi::mask and
wi::shifted_mask with 0 start.

(cherry picked from commit e52592073f6df3d7a3acd9f0436dcc32a8b7493d)

22 months agoDaily bump.
GCC Administrator [Sat, 30 Jul 2022 00:18:55 +0000 (00:18 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Fri, 29 Jul 2022 00:19:13 +0000 (00:19 +0000)] 
Daily bump.

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

22 months agoanalyzer: fix stray get_element decls
David Malcolm [Wed, 27 Jul 2022 21:38:55 +0000 (17:38 -0400)] 
analyzer: fix stray get_element decls

(cherry picked from r13-1847-g0460ba622e833d)

These were copy&paste errors.

gcc/analyzer/ChangeLog:
* region.h (code_region::get_element): Remove stray decl.
(function_region::get_element): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agoanalyzer: fix false positives from -Wanalyzer-tainted-divisor [PR106225]
David Malcolm [Wed, 27 Jul 2022 21:38:55 +0000 (17:38 -0400)] 
analyzer: fix false positives from -Wanalyzer-tainted-divisor [PR106225]

(cherry picked from r13-1562-g897b3b31f0a94b)

gcc/analyzer/ChangeLog:
PR analyzer/106225
* sm-taint.cc (taint_state_machine::on_stmt): Move handling of
assignments from division to...
(taint_state_machine::check_for_tainted_divisor): ...this new
function.  Reject warning when the divisor is known to be non-zero.
* sm.cc: Include "analyzer/program-state.h".
(sm_context::get_old_region_model): New.
* sm.h (sm_context::get_old_region_model): New decl.

gcc/testsuite/ChangeLog:
PR analyzer/106225
* gcc.dg/analyzer/taint-divisor-1.c: Add test coverage for various
correct and incorrect checks against zero.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agoanalyzer: fix uninit false positive with -ftrivial-auto-var-init= [PR106204]
David Malcolm [Wed, 27 Jul 2022 21:38:55 +0000 (17:38 -0400)] 
analyzer: fix uninit false positive with -ftrivial-auto-var-init= [PR106204]

(cherry picked from r13-1517-gb33dd7874523af)

-fanalyzer handles -ftrivial-auto-var-init= by special-casing
IFN_DEFERRED_INIT to be a no-op, so that e.g.:

  len_2 = .DEFERRED_INIT (4, 2, &"len"[0]);

is treated as a no-op, so that len_2 is still uninitialized after the
stmt.

PR analyzer/106204 reports that -fanalyzer gives false positives from
-Wanalyzer-use-of-uninitialized-value on locals that have their address
taken, due to e.g.:

  _1 = .DEFERRED_INIT (4, 2, &"len"[0]);
  len = _1;

where -fanalyzer leaves _1 uninitialized, and then complains about
the assignment to "len".

Fixed thusly by suppressing the warning when assigning from such SSA
names.

gcc/analyzer/ChangeLog:
PR analyzer/106204
* region-model.cc (within_short_circuited_stmt_p): Move extraction
of assign_stmt to caller.
(due_to_ifn_deferred_init_p): New.
(region_model::check_for_poison): Move extraction of assign_stmt
from within_short_circuited_stmt_p to here.  Share logic with
call to due_to_ifn_deferred_init_p.

gcc/testsuite/ChangeLog:
PR analyzer/106204
* gcc.dg/analyzer/torture/uninit-pr106204.c: New test.
* gcc.dg/analyzer/uninit-pr106204.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agoanalyzer: show saved diagnostics as nodes in .eg.dot dumps
David Malcolm [Wed, 27 Jul 2022 21:38:54 +0000 (17:38 -0400)] 
analyzer: show saved diagnostics as nodes in .eg.dot dumps

(cherry picked from r13-1117-gc540077a3bf600)

I've been using this tweak to the output of
-fdump-analyzer-exploded-graph in my working copies for a while;
the extra red nodes make it *much* easier to find the places where
diagnostics are being emitted (or rejected by the diagnostic_manager).

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc (saved_diagnostic::dump_dot_id): New.
(saved_diagnostic::dump_as_dot_node): New.
* diagnostic-manager.h (saved_diagnostic::dump_dot_id): New decl.
(saved_diagnostic::dump_as_dot_node): New decl.
* engine.cc (exploded_node::dump_dot): Add nodes for saved
diagnostics.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agoanalyzer: add more uninit test coverage
David Malcolm [Wed, 27 Jul 2022 21:38:54 +0000 (17:38 -0400)] 
analyzer: add more uninit test coverage

(cherry picked from r13-1116-g44681d45473883)

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/uninit-1.c: Add test coverage of attempts
to jump through an uninitialized function pointer, and of attempts
to pass an uninitialized value to a function call.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agojson: fix escaping of '\'
David Malcolm [Wed, 27 Jul 2022 21:38:54 +0000 (17:38 -0400)] 
json: fix escaping of '\'

(cherry picked from r13-965-g4f9ad0b4b0a8c7)

gcc/ChangeLog:
* json.cc (string::print): Fix escaping of '\'.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agoanalyzer: fix memory leaks
David Malcolm [Wed, 27 Jul 2022 21:38:53 +0000 (17:38 -0400)] 
analyzer: fix memory leaks

(cherry picked from r13-334-g99988b0e8b57b3)

These leaks all relate to logging within -fdump-analyzer[-stderr]
or are one-time leaks; seen with valgrind.

gcc/analyzer/ChangeLog:
* checker-path.cc (state_change_event::get_desc): Call maybe_free
on label_text temporaries.
* diagnostic-manager.cc
(diagnostic_manager::prune_for_sm_diagnostic): Likewise.
* engine.cc (exploded_graph::~exploded_graph): Fix leak of
m_per_point_data and m_per_call_string_data values.  Simplify
cleanup of m_per_function_stats and m_per_point_data values.
(feasibility_state::maybe_update_for_edge): Fix leak of result of
superedge::get_description.
* region-model-manager.cc
(region_model_manager::~region_model_manager): Move cleanup of
m_setjmp_values to match the ordering of the fields within
region_model_manager.  Fix leak of values within
m_repeated_values_map, m_bits_within_values_map,
m_asm_output_values_map, and m_const_fn_result_values_map.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agoanalyzer: handle repeated accesses after init of unknown size [PR105285]
David Malcolm [Wed, 27 Jul 2022 21:38:53 +0000 (17:38 -0400)] 
analyzer: handle repeated accesses after init of unknown size [PR105285]

(cherry-picked from r13-7-g00c4405cd7f6a144d0a439e4d848d246920e6ff3)

PR analyzer/105285 reports a false positive from
-Wanalyzer-null-dereference on git.git's reftable/reader.c.

A reduced version of the problem can be seen in test_1a of
gcc.dg/analyzer/symbolic-12.c in the following:

void test_1a (void *p, unsigned next_off)
{
  struct st_1 *r = p;

  external_fn();

  if (next_off >= r->size)
    return;

  if (next_off >= r->size)
    /* We should have already returned if this is the case.  */
    __analyzer_dump_path (); /* { dg-bogus "path" } */
}

where the analyzer erroneously considers this path, where
(next_off >= r->size) is both false and then true:

symbolic-12.c: In function â€˜test_1a’:
symbolic-12.c:22:5: note: path
   22 |     __analyzer_dump_path (); /* { dg-bogus "path" } */
      |     ^~~~~~~~~~~~~~~~~~~~~~~
  â€˜test_1a’: events 1-5
    |
    |   17 |   if (next_off >= r->size)
    |      |      ^
    |      |      |
    |      |      (1) following â€˜false’ branch...
    |......
    |   20 |   if (next_off >= r->size)
    |      |      ~            ~~~~~~~
    |      |      |             |
    |      |      |             (2) ...to here
    |      |      (3) following â€˜true’ branch...
    |   21 |     /* We should have already returned if this is the case.  */
    |   22 |     __analyzer_dump_path (); /* { dg-bogus "path" } */
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~
    |      |     |
    |      |     (4) ...to here
    |      |     (5) here
    |

The root cause is that, at the call to the external function, the
analyzer considers the cluster for *p to have been touched, binding it
to a conjured_svalue, but because p is void * no particular size is
known for the write, and so the cluster is bound using a symbolic key
covering the base region.  Later, the accesses to r->size are handled by
binding_cluster::get_any_binding, but binding_cluster::get_binding fails
to find a match for the concrete field lookup, due to the key for the
binding being symbolic, and reaching this code:

1522  /* If this cluster has been touched by a symbolic write, then the content
1523     of any subregion not currently specifically bound is "UNKNOWN".  */
1524  if (m_touched)
1525    {
1526      region_model_manager *rmm_mgr = mgr->get_svalue_manager ();
1527      return rmm_mgr->get_or_create_unknown_svalue (reg->get_type ());
1528    }

Hence each access to r->size is an unknown svalue, and thus the
condition (next_off >= r->size) isn't tracked, leading to the path with
contradictory conditions being treated as satisfiable.

In the original reproducer in git's reftable/reader.c, the call to the
external fn is:
  reftable_record_type(rec)
which is considered to possibly write to *rec, which is *tab, where tab
is the void * argument to reftable_reader_seek_void, and thus after the
call to reftable_record_type some arbitrary amount of *rec could have
been written to.

This patch fixes things by detecting the "this cluster has been 'filled'
with a conjured value of unknown size" case, and handling
get_any_binding on it by returning a sub_svalue of the conjured_svalue,
so that repeated accesses to r->size give the same symbolic value, so
that the constraint manager rejects the bogus execution path, fixing the
false positive.

gcc/analyzer/ChangeLog:
PR analyzer/105285
* store.cc (binding_cluster::get_any_binding): Handle accessing
sub_svalues of clusters where the base region has a symbolic
binding.

gcc/testsuite/ChangeLog:
PR analyzer/105285
* gcc.dg/analyzer/symbolic-12.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agoanalyzer: add .fpath.txt dumps to -fdump-analyzer-feasibility
David Malcolm [Wed, 27 Jul 2022 21:38:53 +0000 (17:38 -0400)] 
analyzer: add .fpath.txt dumps to -fdump-analyzer-feasibility

(cherry picked from r13-6-gd8586b00dd00a1783862da5f0c8811a740400074)

I found this extension to -fdump-analyzer-feasibility very helpful when
debugging PR analyzer/105285.

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc (epath_finder::process_worklist_item):
Call dump_feasible_path when a path that reaches the the target
enode is found.
(epath_finder::dump_feasible_path): New.
* engine.cc (feasibility_state::dump_to_pp): New.
* exploded-graph.h (feasibility_state::dump_to_pp): New decl.
* feasible-graph.cc (feasible_graph::dump_feasible_path): New.
* feasible-graph.h (feasible_graph::dump_feasible_path): New
decls.
* program-point.cc (function_point::print): Fix missing trailing
newlines.
* program-point.h (program_point::print_source_line): Remove
unimplemented decl.

gcc/ChangeLog:
* doc/invoke.texi (-fdump-analyzer-feasibility): Mention the
fpath.txt output.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
22 months agoRISC-V: Remove duplicate backslashes from `stack_protect_set_<mode>'
Maciej W. Rozycki [Wed, 27 Jul 2022 10:09:43 +0000 (11:09 +0100)] 
RISC-V: Remove duplicate backslashes from `stack_protect_set_<mode>'

Remove redundant duplicate backslash characters from \t sequences in the
output pattern of the `stack_protect_set_<mode>' RTL insn.

gcc/
* config/riscv/riscv.md (stack_protect_set_<mode>): Remove
duplicate backslashes.

(cherry picked from commit 3cf07cc5e51c833f39f5bad5ca6fbe23c853a214)

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 agolto: Fix option merging [PR106129]
Joseph Myers [Thu, 30 Jun 2022 16:41:40 +0000 (16:41 +0000)] 
lto: Fix option merging [PR106129]

The LTO merging of options from different input files was broken by:

commit 227a2ecf663d69972b851f51f1934d18927b62cd
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Mar 12 11:53:47 2021 +0100

    lto-wrapper: Use vec<cl_decoded_option> data type.

Previously, find_and_merge_options would merge options it read into
those in *opts. After this commit, options in *opts on entry to
find_and_merge_options are ignored; the only merging that takes place
is between multiple sets of options in the same input file that are
read in the same call to this function (not sure how that case can
occur at all). The effects include, for example, that if some objects
are built with PIC enabled and others with it disabled, and the last
LTO object processed has PIC enabled, the choice of PIC for the last
object will result in the whole program being built as PIC, when the
merging logic is intended to ensure that a mixture of PIC and non-PIC
objects results in the whole program being built as non-PIC.

Fix this with an extra argument to find_and_merge_options to determine
whether merging should take place.  This shows up a second issue with
that commit (which I think wasn't actually intended to change code
semantics at all): once merging is enabled again, the check for
-Xassembler options became an infinite loop in the case where both
inputs had -Xassembler options, with the same first option, so fix
that loop to restore the previous semantics.

Note that I'm not sure how LTO option merging might be tested in the
testsuite (clearly there wasn't sufficient, if any, coverage to detect
these bugs).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR lto/106129
* lto-wrapper.cc (find_option): Add argument start.
(merge_and_complain): Loop over existing_opt_index and
existing_opt2_index for Xassembler check.  Update calls to
find_option.
(find_and_merge_options): Add argument first to determine whether
to merge options with those passed in *opts.
(run_gcc): Update calls to find_and_merge_options.

(cherry picked from commit 8a8ee37a3325f1009034245676ef4e482c0444a2)

22 months agoFix tree-opt/PR106087: ICE with inline-asm with multiple output and assigned only...
Andrew Pinski [Thu, 7 Jul 2022 22:06:19 +0000 (22:06 +0000)] 
Fix tree-opt/PR106087: ICE with inline-asm with multiple output and assigned only static vars

The problem here is that when we mark the ssa name that was referenced in the now removed
dead store (to a write only static variable), the inline-asm would also be removed
even though it was defining another ssa name. This fixes the problem by checking
to make sure that the statement was only defining one ssa name.

Committed as approved after a bootstrapped and tested on x86_64 with no regressions.

PR tree-optimization/106087

gcc/ChangeLog:

* tree-ssa-dce.cc (simple_dce_from_worklist): Check
to make sure the statement is only defining one operand.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/inline-asm-1.c: New test.

(cherry picked from commit 71e3daa31cfa35ee58e5899cb00767be92227fd2)

22 months agotestsuite: Require int128 for gcc.dg/pr106063.c
Dimitar Dimitrov [Sun, 10 Jul 2022 08:15:39 +0000 (11:15 +0300)] 
testsuite: Require int128 for gcc.dg/pr106063.c

Require effective target int128 for gcc.dg/pr106063.c.

PR tree-optimization/106063

gcc/testsuite/ChangeLog:

* gcc.dg/pr106063.c: Require effective target int128.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
(cherry picked from commit 4ebbf3906895bcb40d7ff2729cf46deae66bc268)

22 months agomiddle-end: don't lower past veclower [PR106063]
Tamar Christina [Fri, 8 Jul 2022 07:30:22 +0000 (08:30 +0100)] 
middle-end: don't lower past veclower [PR106063]

Hi All,

My previous patch can cause a problem if the pattern matches after veclower
as it may replace the construct with a vector sequence which the target may not
directly support.

As such don't perform the rewriting if after veclower unless the target supports
the operation.  If before veclower do the rewriting as well if the target didn't
support the original operation either.

gcc/ChangeLog:

PR tree-optimization/106063
* match.pd: Do not apply pattern after veclower is not supported.

gcc/testsuite/ChangeLog:

PR tree-optimization/106063
* gcc.dg/pr106063.c: New test.

(cherry picked from commit f7854e2faf7640230062dec3596e71773ca500ed)

22 months ago[PR105665] ivopts: check defs of names in base for undefs
Alexandre Oliva [Fri, 3 Jun 2022 06:59:03 +0000 (03:59 -0300)] 
[PR105665] ivopts: check defs of names in base for undefs

The patch for PR 100810 tested for undefined SSA_NAMEs appearing
directly in the base expression of the potential IV candidate, but
that's not enough.  The testcase for PR105665 shows an undefined
SSA_NAME has the same ill effect if it's referenced as an PHI_NODE arg
in the referenced SSA_NAME.  The variant of that test shows it can be
further removed from the referenced SSA_NAME.

To avoid deep recursion, precompute maybe-undefined SSA_NAMEs: start
from known-undefined nonvirtual default defs, and propagate them to
any PHI nodes reached by a maybe-undefined arg, as long as there
aren't intervening non-PHI uses, that would imply the maybe-undefined
name must be defined at that point, otherwise it would invoke
undefined behavior.  Also test for intervening non-PHI uses of DEFs in
the base expr.

The test for intervening uses implemented herein relies on dominance;
this could be further extended, regarding conditional uses in every
path leading to a point as an unconditional use dominating that point,
but I haven't implemented that.

for  gcc/ChangeLog

PR tree-optimization/105665
PR tree-optimization/100810
* tree-ssa-loop-ivopts.cc
(ssa_name_maybe_undef_p, ssa_name_set_maybe_undef): New.
(ssa_name_any_use_dominates_bb_p, mark_ssa_maybe_undefs): New.
(find_ssa_undef): Check precomputed flag and intervening uses.
(tree_ssa_iv_optimize): Call mark_ssa_maybe_undefs.

for  gcc/testsuite/ChangeLog

PR tree-optimization/105665
PR tree-optimization/100810
* gcc.dg/torture/pr105665.c: New.

(cherry picked from commit be2861fe8c527a5952257462ceca899bb43b1452)

22 months agoDaily bump.
GCC Administrator [Wed, 27 Jul 2022 00:19:35 +0000 (00:19 +0000)] 
Daily bump.

22 months agolibstdc++: Minor codegen improvement for atomic wait spinloop
Thomas Rodgers [Wed, 6 Jul 2022 00:42:42 +0000 (17:42 -0700)] 
libstdc++: Minor codegen improvement for atomic wait spinloop

This patch merges the spin loops in the atomic wait implementation which is a
minor codegen improvement.

libstdc++-v3/ChangeLog:
* include/bits/atomic_wait.h (__atomic_spin): Merge spin loops.

(cherry picked from commit e75da2ace6b6f634237259ef62cfb2d3d34adb10)

22 months agod: Merge upstream dmd 76e3b41375, druntime 1462ebd1, phobos 5fef0d28f.
Iain Buclaw [Tue, 26 Jul 2022 16:13:54 +0000 (18:13 +0200)] 
d: Merge upstream dmd 76e3b41375, druntime 1462ebd1, phobos 5fef0d28f.

Updates D language version to v2.100.1.

D front-end changes:

    - Fix delegate literal with inferred return value that requires
      following alias-this to not use class cast.
    - Fix internal error on variadic template type instantiated with two
      arrays of classes.
    - `scope(failure)' blocks that contain `return' statements are now
      deprecated.
    - Fix regression where wrong cast was inserted for ternary operator
      and non-int enums.
    - Fix internal error in code generation trying to reference
      _d_arraysetctor.
    - Fix memory corruption when array literal is passed to map in
      lambda, then returned from nested function.
    - Generate invariant id on the basis of location rather than a
      global counter.
    - Make `noreturn' conversions work.
    - Fix segfault when `.stringof' of template alias overloaded with
      function accessed by trait.
    - Empty array literal passed to scope param not 'falsey' anymore.

Phobos changes:

    - Avoid copying ranges in std.algorithm.comparison.equal.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 76e3b41375.
* dmd/VERSION: Bump version to v2.100.1.
* decl.cc (DeclVisitor::visit (VarDeclaration *)): Evaluate RHS
  of noreturn declaration expressions first.
* expr.cc (ExprVisitor::visit (AssignExp *)): Don't generate
  assignment for noreturn types.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 1462ebd1.
* src/MERGE: Merge upstream phobos 5fef0d28f.

22 months agoFortran: error recovery from calculation of storage size of a symbol [PR103504]
Harald Anlauf [Mon, 25 Jul 2022 20:29:50 +0000 (22:29 +0200)] 
Fortran: error recovery from calculation of storage size of a symbol [PR103504]

gcc/fortran/ChangeLog:

PR fortran/103504
* interface.cc (get_sym_storage_size): Array bounds and character
length can only be of integer type.

gcc/testsuite/ChangeLog:

PR fortran/103504
* gfortran.dg/pr103504.f90: New test.

(cherry picked from commit 600956c81c784f4a0cc9d10f6e03e01847afd961)

22 months agoc++: ICE with erroneous template redeclaration [PR106311]
Marek Polacek [Fri, 15 Jul 2022 13:51:50 +0000 (09:51 -0400)] 
c++: ICE with erroneous template redeclaration [PR106311]

Here we ICE trying to get DECL_SOURCE_LOCATION of the parm that happens
to be error_mark_node in this ill-formed test.  I kept running into this
while reducing code, so it'd be good to have it fixed.

PR c++/106311

gcc/cp/ChangeLog:

* pt.cc (redeclare_class_template): Check DECL_P before accessing
DECL_SOURCE_LOCATION.

gcc/testsuite/ChangeLog:

* g++.dg/template/redecl5.C: New test.

(cherry picked from commit 2333b58c9892667545d0c2c3ecd2d7b947197511)

22 months agoc++: aggregate prvalue as for range [PR106230]
Jason Merrill [Mon, 25 Jul 2022 15:13:31 +0000 (11:13 -0400)] 
c++: aggregate prvalue as for range [PR106230]

Since my PR94041 work on temporary lifetime in aggregate initialization, we
end up calling build_vec_init to initialize the reference-extended temporary
for the artificial __for_range variable.  And build_vec_init uses
finish_for_stmt to implement its loop.  That function assumes that if
__for_range is in current_binding_level, we're finishing a range-for, and we
should fix up the variable as it goes out of scope.  But when called from
build_vec_init we aren't finishing a range-for, and do_poplevel doesn't
remove the variable from scope because stmts_are_full_exprs_p is false.  So
let's check that here as well, and leave the DECL_NAME alone.

PR c++/106230

gcc/cp/ChangeLog:

* semantics.cc (finish_for_stmt): Check stmts_are_full_exprs_p.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/range-for38.C: New test.

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

22 months agoRTEMS: Do not define _GNU_SOURCE by default
Sebastian Huber [Fri, 22 Jul 2022 12:09:20 +0000 (14:09 +0200)] 
RTEMS: Do not define _GNU_SOURCE by default

gcc/ChangeLog:

* config/rs6000/rtems.h (CPLUSPLUS_CPP_SPEC): Undef.

(cherry picked from commit 556b816b820f6749910784cbaca8bb0bb822a970)

22 months agoDaily bump.
GCC Administrator [Mon, 25 Jul 2022 00:19:30 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 24 Jul 2022 00:19:01 +0000 (00:19 +0000)] 
Daily bump.

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

22 months agolibstdc++: Do not optimize away storing pathname if it's needed
Jonathan Wakely [Tue, 28 Jun 2022 08:26:12 +0000 (09:26 +0100)] 
libstdc++: Do not optimize away storing pathname if it's needed

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (_Dir::_Dir) [!_GLIBCXX_HAVE_OPENAT]:
Always store pathname if we don't have openat or unlinkat,
because the full path is needed to open sub-directories and
remove entries.

(cherry picked from commit 835b19936bf30d693783bfa39145a4ce243bbd7c)

22 months agolibstdc++: check for openat with dirfd in std::filesystem
Alexandre Oliva [Mon, 27 Jun 2022 13:34:16 +0000 (10:34 -0300)] 
libstdc++: check for openat with dirfd in std::filesystem

In the recent patch to check for openat, I missed an occurrence of
dirfd in std::filesystem.

for  libstdc++-v3/ChangeLog

* src/c++17/fs_dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.

(cherry picked from commit 486893b1d325d22d54c1380937943913a7501f91)

22 months agolibstdc++: check for openat
Alexandre Oliva [Fri, 24 Jun 2022 02:20:53 +0000 (23:20 -0300)] 
libstdc++: check for openat

rtems6.0 has fdopendir, and fcntl.h defines AT_FDCWD and declares
openat, but there's no openat in libc.  Adjust dir-common.h to not
assume ::openat just because of AT_FDCWD.

for  libstdc++-v3/ChangeLog

* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for
openat.
* configure, config.h.in: Rebuilt.
* src/filesystem/dir-common.h (openat): Use ::openat if
_GLIBCXX_HAVE_OPENAT.
* src/filesystem/dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.

(cherry picked from commit 93070671eae44f24ba822383e17571a39257c637)

22 months agolibstdc++: Do not include <cxxabi.h> in <stacktrace>
Jonathan Wakely [Fri, 6 May 2022 12:23:45 +0000 (13:23 +0100)] 
libstdc++: Do not include <cxxabi.h> in <stacktrace>

This avoids polluting the global namespace with the "abi" namespace
alias.

libstdc++-v3/ChangeLog:

* include/std/stacktrace: Do not include <cxxabi.h>.
(__cxa_demangle): Declare.

(cherry picked from commit e112e37f2920bcc9185e53b754d9145aac912c72)

22 months agoDaily bump.
GCC Administrator [Fri, 22 Jul 2022 00:19:09 +0000 (00:19 +0000)] 
Daily bump.

22 months agoc++: defaulted friend op== [PR106361]
Jason Merrill [Thu, 21 Jul 2022 00:00:58 +0000 (20:00 -0400)] 
c++: defaulted friend op== [PR106361]

Now non-member functions can be defaulted, so this assert is wrong.
move_signature_fn_p already checks for ctor or op=.

PR c++/106361

gcc/cp/ChangeLog:

* decl.cc (move_fn_p): Remove assert.

gcc/testsuite/ChangeLog:

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

22 months agoc++: non-dependent call to consteval operator [PR105912]
Patrick Palka [Thu, 21 Jul 2022 16:59:44 +0000 (12:59 -0400)] 
c++: non-dependent call to consteval operator [PR105912]

Here we're crashing when substituting a non-dependent call to a
consteval operator, whose CALL_EXPR_OPERATOR_SYNTAX flag we try to
propagate to the result, but the result isn't a CALL_EXPR since the
selected function is consteval.  This patch fixes this by checking the
result of extract_call_expr accordingly.  (Note that we can't check
DECL_IMMEDIATE_FUNCTION_P here because we don't know which function was
selected by overload resolution from here.)

PR c++/105912

gcc/cp/ChangeLog:

* call.cc (extract_call_expr): Return a NULL_TREE on failure
instead of asserting.
* pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Guard against
NULL_TREE extract_call_expr result.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/consteval31.C: New test.

(cherry picked from commit f70c18524221dcefa6cd26cee7b55503181bd912)

22 months agoc++: dependence of constrained memfn from current inst [PR105842]
Patrick Palka [Wed, 13 Jul 2022 18:01:28 +0000 (14:01 -0400)] 
c++: dependence of constrained memfn from current inst [PR105842]

Here we incorrectly deem the calls to func1, func2 and tmpl2 as
ambiguous ahead of time ultimately because we mishandle dependence
of a constrained member function from the current instantiation.

In type_dependent_expression_p, we already consider dependence of a
TEMPLATE_DECL's constraints (via uses_outer_template_parms), but
neglect to do the same for a FUNCTION_DECL (such as that for func1).

And in satisfy_declaration_constraints, we give up if _any_ template
argument is dependent, but for non-dependent member functions from
the current instantiation (such as func2 and tmpl2), we can and must
check constraints as long as the innermost arguments aren't dependent.

PR c++/105842

gcc/cp/ChangeLog:

* constraint.cc (satisfy_declaration_constraints): Refine early
exit test for argument dependence.
* cp-tree.h (uses_outer_template_parms_in_constraints): Declare.
* pt.cc (template_class_depth): Handle TI_TEMPLATE being a
FIELD_DECL.
(usse_outer_template_parms): Factor out constraint dependence
test into ...
(uses_outer_template_parms_in_constraints): ... here.
(type_dependent_expression_p): Use it for FUNCTION_DECL.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit f07778f6f92111aa0abfd0f669b148a0bda537a9)

22 months agoc++: function NTTP argument considered unused [PR53164, PR105848]
Patrick Palka [Mon, 6 Jun 2022 18:29:12 +0000 (14:29 -0400)] 
c++: function NTTP argument considered unused [PR53164, PR105848]

Here at parse time the template argument f (an OVERLOAD) in A<f> gets
resolved ahead of time to the FUNCTION_DECL f<int>, and we defer marking
f<int> as used until instantiation (of g) as usual.

Later when instantiating g the type A<f> (where f has already been
resolved) is non-dependent, so tsubst_aggr_type avoids re-processing its
template arguments, and we end up never actually marking f<int> as used
(which means we never instantiate it) even though A<f>::h() later calls
it, leading to a link error.

This patch works around this issue by looking through ADDR_EXPR when
calling mark_used on the substituted callee of a CALL_EXPR.

PR c++/53164
PR c++/105848

gcc/cp/ChangeLog:

* pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Look through an
ADDR_EXPR callee when calling mark_used.

gcc/testsuite/ChangeLog:

* g++.dg/template/fn-ptr3.C: New test.

(cherry picked from commit 733a792a2b2e1662e738fa358b45a2720a8618a7)

22 months agoc++: cv-quals of dummy obj for non-dep memfn call [PR105637]
Patrick Palka [Fri, 3 Jun 2022 16:06:59 +0000 (12:06 -0400)] 
c++: cv-quals of dummy obj for non-dep memfn call [PR105637]

In non-dependent23.C below we expect the Base::foo calls to
resolve to the second, third and fourth overloads respectively in light
of the cv-qualifiers of 'this' in each case.  But ever since
r12-6075-g2decd2cabe5a4f, the calls incorrectly resolve to the first
overload at instantiation time.

This happens because the calls to Base::foo are all deemed
non-dependent (ever since r7-755-g23cb72663051cd made us ignore 'this'
dependence when considering the dependence of a non-static memfn call),
hence we end up checking the call ahead of time, using as the object
argument a dummy object of type Base.  Since this object argument is
cv-unqualified, the calls in turn resolve to the unqualified overload
of baseDevice.  Before r12-6075 this incorrect result would just get
silently discarded and we'd end up redoing OR at instantiation time
using 'this' as the object argument.  But after r12-6075 we now reuse
this incorrect result at instantiation time.

This patch fixes this by making maybe_dummy_object respect the cv-quals
of (the non-lambda) 'this' when returning a dummy object.  Thus, ahead
of time OR using a dummy object will give us the right answer that's
consistent with the instantiation time answer.

An earlier version of this patch didn't handle 'this'-capturing lambdas
correctly, which broke lambda-this22.C below.

PR c++/105637

gcc/cp/ChangeLog:

* tree.cc (maybe_dummy_object): When returning a dummy
object, respect the cv-quals of 'this' if available.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-this22.C: New test.
* g++.dg/template/non-dependent23.C: New test.

(cherry picked from commit 44a5bd6d933d86ed988fc4695aa00f122cf83eb4)

22 months agoc++: don't substitute TEMPLATE_PARM_CONSTRAINTS [PR100374]
Patrick Palka [Fri, 3 Jun 2022 13:29:12 +0000 (09:29 -0400)] 
c++: don't substitute TEMPLATE_PARM_CONSTRAINTS [PR100374]

This patch makes us avoid substituting into the TEMPLATE_PARM_CONSTRAINTS
of each template parameter except as necessary for declaration matching,
like we already do for the other constituent constraints of a declaration.

This patch also improves the CA104 implementation of explicit
specialization matching of a constrained function template inside a
class template, by considering the function's combined constraints
instead of just its trailing constraints.  This allows us to correctly
handle the first three explicit specializations in concepts-spec2.C
below, but because we compare the constraints as a whole, it means we
incorrectly accept the fourth explicit specialization which writes #3's
constraints in a different way.  For complete correctness here,
determine_specialization should use tsubst_each_template_parm_constraints
and template_parameter_heads_equivalent_p.

PR c++/100374

gcc/cp/ChangeLog:

* pt.cc (determine_specialization): Compare overall constraints
not just the trailing constraints.
(tsubst_each_template_parm_constraints): Define.
(tsubst_friend_function): Use it.
(tsubst_friend_class): Use it.
(tsubst_template_parm): Don't substitute TEMPLATE_PARM_CONSTRAINTS.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-spec2.C: New test.
* g++.dg/cpp2a/concepts-template-parm11.C: New test.

(cherry picked from commit 43c013df02fdb07f9b7a5e7e6669e6d69769d451)

22 months agoc++: non-dep call with empty TYPE_BINFO [PR105758]
Patrick Palka [Tue, 31 May 2022 20:49:08 +0000 (16:49 -0400)] 
c++: non-dep call with empty TYPE_BINFO [PR105758]

Here the out-of-line definition of Z<T>::z causes duplicate_decls to
change z's type from using the primary template type Z<T> (which is also
the type of the injected class name) to the implicit instantiation Z<T>,
and this latter type lacks a TYPE_BINFO (although its TYPE_CANONICAL was
set by a special case in lookup_template_class to point to the former).

Later, when processing the non-dependent call z->foo(0), build_over_call
relies on the object argument's TYPE_BINFO to build the templated form
for this call, which fails because the object argument type has empty
TYPE_BINFO due to the above.

It seems weird that the implicit instantiation Z<T> doesn't have the
same TYPE_BINFO as the primary template type Z<T>, despite them being
proclaimed equivalent via TYPE_CANONICAL.  So I tried also setting
TYPE_BINFO in the special case in lookup_template_class, but that led to
some problems with constrained partial specializations of the form Z<T>.
I'm not sure what, if anything, we ought to do about the subtle
differences between these two versions of the same type.

Fortunately it seems we don't need to rely on TYPE_BINFO at all in
build_over_call here -- the z_candidate struct already contains the
exact binfos we need to rebuild the BASELINK for the templated form.

PR c++/105758

gcc/cp/ChangeLog:

* call.cc (build_over_call): Use z_candidate::conversion_path
and ::access_path instead of TYPE_BINFO when building the
BASELINK for the templated form.

gcc/testsuite/ChangeLog:

* g++.dg/template/non-dependent24.C: New test.

(cherry picked from commit 4f84f12066953186cce4328b7f178d3daa2fe96e)

22 months agoc++: constrained partial spec forward decl [PR96363]
Patrick Palka [Thu, 26 May 2022 13:43:14 +0000 (09:43 -0400)] 
c++: constrained partial spec forward decl [PR96363]

Here during cp_parser_single_declaration for #2, we were calling
associate_classtype_constraints for TPL<T> (the primary template type)
before maybe_process_partial_specialization could get a chance to
notice that we're in fact declaring a distinct constrained partial
spec and not redeclaring the primary template.  This caused us to
emit a bogus error about differing constraints b/t the primary template
and #2's constraints.  This patch fixes this by moving the call to
associate_classtype_constraints after the call to shadow_tag (which
calls maybe_process_partial_specialization) and adjusting shadow_tag to
use the return value of m_p_p_s.

Moreover, if we later try to define a constrained partial specialization
that's been declared earlier (as in the third testcase), then
maybe_new_partial_specialization correctly notices it's a redeclaration
and returns NULL_TREE.  But in this case we also need to update TYPE to
point to the redeclared partial spec (it'll otherwise continue pointing
to the primary template type, eventually leading to a bogus error).

PR c++/96363

gcc/cp/ChangeLog:

* decl.cc (shadow_tag): Use the return value of
maybe_process_partial_specialization.
* parser.cc (cp_parser_single_declaration): Call shadow_tag
before associate_classtype_constraints.
* pt.cc (maybe_new_partial_specialization): Change return type
to bool.  Take 'type' argument by mutable reference.  Set 'type'
to point to the correct constrained specialization when
appropriate.
(maybe_process_partial_specialization): Adjust accordingly.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-partial-spec12.C: New test.
* g++.dg/cpp2a/concepts-partial-spec12a.C: New test.
* g++.dg/cpp2a/concepts-partial-spec13.C: New test.

(cherry picked from commit 97dc78d705a90c1ae83c78a7f2e24942cc3a6257)

22 months agolibgo: don't include <linux/fs.h> when building gen-sysinfo.go
Ian Lance Taylor [Wed, 13 Jul 2022 02:42:43 +0000 (19:42 -0700)] 
libgo: don't include <linux/fs.h> when building gen-sysinfo.go

Removing this doesn't change anything at least with glibc 2.33.
The include was added in https://go.dev/cl/6100049 but it's not
clear why.

Fixes PR go/106266

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/417294
(cherry picked from commit f35d65517a59565758107c5b1a51a5fa382f8d1a)

22 months agolibsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream
Martin Liska [Mon, 11 Jul 2022 20:03:14 +0000 (22:03 +0200)] 
libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream

9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36

(cherry picked from commit 2701442d0cf6292f6624443c15813d6d1a3562fe)

22 months agolibstdc++: Fix std::common_iterator assignment [PR100823]
Jonathan Wakely [Wed, 20 Jul 2022 15:51:44 +0000 (16:51 +0100)] 
libstdc++: Fix std::common_iterator assignment [PR100823]

This fixes the following conformance problems reported in the PR:

- Move constructor and move assignment should be defined.
- Copy assignment from a valueless object should be allowed.

Assignment is completely rewritten by this patch, as the previous
version had a number of problems. The converting assignment failed to
handle the case of assigning a new value to a valueless object, which
should work. It only accepted lvalue arguments, so wasn't usable to
implement the move assignment operator. Finally, it enforced the
precondition that the argument is not valueless, which is correct for
the converting assignment but not for the copy assignment.

A new _M_assign member is added to handle all cases of assignment
(copying from an lvalue, moving from an rvalue, and converting from a
different type). The not valueless precondition is checked in the
converting assignment before calling _M_assign, so isn't enforced for
copy and move assignment. The new function no longer uses a switch, so
handles valueless objects as the LHS or RHS of the assignment.

libstdc++-v3/ChangeLog:

PR libstdc++/100823
* include/bits/stl_iterator.h (common_iterator): Define move
constructor and move assignment operator.
(common_iterator::_M_assign): New function implementing
assignment.
(common_iterator::operator=): Use _M_assign.
(common_iterator::_S_valueless): New constant.
* testsuite/24_iterators/common_iterator/100823.cc: New test.

(cherry picked from commit 56c999860bbbb2fd5091ba0985e2e5eaa90c6478)

22 months agolibstdc++: Fix minor bugs in std::common_iterator
Jonathan Wakely [Wed, 20 Jul 2022 11:49:28 +0000 (12:49 +0100)] 
libstdc++: Fix minor bugs in std::common_iterator

The noexcept-specifier for some std::common_iterator constructors was
incorrectly using an rvalue as the first argument of
std::is_nothrow_assignable_v. This gave the wrong answer for some types,
e.g. std::common_iterator<int*, S>, because an rvalue of scalar type
cannot be assigned to.

Also fix the friend declaration to use the same constraints as on the
definition of the class template. G++ fails to diagnose this error, due
to PR c++/96830.

Finally, the copy constructor was using std::move for its argument
in some cases, which should be removed.

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (common_iterator): Fix incorrect
uses of is_nothrow_assignable_v. Fix inconsistent constraints on
friend declaration. Do not move argument in copy constructor.
* testsuite/24_iterators/common_iterator/1.cc: Check for
noexcept constructibnle/assignable.

(cherry picked from commit 3b5567c3ec7e5759bdecc6a6fc0be2b65a93636e)

22 months agolibstdc++: Make headers include their prerequisites
Nathan Sidwell [Tue, 24 May 2022 09:17:18 +0000 (10:17 +0100)] 
libstdc++: Make headers include their prerequisites

These headers were relying on their includers having already included
some prerequisites.  That makes them unsuitable to be header-units.

So directly include the needed headers.

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

* include/bits/hashtable.h: Include required headers.
* include/bits/hashtable_policy.h: Likewise.
* include/bits/stl_heap.h: Likewise.
* include/bits/stl_iterator_base_funcs.h: Likewise.

(cherry picked from commit a44380541fee1c7ab14cc90a9af8d1aef3c72866)

22 months agolibstdc++: Fix comment typos
Jonathan Wakely [Thu, 30 Jun 2022 10:28:23 +0000 (11:28 +0100)] 
libstdc++: Fix comment typos

libstdc++-v3/ChangeLog:

* include/bits/utility.h: Fix comment typos.

(cherry picked from commit c1fe8ddf6847a14152668064f163a2585e9dc894)

22 months agolibstdc++: testsuite: Guard use of C99 std::log2
Jonathan Wakely [Tue, 28 Jun 2022 08:17:06 +0000 (09:17 +0100)] 
libstdc++: testsuite: Guard use of C99 std::log2

This prevents the test from failing if the only thing not supported is
the text printed to the log about the size of the floating-point type.

libstdc++-v3/ChangeLog:

* testsuite/20_util/from_chars/4.cc: Only use log2 if C99 math
functions are available.

(cherry picked from commit 30aea28bd30027e0a6be8e3077828256779954b3)

22 months agolibstdc++: Simplify test by not using std::log2
Jonathan Wakely [Thu, 23 Jun 2022 10:58:16 +0000 (11:58 +0100)] 
libstdc++: Simplify test by not using std::log2

This test uses std::log2 without including <cmath>, but it doesn't need
to use it at all. Just get the number of digits from numeric_limits
instead.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/random_device/entropy.cc: Use
numeric_limits<unsigned>::digits.

(cherry picked from commit 78fd15fd4a641cfac28ce60bf43a3e1ca309537b)

22 months agolibstdc++: Make __from_chars_alnum_to_val conversion explicit
Marco Falke [Tue, 19 Jul 2022 09:10:39 +0000 (10:10 +0100)] 
libstdc++: Make __from_chars_alnum_to_val conversion explicit

The optimizations from commit r12-8175-ga54137c88061c7 introduced a
clang integer sanitizer error.

Fix this with an explicit static_cast, similar to the fix for PR 96766.

libstdc++-v3/ChangeLog:

* include/std/charconv (__from_chars_alnum_to_val): Replace
implicit conversion from int to unsigned char with explicit
cast.

(cherry picked from commit 20ab3972240aff596a3fa98e9fb09ddc0658fbb3)

22 months agolibstdc++: Fix experimental::filesystem::status on Windows [PR88881]
Jonathan Wakely [Tue, 28 Jun 2022 14:56:30 +0000 (15:56 +0100)] 
libstdc++: Fix experimental::filesystem::status on Windows [PR88881]

Although the Filesystem TS isn't properly supported on Windows (unlike
the C++17 Filesystem lib), most tests do pass. Two of the failures are
due to PR 88881 which was only fixed for std::filesystem not the TS.
This applies the fix to the TS implementation too.

libstdc++-v3/ChangeLog:

PR libstdc++/88881
* src/filesystem/ops.cc (has_trailing_slash): New helper
function.
(fs::status): Strip trailing slashes.
(fs::symlink_status): Likewise.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Clean the environment before each test and use TMP instead of
TMPDIR so the test passes on Windows.

(cherry picked from commit 6c96b14a19a9e6c365eacc59868a866b99f9786d)

22 months agolibstdc++: Fix lifetime bugs for non-TLS eh_globals [PR105880]
Jonathan Wakely [Wed, 8 Jun 2022 09:43:57 +0000 (10:43 +0100)] 
libstdc++: Fix lifetime bugs for non-TLS eh_globals [PR105880]

This ensures that the single-threaded fallback buffer eh_globals is not
destroyed during program termination, using the same immortalization
technique used for error category objects.

Also ensure that init._M_init can still be read after init has been
destroyed, by making it a static data member.

libstdc++-v3/ChangeLog:

PR libstdc++/105880
* libsupc++/eh_globals.cc (eh_globals): Ensure constant init and
prevent destruction during termination.
(__eh_globals_init::_M_init): Replace with static member _S_init.
(__cxxabiv1::__cxa_get_globals_fast): Update.
(__cxxabiv1::__cxa_get_globals): Likewise.

(cherry picked from commit 1e65f2ed99024f23c56f7b6a961898bcaa882a92)

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

22 months agoFortran: fix parsing of omp task affinity iterator clause [PR101330]
Harald Anlauf [Wed, 20 Jul 2022 18:40:23 +0000 (20:40 +0200)] 
Fortran: fix parsing of omp task affinity iterator clause [PR101330]

gcc/fortran/ChangeLog:

PR fortran/101330
* openmp.cc (gfc_match_iterator): Remove left-over code from
development that could lead to a crash on invalid input.

gcc/testsuite/ChangeLog:

PR fortran/101330
* gfortran.dg/gomp/affinity-clause-7.f90: New test.

(cherry picked from commit 26bbe78f77f73bb66af1ac13d0deec888a3c6510)

22 months agoDaily bump.
GCC Administrator [Wed, 20 Jul 2022 00:19:15 +0000 (00:19 +0000)] 
Daily bump.

22 months agoc++: fix SIGFPE with -Wclass-memaccess [PR105634]
Marek Polacek [Tue, 19 Jul 2022 18:24:25 +0000 (14:24 -0400)] 
c++: fix SIGFPE with -Wclass-memaccess [PR105634]

Here we crash because we attempt to % by 0.  Thus fixed.

PR c++/105634

gcc/cp/ChangeLog:

* call.cc (maybe_warn_class_memaccess): Avoid % by zero.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wclass-memaccess-7.C: New test.

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.cc (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.cc (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.cc (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.cc (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 agotree-optimization/105971 - less surprising refs_may_alias_p_2
Richard Biener [Wed, 15 Jun 2022 09:27:31 +0000 (11:27 +0200)] 
tree-optimization/105971 - less surprising refs_may_alias_p_2

When DSE asks whether __real a is using __imag a it gets a surprising
result when a is a FUNCTION_DECL.  The following makes sure this case
is less surprising to callers but keeping the bail-out for the
non-decl case where it is true that PTA doesn't track aliases to code
correctly.

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

PR tree-optimization/105971
* tree-ssa-alias.cc (refs_may_alias_p_2): Put bail-out for
FUNCTION_DECL and LABEL_DECL refs after decl-decl disambiguation
to leak less surprising alias results.

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

(cherry picked from commit 8c2733e16ec1c0cdda3db4cdc5ad158a96a658e8)

22 months agotree-optimization/105969 - FPE with array diagnostics
Richard Biener [Wed, 15 Jun 2022 08:54:48 +0000 (10:54 +0200)] 
tree-optimization/105969 - FPE with array diagnostics

For a [0][0] array we have to be careful when dividing by the element
size which is zero for the outermost dimension.  Luckily the division
is only for an overflow check which is pointless for array size zero.

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

PR tree-optimization/105969
* gimple-ssa-sprintf.cc (get_origin_and_offset_r): Avoid division
by zero in overflow check.

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

(cherry picked from commit edb9330c29fe8a0a0b76df6fafd6a223a4d0e41f)

22 months agomiddle-end/105965 - add missing v_c_e <{ el }> simplification
Richard Biener [Tue, 14 Jun 2022 08:59:49 +0000 (10:59 +0200)] 
middle-end/105965 - add missing v_c_e <{ el }> simplification

When we got the simplification of bit-field-ref to view-convert
we lost the ability to detect FMAs since we cannot look through

  _1 = {_10};
  _11 = VIEW_CONVERT_EXPR<float>(_1);

the following amends the (view_convert CONSTRUCTOR) pattern
to handle this case.

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

PR middle-end/105965
* match.pd (view_convert CONSTRUCTOR): Handle single-element
CTOR case.

* gcc.target/i386/pr105965.c: New testcase.

(cherry picked from commit 90467f0ad649d0817f9e034596a0fb85605b55af)

22 months agotree-optimization/105946 - avoid accessing excess args from uninit diag
Richard Biener [Tue, 14 Jun 2022 09:10:13 +0000 (11:10 +0200)] 
tree-optimization/105946 - avoid accessing excess args from uninit diag

uninit diagnostics uses passing via reference and access attributes
but that iterates over function type arguments which can in some
cases appearantly outrun the actual arguments leading to ICEs.
The following simply ignores not present arguments.

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

PR tree-optimization/105946
* tree-ssa-uninit.cc (maybe_warn_pass_by_reference):
Do not look at arguments not specified in the function call.

(cherry picked from commit e07a876c07601e1f3a27420f7d055d20193c362c)