]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 years agoDaily bump.
GCC Administrator [Thu, 14 Apr 2022 00:19:04 +0000 (00:19 +0000)] 
Daily bump.

3 years agoi386: Fix ICE caused by ix86_emit_i387_log1p [PR105214]
Jakub Jelinek [Tue, 12 Apr 2022 07:19:11 +0000 (09:19 +0200)] 
i386: Fix ICE caused by ix86_emit_i387_log1p [PR105214]

The following testcase ICEs, because ix86_emit_i387_log1p attempts to
emit something like
  if (cond)
    some_code1;
  else
    some_code2;
and emits a conditional jump using emit_jump_insn (standard way in
the file) and an unconditional jump using emit_jump.
The problem with that is that if there is pending stack adjustment,
it isn't emitted before the conditional jump, but is before the
unconditional jump and therefore stack is adjusted only conditionally
(at the end of some_code1 above), which makes dwarf2 pass unhappy about it
but is a serious wrong-code even if it doesn't ICE.

This can be fixed either by emitting pending stack adjust before the
conditional jump as the following patch does, or by not using
  emit_jump (label2);
and instead hand inlining what that function does except for the
pending stack adjustment, like:
  emit_jump_insn (targetm.gen_jump (label2));
  emit_barrier ();
In that case there will be no stack adjustment in the sequence and
it will be done later on somewhere else.

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

PR target/105214
* config/i386/i386-expand.c (ix86_emit_i387_log1p): Call
do_pending_stack_adjust.

* gcc.dg/asan/pr105214.c: New test.

(cherry picked from commit d481d13786cb84f6294833538133dbd6f39d2e55)

3 years agobuiltins: Fix up expand_builtin_int_roundingfn_2 [PR105211]
Jakub Jelinek [Tue, 12 Apr 2022 07:16:06 +0000 (09:16 +0200)] 
builtins: Fix up expand_builtin_int_roundingfn_2 [PR105211]

The expansion of __builtin_iround{,f,l} etc. builtins in some cases
emits calls to a different fallback builtin.  To locate the right builtin
it uses mathfn_built_in_1 with the type of the first argument.
If its TYPE_MAIN_VARIANT is {float,double,long_double}_type_node, all is
fine, but on the following testcase, because GIMPLE considers scalar
float conversions between types with the same mode as useless,
TYPE_MAIN_VARIANT of the arg's type is float32_type_node and because there
isn't __builtin_lroundf32 returns NULL and we ICE.

This patch will first try the type of the first argument of the builtin's
prototype (so that say on sizeof(double)==sizeof(long double) target it honors
whether it was a *l or non-*l call; though even that can't be 100% trusted,
user could incorrectly prototype it) and as fallback the type argument.
If neither works, doesn't fallback.

2022-04-11  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/105211
* builtins.c (expand_builtin_int_roundingfn_2): If mathfn_built_in_1
fails for TREE_TYPE (arg), retry it with
TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl))) and if even that
fails, emit call normally.

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

(cherry picked from commit 91a38e8a848c61b2e23ee277306dc8cd194d135b)

3 years agoc-family: Initialize ridpointers for __int128 etc. [PR105186]
Jakub Jelinek [Mon, 11 Apr 2022 08:41:07 +0000 (10:41 +0200)] 
c-family: Initialize ridpointers for __int128 etc. [PR105186]

The following testcase ICEs with C++ and is incorrectly rejected with C.
The reason is that both FEs use ridpointers identifiers for CPP_KEYWORD
and value or u.value for CPP_NAME e.g. when parsing attributes or OpenMP
directives etc., like:
         /* Save away the identifier that indicates which attribute
            this is.  */
         identifier = (token->type == CPP_KEYWORD)
           /* For keywords, use the canonical spelling, not the
              parsed identifier.  */
           ? ridpointers[(int) token->keyword]
           : id_token->u.value;

         identifier = canonicalize_attr_name (identifier);
I've tried to change those to use ridpointers only if non-NULL and otherwise
use the value/u.value even for CPP_KEYWORDS, but that was a large 10 hunks
patch.

The following patch instead just initializes ridpointers for the __intNN
keywords.  It can't be done earlier before we record_builtin_type as there
are 2 different spellings and if we initialize those ridpointers early, the
second record_builtin_type fails miserably.

2022-04-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/105186
* c-common.c (c_common_nodes_and_builtins): After registering __int%d
and __int%d__ builtin types, initialize corresponding ridpointers
entry.

* c-c++-common/pr105186.c: New test.

(cherry picked from commit 083e8e66d2e90992fa83a53bfc3553dfa91abda1)

3 years agofold-const: Fix up make_range_step [PR105189]
Jakub Jelinek [Fri, 8 Apr 2022 07:14:44 +0000 (09:14 +0200)] 
fold-const: Fix up make_range_step [PR105189]

The following testcase is miscompiled, because fold_truth_andor
incorrectly folds
(unsigned) foo () >= 0U && 1
into
foo () >= 0
For the unsigned comparison (which is useless in this case,
as >= 0U is always true, but hasn't been folded yet), previous
make_range_step derives exp (unsigned) foo () and +[0U, -]
range for it.  Next we process the NOP_EXPR.  We have special code
for unsigned to signed casts, already earlier punt if low or high
aren't representable in arg0_type or if it is a narrowing conversion.
For the signed to unsigned casts, I think if high is specified we
are still fine, as we punt for non-representable values in arg0_type,
n_high is then still representable and so was smaller or equal to
signed maximum and either low is not present (equivalent to 0U), or
low must be smaller or equal to high and so for unsigned exp
+[low, high] the signed exp +[n_low, n_high] will be correct.
Similarly, if both low and high aren't specified (always true or
always false), it is ok too.
But if we have for unsigned exp +[low, -] or -[low, -], using
+[n_low, -] or -[n_high, -] is incorrect.  Because low is smaller
or equal to signed maximum and high is unspecified (i.e. unsigned
maximum), when signed that range is a union of +[n_low, -] and
+[-, -1] which is equivalent to -[0, n_low-1], unless low
is 0, in that case we can treat it as [-, -].

2022-04-08  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/105189
* fold-const.c (make_range_step): Fix up handling of
(unsigned) x +[low, -] ranges for signed x if low fits into
typeof (x).

* g++.dg/torture/pr105189.C: New test.

(cherry picked from commit 5e6597064b0c7eb93b8f720afc4aa970eefb0628)

3 years agocombine: Don't record for UNDO_MODE pointers into regno_reg_rtx array [PR104985]
Jakub Jelinek [Wed, 6 Apr 2022 16:42:52 +0000 (18:42 +0200)] 
combine: Don't record for UNDO_MODE pointers into regno_reg_rtx array [PR104985]

