aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-10-04[Ada] Crash on allocator in alternative accessibility modesJustin Squirek1-5/+9
gcc/ada/ * sem_util.adb (Function_Or_Allocator_Level): Properly handle direct function calls in the default alternative accessibility checking mode.
2021-10-04[Ada] Entities in E_Loop scopes are not library-level entitiesJavier Miranda2-19/+25
gcc/ada/ * sem_util.adb (Is_Library_Level_Entity): Return False for entities defined in E_Loop scopes. This change is not required by the frontend; it is required by tools that depend on the frontend sources. * einfo-utils.adb (Is_Dynamic_Scope): Code cleanup.
2021-10-04[Ada] Spurious accessibility error on renamed expressionJustin Squirek1-4/+14
gcc/ada/ * sem_util.adb (Accessibility_Level): Add a case to handle renamed subprograms in addition to renamed objects.
2021-10-04[Ada] VxWorks inconsistent use of return type FixupDoug Rupp4-4/+10
gcc/ada/ * libgnarl/s-osinte__vxworks.ads (tlsKeyCreate): Return int. * libgnarl/s-tpopsp__vxworks-rtp.adb (ERROR): Declare from System.VxWorks.Ext.ERROR. (Initialize): Declare IERR. Assert it. * libgnarl/s-tpopsp__vxworks.adb (ERROR): Declare from System.VxWorks.Ext.ERROR. (Is_Valid_Task): Declare IERR. Test return. * libgnarl/s-vxwext__kernel.adb (semDelete): Return STATUS.
2021-10-04[Ada] Emit debugging information for TSD objectEric Botcazou1-0/+5
gcc/ada/ * exp_disp.adb (Make_DT): Copy the Needs_Debug_Info flag from the type onto the TSD object.
2021-10-04[Ada] Fix compiler internal errorSteve Baird1-1/+6
gcc/ada/ * sem_util.adb (Is_Repeatedly_Evaluated): Handle the case of an Old attribute reference that occurs within what was originally a quantified expression but which expansion has transformed into an Expression_With_Actions.
2021-10-04[Ada] Improve checking for invalid index values when accessing array elementsSteve Baird1-2/+27
gcc/ada/ * exp_ch4.adb (Expand_N_Indexed_Component): The two improvements described above.
2021-10-04Fortran: Avoid var initialization in interfaces [PR54753]Tobias Burnus2-3/+24
Intent(out) implies deallocation/default initialization; however, it is pointless to do this for dummy-arguments symbols of procedures which are inside an INTERFACE block. – This also fixes a bogus error for the attached included testcase, but fixing the non-interface version still has to be done. PR fortran/54753 gcc/fortran/ChangeLog: * resolve.c (can_generate_init, resolve_fl_variable_derived, resolve_symbol): Only do initialization with intent(out) if not inside of an interface block.
2021-10-04Remove dead code in config/rs6000/vxworks.hEric Botcazou1-4/+0
These lines were added last year: /* Initialize library function table. */ #undef TARGET_INIT_LIBFUNCS #define TARGET_INIT_LIBFUNCS rs6000_vxworks_init_libfuncs but TARGET_INIT_LIBFUNCS is #undef-ed in config/rs6000/rs6000.c and rs6000_vxworks_init_libfuncs is nowhere defined in any case. gcc/ * config/rs6000/vxworks.h (TARGET_INIT_LIBFUNCS): Delete.
2021-10-04Daily bump.GCC Administrator5-1/+70
2021-10-03Fix for powerpc64 long double complex divide failurePatrick McGehearty1-4/+11
- - - - New in version 6: Due to an oversight (i.e. coding error), version 5 changed the use of __LIBGCC_TF_EPSILON__ to __LIBGCC_DF_EPSILON__ but not the other LIBGCC_TF values. For correct execution of the long double test case it is necessary to also switch to using __LIBGCC_DF_MIN__. For consistency we also switch to using __LIBGCC_DF_MAX__. LDBL_MIN is 2**53 times as larger than DBL_MIN. The larger value causes the code to switch the order of computation when it is not optimal, resulting in failure for one of the values in the cdivchk_ld.c test. Using DBL_MIN does not cause that failure.. There may be opportunity for further refinement of IBM128 format Long Double complex divide, but that's beyond the scope of this patch. - - - - This revision adds a test in libgcc/libgcc2.c for when "__LIBGCC_TF_MANT_DIG__ == 106" to use __LIBGCC_DF_EPSILON__ instead of __LIBGCC_TF_EPSILON__. That is specific to IBM 128-bit format long doubles where EPSILON is very, very small and 1/EPSILON oveflows to infinity. This change avoids the overflow without affecting any other platform. Discussion in the patch is adjusted to reflect this limitation. It does not make any changes to .../rs6000/_divkc3.c, leaving it to use __LIBGCC_KF__*. That means the upstream gcc will not build in older IBM environments that do not recognize the KF floating point mode properly. Environments that do not need IBM longdouble support do build cleanly. - - - - This patch addresses the failure of powerpc64 long double complex divide in native ibm long double format after the patch "Practical improvement to libgcc complex divide". The new code uses the following macros which are intended to be mapped to appropriate values according to the underlying hardware representation. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101104 RBIG a value near the maximum representation RMIN a value near the minimum representation (but not in the subnormal range) RMIN2 a value moderately less than 1 RMINSCAL the inverse of RMIN2 RMAX2 RBIG * RMIN2 - a value to limit scaling to not overflow When "long double" values were not using the IEEE 128-bit format but the traditional IBM 128-bit, the previous code used the LDBL values which caused overflow for RMINSCAL. The new code uses the DBL values. RBIG LDBL_MAX = 0x1.fffffffffffff800p+1022 DBL_MAX = 0x1.fffffffffffff000p+1022 RMIN LDBL_MIN = 0x1.0000000000000000p-969 RMIN DBL_MIN = 0x1.0000000000000000p-1022 RMIN2 LDBL_EPSILON = 0x0.0000000000001000p-1022 = 0x1.0p-1074 RMIN2 DBL_EPSILON = 0x1.0000000000000000p-52 RMINSCAL 1/LDBL_EPSILON = inf (1.0p+1074 does not fit in IBM 128-bit). 1/DBL_EPSILON = 0x1.0000000000000000p+52 RMAX2 = RBIG * RMIN2 = 0x1.fffffffffffff800p-52 RBIG * RMIN2 = 0x1.fffffffffffff000p+970 The MAX and MIN values have only modest changes since the maximum and minimum values are about the same as for double precision. The EPSILON field is considerably different. Due to how very small values can be represented in the lower 64 bits of the IBM 128-bit floating point, EPSILON is extremely small, so far beyond the desired value that inversion of the value overflows and even without the overflow, the RMAX2 is so small as to eliminate most usage of the test. The change has been tested on gcc135.fsffrance.org and gains the expected improvements in accuracy for long double complex divide. libgcc/ PR target/101104 * libgcc2.c (RMIN2, RMINSCAL, RMAX2): Use more correct values for native IBM 128-bit.
2021-10-03coroutines: Fail with a sorry when presented with a VLA [PR 101765].Iain Sandoe2-0/+55
We do not support this yet. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR c++/101765 gcc/cp/ChangeLog: * coroutines.cc (register_local_var_uses): Emit a sorry if we encounter a VLA in the coroutine local variables. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr101765.C: New test.
2021-10-03coroutines: Await expressions are not allowed in handlers [PR 99710].Iain Sandoe2-1/+41
C++20 [expr.await] / 2 An await-expression shall appear only in a potentially-evaluated expression within the compound-statement of a function-body outside of a handler. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR c++/99710 gcc/cp/ChangeLog: * coroutines.cc (await_statement_walker): Report an error if an await expression is found in a handler body. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr99710.C: New test.
2021-10-03coroutines: Fix ICE with an invalid await_suspend type [PR100673].John Eivind Helset2-1/+20
The reported ICE occurs when an invalid (non-template) type is found as the return for an await_suspend. Fixed by amending build_co_await to ensure that await_suspend return- type is a template-instantiation before checking to see if it is a valid coroutine handle type. Signed-off-by: John Eivind Helset <jehelset@gmail.com> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR c++/100673 gcc/cp/ChangeLog: * coroutines.cc (build_co_await): Guard against NULL await_suspend types. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr100673.C: New test.
2021-10-03coroutines: Ensure co_await_exprs have TREE_SIDE_EFFECTS set [PR 101133].Iain Sandoe2-12/+43
Although it is not immediately evident from the symptoms, the PR is caused by a variable having a DECL_INITIAL() containing a co_await. This is not correct, since such expressions have side-effects. We were marking the overall co_await expression correctly, but if a consumer of that expression stripped out the underlying co_await_expr then the latter would not be properly marked. Fixed by marking both the underlying and any containing await expr with TREE_SIDE_EFFECTS. Also mark type-dependent co_await expressions. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR c++/101133 gcc/cp/ChangeLog: * coroutines.cc (build_co_await): Mark co_await_expr trees with TREE_SIDE_EFFECTS, also mark any containing expression. (finish_co_await_expr): Mark type-dependent co_await_expr trees with TREE_SIDE_EFFECTS. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr101133.C: New test.
2021-10-03coroutines: Look through NOPs for awaiter variables [PR 99575].Iain Sandoe2-0/+36
There was a missing STRIP_NOPS which meant that, in some cases, an awaiter variable could be hidden by a view-convert-expr. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR c++/99575 gcc/cp/ChangeLog: * coroutines.cc (build_co_await): Strip NOPs from candidate awaiter expressions before testing to see if they need a temporary. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr99575.C: New test.
2021-10-03options: check for CL_OPTIMIZATION only for cl_options.Martin Liska1-1/+2
gcc/ChangeLog: * toplev.c (toplev::main): Check opt_index if it is a part of cl_options.
2021-10-03Daily bump.GCC Administrator7-1/+45
2021-10-02libstdc++: Fix typos in std::filesystem codeJonathan Wakely2-3/+3
There were a couple of typos in r12-4070 and r12-4071 which don't show up when building for POSIX targets. libstdc++-v3/ChangeLog: * src/c++17/fs_ops.cc (create_directory): Fix typo in enum name. * src/filesystem/ops-common.h (__last_system_error): Add explicit cast to avoid narrowing conversion. (do_space): Fix type in function name.
2021-10-02[PR102563] Do not clobber range in operator_lshift::op1_range.Aldy Hernandez2-6/+22
We're clobbering the final range before we're done calculating it. Tested on x86-64 Linux. gcc/ChangeLog: PR tree-optimization/102563 * range-op.cc (operator_lshift::op1_range): Do not clobber range. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr102563.c: New test.
2021-10-02contrib: filter out mmx.md file.Martin Liska1-0/+1
contrib/ChangeLog: * filter-clang-warnings.py: Filter out -Wtautological-compare for the file.
2021-10-02Add libgomp.fortran/order-reproducible-*.f90Tobias Burnus3-0/+118
libgomp/ChangeLog: * testsuite/libgomp.fortran/order-reproducible-1.f90: New test based on libgomp.c-c++-common/order-reproducible-1.c. * testsuite/libgomp.fortran/order-reproducible-2.f90: Likewise. * testsuite/libgomp.fortran/my-usleep.c: New test.
2021-10-02options: fix ASAN issue during saving of opt. optionsMartin Liska1-1/+1
gcc/ChangeLog: * toplev.c (toplev::main): save_decoded_options[0] is program name and so it should be skipped.
2021-10-02c-family: Fix bootstrap for targets defining TARGET_FORMAT_TYPES.Iain Sandoe1-1/+1
A recent improvement in Waddress causes a bootstrap failure on targets that define TARGET_FORMAT_TYPES since it cannot be NULL if defined to an address. There is no default for this target macro, and it would seem no purpose to defining it to NULL, so the warning appears reasonable. Fixed by removing the pointless test. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/c-family/ChangeLog: * c-format.c: Remove a test of TARGET_FORMAT_TYPES with NULL, this is not needed.
2021-10-01Use unsigned long long in asm-x86-linux-rdmsr.cH.J. Lu1-1/+1
Use unsigned long long for 64-bit integer since unsigned long is 32 bits for x32. * gcc.dg/analyzer/torture/asm-x86-linux-rdmsr.c (DECLARE_ARGS): Use unsigned long long for x86-64.
2021-10-02Daily bump.GCC Administrator12-1/+1012
2021-10-02[PR102546] X << Y being non-zero implies X is also non-zero.Aldy Hernandez2-4/+37
This patch teaches this to range-ops. Tested on x86-64 Linux. gcc/ChangeLog: PR tree-optimization/102546 * range-op.cc (operator_lshift::op1_range): Teach range-ops that X << Y is non-zero implies X is also non-zero.
2021-10-01aarch64: enable cortex-x2 CPUPrzemyslaw Wirkus3-3/+5
Patch is adding 'cortex-x2' to -mcpu command line option. gcc/ChangeLog: * config/aarch64/aarch64-cores.def (AARCH64_CORE): New Cortex-X2 core. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Update docs.
2021-10-01aarch64: enable cortex-a710 CPUPrzemyslaw Wirkus3-2/+5
Patch is adding 'cortex-a710' to -mcpu command line option. gcc/ChangeLog: * config/aarch64/aarch64-cores.def (AARCH64_CORE): New Cortex-A710 core. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Update docs.
2021-10-01aarch64: enable cortex-a510 CPUPrzemyslaw Wirkus3-2/+7
Patch is adding 'cortex-a510' to -mcpu command line option. gcc/ChangeLog: * config/aarch64/aarch64-cores.def (AARCH64_CORE): New Cortex-A510 core. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Update docs.
2021-10-01libstdc++: Restore printing of assertion messages [PR102100]Jonathan Wakely3-2/+17
My changes for PR 101429 broke the _-replacement_assert function, because we now always just abort without printing anything. That's because I added checks for _GLIBCXX_HOSTED and _GLIBCXX_VERBOSE, but the checks are done before those get defined. This adds a new macro which is set by the sed command in include/Makefile, once the HOSTED and VERBOSE macros have been set by the configure script. libstdc++-v3/ChangeLog: PR libstdc++/102100 * include/Makefile.am (c++config.h): Define _GLIBCXX_VERBOSE_ASSERT based on configure output. * include/Makefile.in: Regenerate. * include/bits/c++config: Fix condition for verbose assertions.
2021-10-01libstdc++: Reduce header dependencies for C++20 std::erase [PR92546]Jonathan Wakely7-45/+62
This reduces the preprocessed size of <deque>, <string> and <vector> by not including <bits/stl_algo.h> for std::remove and std::remove_if. Also unwrap iterators using __niter_base, to avoid redundant debug mode checks. PR libstdc++/92546 * include/bits/erase_if.h (__erase_nodes_if): Use __niter_base to unwrap debug iterators. * include/bits/refwrap.h: Do not error if included in C++03. * include/bits/stl_algo.h (__remove_if): Move to ... * include/bits/stl_algobase.h (__remove_if): ... here. * include/std/deque (erase, erase_if): Use __remove_if instead of remove and remove_if. * include/std/string (erase, erase_if): Likewise. * include/std/vector (erase, erase_if): Likewise.
2021-10-01libstdc++: Allow stateful allocators in std::list::sort [PR 66742]Jonathan Wakely4-45/+190
The temporary lists used by std::list::sort are default constructed, which means they use default constructed allocators. The sort operation is defined in terms of merge and splice operations, which have undefined behaviour (and abort) if the allocators do not compare equal. This means it is not possible to sort a list that uses an allocator that compares unequal to an default constructed allocator. The solution is to avoid using temporary std::list objects at all. We do not need to be able to allocate memory because no nodes are allocated, only spliced from one list to another. That means the temporary lists don't need an allocator at all, so whether it would compare equal doesn't matter. Instead of temporary std::list objects, we can just use a collection of _List_node_base objects that nodes can be spliced onto as needed. Those objects are wrapped in a _Scratch_list type that implements the splicing and merging operations used by list::sort. We also don't need to update the list size during the sort, because sorting doesn't alter the number of nodes. Although we move nodes in and out of the scratch lists, at the end of the function all nodes are back in the original std::list and the scratch lists are empty. So for the cxx11 ABI we can avoid the _M_size modifications usually done when splicing nodes. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/66742 * include/bits/list.tcc (list::sort()): Use _Scratch_list objects for splicing and merging. (list::sort(StrictWeakOrdering)): Likewise. * include/bits/stl_list.h (__detail::_Scratch_list): New type. * src/c++98/list.cc (_List_node_base::_M_transfer): Add assertion for --enable-libstdcxx-debug library. * testsuite/23_containers/list/operations/66742.cc: New test.
2021-10-01libstdc++: Make std::jthread support pointers to member functions [PR 100612]Jonathan Wakely2-0/+50
This adds a non-standard extension to support initializing a std::jthread with a pointer to a member function that expects a stop_token to be added to the arguments. That use case is not supported by C++20, because the stop_token would get added as the first argument, which is where the object argument needs to be to invoke a pointer to member function. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/100612 * include/std/thread (__pmf_expects_stop_token): New variable template to detect a pointer to member function that needs a stop_token to be added to the arguments. (jthread::__S_create): Use __pmf_expects_stop_token. (jthread::__S_create_pmf): New function. * testsuite/30_threads/jthread/100612.cc: New test.
2021-10-01libstdc++: Add container adaptor constructors taking iterators (P1425R4)Jonathan Wakely5-0/+199
This adds a feature that was recently added to the C++23 working draft. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/stl_queue.h (__cpp_lib_adaptor_iterator_pair_constructor): Define for C++23, as per P1425R4. (queue(InputIterator, InputIterator)): Likewise. (queue(InputIterator, InputIterator, const Alloc&)): Likewise. * include/bits/stl_stack.h (__cpp_lib_adaptor_iterator_pair_constructor): Likewise. (stack(InputIterator, InputIterator)): Likewise. (stack(InputIterator, InputIterator, const Alloc&)): Likewise. * include/std/version (__cpp_lib_adaptor_iterator_pair_constructor): Define. * testsuite/23_containers/queue/cons_from_iters.cc: New test. * testsuite/23_containers/stack/cons_from_iters.cc: New test.
2021-10-01libstdc++: Implement LWG 3506 for std::priority_queueJonathan Wakely2-0/+97
The LWG 3506 issue ads allocator-extended versions of the constructors that take iterator arguments. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/stl_queue.h (priority_queue): Add allocator-extended overloads for constructors taking iterator. * testsuite/23_containers/priority_queue/lwg3506.cc: New test.
2021-10-01libstdc++: Implement LWG 3529 for std::priority_queueJonathan Wakely2-4/+24
The LWG 3529 issue changes to use two overloads instead of one with a default argument, so that the sequence can be initialized directly with the iterator range when no sequence argument is provided. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/stl_queue.h (priority_queue): Construct sequence from iterators when no sequence argument is present (LWG 3529). * testsuite/23_containers/priority_queue/lwg3529.cc: New test.
2021-10-01libstdc++: Implement LWG 3522 for std::priority_queueJonathan Wakely2-2/+30
The LWG 3522 issue constrains all constructors of container adaptors that have InputIterator parameters. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/stl_queue.h (priority_queue): Constrain constructors with InputIterator parameters (LWG 3522). * testsuite/23_containers/priority_queue/lwg3522.cc: New test.
2021-10-01libstdc++: Implement LWG 3392 for std::ranges::distanceJonathan Wakely2-12/+45
libstdc++-v3/ChangeLog: * include/bits/ranges_base.h (ranges::distance): Split overload into two (LWG 3392). * testsuite/24_iterators/range_operations/lwg3392.cc: New test.
2021-10-01libstdc++: Remove unary_function base classes from std::thread testsJonathan Wakely3-7/+6
std::thread does not care if a function object is adaptable, so there is no need to derive from the deprecated std::unary_function class in these tests. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * testsuite/30_threads/thread/cons/3.cc: Remove derivation from std::unary_function. * testsuite/30_threads/thread/cons/4.cc: Likewise. * testsuite/30_threads/thread/cons/5.cc: Likewise.
2021-10-01libstdc++: Remove useless base classes in pb_db testsJonathan Wakely11-21/+20
These function objects do not need to be adaptable, so stop deriving from deprecated classes. Also the 'inline' keyword is redundant on member functions defined in the class body. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * testsuite/ext/pb_ds/example/basic_multimap.cc: Remove unnecesary derivation from std::unary_function. * testsuite/ext/pb_ds/example/erase_if.cc: Likewise. * testsuite/ext/pb_ds/example/hash_illegal_resize.cc: Likewise. * testsuite/ext/pb_ds/example/hash_initial_size.cc: Likewise. * testsuite/ext/pb_ds/example/hash_load_set_change.cc: Likewise. * testsuite/ext/pb_ds/example/hash_mod.cc: Likewise. * testsuite/ext/pb_ds/example/hash_resize.cc: Likewise. * testsuite/ext/pb_ds/example/hash_shift_mask.cc: Likewise. * testsuite/ext/pb_ds/example/priority_queue_dijkstra.cc: Likewise. * testsuite/ext/pb_ds/example/ranged_hash.cc: Likewise. * testsuite/ext/pb_ds/example/store_hash.cc: Likewise.
2021-10-01libstdc++: Simplify __throw_out_of_range_fmt for freestandingJonathan Wakely2-12/+7
There is no point expanding the format string if we're just going to abort instead of throw an exception. And for freestanding or non-verbose builds we shouldn't do it either, to reduce the binary size. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/c++11/functexcept.cc (__throw_out_of_range_fmt): Do not expand the format string for freestanding, or non-vebose, or if we're just going to abort anyway. * src/c++11/snprintf_lite.cc: Remove unused header and declaration.
2021-10-01libstdc++: Fix narrowing conversion in std::visitJonathan Wakely1-1/+2
Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/variant (__do_visit): Use variant_npos instead of literal -1 that requires a narrowing conversion.
2021-10-01libstdc++: Avoid unconditional use of errc::not_supported [PR 99327]Jonathan Wakely4-58/+81
The errc::not_supported constant is only defined if ENOTSUP is defined, which is not true for all targets. Many uses of errc::not_supported in the filesystem library do not actually match the intended meaning of ENOTSUP described by POSIX. They should be using ENOSYS instead (i.e. errc::function_not_supported). This change ensures that appropriate error codes are used by the filesystem library. The remaining uses of errc::not_supported are replaced with a call to a new helper function so that an alternative value will be used on targets that don't support errc::not_supported. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/99327 * src/filesystem/ops-common.h (__unsupported): New function to return a suitable error code for missing functionality. (posix::off_t): New typedef. (posix::*): Set errno to ENOSYS instead of ENOTSUP for no-op fallback implementations. (do_copy_file): Replace uses of errc::not_supported. * src/c++17/fs_ops.cc (fs::copy, fs::copy_file, create_dir) (fs::create_directory, fs::create_directory_symlink) (fs::create_hard_link, fs::create_symlink, fs::current_path) (fs::equivalent, do_stat, fs::file_size, fs::hard_link_count) (fs::last_write_time, fs::permissions, fs::read_symlink): Replace uses of errc::not_supported. (fs::resize_file): Qualify off_t. * src/filesystem/ops.cc (fs::copy, fs::copy_file, create_dir) (fs::create_directory, fs::create_directory_symlink) (fs::create_hard_link, fs::create_symlink, fs::current_path) (fs::equivalent, do_stat, fs::file_size, fs::last_write_time) (fs::permissions, fs::read_symlink, fs::system_complete): Replace uses of errc::not_supported. (fs::resize_file): Qualify off_t and enable unconditionally. * testsuite/19_diagnostics/system_error/cons-1.cc: Likewise.
2021-10-01libstdc++: Add utility for creating std::error_code from OS errorsJonathan Wakely3-9/+21
This adds a helper function to encapsulate obtaining an error code for errors from OS calls. For Windows we want to use GetLastError() and the system error category, but otherwise just use errno and the generic error category. This should not be used to replace existing uses of ec.assign(errno, generic_category()) because in those cases we really do want to get the value of errno, not a system-specific error. Only the cases that currently use GetLastError() are replace by this new function. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/filesystem/ops-common.h (last_error): New helper function. (filesystem::do_space): Use last_error(). * src/c++17/fs_ops.cc (fs::absolute, fs::create_hard_link) (fs::equivalent, fs::remove, fs::temp_directory_path): Use last_error(). * src/filesystem/ops.cc (fs::create_hard_link) (fs::remove, fs::temp_directory_path): Likewise.
2021-10-01libstdc++: Add std::__conditional_t alias templateJonathan Wakely27-154/+168
This change is inspired by the suggestion in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1715r0.html The new std::__conditional_t alias template is functionally equivalent to std::conditional_t but should be more efficient to compile, due to only ever instantiating two specializations (std::__conditional<true> and std::__conditional<false>) rather than a new specialization for every use of std::conditional. The new alias template is also available in C++11, unlike the C++14 std::conditional_t alias. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/type_traits (__conditional): New class template for internal uses of std::conditional. (__conditional_t): New alias template to replace conditional_t. (__and_, __or_, __result_of_memfun, __result_of_memobj): Use __conditional_t instead of conditional::type. * include/bits/atomic_base.h (__atomic_impl::_Diff): Likewise. * include/bits/hashtable.h (_Hashtable): Likewise. * include/bits/hashtable_policy.h (_Node_iterator, _Insert_base) (_Local_iterator): Likewise. Replace typedefs with using-declarations. * include/bits/move.h (move_if_noexcept): Use __conditional_t. * include/bits/parse_numbers.h (_Select_int_base): Likewise. * include/bits/ptr_traits.h (__make_not_void): Likewise. * include/bits/ranges_algobase.h (__copy_or_move_backward) (__copy_or_move): Likewise. * include/bits/ranges_base.h (borrowed_iterator_t): Likewise. * include/bits/ranges_util.h (borrowed_subrange_t): Likewise. * include/bits/regex_compiler.h (_BracketMatcher): Use __conditional_t. Replace typedefs with using-declarations. * include/bits/shared_ptr_base.h (__shared_count): Use __conditional_t. * include/bits/stl_algobase.h (__copy_move, __copy_move_backward): Likewise. * include/bits/stl_iterator.h (__detail::__clamp_iter_cat) (reverse_iterator::iterator_concept) (__make_move_if_noexcept_iterator) (iterator_traits<common_iterator<_It, _Sent>>) (iterator_traits<counted_iterator<_It>>): Likewise. * include/bits/stl_pair.h (_PCC, pair::operator=): Likewise. * include/bits/stl_tree.h (_Rb_tree::insert_return_type) (_Rb_tree::_M_clone_node): Likewise. * include/bits/unique_ptr.h (unique_ptr(unique_ptr<U,E>&&)): Likewise. * include/bits/uses_allocator.h (__uses_alloc): Likewise. (__is_uses_allocator_predicate): Likewise. * include/debug/functions.h (__foreign_iterator_aux2): Likewise. * include/experimental/any (any::_Manager, __any_caster): Likewise. * include/experimental/executor (async_completion): Likewise. * include/experimental/functional (__boyer_moore_base_t): Likewise. * include/std/any (any::_Manager): Likewise. * include/std/functional (__boyer_moore_base_t): Likewise. * include/std/ranges (borrowed_iterator_t) (borrowed_subrange_t, __detail::__maybe_present_t) (__detail::__maybe_const_t, split_view): Likewise. * include/std/tuple (__empty_not_final, tuple::operator=): Likewise. * include/std/variant (__detail::__variant::__get_t): Likewise.
2021-10-01libstdc++: Optimize std::visit for the common case [PR 78113]Jonathan Wakely1-5/+88
GCC does not do a good job of optimizing the table of function pointers used for variant visitation. This avoids using the table for the common case of visiting a single variant with a small number of alternative types. Instead we use: switch(v.index()) { case 0: return visitor(get<0>(v)); case 1: return visitor(get<1>(v)); ... } It's not quite that simple, because get<1>(v) is ill-formed if the variant only has one alternative, and similarly for each get<N>. We need to ensure each case only applies the visitor if the index is in range for the actual type we're dealing with, and tell the compiler that the case is unreachable otherwise. We also need to invoke the visitor via the __gen_vtable_impl::__visit_invoke function, to handle the raw visitation cases used to implement std::variant assignments and comparisons. Because that gets quite verbose and repetitive, a macro is used to stamp out the cases. We also need to handle the valueless_by_exception case, but only for raw visitation, because std::visit already checks for it before calling __do_visit. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/78113 * include/std/variant (__do_visit): Use a switch when we have a single variant with a small number of alternatives.
2021-10-01libstdc++: Allow visiting inherited variants [PR 90943]Jonathan Wakely3-12/+79
Implement the changes from P2162R2 (as a DR for C++17). Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/90943 * include/std/variant (__cpp_lib_variant): Update value. (__detail::__variant::__as): New helpers implementing the as-variant exposition-only function templates. (visit, visit<R>): Use __as to upcast the variant parameters. * include/std/version (__cpp_lib_variant): Update value. * testsuite/20_util/variant/visit_inherited.cc: New test.
2021-10-01libstdc++: Simplify __normal_iterator converting constructorJonathan Wakely1-3/+17
This uses C++11 features to simplify the definition of the __normal_iterator constructor that allows converting from iterator to const_iterator. The previous definition relied on _Container::pointer which is present in std::vector and std::basic_string, but is not actually part of the container requirements. Removing the use of _Container::pointer and defining it in terms of is_convertible allows __normal_iterator to be used with new container types which do not define a pointer member. Specifically, this will allow it to be used in std::basic_stacktrace. In theory this will enable some conversions which were not previously permitted, for example __normal_iterator<volatile T*, vector<T>> can now be converted to __normal_iterator<const volatile T*, vector<T>>. In practice this doesn't matter because the library never uses such types. In any case, allowing those conversions is consistent with the corresponding constructors of std::reverse_iterator and std::move_iterator. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (__normal_iterator): Simplify converting constructor and do not require _Container::pointer.
2021-10-01libstdc++: Make move ctor noexcept for fully-dynamic stringJonathan Wakely1-6/+13
The move constructor for the "fully-dynamic" COW string is not noexcept, because it allocates a new empty string rep for the moved-from string. However, there is no need to do that, because the moved-from string does not have to be left empty. Instead, implement move construction for the fully-dynamic case as a reference count increment, so the string is shared. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/cow_string.h [_GLIBCXX_FULLY_DYNAMIC_STRING] (basic_string(basic_string&&)): Add noexcept and avoid allocation, by sharing rep with the rvalue string.