]> gcc.gnu.org Git - gcc.git/log
gcc.git
3 years agoc: Fix up -Wunused-but-set-* warnings for _Atomics [PR99588]
Jakub Jelinek [Fri, 19 Mar 2021 21:54:31 +0000 (22:54 +0100)]
c: Fix up -Wunused-but-set-* warnings for _Atomics [PR99588]

As the following testcases show, compared to -D_Atomic= case we have many
-Wunused-but-set-* warning false positives.
When an _Atomic variable/parameter is read, we call mark_exp_read on it in
convert_lvalue_to_rvalue, but build_atomic_assign does not.
For consistency with the non-_Atomic case where we mark_exp_read the lhs
for lhs op= ... but not for lhs = ..., this patch does that too.
But furthermore we need to pattern match the trees emitted by _Atomic store,
so that _Atomic store itself is not marked as being a variable read, but
when the result of the store is used, we mark it.

2021-03-19  Jakub Jelinek  <jakub@redhat.com>

PR c/99588
* c-typeck.c (mark_exp_read): Recognize what build_atomic_assign
with modifycode NOP_EXPR produces and mark the _Atomic var as read
if found.
(build_atomic_assign): For modifycode of NOP_EXPR, use COMPOUND_EXPRs
rather than STATEMENT_LIST.  Otherwise call mark_exp_read on lhs.
Set TREE_SIDE_EFFECTS on the TARGET_EXPR.

* gcc.dg/Wunused-var-5.c: New test.
* gcc.dg/Wunused-var-6.c: New test.

3 years agotree-optimization/99824 - avoid excessive integer type precision in VN
Richard Biener [Tue, 30 Mar 2021 09:22:52 +0000 (11:22 +0200)]
tree-optimization/99824 - avoid excessive integer type precision in VN

VN sometimes builds new integer types to handle accesss where precision
of the access type does not match the access size.  The way
ao_ref_init_from_vn_reference is computing the access size ignores
the access type in case the ref operands have an outermost
COMPONENT_REF which, in case it is an array for example, can be
way larger than the access size.  This can cause us to try
building an integer type with precision larger than WIDE_INT_MAX_PRECISION
eventually leading to memory corruption.

The following adjusts ao_ref_init_from_vn_reference to only lower
access sizes via the outermost COMPONENT_REF but otherwise honor
the access size as specified by the access type.

It also places an assert in integer type building that we remain
in the limits of WIDE_INT_MAX_PRECISION.  I chose the shared code
where we set TYPE_MIN/MAX_VALUE because that will immediately
cross the wide_ints capacity otherwise.

2021-03-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99824
* stor-layout.c (set_min_and_max_values_for_integral_type):
Assert the precision is within the bounds of
WIDE_INT_MAX_PRECISION.
* tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Use
the outermost component ref only to lower the access size
and initialize that from the access type.

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

3 years agotestsuite: Expect a warning on aarch64 for declare-simd-coarray-lib.f90 [PR93660]
Jakub Jelinek [Mon, 29 Mar 2021 15:05:47 +0000 (17:05 +0200)]
testsuite: Expect a warning on aarch64 for declare-simd-coarray-lib.f90 [PR93660]

aarch64 currently doesn't support declare simd where the return value and arguments
have different sizes and warns about that case.  This change adds a dg-warning
for that case like various other tests have already.

2021-03-29  Jakub Jelinek  <jakub@redhat.com>

PR fortran/93660
* gfortran.dg/gomp/declare-simd-coarray-lib.f90: Expect a mixed size
declare simd warning on aarch64.

3 years agoDaily bump.
GCC Administrator [Tue, 30 Mar 2021 00:17:29 +0000 (00:17 +0000)]
Daily bump.

3 years agolibstdc++: Set dg-timeout-factor for more slow tests
Jonathan Wakely [Mon, 30 Nov 2020 14:39:54 +0000 (14:39 +0000)]
libstdc++: Set dg-timeout-factor for more slow tests

As in r11-5449, this adds a muliplier to the timeout for slow tests.
This covers the majority of the <regex> and PSTL tests.

libstdc++-v3/ChangeLog:

* testsuite/20_util/specialized_algorithms/pstl/*: Add
dg-timeout-factor.
* testsuite/25_algorithms/pstl/*: Likewise.
* testsuite/26_numerics/pstl/*: Likewise.
* testsuite/28_regex/*: Likewise.

(cherry picked from commit b6a8e3479ea924c424a4939d7129d744a9c7b273)

3 years agolibstdc++: Set dg-timeout-factor for some slow tests
Jonathan Wakely [Thu, 26 Nov 2020 15:16:25 +0000 (15:16 +0000)]
libstdc++: Set dg-timeout-factor for some slow tests

These tests are very, very slow to compile. If the testsuite is run with
a low tool_timeout value they are likely to fail. By adding a
multiplication factor to those tests, it's still possible to use a low
timeout without spurious failures.

libstdc++-v3/ChangeLog:

* testsuite/28_regex/algorithms/regex_match/basic/string_range_01_03.cc:
Add dg-timeout-factor directive.
* testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc:
Likewise.
* testsuite/28_regex/algorithms/regex_match/ecma/char/backref.cc:
Likewise.
* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/63199.cc:
Likewise.
* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/anymatcher.cc:
Likewise.
* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/cjk_match.cc:
Likewise.
* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc:
Likewise.
* testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:
Likewise.
* testsuite/28_regex/algorithms/regex_search/61720.cc: Likewise.
* testsuite/28_regex/algorithms/regex_search/ecma/assertion.cc:
Likewise.
* testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc:
Likewise.
* testsuite/28_regex/basic_regex/ctors/deduction.cc: Likewise.

(cherry picked from commit 218cedd5a36ae1cdd08c5ff997027d44ef4b6542)

3 years agolibstdc++: Fix <stop_token> to compile without gthreads
Jonathan Wakely [Tue, 11 Aug 2020 15:16:21 +0000 (16:16 +0100)]
libstdc++: Fix <stop_token> to compile without gthreads

libstdc++-v3/ChangeLog:

* include/std/stop_token: Check _GLIBCXX_HAS_GTHREADS using
#ifdef instead of #if.
(stop_token::_S_yield()): Check _GLIBCXX_HAS_GTHREADS before
using __gthread_yield.

(cherry picked from commit 35e5294c4b779f8fc24fdc86464f999867332995)

3 years agolibstdc++: Fix some -Wsystem-headers warnings (PR 95765)
Jonathan Wakely [Fri, 19 Jun 2020 17:15:15 +0000 (18:15 +0100)]
libstdc++: Fix some -Wsystem-headers warnings (PR 95765)

PR libstdc++/95765
* include/bits/stl_algobase.h (__size_to_integer(float))
(__size_to_integer(double), __size_to_integer(long double))
(__size_to_integer(__float128)): Cast return type explicitly.

(cherry picked from commit 5b6215083bd6a3e10dd142e1c5d4fab011d6f074)

3 years agolibstdc++: Fix test failure on AIX
Jonathan Wakely [Wed, 25 Nov 2020 16:58:05 +0000 (16:58 +0000)]
libstdc++: Fix test failure on AIX

This fixes a failure on AIX 7.2:

FAIL: 17_intro/names.cc (test for excess errors)
Excess errors:
/home/jwakely/src/gcc/libstdc++-v3/testsuite/17_intro/names.cc:99: error: expected identifier before '(' token
/usr/include/sys/var.h:187: error: expected unqualified-id before '{' token
/usr/include/sys/var.h:187: error: expected ')' before '{' token
/usr/include/sys/var.h:337: error: expected unqualified-id before ';' token
/usr/include/sys/var.h:337: error: expected ')' before ';' token

libstdc++-v3/ChangeLog:

* testsuite/17_intro/names.cc: Do not test 'v' on AIX.

(cherry picked from commit 1a8d1f54de371de88b2604d8c0e4e01306be8870)

3 years agolibstdc++: Make COW string use allocator_traits for nested types
Jonathan Wakely [Thu, 30 Jul 2020 19:58:09 +0000 (20:58 +0100)]
libstdc++: Make COW string use allocator_traits for nested types

When compiled as C++20 the COW std::string fails due to assuming that
the allocator always defines size_type and difference_type. That has
been incorrect since C++11, but we got away with it for specializations
using std::allocator until those members were removed in C++20.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (size_type, difference_type):
Use allocator_traits to obtain the allocator's size_type and
difference_type.

(cherry picked from commit 684d6ee140af6585c18c8790f8f5bddfcc6bd153)

3 years agolibstdc++: Constrain chrono::duration conversions [LWG 2094]
Jonathan Wakely [Tue, 1 Sep 2020 17:18:26 +0000 (18:18 +0100)]
libstdc++: Constrain chrono::duration conversions [LWG 2094]

The chrono::duration constructor that converts from another duration
type is meant to be constrained so that it doesn't participate in
overload resolution if the ratio of the periods cannot be represented as
a std::ratio.

Because our std::ratio_divide is not SFINAE-friendly the evaluation of
__is_harmonic results in an error outside the immediate context when an
overflow occurs. I intend to make ratio_divide (and ratio_multiply)
SFINAE-friendly in a future patch, but for now this patch just
introduces a new SFINAE-friendly alias template for the division.

The standard doesn't require it, but it also seems right to constrain
the constructor with std::is_convertible_v<_Rep2, rep>.

libstdc++-v3/ChangeLog:

* include/std/chrono (duration::_S_gcd(intmax_t, intmax_t)):
New helper function for finding GCD of two positive intmax_t
values.
(duration::__divide): New helper alias for dividing one period
by another.
(duration::__is_harmonic): Use __divide not ratio_divide.
(duration(const duration<R2, P2>&)): Require the duration rep
types to be convertible.
* testsuite/20_util/duration/cons/dr2094.cc: New test.
* testsuite/20_util/duration/requirements/reduced_period.cc:
Fix definition of unused member functions in test type.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
Adjust expected errors.

(cherry picked from commit b1850c617b14eedaf60b358f3b7d4707cff73b8a)

3 years agolibstdc++: Make std::chrono::duration use reduced ratio for period
Jonathan Wakely [Thu, 27 Aug 2020 21:36:03 +0000 (22:36 +0100)]
libstdc++: Make std::chrono::duration use reduced ratio for period

This implements the changes from P0548 "common_type and duration". That
was a change for C++17, but as it corrects some issues introduced by DRs
I'm also treating it as a DR and changing it for all modes from C++11
up.

The main change is that duration<R,P>::period no longer denotes P, but
rather P::type, the reduced ratio. The unary operator+ and operator-
members of duration should now return a duration using that reduced
ratio.

The requirement that common_type<T>::type is the same type as
common_type<T, T>::type (rather than simply T) was already implemented
for PR 89102.

The standard says that duration::operator+() and duration::operator-()
should return common_type_t<duration>, but that seems unnecessarily
expensive to compute. This uses duration<common_type_t<rep>, period>
which is the same type, so we avoid a common_type specialization.

As an optimization, this also adds partial specializations of
common_type for two durations of the same type, a single duration, two
time_points of the same type, and a single time_point. These
specializations avoid instantiating other specializations of common_type
and one or both of __duration_common_type or __timepoint_common_type for
the cases where the answer is trivial to obtain.

libstdc++-v3/ChangeLog:

* include/std/chrono (__duration_common_type): Ensure the
reduced ratio is used. Remove unused partial specialization
using __failure_type.
(common_type): Pass reduced ratios to __duration_common_type.
Add partial specializations for simple cases involving a single
duration or time_point type.
(duration::period): Use reduced ratio.
(duration::operator+(), duration::operator-()): Return duration
type using the reduced ratio.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
Adjust expected errors.
* testsuite/20_util/duration/requirements/reduced_period.cc: New test.

(cherry picked from commit 82030d51017323c5706d58d8c8626324ece007e4)

3 years agolibstdc++: Add workaround for weird std::tuple error [PR 96592]
Jonathan Wakely [Thu, 3 Sep 2020 15:26:16 +0000 (16:26 +0100)]
libstdc++: Add workaround for weird std::tuple error [PR 96592]

This "fix" makes no sense, but it avoids an error from G++ about
std::is_constructible being incomplete. The real problem is elsewhere,
but this "fixes" the regression for now.

libstdc++-v3/ChangeLog:

PR libstdc++/96592
* include/std/tuple (_TupleConstraints<true, T...>): Use
alternative is_constructible instead of std::is_constructible.
* testsuite/20_util/tuple/cons/96592.cc: New test.

(cherry picked from commit 032a4b42cc5f2105f622690ce2552f1c30e1d227)

3 years agolibstdc++: Adjust tests that give different results in C++20
Jonathan Wakely [Fri, 31 Jul 2020 16:51:00 +0000 (17:51 +0100)]
libstdc++: Adjust tests that give different results in C++20

libstdc++-v3/ChangeLog:

* testsuite/20_util/is_aggregate/value.cc: Adjust for changes to
definition of aggregates in C++20.
* testsuite/20_util/optional/requirements.cc: Adjust for
defaulted comparisons in C++20.

(cherry picked from commit 8e2592a88821511aa45c3325246f3b08a88fa063)

3 years agolibstdc++: Add -Wno-deprecated for tests that warn in C++20
Jonathan Wakely [Fri, 31 Jul 2020 16:51:00 +0000 (17:51 +0100)]
libstdc++: Add -Wno-deprecated for tests that warn in C++20

libstdc++-v3/ChangeLog:

* testsuite/20_util/tuple/78939.cc: Suppress warnings about
deprecation of volatile-qualified structured bindings in C++20.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise
for deprecation of is_pod in C++20

(cherry picked from commit 95edead9aab7a70636f87ea041f05469dc41d9a9)

3 years agolibstdc++: Define std::bad_optional_access constructor as defaulted
Jonathan Wakely [Tue, 9 Jun 2020 21:13:37 +0000 (22:13 +0100)]
libstdc++: Define std::bad_optional_access constructor as defaulted

The standard requires that std::bad_optional_access' default
constructor has a non-throwing exception specification.

* include/std/optional (bad_optional_access): Define default
constructor and destructor as defaulted.
* testsuite/20_util/optional/bad_access.cc: New test.

(cherry picked from commit d3647057913d3671312a79a77be02fc459d89fb6)

3 years agolibstdc++: Make std::copy_n work with negative and non-integral sizes
Jonathan Wakely [Thu, 4 Jun 2020 12:52:21 +0000 (13:52 +0100)]
libstdc++: Make std::copy_n work with negative and non-integral sizes

Since it was added in C++11, std::copy_n and std::ranges::copy_n should
do nothing given a negative size, but for random access iterators we add
the size to the iterator, possibly resulting in undefined behaviour.

Also, C++20 clarified that std::copy_n requires the Size type to be
convertible to an integral type. We previously assumed that it could be
directly used in arithmetic expressions, without conversion to an
integral type.

This also fixes a bug in the random_access_iterator_wrapper helper adds
some convenience aliases for using the iterator wrappers.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algobase.h (__copy_n_fn): Only call
ranges::copy for positive values.
* include/bits/stl_algo.h (copy_n): Convert Size argument to an
integral type and only call __copy_n for positive values.
* testsuite/util/testsuite_iterators.h
(random_access_iterator_wrapper::operator+=): Fix range check for
negative values.
(output_container, input_container, forward_container)
(bidirectional_container, random_access_container): New alias
templates.
* testsuite/25_algorithms/copy_n/5.cc: New test.

(cherry picked from commit e1008cd1d8504775e6a5e39325e396e61b39b84c)

3 years agolibstdc++: Enforce copyable/movable checks in std::atomic
Jonathan Wakely [Tue, 16 Jun 2020 21:34:55 +0000 (22:34 +0100)]
libstdc++: Enforce copyable/movable checks in std::atomic

C++20 adds some new preconditions to std::atomic, which weren't
previously checked by our implementation.

* include/std/atomic (atomic): Add static assertions.
* testsuite/29_atomics/atomic/requirements/types_neg.cc: New test.

(cherry picked from commit cc799df98f6eaf73763a069f7854e490a0416573)

3 years agolibstdc++: Define converting assignment operator for std::move_iterator
Jonathan Wakely [Tue, 9 Jun 2020 21:16:24 +0000 (22:16 +0100)]
libstdc++: Define converting assignment operator for std::move_iterator

As clarified by LWG 3265, std::move_iterator is supposed to have an
assignment operator that converts from a different specialization of
std::move_iterator, which performs an assignment. That has always been
missing from libstdc++, so assigning a different type actually performs
a converting construction, then an assignment. This is non-conforming
for the (fairly contrived) case where the converting assignment is
well-formed but the converting construction is not.

* include/bits/stl_iterator.h (move_iterator::operator=): Define.
* testsuite/24_iterators/move_iterator/dr3265.cc: New test.

(cherry picked from commit 733167f9d5ca5b9417559b7362d91e967be95a01)

3 years agolibstdc++: Fix char_traits move with overlap
Paul Keir [Mon, 15 Jun 2020 13:31:26 +0000 (14:31 +0100)]
libstdc++: Fix char_traits move with overlap

Upon constexpr evaluation, char_traits move uses copy_backward, but its
last argument should be to the range end rather than its beginning.

2020-06-12  Paul Keir  <paul.keir@uws.ac.uk>

* include/bits/char_traits.h (char_traits::move): constexpr move with
overlap was using copy_backward incorrectly.
* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
New test.

(cherry picked from commit eb11134d0c4e4db623aefe433c9613632ef8618e)

3 years agolibstdc++: Remove duplicate dg-do directive
Jonathan Wakely [Fri, 31 Jul 2020 16:51:00 +0000 (17:51 +0100)]
libstdc++: Remove duplicate dg-do directive

Also add an effective target to clarify it should only run for C++17 and
later.

libstdc++-v3/ChangeLog:

* testsuite/20_util/time_point_cast/rounding.cc: Remove
duplicate dg-do directive and add c++17 effective target.

(cherry picked from commit 351f60794c116d25a78da5220f3da74b4268cb8d)

3 years agolibstdc++: Fix failing tests for AIX
Jonathan Wakely [Tue, 11 Aug 2020 15:16:22 +0000 (16:16 +0100)]
libstdc++: Fix failing tests for AIX

These two tests fail on AIX because <sys/thread.h> defines struct thread
in the global namespace (despite it not being a reserved name). That
means the using-declaration that adds it to the global namespace causes
a redeclaration error.

libstdc++-v3/ChangeLog:

* testsuite/30_threads/thread/cons/84535.cc: Use a custom
namespace.
* testsuite/30_threads/thread/cons/lwg2097.cc: Likewise.

(cherry picked from commit fe8d7fec4db838cae536eeef1965db83959cf6ee)

3 years agolibstdc++: Allow dejagnu tool_timeout to be overridden
Jonathan Wakely [Thu, 26 Nov 2020 14:42:09 +0000 (14:42 +0000)]
libstdc++: Allow dejagnu tool_timeout to be overridden

This allows the default timeout for libstdc++ tests to be set by the
user, either in ~/.dejagnurc or a site.exp file that $DEJAGNU names.

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp (libstdc++_init): Only set
tool_timeout if it hasn't been set by the user already.

(cherry picked from commit 39e837cd7509ca631fdc382128202464063ff56e)

3 years agolibstdc++: Avoid accidental ADL when calling make_reverse_iterator
Moritz Sichert [Tue, 23 Mar 2021 15:47:37 +0000 (15:47 +0000)]
libstdc++: Avoid accidental ADL when calling make_reverse_iterator

std::ranges::reverse_view uses make_reverse_iterator in its
implementation as described in [range.reverse.view]. This accidentally
allows ADL as an unqualified name is used in the call. According to
[contents], however, this should be treated as a qualified lookup into
the std namespace.

This leads to errors due to ambiguous name lookups when another
make_reverse_iterator function is found via ADL.

libstdc++-v3/Changelog:

* include/std/ranges (reverse_view::begin, reverse_view::end):
Qualify make_reverse_iterator calls to avoid ADL.
* testsuite/std/ranges/adaptors/reverse.cc: Test that
views::reverse works when make_reverse_iterator is defined
in an associated namespace.

(cherry picked from commit 09f08fef71fb776a1d850a7b854c7ccf8a3d6c11)

3 years agolibstdc++: Add noexcept to std::begin etc as per LWG 2280 and 3537
Jonathan Wakely [Mon, 22 Mar 2021 15:15:12 +0000 (15:15 +0000)]
libstdc++: Add noexcept to std::begin etc as per LWG 2280 and 3537

This implements the proposed changes for LWG 3537 (which we're allowed
to do as an extension whatever the outcome of the issue). I noticed we
didn't implement LWG 2280 completely, as the std::begin and std::end
overloads for arrays were not noexcept.

libstdc++-v3/ChangeLog:

* include/bits/range_access.h (begin(T (&)[N]), end(T (&)[N])):
Add missing 'noexcept' as per LWG 2280.
(rbegin(T (&)[N]), rend(T (&)[N]), rbegin(initializer_list<T>))
(rend(initializer_list<T>)): Add 'noexcept' as per LWG 3537.
* testsuite/24_iterators/range_access/range_access.cc: Check for
expected noexcept specifiers. Check result types of generic
std::begin and std::end overloads.
* testsuite/24_iterators/range_access/range_access_cpp14.cc:
Check for expected noexcept specifiers.
* testsuite/24_iterators/range_access/range_access_cpp17.cc:
Likewise.

(cherry picked from commit 00b46c00c8d9003c61e8f817668ad3380e16fedb)

3 years agolibstdc++: Use acq_rel memory ordering [PR 99537]
Jonathan Wakely [Thu, 11 Mar 2021 16:44:57 +0000 (16:44 +0000)]
libstdc++: Use acq_rel memory ordering [PR 99537]

As Lewis Baker wrote in the PR:

> The 'fetch_sub()' operation in _M_release_ownership() should be using
> memory_order::acq_rel instead of memory_order::release. The use of
> 'release' only is insufficient as it does not synchronise with any
> corresponding 'acquire' operation.

> With the current implementation, it's possible that a prior write to
> one of the _M_value or _M_head data-members by a thread releasing the
> second-to-last reference might not be visible to another thread that
> releases the last reference and frees the memory, resulting in
> potential write to freed memory.

This simply changes the memory order to acq_rel as suggested.

libstdc++-v3/ChangeLog:

PR libstdc++/99537
* include/std/stop_token (_Stop_state_t::_M_release_ownership):
Use acq_rel memory ordering.

(cherry picked from commit 15825b17cf3fbf28181c51fe94a2898f448f915c)

3 years agolibstdc++: Handle EPERM for filesystem access errors on MacOS [PR 99537]
Jonathan Wakely [Thu, 11 Mar 2021 16:43:51 +0000 (16:43 +0000)]
libstdc++: Handle EPERM for filesystem access errors on MacOS [PR 99537]

Contrary to what POSIX says, some directory operations on MacOS can fail
with EPERM instead of EACCES, so we need to handle both.

libstdc++-v3/ChangeLog:

PR libstdc++/99533
* src/c++17/fs_dir.cc (recursive_directory_iterator): Use new
helper function to check for permission denied errors.
* src/filesystem/dir.cc (recursive_directory_iterator):
Likewise.
* src/filesystem/dir-common.h (is_permission_denied_error): New
helper function.

(cherry picked from commit 8cfb387388a90730ab36ac24d9049677db633a11)

3 years agolibstdc++: Initialize std::normal_distribution::_M_saved [PR 99536]
Jonathan Wakely [Thu, 11 Mar 2021 16:43:51 +0000 (16:43 +0000)]
libstdc++: Initialize std::normal_distribution::_M_saved [PR 99536]

This avoids a false positive -Wmaybe-uninitialized warning, by
initializing _M_saved on construction.

libstdc++-v3/ChangeLog:

PR libstdc++/99536
* include/bits/random.h (normal_distribution): Use
default-initializer for _M_saved and _M_saved_available.

(cherry picked from commit 67e397660611990efd98f9e4106c1ee81f6803a4)

3 years agolibstdc++: Implement LWG 3530 for concept-constrained comparisons
Jonathan Wakely [Wed, 10 Mar 2021 15:27:06 +0000 (15:27 +0000)]
libstdc++: Implement LWG 3530 for concept-constrained comparisons

The proposed resolution for this library issue simplifies the
constraints for compare_three_way, ranges::equal_to, ranges::less etc.
so that they do not work with types which are convertible to pointers
but which fail to meet the usual syntactic requirements for the
comparisons.

This affects the example in PR libstdc++/93628 but doesn't fix the
problem described in that report.

libstdc++-v3/ChangeLog:

* include/bits/range_cmp.h (__eq_builtin_ptr_cmp): Remove.
(ranges::equal_to, ranges::not_equal_to): Do not constrain
with __eq_builtin_ptr_cmp.
(ranges::less, ranges::greater, ranges::less_equal)
(ranges::greater_equal): Do not constrain with
__less_builtin_ptr_cmp.
* libsupc++/compare (compare_three_way): Do not constrain with
__3way_builtin_ptr_cmp.
* testsuite/18_support/comparisons/object/builtin-ptr-three-way.cc: Moved to...
* testsuite/18_support/comparisons/object/lwg3530.cc: ...here.
* testsuite/20_util/function_objects/range.cmp/lwg3530.cc: New test.

(cherry picked from commit dddd011113b6ceede733d7ae33eca695c06b181b)

3 years agolibstdc++: Fix filesystem::rename on Windows [PR 98985]
Jonathan Wakely [Fri, 12 Feb 2021 15:13:02 +0000 (15:13 +0000)]
libstdc++: Fix filesystem::rename on Windows [PR 98985]

The _wrename function won't overwrite an existing file, so use
MoveFileEx instead. That allows renaming directories over files, which
POSIX doesn't allow, so check for that case explicitly and report an
error.

Also document the deviation from the expected behaviour, and add a test
for filesystem::rename which was previously missing.

The Filesystem TS experimental::filesystem::rename doesn't have that
extra code to handle directories correctly, so the relevant parts of the
new test are not run on Windows.

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2014.xml: Document implementation
specific properties of std::experimental::filesystem::rename.
* doc/xml/manual/status_cxx2017.xml: Document implementation
specific properties of std::filesystem::rename.
* doc/html/*: Regenerate.
* src/c++17/fs_ops.cc (fs::rename): Implement correct behaviour
for directories on Windows.
* src/filesystem/ops-common.h (__gnu_posix::rename): Use
MoveFileExW on Windows.
* testsuite/27_io/filesystem/operations/rename.cc: New test.
* testsuite/experimental/filesystem/operations/rename.cc: New test.

(cherry picked from commit 1dfd95f0a0ca1d9e6cbc00e6cbfd1fa20a98f312)

3 years agolibstdc++: Make "nonexistent" paths less predictable in filesystem tests
Jonathan Wakely [Fri, 12 Feb 2021 15:13:02 +0000 (15:13 +0000)]
libstdc++: Make "nonexistent" paths less predictable in filesystem tests

The helper function for creating new paths doesn't work well on Windows,
because the PID of a process started by Wine is very consistent and so
the same path gets created each time.

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_fs.h (nonexistent_path): Add
random number to the path.

(cherry picked from commit 4179ec107943bea360b8aa75e29e2c5ad9f13e9e)

3 years agolibstdc++: Include scope ID in net::internet::address_v6::to_string()
Jonathan Wakely [Fri, 12 Feb 2021 15:08:29 +0000 (15:08 +0000)]
libstdc++: Include scope ID in net::internet::address_v6::to_string()

libstdc++-v3/ChangeLog:

* include/experimental/internet (address_v6::to_string): Include
scope ID in string.
(address_v6::loopback): Fix to be constexpr in C++14.
* testsuite/experimental/net/internet/address/v6/members.cc:
Test to_string() results.

(cherry picked from commit d1a821b93c45bfe7606b5dee8d160c7172b37e3e)

3 years agolibstdc++: Fix errors in <experimental/internet>
Jonathan Wakely [Fri, 12 Feb 2021 13:01:20 +0000 (13:01 +0000)]
libstdc++: Fix errors in <experimental/internet>

libstdc++-v3/ChangeLog:

* include/experimental/internet (address_v6::any): Avoid using
memcpy in constexpr function.
(address_v6::loopback): Likewise.
(make_address_v6): Fix missing return statements on error paths.
* include/experimental/io_context: Avoid -Wdangling-else
warning.
* testsuite/experimental/net/internet/address/v4/members.cc:
Remove unused variables.
* testsuite/experimental/net/internet/address/v6/members.cc:
New test.

(cherry picked from commit 970ba719250ec06767e0617658bb92a64fde0f3f)

3 years agolibstdc++: Improve tests for constexpr algorithms
Jonathan Wakely [Thu, 29 Oct 2020 14:47:18 +0000 (14:47 +0000)]
libstdc++: Improve tests for constexpr algorithms

These tests just return true without checking that the results of the
algorithms. Although it should be safe to assume that the algorithms
behave the same at compile-time as at run-time, we can use these tests
to verify it.

This replaces each 'return true' statement with a condition that depends
on the basic functionality of the algorithm, such as returning an
iterator to the right position.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/all_of/constexpr.cc: Check result of
the algorithm.
* testsuite/25_algorithms/any_of/constexpr.cc: Likewise.
* testsuite/25_algorithms/binary_search/constexpr.cc: Likewise.
* testsuite/25_algorithms/copy_backward/constexpr.cc: Likewise.
* testsuite/25_algorithms/count/constexpr.cc: Likewise.
* testsuite/25_algorithms/equal/constexpr.cc: Likewise.
* testsuite/25_algorithms/equal_range/constexpr.cc: Likewise.
* testsuite/25_algorithms/fill/constexpr.cc: Likewise.
* testsuite/25_algorithms/find_end/constexpr.cc: Likewise.
* testsuite/25_algorithms/find_if/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_partitioned/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_permutation/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc:
Likewise.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc:
Likewise.
* testsuite/25_algorithms/lower_bound/constexpr.cc: Likewise.
* testsuite/25_algorithms/merge/constexpr.cc: Likewise.
* testsuite/25_algorithms/mismatch/constexpr.cc: Likewise.
* testsuite/25_algorithms/none_of/constexpr.cc: Likewise.
* testsuite/25_algorithms/partition_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/remove_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/remove_copy_if/constexpr.cc: Likewise.
* testsuite/25_algorithms/remove_if/constexpr.cc: Likewise.
* testsuite/25_algorithms/replace_if/constexpr.cc: Likewise.
* testsuite/25_algorithms/reverse/constexpr.cc: Likewise.
* testsuite/25_algorithms/reverse_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/rotate_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/search/constexpr.cc: Likewise.
* testsuite/25_algorithms/set_difference/constexpr.cc: Likewise.
* testsuite/25_algorithms/set_intersection/constexpr.cc:
Likewise.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc:
Likewise.
* testsuite/25_algorithms/set_union/constexpr.cc: Likewise.
* testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise.

(cherry picked from commit 8c84486bba104399b7e544cb1ba343646d39ea0a)

3 years agolibstdc++: Fix bootstrap with -fno-rtti [PR 99077]
Jonathan Wakely [Fri, 12 Feb 2021 10:37:56 +0000 (10:37 +0000)]
libstdc++: Fix bootstrap with -fno-rtti [PR 99077]

When libstdc++ is built without RTTI the __ios_failure type is just an
alias for std::ios_failure, so trying to construct it from an int won't
compile. This changes the RTTI-enabled __ios_failure type to have the
same constructor parameters as std::ios_failure, so that the constructor
takes the same arguments whether RTTI is enabled or not.

The __throw_ios_failure function now constructs the error_code, instead
of the __ios_failure constructor. As a drive-by fix that error_code is
constructed with std::generic_category() not std::system_category(),
because the int comes from errno which corresponds to the generic
category.

libstdc++-v3/ChangeLog:

PR libstdc++/99077
* src/c++11/cxx11-ios_failure.cc (__ios_failure(const char*, int)):
Change int parameter to error_code, to match std::ios_failure.
(__throw_ios_failure(const char*, int)): Construct error_code
from int parameter.

(cherry picked from commit 4591f7e5329dcc6ee9af2f314a050936d470ab5b)

3 years agolibstdc++: Document when C++11/14/17 support became stable [PR 99058]
Jonathan Wakely [Thu, 11 Feb 2021 15:35:23 +0000 (15:35 +0000)]
libstdc++: Document when C++11/14/17 support became stable [PR 99058]

libstdc++-v3/ChangeLog:

PR libstdc++/99058
* doc/xml/manual/status_cxx2011.xml: Document when support
became stable.
* doc/xml/manual/status_cxx2014.xml: Likewise.
* doc/xml/manual/status_cxx2017.xml: Likewise.
* doc/html/manual/status.html: Regenerate.

(cherry picked from commit ce43c906049b828c0472d8499b52ac6233c869d0)

3 years agolibstdc++: Re-enable workaround for _wstat64 bug, again [PR 88881]
Jonathan Wakely [Wed, 10 Feb 2021 16:51:34 +0000 (16:51 +0000)]
libstdc++: Re-enable workaround for _wstat64 bug, again [PR 88881]

I forgot that the workaround is present in both filesystem::status and
filesystem::symlink_status. This restores it in the latter.

libstdc++-v3/ChangeLog:

PR libstdc++/88881
* src/c++17/fs_ops.cc (fs::symlink_status): Re-enable workaround.

(cherry picked from commit b7210405ed8eb5fd723b2c99960dcc5f0aec89b4)

3 years agolibstdc++: Re-enable workaround for _wstat64 bug [PR 88881]
Jonathan Wakely [Wed, 10 Feb 2021 16:51:34 +0000 (16:51 +0000)]
libstdc++: Re-enable workaround for _wstat64 bug [PR 88881]

This wasn't fixed upstream for mingw-w64 so we still need the
workaround.

libstdc++-v3/ChangeLog:

PR libstdc++/88881
* src/c++17/fs_ops.cc (fs::status): Re-enable workaround.

(cherry picked from commit 3df5b249b3c81e95cdcb293a388155ae5b168f9e)

3 years agolibstdc++: Use correct error category for Windows error codes
Jonathan Wakely [Wed, 10 Feb 2021 16:45:38 +0000 (16:45 +0000)]
libstdc++: Use correct error category for Windows error codes

When the result of GetLastError() is stored in a std::error_code it
should use std::system_category(), not std::generic_category() that is
used for POSIX errno values.

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (fs::create_hard_link, fs::equivalent)
(fs::remove): Use std::system_category() for error codes from
GetLastError().
* src/filesystem/ops.cc (fs::create_hard_link, fs::remove):
Likewise.

(cherry picked from commit 313e2dc377d07d5fae5a3fd666ad7000d7e8771d)

3 years agolibstdc++: Fix spelling of __MINGW32__ macros
Jonathan Wakely [Wed, 10 Feb 2021 16:37:39 +0000 (16:37 +0000)]
libstdc++: Fix spelling of __MINGW32__ macros

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/operations/proximate.cc: Fix typo
in __MINGW32__ macro name.
* testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise.
* testsuite/27_io/filesystem/path/generation/proximate.cc:
Likewise.
* testsuite/27_io/filesystem/path/generation/relative.cc:
Likewise.
* testsuite/util/testsuite_fs.h: Likewise.

(cherry picked from commit 6a6f74be9d6891cb0c17c493b1f9bca20673e6a0)

3 years agolibstdc++: Fix incorrect test for std::error_code comparisons
Jonathan Wakely [Wed, 3 Feb 2021 15:49:36 +0000 (15:49 +0000)]
libstdc++: Fix incorrect test for std::error_code comparisons

The tests for std::error_code comparisons assumed that a default
constructed object uses std::generic_category(). That's true for a
default constructed std::error_condition, but not std::error_code.

Fix the three-way comparisons to correctly depend on the result of
comparing the categories, and add another test for comparing two objects
with the same category and different values.

libstdc++-v3/ChangeLog:

* testsuite/19_diagnostics/error_code/operators/not_equal.cc:
Add comparison with same category and different values.
* testsuite/19_diagnostics/error_code/operators/less.cc:
Likewise. Fix comparison involving different categories.
* testsuite/19_diagnostics/error_code/operators/three_way.cc:
Likewise.
* testsuite/19_diagnostics/error_condition/operators/less.cc:
Add comment.
* testsuite/19_diagnostics/error_condition/operators/three_way.cc:
Likewise.

(cherry picked from commit a6f08be383f846a0474ea8d1da9222b802c36c7c)

3 years agolibstdc++: Fix errors from Library Fundamentals TS headers in C++11 [PR 98319]
Jonathan Wakely [Wed, 16 Dec 2020 13:37:17 +0000 (13:37 +0000)]
libstdc++: Fix errors from Library Fundamentals TS headers in C++11 [PR 98319]

Currently the <experimental/random>, <experimental/source_location> and
<experimental/utility> headers can be included in C++98 and C++11 modes,
but gives errors. With this change they can be included, but define
nothing.

libstdc++-v3/ChangeLog:

PR libstdc++/98319
* include/experimental/random: Only define contents for C++14
and later.
* include/experimental/source_location: Likewise.
* include/experimental/utility: Likewise.
* testsuite/experimental/feat-lib-fund.cc: Include all LFTS
headers that are present. Allow test to run for all modes.

(cherry picked from commit ab9bd93271061f436c10e35e261ecb73e2108ccc)

3 years agolibstdc++: Test errno macros directly, not via autoconf [PR 93151]
Jonathan Wakely [Tue, 15 Dec 2020 20:28:11 +0000 (20:28 +0000)]
libstdc++: Test errno macros directly, not via autoconf [PR 93151]

This fixes a bug caused by a mismatch between the macros defined by
<errno.h> when GCC is built and the macros defined by <errno.h> when
users include <system_error>. If the user code is compiled with
_XOPEN_SOURCE defined to 500 or 600, Darwin suppresses the
ENOTRECOVERABLE and EOWNERDEAD macros, which are not defined by SUSv3
(aka POSIX.1-2001).

Since POSIX requires the errno macros to be macros (and not variables or
enumerators) we can just test for them directly using the preprocessor.
That means that <system_error> will match what is actually defined when
it's included, not what was defined when GCC was built. With that change
there is no need for the GLIBCXX_CHECK_SYSTEM_ERROR configure checks and
they can be removed.

libstdc++-v3/ChangeLog:

PR libstdc++/93151
* acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): Remove.
* configure.ac: Regenerate.
* config/os/generic/error_constants.h: Test POSIX errno macros
directly, instead of corresponding _GLIBCXX_HAVE_EXXX macros.
* testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc:
Likewise.
* testsuite/19_diagnostics/headers/system_error/93151.cc: New
test.

(cherry picked from commit a2c2eec183acf25c9b214fa0827718e4d2fdfc93)

3 years agolibstdc++: Remove redundant branches in countl_one and countr_one [PR 98226]
Jonathan Wakely [Thu, 10 Dec 2020 21:57:42 +0000 (21:57 +0000)]
libstdc++: Remove redundant branches in countl_one and countr_one [PR 98226]

There's no need to explicitly check for the maximum value, because the
function we call handles it correctly anyway.

libstdc++-v3/ChangeLog:

PR libstdc++/98226
* include/std/bit (__countl_one, __countr_one): Remove redundant
branches.

(cherry picked from commit 2ea62857a3fbdf091ba38cbb62e98dc76b198e2e)

3 years agolibstdc++: Remove redundant check for zero in std::__popcount
Jonathan Wakely [Mon, 9 Nov 2020 14:31:13 +0000 (14:31 +0000)]
libstdc++: Remove redundant check for zero in std::__popcount

The popcount built-ins work fine for zero, so there's no need to check
for it.

libstdc++-v3/ChangeLog:

* include/std/bit (__popcount): Remove redundant check for zero.

(cherry picked from commit ff4bfb1553cf525d7299bbf7451ac32cfd97ae1b)

3 years agolibstdc++: Implement P2017R1 "Conditionally borrowed ranges"
Jonathan Wakely [Fri, 30 Oct 2020 18:39:43 +0000 (18:39 +0000)]
libstdc++: Implement P2017R1 "Conditionally borrowed ranges"

This makes some range adaptors model the borrowed_range concept if they
are adapting a borrowed range. This hasn't been added to the C++23
working paper yet, but it has been approved by LWG, and the
recommendation is to treat it as a defect report for C++20 as well.

libstdc++-v3/ChangeLog:

* include/std/ranges (enable_borrowed_view<take_view<T>>)
(enable_borrowed_view<drop_view<T>>)
(enable_borrowed_view<drop_while_view<T>>)
(enable_borrowed_view<reverse_view<T>>)
(enable_borrowed_view<common_view<T>>)
(enable_borrowed_view<elements_view<T>>): Add partial
specializations as per P2017R1.
* testsuite/std/ranges/adaptors/conditionally_borrowed.cc:
New test.

(cherry picked from commit 39bf4f14fc75e14aafc4ba8a53a34775f29b743a)

3 years agolibstdc++: Avoid narrowing conversion in subrange constructor
Jonathan Wakely [Thu, 29 Oct 2020 22:47:22 +0000 (22:47 +0000)]
libstdc++: Avoid narrowing conversion in subrange constructor

libstdc++-v3/ChangeLog:

* include/std/ranges (subrange::subrange(R&&)): Use
direct-initialization instead of list-initialization, so a
potential narrowing conversion from ranges::size(r) to the
stored size isn't ill-formed.

(cherry picked from commit a55cda891d69b5a238d2e237903829995ca7249c)

3 years agolibstdc++: Add assertions for preconditions in sampling distributions [PR 82584]
Jonathan Wakely [Thu, 8 Oct 2020 14:14:58 +0000 (15:14 +0100)]
libstdc++: Add assertions for preconditions in sampling distributions [PR 82584]

These three distributions all require 0 < S where S is the sum of the
weights. When the sum is zero there's an undefined FP division by zero.
Add assertions to help users diagnose the problem.

libstdc++-v3/ChangeLog:

PR libstdc++/82584
* include/bits/random.tcc
(discrete_distribution::param_type::_M_initialize)
(piecewise_constant_distribution::param_type::_M_initialize)
(piecewise_linear_distribution::param_type::_M_initialize):
Add assertions for positive sums..
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line.

(cherry picked from commit b2a96bf9dce41ee777b1669e4a8b4c6df3ff3613)

3 years agolibstdc++: Avoid divide by zero in default template arguments
Jonathan Wakely [Thu, 8 Oct 2020 13:01:00 +0000 (14:01 +0100)]
libstdc++: Avoid divide by zero in default template arguments

My previous attempt to fix this only worked when m is a power of two.
There is still a bug when a=00 and !has_single_bit(m).

Instead of trying to make _Mod work for a==0 this change ensures that we
never instantiate it with a==0. For C++17 we can use if-constexpr, but
otherwise we need to use a different multipler. It doesn't matter what
we use, as it won't actually be called, only instantiated.

libstdc++-v3/ChangeLog:

* include/bits/random.h (__detail::_Mod): Revert last change.
(__detail::__mod): Do not use _Mod for a==0 case.
* testsuite/26_numerics/random/linear_congruential_engine/operators/call.cc:
Check other cases with a==0. Also check runtime results.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line.

(cherry picked from commit c06617a79b41da37d80d7e88a3dbc56818f3e706)

3 years agolibstdc++: Fix divide by zero in default template argument
Jonathan Wakely [Wed, 7 Oct 2020 23:34:56 +0000 (00:34 +0100)]
libstdc++: Fix divide by zero in default template argument

libstdc++-v3/ChangeLog:

* include/bits/random.h (__detail::_Mod): Avoid divide by zero.
* testsuite/26_numerics/random/linear_congruential_engine/operators/call.cc:
New test.

(cherry picked from commit 6ae17a3b6835b30102607d45ac89c7a668e2c8d4)

3 years agolibstdc++: Fix constraints for drop_view::begin() const [LWG 3482]
Jonathan Wakely [Mon, 21 Sep 2020 22:43:25 +0000 (23:43 +0100)]
libstdc++: Fix constraints for drop_view::begin() const [LWG 3482]

libstdc++-v3/ChangeLog:

* include/std/ranges (drop_view::begin()): Adjust constraints
to match the correct condition for O(1) ranges::next (LWG 3482).
* testsuite/std/ranges/adaptors/drop.cc: Check that iterator is
cached for non-sized_range.

(cherry picked from commit aecea4158f4e547af349657a3d16cb031a30ec3b)

3 years agolibstdc++: Relax constraints on transform_view and elements_view iterators
Jonathan Wakely [Mon, 21 Sep 2020 13:30:38 +0000 (14:30 +0100)]
libstdc++: Relax constraints on transform_view and elements_view iterators

libstdc++-v3/ChangeLog:

* include/std/ranges (transform_view, elements_view): Relax
constraints on operator- for iterators, as per LWG 3483.
* testsuite/std/ranges/adaptors/elements.cc: Check that we
can take the difference of two iterators from a non-random
access range.
* testsuite/std/ranges/adaptors/transform.cc: Likewise.

(cherry picked from commit 2ec58cfcea146a61755516ce4ed160827fe0b4ff)

3 years agolibstdc++: Fix name clash with _Cosh in QNX headers [PR 95592]
Jonathan Wakely [Wed, 28 Oct 2020 12:35:44 +0000 (12:35 +0000)]
libstdc++: Fix name clash with _Cosh in QNX headers [PR 95592]

This replaces unqualified names like _Cosh with struct std::_Cosh to
ensure there is no ambiguity with other entities with the same name.

libstdc++-v3/ChangeLog:

PR libstdc++/95592
* include/bits/valarray_after.h (_DEFINE_EXPR_UNARY_OPERATOR)
(_DEFINE_EXPR_BINARY_OPERATOR, _DEFINE_EXPR_BINARY_FUNCTION):
Use elaborated-type-specifier and qualified-id to avoid
ambiguities with QNX system headers.
* testsuite/26_numerics/valarray/95592.cc: New test.

(cherry picked from commit 72a87d82e0d0741d75c72c8f3d2fc070e3a02b5f)

3 years agolibstdc++: Fix -Wsign-compare warnings in headers
Jonathan Wakely [Tue, 27 Oct 2020 16:32:53 +0000 (16:32 +0000)]
libstdc++: Fix -Wsign-compare warnings in headers

libstdc++-v3/ChangeLog:

* include/bits/locale_conv.h (__str_codecvt_out_all):
Add cast to compare operands of the same signedness.
* include/bits/locale_facets_nonio.tcc
(time_get::_M_extract_wday_or_month): Likewise.
* include/bits/sstream.tcc (basic_stringbuf::overflow):
Likewise.
* include/tr1/legendre_function.tcc (__sph_legendre): Use
unsigned for loop variable.

(cherry picked from commit 2232b6136822cc44d835f2b788e8d2d77b898878)

3 years agolibstdc++: Fix -Wsign-compare warnings
Jonathan Wakely [Thu, 10 Sep 2020 17:57:39 +0000 (18:57 +0100)]
libstdc++: Fix -Wsign-compare warnings

libstdc++-v3/ChangeLog:

* include/bits/locale_conv.h (__do_str_codecvt, __str_codecvt_in_all):
Add casts to compare types of the same signedness.

(cherry picked from commit 1d5589d11e61fa78b0c0e845728412b1cc6043d8)

3 years agolibstdc++: Fix -Wunused-local-typedefs warning
Jonathan Wakely [Thu, 10 Sep 2020 17:57:05 +0000 (18:57 +0100)]
libstdc++: Fix -Wunused-local-typedefs warning

libstdc++-v3/ChangeLog:

* include/bits/ranges_algobase.h (__equal_fn): Remove unused
typedef.

(cherry picked from commit 866c53cb2e88e172476185327723df9197c34ae7)

3 years agolibstdc++: Fix -Wdeprecated-declarations warnings
Jonathan Wakely [Thu, 10 Sep 2020 17:48:25 +0000 (18:48 +0100)]
libstdc++: Fix -Wdeprecated-declarations warnings

libstdc++-v3/ChangeLog:

* include/experimental/bits/shared_ptr.h (shared_ptr(auto_ptr&&))
(operator=(auto_ptr&&)): Add diagnostic pragmas to suppress
warnings for uses of std::auto_ptr.
* include/experimental/type_traits (is_literal_type_v):
Likewise, for use of std::is_literal_type.
* include/std/condition_variable (condition_variable_any::_Unlock):
Likewise, for use of std::uncaught_exception.

(cherry picked from commit 0943b558171ffc731577c428d6c5f81897b6a034)

3 years agolibstdc++: Fix -Wnarrowing warnings
Jonathan Wakely [Thu, 10 Sep 2020 17:47:08 +0000 (18:47 +0100)]
libstdc++: Fix -Wnarrowing warnings

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (path::_List::type()): Avoid narrowing
conversion.

(cherry picked from commit b6b9fd4af9ac46a8bb19a906e4c2afa14da91017)

3 years agolibstdc++: Simplify constraints for semiregular-box [LWG 3477]
Jonathan Wakely [Mon, 7 Sep 2020 19:09:17 +0000 (20:09 +0100)]
libstdc++: Simplify constraints for semiregular-box [LWG 3477]

libstdc++-v3/ChangeLog:

* include/std/ranges (__box): Simplify constraints as per LWG 3477.

(cherry picked from commit 00ffe730072f5e2e1923692163dc37db7b3784cb)

3 years agolibstdc++: Fix iota_view::size() to avoid overflow
Jonathan Wakely [Mon, 24 Aug 2020 15:17:04 +0000 (16:17 +0100)]
libstdc++: Fix iota_view::size() to avoid overflow

This avoids the overflow that occurs when negating the most negative
value of an integral type.

Also prevent returning signed int when the values have lower rank and
promote to int.

libstdc++-v3/ChangeLog:

* include/std/ranges (ranges::iota_view::size()): Perform all
calculations in the right unsigned types.
* testsuite/std/ranges/iota/size.cc: New test.

(cherry picked from commit a0e6f05d26d286f5a73007e425b109f0d327e15f)

3 years agolibstdc++: Fix net::system_context stop condition
Jonathan Wakely [Tue, 11 Aug 2020 15:16:21 +0000 (16:16 +0100)]
libstdc++: Fix net::system_context stop condition

libstdc++-v3/ChangeLog:

* include/experimental/executor (system_context::_M_run()):
Fix predicate.
(system_context::join()): Do not join unless joinable.
* testsuite/experimental/net/system_context/1.cc: New test.

(cherry picked from commit 61759518adc7679a6f46369543e30a761a16490a)

3 years agolibstdc++: Implement LWG 561 for std::inserter
Jonathan Wakely [Fri, 27 Mar 2020 23:55:48 +0000 (23:55 +0000)]
libstdc++: Implement LWG 561 for std::inserter

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (inserter): Do not deduce
iterator type (LWG 561).
* testsuite/24_iterators/insert_iterator/dr561.cc: New test.

(cherry picked from commit 2203a80a72cb582364245b6997d0724a5f84e062)

3 years agolibstdc++: Add noexcept to declaration of path::_List members
Jonathan Wakely [Tue, 27 Oct 2020 14:48:50 +0000 (14:48 +0000)]
libstdc++: Add noexcept to declaration of path::_List members

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (path::_List::begin, path::_List::end):
Add noexcept to match definitions in src/c++17/fs_path.cc.

(cherry picked from commit fe9d058ca28e0e3a50c44096ce112763057e686e)

3 years agolibstdc++: Fix directory_iterator exception specification
Jonathan Wakely [Tue, 27 Oct 2020 14:49:37 +0000 (14:49 +0000)]
libstdc++: Fix directory_iterator exception specification

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (fs::directory_iterator::operator*):
Add noexcept. Do not throw on precondition violation.

(cherry picked from commit 044b04348cfdc12848f1c6d5a8f45087c3075390)

3 years agoarm: Fix MVE ICEs with vector moves and -mpure-code [PR97252]
Alex Coplan [Mon, 22 Mar 2021 14:43:15 +0000 (14:43 +0000)]
arm: Fix MVE ICEs with vector moves and -mpure-code [PR97252]

This fixes around 500 ICEs in the testsuite which can be seen when
testing with -march=armv8.1-m.main+mve -mfloat-abi=hard -mpure-code
(leaving the testsuite free of ICEs in this configuration). All of the
ICEs are in arm_print_operand (which is expecting a mem and gets another
rtx, e.g. a const_vector) when running the output code for
*mve_mov<mode> in alternative 4.

The issue is that MVE vector moves were relying on the arm_reorg pass to
move constant vectors that we can't easily synthesize to the literal
pool. This doesn't work for -mpure-code where the literal pool is
disabled. LLVM puts these in .rodata: I've chosen to do the same here.

With this change, for -mpure-code, we no longer want to allow a constant
on the RHS of a vector load in RA. To achieve this, I added a new
constraint which matches constants only if the literal pool is
available.

gcc/ChangeLog:

PR target/97252
* config/arm/arm-protos.h (neon_make_constant): Add generate
argument to guard emitting insns, default to true.
* config/arm/arm.c (arm_legitimate_constant_p_1): Reject
CONST_VECTORs which neon_make_constant can't handle.
(neon_vdup_constant): Add generate argument, avoid emitting
insns if it's not set.
(neon_make_constant): Plumb new generate argument through.
* config/arm/constraints.md (Ui): New. Use it...
* config/arm/mve.md (*mve_mov<mode>): ... here.
* config/arm/vec-common.md (movv8hf): Use neon_make_constant to
synthesize constants.

(cherry picked from commit 150a829accd76ddd73c20628774cb0781f6e8bfe)

3 years agoc++: Fix bogus warning in deprecated namespace [PR99318]
Marek Polacek [Wed, 10 Mar 2021 00:23:48 +0000 (19:23 -0500)]
c++: Fix bogus warning in deprecated namespace [PR99318]

In GCC 10, I introduced cp_warn_deprecated_use_scopes so that we can
handle attribute deprecated on a namespace declaration.  This
function walks the decl's contexts so that we warn for code like

  namespace [[deprecated]] N { struct S { }; }
  N::S s;

We call cp_warn_deprecated_use_scopes when we encounter a TYPE_DECL.
But in the following testcase we have a TYPE_DECL whose context is
a deprecated function; that itself is not a reason to warn.  This
patch limits for which entities we call cp_warn_deprecated_use;
essentially it's what can follow ::.

I noticed that we didn't test that

  struct [[deprecated]] S { static void fn(); };
  S::fn();

produces the expected warning, so I've added gen-attrs-73.C.

gcc/cp/ChangeLog:

PR c++/99318
* decl2.c (cp_warn_deprecated_use_scopes): Only call
cp_warn_deprecated_use when decl is a namespace, class, or enum.

gcc/testsuite/ChangeLog:

PR c++/99318
* g++.dg/cpp0x/attributes-namespace6.C: New test.
* g++.dg/cpp0x/gen-attrs-73.C: New test.

(cherry picked from commit 831f9f768eb1fbf9a31d9a89591188b1487b6376)

3 years agoc-family: ICE with assume_aligned attribute [PR99062]
Marek Polacek [Wed, 10 Feb 2021 20:24:25 +0000 (15:24 -0500)]
c-family: ICE with assume_aligned attribute [PR99062]

We ICE in handle_assume_aligned_attribute since r271338 which added

@@ -2935,8 +2936,8 @@ handle_assume_aligned_attribute (tree *node, tree name, tree args, int,
          /* The misalignment specified by the second argument
             must be non-negative and less than the alignment.  */
          warning (OPT_Wattributes,
-                  "%qE attribute argument %E is not in the range [0, %E)",
-                  name, val, align);
+                  "%qE attribute argument %E is not in the range [0, %wu]",
+                  name, val, tree_to_uhwi (align) - 1);
          *no_add_attrs = true;
          return NULL_TREE;
        }