The testcase in the PR fails under valgrind on mips64 (but only Martin
can reproduce, I couldn't).
But the problem reported there is that SUBST_MODE remembers addresses
into the regno_reg_rtx array, then some splitter needs a new pseudo
and calls gen_reg_rtx, which reallocates the regno_reg_rtx array
and finally undo operation is done and dereferences the old regno_reg_rtx
entry.
The rtx values stored in regno_reg_rtx array seems to be created
by gen_reg_rtx only and since then aren't modified, all we do for it
is adjusting its fields (e.g. adjust_reg_mode that SUBST_MODE does).

So, I think it is useless to use where.r for UNDO_MODE and store
&regno_reg_rtx[regno] in struct undo, we can store just
regno_reg_rtx[regno] (i.e. pointer to the REG itself instead of
pointer to pointer to REG) or could also store just the regno.

The following patch does the latter, and because SUBST_MODE no longer
needs to be a macro, changes all SUBST_MODE uses to subst_mode.

2022-04-06  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/104985
* combine.c (struct undo): Add where.regno member.
(do_SUBST_MODE): Rename to ...
(subst_mode): ... this.  Change first argument from rtx * into int,
operate on regno_reg_rtx[regno] and save regno into where.regno.
(SUBST_MODE): Remove.
(try_combine): Use subst_mode instead of SUBST_MODE, change first
argument from regno_reg_rtx[whatever] to whatever.  For UNDO_MODE, use
regno_reg_rtx[undo->where.regno] instead of *undo->where.r.
(undo_to_marker): For UNDO_MODE, use regno_reg_rtx[undo->where.regno]
instead of *undo->where.r.
(simplify_set): Use subst_mode instead of SUBST_MODE, change first
argument from regno_reg_rtx[whatever] to whatever.

(cherry picked from commit 61bee6aed26eb30b798c75b9a595c9d51e080442)

3 years agoDaily bump.
GCC Administrator [Wed, 13 Apr 2022 00:18:25 +0000 (00:18 +0000)] 
Daily bump.

3 years agoc++: treat NON_DEPENDENT_EXPR as not potentially constant [PR104507]
Patrick Palka [Wed, 16 Feb 2022 17:41:35 +0000 (12:41 -0500)] 
c++: treat NON_DEPENDENT_EXPR as not potentially constant [PR104507]

Here we're crashing from potential_constant_expression because it tries
to perform trial evaluation of the first operand '(bool)__r' of the
conjunction (which is overall wrapped in a NON_DEPENDENT_EXPR), but
cxx_eval_constant_expression ICEs on unsupported trees (of which CAST_EXPR
is one).  The sequence of events is:

  1. build_non_dependent_expr for the array subscript yields
     NON_DEPENDENT_EXPR<<<(bool)__r && __s>>> ? 1 : 2
  2. cp_build_array_ref calls fold_non_dependent_expr on this subscript
     (after this point, processing_template_decl is cleared)
  3. during which, the COND_EXPR case of tsubst_copy_and_build calls
     fold_non_dependent_expr on the first operand
  4. during which, we crash from p_c_e_1 because it attempts trial
     evaluation of the CAST_EXPR '(bool)__r'.

Note that even if this crash didn't happen, fold_non_dependent_expr
from cp_build_array_ref would still ultimately be one big no-op here
since neither constexpr evaluation nor tsubst handle NON_DEPENDENT_EXPR.

In light of this and of the observation that we should never see
NON_DEPENDENT_EXPR in a context where a constant expression is needed
(it's used primarily in the build_x_* family of functions), it seems
futile for p_c_e_1 to ever return true for NON_DEPENDENT_EXPR.  And the
otherwise inconsistent handling of NON_DEPENDENT_EXPR between p_c_e_1,
cxx_evaluate_constexpr_expression and tsubst apparently leads to weird
bugs such as this one.

PR c++/104507

gcc/cp/ChangeLog:

* constexpr.c (potential_constant_expression_1)
<case NON_DEPENDENT_EXPR>: Return false instead of recursing.
Assert tf_error isn't set.

gcc/testsuite/ChangeLog:

* g++.dg/template/non-dependent21.C: New test.

(cherry picked from commit c19f317a78c0e4c1b51d0e5a8e4c0a3b985b7a8e)

3 years agoc++: constrained auto in lambda using outer tparms [PR103706]
Patrick Palka [Tue, 8 Feb 2022 13:46:13 +0000 (08:46 -0500)] 
c++: constrained auto in lambda using outer tparms [PR103706]

Here we're crashing during satisfaction of the lambda's placeholder type
constraints because the constraints depend on the template arguments
from the enclosing scope, which aren't part of the lambda's DECL_TI_ARGS.

This patch fixes this by making do_auto_deduction consider the
"regenerating" template arguments of a lambda for satisfaction,
mirroring what's done in satisfy_declaration_constraints.

PR c++/103706

gcc/cp/ChangeLog:

* constraint.cc (satisfy_declaration_constraints): Use
lambda_regenerating_args instead.
* cp-tree.h (lambda_regenerating_args): Declare.
* pt.c (lambda_regenerating_args): Define, split out from
satisfy_declaration_constraints.
(do_auto_deduction): Use lambda_regenerating_args to obtain the
full set of outer template arguments for satisfaction when
inside a lambda.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 34ba3d9a2bf72742b1c150a2dd17d10e3e3f0964)

3 years agoc++: var tmpl w/ dependent constrained auto type [PR103341]
Patrick Palka [Fri, 28 Jan 2022 13:18:28 +0000 (08:18 -0500)] 
c++: var tmpl w/ dependent constrained auto type [PR103341]

When deducing the type of a variable template (or templated static data
member) with a constrained auto type, we might need its template
arguments for satisfaction since the constraint could depend on them.

PR c++/103341

gcc/cp/ChangeLog:

* decl.c (cp_finish_decl): Pass the template arguments of a
variable template specialization or a templated static data
member to do_auto_deduction when the auto is constrained.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-class4.C: New test.
* g++.dg/cpp2a/concepts-var-templ2.C: New test.

(cherry picked from commit e272cf95ba048fde60b21aee046c9ca9c9264425)

3 years agoc++: deleted fn and noexcept inst [PR101532, PR104225]
Patrick Palka [Tue, 25 Jan 2022 20:04:49 +0000 (15:04 -0500)] 
c++: deleted fn and noexcept inst [PR101532, PR104225]

Here when attempting to use B's implicitly deleted default constructor,
mark_used rightfully returns false, but for the wrong reason: it
tries to instantiate the synthesized noexcept specifier which then only
silently fails because get_defaulted_eh_spec suppresses diagnostics
for deleted functions.  This lack of diagnostics causes us to crash on
the first testcase below (thanks to the assert in finish_expr_stmt), and
silently accept the second testcase.

To fix this, this patch makes mark_used avoid attempting to instantiate
the noexcept specifier of a deleted function, so that we'll instead
directly reject (and diagnose) the function due to its deletedness.

PR c++/101532
PR c++/104225

gcc/cp/ChangeLog:

* decl2.c (mark_used): Don't consider maybe_instantiate_noexcept
on a deleted function.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nsdmi-template21.C: New test.
* g++.dg/cpp0x/nsdmi-template21a.C: New test.

(cherry picked from commit bc90dd0ecf02e11d47d1af7f627e2e2acaa40106)

3 years agoc++: requires-expr in pack expansion using pack [PR103105]
Patrick Palka [Tue, 12 Apr 2022 16:58:18 +0000 (12:58 -0400)] 
c++: requires-expr in pack expansion using pack [PR103105]

Here after dependent substitution of {Ts...} into the alias 'wrap',
since we never partially instantiate a requires-expr, we end up with a
requires-expr whose REQUIRES_EXPR_EXTRA_ARGS contains an
ARGUMENT_PACK_SELECT (which just resolves to the parameter pack Ts).
Then when hashing the resulting dependent specialization of A, we crash
from iterative_hash_template_arg since it deliberately doesn't handle
ARGUMENT_PACK_SELECT.

Like in r12-7102-gdb5f1c17031ad8, it seems the right fix here is to
resolve ARGUMENT_PACK_SELECT arguments before storing them into an
extra args tree (such as REQUIRES_EXPR).

PR c++/103105

gcc/cp/ChangeLog:

* pt.c (build_extra_args): Call preserve_args.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit e2c7070ac7740508a7c49bfee9f895e216a272d6)

3 years agoc++: lambda in pack expansion using pack in constraint [PR103706]
Patrick Palka [Tue, 8 Feb 2022 13:46:32 +0000 (08:46 -0500)] 
c++: lambda in pack expansion using pack in constraint [PR103706]

Here when expanding the pack expansion pattern containing a constrained
lambda, the template argument for each Ts is an ARGUMENT_PACK_SELECT,
which we store inside the lambda's LAMBDA_EXPR_REGEN_INFO.  Then during
satisfaction of the lambda's constraint C<Ts> the satisfaction cache
uses this argument as part of the key to the corresponding sat_entry, but
iterative_hash_template_arg and template_args_equal deliberately don't
handle ARGUMENT_PACK_SELECT.

Since it's wrong to preserve ARGUMENT_PACK_SELECT inside a hash table
due to its instability (as documented in iterative_hash_template_arg),
this patch helps make sure the satisfaction cache doesn't see such trees
by resolving ARGUMENT_PACK_SELECT arguments before adding them to
LAMBDA_EXPR_REGEN_INFO.

PR c++/103706

gcc/cp/ChangeLog:

* pt.c (preserve_args): New function.
(tsubst_lambda_expr): Use it when setting LAMBDA_EXPR_REGEN_INFO.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit db5f1c17031ad8a898d77121f1e0e0141306e22a)

3 years agolibstdc++: Prevent -Wstringop-overread warning in std::deque [PR100516]
Jonathan Wakely [Thu, 27 Jan 2022 22:31:26 +0000 (22:31 +0000)] 
libstdc++: Prevent -Wstringop-overread warning in std::deque [PR100516]

The compiler warns about the loop in deque::_M_range_initialize because
it doesn't know that the number of nodes has already been correctly
sized to match the size of the input. Use __builtin_unreachable to tell
it that the loop will never be entered if the number of elements is
smaller than a single node.

libstdc++-v3/ChangeLog:

PR libstdc++/100516
* include/bits/deque.tcc (_M_range_initialize<ForwardIterator>):
Add __builtin_unreachable to loop.
* testsuite/23_containers/deque/100516.cc: New test.

(cherry picked from commit eae41b4d2cc30327f9f15c7390438c46aa09ed3f)

3 years agors6000: Handle pcrel sibcalls to longcall functions [PR104894]
Peter Bergner [Tue, 12 Apr 2022 19:08:53 +0000 (14:08 -0500)] 
rs6000: Handle pcrel sibcalls to longcall functions [PR104894]

Before PCREL in POWER10, we were not allowed to perform sibcalls to longcall
functions since callee's return would skip the TOC restore in the caller.
However, with PCREL we can now safely perform a sibling call to longcall
functions.  The problem with the current code is that pcrel sibcall
branches to a PLT stub label even though -fno-plt was used.  The solution
here is to check for a pcrel longcall and emit an inline plt stub in
that case.

2022-04-11  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR target/104894
* config/rs6000/rs6000.c (rs6000_sibcall_aix): Handle pcrel sibcalls
to longcall functions.

gcc/testsuite/
PR target/104894
* gcc.target/powerpc/pr104894.c: New test.
* gcc.target/powerpc/pr104894-2.c: New test.

(cherry picked from commit d74c4c6a1b4956b5cd9b2a770bb7261836fa1289)

3 years agolibstdc++: Fix std::exception_ptr regressions [PR103630]
Jonathan Wakely [Thu, 9 Dec 2021 13:54:39 +0000 (13:54 +0000)] 
libstdc++: Fix std::exception_ptr regressions [PR103630]

This restores support for std::make_exception_ptr<E&> and for using
std::exception_ptr in C++98.

Because the new non-throwing implementation needs to use std::decay to
handle references the original throwing implementation is used for
C++98.

We also need to change the typeid expression so it doesn't yield the
dynamic type when the function parameter is a reference to a polymorphic
type. Otherwise the new exception object could be caught by any handler
matching the dynamic type, even though the actual exception object is
only a copy of the base class, sliced to the static type.

libstdc++-v3/ChangeLog:

PR libstdc++/103630
* libsupc++/exception_ptr.h (exception_ptr): Fix exception
specifications on inline definitions.
(make_exception_ptr): Decay the template parameter. Use typeid
of the static type.
* testsuite/18_support/exception_ptr/103630.cc: New test.

(cherry picked from commit a1ca039fc0fe934ef36c25d8284e6e116bcaffa7)

3 years agolibstdc++: Disable atomic wait for freestanding [PR105021]
Jonathan Wakely [Tue, 22 Mar 2022 21:17:01 +0000 (21:17 +0000)] 
libstdc++: Disable atomic wait for freestanding [PR105021]

We use either condition variables or futexes to implement atomic waits,
so we can't do it in freestanding. This is non-conforming, so should be
revisited later, probably by making freestanding atomic waiting
operations spin without ever blocking.

Reviewed-by: Thomas Rodgers <trodgers@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/105021
* include/bits/atomic_base.h [!_GLIBCXX_HOSTED]: Do not include
<bits/atomic_wait.h> for freestanding.

(cherry picked from commit 5bf59b004808abf6acbfe5ef54a0f9216b8dce22)

3 years agolibstdc++: Guard mutex and condvar with gthreads macro [PR103638]
Jonathan Wakely [Fri, 10 Dec 2021 11:44:29 +0000 (11:44 +0000)] 
libstdc++: Guard mutex and condvar with gthreads macro [PR103638]

A mutex and condition variable is used for timed waits on atomics if
there is no "platform wait" (e.g. futex) supported. But the use of those
types wasn't guarded by the _GLIBCXX_HAS_GTHREADS macro, causing errors
for --disable-threads builds. This fix allows <atomic> to work on
targets with futexes but no gthreads.

