]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
19 months agolibstdc++: Fix std::format output of %C for negative years
Jonathan Wakely [Mon, 11 Dec 2023 15:33:59 +0000 (15:33 +0000)] 
libstdc++: Fix std::format output of %C for negative years

During discussion of LWG 4022 I noticed that we do not correctly
implement floored division for the century. We were just truncating
towards zero, rather than applying the floor function. For negative
values that rounds the wrong way.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_C_y_Y): Fix
rounding for negative centuries.
* testsuite/std/time/year/io.cc: Check %C for negative years.

(cherry picked from commit a01462ae8bafa86e7df47a252917ba6899d587cf)

19 months agoDaily bump.
GCC Administrator [Wed, 13 Dec 2023 00:22:21 +0000 (00:22 +0000)] 
Daily bump.

19 months agoDon't assume it's AVX_U128_CLEAN after call_insn whose abi.mode_clobber(V4DImode...
liuhongt [Thu, 7 Dec 2023 01:17:27 +0000 (09:17 +0800)] 
Don't assume it's AVX_U128_CLEAN after call_insn whose abi.mode_clobber(V4DImode) deosn't contains all SSE_REGS.

If the function desn't clobber any sse registers or only clobber
128-bit part, then vzeroupper isn't issued before the function exit.
the status not CLEAN but ANY after the function.

Also for sibling_call, it's safe to issue an vzeroupper. Also there
could be missing vzeroupper since there's no mode_exit for
sibling_call_p.

gcc/ChangeLog:

PR target/112891
* config/i386/i386.cc (ix86_avx_u128_mode_after): Return
AVX_U128_ANY if callee_abi doesn't clobber all_sse_regs to
align with ix86_avx_u128_mode_needed.
(ix86_avx_u128_mode_needed): Return AVX_U128_ClEAN for
sibling_call.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr112891.c: New test.
* gcc.target/i386/pr112891-2.c: New test.

19 months agoc++: fix ICE with is_really_empty_class [PR110106]
Marek Polacek [Tue, 18 Jul 2023 20:02:21 +0000 (16:02 -0400)] 
c++: fix ICE with is_really_empty_class [PR110106]

is_really_empty_class is liable to crash when it gets an incomplete
or dependent type.  Since r11-557, we pass the yet-uninstantiated
class type S<0> of the PARM_DECL s to is_really_empty_class -- because
of the potential_rvalue_constant_expression -> is_rvalue_constant_expression
change in cp_parser_constant_expression.  Here we're not parsing
a template so we did not check COMPLETE_TYPE_P as we should.

It should work to complete the type before checking COMPLETE_TYPE_P.

PR c++/110106

gcc/cp/ChangeLog:

* constexpr.cc (potential_constant_expression_1): Try to complete the
type when !processing_template_decl.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit e36d1994051122fc6e1f8c728fbd109a59e0a822)

19 months agoc++: fix parsing with auto(x) [PR112410]
Marek Polacek [Thu, 9 Nov 2023 17:25:25 +0000 (12:25 -0500)] 
c++: fix parsing with auto(x) [PR112410]

Here we are wrongly parsing

  int y(auto(42));

which uses the C++23 cast-to-prvalue feature, and initializes y to 42.
However, we were treating the auto as an implicit template parameter.