because align is INT_MIN and tree_to_uhwi asserts tree_fits_uhwi_p -- which
ALIGN does not and the prior tree_fits_shwi_p check is fine with it, as
well as the integer_pow2p check.

Since neither of the arguments to assume_aligned can be negative, I've
hoisted the tree_int_cst_sgn check.  And add the missing "argument"
word to an existing warning.

gcc/c-family/ChangeLog:

PR c++/99062
* c-attribs.c (handle_assume_aligned_attribute): Check that the
alignment argument is non-negative.  Tweak a warning message.

gcc/testsuite/ChangeLog:

PR c++/99062
* gcc.dg/attr-assume_aligned-4.c: Adjust dg-warning.
* g++.dg/ext/attr-assume-aligned.C: New test.

(cherry picked from commit 30a4d95bf76b0a0fdb66ac0211589a4434c83af3)

3 years agoFortran: Fix intrinsic null() handling [PR99651]
Tobias Burnus [Fri, 26 Mar 2021 07:39:24 +0000 (08:39 +0100)]
Fortran: Fix intrinsic null() handling [PR99651]

gcc/fortran/ChangeLog:

PR fortran/99651
* intrinsic.c (gfc_intrinsic_func_interface): Set
attr.proc = PROC_INTRINSIC if FL_PROCEDURE.