libstdc++-v3/ChangeLog:

PR libstdc++/103638
* include/bits/atomic_timed_wait.h: Check _GLIBCXX_HAS_GTHREADS
before using std::mutex and std::__condvar.

(cherry picked from commit ffb632517fc446474baba10ee2ff13a218ec2c7b)

3 years agolibstdc++: Add missing noexcept to std::variant helper
Jonathan Wakely [Mon, 4 Oct 2021 09:21:58 +0000 (10:21 +0100)] 
libstdc++: Add missing noexcept to std::variant helper

libstdc++-v3/ChangeLog:

* include/std/variant (__detail::__variant::__as): Add missing
noexcept to first overload.

(cherry picked from commit 728e639d82099035fdfe69b716a54717ae7050e0)

3 years agolibstdc++: Allow visiting inherited variants [PR 90943]
Jonathan Wakely [Mon, 19 Apr 2021 13:49:12 +0000 (14:49 +0100)] 
libstdc++: Allow visiting inherited variants [PR 90943]

Implement the changes from P2162R2 (as a DR for C++17).

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/90943
* include/std/variant (__cpp_lib_variant): Update value.
(__detail::__variant::__as): New helpers implementing the
as-variant exposition-only function templates.
(visit, visit<R>): Use __as to upcast the variant parameters.
* include/std/version (__cpp_lib_variant): Update value.
* testsuite/20_util/variant/visit_inherited.cc: New test.

(cherry picked from commit c46ecb0112e91c80ee111439e79a58a953e4479d)

3 years agoc++: operator new lookup [PR98249]
Jason Merrill [Mon, 11 Apr 2022 17:06:05 +0000 (13:06 -0400)] 
c++: operator new lookup [PR98249]

The standard says, as we quote in the comment just above, that if we don't
find operator new in the allocated type, it should be looked up in the
global scope.  This is specifically ::, not just any namespace, and we
already give an error for an operator new declared in any other namespace.

PR c++/98249

gcc/cp/ChangeLog:

* call.c (build_operator_new_call): Just look in ::.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/new3.C: New test.

3 years agoc++: -Wshadow=compatible-local type vs var [PR100608]
Jason Merrill [Tue, 5 Apr 2022 20:02:04 +0000 (16:02 -0400)] 
c++: -Wshadow=compatible-local type vs var [PR100608]

The patch for PR92024 changed -Wshadow=compatible-local to warn if either
new or old decl was a type, but the rationale only talked about the case
where both are types.  If only one is, they aren't compatible.

PR c++/100608

gcc/cp/ChangeLog:

* name-lookup.c (check_local_shadow): Use -Wshadow=local
if exactly one of 'old' and 'decl' is a type.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wshadow-compatible-local-3.C: New test.

3 years agoc++: elaborated-type-spec in requires-expr [PR101677]
Jason Merrill [Mon, 28 Mar 2022 02:31:51 +0000 (22:31 -0400)] 
c++: elaborated-type-spec in requires-expr [PR101677]

We were failing to declare class S in the global namespace because we were
treating the requires-expression parameter scope as a normal block scope, so
the implicit declaration went there.

It seems to me that the requires parameter scope is more like a function
parameter scope (not least in the use of the word "parameter"), so let's
change the scope kind.  But then we need to adjust the prohibition on
placeholders declaring implicit template parameters.

PR c++/101677

gcc/cp/ChangeLog:

* name-lookup.h (struct cp_binding_level): Add requires_expression
bit-field.
* parser.c (cp_parser_requires_expression): Set it.
(synthesize_implicit_template_parm): Check it.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-pr67178.C: Adjust error.
* g++.dg/cpp2a/concepts-requires28.C: New test.

3 years agoc++: hash table ICE with variadic alias [PR105003]
Jason Merrill [Fri, 25 Mar 2022 17:13:35 +0000 (13:13 -0400)] 
c++: hash table ICE with variadic alias [PR105003]

For PR104008 we thought it might be enough to keep strip_typedefs from
removing this alias template specialization, but this PR demonstrates that
other parts of the compiler also need to know to consider it dependent.

So, this patch changes complex_alias_template_p to no longer consider
template parameters used when their only use appears in a pack expansion,
unless they are the parameter packs being expanded.

To do that I also needed to change it to use cp_walk_tree instead of
for_each_template_parm.  It occurs to me that find_template_parameters
should probably also use cp_walk_tree, but I'm not messing with that now.

PR c++/105003
PR c++/104008
PR c++/102869

gcc/cp/ChangeLog:

* pt.c (complex_alias_template_r): walk_tree callback, replacing
uses_all_template_parms_r, complex_pack_expansion_r.
(complex_alias_template_p): Adjust.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-alias6.C: New test.
* g++.dg/cpp0x/variadic-alias7.C: New test.

3 years agoc++: repeated friend template [PR101894]
Jason Merrill [Fri, 1 Apr 2022 20:18:31 +0000 (16:18 -0400)] 
c++: repeated friend template [PR101894]

Since olddecl isn't a definition, it doesn't get DECL_FRIEND_CONTEXT, so we
need to copy it from newdecl when we merge the declarations.

PR c++/101894

gcc/cp/ChangeLog:

* decl.c (duplicate_decls): Copy DECL_FRIEND_CONTEXT.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/friend22.C: New test.

3 years agoc++: CTAD and member function references [PR103943]
Jason Merrill [Sun, 27 Mar 2022 02:05:53 +0000 (22:05 -0400)] 
c++: CTAD and member function references [PR103943]

More quirks of rewriting member references to dependent references for
CTAD.  A reference to a member of dependent scope is definitely dependent.
And since r11-7044, tsubst_baselink builds a SCOPE_REF, so
tsubst_qualified_id should just use it.

PR c++/103943

gcc/cp/ChangeLog:

* pt.c (tsubst_qualified_id): Handle getting SCOPE_REF from
tsubst_baselink.
(instantiation_dependent_scope_ref_p): Check dependent_scope_p.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction109.C: New test.

3 years agoc++: nested generic lambda in DMI [PR101717]
Jason Merrill [Thu, 7 Apr 2022 02:20:49 +0000 (22:20 -0400)] 
c++: nested generic lambda in DMI [PR101717]

We were already checking COMPLETE_TYPE_P to recognize instantiation of a
generic lambda, but didn't consider that we might be nested in a non-generic
lambda.

PR c++/101717

gcc/cp/ChangeLog:

* lambda.c (lambda_expr_this_capture): Check all enclosing
lambdas for completeness.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/lambda-generic-this4.C: New test.

3 years agoc++: conversion with trailing return type [PR101051]
Jason Merrill [Thu, 7 Apr 2022 01:57:33 +0000 (21:57 -0400)] 
c++: conversion with trailing return type [PR101051]

We've had a diagnostic for this, but since r10-6571 added an assert to
splice_late_return_type, we need to diagnose before we call it.

PR c++/101051

gcc/cp/ChangeLog:

* decl.c (grokdeclarator): Reject conversion with trailing return
sooner.

gcc/testsuite/ChangeLog:

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

3 years agolibstdc++: Avoid overflow in bounds checks [PR103955]
Patrick Palka [Wed, 12 Jan 2022 14:10:24 +0000 (09:10 -0500)] 
libstdc++: Avoid overflow in bounds checks [PR103955]

We currently crash when the floating-point to_chars overloads are passed
a precision value near INT_MAX, ultimately due to overflow in the bounds
checks that verify the output range is large enough.

The simplest portable fix seems to be to replace bounds checks of the form
A >= B + C (where B + C may overflow) with the otherwise equivalent check
A >= B && A - B >= C, which is the approach this patch takes.

Before we could do this in __floating_to_chars_hex, there we first need
to track the unbounded "excess" precision (i.e. the number of trailing
fractional digits in the output that are guaranteed to be '0') separately
from the bounded "effective" precision (i.e. the number of significant
fractional digits in the output), like we do in __f_t_c_precision.

PR libstdc++/103955

libstdc++-v3/ChangeLog:

* src/c++17/floating_to_chars.cc (__floating_to_chars_hex):
Track the excess precision separately from the effective
precision.  Avoid overflow in bounds check by splitting it into
two checks.
(__floating_to_chars_precision): Avoid overflow in bounds checks
similarly.
* testsuite/20_util/to_chars/103955.cc: New test.

(cherry picked from commit c0e355c77972d96fcec2ff7da047ad03e10e51d9)

3 years agolibstdc++: Implement LWG 3595 changes to common_iterator
Patrick Palka [Thu, 21 Oct 2021 01:43:42 +0000 (21:43 -0400)] 
libstdc++: Implement LWG 3595 changes to common_iterator

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (common_iterator::__arrow_proxy):
Make fully constexpr as per LWG 3595.
(common_iterator::__postfix_proxy): Likewise.

(cherry picked from commit 1556e447c0fee5c77ccd9bda243d5281e10e895b)

3 years agolibstdc++: Implement LWG 3591-3592 changes to split_view
Patrick Palka [Thu, 21 Oct 2021 01:34:23 +0000 (21:34 -0400)] 
libstdc++: Implement LWG 3591-3592 changes to split_view

libstdc++-v3/ChangeLog:

* include/std/ranges (split_view::base): Add forward_range
constraint as per LWG 3591.
(split_view::begin, lazy_split_view::end): Also check
simpleness of _Pattern as per LWG 3592.

(cherry picked from commit 2d3ac6039074832978ce9bcd41ba93ef4812458f)

3 years agolibstdc++: Implement LWG 3535 changes to ranges::join_view
Patrick Palka [Thu, 21 Oct 2021 01:34:21 +0000 (21:34 -0400)] 
libstdc++: Implement LWG 3535 changes to ranges::join_view

libstdc++-v3/ChangeLog:

* include/std/ranges (join_view::__iter_cat::_S_iter_cat): Adjust
criteria for returning bidirectional_iterator_tag as per LWG 3535.
(join_view::_Iterator::_S_iter_concept): Likewise.

(cherry picked from commit 6667274b0593a64dd3de3c7c3565bec42af35b62)

3 years agolibstdc++: Implement LWG 3481 change to ranges::viewable_range
Patrick Palka [Thu, 21 Oct 2021 01:34:18 +0000 (21:34 -0400)] 
libstdc++: Implement LWG 3481 change to ranges::viewable_range

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (viewable_range): Adjust as per
LWG 3481.
* testsuite/std/ranges/adaptors/all.cc (test07): New test.

