Iain Buclaw [Tue, 26 Jul 2022 16:13:54 +0000 (18:13 +0200)]
d: Merge upstream dmd
76e3b41375, druntime
1462ebd1, phobos
5fef0d28f.
Updates D language version to v2.100.1.
D front-end changes:
- Fix delegate literal with inferred return value that requires
following alias-this to not use class cast.
- Fix internal error on variadic template type instantiated with two
arrays of classes.
- `scope(failure)' blocks that contain `return' statements are now
deprecated.
- Fix regression where wrong cast was inserted for ternary operator
and non-int enums.
- Fix internal error in code generation trying to reference
_d_arraysetctor.
- Fix memory corruption when array literal is passed to map in
lambda, then returned from nested function.
- Generate invariant id on the basis of location rather than a
global counter.
- Make `noreturn' conversions work.
- Fix segfault when `.stringof' of template alias overloaded with
function accessed by trait.
- Empty array literal passed to scope param not 'falsey' anymore.
Phobos changes:
- Avoid copying ranges in std.algorithm.comparison.equal.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd
76e3b41375.
* dmd/VERSION: Bump version to v2.100.1.
* decl.cc (DeclVisitor::visit (VarDeclaration *)): Evaluate RHS
of noreturn declaration expressions first.
* expr.cc (ExprVisitor::visit (AssignExp *)): Don't generate
assignment for noreturn types.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime
1462ebd1.
* src/MERGE: Merge upstream phobos
5fef0d28f.
Harald Anlauf [Mon, 25 Jul 2022 20:29:50 +0000 (22:29 +0200)]
Fortran: error recovery from calculation of storage size of a symbol [PR103504]
gcc/fortran/ChangeLog:
PR fortran/103504
* interface.cc (get_sym_storage_size): Array bounds and character
length can only be of integer type.
gcc/testsuite/ChangeLog:
PR fortran/103504
* gfortran.dg/pr103504.f90: New test.
(cherry picked from commit
600956c81c784f4a0cc9d10f6e03e01847afd961)
Marek Polacek [Fri, 15 Jul 2022 13:51:50 +0000 (09:51 -0400)]
c++: ICE with erroneous template redeclaration [PR106311]
Here we ICE trying to get DECL_SOURCE_LOCATION of the parm that happens
to be error_mark_node in this ill-formed test. I kept running into this
while reducing code, so it'd be good to have it fixed.
PR c++/106311
gcc/cp/ChangeLog:
* pt.cc (redeclare_class_template): Check DECL_P before accessing
DECL_SOURCE_LOCATION.
gcc/testsuite/ChangeLog:
* g++.dg/template/redecl5.C: New test.
(cherry picked from commit
2333b58c9892667545d0c2c3ecd2d7b947197511)
Jason Merrill [Mon, 25 Jul 2022 15:13:31 +0000 (11:13 -0400)]
c++: aggregate prvalue as for range [PR106230]
Since my PR94041 work on temporary lifetime in aggregate initialization, we
end up calling build_vec_init to initialize the reference-extended temporary
for the artificial __for_range variable. And build_vec_init uses
finish_for_stmt to implement its loop. That function assumes that if
__for_range is in current_binding_level, we're finishing a range-for, and we
should fix up the variable as it goes out of scope. But when called from
build_vec_init we aren't finishing a range-for, and do_poplevel doesn't
remove the variable from scope because stmts_are_full_exprs_p is false. So
let's check that here as well, and leave the DECL_NAME alone.
PR c++/106230
gcc/cp/ChangeLog:
* semantics.cc (finish_for_stmt): Check stmts_are_full_exprs_p.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/range-for38.C: New test.
GCC Administrator [Tue, 26 Jul 2022 00:19:22 +0000 (00:19 +0000)]
Daily bump.
Sebastian Huber [Fri, 22 Jul 2022 12:09:20 +0000 (14:09 +0200)]
RTEMS: Do not define _GNU_SOURCE by default
gcc/ChangeLog:
* config/rs6000/rtems.h (CPLUSPLUS_CPP_SPEC): Undef.
(cherry picked from commit
556b816b820f6749910784cbaca8bb0bb822a970)
GCC Administrator [Mon, 25 Jul 2022 00:19:30 +0000 (00:19 +0000)]
Daily bump.
GCC Administrator [Sun, 24 Jul 2022 00:19:01 +0000 (00:19 +0000)]
Daily bump.
GCC Administrator [Sat, 23 Jul 2022 00:19:16 +0000 (00:19 +0000)]
Daily bump.
Jonathan Wakely [Tue, 28 Jun 2022 08:26:12 +0000 (09:26 +0100)]
libstdc++: Do not optimize away storing pathname if it's needed
libstdc++-v3/ChangeLog:
* src/c++17/fs_dir.cc (_Dir::_Dir) [!_GLIBCXX_HAVE_OPENAT]:
Always store pathname if we don't have openat or unlinkat,
because the full path is needed to open sub-directories and
remove entries.
(cherry picked from commit
835b19936bf30d693783bfa39145a4ce243bbd7c)
Alexandre Oliva [Mon, 27 Jun 2022 13:34:16 +0000 (10:34 -0300)]
libstdc++: check for openat with dirfd in std::filesystem
In the recent patch to check for openat, I missed an occurrence of
dirfd in std::filesystem.
for libstdc++-v3/ChangeLog
* src/c++17/fs_dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.
(cherry picked from commit
486893b1d325d22d54c1380937943913a7501f91)
Alexandre Oliva [Fri, 24 Jun 2022 02:20:53 +0000 (23:20 -0300)]
libstdc++: check for openat
rtems6.0 has fdopendir, and fcntl.h defines AT_FDCWD and declares
openat, but there's no openat in libc. Adjust dir-common.h to not
assume ::openat just because of AT_FDCWD.
for libstdc++-v3/ChangeLog
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for
openat.
* configure, config.h.in: Rebuilt.
* src/filesystem/dir-common.h (openat): Use ::openat if
_GLIBCXX_HAVE_OPENAT.
* src/filesystem/dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.
(cherry picked from commit
93070671eae44f24ba822383e17571a39257c637)
Jonathan Wakely [Fri, 6 May 2022 12:23:45 +0000 (13:23 +0100)]
libstdc++: Do not include <cxxabi.h> in <stacktrace>
This avoids polluting the global namespace with the "abi" namespace
alias.
libstdc++-v3/ChangeLog:
* include/std/stacktrace: Do not include <cxxabi.h>.
(__cxa_demangle): Declare.
(cherry picked from commit
e112e37f2920bcc9185e53b754d9145aac912c72)
GCC Administrator [Fri, 22 Jul 2022 00:19:09 +0000 (00:19 +0000)]
Daily bump.
Jason Merrill [Thu, 21 Jul 2022 00:00:58 +0000 (20:00 -0400)]
c++: defaulted friend op== [PR106361]
Now non-member functions can be defaulted, so this assert is wrong.
move_signature_fn_p already checks for ctor or op=.
PR c++/106361
gcc/cp/ChangeLog:
* decl.cc (move_fn_p): Remove assert.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/spaceship-eq14.C: New test.
Patrick Palka [Thu, 21 Jul 2022 16:59:44 +0000 (12:59 -0400)]
c++: non-dependent call to consteval operator [PR105912]
Here we're crashing when substituting a non-dependent call to a
consteval operator, whose CALL_EXPR_OPERATOR_SYNTAX flag we try to
propagate to the result, but the result isn't a CALL_EXPR since the
selected function is consteval. This patch fixes this by checking the
result of extract_call_expr accordingly. (Note that we can't check
DECL_IMMEDIATE_FUNCTION_P here because we don't know which function was
selected by overload resolution from here.)
PR c++/105912
gcc/cp/ChangeLog:
* call.cc (extract_call_expr): Return a NULL_TREE on failure
instead of asserting.
* pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Guard against
NULL_TREE extract_call_expr result.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/consteval31.C: New test.
(cherry picked from commit
f70c18524221dcefa6cd26cee7b55503181bd912)
Patrick Palka [Wed, 13 Jul 2022 18:01:28 +0000 (14:01 -0400)]
c++: dependence of constrained memfn from current inst [PR105842]
Here we incorrectly deem the calls to func1, func2 and tmpl2 as
ambiguous ahead of time ultimately because we mishandle dependence
of a constrained member function from the current instantiation.
In type_dependent_expression_p, we already consider dependence of a
TEMPLATE_DECL's constraints (via uses_outer_template_parms), but
neglect to do the same for a FUNCTION_DECL (such as that for func1).
And in satisfy_declaration_constraints, we give up if _any_ template
argument is dependent, but for non-dependent member functions from
the current instantiation (such as func2 and tmpl2), we can and must
check constraints as long as the innermost arguments aren't dependent.
PR c++/105842
gcc/cp/ChangeLog:
* constraint.cc (satisfy_declaration_constraints): Refine early
exit test for argument dependence.
* cp-tree.h (uses_outer_template_parms_in_constraints): Declare.
* pt.cc (template_class_depth): Handle TI_TEMPLATE being a
FIELD_DECL.
(usse_outer_template_parms): Factor out constraint dependence
test into ...
(uses_outer_template_parms_in_constraints): ... here.
(type_dependent_expression_p): Use it for FUNCTION_DECL.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-memtmpl6.C: New test.
(cherry picked from commit
f07778f6f92111aa0abfd0f669b148a0bda537a9)
Patrick Palka [Mon, 6 Jun 2022 18:29:12 +0000 (14:29 -0400)]
c++: function NTTP argument considered unused [PR53164, PR105848]
Here at parse time the template argument f (an OVERLOAD) in A<f> gets
resolved ahead of time to the FUNCTION_DECL f<int>, and we defer marking
f<int> as used until instantiation (of g) as usual.
Later when instantiating g the type A<f> (where f has already been
resolved) is non-dependent, so tsubst_aggr_type avoids re-processing its
template arguments, and we end up never actually marking f<int> as used
(which means we never instantiate it) even though A<f>::h() later calls
it, leading to a link error.
This patch works around this issue by looking through ADDR_EXPR when
calling mark_used on the substituted callee of a CALL_EXPR.
PR c++/53164
PR c++/105848
gcc/cp/ChangeLog:
* pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Look through an
ADDR_EXPR callee when calling mark_used.
gcc/testsuite/ChangeLog:
* g++.dg/template/fn-ptr3.C: New test.
(cherry picked from commit
733a792a2b2e1662e738fa358b45a2720a8618a7)
Patrick Palka [Fri, 3 Jun 2022 16:06:59 +0000 (12:06 -0400)]
c++: cv-quals of dummy obj for non-dep memfn call [PR105637]
In non-dependent23.C below we expect the Base::foo calls to
resolve to the second, third and fourth overloads respectively in light
of the cv-qualifiers of 'this' in each case. But ever since
r12-6075-g2decd2cabe5a4f, the calls incorrectly resolve to the first
overload at instantiation time.
This happens because the calls to Base::foo are all deemed
non-dependent (ever since r7-755-g23cb72663051cd made us ignore 'this'
dependence when considering the dependence of a non-static memfn call),
hence we end up checking the call ahead of time, using as the object
argument a dummy object of type Base. Since this object argument is
cv-unqualified, the calls in turn resolve to the unqualified overload
of baseDevice. Before r12-6075 this incorrect result would just get
silently discarded and we'd end up redoing OR at instantiation time
using 'this' as the object argument. But after r12-6075 we now reuse
this incorrect result at instantiation time.
This patch fixes this by making maybe_dummy_object respect the cv-quals
of (the non-lambda) 'this' when returning a dummy object. Thus, ahead
of time OR using a dummy object will give us the right answer that's
consistent with the instantiation time answer.
An earlier version of this patch didn't handle 'this'-capturing lambdas
correctly, which broke lambda-this22.C below.
PR c++/105637
gcc/cp/ChangeLog:
* tree.cc (maybe_dummy_object): When returning a dummy
object, respect the cv-quals of 'this' if available.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/lambda/lambda-this22.C: New test.
* g++.dg/template/non-dependent23.C: New test.
(cherry picked from commit
44a5bd6d933d86ed988fc4695aa00f122cf83eb4)
Patrick Palka [Fri, 3 Jun 2022 13:29:12 +0000 (09:29 -0400)]
c++: don't substitute TEMPLATE_PARM_CONSTRAINTS [PR100374]
This patch makes us avoid substituting into the TEMPLATE_PARM_CONSTRAINTS
of each template parameter except as necessary for declaration matching,
like we already do for the other constituent constraints of a declaration.
This patch also improves the CA104 implementation of explicit
specialization matching of a constrained function template inside a
class template, by considering the function's combined constraints
instead of just its trailing constraints. This allows us to correctly
handle the first three explicit specializations in concepts-spec2.C
below, but because we compare the constraints as a whole, it means we
incorrectly accept the fourth explicit specialization which writes #3's
constraints in a different way. For complete correctness here,
determine_specialization should use tsubst_each_template_parm_constraints
and template_parameter_heads_equivalent_p.
PR c++/100374
gcc/cp/ChangeLog:
* pt.cc (determine_specialization): Compare overall constraints
not just the trailing constraints.
(tsubst_each_template_parm_constraints): Define.
(tsubst_friend_function): Use it.
(tsubst_friend_class): Use it.
(tsubst_template_parm): Don't substitute TEMPLATE_PARM_CONSTRAINTS.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-spec2.C: New test.
* g++.dg/cpp2a/concepts-template-parm11.C: New test.
(cherry picked from commit
43c013df02fdb07f9b7a5e7e6669e6d69769d451)
Patrick Palka [Tue, 31 May 2022 20:49:08 +0000 (16:49 -0400)]
c++: non-dep call with empty TYPE_BINFO [PR105758]
Here the out-of-line definition of Z<T>::z causes duplicate_decls to
change z's type from using the primary template type Z<T> (which is also
the type of the injected class name) to the implicit instantiation Z<T>,
and this latter type lacks a TYPE_BINFO (although its TYPE_CANONICAL was
set by a special case in lookup_template_class to point to the former).
Later, when processing the non-dependent call z->foo(0), build_over_call
relies on the object argument's TYPE_BINFO to build the templated form
for this call, which fails because the object argument type has empty
TYPE_BINFO due to the above.
It seems weird that the implicit instantiation Z<T> doesn't have the
same TYPE_BINFO as the primary template type Z<T>, despite them being
proclaimed equivalent via TYPE_CANONICAL. So I tried also setting
TYPE_BINFO in the special case in lookup_template_class, but that led to
some problems with constrained partial specializations of the form Z<T>.
I'm not sure what, if anything, we ought to do about the subtle
differences between these two versions of the same type.
Fortunately it seems we don't need to rely on TYPE_BINFO at all in
build_over_call here -- the z_candidate struct already contains the
exact binfos we need to rebuild the BASELINK for the templated form.
PR c++/105758
gcc/cp/ChangeLog:
* call.cc (build_over_call): Use z_candidate::conversion_path
and ::access_path instead of TYPE_BINFO when building the
BASELINK for the templated form.
gcc/testsuite/ChangeLog:
* g++.dg/template/non-dependent24.C: New test.
(cherry picked from commit
4f84f12066953186cce4328b7f178d3daa2fe96e)
Patrick Palka [Thu, 26 May 2022 13:43:14 +0000 (09:43 -0400)]
c++: constrained partial spec forward decl [PR96363]
Here during cp_parser_single_declaration for #2, we were calling
associate_classtype_constraints for TPL<T> (the primary template type)
before maybe_process_partial_specialization could get a chance to
notice that we're in fact declaring a distinct constrained partial
spec and not redeclaring the primary template. This caused us to
emit a bogus error about differing constraints b/t the primary template
and #2's constraints. This patch fixes this by moving the call to
associate_classtype_constraints after the call to shadow_tag (which
calls maybe_process_partial_specialization) and adjusting shadow_tag to
use the return value of m_p_p_s.
Moreover, if we later try to define a constrained partial specialization
that's been declared earlier (as in the third testcase), then
maybe_new_partial_specialization correctly notices it's a redeclaration
and returns NULL_TREE. But in this case we also need to update TYPE to
point to the redeclared partial spec (it'll otherwise continue pointing
to the primary template type, eventually leading to a bogus error).
PR c++/96363
gcc/cp/ChangeLog:
* decl.cc (shadow_tag): Use the return value of
maybe_process_partial_specialization.
* parser.cc (cp_parser_single_declaration): Call shadow_tag
before associate_classtype_constraints.
* pt.cc (maybe_new_partial_specialization): Change return type
to bool. Take 'type' argument by mutable reference. Set 'type'
to point to the correct constrained specialization when
appropriate.
(maybe_process_partial_specialization): Adjust accordingly.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-partial-spec12.C: New test.
* g++.dg/cpp2a/concepts-partial-spec12a.C: New test.
* g++.dg/cpp2a/concepts-partial-spec13.C: New test.
(cherry picked from commit
97dc78d705a90c1ae83c78a7f2e24942cc3a6257)
Ian Lance Taylor [Wed, 13 Jul 2022 02:42:43 +0000 (19:42 -0700)]
libgo: don't include <linux/fs.h> when building gen-sysinfo.go
Removing this doesn't change anything at least with glibc 2.33.
The include was added in https://go.dev/cl/6100049 but it's not
clear why.
Fixes PR go/106266
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/417294
(cherry picked from commit
f35d65517a59565758107c5b1a51a5fa382f8d1a)
Martin Liska [Mon, 11 Jul 2022 20:03:14 +0000 (22:03 +0200)]
libsanitizer: cherry-pick
9cf13067cb5088626ba7 from upstream
9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
(cherry picked from commit
2701442d0cf6292f6624443c15813d6d1a3562fe)
Jonathan Wakely [Wed, 20 Jul 2022 15:51:44 +0000 (16:51 +0100)]
libstdc++: Fix std::common_iterator assignment [PR100823]
This fixes the following conformance problems reported in the PR:
- Move constructor and move assignment should be defined.
- Copy assignment from a valueless object should be allowed.
Assignment is completely rewritten by this patch, as the previous
version had a number of problems. The converting assignment failed to
handle the case of assigning a new value to a valueless object, which
should work. It only accepted lvalue arguments, so wasn't usable to
implement the move assignment operator. Finally, it enforced the
precondition that the argument is not valueless, which is correct for
the converting assignment but not for the copy assignment.
A new _M_assign member is added to handle all cases of assignment
(copying from an lvalue, moving from an rvalue, and converting from a
different type). The not valueless precondition is checked in the
converting assignment before calling _M_assign, so isn't enforced for
copy and move assignment. The new function no longer uses a switch, so
handles valueless objects as the LHS or RHS of the assignment.
libstdc++-v3/ChangeLog:
PR libstdc++/100823
* include/bits/stl_iterator.h (common_iterator): Define move
constructor and move assignment operator.
(common_iterator::_M_assign): New function implementing
assignment.
(common_iterator::operator=): Use _M_assign.
(common_iterator::_S_valueless): New constant.
* testsuite/24_iterators/common_iterator/100823.cc: New test.
(cherry picked from commit
56c999860bbbb2fd5091ba0985e2e5eaa90c6478)
Jonathan Wakely [Wed, 20 Jul 2022 11:49:28 +0000 (12:49 +0100)]
libstdc++: Fix minor bugs in std::common_iterator
The noexcept-specifier for some std::common_iterator constructors was
incorrectly using an rvalue as the first argument of
std::is_nothrow_assignable_v. This gave the wrong answer for some types,
e.g. std::common_iterator<int*, S>, because an rvalue of scalar type
cannot be assigned to.
Also fix the friend declaration to use the same constraints as on the
definition of the class template. G++ fails to diagnose this error, due
to PR c++/96830.
Finally, the copy constructor was using std::move for its argument
in some cases, which should be removed.
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h (common_iterator): Fix incorrect
uses of is_nothrow_assignable_v. Fix inconsistent constraints on
friend declaration. Do not move argument in copy constructor.
* testsuite/24_iterators/common_iterator/1.cc: Check for
noexcept constructibnle/assignable.
(cherry picked from commit
3b5567c3ec7e5759bdecc6a6fc0be2b65a93636e)
Nathan Sidwell [Tue, 24 May 2022 09:17:18 +0000 (10:17 +0100)]
libstdc++: Make headers include their prerequisites
These headers were relying on their includers having already included
some prerequisites. That makes them unsuitable to be header-units.
So directly include the needed headers.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/hashtable.h: Include required headers.
* include/bits/hashtable_policy.h: Likewise.
* include/bits/stl_heap.h: Likewise.
* include/bits/stl_iterator_base_funcs.h: Likewise.
(cherry picked from commit
a44380541fee1c7ab14cc90a9af8d1aef3c72866)
Jonathan Wakely [Thu, 30 Jun 2022 10:28:23 +0000 (11:28 +0100)]
libstdc++: Fix comment typos
libstdc++-v3/ChangeLog:
* include/bits/utility.h: Fix comment typos.
(cherry picked from commit
c1fe8ddf6847a14152668064f163a2585e9dc894)
Jonathan Wakely [Tue, 28 Jun 2022 08:17:06 +0000 (09:17 +0100)]
libstdc++: testsuite: Guard use of C99 std::log2
This prevents the test from failing if the only thing not supported is
the text printed to the log about the size of the floating-point type.
libstdc++-v3/ChangeLog:
* testsuite/20_util/from_chars/4.cc: Only use log2 if C99 math
functions are available.
(cherry picked from commit
30aea28bd30027e0a6be8e3077828256779954b3)
Jonathan Wakely [Thu, 23 Jun 2022 10:58:16 +0000 (11:58 +0100)]
libstdc++: Simplify test by not using std::log2
This test uses std::log2 without including <cmath>, but it doesn't need
to use it at all. Just get the number of digits from numeric_limits
instead.
libstdc++-v3/ChangeLog:
* testsuite/26_numerics/random/random_device/entropy.cc: Use
numeric_limits<unsigned>::digits.
(cherry picked from commit
78fd15fd4a641cfac28ce60bf43a3e1ca309537b)
Marco Falke [Tue, 19 Jul 2022 09:10:39 +0000 (10:10 +0100)]
libstdc++: Make __from_chars_alnum_to_val conversion explicit
The optimizations from commit r12-8175-ga54137c88061c7 introduced a
clang integer sanitizer error.
Fix this with an explicit static_cast, similar to the fix for PR 96766.
libstdc++-v3/ChangeLog:
* include/std/charconv (__from_chars_alnum_to_val): Replace
implicit conversion from int to unsigned char with explicit
cast.
(cherry picked from commit
20ab3972240aff596a3fa98e9fb09ddc0658fbb3)
Jonathan Wakely [Tue, 28 Jun 2022 14:56:30 +0000 (15:56 +0100)]
libstdc++: Fix experimental::filesystem::status on Windows [PR88881]
Although the Filesystem TS isn't properly supported on Windows (unlike
the C++17 Filesystem lib), most tests do pass. Two of the failures are
due to PR 88881 which was only fixed for std::filesystem not the TS.
This applies the fix to the TS implementation too.
libstdc++-v3/ChangeLog:
PR libstdc++/88881
* src/filesystem/ops.cc (has_trailing_slash): New helper
function.
(fs::status): Strip trailing slashes.
(fs::symlink_status): Likewise.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Clean the environment before each test and use TMP instead of
TMPDIR so the test passes on Windows.
(cherry picked from commit
6c96b14a19a9e6c365eacc59868a866b99f9786d)
Jonathan Wakely [Wed, 8 Jun 2022 09:43:57 +0000 (10:43 +0100)]
libstdc++: Fix lifetime bugs for non-TLS eh_globals [PR105880]
This ensures that the single-threaded fallback buffer eh_globals is not
destroyed during program termination, using the same immortalization
technique used for error category objects.
Also ensure that init._M_init can still be read after init has been
destroyed, by making it a static data member.
libstdc++-v3/ChangeLog:
PR libstdc++/105880
* libsupc++/eh_globals.cc (eh_globals): Ensure constant init and
prevent destruction during termination.
(__eh_globals_init::_M_init): Replace with static member _S_init.
(__cxxabiv1::__cxa_get_globals_fast): Update.
(__cxxabiv1::__cxa_get_globals): Likewise.
(cherry picked from commit
1e65f2ed99024f23c56f7b6a961898bcaa882a92)
GCC Administrator [Thu, 21 Jul 2022 00:19:21 +0000 (00:19 +0000)]
Daily bump.
Harald Anlauf [Wed, 20 Jul 2022 18:40:23 +0000 (20:40 +0200)]
Fortran: fix parsing of omp task affinity iterator clause [PR101330]
gcc/fortran/ChangeLog:
PR fortran/101330
* openmp.cc (gfc_match_iterator): Remove left-over code from
development that could lead to a crash on invalid input.
gcc/testsuite/ChangeLog:
PR fortran/101330
* gfortran.dg/gomp/affinity-clause-7.f90: New test.
(cherry picked from commit
26bbe78f77f73bb66af1ac13d0deec888a3c6510)
GCC Administrator [Wed, 20 Jul 2022 00:19:15 +0000 (00:19 +0000)]
Daily bump.
Marek Polacek [Tue, 19 Jul 2022 18:24:25 +0000 (14:24 -0400)]
c++: fix SIGFPE with -Wclass-memaccess [PR105634]
Here we crash because we attempt to % by 0. Thus fixed.
PR c++/105634
gcc/cp/ChangeLog:
* call.cc (maybe_warn_class_memaccess): Avoid % by zero.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wclass-memaccess-7.C: New test.
Richard Biener [Tue, 19 Jul 2022 07:57:22 +0000 (09:57 +0200)]
middle-end/106331 - fix mem attributes for string op arguments
get_memory_rtx tries hard to come up with a MEM_EXPR to record
in the memory attributes but in the last fallback fails to properly
account for an unknown offset and thus, as visible in this testcase,
incorrect alignment computed from set_mem_attributes. The following
rectifies both parts.
PR middle-end/106331
* builtins.cc (get_memory_rtx): Compute alignment from
the original address and set MEM_OFFSET to unknown when
we create a MEM_EXPR from the base object of the address.
* gfortran.dg/pr106331.f90: New testcase.
(cherry picked from commit
e4ff11a8f2e80adb8ada69bf35ee6a1ab18a9c85)
Richard Biener [Thu, 30 Jun 2022 08:33:40 +0000 (10:33 +0200)]
tree-optimization/106131 - wrong code with FRE rewriting
The following makes sure to not use the original TBAA type for
looking up a value across an aggregate copy when we had to offset
the read.
2022-06-30 Richard Biener <rguenther@suse.de>
PR tree-optimization/106131
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Force alias-set
zero when offsetting the read looking through an aggregate
copy.
* g++.dg/torture/pr106131.C: New testcase.
(cherry picked from commit
9701432ff79926a5dd3303be3417e0bd0c24140b)
Richard Biener [Tue, 28 Jun 2022 11:57:29 +0000 (13:57 +0200)]
tree-optimization/106112 - fix CSE from wider operation
The following fixes a mistake in looking up an extended operand
in the CSE of a truncated operation.
2022-06-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/106112
* tree-ssa-sccvn.cc (valueized_wider_op): Properly extend
a constant operand according to its type.
* gcc.dg/torture/pr106112.c: New testcase.
(cherry picked from commit
2dbb45d6dc0d20dc159b3d8e27ebb6825074827a)
Richard Biener [Mon, 20 Jun 2022 11:40:50 +0000 (13:40 +0200)]
middle-end/106027 - fix types in needle folding
The fold_to_nonsharp_ineq_using_bound folding ends up creating invalid
typed IL which confuses later foldings. The following fixes that.
2022-06-20 Richard Biener <rguenther@suse.de>
PR middle-end/106027
* fold-const.cc (fold_to_nonsharp_ineq_using_bound): Use the
type of the prevailing comparison for the new comparison type.
(fold_binary_loc): Use proper types for the A < X && A + 1 > Y
to A < X && A >= Y folding.
* gcc.dg/pr106027.c: New testcase.
(cherry picked from commit
713f2fd923442b1be620a44240ddf786ae0ab476)
Richard Biener [Wed, 15 Jun 2022 09:27:31 +0000 (11:27 +0200)]
tree-optimization/105971 - less surprising refs_may_alias_p_2
When DSE asks whether __real a is using __imag a it gets a surprising
result when a is a FUNCTION_DECL. The following makes sure this case
is less surprising to callers but keeping the bail-out for the
non-decl case where it is true that PTA doesn't track aliases to code
correctly.
2022-06-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/105971
* tree-ssa-alias.cc (refs_may_alias_p_2): Put bail-out for
FUNCTION_DECL and LABEL_DECL refs after decl-decl disambiguation
to leak less surprising alias results.
* gcc.dg/torture/pr106971.c: New testcase.
(cherry picked from commit
8c2733e16ec1c0cdda3db4cdc5ad158a96a658e8)
Richard Biener [Wed, 15 Jun 2022 08:54:48 +0000 (10:54 +0200)]
tree-optimization/105969 - FPE with array diagnostics
For a [0][0] array we have to be careful when dividing by the element
size which is zero for the outermost dimension. Luckily the division
is only for an overflow check which is pointless for array size zero.
2022-06-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/105969
* gimple-ssa-sprintf.cc (get_origin_and_offset_r): Avoid division
by zero in overflow check.
* gcc.dg/pr105969.c: New testcase.
(cherry picked from commit
edb9330c29fe8a0a0b76df6fafd6a223a4d0e41f)
Richard Biener [Tue, 14 Jun 2022 08:59:49 +0000 (10:59 +0200)]
middle-end/105965 - add missing v_c_e <{ el }> simplification
When we got the simplification of bit-field-ref to view-convert
we lost the ability to detect FMAs since we cannot look through
_1 = {_10};
_11 = VIEW_CONVERT_EXPR<float>(_1);
the following amends the (view_convert CONSTRUCTOR) pattern
to handle this case.
2022-06-14 Richard Biener <rguenther@suse.de>
PR middle-end/105965
* match.pd (view_convert CONSTRUCTOR): Handle single-element
CTOR case.
* gcc.target/i386/pr105965.c: New testcase.
(cherry picked from commit
90467f0ad649d0817f9e034596a0fb85605b55af)
Richard Biener [Tue, 14 Jun 2022 09:10:13 +0000 (11:10 +0200)]
tree-optimization/105946 - avoid accessing excess args from uninit diag
uninit diagnostics uses passing via reference and access attributes
but that iterates over function type arguments which can in some
cases appearantly outrun the actual arguments leading to ICEs.
The following simply ignores not present arguments.
2022-06-14 Richard Biener <rguenther@suse.de>
PR tree-optimization/105946
* tree-ssa-uninit.cc (maybe_warn_pass_by_reference):
Do not look at arguments not specified in the function call.
(cherry picked from commit
e07a876c07601e1f3a27420f7d055d20193c362c)
Richard Biener [Fri, 1 Jul 2022 12:11:35 +0000 (14:11 +0200)]
target/105459 - allow delayed target option node fixup
The following avoids the need to massage the target optimization
node at WPA time when we fixup the optimization node, copying
FP related flags from callee to caller. The target is already
set up to fixup, but that only works when not switching between
functions. After fixing that the fixup is then done at LTRANS
time when materializing the function.
2022-07-01 Richard Biener <rguenthert@suse.de>
PR target/105459
* config/i386/i386-options.cc (ix86_set_current_function):
Rebuild the target optimization node whenever necessary,
not only when the optimization node didn't change.
* gcc.dg/lto/pr105459_0.c: New testcase.
(cherry picked from commit
4c94382a132a4b2b9d020806549a006fa6764d1b)
GCC Administrator [Tue, 19 Jul 2022 00:19:24 +0000 (00:19 +0000)]
Daily bump.
GCC Administrator [Mon, 18 Jul 2022 00:19:06 +0000 (00:19 +0000)]
Daily bump.
GCC Administrator [Sun, 17 Jul 2022 00:19:13 +0000 (00:19 +0000)]
Daily bump.
Steve Kargl [Fri, 15 Jul 2022 20:07:15 +0000 (22:07 +0200)]
Fortran: do not generate conflicting results under -ff2c [PR104313]
gcc/fortran/ChangeLog:
PR fortran/104313
* trans-decl.cc (gfc_generate_return): Do not generate conflicting
fake results for functions with no result variable under -ff2c.
gcc/testsuite/ChangeLog:
PR fortran/104313
* gfortran.dg/pr104313.f: New test.
(cherry picked from commit
517fb1a78102df43f052c6934c27dd51d786aff7)
GCC Administrator [Sat, 16 Jul 2022 00:19:13 +0000 (00:19 +0000)]
Daily bump.
GCC Administrator [Fri, 15 Jul 2022 00:19:21 +0000 (00:19 +0000)]
Daily bump.
Michael Meissner [Thu, 14 Jul 2022 15:16:08 +0000 (11:16 -0400)]
[BACKPORT] Disable generating load/store vector pairs for block copies.
Testing has found that using load and store vector pair for block copies
can result in a slow down on power10. This patch disables using the
vector pair instructions for block copies if we are tuning for power10.
2022-06-11 Michael Meissner <meissner@linux.ibm.com>
gcc/
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Do
not generate block copies with vector pair instructions if we are
tuning for power10. Back port from master branch.
Surya Kumari Jangala [Fri, 10 Jun 2022 14:22:57 +0000 (19:52 +0530)]
regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041]
In check_new_reg_p, the nregs of a du chain is computed by obtaining the
MODE of the first element in the chain, and then calling
hard_regno_nregs() with the MODE. But the first element of the chain can
be a DEBUG_INSN whose mode need not be the same as the rest of the
elements in the du chain. This was resulting in fcompare-debug failure
as check_new_reg_p was returning a different result with -g for the same
candidate register. We can instead obtain nregs from the du chain
itself.
2022-06-10 Surya Kumari Jangala <jskumari@linux.ibm.com>
gcc/
PR rtl-optimization/105041
* regrename.cc (check_new_reg_p): Use nregs value from du chain.
gcc/testsuite/
PR rtl-optimization/105041
* gcc.target/powerpc/pr105041.c: New test.
(cherry picked from commit
3e16b4359e86b36676ed01219e6deafa95f3c16b)
GCC Administrator [Thu, 14 Jul 2022 00:19:28 +0000 (00:19 +0000)]
Daily bump.
GCC Administrator [Wed, 13 Jul 2022 00:19:15 +0000 (00:19 +0000)]
Daily bump.
GCC Administrator [Tue, 12 Jul 2022 00:19:05 +0000 (00:19 +0000)]
Daily bump.
Martin Jambor [Mon, 11 Jul 2022 16:43:23 +0000 (18:43 +0200)]
tree-sra: Fix union handling in build_reconstructed_reference
As the testcase in PR 105860 shows, the code that tries to re-use the
handled_component chains in SRA can be horribly confused by unions,
where it thinks it has found a compatible structure under which it can
chain the references, but in fact it found the type it was looking
for elsewhere in a union and generated a write to a completely wrong
part of an aggregate.
I don't remember whether the plan was to support unions at all in
build_reconstructed_reference but it can work, to an extent, if we
make sure that we start the search only outside the outermost union,
which is what the patch does (and the extra testcase verifies).
Additionally, this commit also contains sqashed in it a backport of
b984b84cbe4bf026edef2ba37685f3958a1dc1cf which fixes the testcase
gcc.dg/tree-ssa/alias-access-path-13.c for many 32-bit targets.
gcc/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* tree-sra.cc (build_reconstructed_reference): Start expr
traversal only just below the outermost union.
gcc/testsuite/ChangeLog:
2022-07-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/105860
* gcc.dg/tree-ssa/alias-access-path-13.c: New test.
* gcc.dg/tree-ssa/pr105860.c: Likewise.
(cherry picked from commit
b110e5283e368b5377e04766e4ff82cd52634208)
GCC Administrator [Mon, 11 Jul 2022 00:19:21 +0000 (00:19 +0000)]
Daily bump.
Xi Ruoyao [Fri, 8 Jul 2022 13:09:25 +0000 (21:09 +0800)]
loongarch: fix mulsidi3_64bit instruction
(mult (sign_extend:DI rj:SI) (sign_extend:DI rk:SI)) should be
"mulw.d.w", not "mul.d".
gcc/ChangeLog:
* config/loongarch/loongarch.md (mulsidi3_64bit): Use mulw.d.w
instead of mul.d.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/mulw_d_w.c: New test.
* gcc.c-torture/execute/mul-sext.c: New test.
(cherry picked from commit
1fa42d62140b56589771eb3d46f89c810bfc8e0a)
GCC Administrator [Sun, 10 Jul 2022 00:19:06 +0000 (00:19 +0000)]
Daily bump.
Roger Sayle [Sat, 9 Jul 2022 11:38:12 +0000 (12:38 +0100)]
PR target/105930: Split *xordi3_doubleword after reload on x86.
This is a backport of the fix for PR target/105930 from mainline to the
gcc12 release branch.
2022-07-09 Roger Sayle <roger@nextmovesoftware.com>
Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog
PR target/105930
* config/i386/i386.md (*<any_or>di3_doubleword): Split after
reload. Use rtx_equal_p to avoid creating memory-to-memory moves,
and emit NOTE_INSN_DELETED if operand[2] is zero (i.e. with -O0).
GCC Administrator [Sat, 9 Jul 2022 00:19:34 +0000 (00:19 +0000)]
Daily bump.
Lulu Cheng [Thu, 7 Jul 2022 10:07:28 +0000 (18:07 +0800)]
LoongArch: Modify fp_sp_offset and gp_sp_offset's calculation method when frame->mask or frame->fmask is zero.
Under the LA architecture, when the stack is dropped too far, the process
of dropping the stack is divided into two steps.
step1: After dropping the stack, save callee saved registers on the stack.
step2: The rest of it.
The stack drop operation is optimized when frame->total_size minus
frame->sp_fp_offset is an integer multiple of 4096, can reduce the number
of instructions required to drop the stack. However, this optimization is
not effective because of the original calculation method
The following case:
int main()
{
char buf[1024 * 12];
printf ("%p\n", buf);
return 0;
}
As you can see from the generated assembler, the old GCC has two more
instructions than the new GCC, lines 14 and line 24.
new old
10 main: | 11 main:
11 addi.d $r3,$r3,-16 | 12 lu12i.w $r13,-12288>>12
12 lu12i.w $r13,-12288>>12 | 13 addi.d $r3,$r3,-2032
13 lu12i.w $r5,-12288>>12 | 14 ori $r13,$r13,2016
14 lu12i.w $r12,12288>>12 | 15 lu12i.w $r5,-12288>>12
15 st.d $r1,$r3,8 | 16 lu12i.w $r12,12288>>12
16 add.d $r12,$r12,$r5 | 17 st.d $r1,$r3,2024
17 add.d $r3,$r3,$r13 | 18 add.d $r12,$r12,$r5
18 add.d $r5,$r12,$r3 | 19 add.d $r3,$r3,$r13
19 la.local $r4,.LC0 | 20 add.d $r5,$r12,$r3
20 bl %plt(printf) | 21 la.local $r4,.LC0
21 lu12i.w $r13,12288>>12 | 22 bl %plt(printf)
22 add.d $r3,$r3,$r13 | 23 lu12i.w $r13,8192>>12
23 ld.d $r1,$r3,8 | 24 ori $r13,$r13,2080
24 or $r4,$r0,$r0 | 25 add.d $r3,$r3,$r13
25 addi.d $r3,$r3,16 | 26 ld.d $r1,$r3,2024
26 jr $r1 | 27 or $r4,$r0,$r0
| 28 addi.d $r3,$r3,2032
| 29 jr $r1
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_compute_frame_info):
Modify fp_sp_offset and gp_sp_offset's calculation method,
when frame->mask or frame->fmask is zero, don't minus UNITS_PER_WORD
or UNITS_PER_FP_REG.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/prolog-opt.c: New test.
(cherry picked from commit
aa8fd7f65683ef9c3b6d2e9306bea2f28b5cadf7)
GCC Administrator [Fri, 8 Jul 2022 00:19:15 +0000 (00:19 +0000)]
Daily bump.
Jonathan Wakely [Fri, 1 Jul 2022 21:23:43 +0000 (22:23 +0100)]
libstdc++: Add missing prerequisite to generated header [PR106162]
The ${host_builddir}/largefile-config.h header can't be written until
its parent directory has been created, so it needs to have the creation
of that directory as a prerequisite.
libstdc++-v3/ChangeLog:
PR libstdc++/106162
* include/Makefile.am (largefile-config.h): Add
stamp-${host_alias} prerequisite.
* include/Makefile.in: Regenerate.
(cherry picked from commit
8a6ee426c2be3bd4359520e02c00ec60cac2fece)
Jonathan Wakely [Thu, 23 Jun 2022 13:25:49 +0000 (14:25 +0100)]
libstdc++: Properly remove temporary directories in filesystem tests
Although these tests use filesystem::remove_all to clean up, that fails
because it uses recursive_directory_iterator which is intentionally
bodged by the custom readdir defined in the test.
Just use POSIX rmdir to clean up. We don't need to use _rmdir or _wrmdir
for Windows, because we'll never reach test02() on targets where the
custom readdir doesn't interpose the one from libc.
libstdc++-v3/ChangeLog:
* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
rmdir to remove directories.
* testsuite/experimental/filesystem/iterators/error_reporting.cc:
Likewise.
(cherry picked from commit
7c1c7e120cca183671b11ba68a6350c8800823c0)
GCC Administrator [Thu, 7 Jul 2022 00:19:11 +0000 (00:19 +0000)]
Daily bump.
Jonathan Wakely [Wed, 29 Jun 2022 22:41:46 +0000 (23:41 +0100)]
c-family: Add <time.h> names to diagnostics for known headers
gcc/c-family/ChangeLog:
* known-headers.cc (get_stdlib_header_for_name): Add <time.h>
names.
gcc/testsuite/ChangeLog:
* g++.dg/spellcheck-stdlib.C: Check <ctime> types and functions.
(cherry picked from commit
d489ec082ea214109ff54071410f8cd00344e654)
Marek Polacek [Tue, 5 Jul 2022 18:22:26 +0000 (14:22 -0400)]
c-family: Prevent -Wformat warnings with u8 strings [PR105626]
The <https://gcc.gnu.org/pipermail/gcc/2022-May/238679.html> thread
seems to have concluded that -Wformat shouldn't warn about
printf((const char*) u8"test %d\n", 1);
saying "format string is not an array of type 'char'". This code
is not an aliasing violation, and there are no I/O functions for u8
strings, so the const char * cast is OK and shouldn't be disregarded.
PR c++/105626
gcc/c-family/ChangeLog:
* c-format.cc (check_format_arg): Don't emit -Wformat warnings with
u8 strings.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wformat-char8_t-1.C: New test.
(cherry picked from commit
543828e79bfa63ef26b11a2c9ea81fd7905f33aa)
GCC Administrator [Wed, 6 Jul 2022 00:19:23 +0000 (00:19 +0000)]
Daily bump.
GCC Administrator [Tue, 5 Jul 2022 00:19:34 +0000 (00:19 +0000)]
Daily bump.
Andrew MacLeod [Mon, 4 Jul 2022 15:21:34 +0000 (11:21 -0400)]
Don't use gori depedencies to optimize.
The routine fold_using_range::relation_fold_and_or needs to verify that both
operands of 2 stmts are the same, and uses GORIs dependency cache for this.
This cache cannot be counted on to reflect the current contents of a
stmt, expecially in the presence of an IL changing pass. Instead, look at the
statement operands.
PR tree-optimization/106114
gcc/
* gimple-range-fold.cc (fold_using_range::relation_fold_and_or): Check
statement operands instead of GORI cache.
gcc/testsuite/
* gcc.dg/pr106114.c: New.
Iain Buclaw [Wed, 29 Jun 2022 19:52:39 +0000 (21:52 +0200)]
d: Fix error: aggregate value used where floating point was expected
Casting from vector to static array is permitted, and the frontend
generates a reinterpret cast, but casting back the other way resulted in
an error. This has been fixed to be properly handled in the code
generation pass of VectorExp, and the conversion for lvalue and rvalue
handling done in convert_expr and convert_for_rvalue respectively.
PR d/106139
gcc/d/ChangeLog:
* d-convert.cc (convert_expr): Handle casting from array to vector.
(convert_for_rvalue): Rewrite vector to array casts of the same
element type into a constructor.
(convert_for_assignment): Return calling convert_for_rvalue.
* expr.cc (ExprVisitor::visit (VectorExp *)): Handle generating a
vector expression from a static array.
* toir.cc (IRVisitor::visit (ReturnStatement *)): Call
convert_for_rvalue on return value.
gcc/testsuite/ChangeLog:
* gdc.dg/pr106139a.d: New test.
* gdc.dg/pr106139b.d: New test.
* gdc.dg/pr106139c.d: New test.
* gdc.dg/pr106139d.d: New test.
(cherry picked from commit
329bef49da30158d30fed1106002bb71674776bd)
Roger Sayle [Mon, 4 Jul 2022 12:58:37 +0000 (13:58 +0100)]
PR target/105991: Recognize PLUS and XOR forms of rldimi in rs6000.md.
This patch addresses PR target/105991 where a change to prefer representing
shifts and adds at the tree-level as multiplications, causes problems for
the rldimi patterns in the powerpc backend. The issue is that rs6000.md
models this pattern using IOR, and some variants that have the equivalent
PLUS or XOR in the RTL fail to match some *rotl<mode>4_insert patterns.
This is fixed in this patch by adding a define_insn_and_split to locally
canonicalize the PLUS and XOR forms to the backend's preferred IOR form.
Backported from master.
2022-07-04 Roger Sayle <roger@nextmovesoftware.com>
Marek Polacek <polacek@redhat.com>
Segher Boessenkool <segher@kernel.crashing.org>
Kewen Lin <linkw@linux.ibm.com>
gcc/ChangeLog
PR target/105991
* config/rs6000/rs6000.md (rotl<mode>3_insert_3): Check that
exact_log2 doesn't return -1 (or zero).
(plus_xor): New code iterator.
(*rotl<mode>3_insert_3_<code>): New define_insn_and_split.
gcc/testsuite/ChangeLog
PR target/105991
* gcc.target/powerpc/pr105991.c: New test case.
Xi Ruoyao [Sat, 2 Jul 2022 08:16:44 +0000 (16:16 +0800)]
loongarch: use -mno-check-zero-division as the default for optimized code
Integer division by zero is undefined behavior anyway, and there are
already many platforms where neither the GCC port and the hardware do
anything to trap on division by zero. So any portable program shall not
rely on SIGFPE on division by zero, in both theory and practice. As the
result, there is no real reason to cost two additional instructions just
for the trap on division by zero with a new ISA.
One remaining reason to trap on division by zero may be debugging,
especially while -fsanitize=integer-divide-by-zero is not implemented
for LoongArch yet. To make debugging easier, keep -mcheck-zero-division
as the default for -O0 and -Og, but use -mno-check-zero-division as the
default for all other optimization levels.
Backport this behavior change for 12.2, so 12.1 will be the only release
with a different default.
Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_check_zero_div_p):
New static function.
(loongarch_idiv_insns): Use loongarch_check_zero_div_p instead
of TARGET_CHECK_ZERO_DIV.
(loongarch_output_division): Likewise.
* common/config/loongarch/loongarch-common.cc
(TARGET_DEFAULT_TARGET_FLAGS): Remove unneeded hook.
* doc/invoke.texi: Update to match the new behavior.
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/
20101011-1.c (dg-additional-options):
add -mcheck-zero-division for LoongArch targets.
(cherry picked from commit
f150dc1bd11802b70277f0fa209f2d23695a1095)
GCC Administrator [Mon, 4 Jul 2022 00:19:07 +0000 (00:19 +0000)]
Daily bump.
Harald Anlauf [Wed, 29 Jun 2022 19:36:17 +0000 (21:36 +0200)]
Fortran: error recovery on invalid CLASS(), PARAMETER declarations [PR105243]
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* decl.cc (gfc_match_data_decl): Reject CLASS entity declaration
when it is given the PARAMETER attribute.
gcc/testsuite/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* gfortran.dg/class_58.f90: Fix test.
* gfortran.dg/class_73.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit
4c233cabbe388a6b8957c1507e129090e9267ceb)
Harald Anlauf [Tue, 28 Jun 2022 20:29:28 +0000 (22:29 +0200)]
Fortran: improve error recovery for EXTENDS_TYPE_OF() [PR106121]
gcc/fortran/ChangeLog:
PR fortran/106121
* simplify.cc (gfc_simplify_extends_type_of): Do not attempt to
simplify when one of the arguments is a CLASS variable that was
not properly declared.
gcc/testsuite/ChangeLog:
PR fortran/106121
* gfortran.dg/extends_type_of_4.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit
b8f284d3673004dffae714b56ed663467c2a52a7)
Roger Sayle [Sun, 3 Jul 2022 13:01:17 +0000 (14:01 +0100)]
PR target/106122: Don't update %esp via the stack with -Oz on x86.
When optimizing for size with -Oz, setting a register can be minimized by
pushing an immediate value to the stack and popping it to the destination.
Alas the one general register that shouldn't be updated via the stack is
the stack pointer itself, where "pop %esp" can't be represented in GCC's
RTL ("use of a register mentioned in pre_inc, pre_dec, post_inc or
post_dec is not permitted within the same instruction"). This patch
fixes PR target/106122 by explicitly checking for SP_REG in the
problematic peephole2.
2022-07-O3 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/106122
* config/i386/i386.md (peephole2): Avoid generating pop %esp
when optimizing for size.
gcc/testsuite/ChangeLog
PR target/106122
* gcc.target/i386/pr106122.c: New test case.
GCC Administrator [Sun, 3 Jul 2022 00:19:11 +0000 (00:19 +0000)]
Daily bump.
Sergei Trofimovich [Mon, 27 Jun 2022 22:42:44 +0000 (23:42 +0100)]
jit: avoid calloc() poisoning on musl [PR106102]
On musl <pthread.h> uses calloc() (via <sched.h>). jit/ includes
it directly and exposes use of poisoned calloc():
/build/build/./prev-gcc/xg++ ... ../../gcc-13-
20220626/gcc/jit/jit-playback.cc
make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1
make[3]: *** Waiting for unfinished jobs....
In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
from ../../gcc-13-
20220626/gcc/jit/jit-playback.cc:44:
/<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
84 | void *calloc(size_t, size_t);
| ^
/<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
| ^
The change moves <pthread.h> inclusion to "system.h" under new
INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit.
gcc/
PR c++/106102
* system.h: Introduce INCLUDE_PTHREAD_H macros to include <pthread.h>.
gcc/jit/
PR c++/106102
* jit-playback.cc: Include <pthread.h> via "system.h" to avoid calloc()
poisoning.
* jit-recording.cc: Ditto.
* libgccjit.cc: Ditto.
(cherry picked from commit
49d508065bdd36fb1a9b6aad9666b1edb5e06474)
Sergei Trofimovich [Mon, 27 Jun 2022 12:27:24 +0000 (13:27 +0100)]
c++: avoid <memory> poisoning on musl [PR106102]
On musl <pthread.h> uses calloc() (via <sched.h>). <memory> includes
it indirectly and exposes use of poisoned calloc() when module code
is built:
/build/build/./prev-gcc/xg++ ... ../../gcc-13-
20220626/gcc/cp/mapper-resolver.cc
In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35,
....
from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77,
from ../../gcc-13-
20220626/gcc/../libcody/cody.hh:24,
from ../../gcc-13-
20220626/gcc/cp/../../c++tools/resolver.h:25,
from ../../gcc-13-
20220626/gcc/cp/../../c++tools/resolver.cc:23,
from ../../gcc-13-
20220626/gcc/cp/mapper-resolver.cc:32:
/<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
84 | void *calloc(size_t, size_t);
| ^
/<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
| ^
gcc/cp/
PR c++/106102
* mapper-client.cc: Include <memory> via "system.h".
* mapper-resolver.cc: Ditto.
* module.cc: Ditto.
libcc1/
PR c++/106102
* libcc1plugin.cc: Include <memory> via "system.h".
* libcp1plugin.cc: Ditto.
(cherry picked from commit
3b21c21f3f5726823e19728fdd1571a14aae0fb3)
GCC Administrator [Sat, 2 Jul 2022 00:19:15 +0000 (00:19 +0000)]
Daily bump.
Jason Merrill [Fri, 1 Jul 2022 15:02:54 +0000 (11:02 -0400)]
c++: simpler fix for PR106024
Actually, for release branches let's just avoid the lookup for the lambdas
that are the problematic case and only make the bigger change on trunk.
PR c++/106024
gcc/cp/ChangeLog:
* parser.cc (cp_parser_lookup_name): Limit previous change to
lambdas.
Vladimir Makarov [Sat, 28 May 2022 18:08:38 +0000 (12:08 -0600)]
Fix ICE on sh
gcc/
PR target/103722
* config/sh/sh.cc (sh_register_move_cost): Avoid cost "2" (which
is special) for various scenarios.
(cherry picked from commit
ce1580252ea57de23a595e9804ea87ed4353aa6a)
Jason Merrill [Wed, 11 May 2022 18:53:26 +0000 (14:53 -0400)]
c++: lambda template in requires [PR105541]
Since the patch for PR103408, the template parameters for the lambda in this
test have level 1 instead of 2, and we were treating null template args as 1
level of arguments, so tsubst_template_parms decided it had nothing to do.
Fixed by distinguishing between <> and no args at all, which is what we have
in our "substitution" in a requires-expression.
PR c++/105541
gcc/cp/ChangeLog:
* cp-tree.h (TMPL_ARGS_DEPTH): 0 for null args.
* parser.cc (cp_parser_enclosed_template_argument_list):
Use 0-length TREE_VEC for <>.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/lambda-requires1.C: New test.
Jason Merrill [Fri, 1 Jul 2022 04:37:10 +0000 (00:37 -0400)]
c++: tweak resolve_args change
I don't know why I used tf_error instead of complain here.
PR c++/105779
gcc/cp/ChangeLog:
* call.cc (resolve_args): Use complain.
Jason Merrill [Fri, 24 Jun 2022 03:14:35 +0000 (23:14 -0400)]
c++: dependent generic lambda template-id [PR106024]
We were wrongly looking up the generic lambda op() in a dependent scope, and
then trying to look up its instantiation at substitution time, but lambdas
aren't instantiated, so we crashed. The fix is to not look into dependent
class scopes.
But this created trouble with wrongly trying to use a template from the
enclosing scope when we aren't actually looking at a template-argument-list,
in template/lookup18.C, so let's avoid that.
PR c++/106024
gcc/cp/ChangeLog:
* parser.cc (missing_template_diag): Factor out...
(cp_parser_id_expression): ...from here.
(cp_parser_lookup_name): Don't look in dependent object_type.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/lambda-generic10.C: New test.
GCC Administrator [Fri, 1 Jul 2022 00:19:20 +0000 (00:19 +0000)]
Daily bump.
Harald Anlauf [Mon, 20 Jun 2022 18:59:55 +0000 (20:59 +0200)]
Fortran: handle explicit-shape specs with constant bounds [PR105954]
gcc/fortran/ChangeLog:
PR fortran/105954
* decl.cc (variable_decl): Adjust upper bounds for explicit-shape
specs with constant bound expressions to ensure non-negative
extents.
gcc/testsuite/ChangeLog:
PR fortran/105954
* gfortran.dg/pr105954.f90: New test.
(cherry picked from commit
a312407bd715647f7c11b67e0a52effc94d0f15d)
Harald Anlauf [Tue, 21 Jun 2022 21:20:18 +0000 (23:20 +0200)]
Fortran: fix simplification of INDEX(str1,str2) [PR105691]
gcc/fortran/ChangeLog:
PR fortran/105691
* simplify.cc (gfc_simplify_index): Replace old simplification
code by the equivalent of the runtime library implementation. Use
HOST_WIDE_INT instead of int for string index, length variables.
gcc/testsuite/ChangeLog:
PR fortran/105691
* gfortran.dg/index_6.f90: New test.
(cherry picked from commit
ff35dbc02092fbcd3d814fcd9fe8e871c3f741fd)
Harald Anlauf [Fri, 24 Jun 2022 20:21:39 +0000 (22:21 +0200)]
Fortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813]
gcc/fortran/ChangeLog:
PR fortran/105813
* check.cc (gfc_check_unpack): Try to simplify MASK argument to
UNPACK so that checking of the VECTOR argument can work when MASK
is a variable.
gcc/testsuite/ChangeLog:
PR fortran/105813
* gfortran.dg/unpack_vector_1.f90: New test.
(cherry picked from commit
f21f17f95c0237f4f987a5fa9f1fa9c7e0db3c40)
GCC Administrator [Thu, 30 Jun 2022 00:19:11 +0000 (00:19 +0000)]
Daily bump.
Martin Liska [Wed, 29 Jun 2022 13:28:07 +0000 (15:28 +0200)]
libsanitizer: cherry-pick
791e0d1bc85d
791e0d1bc85d: [compiler-rt] Add NO_EXEC_STACK_DIRECTIVE on s390x
(cherry picked from commit
aa87b7541b4c11f59c521154513f844ea6b5c977)
Richard Biener [Wed, 11 May 2022 08:47:34 +0000 (10:47 +0200)]
bootstrap/105551 - restore nvptx build
The following makes sure to disable var-tracking if only
dwarf2-line debuginfo is present.
2022-05-11 Richard Biener <rguenther@suse.de>
PR bootstrap/105551
* opts.cc (finish_options): Also disable var-tracking if
!DWARF2_DEBUGGING_INFO.
(cherry picked from commit
e7d9fdf5e0ee4c34a880139254340b4165016289)
Lulu Cheng [Mon, 27 Jun 2022 08:26:25 +0000 (16:26 +0800)]
LoongArch: Remove undefined behavior from code [PR 106097]
C++2017 and previous standard description:
The value of E1 << E2 is E1 left-shifted E2 bit positions;
vacated bits are zero-filled. If E1 has an unsigned type,
the value of the result is E1×2E2, reduced modulo one more
than the maximum value representable inthe result type.
Otherwise, if E1 has a signed type and non-negative value,
and E1×2E2 is representablein the corresponding unsigned
type of the result type, then that value, converted to the
result type, is the resulting value; otherwise, the behavior
is undefined.
The value of E1 >> E2 is E1 right-shifted E2 bit positions.
If E1 has an unsigned type or if E1 has a signed type and
a non-negative value, the value of the result is the integral
part of the quotient of E1/2E2. If E1 has a signed type and
a negative value, the resulting value is implementation-defined.
gcc/ChangeLog:
PR target/106097
* config/loongarch/loongarch.cc (loongarch_build_integer):
Remove undefined behavior from code.
(cherry picked from commit
43653547e7c8da2cd861bceb4a3e4bd338787ced)
GCC Administrator [Wed, 29 Jun 2022 00:19:26 +0000 (00:19 +0000)]
Daily bump.
Jakub Jelinek [Tue, 21 Jun 2022 09:40:16 +0000 (11:40 +0200)]
ifcvt: Don't introduce trapping or faulting reads in noce_try_sign_mask [PR106032]
noce_try_sign_mask as documented will optimize
if (c < 0)
x = t;
else
x = 0;
into x = (c >> bitsm1) & t;
The optimization is done if either t is unconditional
(e.g. for
x = t;
if (c >= 0)
x = 0;
) or if it is cheap. We already check that t doesn't have side-effects,
but if t is conditional, we need to punt also if it may trap or fault,
as we make it unconditional.
I've briefly skimmed other noce_try* optimizations and didn't find one that
would suffer from the same problem.
2022-06-21 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/106032
* ifcvt.cc (noce_try_sign_mask): Punt if !t_unconditional, and
t may_trap_or_fault_p, even if it is cheap.
* gcc.c-torture/execute/pr106032.c: New test.
(cherry picked from commit
a0c30fe3b888f20215f3e040d21b62b603804ca9)
Jakub Jelinek [Tue, 21 Jun 2022 09:38:59 +0000 (11:38 +0200)]
expand: Fix up expand_cond_expr_using_cmove [PR106030]
If expand_cond_expr_using_cmove can't find a cmove optab for a particular
mode, it tries to promote the mode and perform the cmove in the promoted
mode.
The testcase in the patch ICEs on arm because in that case we pass temp which
has the promoted mode (SImode) as target to expand_operands where the
operands have the non-promoted mode (QImode).
Later on the function uses paradoxical subregs:
if (GET_MODE (op1) != mode)
op1 = gen_lowpart (mode, op1);
if (GET_MODE (op2) != mode)
op2 = gen_lowpart (mode, op2);
to change the operand modes.
The following patch fixes it by passing NULL_RTX as target if it has
promoted mode.
2022-06-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/106030
* expr.cc (expand_cond_expr_using_cmove): Pass NULL_RTX instead of
temp to expand_operands if mode has been promoted.
* gcc.c-torture/compile/pr106030.c: New test.
(cherry picked from commit
2df1df945fac85d7b3d084001414a66a2709d8fe)