gcc/testsuite/ChangeLog:

PR fortran/99651
* gfortran.dg/null_11.f90: New test.

(cherry picked from commit 9d45e848d02e71c11420ec49630281e9a29c89b8)

3 years agoDaily bump.
GCC Administrator [Mon, 29 Mar 2021 00:17:13 +0000 (00:17 +0000)]
Daily bump.

3 years agoaix: TLS DWARF symbol decorations.
David Edelsohn [Sun, 28 Mar 2021 17:11:50 +0000 (13:11 -0400)]
aix: TLS DWARF symbol decorations.

GCC currently emits TLS relocation decorations on symbols in DWARF sections.
Recent changes to the AIX linker cause it to reject such symbols.
This patch removes the decorations (@ie, @le, @m) and emit only the
qualified symbol name.

gcc/ChangeLog:

* config/rs6000/rs6000.c (rs6000_output_dwarf_dtprel): Do not add
XCOFF TLS reloc decorations.

(cherry picked from commit 499fa254ae8c9752d8c2cf3130b13ffddfd83546)

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

3 years agoDaily bump.
GCC Administrator [Sat, 27 Mar 2021 00:17:10 +0000 (00:17 +0000)]
Daily bump.

3 years agoFix ICE: in function_and_variable_visibility, at ipa-visibility.c:795 [PR99466]
Iain Buclaw [Sat, 13 Mar 2021 16:05:52 +0000 (17:05 +0100)]
Fix ICE: in function_and_variable_visibility, at ipa-visibility.c:795 [PR99466]