(cherry picked from commit a2c2dcc6ca205a8c5c76b04ef2eb4fb097dcb069)

3 years agolibstdc++: Implement LWG 3580 change to ranges::iota_view
Patrick Palka [Tue, 19 Oct 2021 22:07:19 +0000 (18:07 -0400)] 
libstdc++: Implement LWG 3580 change to ranges::iota_view

libstdc++-v3/ChangeLog:

* include/std/ranges (iota_view::_Iterator::operator+): Adjust
definition as per LWG 3580.
(iota_view::_Iterator::operator-): Likewise.

(cherry picked from commit 5566f3c6b46cf053ae4b918513e318561b7af053)

3 years agolibstdc++: Implement LWG 3470 change to ranges::subrange
Patrick Palka [Tue, 19 Oct 2021 22:07:05 +0000 (18:07 -0400)] 
libstdc++: Implement LWG 3470 change to ranges::subrange

libstdc++-v3/ChangeLog:

* include/bits/ranges_util.h
(__detail::__uses_nonqualification_pointer_conversion): Define
and use it ...
(__detail::__convertible_to_nonslicing): ... here, as per LWG 3470.
* testsuite/std/ranges/subrange/1.cc: New test.

(cherry picked from commit 98af6b86bc6cac705474c14bb3f9748f6866c859)

3 years agolibstdc++: Implement LWG 3523 changes to ranges::iota_view
Patrick Palka [Tue, 19 Oct 2021 21:54:24 +0000 (17:54 -0400)] 
libstdc++: Implement LWG 3523 changes to ranges::iota_view

libstdc++-v3/ChangeLog:

* include/std/ranges (iota_view::_Iterator): Befriend iota_view.
(iota_view::_Sentinel): Likewise.
(iota_view::iota_view): Add three overloads, each taking an
iterator/sentinel pair as per LWG 3523.
* testsuite/std/ranges/iota/iota_view.cc (test06): New test.

(cherry picked from commit 861440a77b62756d200ae356c4fdfd9653902e77)

3 years agotree-optimization/105235 - clean EH in execute_cse_conv_1
Richard Biener [Tue, 12 Apr 2022 08:07:10 +0000 (10:07 +0200)] 
tree-optimization/105235 - clean EH in execute_cse_conv_1

When a FP conversion is removed we have to eventually clean EH.

2022-04-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105235
* tree-ssa-math-opts.c (execute_cse_conv_1): Clean EH and
return whether the CFG changed.
(execute_cse_sincos_1): Adjust.

* g++.dg/opt/pr105235-1.C: New testcase.

(cherry picked from commit 31cccadcf2d3cc8acb7a5f36ed57ca847f7ea0ea)

3 years agotree-optimization/105232 - handle overly large sizes in component_ref_size
Richard Biener [Tue, 12 Apr 2022 07:54:32 +0000 (09:54 +0200)] 
tree-optimization/105232 - handle overly large sizes in component_ref_size

The following properly checks tree_fits_poly_int64_p before converting
a size to a poly_int64.

2022-04-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105232
* tree.c (component_ref_size): Bail out for too large
or non-constant sizes.

(cherry picked from commit 1bd96873cf73c4f59de48e9bc0d17a498f1ede04)

3 years agotree-optimization/105226 - avoid splitting abnormal edges
Richard Biener [Tue, 12 Apr 2022 07:40:15 +0000 (09:40 +0200)] 
tree-optimization/105226 - avoid splitting abnormal edges

Vectorizer loop versioning tries to version outer loops if possible
but fails to check whether it can actually split the single exit
edge as it will do.

2022-04-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105226
* tree-vect-loop-manip.c (vect_loop_versioning): Verify
we can split the exit of an outer loop we choose to version.

* gcc.dg/pr105226.c: New testcase.

(cherry picked from commit 62d5bb0f35fb6ec373eaac942755585a633528a0)

3 years agoDaily bump.
GCC Administrator [Tue, 12 Apr 2022 00:18:31 +0000 (00:18 +0000)] 
Daily bump.

3 years agoppc: testsuite: require target effectively [PR104253]
Alexandre Oliva [Mon, 11 Apr 2022 15:11:10 +0000 (12:11 -0300)] 
ppc: testsuite: require target effectively [PR104253]

The testcase was missing dg- before require-effective-target.

While at that, I'm also pruning the excess-error warning I got when
the test failed to be disabled because of the above.  I suppose it
might be useful for some target variants.

for gcc/testsuite/ChangeLog

PR target/104253
* gcc.target/powerpc/pr104253.c: Add missing dg- before
require-effective-target.  Prune warning about -mfloat128
possibly not being fully supported.

(cherry picked from commit ab0f04e4df1b7b312a4c9fa9b4d675778a0bae86)

3 years agoRISC-V: Support -misa-spec for arch-canonicalize and multilib-generator. [PR104853]
Kito Cheng [Mon, 11 Apr 2022 08:29:34 +0000 (16:29 +0800)] 
RISC-V: Support -misa-spec for arch-canonicalize and multilib-generator. [PR104853]

We migrate the default ISA spec version from 2.2 to 20191213, but those scripts
aren't updated at the same time, this patch is making both scripts support
different ISA spec versions.

gcc/ChangeLog:

PR target/104853
* config.gcc: Pass -misa-spec to arch-canonicalize and
multilib-generator.
* config/riscv/arch-canonicalize: Adding -misa-spec option.
(SUPPORTED_ISA_SPEC): New.
(arch_canonicalize): New argument `isa_spec`.
Handle multiple ISA spec versions.
* config/riscv/multilib-generator: Adding -misa-spec option.

(cherry picked from commit 4132f6ba9583e128a00d55961ae8c8e7245b2223)

3 years agoRISC-V: Allow multi-lib build with different code model
Kito Cheng [Tue, 20 Jul 2021 02:53:18 +0000 (10:53 +0800)] 
RISC-V: Allow multi-lib build with different code model

--with-multilib-generator was only support for different ISA/ABI
combination, however code model is effect the code gen a lots it
should able to handled in multilib mechanism.

Adding `--cmodel=` option to `--with-multilib-generator` to generating
multilib combination with different code model.

E.g.
--with-multilib-generator="rv64ima-lp64--;--cmodel=medlow,medany"
will generate 3 multi-lib suppport:
1) rv64ima with lp64
2) rv64ima with lp64 and medlow code model
3) rv64ima with lp64 and medany code model

gcc/

* config/riscv/multilib-generator: Support code model option for
multi-lib.
* doc/install.texi: Add document of new option for
--with-multilib-generator.

(cherry picked from commit fdd40498d1981fde0720a0886d6f59ea5fb7ab40)

3 years agoDaily bump.
GCC Administrator [Mon, 11 Apr 2022 00:18:22 +0000 (00:18 +0000)] 
Daily bump.

3 years agoFortran: a RECURSIVE procedure cannot be an INTRINSIC
Harald Anlauf [Mon, 4 Apr 2022 18:42:51 +0000 (20:42 +0200)] 
Fortran: a RECURSIVE procedure cannot be an INTRINSIC

gcc/fortran/ChangeLog:

PR fortran/105138
* intrinsic.c (gfc_is_intrinsic): When a symbol refers to a
RECURSIVE procedure, it cannot be an INTRINSIC.

gcc/testsuite/ChangeLog:

PR fortran/105138
* gfortran.dg/recursive_reference_3.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit d46685b04071a485b56de353d997a866bfc8caba)

3 years agofortran: Separate associate character lengths earlier [PR104570]
Mikael Morin [Sun, 13 Mar 2022 21:22:55 +0000 (22:22 +0100)] 
fortran: Separate associate character lengths earlier [PR104570]

This change workarounds an ICE in the evaluation of the character length
of an array expression referencing an associate variable; the code is
not prepared to see a non-scalar expression as it doesn’t initialize the
scalarizer.

Before this change, associate length symbols get a new gfc_charlen at
resolution stage to unshare them from the associate expression, so that
at translation stage it is a decl specific to the associate symbol that
is initialized, not the decl of some other symbol.  This
reinitialization of gfc_charlen happens after expressions referencing
the associate symbol have been parsed, so that those expressions retain
the original gfc_charlen they have copied from the symbol.
At translation stage, the gfc_charlen for the associate symbol is setup
with the decl holding the actual length value, but the expressions have
retained the original gfc_charlen without any decl.  So they need to
evaluate the character length, and this is where the ICE happens.

This change moves the reinitialization of gfc_charlen earlier at parsing
stage, so that at resolution stage the gfc_charlen can be retained as
it’s already not shared with any other symbol, and the expressions which
now share their gfc_charlen with the symbol are automatically updated
when the length decl is setup at translation stage.  There is no need
any more to evaluate the character length as it has all the required
information, and the ICE doesn’t happen.

The first resolve.c hunk is necessary to avoid regressing on the
associate_35.f90 testcase.

PR fortran/104228
PR fortran/104570

gcc/fortran/ChangeLog:

* parse.c (parse_associate): Use a new distinct gfc_charlen if the
copied type has one whose length is not known to be constant.
* resolve.c (resolve_assoc_var): Reset charlen if it’s shared with
the associate target regardless of the expression type.
Don’t reinitialize charlen if it’s deferred.

gcc/testsuite/ChangeLog:

* gfortran.dg/associate_58.f90: New test.

(cherry picked from commit 907811ddc35da6c1701ed22355ece63a8c3ed7fb)

3 years agofortran: Unshare associate var charlen [PR104228]
Mikael Morin [Fri, 28 Jan 2022 21:00:57 +0000 (22:00 +0100)] 
fortran: Unshare associate var charlen [PR104228]

PR104228 showed that character lengths were shared between associate
variable and associate targets.  This is problematic when the associate
target is itself a variable and gets a variable to hold the length, as
the length variable is added (and all the variables following it in the chain)
to both the associate variable scope and the target variable scope.
This caused an ICE when compiling with -O0 -fsanitize=address.

This change forces the creation of a separate character length for the
associate variable.  It also forces the initialization of the character
length variable to avoid regressing associate_32 and associate_47 tests.

PR fortran/104228

gcc/fortran/ChangeLog:

* resolve.c (resolve_assoc_var): Also create a new character
length for non-dummy associate targets.
* trans-stmt.c (trans_associate_var): Initialize character length
even if no temporary is used for the associate variable.

gcc/testsuite/ChangeLog:

* gfortran.dg/asan/associate_58.f90: New test.
* gfortran.dg/asan/associate_59.f90: New test.

(cherry picked from commit 57da34939703a6e6d3267a0d25d1fb9369d3ac0e)

3 years agoDaily bump.
GCC Administrator [Sun, 10 Apr 2022 00:18:21 +0000 (00:18 +0000)] 
Daily bump.

3 years agoDaily bump.
GCC Administrator [Sat, 9 Apr 2022 00:18:47 +0000 (00:18 +0000)] 
Daily bump.

3 years agoc++: parameter pack inside static_assert [PR99893]
Patrick Palka [Thu, 27 May 2021 18:25:33 +0000 (14:25 -0400)] 
c++: parameter pack inside static_assert [PR99893]

Here, we're not finding the parameter pack inside the static_assert because
STATIC_ASSERT trees are tcc_exceptional, and we weren't explicitly walking
them in cp_walk_subtrees.

PR c++/99893
PR c++/103885

gcc/cp/ChangeLog:

* tree.c (cp_walk_subtrees) <case STATIC_ASSERT>: New case.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit fc3fdf0f2196e805a3a43ccb73595c33673670f3)

3 years agotree-optimization/105198 - wrong code with predictive commoning
Richard Biener [Fri, 8 Apr 2022 11:13:29 +0000 (13:13 +0200)] 
tree-optimization/105198 - wrong code with predictive commoning

When predictive commoning looks for a looparound PHI it tries
to match the entry value definition (a load) up with the appropriate
member of the chain.  But it fails to consider stmts clobbering
the very same memory location inbetween the load and loop entry.

In theory we could be more clever on must aliases that would be
also picked up from a load (so not exactly stmt_kills_ref_p) and
use the stored value from that if it is an exact match.  But we
currently have no way to propagate this information inside predcom.

2022-04-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105198
* tree-predcom.c (find_looparound_phi): Check whether
the found memory location of the entry value is clobbered
inbetween the value we want to use and loop entry.

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

(cherry picked from commit e5453bcc217ea4ac53a4ac277661d6ef0ccd425b)

3 years agoDaily bump.
GCC Administrator [Fri, 8 Apr 2022 00:18:32 +0000 (00:18 +0000)] 
Daily bump.

3 years agolibstdc++: Avoid implicit narrowing from uint128_t [PR104859]
Patrick Palka [Wed, 9 Mar 2022 23:48:52 +0000 (18:48 -0500)] 
libstdc++: Avoid implicit narrowing from uint128_t [PR104859]

We need to be explicit about narrowing conversions from uint128_t since,
on targets that lack __int128, this type is defined as an integer-class
type that is only _explicitly_ convertible to the builtin integer types.
This issue was latent until r12-7563-ge32869a17b788b made the frontend
correctly reject explicit conversion functions during (dependent)
copy-initialization.

PR libstdc++/104859

libstdc++-v3/ChangeLog:

* src/c++17/floating_to_chars.cc (__floating_to_chars_hex):
Be explicit when narrowing the shifted effective_mantissa,
since it may have an integer-class type.

(cherry picked from commit 65857caee8ccfac5007a9fd0e5f18cce5e5fe934)

3 years agoc++: make -Wctad-maybe-unsupported respect complain [PR105143]
Patrick Palka [Wed, 6 Apr 2022 15:46:25 +0000 (11:46 -0400)] 
c++: make -Wctad-maybe-unsupported respect complain [PR105143]

We were attempting to issue a -Wctad-maybe-unsupported warning even when
complain=tf_none, which led to a crash in the first testcase below and a
bogus error during overload resolution in the second testcase.

PR c++/105143

gcc/cp/ChangeLog:

* pt.c (do_class_deduction): Check complain before attempting
to issue a -Wctad-maybe-unsupported warning.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nodiscard1.C: New test.
* g++.dg/warn/Wctad-maybe-unsupported4.C: New test.

(cherry picked from commit e58484a019c57b1085bbbcc1654f1944feddfe73)

3 years agoc++: constrained template friend matching ICE [PR105064]
Patrick Palka [Mon, 28 Mar 2022 18:15:16 +0000 (14:15 -0400)] 
c++: constrained template friend matching ICE [PR105064]

Here during declaration matching for the two constrained template
friends, we crash from maybe_substitute_reqs_for because the second
friend doesn't yet have DECL_TEMPLATE_INFO set (we're being called
indirectly from push_template_decl).

As far as I can tell, this situation happens only when declaring a
constrained template friend within a non-template class (as in the
testcase), in which case the substitution would be a no-op anyway.
So this patch rearranges maybe_substitute_reqs_for to gracefully
handle missing DECL_TEMPLATE_INFO by just skipping the substitution.

PR c++/105064

gcc/cp/ChangeLog:

* constraint.cc (maybe_substitute_reqs_for): Don't assume
DECL_TEMPLATE_INFO is available.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit ecb4882e362e80a1bf172453ac9b366edbb4e89c)

3 years agoc++: double non-dep folding from finish_compound_literal [PR104565]
Patrick Palka [Thu, 17 Feb 2022 13:35:23 +0000 (08:35 -0500)] 
c++: double non-dep folding from finish_compound_literal [PR104565]

In finish_compound_literal, we perform non-dependent expr folding before
the call to check_narrowing ever since r9-5973.  But ever since r10-7096,
check_narrowing also performs non-dependent expr folding of its own.
This double folding means tsubst will see non-templated trees during the
second folding, which causes a spurious error in the below testcase.

This patch removes the former folding operation; it seems obviated by
the latter one.

PR c++/104565

gcc/cp/ChangeLog:

* semantics.c (finish_compound_literal): Don't perform
non-dependent expr folding before calling check_narrowing.

gcc/testsuite/ChangeLog:

* g++.dg/template/non-dependent22.C: New test.

(cherry picked from commit 6bbd8afee0036c274f5ebb5b48d6fdc2091bd046)

3 years agoc++: dependence of member noexcept-spec [PR104079]
Patrick Palka [Thu, 3 Feb 2022 23:54:23 +0000 (18:54 -0500)] 
c++: dependence of member noexcept-spec [PR104079]

Here a stale TYPE_DEPENDENT_P/_P_VALID value for f's function type
after replacing the type's DEFERRED_NOEXCEPT with the parsed dependent
noexcept-spec causes us to try to instantiate g's noexcept-spec ahead
of time (since it in turn appears non-dependent), leading to an ICE.

This patch fixes this by clearing TYPE_DEPENDENT_P_VALID in
fixup_deferred_exception_variants appropriately (as in
build_cp_fntype_variant).

That turns out to fix the testcase for C++17 but not for C++11/14,
because it's not until C++17 that a noexcept-spec is part of (and
therefore affects dependence of) the function type.  Since dependence of
NOEXCEPT_EXPR is defined in terms of instantiation dependence, the most
appropriate fix for earlier dialects seems to be to make instantiation
dependence consider dependence of a noexcept-spec.

PR c++/104079

gcc/cp/ChangeLog:

* pt.c (value_dependent_noexcept_spec_p): New predicate split
out from ...
(dependent_type_p_r): ... here.
(instantiation_dependent_r): Use value_dependent_noexcept_spec_p
to consider dependence of a noexcept-spec before C++17.
* tree.c (fixup_deferred_exception_variants): Clear
TYPE_DEPENDENT_P_VALID.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept74.C: New test.
* g++.dg/cpp0x/noexcept74a.C: New test.

(cherry picked from commit 82e31c8973eb1a752c2ffd01005efe291d35cee3)

3 years agoc++: ICE when building builtin operator->* set [PR103455]
Patrick Palka [Sat, 26 Mar 2022 14:20:16 +0000 (10:20 -0400)] 
c++: ICE when building builtin operator->* set [PR103455]

Here when constructing the builtin operator->* candidate set according
to the available conversion functions for the operand types, we end up
considering a candidate with C1=T (through B's dependent conversion
function) and C2=F, during which we crash from DERIVED_FROM_P because
dependent_type_p sees a TEMPLATE_TYPE_PARM outside of a template
context.

Sidestepping the question of whether we should be considering such a
dependent conversion function here in the first place, it seems futile
to test DERIVED_FROM_P for anything other than an actual class type, so
this patch fixes this ICE by simply guarding the DERIVED_FROM_P test
with CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.

PR c++/103455

gcc/cp/ChangeLog:

* call.c (add_builtin_candidate) <case MEMBER_REF>: Test
CLASS_TYPE_P instead of MAYBE_CLASS_TYPE_P.

gcc/testsuite/ChangeLog:

* g++.dg/overload/builtin6.C: New test.

(cherry picked from commit 04f19580e8dbdbc7366d0f5fd068aa0cecafdc9d)

3 years agoFortran: improve error recovery for invalid coarray function declarations
Harald Anlauf [Tue, 29 Mar 2022 21:33:23 +0000 (23:33 +0200)] 
Fortran: improve error recovery for invalid coarray function declarations

gcc/fortran/ChangeLog:

PR fortran/104210
* arith.c (eval_intrinsic): Avoid NULL pointer dereference.
(gfc_zero_size_array): Likewise.

gcc/testsuite/ChangeLog:

PR fortran/104210
* gfortran.dg/pr104210.f90: New test.

(cherry picked from commit 892c7f03ae63121766a8be48f7e3b672547fd627)

3 years agoFix handling of in_flags in update_escape_summary_1
Jan Hubicka [Fri, 26 Nov 2021 12:36:35 +0000 (13:36 +0100)] 
Fix handling of in_flags in update_escape_summary_1

update_escape_summary_1 has thinko where it compues proper min_flags but then
stores original value (ignoring the fact whether there was a dereference
in the escape point).

PR ipa/103432
* ipa-modref.c (update_escape_summary_1): Fix handling of min_flags.

(cherry picked from commit a70faf6e4df7481c2c9a08a06657c20beb3043de)

3 years agoFix min_flags handling in mod-ref
Jan Hubicka [Wed, 11 Aug 2021 13:01:39 +0000 (15:01 +0200)] 
Fix min_flags handling in mod-ref

gcc/ChangeLog:

2021-08-11  Jan Hubicka  <hubicka@ucw.cz>
    Alexandre Oliva  <oliva@adacore.com>

* ipa-modref.c (modref_lattice::dump): Fix escape_point's min_flags
dumping.
(modref_lattice::merge_deref): Fix handling of indirect scape points.
(update_escape_summary_1): Likewise.
(update_escape_summary): Likewise.
(ipa_merge_modref_summary_after_inlining): Likewise.

gcc/testsuite/ChangeLog:

* c-c++-common/modref-dse.c: New test.

(cherry picked from commit 9851a1631f2915fafdc733539b6c8b5fb81e7ae5)

3 years agoc++: Fix ICE due to shared BLOCK node in coroutine generation [PR103328]
Benno Evers [Sat, 2 Apr 2022 16:22:33 +0000 (17:22 +0100)] 
c++: Fix ICE due to shared BLOCK node in coroutine generation [PR103328]

When finishing a function that is a coroutine, the function is
transformed into a "ramp" function, and the original user-provided
function body gets moved into a newly created "actor" function.

In this case `current_function_decl` points to the ramp function,
but `current_binding_level->blocks` would still point to the
scope block of the user-provided function body in the actor function,
so when the ramp function was finished during `poplevel()` in decl.cc,
we could end up with that block being reused as the `DECL_INITIAL()` of
the ramp function:

   subblocks = functionbody >= 0 ? current_binding_level->blocks : 0;
   // [...]
   DECL_INITIAL (current_function_decl) = block ? block : subblocks;

This block would then be independently modified by subsequent passes
touching either the ramp or the actor function, potentially causing
an ICE depending on the order and function of these passes.

gcc/cp/ChangeLog:

PR c++/103328
* coroutines.cc (morph_fn_to_coro): Reset
current_binding_level->blocks.

gcc/testsuite/ChangeLog:

PR c++/103328
* g++.dg/coroutines/pr103328.C: New test.

Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 0847ad33b908af88bca1e6980d0b977316d05e18)

3 years agoUse OEP_DECL_NAME when comparing VLA bounds [PR101585].
Martin Sebor [Tue, 27 Jul 2021 19:51:55 +0000 (13:51 -0600)] 
Use OEP_DECL_NAME when comparing VLA bounds [PR101585].

Resolves:
PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters

gcc/c-family:

PR c/101585
* c-warn.c (warn_parm_ptrarray_mismatch): Use OEP_DECL_NAME.

gcc/testsuite:
PR c/101585
* gcc.dg/Wvla-parameter-13.c: New test.

(cherry picked from commit a0f9a5dcc3bbe6c7de499e17d201d0f2cb512649)

3 years agotree-optimization/99121 - avoid ICEing for non-constant sizes
Richard Biener [Thu, 7 Apr 2022 09:59:04 +0000 (11:59 +0200)] 
tree-optimization/99121 - avoid ICEing for non-constant sizes

The following is a simple fix to avoid ICEing on non-constant
sizes of ARRAY_REFs instead of backporting too intrusive changes
done on trunk.

2022-04-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99121
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref):
Bail out for non-constant type size.

3 years agoFix target/100106 ICE in gen_movdi
Bernd Edlinger [Wed, 21 Apr 2021 12:13:04 +0000 (14:13 +0200)] 
Fix target/100106 ICE in gen_movdi

As the test case shows, the outer mode may have a higher alignment
requirement than the inner mode here.

2021-04-27  Bernd Edlinger  <bernd.edlinger@hotmail.de>

PR target/100106
* simplify-rtx.c (simplify_context::simplify_subreg): Check the
memory alignment for the outer mode.

* gcc.c-torture/compile/pr100106.c: New testcase.

(cherry picked from commit c33db31d9ad96f6414460315c12b4b505fad5dd7)

3 years agomiddle-end/104497 - gimplification of vector indexing
Richard Biener [Fri, 11 Feb 2022 10:08:57 +0000 (11:08 +0100)] 
middle-end/104497 - gimplification of vector indexing

The following attempts to address gimplification of

   ... = VIEW_CONVERT_EXPR<int[4]>((i & 1) != 0 ? inv : src)[i];

which is problematic since gimplifying the base object
? inv : src produces a register temporary but GIMPLE does not
really support a register as a base for an ARRAY_REF (even
though that's not strictly validated it seems as can be seen
at -O0).  Interestingly the C++ frontend avoids this issue
by emitting the following GENERIC instead:

   ... = (i & 1) != 0 ? VIEW_CONVERT_EXPR<int[4]>(inv)[i] : VIEW_CONVERT_EXPR<int[4]>(src)[i];

The proposed patch below fixes things up when using an rvalue
as the base is OK by emitting a copy from a register base to a
non-register one.  The ?: as lvalue extension seems to be gone
for C, C++ again unwraps the COND_EXPR in that case.

2022-02-11  Richard Biener  <rguenther@suse.de>

PR middle-end/104497
* gimplify.c (gimplify_compound_lval): Make sure the
base is a non-register if needed and possible.

* c-c++-common/torture/pr104497.c: New testcase.

3 years agotree-optimization/105053 - fix reduction chain epilogue generation
Richard Biener [Fri, 25 Mar 2022 13:31:25 +0000 (14:31 +0100)] 
tree-optimization/105053 - fix reduction chain epilogue generation

When we optimize permutations in a reduction chain we have to
be careful to select the correct live-out stmt, otherwise the
reduction result will be unused and the retained scalar code will
execute only the number of vector iterations.

2022-03-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105053
* tree-vect-loop.c (vect_create_epilog_for_reduction): Pick
the correct live-out stmt for a reduction chain.

* g++.dg/vect/pr105053.cc: New testcase.

3 years ago[COMMITTED] Fix PR aarch64/104474: ICE with vector float initializers and non-consts.
Andrew Pinski [Wed, 9 Feb 2022 22:56:58 +0000 (14:56 -0800)] 
[COMMITTED] Fix PR aarch64/104474: ICE with vector float initializers and non-consts.

The problem here is that the aarch64 back-end was placing const0_rtx
into the constant vector RTL even if the mode was a floating point mode.
The fix is instead to use CONST0_RTX and pass the mode to select the
correct zero (either const_int or const_double).

Committed as obvious after a bootstrap/test on aarch64-linux-gnu with
no regressions.

PR target/104474

gcc/ChangeLog:

* config/aarch64/aarch64.c
(aarch64_sve_expand_vector_init_handle_trailing_constants):
Use CONST0_RTX instead of const0_rtx for the non-constant elements.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/pr104474-1.c: New test.
* gcc.target/aarch64/sve/pr104474-2.c: New test.
* gcc.target/aarch64/sve/pr104474-3.c: New test.

(cherry picked from commit 41582f88ec01c5ce2f85ebc4ac2743eb426d6e33)

3 years agotree-optimization/105070 - annotate bit cluster tests with locations
Richard Biener [Mon, 28 Mar 2022 08:07:53 +0000 (10:07 +0200)] 
tree-optimization/105070 - annotate bit cluster tests with locations

The following makes sure to annotate the tests generated by
switch lowering bit-clustering with locations which otherwise
can be completely lost even at -O0.

2022-03-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105070
* tree-switch-conversion.h
(bit_test_cluster::hoist_edge_and_branch_if_true): Add location
argument.
* tree-switch-conversion.c
(bit_test_cluster::hoist_edge_and_branch_if_true): Annotate
cond with location.
(bit_test_cluster::emit): Annotate all generated expressions
with location.

(cherry picked from commit bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717)

3 years agortl-optimization/105028 - fix compile-time hog in form_threads_from_copies
Richard Biener [Wed, 23 Mar 2022 11:21:32 +0000 (12:21 +0100)] 
rtl-optimization/105028 - fix compile-time hog in form_threads_from_copies

form_threads_from_copies processes a sorted array of copies, skipping
those with the same thread and conflicting threads and merging the
first non-conflicting ones.  After that it terminates the loop and
gathers the remaining elements of the array, skipping same thread
copies, re-starting the process.  For a large number of copies this
gathering of the rest takes considerable time and it also appears
pointless.  The following simply continues processing the array
which should be equivalent as far as I can see.

This takes form_threads_from_copies off the profile radar from
previously taking ~50% of the compile-time.

2022-03-23  Richard Biener  <rguenther@suse.de>

PR rtl-optimization/105028
* ira-color.c (form_threads_from_copies): Remove unnecessary
copying of the sorted_copies tail.

(cherry picked from commit 1daa198aafd72925ca8dd8616385f523ff180d4a)

3 years agotree-optimization/104880 - update-address-taken and cmpxchg
Richard Biener [Fri, 11 Mar 2022 13:09:33 +0000 (14:09 +0100)] 
tree-optimization/104880 - update-address-taken and cmpxchg

The following addresses optimistic non-addressable marking of
an argument of __atomic_compare_exchange_n which broke when
I added DECL_NOT_GIMPLE_REG_P since we cannot guarantee we can
rewrite it when TREE_ADDRESSABLE is unset.  Instead we have to
restore TREE_ADDRESSABLE in that case.

2022-03-11  Richard Biener  <rguenther@suse.de>

PR tree-optimization/104880
* tree-ssa.c (execute_update_address_taken): Remember if we
optimistically made something not addressable and
prepare to undo it.

* g++.dg/opt/pr104880.cc: New testcase.

(cherry picked from commit eb5edcf3f3ae008a1c55c88f08a886a5f350a759)

3 years agomiddle-end/105165 - sorry instead of ICE for _Complex asm goto
Richard Biener [Wed, 6 Apr 2022 11:46:56 +0000 (13:46 +0200)] 
middle-end/105165 - sorry instead of ICE for _Complex asm goto

Complex lowering cannot currently deal with asm gotos with _Complex
output operands.  Emit a sorry instead of ICEing, those should not
appear in practice.

2022-04-06  Richard Biener  <rguenther@suse.de>

PR middle-end/105165
* tree-complex.c (expand_complex_asm): Sorry for asm goto
_Complex outputs.

* gcc.dg/pr105165.c: New testcase.

(cherry picked from commit 54ed6563d22694aa3e1935f89641a4f696a3a9f7)

3 years agoDaily bump.
GCC Administrator [Thu, 7 Apr 2022 00:18:43 +0000 (00:18 +0000)] 
Daily bump.