Fixing the auto{42} case is easy, but when auto is followed by a (,
I found the fix to be much more involved.  For instance, we cannot
use cp_parser_expression, because that can give hard errors.  It's
also necessary to disambiguate 'auto(i)' as 'auto i', not a cast.
auto(), auto(int), auto(f)(int), auto(*), auto(i[]), auto(...), etc.
are all function declarations.

This patch rectifies that by undoing the implicit function template
modification.  In the test above, we should notice that the parameter
list is ill-formed, and since we've synthesized an implicit template
parameter, we undo it by calling abort_fully_implicit_template.  Then,
we'll parse the "(auto(42))" as an initializer.

PR c++/112410

gcc/cp/ChangeLog:

* parser.cc (cp_parser_direct_declarator): Maybe call
abort_fully_implicit_template if it turned out the parameter list was
ill-formed.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/auto-fncast13.C: New test.
* g++.dg/cpp23/auto-fncast14.C: New test.

(cherry picked from commit 70060dadfbf0d0af5f4cab5f3aff3223a4523606)

19 months agoc++: wrong error with static constexpr var in tmpl [PR109876]
Marek Polacek [Thu, 25 May 2023 22:54:18 +0000 (18:54 -0400)] 
c++: wrong error with static constexpr var in tmpl [PR109876]

Since r8-509, we'll no longer create a static temporary var for
the initializer '{ 1, 2 }' for num in the attached test because
the code in finish_compound_literal is now guarded by
'&& fcl_context == fcl_c99' but it's fcl_functional here.  This
causes us to reject num as non-constant when evaluating it in
a template.

Jason's idea was to treat num as value-dependent even though it
actually isn't.  This patch implements that suggestion.

We weren't marking objects whose type is an empty class type
constant.  This patch changes that so that v_d_e_p doesn't need
to check is_really_empty_class.

Co-authored-by: Jason Merrill <jason@redhat.com>
PR c++/109876

gcc/cp/ChangeLog:

* decl.cc (cp_finish_decl): Set TREE_CONSTANT when initializing
an object of empty class type.
* pt.cc (value_dependent_expression_p) <case VAR_DECL>: Treat a
constexpr-declared non-constant variable as value-dependent.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-template12.C: New test.
* g++.dg/cpp1z/constexpr-template1.C: New test.
* g++.dg/cpp1z/constexpr-template2.C: New test.

(cherry picked from commit b5138df96a93d3b5070c88b8617eabd38cb24ab6)

19 months agoDaily bump.
GCC Administrator [Tue, 12 Dec 2023 00:21:45 +0000 (00:21 +0000)] 
Daily bump.

19 months agofixincludes: Update darwin_flt_eval_method for macOS 14
Francois-Xavier Coudert [Mon, 11 Dec 2023 14:56:04 +0000 (15:56 +0100)] 
fixincludes: Update darwin_flt_eval_method for macOS 14

On macOS 14, a guard in <math.h> changed:

-- MacOSX13.3.sdk/usr/include/math.h 2023-04-19 01:54:44
+++ MacOSX14.0.sdk/usr/include/math.h 2023-08-01 08:42:43
@@ -22,0 +23 @@
+
@@ -43 +44 @@
-#if __FLT_EVAL_METHOD__ == 0
+#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1
@@ -49 +50 @@
-#elif __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ == -1
+#elif __FLT_EVAL_METHOD__ == 2

Therefore the darwin_flt_eval_method fixincludes fix doesn't match any
longer, leading to a large number of testsuite failures like

/private/var/gcc/regression/master/14-gcc/build/gcc/include-fixed/math.h:69:5:
error: #error "Unsupported value of __FLT_EVAL_METHOD__."

where __FLT_EVAL_METHOD__ = 16.

This patch adjusts the fix to allow for both forms.

Tested with make check in fixincludes on x86_64-apple-darwin23.0.0 and
verifying that <math.h> has indeed been fixed as expected.

(backport of 93f803d53b5ccaabded9d7b4512b54da81c1c616)

2023-12-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

fixincludes:
* inclhack.def (darwin_flt_eval_method): Handle macOS 14 guard
variant.
* fixincl.x: Regenerate.
* tests/base/math.h [DARWIN_FLT_EVAL_METHOD_CHECK]: Update test.

19 months agoDaily bump.
GCC Administrator [Mon, 11 Dec 2023 00:21:34 +0000 (00:21 +0000)] 
Daily bump.

19 months agoFortran: deferred-length character optional dummy arguments [PR93762,PR100651]
Harald Anlauf [Fri, 1 Dec 2023 21:44:30 +0000 (22:44 +0100)] 
Fortran: deferred-length character optional dummy arguments [PR93762,PR100651]

gcc/fortran/ChangeLog:

PR fortran/93762
PR fortran/100651
* trans-array.cc (gfc_trans_deferred_array): Add presence check
for optional deferred-length character dummy arguments.
* trans-expr.cc (gfc_conv_missing_dummy): The character length for
deferred-length dummy arguments is passed by reference, so that
its value can be returned.  Adjust handling for optional dummies.

gcc/testsuite/ChangeLog:

PR fortran/93762
PR fortran/100651
* gfortran.dg/optional_deferred_char_1.f90: New test.

(cherry picked from commit 27ce74fa23c93c1189c301993cd19ea766e6bdb5)

20 months agoDaily bump.
GCC Administrator [Sun, 10 Dec 2023 00:20:49 +0000 (00:20 +0000)] 
Daily bump.

20 months agolibstdc++: Fix value of __cpp_lib_format macro [PR111826]
Jonathan Wakely [Fri, 8 Dec 2023 14:40:26 +0000 (14:40 +0000)] 
libstdc++: Fix value of __cpp_lib_format macro [PR111826]

As noted in the PR, we support both features required for the 202110L
value, so we should define it with that value.

libstdc++-v3/ChangeLog:

PR libstdc++/111826
* include/std/format (__cpp_lib_format): Update value.
* include/std/version (__cpp_lib_format): Likewise.
* testsuite/std/format/functions/format.cc: Update expected
value.

(cherry picked from commit cdf45e00a936a76a785c592c9730f24ef1ac25cd)

20 months agolibstdc++: Fix misleading typedef name in <format>
Jonathan Wakely [Thu, 7 Dec 2023 12:40:18 +0000 (12:40 +0000)] 
libstdc++: Fix misleading typedef name in <format>

This local typedef for uintptr_t was accidentally named uint64_t,
probably from a careless code completion shortcut. We don't need the
typedef at all since it's only used once. Just use __UINTPTR_TYPE__
directly instead.

libstdc++-v3/ChangeLog:

* include/std/format (_Iter_sink<charT, contiguous_iterator>):
Remove uint64_t local type.

(cherry picked from commit cab0083dc72dfd22a1b2016b068f9313beb7f091)

20 months agolibstdc++: Use <cstdint> instead of <stdint.h> in <bits/atomic_wait.h>
Jonathan Wakely [Thu, 7 Dec 2023 11:00:02 +0000 (11:00 +0000)] 
libstdc++: Use <cstdint> instead of <stdint.h> in <bits/atomic_wait.h>

In r14-5922-g6c8f2d3a08bc01 I added <stdint.h> to <bits/atomic_wait.h>,
so that uintptr_t is declared if that header is compiled as a header
unit. I used <stdint.h> because that's what <atomic> already includes,
so it seemed simpler to be consistent. However, this means that name
lookup for uintptr_t in <bits/atomic_wait.h> depends on whether
<cstdint> has been included by another header first. Whether name lookup
finds std::uintptr_t or ::uintptr_t will depend on include order. This
causes problems when compiling modules with Clang:

bits/atomic_wait.h:251:7: error: 'std::__detail::__waiter_pool_base' has different definitions in different modules; first difference is defined here found method '_S_for' with body
      _S_for(const void* __addr) noexcept
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bits/atomic_wait.h:251:7: note: but in 'tm.<global>' found method '_S_for' with different body
      _S_for(const void* __addr) noexcept
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By including <cstdint> we would ensure that name lookup always finds the
name in namespace std. Alternatively, we can stop including <stdint.h>
for those types, so that we don't declare the entire contents of
<stdint.h> when we only need a couple of types from it. This patch does
the former, which is appropriate for backporting.

libstdc++-v3/ChangeLog:

* include/bits/atomic_wait.h: Include <cstdint> instead of
<stdint.h>.

(cherry picked from commit 2f512f6fcdd55296daff3e01a250d866491014e6)

20 months agoDaily bump.
GCC Administrator [Sat, 9 Dec 2023 00:21:21 +0000 (00:21 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Fri, 8 Dec 2023 00:21:28 +0000 (00:21 +0000)] 
Daily bump.

20 months agoaarch64: add -fno-stack-protector to tests
Marek Polacek [Wed, 6 Dec 2023 20:34:24 +0000 (15:34 -0500)] 
aarch64: add -fno-stack-protector to tests

These tests fail when the testsuite is executed with -fstack-protector-strong.
To avoid this, this patch adds -fno-stack-protector to dg-options.

The list of FAILs is appended.  As you can see, it's mostly about
scan-assembler-* which are sort of expected to fail with the stack
protector on.

FAIL: gcc.target/aarch64/ldp_stp_unaligned_2.c scan-assembler-not mov\\tx[0-9]+, sp
FAIL: gcc.target/aarch64/shadow_call_stack_5.c scan-assembler-times stp\\\\tx29, x30, \\\\[sp\\\\] 1
FAIL: gcc.target/aarch64/shadow_call_stack_5.c scan-assembler ldr\\\\tx29, \\\\[sp\\\\]
FAIL: gcc.target/aarch64/shadow_call_stack_6.c scan-assembler-times str\\\\tx30, \\\\[sp\\\\] 1
FAIL: gcc.target/aarch64/shadow_call_stack_7.c scan-assembler-times stp\\\\tx19, x30, \\\\[sp, -[0-9]+\\\\]! 1
FAIL: gcc.target/aarch64/shadow_call_stack_7.c scan-assembler ldr\\\\tx19, \\\\[sp\\\\], [0-9]+
FAIL: gcc.target/aarch64/shadow_call_stack_8.c scan-assembler-times stp\\\\tx19, x20, \\\\[sp, -[0-9]+\\\\]! 1
FAIL: gcc.target/aarch64/shadow_call_stack_8.c scan-assembler ldp\\\\tx19, x20, \\\\[sp\\\\], [0-9]+
FAIL: gcc.target/aarch64/stack-check-12.c scan-assembler-times str\\\\txzr,  2
FAIL: gcc.target/aarch64/stack-check-prologue-11.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-12.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-13.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-13.c scan-assembler-times str\\\\s+x30, \\\\[sp\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-14.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-14.c scan-assembler-times str\\\\s+x30, \\\\[sp\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-15.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-15.c scan-assembler-times str\\\\s+x30, \\\\[sp\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-17.c check-function-bodies test1
FAIL: gcc.target/aarch64/stack-check-prologue-17.c check-function-bodies test2
FAIL: gcc.target/aarch64/stack-check-prologue-18.c check-function-bodies test1
FAIL: gcc.target/aarch64/stack-check-prologue-18.c check-function-bodies test2
FAIL: gcc.target/aarch64/stack-check-prologue-18.c check-function-bodies test3
FAIL: gcc.target/aarch64/stack-check-prologue-19.c check-function-bodies test1
FAIL: gcc.target/aarch64/stack-check-prologue-19.c check-function-bodies test2
FAIL: gcc.target/aarch64/stack-check-prologue-19.c check-function-bodies test3
FAIL: gcc.target/aarch64/stack-check-prologue-2.c scan-assembler-times str\\\\s+xzr, 0
FAIL: gcc.target/aarch64/stack-check-prologue-5.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-6.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 1
FAIL: gcc.target/aarch64/stack-check-prologue-8.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 2
FAIL: gcc.target/aarch64/stack-check-prologue-9.c scan-assembler-times str\\\\s+xzr, \\\\[sp, 1024\\\\] 1
FAIL: gcc.target/aarch64/test_frame_1.c scan-assembler-times str\\tx30, \\\\[sp, -[0-9]+\\\\]! 2
FAIL: gcc.target/aarch64/test_frame_10.c scan-assembler-times stp\\tx19, x30, \\\\[sp, [0-9]+\\\\] 1
FAIL: gcc.target/aarch64/test_frame_10.c scan-assembler ldp\\tx19, x30, \\\\[sp, [0-9]+\\\\]
FAIL: gcc.target/aarch64/test_frame_11.c scan-assembler-times stp\\tx29, x30, \\\\[sp, -[0-9]+\\\\]! 2
FAIL: gcc.target/aarch64/test_frame_13.c scan-assembler-times stp\\tx29, x30, \\\\[sp\\\\] 1
FAIL: gcc.target/aarch64/test_frame_15.c scan-assembler-times stp\\tx29, x30, \\\\[sp, [0-9]+\\\\] 1
FAIL: gcc.target/aarch64/test_frame_2.c scan-assembler-times stp\\tx19, x30, \\\\[sp, -[0-9]+\\\\]! 1
FAIL: gcc.target/aarch64/test_frame_2.c scan-assembler ldp\\tx19, x30, \\\\[sp\\\\], [0-9]+
FAIL: gcc.target/aarch64/test_frame_4.c scan-assembler-times stp\\tx19, x30, \\\\[sp, -[0-9]+\\\\]! 1
FAIL: gcc.target/aarch64/test_frame_4.c scan-assembler ldp\\tx19, x30, \\\\[sp\\\\], [0-9]+
FAIL: gcc.target/aarch64/test_frame_6.c scan-assembler-times str\\tx30, \\\\[sp\\\\] 1
FAIL: gcc.target/aarch64/test_frame_7.c scan-assembler-times stp\\tx19, x30, \\\\[sp] 1
FAIL: gcc.target/aarch64/test_frame_8.c scan-assembler-times str\\tx30, \\\\[sp, [0-9]+\\\\] 1
FAIL: gcc.target/aarch64/test_frame_8.c scan-assembler ldr\\tx30, \\\\[sp, [0-9]+\\\\]
FAIL: gcc.target/aarch64/sve/struct_vect_24.c scan-assembler-times cmp\\\\s+x[0-9]+, 61440 4
FAIL: gcc.target/aarch64/sve/struct_vect_24.c scan-assembler-times sub\\\\s+x[0-9]+, x[0-9]+, 61440 4
FAIL: gcc.target/aarch64/sve/struct_vect_24.c scan-assembler-times cmp\\s+x[0-9]+, 61440 4
FAIL: gcc.target/aarch64/sve/struct_vect_24.c scan-assembler-times sub\\s+x[0-9]+, x[0-9]+, 61440 4

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/ldp_stp_unaligned_2.c: Use -fno-stack-protector.
* gcc.target/aarch64/shadow_call_stack_5.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_6.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_7.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_8.c: Likewise.
* gcc.target/aarch64/stack-check-12.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-11.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-12.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-13.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-14.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-15.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-17.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-18.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-19.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-2.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-5.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-6.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-8.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-9.c: Likewise.
* gcc.target/aarch64/sve/struct_vect_24.c: Likewise.
* gcc.target/aarch64/test_frame_1.c: Likewise.
* gcc.target/aarch64/test_frame_10.c: Likewise.
* gcc.target/aarch64/test_frame_11.c: Likewise.
* gcc.target/aarch64/test_frame_13.c: Likewise.
* gcc.target/aarch64/test_frame_15.c: Likewise.
* gcc.target/aarch64/test_frame_2.c: Likewise.
* gcc.target/aarch64/test_frame_4.c: Likewise.
* gcc.target/aarch64/test_frame_6.c: Likewise.
* gcc.target/aarch64/test_frame_7.c: Likewise.
* gcc.target/aarch64/test_frame_8.c: Likewise.

(cherry picked from commit 2125710245d64ff6edff7ebd339caf4698fdd89d)

20 months agoDaily bump.
GCC Administrator [Thu, 7 Dec 2023 00:21:11 +0000 (00:21 +0000)] 
Daily bump.

20 months agolibstdc++: Add workaround to std::ranges::subrange [PR111948]
Jonathan Wakely [Tue, 24 Oct 2023 19:15:12 +0000 (20:15 +0100)] 
libstdc++: Add workaround to std::ranges::subrange [PR111948]

libstdc++-v3/ChangeLog:

PR libstdc++/111948
* include/bits/ranges_util.h (subrange): Add constructor to
_Size to avoid setting member in constructor.
* testsuite/std/ranges/subrange/111948.cc: New test.

(cherry picked from commit 08448dc146b6dd32383d64ab491a594d41f62aaa)

20 months agolibstdc++: Micro-optimization for std::optional [PR112480]
Jonathan Wakely [Sat, 11 Nov 2023 00:35:18 +0000 (00:35 +0000)] 
libstdc++: Micro-optimization for std::optional [PR112480]

This small change removes a branch when clearing a std::optional<T> for
types with no-op destructors. For types where the destructor can be
optimized away (e.g. because it's trivial, or empty and can be inlined)
the _M_destroy() function does nothing but set _M_engaged to false.
Setting _M_engaged=false unconditionally is cheaper than only doing it
when initially true, because it allows the compiler to remove a branch.

The compiler thinks it would be incorrect to unconditionally introduce a
store there, because it could conflict with reads in other threads, so
it won't do that optimization itself. We know it's safe to do because
we're in a non-const member function, so the standard forbids any
potentially concurrent calls to other member functions of the same
object. Making the store unconditional can't create a data race that
isn't already present in the program.

libstdc++-v3/ChangeLog:

PR libstdc++/112480
* include/std/optional (_Optional_payload_base::_M_reset): Set
_M_engaged to false unconditionally.

(cherry picked from commit 2c492f99fc1fcb5f598286c3f3a21a05bca69d9e)

20 months agolibstdc++: Add static_assert to std::integer_sequence [PR112473]
Jonathan Wakely [Fri, 10 Nov 2023 12:21:52 +0000 (12:21 +0000)] 
libstdc++: Add static_assert to std::integer_sequence [PR112473]

C++20 allows class types as non-type template parameters, but
std::integer_sequence explicitly disallows them. Enforce that.

libstdc++-v3/ChangeLog:

PR libstdc++/112473
* include/bits/utility.h (integer_sequence): Add static_assert.
* testsuite/20_util/integer_sequence/112473.cc: New test.

(cherry picked from commit 0953497a81f1e320989b9f2aaa7f56747eddd4a0)

20 months agolibstdc++: Disable std::formatter::set_debug_format [PR112832]
Jonathan Wakely [Mon, 4 Dec 2023 12:03:28 +0000 (12:03 +0000)] 
libstdc++: Disable std::formatter::set_debug_format [PR112832]

All set_debug_format member functions should be guarded by the
__cpp_lib_formatting_ranges macro (which is not defined yet).

libstdc++-v3/ChangeLog:

PR libstdc++/112832
* include/std/format (formatter::set_debug_format): Ensure this
member is defined conditionally for all specializations.
* testsuite/std/format/formatter/112832.cc: New test.

(cherry picked from commit 3cd73543a1122d3c81409e3e9a26c3e94c3d324f)

20 months agolibstdc++: Use strerror_r in std::generic_category()::message(int) [PR110133]
Jonathan Wakely [Fri, 3 Nov 2023 13:59:48 +0000 (13:59 +0000)] 
libstdc++: Use strerror_r in std::generic_category()::message(int) [PR110133]

Use strerror_r instead of strerror when available, due to the latter not
being thread-safe. This is complicated by Glibc providing a GNU-specific
strerror_r which is not compatible with POSIX strerror_r, so we need to
dispatch on the return type.

Because we estimate the initial std::string buffer size we might end up
with excess capacity in the returned std::string. We can slightly tweak
the std::system_error constructors to make use of that excess capacity,
so that in some cases we require fewer allocations to construct the
std::system_error::what() string.

libstdc++-v3/ChangeLog:

PR libstdc++/110133
* include/std/system_error (system_error::system_error): Group
arguments so that concatenation can reuse rvalue's capacity.
* src/c++11/system_error.cc (strerror_string): New function.
[_GLIBCXX_HAVE_STRERROR_R] (use_strerror_result): New functions.
(generic_error_category::message): Use strerror_string.
(system_error_category::message): Likewise.

(cherry picked from commit 51f94778b45514992a716b0b2d7a87244e6f0018)

20 months agoDaily bump.
GCC Administrator [Wed, 6 Dec 2023 00:20:51 +0000 (00:20 +0000)] 
Daily bump.

20 months agoi386: Fix -fcf-protection -Os ICE due to movabsq peephole2 [PR112845]
Jakub Jelinek [Tue, 5 Dec 2023 12:17:57 +0000 (13:17 +0100)] 
i386: Fix -fcf-protection -Os ICE due to movabsq peephole2 [PR112845]

The following testcase ICEs in the movabsq $(i32 << shift), r64 peephole2
I've added a while back to use smaller code than movabsq if possible.
If i32 is 0xfa1e0ff3 and shift is not divisible by 8, then it creates
an invalid insn (as 0xfa1e0ff3 CONST_INT is not allowed as
x86_64_immediate_operand nor x86_64_zext_immediate_operand), the peephole2
even triggers on it again and again (this time with shift 0) until it gives
up.

The following patch fixes that.  As ix86_endbr_immediate_operand needs a
CONST_INT and it is hopefully rare, I chose to use FAIL rather than handling
it in the condition (where I'd probably need to call ctz_hwi again etc.).

2023-12-05  Jakub Jelinek  <jakub@redhat.com>

PR target/112845
* config/i386/i386.md (movabsq $(i32 << shift), r64 peephole2): FAIL
if the new immediate is ix86_endbr_immediate_operand.

(cherry picked from commit e0786ca9a18c50ad08c40936b228e325193664b8)

20 months agoi386: Fix rtl checking ICE in ix86_elim_entry_set_got [PR112837]
Jakub Jelinek [Mon, 4 Dec 2023 08:01:09 +0000 (09:01 +0100)] 
i386: Fix rtl checking ICE in ix86_elim_entry_set_got [PR112837]

The following testcase ICEs with RTL checking, because it sets if
XINT (SET_SRC (set), 1) is UNSPEC_SET_GOT without checking if SET_SRC (set)
is actually an UNSPEC, so any time we see any other insn with PARALLEL
and a SET in it which is not an UNSPEC we ICE during RTL checking or
access there some other union member as if it was an rt_int.
The rest is just small cleanup.

2023-12-04  Jakub Jelinek  <jakub@redhat.com>

PR target/112837
* config/i386/i386.cc (ix86_elim_entry_set_got): Before checking
for UNSPEC_SET_GOT check that SET_SRC is UNSPEC.  Use SET_SRC and
SET_DEST macros instead of XEXP, rename vec variable to set.

* gcc.dg/pr112837.c: New test.

(cherry picked from commit 4586d7d0a92e9b60d0c01043e0ae262b1e06f337)

20 months agoi386: Fix up signbit<mode>2 expander [PR112816]
Jakub Jelinek [Mon, 4 Dec 2023 08:00:18 +0000 (09:00 +0100)] 
i386: Fix up signbit<mode>2 expander [PR112816]

The following testcase ICEs, because the signbit<mode>2 expander uses an
explicit SUBREG in the pattern around match_operand with register_operand
predicate.  If we are unlucky enough that expansion tries to expand it
with some SUBREG as operands[1], we have two nested SUBREGs in the IL,
which is not valid and causes ICE later.

2023-12-04  Jakub Jelinek  <jakub@redhat.com>

PR target/112816
* config/i386/sse.md (signbit<mode>2): Force operands[1] into a REG.

* gcc.target/i386/sse2-pr112816.c: New test.

(cherry picked from commit 994d6dc64435d6b7c50accca9941ee7decd92a22)

20 months agoc++: #pragma GCC unroll C++ fixes [PR112795]
Jakub Jelinek [Mon, 4 Dec 2023 07:59:15 +0000 (08:59 +0100)] 
c++: #pragma GCC unroll C++ fixes [PR112795]

foo in the unroll-5.C testcase ICEs because cp_parser_pragma_unroll
during parsing calls maybe_constant_value unconditionally, which is
fine if !processing_template_decl, but can ICE otherwise.

While just calling fold_non_dependent_expr there instead could be enough
to fix the ICE (and I guess the right thing to do for backports if any),
I don't see a reason why we couldn't handle a dependent #pragma GCC unroll
argument as well, the unrolling isn't done in the FE and all the middle-end
cares about is that ANNOTATE_EXPR has a 1..65534 last operand when it is
annot_expr_unroll_kind.

So, the following patch changes all the unsigned short unroll arguments
to tree unroll (and thus avoids the tree -> unsigned short -> tree
conversions), does the type and value checking during parsing only if
the argument isn't dependent and repeats it during instantiation.

2023-12-04  Jakub Jelinek  <jakub@redhat.com>

PR c++/112795
gcc/cp/
* parser.cc (cp_parser_pragma_unroll): Use fold_non_dependent_expr
instead of maybe_constant_value.
gcc/testsuite/
* g++.dg/ext/unroll-5.C: New test.

(cherry picked from commit b6c78feea08c36e5754818c6a3d7536b3f8913dc)

20 months agoextend.texi: Fix up defbuiltin* with spaces in return type
Jakub Jelinek [Fri, 1 Dec 2023 15:57:30 +0000 (16:57 +0100)] 
extend.texi: Fix up defbuiltin* with spaces in return type

In https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fstdc_005fbit_005ffloor
I've noticed that while e.g. __builtin_stdc_bit_floor builtin is properly
rendered in bold and bigger size, for the __builtin_stdc_bit_width builtin
it is not the builtin name which is marked like that, but the keyword int
before it.  Also, seems such builtins are missing from the index.

I've read the texinfo docs and they seem to suggest in
https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Line-Macros.html
that return types of functions with spaces in the return type should be
wrapped with {}s and we already use that e.g. in
@defbuiltin{{void *} __builtin_thread_pointer (void)}

The following patch adjusts builtins I found which contained one or two
spaces in the return type name (plus two spots which used 2 spaces after
single keyword return type instead of 1 which triggered my search regex as
well).

2023-12-01  Jakub Jelinek  <jakub@redhat.com>

* doc/extend.texi (__builtin_darn, __builtin_darn_raw,
__builtin_ia32_vec_ext_v2di, __builtin_ia32_crc32qi,
__builtin_ia32_crc32hi, __builtin_ia32_crc32si,
__builtin_ia32_crc32di): Put {}s around return type with spaces in it.
(__builtin_rx_mvfachi, __builtin_rx_mvfacmi): Remove superfluous
whitespace.

(cherry picked from commit ff99671ac3ea583a9d65c8c3cd3ff4aad1d68592)

20 months agoi386: Fix up *jcc_bt*_mask{,_1} [PR111408]
Jakub Jelinek [Sat, 25 Nov 2023 09:31:55 +0000 (10:31 +0100)] 
i386: Fix up *jcc_bt*_mask{,_1} [PR111408]

The following testcase is miscompiled in GCC 14 because the
*jcc_bt<mode>_mask and *jcc_bt<SWI48:mode>_mask_1 patterns have just
one argument in (match_operator 0 "bt_comparison_operator" [...])
but as bt_comparison_operator is eq,ne, we need two.
The md readers don't warn about it, after all, some checks can
be done in the predicate rather than specified explicitly, and the
behavior is that anything is accepted as the second argument.

I went through all other i386.md match_operator uses and all others
looked right (extract_operator using 3 operands, all others 2).

I think we'll want to fix this at different spots in older releases
because I think the bug was introduced already in 2008, though most
likely just latent.

2023-11-25  Jakub Jelinek  <jakub@redhat.com>

PR target/111408
* config/i386/i386.md (*jcc_bt<mode>_mask,
*jcc_bt<mode>_mask_1): Add (const_int 0) as expected
second operand of bt_comparison_operator.

* gcc.c-torture/execute/pr111408.c: New test.

(cherry picked from commit 9866c98e1015d98b8fc346d7cf73a0070cce5f69)

20 months agogimple-range-cache: Fix ICEs when dumping details [PR111967]
Jakub Jelinek [Mon, 13 Nov 2023 07:47:41 +0000 (08:47 +0100)] 
gimple-range-cache: Fix ICEs when dumping details [PR111967]

The following testcase ICEs when dumping details.
When m_ssa_ranges vector is created, it is safe_grow_cleared (num_ssa_names),
but when when some new SSA_NAME is added, we strangely grow it to
num_ssa_names + 1 instead and later on the 3 argument dump method
iterates from 1 to m_ssa_ranges.length () - 1 and uses ssa_name (x)
on each; but because set_bb_range grew it one too much, ssa_name
(m_ssa_ranges.length () - 1) might be after the end of the ssanames
vector and ICE.

The fix grows the vector consistently only to num_ssa_names,
doesn't waste time checking m_ssa_ranges[0] because there is no
ssa_names (0), it is always NULL, before using ssa_name (x) checks
if we'll need it at all (we check later if m_ssa_ranges[x] is non-NULL,
so we might check it earlier as well) and also in the last loop
iterates until m_ssa_ranges.length () rather than num_ssa_names, I don't
see a reason for the inconsistency and in theory some SSA_NAME could be
added without set_bb_range called for it and the vector could be shorter
than the ssanames vector.

To actually fix the ICE, either the first hunk or the last 2 hunks
would be enough, but I think it doesn't hurt to change all the spots.

2023-11-13  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/111967
* gimple-range-cache.cc (block_range_cache::set_bb_range): Grow
m_ssa_ranges to num_ssa_names rather than num_ssa_names + 1.
(block_range_cache::dump): Iterate from 1 rather than 0.  Don't use
ssa_name (x) unless m_ssa_ranges[x] is non-NULL.  Iterate to
m_ssa_ranges.length () rather than num_ssa_names.

* gcc.dg/tree-ssa/pr111967.c: New test.

(cherry picked from commit 5a0c302d2d721b9650c1e354695dbba87364c334)

20 months agoattribs: Fix ICE with -Wno-attributes= [PR112339]
Jakub Jelinek [Thu, 9 Nov 2023 08:05:54 +0000 (09:05 +0100)] 
attribs: Fix ICE with -Wno-attributes= [PR112339]

The following testcase ICEs, because with -Wno-attributes=foo::no_sanitize
(but generally any other non-gnu namespace and some gnu well known attribute
name within that other namespace) the FEs don't really parse attribute
arguments of such attribute, but lookup_attribute_spec is non-NULL with
NULL handler and such attributes are added to DECL_ATTRIBUTES or
TYPE_ATTRIBUTES and then when e.g. middle-end does lookup_attribute
on a particular attribute and expects the attribute to mean something
and/or have a particular verified arguments, it can crash when seeing
the foreign attribute in there instead.

The following patch fixes that by never adding ignored attributes
to DECL_ATTRIBUTES/TYPE_ATTRIBUTES, previously that was the case just
for attributes in ignored namespace (where lookup_attribute_space
returned NULL).  We don't really know anything about those attributes,
so shouldn't pretend we know something about them, especially when
the arguments are error_mark_node or NULL instead of something that
would have been parsed.  And it would be really weird if we normally
ignore say [[clang::unused]] attribute, but when people use
-Wno-attributes=clang::unused we actually treated it as gnu::unused.
All the user asked for is suppress warnings about that attribute being
unknown.

The first hunk is just playing safe, I'm worried people could
-Wno-attributes=gnu::
and get various crashes with known GNU attributes not being actually
parsed and recorded (or worse e.g. when we tweak standard attributes
into GNU attributes and we wouldn't add those).
The -Wno-attributes= documentation says that it suppresses warning about
unknown attributes, so I think -Wno-attributes=gnu:: should prevent
warning about say [[gnu::foobarbaz]] attribute, but not about
[[gnu::unused]] because the latter is a known attribute.
The routine would return true for any scoped attribute in the ignored
namespace, with the change it ignores only unknown attributes in ignored
namespace, known ones in there will be ignored only if they have
max_length of -2 (e.g.. with
-Wno-attributes=gnu:: -Wno-attributes=gnu::foobarbaz).

2023-11-09  Jakub Jelinek  <jakub@redhat.com>

PR c/112339
* attribs.cc (attribute_ignored_p): Only return true for
attr_namespace_ignored_p if as is NULL.
(decl_attributes): Never add ignored attributes.

* c-c++-common/ubsan/Wno-attributes-1.c: New test.

(cherry picked from commit 533241c6c60bc7c9f7dc47a94e94b5eed1b370e6)

20 months agolibstdc++: Fix tr1/8_c_compatibility/cstdio/functions.cc regression with recent glibc
Jakub Jelinek [Fri, 13 Oct 2023 07:09:32 +0000 (09:09 +0200)] 
libstdc++: Fix tr1/8_c_compatibility/cstdio/functions.cc regression with recent glibc

The following testcase started FAILing recently after the
https://sourceware.org/git/?p=glibc.git;a=commit;h=64b1a44183a3094672ed304532bedb9acc707554
glibc change which marked vfscanf with nonnull (1) attribute.
While vfwscanf hasn't been marked similarly (strangely), the patch changes
that too.  By using va_arg one hides the value of it from the compiler
(volatile keyword would do too, or making the FILE* stream a function
argument, but then it might need to be guarded by #if or something).

2023-10-13  Jakub Jelinek  <jakub@redhat.com>

* testsuite/tr1/8_c_compatibility/cstdio/functions.cc (test01):
Initialize stream to va_arg(ap, FILE*) rather than 0.
* testsuite/tr1/8_c_compatibility/cwchar/functions.cc (test01):
Likewise.

(cherry picked from commit badb798f5e96a995bb9fa8c4ea48071aa4f2b4b3)

20 months agolibgomp: Handle NULL environ like pointer to NULL pointer [PR111413]
Jakub Jelinek [Tue, 19 Sep 2023 07:26:35 +0000 (09:26 +0200)] 
libgomp: Handle NULL environ like pointer to NULL pointer [PR111413]

clearenv function just sets environ to NULL (after sometimes freeing it),
rather than setting it to a pointer to NULL, and our code was assuming
it is always non-NULL.

Fixed thusly, the change seems to be large but actually is just
+  if (environ)
     for (env = environ; *env != 0; env++)
plus reindentation.  I've also noticed the block after this for loop
was badly indented (too much) and fixed that too.

No testcase added, as it needs clearenv + dlopen.

2023-09-19  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/111413
* env.c (initialize_env): Don't dereference environ if it is NULL.
Reindent.

(cherry picked from commit 15345980633c502f0486a2e40e96224f49134130)

20 months agoDaily bump.
GCC Administrator [Tue, 5 Dec 2023 00:20:03 +0000 (00:20 +0000)] 
Daily bump.

20 months agoada: Error compiling reduction expression with overloaded reducer subprogram
Steve Baird [Tue, 14 Nov 2023 20:06:36 +0000 (12:06 -0800)] 
ada: Error compiling reduction expression with overloaded reducer subprogram

In some cases involving a reduction expression with an overloaded reducer
subprogram, the accumulator type is not determined correctly. This can lead
to spurious compile-time errors.

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference): In the case of a
Reduce attribute reference, fix bugs in initializing Accum_Typ.
The previous version was incorrect in the case where E1 refers to
the first of multiple possible overload resolution candidates and
that candidate does not turn out to be the right one. The previous
version also had code to compute Accum_Typ via a different method
if the initial computation turned out to yield a universal numeric
type. Delete that initial computation and use the second method in
all cases.

20 months agoDaily bump.
GCC Administrator [Mon, 4 Dec 2023 00:19:58 +0000 (00:19 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Sun, 3 Dec 2023 00:20:02 +0000 (00:20 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Sat, 2 Dec 2023 00:20:43 +0000 (00:20 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Fri, 1 Dec 2023 00:21:00 +0000 (00:21 +0000)] 
Daily bump.

20 months agoFortran: avoid obsolescence warning for COMMON with submodule [PR111880]
Harald Anlauf [Thu, 23 Nov 2023 21:48:38 +0000 (22:48 +0100)] 
Fortran: avoid obsolescence warning for COMMON with submodule [PR111880]

gcc/fortran/ChangeLog:

PR fortran/111880
* resolve.cc (resolve_common_vars): Do not call gfc_add_in_common
for symbols that are USE associated or used in a submodule.

gcc/testsuite/ChangeLog:

PR fortran/111880
* gfortran.dg/pr111880.f90: New test.

(cherry picked from commit c9d029ba2ceb435e31492c1f3f0fd3edf0e386be)

20 months agoFortran: fix TARGET attribute of associating entity in ASSOCIATE [PR112764]
Harald Anlauf [Wed, 29 Nov 2023 20:47:24 +0000 (21:47 +0100)] 
Fortran: fix TARGET attribute of associating entity in ASSOCIATE [PR112764]

The associating entity in an ASSOCIATE construct has the TARGET attribute
if and only if the selector is a variable and has either the TARGET or
POINTER attribute (e.g. F2018:11.1.3.3).

gcc/fortran/ChangeLog:

PR fortran/112764
* primary.cc (gfc_variable_attr): Set TARGET attribute of associating
entity dependent on TARGET or POINTER attribute of selector.

gcc/testsuite/ChangeLog:

PR fortran/112764
* gfortran.dg/associate_62.f90: New test.

(cherry picked from commit 951a3e3749a9bf15cea3940ad4bd76d696e1b0b6)

20 months ago[PR111497][LRA]: Copy substituted equivalence
Vladimir N. Makarov [Mon, 25 Sep 2023 20:19:50 +0000 (16:19 -0400)] 
[PR111497][LRA]: Copy substituted equivalence

When we substitute the equivalence and it becomes shared, we can fail
to correctly update reg info used by LRA.  This can result in wrong
code generation, e.g. because of incorrect live analysis.  It can also
result in compiler crash as the pseudo survives RA.  This is what
exactly happened for the PR.  This patch solves this problem by
unsharing substituted equivalences.

gcc/ChangeLog:

PR middle-end/111497
* lra-constraints.cc (lra_constraints): Copy substituted
equivalence.
* lra.cc (lra): Change comment for calling unshare_all_rtl_again.

gcc/testsuite/ChangeLog:

PR middle-end/111497
* g++.target/i386/pr111497.C: new test.

(cherry picked from commit 3c23defed384cf17518ad6c817d94463a445d21b)

20 months agoDaily bump.
GCC Administrator [Thu, 30 Nov 2023 00:20:16 +0000 (00:20 +0000)] 
Daily bump.

20 months agomingw: Exclude utf8 manifest [PR111170, PR108865]
Costas Argyris [Mon, 20 Nov 2023 17:58:16 +0000 (17:58 +0000)] 
mingw: Exclude utf8 manifest [PR111170, PR108865]

Make the utf8 manifest optional (on by default and
explicitly off with --disable-win32-utf8-manifest)
in the mingw hosts.

Also eliminate duplication between the 32-bit and
64-bit mingw hosts by putting them both in the
same branch and special-case only the 64-bit long
long setting.

PR mingw/111170
PR mingw/108865

Signed-off-by: Costas Argyris <costas.argyris@gmail.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
gcc/Changelog:

* configure.ac: Handle new --enable-win32-utf8-manifest
option.
* config.host: allow win32 utf8 manifest to be disabled
by user.
* configure: Regenerate.

(cherry picked from commit 4f1ebd54380e16927cd0085be939165870354eac)

20 months agoDaily bump.
GCC Administrator [Wed, 29 Nov 2023 00:20:15 +0000 (00:20 +0000)] 
Daily bump.

20 months agolibstdc++: Check string value_type in std::make_format_args [PR112607]
Jonathan Wakely [Sat, 18 Nov 2023 20:56:35 +0000 (20:56 +0000)] 
libstdc++: Check string value_type in std::make_format_args [PR112607]

libstdc++-v3/ChangeLog:

PR libstdc++/112607
* include/std/format (basic_format_arg::_S_to_arg_type): Check
value_type for basic_string_view and basic_string
specializations.
* testsuite/std/format/arguments/112607.cc: New test.

(cherry picked from commit 279e407a06cc676d8e6e0bb5755b0a804e05377c)

20 months agolibstdc++: Include <stdint.h> in <bits/atomic_wait.h>
Jonathan Wakely [Sun, 26 Nov 2023 21:31:05 +0000 (21:31 +0000)] 
libstdc++: Include <stdint.h> in <bits/atomic_wait.h>

This is needed in order to compile it as a header-unit, which might be
desired because it's included by both <atomic> and <semaphore>.

libstdc++-v3/ChangeLog:

* include/bits/atomic_wait.h: Include <stdint.h>.

(cherry picked from commit 6c8f2d3a08bc013ddb31f7fccd7136751a1460ed)

20 months agolibstdc++: Adjust std::in_range template parameter name
Jonathan Wakely [Fri, 17 Nov 2023 12:18:17 +0000 (12:18 +0000)] 
libstdc++: Adjust std::in_range template parameter name

This is more consistent with the specification in the standard.

libstdc++-v3/ChangeLog:

* include/std/utility (in_range): Rename _Up parameter to _Res.

(cherry picked from commit 97fc8851f60fda381ac3bf6213a1cc93d9fda4f0)

20 months agoDaily bump.
GCC Administrator [Tue, 28 Nov 2023 00:20:17 +0000 (00:20 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Mon, 27 Nov 2023 00:21:35 +0000 (00:21 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Sun, 26 Nov 2023 00:21:48 +0000 (00:21 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Sat, 25 Nov 2023 00:21:20 +0000 (00:21 +0000)] 
Daily bump.

20 months agoc++: constantness of call to function pointer [PR111703]
Patrick Palka [Thu, 16 Nov 2023 14:32:07 +0000 (09:32 -0500)] 
c++: constantness of call to function pointer [PR111703]

potential_constant_expression for CALL_EXPR tests FUNCTION_POINTER_TYPE_P
on the callee rather than on the type of the callee, which means we
always pass want_rval=any when recursing and so may fail to identify a
non-constant function pointer callee as such.  Fixing this turns out to
further work around PR111703.

PR c++/111703
PR c++/107939

gcc/cp/ChangeLog:

* constexpr.cc (potential_constant_expression_1) <case CALL_EXPR>:
Fix FUNCTION_POINTER_TYPE_P test.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-fn8.C: Extend test.
* g++.dg/diagnostic/constexpr4.C: New test.

(cherry picked from commit 0077c0fb19981c108a01cd15af9b2d6d478c183b)

20 months agoc++: constantness of local var in constexpr fn [PR111703, PR112269]
Patrick Palka [Wed, 15 Nov 2023 17:03:16 +0000 (12:03 -0500)] 
c++: constantness of local var in constexpr fn [PR111703, PR112269]

potential_constant_expression was incorrectly treating most local
variables from a constexpr function as constant because it wasn't
considering the 'now' parameter.  This patch fixes this by relaxing
its var_in_maybe_constexpr_fn checks accordingly, which turns out to
partially fix two recently reported regressions:

PR111703 is a regression caused by r11-550-gf65a3299a521a4 for restricting
constexpr evaluation during warning-dependent folding.  The mechanism is
intended to restrict only constant evaluation of the instantiated
non-dependent expression, but it also ends up restricting constant
evaluation occurring during instantiation of the expression, in particular
when instantiating the converted argument 'x' (a VIEW_CONVERT_EXPR) into
a copy constructor call.  This seems like a flaw in the mechanism, though
I don't know if we want to fix the mechanism or get rid of it completely
since the original testcases which motivated the mechanism are fixed more
simply by r13-1225-gb00b95198e6720.  In any case, this patch partially
fixes this by making us correctly treat 'x' as non-constant which prevents
the problematic warning-dependent folding from occurring at all.

PR112269 is caused by r14-4796-g3e3d73ed5e85e7 for merging tsubst_copy
into tsubst_copy_and_build.  tsubst_copy used to exit early when 'args'
was empty, behavior which that commit deliberately didn't preserve.
This early exit masked the fact that COMPLEX_EXPR wasn't handled by
tsubst at all, and is a tree code that apparently we could see during
warning-dependent folding on some targets.  A complete fix is to add
handling for this tree code in tsubst_expr, but this patch should fix
the reported testsuite failures since the COMPLEX_EXPRs that crop up
in <complex> are considered non-constant expressions after this patch.

PR c++/111703
PR c++/112269

gcc/cp/ChangeLog:

* constexpr.cc (potential_constant_expression_1) <case VAR_DECL>:
Only consider var_in_maybe_constexpr_fn if 'now' is false.
<case INDIRECT_REF>: Likewise.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 6665a8572c8f24bd55c6081c91f461442c94dcfb)

20 months agotree-optimization/111465 - bougs jump threading with no-copy src block
Richard Biener [Tue, 19 Sep 2023 10:36:04 +0000 (12:36 +0200)] 
tree-optimization/111465 - bougs jump threading with no-copy src block

The following avoids to forward thread a path with a EDGE_NO_COPY_SRC_BLOCK
block that became non-empty due to folding.

PR tree-optimization/111465
* tree-ssa-threadupdate.cc (fwd_jt_path_registry::thread_block_1):
Cancel the path when a EDGE_NO_COPY_SRC_BLOCK became non-empty.

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

(cherry picked from commit 564ecb7d5afb0bb4eb39285ce65c631490e37dce)

20 months agotree-optimization/111137 - dependence checking for SLP
Richard Biener [Fri, 25 Aug 2023 11:37:30 +0000 (13:37 +0200)] 
tree-optimization/111137 - dependence checking for SLP

The following fixes a mistake with SLP dependence checking.  When
checking whether we can hoist loads to the first load place we
special-case stores of the same instance considering them sunk
to the last store place.  But we fail to consider that stores from
other SLP instances are sunk in a similar way.  This leads us to
miss the dependence between (A) and (B) in

  b[0][1] = 0;             (A)
...
  _6 = b[_5 /* 0 */][0];   (B')
  _7 = _6 ^ 1;
  b[_5 /* 0 */][0] = _7;
  b[0][2] = 0;             (A')
  _10 = b[_5 /* 0 */][1];  (B)
  _11 = _10 ^ 1;
  b[_5 /* 0 */][1] = _11;

where the zeroing stores are sunk to (A') and the loads hoisted
to (B').  The following fixes this, treating grouped stores from
other instances similar to stores from our own instance.  The
difference is - and this is more conservative than necessary - that
we don't know which stores of a group are in which SLP instance
(though I believe either all of the grouped stores will be in
a single SLP instance or in none at the moment), so we don't
know which stores are sunk where.  We simply assume they are
all sunk to the last store we run into.  Likewise we do not take
into account that an SLP instance might be cancelled (or a grouped
store not actually belong to any instance).

PR tree-optimization/111137
* tree-vect-data-refs.cc (vect_slp_analyze_load_dependences):
Properly handle grouped stores from other SLP instances.

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

(cherry picked from commit 845ee9c7107956845e487cb123fa581d9c70ea1b)

20 months agoApply some TLC to vect_slp_analyze_instance_dependence
Richard Biener [Fri, 25 Aug 2023 09:43:36 +0000 (11:43 +0200)] 
Apply some TLC to vect_slp_analyze_instance_dependence

This refactors things, separating load and store handing, adjusting
comments to reflect reality and removing some dead code.

* tree-vect-data-refs.cc (vect_slp_analyze_store_dependences):
Split out from vect_slp_analyze_node_dependences, remove
dead code.
(vect_slp_analyze_load_dependences): Split out from
vect_slp_analyze_node_dependences, adjust comments.  Process
queued stores before any disambiguation.
(vect_slp_analyze_node_dependences): Remove.
(vect_slp_analyze_instance_dependence): Adjust.

(cherry picked from commit 470da3b27e6dbeb3286b09dcb1c1b810ac75b276)

20 months agoDaily bump.
GCC Administrator [Fri, 24 Nov 2023 00:21:24 +0000 (00:21 +0000)] 
Daily bump.

20 months agoi386: Wrong code with __builtin_parityl [PR112672]
Uros Bizjak [Thu, 23 Nov 2023 15:17:57 +0000 (16:17 +0100)] 
i386: Wrong code with __builtin_parityl [PR112672]

gen_parityhi2_cmp instruction clobbers its input operand, so use
a temporary register in the call to gen_parityhi2_cmp.

PR target/112672

gcc/ChangeLog:

* config/i386/i386.md (parityhi2):
Use temporary register in the call to gen_parityhi2_cmp.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit b2d17bdd45b582b93e89c00b04763a45f97d7a34)

20 months agoDaily bump.
GCC Administrator [Thu, 23 Nov 2023 00:22:04 +0000 (00:22 +0000)] 
Daily bump.

20 months agoc++: alias template of non-template class [PR112633]
Patrick Palka [Thu, 23 Nov 2023 00:07:19 +0000 (19:07 -0500)] 
c++: alias template of non-template class [PR112633]

The entering_scope adjustment in tsubst_aggr_type assumes if an alias is
dependent, then so is the aliased type (and therefore it has template info)
but that's not true for the dependent alias template specialization ty1<T>
below which aliases the non-template class A.  In this case no adjustment
is needed anyway, so we can just punt.

PR c++/112633

gcc/cp/ChangeLog:

* pt.cc (tsubst_aggr_type): Handle empty TYPE_TEMPLATE_INFO
in the entering_scope adjustment.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-75.C: New test.

(cherry picked from commit 3f266c84a15d63e42bfad46397fea9aff92b0720)

20 months agoPR target/111815: VAX: Only accept the index scaler as the RHS operand to ASHIFT
Maciej W. Rozycki [Wed, 22 Nov 2023 01:27:02 +0000 (01:27 +0000)] 
PR target/111815: VAX: Only accept the index scaler as the RHS operand to ASHIFT

As from commit 9df1ba9a35b8 ("libbacktrace: support zstd decompression")
GCC for the `vax-netbsdelf' target fails to complete building, with an
ICE:

during RTL pass: final
.../libbacktrace/elf.c: In function 'elf_zstd_decompress':
.../libbacktrace/elf.c:5006:1: internal compiler error: in print_operand_address, at config/vax/vax.cc:514
 5006 | }
      | ^
0x1113df97 print_operand_address(_IO_FILE*, rtx_def*)
.../gcc/config/vax/vax.cc:514
0x10c2489b default_print_operand_address(_IO_FILE*, machine_mode, rtx_def*)
.../gcc/targhooks.cc:373
0x106ddd0b output_address(machine_mode, rtx_def*)
.../gcc/final.cc:3648
0x106ddd0b output_asm_insn(char const*, rtx_def**)
.../gcc/final.cc:3505
0x106e2143 output_asm_insn(char const*, rtx_def**)
.../gcc/final.cc:3421
0x106e2143 final_scan_insn_1
.../gcc/final.cc:2841
0x106e28e3 final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
.../gcc/final.cc:2887
0x106e2bf7 final_1
.../gcc/final.cc:1979
0x106e3c67 rest_of_handle_final
.../gcc/final.cc:4240
0x106e3c67 execute
.../gcc/final.cc:4318
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

This is due to combine producing an invalid address RTX:

(plus:SI (ashift:SI (const_int 1 [0x1])
        (reg:QI 3 %r3 [1232]))
    (reg/v:SI 10 %r10 [orig:736 weight_mask ] [736]))

where the expression is ((1 << R3) + R10), which does not match a valid
machine addressing mode.  Consequently `print_operand_address' chokes.

This can be reduced to the testcase included, where it triggers the same
ICE in `p'.  Preincrements are required so that their results land in
registers and consequently an indexed addressing mode is tried or
otherwise doing operations piecemeal on stack-based function arguments
as direct input operands turns out more profitable in terms of RTX costs
and the ICE is avoided.

The ultimate cause has been commit c605a8bf9270 ("VAX: Accept ASHIFT in
address expressions"), where a shift of an immediate value by a register
has been mistakenly allowed as an index expression as if the shift
operation was commutative such as multiplication is.  So with ASHIFT the
scaler in an index expression has to be the right-hand operand, and the
backend has to enforce that, whereas with MULT the scaler can be either
operand.

Fix this by only accepting the index scaler as the RHS operand to
ASHIFT.

gcc/
PR target/111815
* config/vax/vax.cc (index_term_p): Only accept the index scaler
as the RHS operand to ASHIFT.

gcc/testsuite/
PR target/111815
* gcc.dg/torture/pr111815.c: New test.

(cherry picked from commit 56ff988e6be3fdba70cad86d73ec0038bc3b6b5a)

20 months agoDaily bump.
GCC Administrator [Wed, 22 Nov 2023 00:21:36 +0000 (00:21 +0000)] 
Daily bump.

20 months agoBump LTO_minor_version
Martin Jambor [Tue, 21 Nov 2023 12:41:56 +0000 (13:41 +0100)] 
Bump LTO_minor_version

I believe r13-8039-g06ee3438a4fcf9 has changed LTO format and
therefore we should bump the minor version of the GCC 13 LTO format.

gcc/ChangeLog:

2023-11-20  Martin Jambor  <mjambor@suse.cz>

* lto-streamer.h (LTO_minor_version): Bump.

20 months agoDaily bump.
GCC Administrator [Tue, 21 Nov 2023 00:22:21 +0000 (00:22 +0000)] 
Daily bump.

20 months agoLoongArch: Modify MUSL_DYNAMIC_LINKER.
Lulu Cheng [Sat, 18 Nov 2023 03:04:42 +0000 (11:04 +0800)] 
LoongArch: Modify MUSL_DYNAMIC_LINKER.

Use no suffix at all in the musl dynamic linker name for hard
float ABI. Use -sf and -sp suffixes in musl dynamic linker name
for soft float and single precision ABIs. The following table
outlines the musl interpreter names for the LoongArch64 ABI names.

musl interpreter            | LoongArch64 ABI
--------------------------- | -----------------
ld-musl-loongarch64.so.1    | loongarch64-lp64d
ld-musl-loongarch64-sp.so.1 | loongarch64-lp64f
ld-musl-loongarch64-sf.so.1 | loongarch64-lp64s

gcc/ChangeLog:

* config/loongarch/gnu-user.h (MUSL_ABI_SPEC): Modify suffix.

(cherry picked from commit 8bccee51f0deac64b79cd9ad75df599422f4c8ff)

20 months agoLoongArch: Fix MUSL_DYNAMIC_LINKER
Peng Fan [Wed, 19 Apr 2023 08:23:42 +0000 (16:23 +0800)] 
LoongArch: Fix MUSL_DYNAMIC_LINKER

The system based on musl has no '/lib64', so change it.

https://wiki.musl-libc.org/guidelines-for-distributions.html,
"Multilib/multi-arch" section of this introduces it.

gcc/
* config/loongarch/gnu-user.h (MUSL_DYNAMIC_LINKER): Redefine.

Signed-off-by: Peng Fan <fanpeng@loongson.cn>
Suggested-by: Xi Ruoyao <xry111@xry111.site>
(cherry picked from commit a80c68a08604b0ac625ac7fc59eae40b551b1176)

20 months agoDaily bump.
GCC Administrator [Mon, 20 Nov 2023 00:20:40 +0000 (00:20 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Sun, 19 Nov 2023 00:21:26 +0000 (00:21 +0000)] 
Daily bump.

20 months agoDaily bump.
GCC Administrator [Sat, 18 Nov 2023 00:21:20 +0000 (00:21 +0000)] 
Daily bump.

20 months agoPR target/53372: Don't ignore section attribute with address-space.
Georg-Johann Lay [Fri, 17 Nov 2023 11:51:16 +0000 (12:51 +0100)] 
PR target/53372: Don't ignore section attribute with address-space.

gcc/
PR target/53372
* config/avr/avr.cc (avr_asm_named_section) [AVR_SECTION_PROGMEM]:
Only return some .progmem*.data section if the user did not
specify a section attribute.
(avr_section_type_flags) [avr_progmem_p]: Unset SECTION_NOTYPE
in returned section flags.

gcc/testsuite/
PR target/53372
* gcc.target/avr/pr53372-1.c: New test.
* gcc.target/avr/pr53372-2.c: New test.

(cherry picked from commit 68221c54a9752dbf131c231413edfd21046f8dad)

20 months agoc++: retval dtor on rethrow [PR112301]
Jason Merrill [Mon, 30 Oct 2023 21:44:54 +0000 (17:44 -0400)] 
c++: retval dtor on rethrow [PR112301]

In r12-6333 for PR33799, I fixed the example in [except.ctor]/2.  In that
testcase, the exception is caught and the function returns again,
successfully.

In this testcase, however, the exception is rethrown, and hits two separate
cleanups: one in the try block and the other in the function body.  So we
destroy twice an object that was only constructed once.

Fortunately, the fix for the normal case is easy: we just need to clear the
"return value constructed by return" flag when we do it the first time.

This gets more complicated with the named return value optimization, since
we don't want to destroy the return value while the NRV variable is still in
scope.

PR c++/112301
PR c++/102191
PR c++/33799

gcc/cp/ChangeLog:

* except.cc (maybe_splice_retval_cleanup): Clear
current_retval_sentinel when destroying retval.
* semantics.cc (nrv_data): Add in_nrv_cleanup.
(finalize_nrv): Set it.
(finalize_nrv_r): Fix handling of throwing cleanups.

gcc/testsuite/ChangeLog:

* g++.dg/eh/return1.C: Add more cases.

20 months agoc++: fix contracts with NRV
Jason Merrill [Tue, 6 Jun 2023 03:58:32 +0000 (23:58 -0400)] 
c++: fix contracts with NRV

The NRV implementation was blindly replacing the operand of RETURN_EXPR,
clobbering anything that check_return_expr might have added on to the actual
initialization, such as checking the postcondition.

gcc/cp/ChangeLog:

* semantics.cc (finalize_nrv_r): [RETURN_EXPR]: Only replace the
INIT_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/contracts-post7.C: New test.

20 months agoc++: fix throwing cleanup with label
Jason Merrill [Tue, 6 Jun 2023 19:31:23 +0000 (15:31 -0400)] 
c++: fix throwing cleanup with label

While looking at PR92407 I noticed that the expectations of
maybe_splice_retval_cleanup weren't being met; an sk_cleanup level was
confusing its attempt to recognize the outer block of the function.  And
even if I fixed the detection, it failed to actually wrap the body of the
function because the STATEMENT_LIST it got only had the label, not anything
after it.  So I moved the call after poplevel does pop_stmt_list on all the
sk_cleanup levels.

PR c++/33799

gcc/cp/ChangeLog:

* except.cc (maybe_splice_retval_cleanup): Change
recognition of function body and try scopes.
* semantics.cc (do_poplevel): Call it after poplevel.
(at_try_scope): New.
* cp-tree.h (maybe_splice_retval_cleanup): Adjust.

gcc/testsuite/ChangeLog:

* g++.dg/eh/return1.C: Add label cases.

20 months agoFix warning on new Ada testcase
Eric Botcazou [Thu, 16 Nov 2023 21:41:53 +0000 (22:41 +0100)] 
Fix warning on new Ada testcase

gcc/testsuite/
* gnat.dg/varsize4.adb (Func): Initialize Byte_Read parameter.

20 months agoFix internal error on function returning dynamically-sized type
Eric Botcazou [Thu, 16 Nov 2023 17:36:44 +0000 (18:36 +0100)] 
Fix internal error on function returning dynamically-sized type

This is a tree sharing issue for the internal return type synthesized for
a function returning a dynamically-sized type and taking an Out or In/Out
parameter passed by copy.

gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Also create a
TYPE_DECL for the return type built for the CI/CO mechanism.

gcc/testsuite/
* gnat.dg/varsize4.ads, gnat.dg/varsize4.adb: New test.
* gnat.dg/varsize4_pkg.ads: New helper.

20 months agoLoongArch: Remove redundant barrier instructions before LL-SC loops
Xi Ruoyao [Mon, 6 Nov 2023 08:06:08 +0000 (16:06 +0800)] 
LoongArch: Remove redundant barrier instructions before LL-SC loops

This is isomorphic to the LLVM changes [1-2].

On LoongArch, the LL and SC instructions has memory barrier semantics:

- LL: <memory-barrier> + <load-exclusive>
- SC: <store-conditional> + <memory-barrier>

But the compare and swap operation is allowed to fail, and if it fails
the SC instruction is not executed, thus the guarantee of acquiring
semantics cannot be ensured. Therefore, an acquire barrier needs to be
generated when failure_memorder includes an acquire operation.

On CPUs implementing LoongArch v1.10 or later, "dbar 0b10100" is an
acquire barrier; on CPUs implementing LoongArch v1.00, it is a full
barrier.  So it's always enough for acquire semantics.  OTOH if an
acquire semantic is not needed, we still needs the "dbar 0x700" as the
load-load barrier like all LL-SC loops.

[1]:https://github.com/llvm/llvm-project/pull/67391
[2]:https://github.com/llvm/llvm-project/pull/69339

Backported for fixing the acquire semantic issue which is known to
cause troubles on LA664.

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_memmodel_needs_release_fence): Remove.
(loongarch_cas_failure_memorder_needs_acquire): New static
function.
(loongarch_print_operand): Redefine 'G' for the barrier on CAS
failure.
* config/loongarch/sync.md (atomic_cas_value_strong<mode>):
Remove the redundant barrier before the LL instruction, and
emit an acquire barrier on failure if needed by
failure_memorder.
(atomic_cas_value_cmp_and_7_<mode>): Likewise.
(atomic_cas_value_add_7_<mode>): Remove the unnecessary barrier
before the LL instruction.
(atomic_cas_value_sub_7_<mode>): Likewise.
(atomic_cas_value_and_7_<mode>): Likewise.
(atomic_cas_value_xor_7_<mode>): Likewise.
(atomic_cas_value_or_7_<mode>): Likewise.
(atomic_cas_value_nand_7_<mode>): Likewise.
(atomic_cas_value_exchange_7_<mode>): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/cas-acquire.c: New test.

(cherry picked from commit 4d86dc51e34d2a5695b617afeb56e3414836a79a)

20 months agoDaily bump.
GCC Administrator [Thu, 16 Nov 2023 00:21:25 +0000 (00:21 +0000)] 
Daily bump.

20 months agolibstdc++: Fix std::deque::operator[] Xmethod [PR112491]
Jonathan Wakely [Tue, 14 Nov 2023 15:08:13 +0000 (15:08 +0000)] 
libstdc++: Fix std::deque::operator[] Xmethod [PR112491]

The Xmethod for std::deque::operator[] has the same bug that I recently
fixed for the std::deque::size() Xmethod. The first node might have
unused capacity at the start, which needs to be accounted for when
indexing into the deque.

libstdc++-v3/ChangeLog:

PR libstdc++/112491
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.index):
Correctly handle unused capacity at the start of the first node.
* testsuite/libstdc++-xmethods/deque.cc: Check index operator
when elements have been removed from the front.

(cherry picked from commit 452476db0c705caeac8712d560fc16ced0ca5226)

20 months agolibstdc++: std::stacktrace tweaks
Jonathan Wakely [Wed, 15 Nov 2023 09:17:49 +0000 (09:17 +0000)] 
libstdc++: std::stacktrace tweaks

Fix a typo in a string literal and make the new hash.cc test gracefully
handle missing stacktrace data (see PR 112541).

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::at): Fix class name
in exception message.
* testsuite/19_diagnostics/stacktrace/hash.cc: Do not fail if
current() returns a non-empty stacktrace.

(cherry picked from commit cbd0fe22a5ced9751d2450dc4fd6fe3525c2fc02)

20 months agors6000: Consider inline asm as safe if no assembler complains [PR111828]
Kewen Lin [Mon, 6 Nov 2023 06:14:43 +0000 (00:14 -0600)] 
rs6000: Consider inline asm as safe if no assembler complains [PR111828]

As discussed in PR111828, rs6000_update_ipa_fn_target_info
is much conservative, currently for any non-empty inline
asm, without any parsing, it would take inline asm could
have HTM insns.  It means for one function attributed with
power8 having inline asm, even if it has no HTM insns, we
don't make a function attributed with power10 inline it.

Peter pointed out an inline asm parser can be a slippery
slope, and noticed that the current gnu assembler still
allows HTM insns even with power10 machine type, so he
suggested that we can aggressively ignore the handling on
inline asm, this patch goes for this suggestion.

Considering that there are a few assembler alternatives
and assembler can update its behaviors (complaining HTM
insns at power10 and later cpus sounds reasonable from a
certain point of view), this patch also checks assembler
complains on HTM insns at power10 or not.  For a case that
a caller attributed power10 calls a callee attributed
power8 having inline asm with HTM insn, without inlining
at least the compilation succeeds, but if assembler
complains HTM insns at power10, after inlining the
compilation would fail.

The two associated test cases are fine without and with
this patch (effective target takes effect or not).

PR target/111828

gcc/ChangeLog:

* config.in: Regenerate.
* config/rs6000/rs6000.cc (rs6000_update_ipa_fn_target_info): Guard
inline asm handling under !HAVE_AS_POWER10_HTM.
* configure: Regenerate.
* configure.ac: Detect assembler support for HTM insns at power10.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_powerpc_as_p10_htm): New proc.
* g++.target/powerpc/pr111828-1.C: New test.
* g++.target/powerpc/pr111828-2.C: New test.

(cherry picked from commit b2075291af8810794c7184fd125b991c2341cb1e)

20 months agoDaily bump.
GCC Administrator [Wed, 15 Nov 2023 00:20:17 +0000 (00:20 +0000)] 
Daily bump.

20 months agoFix ICE in vectorizable_nonlinear_induction with bitfield.
liuhongt [Mon, 13 Nov 2023 09:56:49 +0000 (17:56 +0800)] 
Fix ICE in vectorizable_nonlinear_induction with bitfield.

 if (TREE_CODE (init_expr) == INTEGER_CST)
    init_expr = fold_convert (TREE_TYPE (vectype), init_expr);
  else
    gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype),
                                       TREE_TYPE (init_expr)));

and init_expr is a 24 bit integer type while vectype has 32bit components.

The "fix" is to bail out instead of asserting.

gcc/ChangeLog:

PR tree-optimization/112496
* tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
false when !tree_nop_conversion_p (TREE_TYPE (vectype),
TREE_TYPE (init_expr)).

gcc/testsuite/ChangeLog:

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

(cherry picked from commit f28306b4fd309b579c8a4a5bf2f1b24fa40f8f7f)

20 months agolibstdc++: Fix std::hash<std::stacktrace> [PR112348]
Jonathan Wakely [Tue, 14 Nov 2023 22:36:31 +0000 (22:36 +0000)] 
libstdc++: Fix std::hash<std::stacktrace> [PR112348]

libstdc++-v3/ChangeLog:

PR libstdc++/112348
* include/std/stacktrace (hash<basic_stacktrace<Alloc>>): Fix
type of hash function for entries.
* testsuite/19_diagnostics/stacktrace/hash.cc: New test.

(cherry picked from commit 6f2fc42d9e52e8322e718e0154cd235d00906f99)

20 months agolibstdc++: Fix std::deque::size() Xmethod [PR112491]
Jonathan Wakely [Tue, 14 Nov 2023 15:08:13 +0000 (15:08 +0000)] 
libstdc++: Fix std::deque::size() Xmethod [PR112491]

The Xmethod for std::deque::size() assumed that the first element would
be at the start of the first node. That's only true if elements are only
added at the back. If an element is inserted at the front, or removed
from the front (or anywhere before the middle) then the first node will
not be completely populated, and the Xmethod will give the wrong result.

libstdc++-v3/ChangeLog:

PR libstdc++/112491
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.size): Fix
calculation to use _M_start._M_cur.
* testsuite/libstdc++-xmethods/deque.cc: Check failing cases.

(cherry picked from commit 4db820928065eccbeb725406450d826186582b9f)

20 months agolibstdc++: Add dg-timeout-factor to remaining <chrono> IO tests
Jonathan Wakely [Mon, 13 Nov 2023 10:50:39 +0000 (10:50 +0000)] 
libstdc++: Add dg-timeout-factor to remaining <chrono> IO tests

I meant to add these changes as part of r14-4959-g7d06b29f814580 but
missed these files out.

libstdc++-v3/ChangeLog:

* testsuite/std/time/clock/file/io.cc: Double timeout using
dg-timeout-factor.
* testsuite/std/time/clock/gps/io.cc: Likewise.
* testsuite/std/time/clock/system/io.cc: Likewise.
* testsuite/std/time/clock/tai/io.cc: Likewise.
* testsuite/std/time/clock/utc/io.cc: Likewise.

(cherry picked from commit c28b0326ce040cf8c9ce0b008cc7a920ae4b7db7)

20 months agors6000: Don't allow AltiVec address in movoo & movxo pattern [PR110411]
Jeevitha [Thu, 31 Aug 2023 10:40:18 +0000 (05:40 -0500)] 
rs6000: Don't allow AltiVec address in movoo & movxo pattern [PR110411]

There are no instructions that do traditional AltiVec addresses (i.e.
with the low four bits of the address masked off) for OOmode and XOmode
objects. The solution is to modify the constraints used in the movoo and
movxo pattern to disallow these types of addresses, which assists LRA in
resolving this issue. Furthermore, the mode size 16 check has been
removed in vsx_quad_dform_memory_operand to allow OOmode and XOmode, and
quad_address_p already handles less than size 16.

2023-08-31  Jeevitha Palanisamy  <jeevitha@linux.ibm.com>

gcc/
PR target/110411
* config/rs6000/mma.md (define_insn_and_split movoo): Disallow
AltiVec address operands.
(define_insn_and_split movxo): Likewise.
* config/rs6000/predicates.md (vsx_quad_dform_memory_operand): Remove
redundant mode size check.

gcc/testsuite/
PR target/110411
* gcc.target/powerpc/pr110411-1.c: New testcase.
* gcc.target/powerpc/pr110411-2.c: New testcase.

(cherry picked from commit 9ea1248604d7b65009af32103814332f35bd33e2)

20 months agoDaily bump.
GCC Administrator [Tue, 14 Nov 2023 12:27:11 +0000 (12:27 +0000)] 
Daily bump.

20 months agoLibF7: sinh: Fix loss of precision due to cancellation for small values.
Georg-Johann Lay [Tue, 14 Nov 2023 11:05:19 +0000 (12:05 +0100)] 
LibF7: sinh: Fix loss of precision due to cancellation for small values.

libgcc/config/avr/libf7/
* libf7-const.def [F7MOD_sinh_]: Add MiniMax polynomial.
* libf7.c (f7_sinh): Use it instead of (exp(x) - exp(-x)) / 2
when |x| < 0.5 to avoid loss of precision due to cancellation.

20 months agolibstdc++: Correctly call _string_types function
Tom Tromey [Wed, 4 Oct 2023 14:59:47 +0000 (08:59 -0600)] 
libstdc++: Correctly call _string_types function

flake8 points out that the new call to _string_types from
StdExpAnyPrinter.__init__ is not correct -- it needs to be qualified.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py
(StdExpAnyPrinter.__init__): Qualify call to
_string_types.

(cherry picked from commit 4bf77db70e2521dc89f9d7f51c7ae6e58a94b4f9)

20 months agolibstdc++: _versioned_namespace is always non-None
Tom Tromey [Tue, 3 Oct 2023 17:14:45 +0000 (11:14 -0600)] 
libstdc++: _versioned_namespace is always non-None

Some code in the pretty-printers seems to assume that the
_versioned_namespace global might be None (or the empty string).
However, doesn't occur, as the variable is never reassigned.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Assume that
_versioned_namespace is non-None.
* python/libstdcxx/v6/xmethods.py (is_specialization_of):
Assume that _versioned_namespace is non-None.

(cherry picked from commit d342c9de6a1534cbce324bcc3c7c0898ff74d386)

20 months agolibstdc++: Define _versioned_namespace in xmethods.py
Tom Tromey [Tue, 3 Oct 2023 17:08:02 +0000 (11:08 -0600)] 
libstdc++: Define _versioned_namespace in xmethods.py

flake8 pointed out that is_specialization_of in xmethods.py looks at a
global that wasn't added to the file.  This patch correct the
oversight.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/xmethods.py (_versioned_namespace):
Define.

(cherry picked from commit 83ec6e80ff0d56342fc066c2ef649036c0983529)

20 months agolibstdc++: Use Python "not in" operator
Tom Tromey [Wed, 27 Sep 2023 15:26:01 +0000 (09:26 -0600)] 
libstdc++: Use Python "not in" operator

flake8 warns about code like

    not something in "whatever"

Ordinarily in Python this should be written as:

    something not in "whatever"

This patch makes this change.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (Printer.add_version)
(add_one_template_type_printer)
(FilteringTypePrinter.add_one_type_printer): Use Python
"not in" operator.

(cherry picked from commit 202810947ca793b17653658e584008fb151e0937)

20 months agolibstdc++: Remove std_ratio_t_tuple
Tom Tromey [Tue, 26 Sep 2023 20:04:26 +0000 (14:04 -0600)] 
libstdc++: Remove std_ratio_t_tuple

This removes the std_ratio_t_tuple function from the Python
pretty-printer code.  It is not used.  Apparently the relevant parts
were moved to StdChronoDurationPrinter._ratio at some point in the
past.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (std_ratio_t_tuple):
Remove.

(cherry picked from commit 860b284e3eea49e5bd49e6fe07c66e53faebb893)

20 months agolibstdc++: Remove unused locals from printers.py
Tom Tromey [Tue, 26 Sep 2023 19:58:57 +0000 (13:58 -0600)] 
libstdc++: Remove unused locals from printers.py

flake8 pointed out some unused local variables in the libstdc++
pretty-printers.  This removes them.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py
(StdExpOptionalPrinter.__init__, lookup_node_type):
Remove unused variables.

(cherry picked from commit 33841921a2b1153e6d79f0b4a5870f12aa2e86a1)

20 months agolibstdc++: Remove unused Python imports
Tom Tromey [Tue, 26 Sep 2023 19:46:57 +0000 (13:46 -0600)] 
libstdc++: Remove unused Python imports

flake8 pointed out some unused imports.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Don't import 'os'.
* python/libstdcxx/v6/__init__.py: Don't import 'gdb'.

(cherry picked from commit bed1f8498a1ba0c5ffdb09fd9bd0c080d9bdfe8c)

20 months agolibstdc++: Use gdb.ValuePrinter base class
Tom Tromey [Tue, 26 Sep 2023 19:38:42 +0000 (13:38 -0600)] 
libstdc++: Use gdb.ValuePrinter base class

GDB 14 will add a new ValuePrinter tag class that will be used to
signal that pretty-printers will agree to the "extension protocol" --
essentially that they will follow some simple namespace rules, so that
GDB can add new methods over time.

A couple new methods have already been added to GDB, to support DAP.
While I haven't implemented these for any libstdc++ printers yet, this
patch makes the basic conversion: printers derive from
gdb.ValuePrinter if it is available, and all "non-standard" (that is,
not specified by GDB) members of the various value-printing classes
are renamed to have a leading underscore.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Use gdb.ValuePrinter
everywhere.  Rename members to start with "_".

(cherry picked from commit 64f121030135b421d6ec16bf619cb14c50443aff)

20 months agolibstdc++: Refactor Python Xmethods to use is_specialization_of
Jonathan Wakely [Thu, 28 Sep 2023 19:52:01 +0000 (20:52 +0100)] 
libstdc++: Refactor Python Xmethods to use is_specialization_of

This copies the is_specialization_of function from printers.py (with
slight modification for versioned namespace handling) and reuses it in
xmethods.py to replace repetitive re.match calls in every class.

This fixes the problem that the regular expressions used \d without
escaping the backslash properly.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/xmethods.py (is_specialization_of): Define
new function.
(ArrayMethodsMatcher, DequeMethodsMatcher)
(ForwardListMethodsMatcher, ListMethodsMatcher)
(VectorMethodsMatcher, AssociativeContainerMethodsMatcher)
(UniquePtrGetWorker, UniquePtrMethodsMatcher)
(SharedPtrSubscriptWorker, SharedPtrMethodsMatcher): Use
is_specialization_of instead of re.match.

(cherry picked from commit 17d3477fa89466604bee5af2a2caf8de5441aeb5)

20 months agolibstdc++: Reformat Python code
Jonathan Wakely [Thu, 28 Sep 2023 13:54:59 +0000 (14:54 +0100)] 
libstdc++: Reformat Python code

Some of these changes were suggested by autopep8's --aggressive
option, others are for readability.

Break long lines by splitting strings across multiple lines, or
introducing local variables to hold results.

Use raw strings for regular expressions, so that backslashes don't need
to be escaped.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py: Break long lines. Use raw
strings for regular expressions. Add whitespace around
operators.
(is_member_of_namespace): Use isinstance to check type.
(is_specialization_of): Likewise. Adjust template_name
for versioned namespace instead of duplicating the re.match
call.
(StdExpAnyPrinter._string_types): New static method.
(StdExpAnyPrinter.to_string): Use _string_types.

(cherry picked from commit 6b5c3f9b8139d9eee358b354b35da0b757a0270d)