In get_emutls_init_templ_addr, only thread-local declarations that were
DECL_ONE_ONLY would have a public initializer symbol, ignoring variables
that were declared with __attribute__((weak)).

gcc/ChangeLog:

PR ipa/99466
* tree-emutls.c (get_emutls_init_templ_addr): Mark initializer of weak
TLS declarations as public.

gcc/testsuite/ChangeLog:

PR ipa/99466
* gcc.dg/tls/pr99466-1.c: New test.
* gcc.dg/tls/pr99466-2.c: New test.

(cherry picked from commit 8f5e18db259c8a9790feb1d73bb0348182264f15)

3 years agoDaily bump.
GCC Administrator [Fri, 26 Mar 2021 00:17:09 +0000 (00:17 +0000)]
Daily bump.

3 years agotree-optimization/96974 - avoid ICE by replacing assert with standard failure
Stam Markianos-Wright [Thu, 25 Mar 2021 15:31:17 +0000 (15:31 +0000)]
tree-optimization/96974 - avoid ICE by replacing assert with standard failure

Minor patch to add a graceful exit in the rare case where an invalid
combination of TYPE_VECTOR_SUBPARTS for nunits_vectype and
*stmt_vectype_out is reached in vect_get_vector_types_for_stmt.

This resolves the ICE seen in PR tree-optimization/96974, however the issue
of correctly handling this rare vectorization combination is left for a
later patch.

