aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-08-24c++, coroutines: Look through initial_await target exprs [PR110635].Iain Sandoe2-1/+79
In the case that the initial awaiter returns an object, the initial await can be a target expression and we need to look at its initializer to cast the await_resume() to void and to wrap in a compound expression that sets the initial_await_resume_called flag. PR c++/110635 gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::wrap_original_function_body): Look through initial await target expressions to find the actual co_await_expr that we need to update. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr110635.C: New test. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++, coroutines: Rework handling of throwing_cleanups [PR102051].Iain Sandoe2-11/+21
In the fix for PR95822 (r11-7402) we set throwing_cleanup false in the top level of the coroutine transform code. However, as the current PR shows, that is not sufficient. Any use of cxx_maybe_build_cleanup() can reset the flag, which causes the check_return_expr () logic to try to add a guard variable and set it. For the coroutine code, we need to handle the cleanups separately, since the responsibility for them changes after the first resume point, which we handle in the ramp exception processing. Fix this by forcing the "throwing_cleanup" flag false right before the processing of the return expression. PR c++/102051 gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::build_ramp_function): Handle "throwing_cleanup" here instead of ... (cp_coroutine_transform::apply_transforms): ... here. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr102051.C: New test. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++, coroutines: Fix ordering of return object conversions [PR115908].Iain Sandoe2-107/+129
[dcl.fct.def.coroutine]/7 says: The expression promise.get_return_object() is used to initialize the returned reference or prvalue result object of a call to a coroutine. The call to get_return_object is sequenced before the call to initial_suspend and is invoked at most once. The issue is about when any conversions are carried out if the type of the g_r_o call is not the same as the ramp return. Currently, we have been doing this by materialising the g_r_o return value and passing that to finish_return_expr() which handles the necessary conversions and checks. As the PR shows, this does not work as expected. In the revised version we carry out the work of the conversions when intialising the return slot (with the same facilities that are used by finish_return_expr()). We do this before the call that initiates the coroutine body, satisfying the requirements for one call before initial suspend. The return expression becomes a trivial 'return <retval>'. This simplifies the ramp logic considerably, since we no longer need to keep track of the temporarily-materialised g_r_o value. PR c++/115908 gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::build_ramp_function): Rework the return value initialisation to initialise the return slot always from get_return_object, even if that implies carrying out conversions to do so. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr115908.C: New test. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++, coroutines: Allow convertible get_return_on_allocation_fail [PR109682].Iain Sandoe2-13/+34
We have been requiring the get_return_on_allocation_fail() call to have the same type as the ramp. This is not intended by the standard, so relax that to allow anything convertible to the ramp return. PR c++/109682 gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::build_ramp_function): Allow for cases where get_return_on_allocation_fail has a type convertible to the ramp return type. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr109682.C: New test. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++, coroutines: Only allow void get_return_object if the ramp is void ↵Iain Sandoe7-49/+48
[PR100476]. Require that the value returned by get_return_object is convertible to the ramp return. This means that the only time we allow a void get_return_object, is when the ramp is also a void function. We diagnose this early to allow us to exit the ramp build if the return values are incompatible. PR c++/100476 gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::build_ramp_function): Remove special handling of void get_return_object expressions. gcc/testsuite/ChangeLog: * g++.dg/coroutines/coro-bad-gro-01-void-gro-non-class-coro.C: Adjust expected diagnostic. * g++.dg/coroutines/pr102489.C: Avoid void get_return_object. * g++.dg/coroutines/pr103868.C: Likewise. * g++.dg/coroutines/pr94879-folly-1.C: Likewise. * g++.dg/coroutines/pr94883-folly-2.C: Likewise. * g++.dg/coroutines/pr96749-2.C: Likewise. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++, coroutines: Fix handling of early exceptions [PR113773].Iain Sandoe2-13/+92
The responsibility for destroying part of the frame content (promise, arg copies and the frame itself) transitions from the ramp to the body of the coroutine once we reach the await_resume () for the initial suspend. We added the variable that flags the transition, but failed to act on it. This corrects that so that the ramp only tries to run DTORs for objects when an exception occurs before the initial suspend await resume has started. PR c++/113773 gcc/cp/ChangeLog: * coroutines.cc (cp_coroutine_transform::build_ramp_function): Only cleanup the frame state on exceptions that occur before the initial await resume has begun. gcc/testsuite/ChangeLog: * g++.dg/coroutines/torture/pr113773.C: New test. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++, coroutines: Separate allocator work from the ramp body build.Iain Sandoe9-235/+280
This splits out the building of the allocation and deallocation expressions and runs them early in the ramp build, so that we can exit if they are not usable, before we start building the ramp body. Likewise move checks for other required resources to the begining of the ramp builder. This is preparation for work needed to update the allocation/destruction in cases where we have excess alignment of the promise or other saved frame state. gcc/cp/ChangeLog: * call.cc (build_op_delete_call_1): Renamed and added a param to allow the caller to prioritize two argument usual deleters. (build_op_delete_call): New. (build_coroutine_op_delete_call): New. * coroutines.cc (coro_get_frame_dtor): Rename... (build_coroutine_frame_delete_expr):... to this; simplify to use build_op_delete_call for all cases. (build_actor_fn): Use revised frame delete function. (build_coroutine_frame_alloc_expr): New. (cp_coroutine_transform::complete_ramp_function): Rename... (cp_coroutine_transform::build_ramp_function): ... to this. Reorder code to carry out checks for prerequisites before the codegen. Split out the allocation/delete code. (cp_coroutine_transform::apply_transforms): Use revised name. * coroutines.h: Rename function. * cp-tree.h (build_coroutine_op_delete_call): New. gcc/testsuite/ChangeLog: * g++.dg/coroutines/coro-bad-alloc-01-bad-op-del.C: Use revised diagnostics. * g++.dg/coroutines/coro-bad-gro-00-class-gro-scalar-return.C: Likewise. * g++.dg/coroutines/coro-bad-gro-01-void-gro-non-class-coro.C: Likewise. * g++.dg/coroutines/coro-bad-grooaf-00-static.C: Likewise. * g++.dg/coroutines/ramp-return-b.C: Likewise. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++, coroutines: Separate the analysis, ramp and outlined function synthesis.Iain Sandoe4-414/+446
This change is preparation for fixes to the ramp and codegen to follow. The primary motivation is that we have thee activities; analysis, ramp synthesis and outlined coroutine body synthesis. These are currently carried out in sequence in the 'morph_fn_to_coro' code, which means that we are nesting the synthesis of the outlined coroutine body inside the finish_function call for the original function (which becomes the ramp). The revised code splits the three interests so that the analysis can be used independently by the ramp and body synthesis. This avoids some issues seen with global state that start/finish function use and allows us to use more of the high-level APIs in fixing bugs. The resultant implementation is more self-contained, and has less impact on finish_function. gcc/cp/ChangeLog: * coroutines.cc (struct suspend_point_info, struct param_info, struct local_var_info, struct susp_frame_data, struct local_vars_frame_data): Move to coroutines.h. (build_actor_fn): Use start/finish function APIs. (build_destroy_fn): Likewise. (coro_build_actor_or_destroy_function): No longer mark the actor / destroyer as DECL_COROUTINE_P. (coro_rewrite_function_body): Use class members. (cp_coroutine_transform::wrap_original_function_body): Likewise. (build_ramp_function): Replace by... (cp_coroutine_transform::complete_ramp_function): ...this. (cp_coroutine_transform::cp_coroutine_transform): New. (cp_coroutine_transform::~cp_coroutine_transform): New (morph_fn_to_coro): Replace by... (cp_coroutine_transform::apply_transforms): ...this. (cp_coroutine_transform::finish_transforms): New. * cp-tree.h (morph_fn_to_coro): Remove. * decl.cc (emit_coro_helper): Remove. (finish_function): Revise handling of coroutine transforms. * coroutines.h: New file. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> Co-authored-by: Arsen Arsenović <arsen@aarsen.me>
2024-08-24c++, coroutines: Split the ramp build into a separate function.Iain Sandoe1-183/+201
This is primarily preparation to partition the functionality of the coroutine transform into analysis, ramp generation and then (later) synthesis of the coroutine body. The patch does fix one latent issue in the ordering of DTORs for frame parameter copies (to ensure that they are processed in reverse order to the copy creation). gcc/cp/ChangeLog: * coroutines.cc (build_actor_fn): Arrange to apply any required parameter copy DTORs in reverse order to their creation. (coro_rewrite_function_body): Handle revised param uses. (morph_fn_to_coro): Split the ramp function completion into a separate function. (build_ramp_function): New. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++, coroutines: Tidy up awaiter variable checks.Iain Sandoe1-48/+11
When we build an await expression, we might need to materialise the awaiter if it is a prvalue. This re-implements this using core APIs instead of local code. gcc/cp/ChangeLog: * coroutines.cc (build_co_await): Simplify checks for the cases that we need to materialise an awaiter. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-24c++: Add testcase for (now fixed) regression [PR113746]Simon Martin1-0/+6
The case in PR113746 used to ICE until commit r15-123-gf04dc89a991ddc. This patch simply adds the case to the testsuite. PR c++/113746 gcc/testsuite/ChangeLog: * g++.dg/parse/crash76.C: New test.
2024-08-24testsuite: Add dg-require-effective-target scheduling for some tests that ↵Georg-Johann Lay2-0/+2
set -fschedule-insns. gcc/testsuite/ * gcc.dg/torture/pr115929-2.c: Add dg-require-effective-target scheduling. * gcc.dg/torture/pr116343.c: Same.
2024-08-24Daily bump.GCC Administrator8-1/+487
2024-08-23libstdc++: Update and clarify Doxygen version requirements in manualJonathan Wakely6-10/+11
There are lots of bugs that affect libstdc++ output from Doxygen, so using 1.9.6 or later is recommended. Give a lower minimum, because some distros still use 1.9.1 and that will work, albeit suboptimally. libstdc++-v3/ChangeLog: * doc/xml/manual/documentation_hacking.xml: Update minimum Doxygen version. * doc/html/*: Regenerate.
2024-08-23libstdc++: Hide std::tuple internals from Doxygen docsJonathan Wakely1-0/+2
libstdc++-v3/ChangeLog: * include/std/tuple: Do not include implementation details in Doxygen documentation.
2024-08-23libstdc++: Improve Doxygen docs for std::allocator_traits specializationsJonathan Wakely2-4/+21
The main fix here is to use @header so that the docs show the correct header file instead of an internal header like alloc_traits.h. libstdc++-v3/ChangeLog: * include/bits/alloc_traits.h: Improve doxygen docs for allocator_traits specializations. * include/bits/memory_resource.h: Likewise.
2024-08-23RISC-V: Use encoded nelts when calling repeating_sequence_pPatrick O'Neill1-7/+3
repeating_sequence_p operates directly on the encoded pattern and does not derive elements using the .elt() accessor. Passing in the length of the unencoded vector can cause an out-of-bounds read of the encoded pattern. gcc/ChangeLog: * config/riscv/riscv-v.cc (rvv_builder::can_duplicate_repeating_sequence_p): Use encoded_nelts when calling repeating_sequence_p. (rvv_builder::is_repeating_sequence): Ditto. (rvv_builder::repeating_sequence_use_merge_profitable_p): Ditto. Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2024-08-23ifcvt: Do not overwrite results in noce_convert_multiple_sets [PR116372, ↵Manolis Tsamis3-4/+48
PR116405] Now that more operations are allowed for noce_convert_multiple_sets, it is possible that the same register appears multiple times as target in a basic block. After noce_convert_multiple_sets_1 is called we potentially also emit register moves from temporaries back to the original targets. In some cases where the target registers overlap with the block's condition, these register moves may overwrite intermediate variables because they're emitted after the if-converted code. To address this issue we now iterate backwards and keep track of seen registers when emitting these final register moves. PR rtl-optimization/116372 PR rtl-optimization/116405 gcc/ChangeLog: * ifcvt.cc (noce_convert_multiple_sets): Iterate backwards and track target registers. gcc/testsuite/ChangeLog: * gcc.dg/pr116372.c: New test. * gcc.dg/pr116405.c: New test.
2024-08-23ifcvt: disallow call instructions in noce_convert_multiple_sets [PR116358]Manolis Tsamis2-1/+16
Similar to not allowing jump instructions in the generated code, we also shouldn't allow call instructions in noce_convert_multiple_sets. In the case of PR116358 a libcall was generated from force_operand. PR middle-end/116358 gcc/ChangeLog: * ifcvt.cc (noce_convert_multiple_sets): Disallow call insns. gcc/testsuite/ChangeLog: * gcc.target/aarch64/pr116358.c: New test.
2024-08-23rs6000: Fix PTImode handling in power8 swap optimization pass [PR116415]Peter Bergner3-4/+48
Our power8 swap optimization pass has some special handling for optimizing swaps of TImode variables. The test case reported in bugzilla uses a call to __atomic_compare_exchange, which introduces a variable of PTImode and that does not get the same treatment as TImode leading to wrong code generation. The simple fix is to treat PTImode identically to TImode. 2024-08-23 Peter Bergner <bergner@linux.ibm.com> gcc/ PR target/116415 * config/rs6000/rs6000.h (TI_OR_PTI_MODE): New define. * config/rs6000/rs6000-p8swap.cc (rs6000_analyze_swaps): Use it to handle PTImode identically to TImode. gcc/testsuite/ PR target/116415 * gcc.target/powerpc/pr116415.c: New test.
2024-08-23lto: Don't check obj.found for offload sectionH.J. Lu1-1/+1
obj.found is the number of LTO symbols. We should include the offload section when it is used by linker even if there are no LTO symbols. PR lto/116361 * lto-plugin.c (claim_file_handler_v2): Don't check obj.found for the offload section. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-23libstdc++: Implement LWG 3746 for std::optionalJonathan Wakely2-2/+30
This avoids constraint recursion in operator<=> for std::optional. The resolution was approved in Kona 2022. libstdc++-v3/ChangeLog: * include/std/optional (__is_derived_from_optional): New concept. (operator<=>): Use __is_derived_from_optional. * testsuite/20_util/optional/relops/lwg3746.cc: New test.
2024-08-23libstdc++: Optimize __try_use_facet for const typesJonathan Wakely1-1/+1
LWG 436 confirmed that const-qualified types are valid arguments for Facet template parameters (but volatile-qualified types are not). Use the fast path in std::use_facet and std::has_facet for const T as well as T. libstdc++-v3/ChangeLog: * include/bits/locale_classes.tcc (__try_use_facet): Also avoid dynamic_cast for const-qualified facet types.
2024-08-23libstdc++: Fix std::allocator_traits::construct constraints [PR108619]Jonathan Wakely8-133/+314
Using std::is_constructible in the constraints introduces a spurious dependency on the type being destructible, which should not be required for constructing with an allocator. The test case shows a case where the type has a private destructor, which can be destroyed by the allocator, but std::is_destructible and std::is_constructible are false. Similarly, using is_nothrow_constructible in the noexcept-specifiers for the construct members of allocator_traits and std::allocator, __gnu_cxx::__new_allocator, and __gnu_cxx::__malloc_allocator gives the wrong answer if the type isn't destructible. We need a new type trait to define those correctly, so that we only check if the placement new-expression is nothrow after using is_constructible to check that it would be well-formed. Instead of just fixing the overly restrictive constraint to check for placement new, rewrite allocator_traits in terms of 'if constexpr' using variable templates and the detection idiom. Although we can use 'if constexpr' and variable templates in C++11 with appropriate uses of diagnostic pragmas, we can't have constexpr functions with multiple return statements. This means that in C++11 mode the _S_nothrow_construct and _S_nothrow_destroy helpers used for noexcept-specifiers still need to be overlaods using enable_if. Nearly everything else can be simplified to reduce overload resolution and enable_if checks. libstdc++-v3/ChangeLog: PR libstdc++/108619 * include/bits/alloc_traits.h (__allocator_traits_base): Add variable templates for detecting which allocator operations are supported. (allocator_traits): Use 'if constexpr' instead of dispatching to overloads constrained with enable_if. (allocator_traits<allocator<T>>::construct): Use Construct if construct_at is not supported. Use __is_nothrow_new_constructible for noexcept-specifier. (allocator_traits<allocator<void>>::construct): Use __is_nothrow_new_constructible for noexcept-specifier. * include/bits/new_allocator.h (construct): Likewise. * include/ext/malloc_allocator.h (construct): Likewise. * include/std/type_traits (__is_nothrow_new_constructible): New variable template. * testsuite/20_util/allocator/89510.cc: Adjust expected results. * testsuite/ext/malloc_allocator/89510.cc: Likewise. * testsuite/ext/new_allocator/89510.cc: Likewise. * testsuite/20_util/allocator_traits/members/108619.cc: New test.
2024-08-23libstdc++: Only use std::time_put in std::format for non-C localesJonathan Wakely1-59/+74
When testing on Solaris I noticed that std/time/year/io.cc was FAILing because the year 1642 was being formatted as "+(" by %Ey. This turns out to be because we defer to std::time_put for modified conversion specs, and std::time_put uses std::strftime, and that's undefined for years before 1970. In particular, years before 1900 mean that the tm_year field is negative, which then causes incorrect results from strftime on at least Solaris and AIX. I've raised the general problem with LWG, but we can fix the FAILing test case (and probably improve performance slightly) by ignoring the E and O modifiers when the formatting locale is the "C" locale. The modifiers have no effect for the C locale, so we can just treat %Ey as %y and format it directly. This doesn't fix anything when the formatting locale isn't the C locale, but that case is not adequately tested, so doesn't cause any FAIL right now! The naïve fix would be simply: if (__mod) if (auto __loc = _M_locale(__ctx); __loc != locale::classic()) // ... However when the format string doesn't use the 'L' option, _M_locale always returns locale::classic(). In that case, we make a copy of the classic locale (which calls the non-inline copy constructor in the library), then make another copy of the classic locale, then compare the two. We can avoid all that by checking for the 'L' option first, instead of letting _M_locale do that: if (__mod && _M_spec._M_localized) if (auto __loc = __ctx.locale(); __loc != locale::classic()) // ... We could optimize this further if we had a __is_classic(__loc) function that would do the __loc == locale::classic() check without making any copies or non-inline calls. That would require examining the locale's _M_impl member, and probably require checking its name, because the locale::_S_classic singleton is not exported from the library. For _M_S the change is slightly different from the other functions, because if we skip using std::time_put for %OS then we fall through to the code that potentially prints fractional seconds, but the %OS format only prints whole seconds. So we need to format whole seconds directly when not using std::time_put, instead of falling through to the code below. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (__formatter_chrono::_M_C_y_Y): Ignore modifiers unless the formatting locale is not the C locale. (__formatter_chrono::_M_d_e): Likewise. (__formatter_chrono::_M_H_I): Likewise. (__formatter_chrono::_M_m): Likewise. (__formatter_chrono::_M_M): Likewise. (__formatter_chrono::_M_S): Likewise. (__formatter_chrono::_M_u_w): Likewise. (__formatter_chrono::_M_U_V_W): Likewise.
2024-08-23libstdc++: Define operator== for hash table iterators [PR115939]Jonathan Wakely2-2/+107
Currently iterators for unordered containers do not directly define operator== and operator!= overloads. Instead they rely on the base class defining them, which is done so that iterator and const_iterator comparisons work using the same overloads. However this means a derived-to-base conversion is needed to call those operators, and PR libstdc++/115939 shows that this can be ambiguous (for -pedantic) when another overloaded operator could be used after an implicit conversion. This change defines operator== and operator!= directly for _Node_iterator and _Node_const_iterator so that no derived-to-base conversions are needed. The new overloads just forward to the base class ones, so the implementation is still shared and doesn't need to be duplicated. libstdc++-v3/ChangeLog: PR libstdc++/115939 * include/bits/hashtable_policy.h (_Node_iterator): Add operator== and operator!=. (_Node_const_iterator): Likewise. * testsuite/23_containers/unordered_map/115939.cc: New test.
2024-08-23libstdc++: Fix std::random_shuffle for low RAND_MAX [PR88935]Giovanni Bajo2-9/+57
When RAND_MAX is small and the number of elements being shuffled is close to it, we get very uneven distributions in std::random_shuffle. This uses a simple xorshift generator seeded by std::rand if we can't rely on std::rand itself. libstdc++-v3/ChangeLog: PR libstdc++/88935 * include/bits/stl_algo.h (random_shuffle) [RAND_MAX < INT_MAX]: Use xorshift instead of rand(). * testsuite/25_algorithms/random_shuffle/88935.cc: New test. Co-authored-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Giovanni Bajo <rasky@develer.com>
2024-08-23tree-optimization/116463 - complex lowering leaves around dead stmtsRichard Biener1-0/+9
Complex lowering generally replaces existing complex defs with COMPLEX_EXPRs but those might be dead when it can always refer to components from the lattice. This in turn can pessimize followup transforms like forwprop and reassoc, the following makes sure to get rid of dead COMPLEX_EXPRs generated by using simple_dce_from_worklist. PR tree-optimization/116463 * tree-complex.cc: Include tree-ssa-dce.h. (dce_worklist): New global. (update_complex_assignment): Add SSA def to the DCE worklist. (tree_lower_complex): Perform DCE.
2024-08-23libstdc++: Make debug sequence members mutable [PR116369]Jonathan Wakely1-2/+2
We need to be able to attach debug mode iterators to const containers, so the safe iterator constructor uses const_cast to get a modifiable pointer to the container. If the container was defined as const, that const_cast to access its members results in undefined behaviour. PR 116369 shows a case where it results in a segfault because the container is in a rodata section (which shouldn't have happened, but the undefined behaviour in the library still exists in any case). This makes the _M_iterators and _M_const_iterators data members mutable, so that it's safe to modify them even if the declared type of the container is a const type. Ideally we would not need the const_cast at all. Instead, the _M_attach member (and everything it calls) should be const-qualified. That would work fine now, because the members that it ends up modifying are mutable. Making that change would require a number of new exports from the shared library, and would require retaining the old non-const member functions (maybe as symbol aliases) for backwards compatibility. That might be worth changing at some point, but isn't done here. libstdc++-v3/ChangeLog: PR c++/116369 * include/debug/safe_base.h (_Safe_sequence_base::_M_iterators): Add mutable specifier. (_Safe_sequence_base::_M_const_iterators): Likewise.
2024-08-23libstdc++: Use noexcept insted of throw() in src/c++11/debug.ccJonathan Wakely1-16/+16
libstdc++-v3/ChangeLog: * src/c++11/debug.cc: Replace throw() with noexcept.
2024-08-23libstdc++: Simplify C++20 implementation of std::variantJonathan Wakely1-46/+37
For C++20 the __detail::__variant::_Uninitialized primary template can be used for all types, because _Variant_union can have a non-trivially destructible union member in C++20, and the constrained user-provided destructor will ensure we don't destroy inactive objects. Since we always use the primary template for C++20, we don't need the _Uninitialized::_M_get accessors to abstract the difference between the primary template and the partial specialization. That allows us to simplify __get_n for C++20 too. Also improve the comments that explain the uses of _Uninitialized and when/why _Variant_union needs a user-provided destructor. libstdc++-v3/ChangeLog: * include/std/variant [C++20] (_Uninitialized): Always use the primary template. [C++20] (__get_n): Access the _M_storage member directly.
2024-08-23libstdc++: Make std::vector<bool>::reference constructor private [PR115098]Jonathan Wakely4-7/+29
The standard says this constructor should be private. LWG 4141 proposes to remove it entirely. We still need it, but it doesn't need to be public. For std::bitset the default constructor is already private (and never even defined) but there's a non-standard constructor that's public, but doesn't need to be. libstdc++-v3/ChangeLog: PR libstdc++/115098 * include/bits/stl_bvector.h (_Bit_reference): Make default constructor private. Declare vector and bit iterators as friends. * include/std/bitset (bitset::reference): Make constructor and data members private. * testsuite/20_util/bitset/115098.cc: New test. * testsuite/23_containers/vector/bool/115098.cc: New test.
2024-08-23Revert "Fortran: Fix class transformational intrinsic calls [PR102689]"Paul Thomas4-475/+35
This reverts commit 4cb07a38233aadb4b389a6e5236c95f52241b6e0.
2024-08-23Match: Support form 4 for unsigned integer .SAT_TRUNCPan Li1-0/+18
This patch would like to support the form 4 of the unsigned integer .SAT_TRUNC. Aka below example: Form 4: #define DEF_SAT_U_TRUC_FMT_4(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_4 (WT x) \ { \ bool not_overflow = x <= (WT)(NT)(-1); \ return ((NT)x) | (NT)((NT)not_overflow - 1); \ } DEF_SAT_U_TRUC_FMT_4(uint32_t, uint64_t) Before this patch: 4 │ __attribute__((noinline)) 5 │ uint8_t sat_u_truc_uint32_t_to_uint8_t_fmt_4 (uint32_t x) 6 │ { 7 │ _Bool not_overflow; 8 │ unsigned char _1; 9 │ unsigned char _2; 10 │ unsigned char _3; 11 │ uint8_t _6; 12 │ 13 │ ;; basic block 2, loop depth 0 14 │ ;; pred: ENTRY 15 │ not_overflow_5 = x_4(D) <= 255; 16 │ _1 = (unsigned char) x_4(D); 17 │ _2 = (unsigned char) not_overflow_5; 18 │ _3 = _2 + 255; 19 │ _6 = _1 | _3; 20 │ return _6; 21 │ ;; succ: EXIT 22 │ 23 │ } After this patch: 4 │ __attribute__((noinline)) 5 │ uint8_t sat_u_truc_uint32_t_to_uint8_t_fmt_4 (uint32_t x) 6 │ { 7 │ uint8_t _6; 8 │ 9 │ ;; basic block 2, loop depth 0 10 │ ;; pred: ENTRY 11 │ _6 = .SAT_TRUNC (x_4(D)); [tail call] 12 │ return _6; 13 │ ;; succ: EXIT 14 │ 15 │ } The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. gcc/ChangeLog: * match.pd: Add form 4 for unsigned .SAT_TRUNC matching. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-08-23libcpp: bump padding size in _cpp_convert_input [PR116458]Alexander Monakov1-9/+12
The recently introduced search_line_fast_ssse3 raised padding requirement from 16 to 64, which was adjusted in read_file_guts, but the corresponding ' + 16' in _cpp_convert_input was overlooked. libcpp/ChangeLog: PR preprocessor/116458 * charset.cc (_cpp_convert_input): Bump padding to 64 if HAVE_SSSE3.
2024-08-23optabs-query: Use opt_machine_mode for smallest_int_mode_for_size [PR115495].Robin Dapp22-42/+62
In get_best_extraction_insn we use smallest_int_mode_for_size with struct_bits as size argument. PR115495 has struct_bits = 256 and we don't have a mode for that. This patch makes smallest_mode_for_size and smallest_int_mode_for_size return opt modes so we can just skip over the loop when there is no mode. PR middle-end/115495 gcc/ChangeLog: * cfgexpand.cc (expand_debug_expr): Require mode. * combine.cc (make_extraction): Ditto. * config/aarch64/aarch64.cc (aarch64_expand_cpymem): Ditto. (aarch64_expand_setmem): Ditto. * config/arc/arc.cc (arc_expand_cpymem): Ditto. * config/arm/arm.cc (arm_expand_divmod_libfunc): Ditto. * config/i386/i386.cc (ix86_get_mask_mode): Ditto. * config/rs6000/predicates.md: Ditto. * config/rs6000/rs6000.cc (vspltis_constant): Ditto. * config/s390/s390.cc (s390_expand_insv): Ditto. * config/sparc/sparc.cc (assign_int_registers): Ditto. * coverage.cc (get_gcov_type): Ditto. (get_gcov_unsigned_t): Ditto. * dse.cc (find_shift_sequence): Ditto. * expmed.cc (store_integral_bit_field): Ditto. * expr.cc (convert_mode_scalar): Ditto. (op_by_pieces_d::smallest_fixed_size_mode_for_size): Ditto. (emit_block_move_via_oriented_loop): Ditto. (copy_blkmode_to_reg): Ditto. (store_field): Ditto. * internal-fn.cc (expand_arith_overflow): Ditto. * machmode.h (HAVE_MACHINE_MODES): Ditto. (smallest_mode_for_size): Use opt_machine_mode. (smallest_int_mode_for_size): Use opt_scalar_int_mode. * optabs-query.cc (get_best_extraction_insn): Require mode. * optabs.cc (expand_twoval_binop_libfunc): Ditto. * stor-layout.cc (smallest_mode_for_size): Return opt_machine_mode. (layout_type): Require mode. (initialize_sizetypes): Ditto. * tree-ssa-loop-manip.cc (canonicalize_loop_ivs): Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr115495.c: New test. gcc/ada/ChangeLog: * gcc-interface/utils2.cc (fast_modulo_reduction): Require mode. (nonbinary_modular_operation): Ditto.
2024-08-23RISC-V: Expand vec abs without masking.Robin Dapp12-41/+47
Standard abs synthesis during expand is max (a, -a). This expansion has the advantage of avoiding masking and is thus potentially faster than the a < 0 ? -a : a synthesis. gcc/ChangeLog: * config/riscv/autovec.md (abs<mode>2): Expand via max (a, -a). gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/abs-rv32gcv.c: Adjust test expectation. * gcc.target/riscv/rvv/autovec/unop/abs-rv64gcv.c: Ditto. * gcc.target/riscv/rvv/autovec/vls/abs-2.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-1.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-2.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-3.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-4.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-5.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-6.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-7.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-8.c: Ditto.
2024-08-23Fix test failure on powerpc targetsBernd Edlinger1-3/+3
Apparently due to slightly different optimization levels not always both subroutines have multiple subranges, but having at least one such, and no lexical blocks is sufficient to prove that the fix worked. Q.E.D. So reduce the test expectations to only at least one inlined subroutine with multiple subranges. gcc/testsuite/ChangeLog: PR other/116462 * gcc.dg/debug/dwarf2/inline7.c: Reduce test expectations.
2024-08-23ada: Fix crash on aliased variable with packed array type and -g switchEric Botcazou1-10/+11
This comes from a loophole in gnat_get_array_descr_info for record types containing a template, which represent an aliased array, when this array type is bit-packed and implemented as a modular integer. gcc/ada/ * gcc-interface/misc.cc (gnat_get_array_descr_info): Test the BIT_PACKED_ARRAY_TYPE_P flag only once on the final debug type. In the case of records containing a template, replay the entire processing for the array type contained therein.
2024-08-23ada: String interpolation: report error without Extensions allowedJavier Miranda1-13/+23
The compiler does not report the correct error in occurrences of interpolated strings, when the sources are compiled without language extensions allowed. gcc/ada/ * scng.adb (Scan): Call Error_Msg_GNAT_Extension() to report an error, when the sources are compiled without Core_Extensions_ Allowed, and the scanner detects the beginning of an interpolated string.
2024-08-23ada: Fix incorrect tracebacks on WindowsSebastian Poeplau1-1/+25
PECOFF symbols don't have a size attached to them. The symbol size that System.Object_Reader.Read_Symbol guesses to make up for the lack of information can be wrong when the symbol table doesn't match the algorithm's expectations; in particular that's the case when function symbols aren't sorted by address. To avoid incorrect tracebacks caused by wrong symbol size guesses, don't use the symbol size for PECOFF files when producing a traceback and instead pick the symbol with the highest address lower than the target address. gcc/ada/ * libgnat/s-dwalin.adb (Symbolic_Address): Ignore symbol size in address-to-symbol translation for PECOFF files.
2024-08-23ada: Crash on string interpolation with custom string typesJavier Miranda3-2/+76
The compiler crashes when processing an object declaration of a custom string type initialized with an interpolated string. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference: [Put_Image]): Add support for custom string types. * exp_ch2.adb (Expand_N_Interpolated_String_Literal): Add a type conversion to the result object declaration of custom string types. * exp_put_image.adb (Build_String_Put_Image_Call): Handle custom string types.
2024-08-23ada: Implicit_Dereference aspect specification for subtype incorrectly acceptedSteve Baird1-0/+5
Implicit_Dereference is a type-specific aspect and therefore cannot be legally specified as part of a subtype declaration. gcc/ada/ * sem_ch13.adb (Analyze_Aspect_Implicit_Dereference): Generate error if an aspect specification specifies the Implicit_Dereference aspect of a non-first subtype.
2024-08-23ada: Eliminated-mode overflow check not eliminatedSteve Baird1-4/+8
If the Overflow_Mode in effect is Eliminated, then evaluating an arithmetic op such as addition or subtraction should not fail an overflow check. Fix a bug which resulted in such an overflow check failure. gcc/ada/ * checks.adb (Is_Signed_Integer_Arithmetic_Op): Return True in the case of relational operator whose operands are of a signed integer type.
2024-08-23ada: Update libraries with the limited flagViljar Indus6-7/+7
Records without a limited keyword now emit a warning if they contain a member that has an inherently limited type. gcc/ada/ * libgnat/a-coinho__shared.ads: add limited keyword. * libgnat/g-awk.adb: add limited keyword. * libgnat/g-comlin.ads: add limited keyword. * libgnat/s-excmac__arm.ads: add limited keyword. * libgnat/s-excmac__gcc.ads: add limited keyword. * libgnat/s-soflin.ads: add limited keyword.
2024-08-23ada: Emit a warning on inheritly limited typesViljar Indus5-2/+86
Record types that do not have a limited keyword but have a member with a limited type are also considered to be limited types. This can be confusing to understand for newer Ada users. It is better to emit a warning in this scenario and suggest that the type should be marked with a limited keyword. This diagnostic will be acticated when the -gnatw_l switch is used. gcc/ada/ * sem_ch3.adb: Add method Check_Inherited_Limted_Record for emitting the warning for an inherited limited type. * warnsw.adb: Add processing for the -gnatw_l switch that triggeres the inheritly limited type warning. * warnsw.ads: same as above. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add entry for -gnatw_l switch. * gnat_ugn.texi: Regenerate.
2024-08-23ada: First controlling parameter aspectJavier Miranda1-2/+12
gcc/ada/ * sem_ch6.adb (Check_Private_Overriding): Improve code detecting error on private function with controlling result. Fixes the regression of ACATS bde0003.
2024-08-23ada: Fix style in lines starting with assignment operatorPiotr Trojanek24-148/+151
Style cleanup; semantics is unaffected. Offending occurrences found with grep "^ *:=" and fixed manually. gcc/ada/ * checks.ads, cstand.adb, exp_aggr.adb, exp_ch4.adb, exp_ch5.adb, exp_dbug.adb, exp_util.adb, gnatlink.adb, lib-util.adb, libgnat/a-except.adb, libgnat/a-exexpr.adb, libgnat/a-ngcoar.adb, libgnat/s-rannum.adb, libgnat/s-trasym__dwarf.adb, osint.adb, rtsfind.adb, sem_case.adb, sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_ch6.adb, sem_eval.adb, sem_prag.adb, sem_util.adb: Fix style.
2024-08-23ada: Cleanup validity of boolean operatorsPiotr Trojanek1-13/+3
Move detection of always valid expressions from routine Ensure_Valid (which inserts validity checks) to Expr_Known_Valid (which decides their validity). In particular, this patch removes duplicated detection of boolean operators, which were recognized in both these routines. Code cleanup; behavior is unaffected. gcc/ada/ * checks.adb (Ensure_Valid): Remove detection of boolean and short-circuit operators. (Expr_Known_Valid): Detect short-circuit operators; detection of boolean operators was already done in this routine.
2024-08-23ada: Simplify validity checks for scalar parametersPiotr Trojanek1-50/+8
Replace low-level iteration over formal and actual parameters with a call to high-level Find_Actual routine. Code cleanup; behavior is unaffected. gcc/ada/ * checks.adb (Ensure_Valid): Use Find_Actual.