3 years agoDaily bump.
GCC Administrator [Wed, 6 Apr 2022 00:18:36 +0000 (00:18 +0000)] 
Daily bump.

3 years agoDaily bump.
GCC Administrator [Tue, 5 Apr 2022 00:18:38 +0000 (00:18 +0000)] 
Daily bump.

3 years agoipa: Careful processing ANCESTOR jump functions and NULL pointers (PR 103083)
Martin Jambor [Mon, 4 Apr 2022 17:31:42 +0000 (19:31 +0200)] 
ipa: Careful processing ANCESTOR jump functions and NULL pointers (PR 103083)

IPA_JF_ANCESTOR jump functions are constructed also when the formal
parameter of the caller is first checked whether it is NULL and left
as it is if it is NULL, to accommodate C++ casts to an ancestor class.

The jump function type was invented for devirtualization and IPA-CP
propagation of tree constants is also careful to apply it only to
existing DECLs(*) but as PR 103083 shows, the part propagating "known
bits" was not careful about this, which can lead to miscompilations.

This patch introduces a flag to the ancestor jump functions which
tells whether a NULL-check was elided when creating it and makes the
bits propagation behave accordingly, masking any bits otherwise would
be known to be one.  This should safely preserve alignment info, which
is the primary ifnormation that we keep in bits for pointers.

(*) There still may remain problems when a DECL resides on address
zero (with -fno-delete-null-pointer-checks ...I hope it cannot happen
otherwise).  I am looking into that now but I think it will be easier
for everyone if I do so in a follow-up patch.

gcc/ChangeLog:

2022-02-11  Martin Jambor  <mjambor@suse.cz>

PR ipa/103083
* ipa-prop.h (ipa_ancestor_jf_data): New flag keep_null;
(ipa_get_jf_ancestor_keep_null): New function.
* ipa-prop.c (ipa_set_ancestor_jf): Initialize keep_null field of the
ancestor function.
(compute_complex_assign_jump_func): Pass false to keep_null
parameter of ipa_set_ancestor_jf.
(compute_complex_ancestor_jump_func): Pass true to keep_null
parameter of ipa_set_ancestor_jf.
(update_jump_functions_after_inlining): Carry over keep_null from the
original ancestor jump-function or merge them.
(ipa_write_jump_function): Stream keep_null flag.
(ipa_read_jump_function): Likewise.
(ipa_print_node_jump_functions_for_edge): Print the new flag.
* ipa-cp.c (class ipcp_bits_lattice): Make various getters const.  New
member function known_nonzero_p.
(ipcp_bits_lattice::known_nonzero_p): New.
(ipcp_bits_lattice::meet_with_1): New parameter drop_all_ones,
observe it.
(ipcp_bits_lattice::meet_with): Likewise.
(propagate_bits_across_jump_function): Simplify.  Pass true in
drop_all_ones when it is necessary.
(propagate_aggs_across_jump_function): Take care of keep_null
flag.
(ipa_get_jf_ancestor_result): Propagate NULL accross keep_null
jump functions.

gcc/testsuite/ChangeLog:

2021-11-25  Martin Jambor  <mjambor@suse.cz>

* gcc.dg/ipa/pr103083-1.c: New test.
* gcc.dg/ipa/pr103083-2.c: Likewise.

(cherry picked from commit 7ea3a73c195a79e6740ae594ee1a14c8bf7a938d)

3 years agolibstdc++: Make std::error_code printer more robust
Jonathan Wakely [Thu, 17 Feb 2022 17:23:36 +0000 (17:23 +0000)] 
libstdc++: Make std::error_code printer more robust

This attempts to implement a partial workaround for the GDB bug
https://sourceware.org/bugzilla/show_bug.cgi?id=28856 which causes GDB
to crash when printing a frame with a std::error_code argument.

By recognising the known error categories defined in the library and
hardcoding their names we do not need to call cat->name() on the
category.  This has the additional benefit of also working when
debugging a core file rather than a running process. For those known
categories we can also cast the int value to the corresponding error
code enum (e.g. future_errc) so that we show an enumerator instead of
just an integer.

For program-defined categories we just use the name of the dynamic type
to identify the category, and print the value as an integer. Once the
GDB bug is fixed and the virtual name() function can be called safely,
that would be preferable. For now it's better to have an imperfect
printer that doesn't crash GDB.

This rewritten StdErrorCodePrinter needs gdb.Value.dynamic_type, so is
only registered if that is supported, which means GDB 7.7 and later.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Replace
code that call cat->name() on std::error_category objects.
Identify known categories by symbol name and use a hardcoded
name. Print error code values as enumerators where appopriate.
* testsuite/libstdc++-prettyprinters/cxx11.cc: Adjust expected
name of custom category. Check io_errc and future_errc errors.

(cherry picked from commit 36100e0e952b92a6cd819620fcef851f0069ac8f)

3 years agolibstdc++: Add missing constraints to std::bit_cast [PR105027]
Jonathan Wakely [Wed, 23 Mar 2022 09:57:20 +0000 (09:57 +0000)] 
libstdc++: Add missing constraints to std::bit_cast [PR105027]

Our std::bit_cast was relying on the compiler to check for errors inside
__builtin_bit_cast, instead of checking them as constraints. That means
std::bit_cast was not SFINAE-friendly.

This fix uses a requires-clause, so for old versions of Clang without
concepts support the function will still be unconstrained. At some point
in future we can remove the #ifdef __cpp_concepts check and rely on all
compilers having full concepts support in C++20 mode.

libstdc++-v3/ChangeLog:

PR libstdc++/105027
* include/std/bit (bit_cast): Add constraints.
* testsuite/26_numerics/bit/bit.cast/105027.cc: New test.

(cherry picked from commit 4894d69a1f37d54b6a612e58053db477ff5ba832)

3 years agolibstdc++: Fix mismatched noexcept-specifiers in Filesystem TS
Jonathan Wakely [Mon, 27 Sep 2021 21:07:12 +0000 (22:07 +0100)] 
libstdc++: Fix mismatched noexcept-specifiers in Filesystem TS

The copy_file fix should have been part of r12-7063-gda72e0fd20f87b.

The path::begin() fix should have been part of r12-3930-gf2b7f56a15d9cb.
Thanks to Timm Bäder for reporting this one.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_fwd.h (copy_file): Remove
incorrect noexcept from declaration.
* include/experimental/bits/fs_path.h (path::begin, path::end):
Add noexcept to declarations, to match definitions.

(cherry picked from commit 944da70a5d1cdc5bd4327b2d32420f57b6883985)

3 years agolibstdc++: Adjust Filesystem TS test for Windows
Jonathan Wakely [Tue, 8 Feb 2022 12:45:46 +0000 (12:45 +0000)] 
libstdc++: Adjust Filesystem TS test for Windows

The Filesystem TS isn't really supported for Windows, but the FAIL for
this test is just because it doesn't match what happens on Windows.

libstdc++-v3/ChangeLog:

* testsuite/experimental/filesystem/operations/create_directories.cc:
Adjust expected results for Windows.

(cherry picked from commit 61b783995fac5355827ada1f8544052119a23606)

3 years agolibstdc++: Do not use dirent::d_type unconditionally
Jonathan Wakely [Tue, 1 Feb 2022 23:58:08 +0000 (23:58 +0000)] 
libstdc++: Do not use dirent::d_type unconditionally

These new tests should not use the d_type member unless it's actually
present on the OS.

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
autoconf macro to check whether d_type is present.
* testsuite/experimental/filesystem/iterators/error_reporting.cc:
Likewise.

(cherry picked from commit d98668eb06f532b2dbe0c721fa1b9ed6e643df27)

3 years agolibstdc++: Reset filesystem::recursive_directory_iterator on error
Jonathan Wakely [Mon, 31 Jan 2022 21:12:53 +0000 (21:12 +0000)] 
libstdc++: Reset filesystem::recursive_directory_iterator on error

The standard requires directory iterators to become equal to the end
iterator value if they report an error. Some members functions of
filesystem::recursive_directory_iterator fail to do that.

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (recursive_directory_iterator::increment):
Reset state to past-the-end iterator on error.
(fs::recursive_directory_iterator::pop(error_code&)): Likewise.
(fs::recursive_directory_iterator::pop()): Check _M_dirs before
it might get reset.
* src/filesystem/dir.cc (recursive_directory_iterator): Likewise,
for the TS implementation.
* testsuite/27_io/filesystem/iterators/error_reporting.cc: New test.
* testsuite/experimental/filesystem/iterators/error_reporting.cc: New test.

(cherry picked from commit ec09a5335f0ade7071f6157dfd97dbb3de3e4f97)

3 years agolibstdc++: Simplify std::allocator_traits<allocator<void>>::construct
Jonathan Wakely [Tue, 4 Jan 2022 16:39:01 +0000 (16:39 +0000)] 
libstdc++: Simplify std::allocator_traits<allocator<void>>::construct

We don't need a preprocessor condition to decide whether to use
placement new or std::construct_at, because std::_Construct already does
that.

libstdc++-v3/ChangeLog:

* include/bits/alloc_traits.h (allocator_traits<allocator<void>>):
Use std::_Construct for construct.

(cherry picked from commit 917c7b136e8b556b0027223058006a6caeb56871)

3 years agolibstdc++: Remove un-implementable noexcept from Filesystem TS operations
Jonathan Wakely [Fri, 4 Feb 2022 15:23:31 +0000 (15:23 +0000)] 
libstdc++: Remove un-implementable noexcept from Filesystem TS operations

LWG 3014 removed these incorrect noexcept specifications from the C++17
std::filesystem operations. They are also incorrect on the experimental
TS versions and should be removed from them too.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_ops.h (fs::copy_file): Remove
noexcept.
(fs::create_directories): Likewise.
(fs::remove_all): Likewise.
* src/filesystem/ops.cc (fs::copy_file): Remove noexcept.
(fs::create_directories): Likewise.
(fs::remove_all): Likewise.

(cherry picked from commit da72e0fd20f87bb523a81a505c00546d3622e9dd)

3 years agolibstdc++: Fix doxygen comment for filesystem::perms operators
Jonathan Wakely [Mon, 31 Jan 2022 14:11:34 +0000 (14:11 +0000)] 
libstdc++: Fix doxygen comment for filesystem::perms operators

libstdc++-v3/ChangeLog:

* include/bits/fs_fwd.h (filesystem::perms): Fix comment.

(cherry picked from commit 90263a48303a5ae552ea04c68ed7fa5da49b1876)

3 years agolibstdc++: Rename non-reserved macros in config header [PR103650]
Jonathan Wakely [Mon, 17 Jan 2022 11:24:35 +0000 (11:24 +0000)] 
libstdc++: Rename non-reserved macros in config header [PR103650]

libstdc++-v3/ChangeLog:

PR libstdc++/103650
* include/Makefile.am: Rename LT_OBJDIR and STDC_HEADERS.
* include/Makefile.in: Regenerate.
* testsuite/17_intro/headers/c++1998/103650.cc: New test.

(cherry picked from commit fa092570fbaf3bb4202e518eb8beba146c464d9f)

3 years agolibstdc++: Use __cpp_lib_concepts in std::reverse_iterator [PR104098]
Jonathan Wakely [Tue, 18 Jan 2022 15:34:24 +0000 (15:34 +0000)] 
libstdc++: Use __cpp_lib_concepts in std::reverse_iterator [PR104098]

We should not assume that std::iter_value_t etc. are defined
unconditionally for C++20 mode.

libstdc++-v3/ChangeLog:

PR libstdc++/104098
* include/bits/stl_iterator.h (reverse_iterator): Check
__cpp_lib_concepts instead of __cplusplus.

(cherry picked from commit e13e95bd274148a825bc9527efac49e99080dd64)

3 years agolibstdc++: Remove -gdwarf-4 from flags for debug library
Jonathan Wakely [Wed, 19 Jan 2022 19:29:42 +0000 (19:29 +0000)] 
libstdc++: Remove -gdwarf-4 from flags for debug library

The default is -gdwarf-5 now, so this is hurting rather than improving
things.

libstdc++-v3/ChangeLog:

* configure.ac (GLIBCXX_ENABLE_DEBUG_FLAGS): Remove -gdwarf-4
from default flags.
* configure: Regenerate.

(cherry picked from commit fe3e978027724f28d3e15747c991844793d42922)

3 years agolibstdc++: Document final option names for enabling C++20
Jonathan Wakely [Mon, 17 Jan 2022 11:26:21 +0000 (11:26 +0000)] 
libstdc++: Document final option names for enabling C++20

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2020.xml: Use final C++20 option
names.
* doc/html/manual/status.html: Regenerate.

(cherry picked from commit 5a3dc58a1d7a792e776a59389e8901b614ce6d0d)

3 years agolibstdc++: Add suggestion to std::uncaught_exception() warning
Jonathan Wakely [Thu, 3 Feb 2022 13:17:05 +0000 (13:17 +0000)] 
libstdc++: Add suggestion to std::uncaught_exception() warning

We should use the SUGGEST macro for std::uncaught_exception()
deprecation warnings.

libstdc++-v3/ChangeLog:

* include/bits/allocator.h: Qualify std::allocator_traits in
deprecated warnings.
* libsupc++/exception (uncaught_exception): Add suggestion to
deprecated warning.

(cherry picked from commit 27ba40559ccb887458009a34f710d4a22af85156)

3 years agolibstdc++: Add missing constexpr to uses-allocator construction utilities [PR104542]
Jonathan Wakely [Tue, 15 Feb 2022 12:47:39 +0000 (12:47 +0000)] 
libstdc++: Add missing constexpr to uses-allocator construction utilities [PR104542]

libstdc++-v3/ChangeLog:

PR libstdc++/104542
* include/bits/uses_allocator_args.h (make_obj_using_allocator)
(uninitialized_construct_using_allocator): Add constexpr.
* testsuite/20_util/uses_allocator/make_obj.cc: Check constexpr.
* testsuite/20_util/uses_allocator/uninitialized_construct.cc: New test.

(cherry picked from commit 6cfb7ffb659fd6b87a21312021ab023a06e8f6be)

3 years agolibstdc++: Fix filenames in Doxygen @file comments
Timm Bäder [Fri, 1 Apr 2022 10:03:45 +0000 (11:03 +0100)] 
libstdc++: Fix filenames in Doxygen @file comments

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/fs_ops.h: Fix filename in Doxygen comment.
* include/experimental/bits/fs_ops.h: Likewise.

(cherry picked from commit 1e9c026848dd871266305d7e52292e0e10897f31)

3 years agolibstdc++: Remove incorrect copyright notice from header
Jonathan Wakely [Tue, 8 Mar 2022 09:14:33 +0000 (09:14 +0000)] 
libstdc++: Remove incorrect copyright notice from header

This file has the SGI copyright notice, but contains no code from
the SGI STL. It was entirely written by me in 2019, originally as part
of the <memory> header. When I extracted it into a new header I
accidentally copied across the SGI copyright, but that only applies to
some much older parts of <memory>.

libstdc++-v3/ChangeLog:

* include/bits/uses_allocator_args.h: Remove incorrect copyright
notice.

(cherry picked from commit 7cce7b1c3d829172eb7f232e71ad194a0ad51931)

3 years agolibstdc++: Improve config output for --enable-cstdio [PR104301]
Jonathan Wakely [Mon, 31 Jan 2022 11:00:18 +0000 (11:00 +0000)] 
libstdc++: Improve config output for --enable-cstdio [PR104301]

Currently we just print "checking for underlying I/O to use... stdio"
unconditionally, whether configured to use stdio_pure or stdio_posix. We
should make it clear that the user's configure option chose the right
thing.

libstdc++-v3/ChangeLog:

PR libstdc++/104301
* acinclude.m4 (GLIBCXX_ENABLE_CSTDIO): Print different messages
for stdio_pure and stdio_posix options.
* configure: Regenerate.

(cherry picked from commit 19b8946dbda5fda4389ef8e3ea162c3df2b1998d)

3 years agoDaily bump.
GCC Administrator [Mon, 4 Apr 2022 08:03:01 +0000 (08:03 +0000)] 
Daily bump.

3 years agoi386: Fix up ix86_expand_vector_init_general [PR105123]
Jakub Jelinek [Sun, 3 Apr 2022 19:50:43 +0000 (21:50 +0200)] 
i386: Fix up ix86_expand_vector_init_general [PR105123]

The following testcase is miscompiled on ia32.
The problem is that at -O0 we end up with:
  vector(4) short unsigned int _1;
  short unsigned int u.0_3;
...
  _1 = {u.0_3, u.0_3, u.0_3, u.0_3};
statement (dead) which is wrongly expanded.
elt is (subreg:HI (reg:SI 83 [ u.0_3 ]) 0), tmp_mode SImode,
so after convert_mode we start with word (reg:SI 83 [ u.0_3 ]).
The intent is to manually broadcast that value to 2 SImode parts,
but because we pass word as target to expand_simple_binop, it will
overwrite (reg:SI 83 [ u.0_3 ]) and we end up with 0:
   10: {r83:SI=r83:SI<<0x10;clobber flags:CC;}
   11: {r83:SI=r83:SI|r83:SI;clobber flags:CC;}
   12: {r83:SI=r83:SI<<0x10;clobber flags:CC;}
   13: {r83:SI=r83:SI|r83:SI;clobber flags:CC;}
   14: clobber r110:V4HI
   15: r110:V4HI#0=r83:SI
   16: r110:V4HI#4=r83:SI
as the two ors do nothing and two shifts each by 16 left shift it all
away.
The following patch fixes that by using NULL_RTX target, so we expand it as
   10: {r110:SI=r83:SI<<0x10;clobber flags:CC;}
   11: {r111:SI=r110:SI|r83:SI;clobber flags:CC;}
   12: {r112:SI=r83:SI<<0x10;clobber flags:CC;}
   13: {r113:SI=r112:SI|r83:SI;clobber flags:CC;}
   14: clobber r114:V4HI
   15: r114:V4HI#0=r111:SI
   16: r114:V4HI#4=r113:SI
instead.

Another possibility would be to pass NULL_RTX only when word == elt
and word otherwise, where word would necessarily be a pseudo from the first
shift after passing NULL_RTX there once or pass NULL_RTX for the shift and
word for ior.

2022-04-03  Jakub Jelinek  <jakub@redhat.com>

PR target/105123
* config/i386/i386-expand.c (ix86_expand_vector_init_general): Avoid
using word as target for expand_simple_binop when doing ASHIFT and
IOR.

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

(cherry picked from commit e1a74058b784c845e84a0cf1997b54b984df483d)

3 years ago[PR105032] LRA: modify loop condition to find reload insns for hard reg splitting
Vladimir N. Makarov [Fri, 1 Apr 2022 13:48:57 +0000 (09:48 -0400)] 
[PR105032] LRA: modify loop condition to find reload insns for hard reg splitting

When trying to split hard reg live range to assign hard reg to a reload
pseudo, LRA searches for reload insns of the reload pseudo
assuming a specific order of the reload insns.  This order is violated if
reload involved in inheritance transformation. In such case, the loop used
for reload insn searching can become infinite.  The patch fixes this.

gcc/ChangeLog:

PR middle-end/105032
* lra-assigns.c (find_reload_regno_insns): Modify loop condition.

gcc/testsuite/ChangeLog:

PR middle-end/105032
* gcc.target/i386/pr105032.c: New.

3 years agoDaily bump.
GCC Administrator [Fri, 1 Apr 2022 00:18:46 +0000 (00:18 +0000)] 
Daily bump.

3 years agoDaily bump.
GCC Administrator [Thu, 31 Mar 2022 00:18:21 +0000 (00:18 +0000)] 
Daily bump.

3 years agoc-family: ICE with -Wconversion and A ?: B [PR101030]
Marek Polacek [Tue, 29 Mar 2022 18:36:55 +0000 (14:36 -0400)] 
c-family: ICE with -Wconversion and A ?: B [PR101030]

This patch fixes a crash in conversion_warning on a null expression.
It is null because the testcase uses the GNU A ?: B extension.  We
could also use op0 instead of op1 in this case, but it doesn't seem
to be necessary.

PR c++/101030

gcc/c-family/ChangeLog:

* c-warn.c (conversion_warning) <case COND_EXPR>: Don't call
conversion_warning when OP1 is null.

gcc/testsuite/ChangeLog:

* g++.dg/ext/cond5.C: New test.

(cherry picked from commit 5db9ce171019f8915885cebd5cc5f4101bb926e6)