Bootstrapped and reg-tested on aarch64-linux-gnu.

2021-03-25  Stam Markianos-Wright  <stam.markianos-wright@arm.com>

gcc/ChangeLog:

PR tree-optimization/96974
* tree-vect-stmts.c (vect_get_vector_types_for_stmt): Replace assert
with graceful exit.

gcc/testsuite/ChangeLog:

PR tree-optimization/96974
* g++.target/aarch64/sve/pr96974.C: New test.

3 years agolibgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime6...
Thomas Schwinge [Thu, 25 Jun 2020 09:59:42 +0000 (11:59 +0200)]
libgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'

For unknown reasons, this had gotten added for the libgomp HSA plugin in commit
b8d89b03db5f212919e4571671ebb4f5f8b1e19d (r242749) "Remove build dependence on
HSA run-time", and later propagated into the GCN plugin.

libgomp/
* plugin/plugin-hsa.c (init_enviroment_variables): Don't prepend
the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so'.
* plugin/plugin-gcn.c (init_environment_variables): Likewise.
* plugin/configfrag.ac (HSA_RUNTIME_LIB): Clean up.
* config.h.in: Regenerate.
* configure: Likewise.

(cherry picked from commit 7c1e856bedb4ae190c420ec2d2ca5e08730cf21d)

3 years agoFortran: Fix func decl mismatch [PR93660]
Tobias Burnus [Tue, 23 Mar 2021 14:45:36 +0000 (15:45 +0100)]
Fortran: Fix func decl mismatch [PR93660]

gcc/fortran/ChangeLog:

PR fortran/93660
* trans-decl.c (build_function_decl): Add comment;
increment hidden_typelist for caf_token/caf_offset.
* trans-types.c (gfc_get_function_type): Add comment;
add missing caf_token/caf_offset args.

gcc/testsuite/ChangeLog:

PR fortran/93660
* gfortran.dg/gomp/declare-simd-coarray-lib.f90: New test.

(cherry picked from commit 212f4988f37ccf788c8c72b1dc952980bc9be3b7)

3 years agoFortran: Extend buffer, use snprintf to avoid overflows [PR99369]
Tobias Burnus [Wed, 24 Mar 2021 06:50:22 +0000 (07:50 +0100)]
Fortran: Extend buffer, use snprintf to avoid overflows [PR99369]

gcc/fortran/ChangeLog:

PR fortran/99369
* resolve.c (resolve_operator): Make 'msg' buffer larger
and use snprintf.

gcc/testsuite/ChangeLog:

PR fortran/99369
* gfortran.dg/longnames.f90: New test.

(cherry picked from commit b179026a5d9fcadadef6ca511933933672557495)

3 years agors6000: Correct Power8 cost of l2 cache size [PR97329]
Xionghu Luo [Thu, 25 Mar 2021 04:45:58 +0000 (23:45 -0500)]
rs6000: Correct Power8 cost of l2 cache size [PR97329]

This patch is a backport to gcc 10 from master.
L2 cache size for Power8 is 512kB, it was copied from Power7 before
public.  Tested no performance change for SPEC2017.

gcc/
2021-03-25  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/97329
* config/rs6000/rs6000.c (power8_costs): Change l2 cache
from 256 to 512.

(cherry picked from commit 08103e4d6ada9b57366f2df2a2b745babfab914c)

3 years agoDaily bump.
GCC Administrator [Thu, 25 Mar 2021 00:17:35 +0000 (00:17 +0000)]
Daily bump.

3 years agotestsuite, Darwin : Fix the asan/strncpy-overflow-1 test.
Iain Sandoe [Wed, 17 Mar 2021 13:05:47 +0000 (13:05 +0000)]
testsuite, Darwin : Fix the asan/strncpy-overflow-1 test.

1. To be more compatible with Linux, Darwin testcases that include
string.h should set _FORTIFY_SOURCE=0 since, otherwise, it will be
defaulted on and the _chk versions of the string builtins will be
used.  This testcase fails otherwise because there's no convenient
way to disable the _chk builtins.

2. The system tool that handles symbolization (atos) is not reliable
with GCC's DWARF-2 output but, fortunately, all the platform
versions that support the current sanitizers are able to handle
dwarf-3 for this testcase.

gcc/testsuite/ChangeLog:

PR sanitizer/96318
* c-c++-common/asan/strncpy-overflow-1.c: Add _FORTIFY_SOURCE=0 and
-gdwarf-3 to the command line options. Adjust the expected line
numbers for the revised options header.

(cherry picked from commit c86c5195c8c02f5891a222f498c074b373aa946c)

3 years agotestsuite, Darwin : Fix match output for asan/memcmp-1.c.
Iain Sandoe [Wed, 17 Mar 2021 12:56:49 +0000 (12:56 +0000)]
testsuite, Darwin : Fix match output for asan/memcmp-1.c.

The Darwin part of libasan produces different output for memcmp
cases from other ports.  The GCC implementation does produce the
same output for this test as the clang one (modulo the two points
below).

1. To be more compatible with Linux, Darwin testcases that include
string.h should set _FORTIFY_SOURCE=0 since, otherwise, it will be
defaulted on and the _chk versions of the string builtins will be
used.

2. The system tool that handles symbolization (atos) is not reliable
with GCC's DWARF-2 output but, fortunately, all the platform
versions that support the current sanitizers are able to handle
dwarf-3 for this testcase.

gcc/testsuite/ChangeLog:

* c-c++-common/asan/memcmp-1.c: Add _FORTIFY_SOURCE=0 and
-gdwarf-3 to the command line options.  Provide Darwin-
specific match lines for the expected output.

(cherry picked from commit 9c4d77fc1cc363342b5963b07e837d2b017cac43)

3 years agoObjective-C : Implement SEL as a built-in typedef.
Iain Sandoe [Sat, 24 Oct 2020 08:48:44 +0000 (09:48 +0100)]
Objective-C : Implement SEL as a built-in typedef.

The reference implementation for Objective-C provides the SEL
typedef (although it is also available from <objc/objc.h>).

gcc/objc/ChangeLog:

* objc-act.c (synth_module_prologue): Get the SEL identifier.
* objc-act.h (enum objc_tree_index): Add OCTI_SEL_NAME.
(objc_selector_name): New.
(SEL_TYPEDEF_NAME): New.
* objc-gnu-runtime-abi-01.c
(gnu_runtime_01_initialize): Initialize SEL typedef.
* objc-next-runtime-abi-01.c
(next_runtime_01_initialize): Likewise.
* objc-next-runtime-abi-02.c

gcc/testsuite/ChangeLog:

* obj-c++.dg/SEL-typedef.mm: New test.
* objc.dg/SEL-typedef.m: New test.

(cherry picked from commit bb93020ff852fb159bc329bbaea12a33a4ef6761)

3 years agoObjective-C++ : Fix handling of unnamed message parms [PR49070].
Iain Sandoe [Fri, 26 Feb 2021 10:21:02 +0000 (10:21 +0000)]
Objective-C++ : Fix handling of unnamed message parms [PR49070].

When we are parsing an Objective-C++ message, a colon is a valid
terminator for a assignment-expression.  That is:

[receiver meth:x:x:x:x];

Is a valid, if somewhat unreadable, construction; corresponding
to a method declaration like:

- (id) meth:(id)arg0 :(id)arg1 :(id)arg2 :(id)arg3;

Where three of the message params have no selector name.

If fact, although it might be unintentional, Objective-C/C++ can
accept message selectors with all the parms unnamed (this applies
to the clang implementation too, which is taken as the reference
for the language).

For regular C++, the pattern x:x is not valid in that position an
an error is emitted with a fixit for the expected scope token.

If we simply made that error conditional on !c_dialect_objc()
that would regress Objective-C++ diagnostics for cases outside a
message selector, so we add a state flag for this.

gcc/cp/ChangeLog:

PR objc++/49070
* parser.c (cp_debug_parser): Add Objective-C++ message
state flag.
(cp_parser_nested_name_specifier_opt): Allow colon to
terminate an assignment-expression when parsing Objective-
C++ messages.
(cp_parser_objc_message_expression): Set and clear message
parsing state on entry and exit.
* parser.h (struct cp_parser): Add a context flag for
Objective-C++ message state.

gcc/testsuite/ChangeLog:

PR objc++/49070
* obj-c++.dg/pr49070.mm: New test.
* objc.dg/unnamed-parms.m: New test.

(cherry picked from commit 0cc218d42c241ed286cc5af9fb7d2e45386f7a24)

3 years agotestsuite, Objective-c++ : Backport test fixes.
Iain Sandoe [Wed, 7 Oct 2020 15:19:09 +0000 (16:19 +0100)]
testsuite, Objective-c++ : Backport test fixes.

Backported from fa99b56c7f3bca72c27d9bfcddf68ab9cc6a35e3,
6b468b7556fd96cf5bdc56ae30131980a3d596ae,
fd36daf64a1596b493d054604dd409bc7506fbfd,
cc3014d80e1072c376687f6fcfa421953a58fdd1 and
04103ecbaa59ccacc977256ae02e2f63dfd90258

gcc/testsuite/ChangeLog:

* obj-c++.dg/gnu-api-2-class-meta.mm: Add a flag to cause NeXT
headers to expose prototypes for messaging.
* obj-c++.dg/gnu-api-2-class.mm: Likewise.
* obj-c++.dg/gnu-api-2-objc.mm: Skip this because of the extra
protocols pulled in by system headers.
* obj-c++.dg/cxx-ivars-3.mm: Skip for macOS >= 10.7.
* obj-c++.dg/objc-gc-3.mm:i Skip for Darwin >= 16.
* objc-obj-c++-shared/TestsuiteObject.h: Add dummy retain and
release method declarations.
* objc-obj-c++-shared/TestsuiteObject.m: Add dummy retain and
release implementations.
* obj-c++.dg/plugin/diagnostic-test-expressions-1.mm:
Adjust testcase to include expressions for @selector and
@protocol. XFAIL where this is still not sufficient to obtain
a disgnostic range.

3 years agotestsuite, Objective-C : Backport test fixes.
Iain Sandoe [Sat, 3 Oct 2020 23:05:17 +0000 (00:05 +0100)]
testsuite, Objective-C : Backport  test fixes.

Backport f2ac4fc035b327ab8ccf562a7667f6d13758c72b,
bae828f7bbf49709df96cb264aae2c38a0cca807,
40330e70770d1c42ca51f6d84b70b04537687bc5,
b1b7599ca52f3ba94deea842c80286194d516210,
b292746ff7cfe708d3311ea41242c44ccbbe2693,
5505a9eab9bc3b170fc9f22e8a7292464efe88f6 and
406b452dc0e1254684365e3cec026258a39ba6c1

gcc/testsuite/ChangeLog:

* objc.dg/objc-gc-4.m: Disable for macOS 10.15 and 11.x.
* objc.dg/gnu-api-2-class-meta.m: Add a flag to cause NeXT
headers to expose prototypes for messaging. Mark the root
class if the objc_root_class attribute is available. Use
char ** as the second arg to main.
* objc.dg/gnu-api-2-class.m: Use dispatch prototype.
* objc.dg/gnu-api-2-objc.m: Skip on NeXT because of extra
prototypes pulled in by headers.
* objc.dg/ivar-scope-4.m: Add inititialize method to the
root class.
* objc.dg/torture/forward-1.m: Implement forwarding using the
native NeXT (NSInvocation) method for Darwin.
* objc.dg/call-super-2.m: Remove inclusion of runtime.h.
Add a FIXME about the test portability.
* objc.dg/plugin/diagnostic-test-expressions-1.m: Use assignment
expressions for @selector and @protocol to obtain a useful
diagnostic range.
* objc.dg/pr23214.m: Use Object as the root object before
Darwin12 (and NSObject after).

3 years agotestsuite, Objective-C : Compatibility fixes.
Iain Sandoe [Sat, 3 Oct 2020 23:03:54 +0000 (00:03 +0100)]
testsuite, Objective-C : Compatibility fixes.

Changes to deal with warnings and/or errors seen when compiling the
tests with clang.

gcc/testsuite/ChangeLog:

* objc-obj-c++-shared/TestsuiteObject.h: If the compiler
supports objc_root_object attributes, then mark the testsuite
object accordingly.
* objc-obj-c++-shared/TestsuiteObject.m: Avoid direct access
to isa, which is an error for modern Objective-C.
* objc/execute/class-tests-1.h: Declare a string function we
use locally (avoid pulling in the whole of string.h).

(cherry picked from commit 67f984d62e3acd729e086d49780be8e3e5e69833)

3 years agoObjective-C/C++ : Allow visibility prefix attributes on interfaces.
Iain Sandoe [Sun, 25 Oct 2020 17:34:29 +0000 (17:34 +0000)]
Objective-C/C++ : Allow visibility prefix attributes on interfaces.

This passes visibiliy through without warning (so that, for example,
__attribute__((__visibility("default"))) does not result in any
diagnostic).

gcc/objc/ChangeLog:

* objc-act.c (start_class): Accept visibility attributes
without warning.

(cherry picked from commit 6e8e1036f79e575fbe1eda57957158291c12f195)

3 years agoObjective-C/C++ : Fix rejects valid fails for properties.
Iain Sandoe [Fri, 30 Oct 2020 19:24:07 +0000 (19:24 +0000)]
Objective-C/C++ : Fix rejects valid fails for properties.

This amends the property handling to fix missing cases and improve
diagnostics.

1. Address a FIXME.

We can avoid the spurious additional complaint about a closing
')' by short-circuiting the test in the case we know there's a
syntax error already reported.

2. Improve '@' keyword locations.

When we are lexing tokens for Objective-C, we combine '@' tokens
with a following keyword (when that keyword is a valid Objective-C
one or, for Objective-C, one of the C++ keywords that can appear in
this position).  The responsibility is passed on to the parser to
validate the resulting combination.

The combination of tokens was being done without applying the rule
to their locations - so that we get:

@property
^

instead of what the user might expect:

@property
^~~~~~~~~

This patch combines the source range of the keyword with that of the
'@' sign - which improves diagnostics.

3. Update @property attribute parsing

At present, we are missing parsing and checking for around
half of the property attributes in use.  The existing ad hoc scheme
for the parser's communication with the Objective C validation
is not suitable for extending to cover all the missing cases.

We are not adding the new cases in the backport, but covering the
missing 'atomic' one.

4. Add missing 'atomic' property attribute.

This is the default, but it is still legal in user code and therefore
we should handle it in parsing.  Fix whitespace issues in the lines
affected.

Backported from e344ea07e4024316e1bc01f18bf7f187ad3aef89,
7a2cc1e8438ee853900f20880ca8858c17486b10,
9a34a5cce6b50fc3527e7c7ab356808ed435883c and
6f762481a21f211c03b6eda416b5d5737c3ed4b7

gcc/cp/ChangeLog:

* parser.c (cp_parser_objc_at_property_declaration): Use any
exisiting syntax error to suppress complaints about a missing
closing parenthesis in parsing property attributes.

gcc/testsuite/ChangeLog:

* obj-c++.dg/property/at-property-1.mm: Adjust test after
fixing spurious error output.

gcc/c-family/ChangeLog:

* c-lex.c (c_lex_with_flags): When combining '@' with a
keyword for Objective-C, combine the location ranges too.

gcc/c-family/ChangeLog:

* c-objc.h (enum objc_property_attribute_group): New
(enum objc_property_attribute_kind): New.
(OBJC_PROPATTR_GROUP_MASK): New.
(struct property_attribute_info): Small class encapsulating
parser output from property attributes.
(objc_prop_attr_kind_for_rid): New
(objc_add_property_declaration): Simplify interface.
* stub-objc.c (enum rid): Dummy type.
(objc_add_property_declaration): Simplify interface.
(objc_prop_attr_kind_for_rid): New.

gcc/c/ChangeLog:

* c-parser.c (c_parser_objc_at_property_declaration):
Improve parsing fidelity. Associate better location info
with @property attributes.  Clean up the interface to
objc_add_property_declaration ().

gcc/cp/ChangeLog:

* parser.c (cp_parser_objc_at_property_declaration):
Improve parsing fidelity. Associate better location info
with @property attributes.  Clean up the interface to
objc_add_property_declaration ().

gcc/objc/ChangeLog:

* objc-act.c (objc_prop_attr_kind_for_rid): New.
(objc_add_property_declaration): Adjust to consume the
parser output using a vector of parsed attributes.

gcc/testsuite/ChangeLog:

* obj-c++.dg/property/at-property-1.mm: Adjust expected
diagnostics.
* obj-c++.dg/property/at-property-29.mm: Likewise.
* obj-c++.dg/property/at-property-4.mm: Likewise.
* obj-c++.dg/property/property-neg-2.mm: Likewise.
* objc.dg/property/at-property-1.m: Likewise.
* objc.dg/property/at-property-29.m: Likewise.
* objc.dg/property/at-property-4.m: Likewise.
* objc.dg/property/at-property-5.m: Likewise.
* objc.dg/property/property-neg-2.m: Likewise.

gcc/c-family/ChangeLog:

* c-common.c (c_common_reswords): Add 'atomic' property
attribute.
* c-common.h (enum rid): Add RID_PROPATOMIC for atomic
property attributes.

gcc/objc/ChangeLog:

* objc-act.c (objc_prop_attr_kind_for_rid): Handle
RID_PROPATOMIC.

gcc/testsuite/ChangeLog:

* obj-c++.dg/property/at-property-4.mm: Test atomic property
attribute.
* objc.dg/property/at-property-4.m: Likewise.

3 years agoObjective-C++ : Fix bitfield ivars regression.
Iain Sandoe [Sat, 10 Oct 2020 10:14:47 +0000 (11:14 +0100)]
Objective-C++ : Fix bitfield ivars regression.

This fixes a regression present from 8.x;  It used to be OK
to test for a DECL_INITIAL value to flag that an ivar was a
bitfield (the initial value was the width).  This still works
on C / Objective-C, but no longer on C++.  Replace the test
with DECL_C_BIT_FIELD() which is set for both C and C++.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (objc_v2_build_ivar_ref): Test
DECL_C_BIT_FIELD to detect that an ivar is a bitfield.

(cherry picked from commit 73699d921d8734c351b9897f16a04453f6a47301)

3 years agoDarwin, Objective-C/C++ : Fix code-gen for NeXT runtimes.
Iain Sandoe [Sat, 3 Oct 2020 12:51:29 +0000 (13:51 +0100)]
Darwin, Objective-C/C++ : Fix code-gen for NeXT runtimes.

This addresses regressions in the handling of the NeXT runtime on Darwin
platforms which result from changes in the codegen requirements over different
OS versions and system toolchains.

1. Only emit Objective-C section switches for older linkers.

At one time, the system linkers needed to have at least a dummy entry for
every Objective-C section in use.  This removes the extra emitted code when
it is not needed by the linker.

2. Pick up super refs directly.

The current code assumed that super refs could be computed indirectly, i.e.
that the meta-data generated by the compiler was treated as read-only by the
runtime. This does not always hold (it depends on the NeXT runtime version).
So, compute super refs directly.

3. Update protocol metadata to current version.

Later versions of the NeXT runtime protocol metadata contain additional
fields.  This patch adds these fields and populates a new list of method
types.

4. Make meta-data 'extern "C"'.

For current system toolchains NeXT runtime meta-data symbols are not
mangled for Objective-C++ (i.e. they are considered to be 'extern "C"').

5. Revise the runtime selection options.

For the NeXT/Darwin runtime as installed on macOS, we now need to deal with
changes in ABI and APIs over the range of system versions supported.  So
arrange to keep track of this.

6. Update message call codegen.

Platform compilers based on LLVM do not use the objc_sendMsg_fixit
and friends for newer editions of the OS (runtimes for Arm64 do not even
have those entries). However, the _fixit versions are needed for some OS
versions (at least, up to 10.6) since the super2 call is not implemented
there.

7. Update meta-data linkage.

Newer versions of ld64 require that some meta-data symbols are
global, and that a larger set are linker-visible...

8. Adjust objective-c symbol linkage with version.

.. but earlier linkers cannot handle publicly-visible (or linker-visible)
metadata, so we need to make the output of these conditional on version.

9. Make protocols private extern and weak.

Newer linkers want protocols to be private-extern and weak.

Backported from bb675539ba2f661c6bfab258847b41798a449432,
c28d91bf23ad5767265a1298be6fef0caa0a85f0,
6224a8aa1ba46218fac36266b9cd2a746d0a4a66,
1cc7476610299eb1969f6a93ee21010ac30f5dd6,
75d4d7bc697dd1853e89a93e6c4fa1db9a709bc0,
3ba0afac60e80851c01541364d8991667809cec0,
336fdc8ba88cf617d76d1764df033cbf972904dd,
8703bf5d31fdb4789b5eddca394f8e92a0c55801 and
07c7498dc0379354d73ef4c8fd92d0473eb3a12f

gcc/ChangeLog:

* config/darwin.c (output_objc_section_asm_op): Avoid extra
objective-c section switches unless the linker needs them.
* config/darwin.c (darwin_objc2_section): Allow for
values > 1 to represent the next runtime.
(darwin_objc1_section): Likewise.
* config/darwin.c (darwin_globalize_label): Add protocol
meta-data labels to the set that are global. Make a subset of
metadate symbols global.
(darwin_label_is_anonymous_local_objc_name): Make a subset of
metadata symbols linker-visible.
(darwin_override_options): Track more target OS versions, make
the next_runtime version track this (unless it's set to 0 for
GNU runtime).
* config/darwin.h (NEXT_OBJC_RUNTIME): Set the default
next runtime value to be 10.5.8.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(objc_get_superclass_ref_decl): Split this code out.
(next_runtime_abi_02_get_class_super_ref): Compute
super refs using the objc_get_superclass_ref_decl().
(next_runtime_abi_02_get_category_super_ref): Likewise.
(build_v2_super_template): Add new
fields to the template.
(build_v2_protocol_template): Build new field entries.
(generate_v2_meth_descriptor_table): Adjust to allow recording all
method types.
(generate_v2_meth_type_list): New.
(build_v2_protocol_initializer): Initialize the additional fields.
(generate_v2_protocols): Record method types for all entries and
generate the additional method type table.
* objc-runtime-shared-support.c (start_var_decl): Make the
decl_assembler_name follow the metadata name for C++ on NeXT
runtime platforms.
(TAG_MSGSENDSUPER, TAG_MSGSENDID, TAG_MSGSENDSUPER_STRET,
TAG_MSGSENDID_STRET, FIXUP_NEEDED): Revised spelling.
(TAG_FIXUP): New.
Rename FIXUP_NEEDED to USE_FIXUP_BEFORE
(next_runtime_02_initialize): Adjust message calls to use
fixup variants only when required. Use renamed macros.
(next_runtime_abi_02_get_arg_type_list_base): Likewise.
(next_runtime_abi_02_build_objc_method_call): Likewise.
(next_runtime_abi_02_get_arg_type_list_base): Correct indent.
(build_v2_build_objc_method_call): New.
(build_v2_objc_method_fixup_call): Split out from ...
(next_runtime_abi_02_build_objc_method_call): ... here.
Arrange to adjust the call on the basis of the target
runtime.
(create_global_decl): Update to allow the caller to
specify declaration or definition.
(create_hidden_decl): Likewise.
(next_runtime_abi_02_protocol_decl): Make the symbol
weak and hidden for later OS runtime versions.
(build_v2_protocol_list_address_table): Likewise.

3 years agoaarch64: Make aarch64_add_offset work with -ftrapv [PR99540]
Richard Sandiford [Wed, 24 Mar 2021 19:18:02 +0000 (19:18 +0000)]
aarch64: Make aarch64_add_offset work with -ftrapv [PR99540]

aarch64_add_offset uses expand_mult to multiply the SVE VL by an
out-of-range constant.  expand_mult takes an argument to indicate
whether the multiplication is signed or unsigned, but in this
context the multiplication is effectively signless and so the
choice seemed arbitrary.

However, one of the things that the signedness input does is
indicate whether signed overflow should be trapped for -ftrapv.
We don't want that here, so we must treat the multiplication
as unsigned.

gcc/
2021-03-24  Jakub Jelinek  <jakub@redhat.com>

PR target/99540
* config/aarch64/aarch64.c (aarch64_add_offset): Tell
expand_mult to perform an unsigned rather than a signed
multiplication.

gcc/testsuite/
2021-03-24  Richard Sandiford  <richard.sandiford@arm.com>

PR target/99540
* gcc.dg/vect/pr99540.c: New test.

3 years agotree-optimization/98834 - fix optimization regression with _b_c_p
Richard Biener [Mon, 15 Mar 2021 12:44:07 +0000 (13:44 +0100)]
tree-optimization/98834 - fix optimization regression with _b_c_p

The following makes FRE optimize a load we formerly required
SRA + CCP for which now run after we get rid of all __builtin_constant_p
calls.

2021-03-15  Richard Biener  <rguenther@suse.de>

PR tree-optimization/98834
* tree-ssa-sccvn.c (vn_reference_lookup_3): Handle missing
subsetting by truncating the access size.

* g++.dg/opt/pr98834.C: New testcase.

(cherry picked from commit 99415d0f18716deeaa8d80e929b1337968cdfa23)

3 years agolto/96591 - walk VECTOR_CST elements in walk_tree
Richard Biener [Mon, 8 Feb 2021 08:52:56 +0000 (09:52 +0100)]
lto/96591 - walk VECTOR_CST elements in walk_tree

This implements walking of VECTOR_CST elements in walk_tree, mimicing
the walk of COMPLEX_CST elements.  Without this free-lang-data fails
to see some types in case they are only refered to via tree constants
used only as VECTOR_CST elements.

2021-02-08  Richard Biener  <rguenther@suse.de>

PR lto/96591
* tree.c (walk_tree_1): Walk VECTOR_CST elements.

* g++.dg/lto/pr96591_0.C: New testcase.

(cherry picked from commit d4536e431316b4568e236afd7a6017e5efd1b0a1)

3 years agotree-optimization/99694 - fix value-numbering PHIs
Richard Biener [Mon, 22 Mar 2021 10:09:46 +0000 (11:09 +0100)]
tree-optimization/99694 - fix value-numbering PHIs

This avoids endless cycling when a PHI node with unchanged backedge
value (the PHI result appearing there) is subject to CSE since doing
that effectively alters the hash entry.  The way to avoid this is
to ignore such edges when processing the PHI node.

2021-03-22  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99694
* tree-ssa-sccvn.c (visit_phi): Ignore edges with the
PHI result.

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

(cherry picked from commit b931e4792b8696f3da69f70988720c4d1ec6142a)

3 years agoDaily bump.
GCC Administrator [Wed, 24 Mar 2021 00:17:10 +0000 (00:17 +0000)]
Daily bump.

3 years agox86: Add __volatile__ to __cpuid and __cpuid_count
H.J. Lu [Mon, 22 Mar 2021 02:47:24 +0000 (19:47 -0700)]
x86: Add __volatile__ to __cpuid and __cpuid_count

Since CPUID instruction may return different values on hybrid core.
volatile is needed on asm statements in <cpuid.h>.

PR target/99704
* config/i386/cpuid.h (__cpuid): Add __volatile__.
(__cpuid_count): Likewise.

(cherry picked from commit 9c89c9e9c6b59260c7745c8714b69f94784a9c13)

3 years agoFortran: Fix 'name' bound size [PR99688]
Tobias Burnus [Mon, 22 Mar 2021 08:49:48 +0000 (09:49 +0100)]
Fortran: Fix 'name' bound size [PR99688]

gcc/fortran/ChangeLog:

PR fortran/99688
* match.c (select_type_set_tmp, gfc_match_select_type,
gfc_match_select_rank): Fix 'name' buffersize to avoid out of bounds.
* resolve.c (resolve_select_type): Likewise.

(cherry picked from commit 0e792ee11aa6ebb6f61e9ed33eb06e260f0ec703)

3 years agoDaily bump.
GCC Administrator [Tue, 23 Mar 2021 00:17:13 +0000 (00:17 +0000)]
Daily bump.

3 years agoObjective-C, Darwin : Update metadata section uses.
Iain Sandoe [Sat, 3 Oct 2020 12:40:03 +0000 (13:40 +0100)]
Objective-C, Darwin : Update metadata section uses.

Newer versions of ld64 are more picky about adherence to placement
rules for objective c metadata.  This adds protocol refs and uses
the ivar refs for all targets.

gcc/ChangeLog:

* config/darwin-sections.def (objc2_data_section): New.
(objc2_ivar_section): New.
* config/darwin.c (darwin_objc2_section): Act on Protocol and
ivar refs.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(next_runtime_abi_02_init_metadata_attributes): Make protocol
refs a distinct section.

(cherry picked from commit ecd616f68067cca5e7051c8872b76311b09d8f45)

This page took 0.117759 seconds and 5 git commands to generate.