platform/upstream/gcc.git
3 years agoFortran: Fix -freal-{4,8}-real* handling [PR99355]
Tobias Burnus [Thu, 4 Mar 2021 07:18:31 +0000 (08:18 +0100)]
Fortran: Fix -freal-{4,8}-real* handling [PR99355]

Avoid chain kind conversion for, e.g., -freal-4-real-8 -freal-8-real-10.
Note that gfc_default_double_kind/gfc_default_double_kind already
honors the -freal flags.

gcc/fortran/ChangeLog:

PR fortran/99355
* decl.c (gfc_match_old_kind_spec, gfc_match_kind_spec): Avoid
redoing kind conversions.
* primary.c (match_real_constant): Likewise.

gcc/testsuite/ChangeLog:

PR fortran/99355
* gfortran.dg/real4-10-real8-10.f90: New test.
* gfortran.dg/real4-10-real8-16.f90: New test.
* gfortran.dg/real4-10-real8-4.f90: New test.
* gfortran.dg/real4-10.f90: New test.
* gfortran.dg/real4-16-real8-10.f90: New test.
* gfortran.dg/real4-16-real8-16.f90: New test.
* gfortran.dg/real4-16-real8-4.f90: New test.
* gfortran.dg/real4-16.f90: New test.
* gfortran.dg/real4-8-real8-10.f90: New test.
* gfortran.dg/real4-8-real8-16.f90: New test.
* gfortran.dg/real4-8-real8-4.f90: New test.
* gfortran.dg/real4-8.f90: New test.
* gfortran.dg/real8-10.f90: New test.
* gfortran.dg/real8-16.f90: New test.
* gfortran.dg/real8-4.f90: New test.

3 years agoDaily bump.
GCC Administrator [Thu, 4 Mar 2021 00:16:48 +0000 (00:16 +0000)]
Daily bump.

3 years agogcc.misc-tests/outputs.exp: enumerate tests
Hans-Peter Nilsson [Wed, 3 Mar 2021 23:57:21 +0000 (00:57 +0100)]
gcc.misc-tests/outputs.exp: enumerate tests

Go from:
PASS: outputs asm default 1: outputs-0.s
PASS: outputs asm default 1: extra
PASS: outputs asm default 1: std out
PASS: outputs asm default 2: outputs-1.s
PASS: outputs asm default 2: outputs-2.s
PASS: outputs asm default 2: extra
PASS: outputs asm default 2: std out
PASS: outputs obj default 1: outputs-0.o
PASS: outputs obj default 1: extra
PASS: outputs obj default 1: std out
...

to:
PASS: outputs-1 asm default 1: outputs-0.s
PASS: outputs-1 asm default 1: extra
PASS: outputs-1 asm default 1: std out
PASS: outputs-2 asm default 2: outputs-1.s
PASS: outputs-2 asm default 2: outputs-2.s
PASS: outputs-2 asm default 2: extra
PASS: outputs-2 asm default 2: std out
PASS: outputs-3 obj default 1: outputs-0.o
PASS: outputs-3 obj default 1: extra
PASS: outputs-3 obj default 1: std out
...

thereby helping a human to quickly pin-point the result of a
specific test.

This mechanical patch was produced by applying
perl -pe 's/^(outest "\$b) /sprintf("%s-%d ",$1, ++$n)/e;'
to outputs.exp.

gcc/testsuite:
* gcc.misc-tests/outputs.exp: Enumerate tests.

3 years agogcc.misc-tests/outputs.exp: assert unique test-names
Hans-Peter Nilsson [Thu, 25 Feb 2021 05:03:47 +0000 (06:03 +0100)]
gcc.misc-tests/outputs.exp: assert unique test-names

The gcc.misc-tests/outputs.exp tests can take some effort to
digest.

Navigating and debugging causes for failing tests here isn't
helped by the existence of tests with duplicate names.
Let's stop that from happening.  This requires that test-run
output is actually reviewed, as Tcl errors don't stop the
test-run, but then again there's no such dejagnu construct
that I know of.

Tested x86_64-pc-linux-gnu.

gcc/testsuite:
* gcc.misc-tests/outputs.exp: Append discriminating
suffixes to tests with duplicate names.
(outest): Assert that each running test has a unique
name.

3 years agoCorrect a workaround for vectorized stores.
Martin Sebor [Wed, 3 Mar 2021 23:56:45 +0000 (16:56 -0700)]
Correct a workaround for vectorized stores.

Resolves:
PR middle-end/96963 - -Wstringop-overflow false positive with -ftree-vectorize when assigning consecutive char struct members
PR middle-end/94655 - -Wstringop-overflow on implicit string assignment with vectorized char store

gcc/ChangeLog:

PR middle-end/96963
PR middle-end/94655
* builtins.c (handle_array_ref): New helper.
(handle_mem_ref): New helper.
(compute_objsize_r): Factor out ARRAY_REF and MEM_REF handling
into new helper functions.  Correct a workaround for vectorized
assignments.

gcc/testsuite/ChangeLog:

PR middle-end/96963
PR middle-end/94655
* gcc.dg/Wstringop-overflow-47.c: Xfail tests.
* gcc.dg/Wstringop-overflow-65.c: New test.
* gcc.dg/Warray-bounds-69.c: Same.

3 years agoUpdate size attribute for Power10.
Pat Haugen [Wed, 3 Mar 2021 23:54:30 +0000 (17:54 -0600)]
Update size attribute for Power10.

2021-03-03  Pat Haugen  <pthaugen@linux.ibm.com>

gcc/
* config/rs6000/dfp.md (extendddtd2, trunctddd2, *cmp<mode>_internal1,
floatditd2, ftrunc<mode>2, fix<mode>di2, dfp_ddedpd_<mode>,
dfp_denbcd_<mode>, dfp_dxex_<mode>, dfp_diex_<mode>,
*dfp_sgnfcnc_<mode>, dfp_dscli_<mode>, dfp_dscri_<mode>): Update size
attribute for Power10.
* config/rs6000/mma.md (*movoo): Likewise.
* config/rs6000/rs6000.md (define_attr "size"): Add 256.
(define_mode_attr bits): Add DD/TD modes.
* config/rs6000/sync.md (load_quadpti, store_quadpti, load_lockedpti,
store_conditionalpti): Update size attribute for Power10.

3 years agoc++: Defer cloning to post-loading [PR 99170]
Nathan Sidwell [Wed, 3 Mar 2021 20:38:20 +0000 (12:38 -0800)]
c++: Defer cloning to post-loading [PR 99170]

It turns out that cloning can cause use to load things. Specifically when
checking paramter shadows (this is avoidable), and also the delete
operator of a deleting dtor (not avoidable).  Doing that in the middle of
loading is a bad thing.  This defers it to a post-load worklist.  If it
causes more loading at that point there is no problem, as we've completed
the first set of loads, bar this bit of cleanup.

Again, this doesn't fix 99170, but is a step towards a solution.

PR c++/99170
gcc/cp/
* module.cc (post_load_decls): New.
(lazy_snum, recursive_lazy): Move earlier.
(module_state::read_cluster): Push cloning onto post_load_decls.
(post_load_processing): New.  Do the cloning here.
(module_state::read_inits): Call post_load_processing.
(module_state::read_language): Likewise.
(lazy_load_binding, lazy_load_specializations): Likewise
(lazy_load_members): Likewise

3 years agoc++: Add fixed test [PR96474]
Marek Polacek [Wed, 3 Mar 2021 20:10:21 +0000 (15:10 -0500)]
c++: Add fixed test [PR96474]

Was happy to find out that my recent dguide fix (r11-7483) fixed
this test too.  In particular, the

+  /* Wait until the enclosing scope is non-dependent.  */
+  if (DECL_CLASS_SCOPE_P (tmpl)
+      && dependent_type_p (DECL_CONTEXT (tmpl)))
+    return ptype;

bit.

gcc/testsuite/ChangeLog:

PR c++/96474
* g++.dg/cpp1z/class-deduction83.C: New test.

3 years agoc++: Defer specialization registration [PR 99170]
Nathan Sidwell [Wed, 3 Mar 2021 19:22:56 +0000 (11:22 -0800)]
c++: Defer specialization registration [PR 99170]

This defers inserting specializations into the specialization table,
until we have completed their streaming.  When streaming a cluster we
ensure that all imports are populated before any of the cluster, so
they need no visibility of other specializations.  Further within the
same import, we've already partitioned the graph, so no earlier
cluster can be refering to a specialization in a later cluster.
Inserting them early causes problems when other specializations of the
same template are inserted.  (This doesn't fix 99170, but is a
necessary change for that PR).

Earlier on, I had less deferred processing, but it has become clearer
that deferred worklists are the right way of handling a few things.
This patch highlights a fixme, in that we're streaming a key twice,
and need not do that, but I wanted to get correctness first.  Besides
the second streaming will end up being a back reference, which is of
course much cheaper than a by-value stream.

PR c++/99170
gcc/cp/
* module.cc (trees_out::decl_value): Stream specialization keys
after decl.
(trees_in::decl_value): Stream them back and insert after
completing the decl.
(trees_out::key_mergeable): Drop some streaming here ...
(trees_in::key_mergeable): ... and here.  Don't insert into
specialization tables.

3 years agod: Fix heap-buffer-overflow in checkModFileAlias [PR 99337]
Iain Buclaw [Wed, 3 Mar 2021 14:34:04 +0000 (15:34 +0100)]
d: Fix heap-buffer-overflow in checkModFileAlias [PR 99337]

The code wrongly assumed memcmp did not read past the mismatch.

Reviewed-on: https://github.com/dlang/dmd/pull/12247

gcc/d/ChangeLog:

PR d/99337
* dmd/MERGE: Merge upstream dmd a3c9bf422.

3 years agoc++: Unify REQUIRES_EXPR evaluation / diagnostic routines
Patrick Palka [Wed, 3 Mar 2021 17:03:09 +0000 (12:03 -0500)]
c++: Unify REQUIRES_EXPR evaluation / diagnostic routines

This folds the diagnose_requires_expr routines into the corresponding
tsubst_requires_expr ones.  This is achieved by making the latter
routines take a sat_info instead of a subst_info, and assigning the
appropriate meanings to the flags sat_info::noisy and
sat_info::diagnose_unsatisfaction_p during tsubst_requires_expr:
info.noisy() controls whether to diagnose invalid types and expressions
inside the requirements, and info.diagnose_unsatisfaction_p() controls
whether to additionally diagnose why the requires-expression evaluates
to false.

gcc/cp/ChangeLog:

* constraint.cc (struct sat_info): Document the different
meanings of noisy() and diagnose_unsatisfaction_p() during
satisfaction and requires-expression evaluation.
(tsubst_valid_expression_requirement): Take a sat_info instead
of a subst_info.  Perform the substitution quietly first.  Fold
in error-replaying code from diagnose_valid_expression.
(tsubst_simple_requirement): Take a sat_info instead of a
subst_info.
(tsubst_type_requirement_1): New.  Fold in error-replaying code
from diagnose_valid_type.
(tsubst_type_requirement): Use the above.  Take a sat_info
instead of a subst_info.
(tsubst_compound_requirement): Likewise.  Fold in
error-replaying code from diagnose_compound_requirement.
(tsubst_nested_requirement): Take a sat_info instead of a
subst_info.  Fold in error-replaying code from
diagnose_nested_requirement.
(tsubst_requirement): Take a sat_info instead of a subst_info.
(tsubst_requires_expr): Split into two versions, one that takes
a sat_info argument and another that takes a complain and
in_decl argument.  Remove outdated documentation.  Document the
effects of the sat_info argument.  Don't short-circuit
processing of requirements when diagnosing unsatisfaction,
mirroring diagnose_requires_expr.
(satisfy_nondeclaration_constraint) <case REQUIRES_EXPR>: Remove
assert, and se the three-parameter version of tsubst_requires_expr.
(diagnose_trait_expr): Make static.  Take a template argument
vector instead of a parameter mapping.
(diagnose_valid_expression): Remove.
(diagnose_valid_type): Remove.
(diagnose_simple_requirement): Remove.
(diagnose_compound_requirement): Remove.
(diagnose_type_requirement): Remove.
(diagnose_nested_requirement): Remove.
(diagnose_requirement): Remove.
(diagnose_requires_expr): Remove.
(diagnose_atomic_constraint): Take a sat_info instead of a
subst_info.  Adjust call to diagnose_trait_expr.  Call
tsubst_requires_expr instead of diagnose_requires_expr.
(diagnose_constraints): Remove special casing of REQUIRES_EXPR
and just always call constraint_satisfaction_value.

3 years agoc++: Clean up normalization and satisfaction routines
Patrick Palka [Wed, 3 Mar 2021 17:01:13 +0000 (12:01 -0500)]
c++: Clean up normalization and satisfaction routines

This patch mostly performs some straightforward refactoring:

  - Renamed satisfy_constraint to satisfy_normalized_constraints
  - Renamed the three-parameter version of satisfy_constraint_expression
    to satisfy_nondeclaration_constraints
  - Removed normalize_(non)?template_requirements
  - Removed satisfy_associated_constraints (and made its callers
    check for dependent template args sooner, before normalization)
  - Removed the tsubst_flags_t parameter of evaluate_concept_check
  - Combined the two versions of constraint_satisfaction_value
  - Combined the two versions of constraint_satisfied_p

Additionally, this patch removes the handling of general
constraint-expressions from satisfy_nondeclaration_constraints, and
hence constraints_satisfied_p and constraint_satisfaction_value now take
only things that carry their own template information needed for
normalization, and, as a special case, REQUIRES_EXPRs.  But the latter
now get evaluated directly via tsubst_requires_expr rather than going
through satisfaction.

(That we used to evaluate REQUIRES_EXPR via satisfaction might even be a
correctness issue: since we cache satisfaction in special ways that don't
apply to regular evaluation, going through satisfaction could in theory
cause us to reuse a cached value for a REQUIRES_EXPR when we shouldn't
have.)

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_call_expression): Adjust call to
evaluate_concept_check.
(cxx_eval_constant_expression) <case REQUIRES_EXPR>: Use
evaluate_requires_expression instead of
satisfy_constraint_expression.
<case TEMPLATE_ID_EXPR>: Adjust call to evaluate_concept_check.
* constraint.cc (struct sat_info): Adjust comment about which
satisfaction entrypoints use noisy-unsat.
(normalize_template_requirements): Remove (and adjust callers
appropriately).
(normalize_nontemplate_requirements): Likewise.
(tsubst_nested_requirement): Use constraint_satisfaction_value
instead of satisfy_constraint_expression, which'll do the
noisy replaying of ill-formed quiet satisfaction for us.
(decl_satisfied_cache): Adjust comment.
(satisfy_constraint): Rename to ...
(satisfy_normalized_constraints): ... this.
(satisfy_associated_constraints): Remove (and make its
callers check for dependent arguments).
(satisfy_constraint_expression): Rename to ...
(satisfy_nondeclaration_constraints): ... this.  Assert that
'args' is empty when 't' is a concept-id.  Removing handling
bare constraint-expressions, and handle REQUIRES_EXPRs
specially.  Adjust comment accordingly.
(satisfy_declaration_constraints): Assert in the two-parameter
version that 't' is not a TEMPLATE_DECL.  Adjust following
removal of normalize_(non)?template_requirements and
satisfy_asociated_constraints.
(constraint_satisfaction_value): Combine the two- and
three-parameter versions in the natural way.
(constraints_satisfied_p): Combine the one- and two-parameter
versions in the natural way.  Improve documentation.
(evaluate_requires_expr): Define.
(evaluate_concept_check): Remove 'complain' parameter.  Use
constraint_satisfaction_value instead of
satisfy_constraint_expression.
(diagnose_nested_requirement): Adjust following renaming of
satisfy_constraint_expression.
(diagnose_constraints): Handle REQUIRES_EXPR by going through
diagnose_requires_expr directly instead of treating it as a
constraint-expression.  Improve documentation.
* cp-gimplify.c (cp_genericize_r) <case CALL_EXPR>: Adjust call
to evaluate_concept_check.
<case REQUIRES_EXPR>: Use evaluate_requires_expr instead of
constraints_satisfied_p.
<case TEMPLATE_ID_EXPR>: Adjust call to evaluate_concept_check.
* cp-tree.h (evaluate_requires_expr): Declare.
(evaluate_concept_check): Remove tsubst_flag_t parameter.
(satisfy_constraint_expression): Remove declaration.
(constraints_satisfied_p): Remove one-parameter declaration.
Add a default argument to the two-parameter declaration.
* cvt.c (convert_to_void): Adjust call to
evaluate_concept_check.

3 years agotestsuite: aarch64: Add tests for vcvt FP intrinsics
Jonathan Wright [Thu, 18 Feb 2021 19:01:06 +0000 (19:01 +0000)]
testsuite: aarch64: Add tests for vcvt FP intrinsics

Add tests for vcvtx* and vcvt_fXX_fXX floating-point Neon intrinsics.
Since these intrinsics are only supported for AArch64, these tests
are restricted to only run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-02-18  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vcvt_fXX_fXX.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vcvtx.c:
New test.

3 years agotestsuite: aarch64: Add tests for v[q]mov[u]n_high intrinsics
Jonathan Wright [Tue, 2 Mar 2021 17:37:54 +0000 (17:37 +0000)]
testsuite: aarch64: Add tests for v[q]mov[u]n_high intrinsics

Add tests for v[q]mov[u]n_high Neon intrinsics. Since these
intrinsics are only supported for AArch64, these tests are restricted
to only run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-03-02  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vmovn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vqmovn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vqmovun_high.c:
New test.

3 years agotestsuite: aarch64: Add tests for v[r]shrn_high intrinsics
Jonathan Wright [Tue, 2 Mar 2021 15:30:30 +0000 (15:30 +0000)]
testsuite: aarch64: Add tests for v[r]shrn_high intrinsics

Add tests for v[r]shrn_high Neon intrinsics. Since these intrinsics
are only supported for AArch64, these tests are restricted to only
run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-03-02  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vrshrn_high_n.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vshrn_high_n.c:
New test.

3 years agotestsuite: aarch64: Add tests for narrowing-arithmetic intrinsics
Jonathan Wright [Tue, 2 Mar 2021 11:57:31 +0000 (11:57 +0000)]
testsuite: aarch64: Add tests for narrowing-arithmetic intrinsics

Add tests for v[r]addhn_high and v[r]subhn_high Neon intrinsics.
Since these intrinsics are only supported for AArch64, these tests
are restricted to only run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-03-02  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vXXXhn_high.inc:
New test template.
* gcc.target/aarch64/advsimd-intrinsics/vaddhn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vraddhn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vrsubhn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vsubhn_high.c:
New test.

3 years agoc++: Fix -fstrong-eval-order for operator &&, || and , [PR82959]
Jakub Jelinek [Wed, 3 Mar 2021 15:12:23 +0000 (16:12 +0100)]
c++: Fix -fstrong-eval-order for operator &&, || and , [PR82959]

P0145R3 added
"However, the operands are sequenced in the order prescribed for the built-in
operator" rule for overloaded operator calls when using the operator syntax.
op_is_ordered follows that, but added just the overloaded operators
added in that paper.  &&, || and comma operators had rules that
lhs is sequenced before rhs already in C++98.
The following patch adds those cases to op_is_ordered.

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

PR c++/82959
* call.c (op_is_ordered): Handle TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR
and COMPOUND_EXPR.

* g++.dg/cpp1z/eval-order10.C: New test.

3 years agosparcv9: Disable -Wuninitialized warnings breaking bootstrap [PR92002]
Rainer Orth [Wed, 3 Mar 2021 15:01:50 +0000 (16:01 +0100)]
sparcv9: Disable -Wuninitialized warnings breaking bootstrap [PR92002]

sparcv9 bootstrap has been broken for 1 1/2 years now by spurious
-Wuninitialized warnings:

In function ‘wide_int wi::max_value(unsigned int, signop)’,
    inlined from ‘wide_int wi::max_value(unsigned int, signop)’ at /vol/gcc/src/hg/master/local/gcc/wide-int.cc:330:1:
/vol/gcc/src/hg/master/local/gcc/wide-int.cc:335:31: error: ‘<anonymous>.generic_wide_int<wide_int_storage>::<anonymous>.wide_int_storage::val[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
  335 |     return shwi (-1, precision);
      |                               ^
[...]
In function ‘wide_int get_nonzero_bits(const_tree)’,
    inlined from ‘wide_int get_nonzero_bits(const_tree)’ at /vol/gcc/src/hg/master/local/gcc/tree-ssanames.c:531:1:
/vol/gcc/src/hg/master/local/gcc/tree-ssanames.c:544:67: error: ‘<anonymous>.generic_wide_int<wide_int_storage>::<anonymous>.wide_int_storage::val[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
  544 |                          | (HOST_WIDE_INT) pi->misalign, precision);
      |                                                                   ^
[...]

Before we ship yet another release with this issue, I suggest to at
least include a workaround of demoting them to warnings.

Tested on sparcv9-sun-solaris2.11.

2021-03-03  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
PR bootstrap/92002
* config/sparc/t-sparc (tree-ssanames.o-warn): Don't error for
-Wuninitialized, -Wmaybe-uninitialized.
(wide-int.o-warn): Likewise.

3 years agoc++: ICE with deduction guide in checking type-dep [PR99009, PR97034]
Marek Polacek [Fri, 12 Feb 2021 17:21:15 +0000 (12:21 -0500)]
c++: ICE with deduction guide in checking type-dep [PR99009, PR97034]

We represent deduction guides with FUNCTION_DECLs, but they are built
without DECL_CONTEXT, leading to an ICE in type_dependent_expression_p
on the assert that the type of a function template with no dependent
(innermost!) template arguments must be non-dependent.  Consider the
attached class-deduction79.C: we create a deduction guide:

  template<class T> G(T)-> E<Z>::G<T>

we deduce T and create a partial instantiation:

  G(T) -> E<Z>::G<T> [with T = int]

And then do_class_deduction wants to create a CALL_EXPR from the above
using build_new_function_call -> build_over_call which calls mark_used
-> maybe_instantiate_noexcept -> type_dependent_expression_p.

There, the innermost template arguments are non-dependent (<int>), but
the fntype is dependent -- the return type is a TYPENAME_TYPE, and
since we have no DECL_CONTEXT, this check holds:

  /* Otherwise, if the function decl isn't from a dependent scope, it can't be
     type-dependent.  Checking this is important for functions with auto return
     type, which looks like a dependent type.  */
  if (TREE_CODE (expression) == FUNCTION_DECL
      && !(DECL_CLASS_SCOPE_P (expression)
           && dependent_type_p (DECL_CONTEXT (expression)))

whereupon we ICE.

This patch fixes it by deferring the class deduction until the
enclosing scope is non-dependent.  build_deduction_guide and maybe_aggr_guide
needed a little tweaking to make the deduction work in a member
template.

Co-Authored-By: Jason Merrill <jason@redhat.com>
gcc/cp/ChangeLog:

PR c++/97034
PR c++/99009
* pt.c (build_deduction_guide): Use INNERMOST_TEMPLATE_ARGS.
(maybe_aggr_guide): Use the original template type where needed.  In
a class member template, partially instantiate the result of
collect_ctor_idx_types.
(do_class_deduction): Defer the deduction until the enclosing
scope is non-dependent.

gcc/testsuite/ChangeLog:

PR c++/97034
PR c++/99009
* g++.dg/cpp1z/class-deduction81.C: New test.
* g++.dg/cpp1z/class-deduction82.C: New test.
* g++.dg/cpp2a/class-deduction-aggr8.C: New test.
* g++.dg/cpp2a/class-deduction-aggr9.C: New test.
* g++.dg/cpp2a/class-deduction-aggr10.C: New test.

3 years agoarm: Ignore --with-mode when CPU only supports one instruction set.
Richard Earnshaw [Tue, 2 Mar 2021 14:51:11 +0000 (14:51 +0000)]
arm: Ignore --with-mode when CPU only supports one instruction set.

Arm processors can support up to two instruction sets.  Some early
cores only support the traditional A32 (Arm) instructions, while some
more recent devices only support T32 (Thumb) instructions.

When configuring the compiler,--with-mode can be used to select the
default instruction set to target if the user has not made an explicit
choice, but this can cause needless problems if the default is not
supported by the requested CPU.

To fix this this patch adjusts the way that the --with-mode selection
is processed so that it can take into account the selected CPU or
architecture and not create a meaningless combination.

gcc:
* common/config/arm/arm-common.c: Include configargs.h.
(arm_config_default): New function.
(arm_target_mode): Renamed from arm_target_thumb_only.  Handle
processors that do not support Thumb.  Take into account the
--with-mode configuration setting for selecting the default.
* config/arm/arm.h (OPTION_DEFAULT_SPECS): Remove entry for 'mode'.
(TARGET_MODE_SPEC_FUNCTIONS): Update for function name change.

3 years agoc++: C++17 and decltype of multi-operator expression [PR95675]
Jason Merrill [Wed, 3 Mar 2021 04:59:00 +0000 (23:59 -0500)]
c++: C++17 and decltype of multi-operator expression [PR95675]

A call that is the immediate operand of decltype has special semantics: no
temporary is produced, so it's OK for the return type to be e.g. incomplete.
But we were treating (e | f) the same way, which confused overload
resolution when we then tried to evaluate ... | g.

Fixed by making build_temp do what its name says, and force the C++17
temporary materialization conversion.

gcc/cp/ChangeLog:

PR c++/95675
* call.c (build_temp): Wrap a CALL_EXPR in a TARGET_EXPR
if it didn't get one before.

gcc/testsuite/ChangeLog:

PR c++/95675
* g++.dg/cpp0x/decltype-call5.C: New test.
* g++.dg/cpp0x/decltype-call6.C: New test.

3 years agolibstdc++: Update Solaris baselines for GCC 11.1
Rainer Orth [Wed, 3 Mar 2021 13:25:51 +0000 (14:25 +0100)]
libstdc++: Update Solaris baselines for GCC 11.1

The following patch updates the Solaris baselines for GCC 11.1.  There's
only one caveat: comparing the Solaris 11.3 and 11.4 baselines, I find

+FUNC:_ZSt10from_charsPKcS0_RdSt12chars_format@@GLIBCXX_3.4.29
+FUNC:_ZSt10from_charsPKcS0_ReSt12chars_format@@GLIBCXX_3.4.29
+FUNC:_ZSt10from_charsPKcS0_RfSt12chars_format@@GLIBCXX_3.4.29

i.e.

std::from_chars(char const*, char const*, double&, std::chars_format)

and similarly for long double, float.  Those are from from
src/c++17/floating_from_chars.cc and only defined if
_GLIBCXX_HAVE_USELOCALE, i.e. depend on the XPG7 addition.  Given that
only Solaris 11.4 supports XPG7, I've taken the 11.3 baselines to avoid
having separate ones for 11.3 and 11.4.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (sparc and x86,
32 and 64-bit, 11.3 and 11.4).

2021-02-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
Likewise.
* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
Likewise.

3 years agogcov: use mmap pools for KVP.
Martin Liska [Wed, 13 Jan 2021 10:17:03 +0000 (11:17 +0100)]
gcov: use mmap pools for KVP.

gcc/ChangeLog:

PR gcov-profile/97461
* gcov-io.h (GCOV_PREALLOCATED_KVP): Remove.

libgcc/ChangeLog:

PR gcov-profile/97461
* config.in: Regenerate.
* configure: Likewise.
* configure.ac: Check sys/mman.h header file
* libgcov-driver.c (struct gcov_kvp): Remove static
pre-allocated pool and use a dynamic one.
* libgcov.h (MMAP_CHUNK_SIZE): New.
(gcov_counter_add): Use mmap to allocate pool for struct
gcov_kvp.

3 years agotestsuite: i386: Fix gcc.target/i386/pr95798-?.c on Solaris
Rainer Orth [Wed, 3 Mar 2021 12:49:28 +0000 (13:49 +0100)]
testsuite: i386: Fix gcc.target/i386/pr95798-?.c on Solaris

The new gcc.target/i386/pr95798-?.c tests FAIL on 64-bit Solaris/x86:

+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 1,
8\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 2,
16\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 3,
24\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 4,
32\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 5,
40\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 6,
48\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 7,
56\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 1,
8\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 2,
16\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 3,
24\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 4,
32\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 5,
40\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 6,
48\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 7,
56\\\\(%rsp,%r[a-z0-9]*,8\\\\)

This happens because Solaris/amd64 defaults to -fno-omit-frame-pointer
and can be avoided by always passing -fomit-frame-pointer.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2021-03-02  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* gcc.target/i386/pr95798-1.c: Add -fomit-frame-pointer to
dg-options.
* gcc.target/i386/pr95798-2.c: Likewise.

3 years agoc++: namespace reachability [PR 99344]
Nathan Sidwell [Fri, 26 Feb 2021 15:51:13 +0000 (07:51 -0800)]
c++: namespace reachability [PR 99344]

This reworks namespace serializing to avoid some issues I ran into
when working on 99170.  In modules, (non-anonymous) namespaces are
strange beasts, that always have external linkage, but may have
module-specific visibility.  I still don't get the latter 100%
correct, but this is in the right direction.

PR c++/99344
gcc/cp/
* module.cc (trees_out::decl_node): Small refactor.
(depset::hash::add_binding_entity): Return true on meeting an
import.  Set namespace's import here.
(module_state:write_namespaces): Inform of purview too.
(module_state:read_namespaces): Adjust.
* name-lookup.c (implicitly_export_namespace): Delete.
(do_pushdecl): Don't call it.
(push_namespace): Likewise, set purview.
(add_imported_namespace): Reorder parms.
* name-lookup.h (add_imported_namespace): Alter param ordering.
gcc/testsuite/
* g++.dg/modules/namespace-2_a.C
* g++.dg/modules/pr99344_a.C
* g++.dg/modules/pr99344_b.C

3 years agolibstdc++: Don't use reserved identifiers in simd headers
Rainer Orth [Wed, 3 Mar 2021 12:16:35 +0000 (13:16 +0100)]
libstdc++: Don't use reserved identifiers in simd headers

Two simd tests FAIL on Solaris, both SPARC and x86:

FAIL: experimental/simd/standard_abi_usable.cc -msse2 -O2 -Wno-psabi (test for excess errors)
FAIL: experimental/simd/standard_abi_usable_2.cc -msse2 -O2 -Wno-psabi (test for excess errors)

This happens because the simd headers use identifiers documented in the
libstdc++ manual as reserved by system headers.

Fixed as follows, tested on i386-pc-solaris2.11, sparc-sun-solaris2.11,
and x86_64-pc-linux-gnu.

2021-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* include/experimental/bits/simd.h: Replace reserved _X, _B by
_Xp, _Bp.
* include/experimental/bits/simd_builtin.h: Likewise.
* include/experimental/bits/simd_x86.h: Likewise.

3 years agoFix ICE with pathologically large frames
Eric Botcazou [Wed, 3 Mar 2021 11:25:03 +0000 (12:25 +0100)]
Fix ICE with pathologically large frames

gcc/
PR target/99234
* config/i386/i386.c (ix86_compute_frame_layout): For a SEH target,
point back the hard frame pointer to its default location when the
frame is larger than SEH_MAX_FRAME_SIZE.

3 years agoi386: Fix a peephole2 for -mavx512vl -mno-avx512bw [PR99321]
Jakub Jelinek [Wed, 3 Mar 2021 09:06:14 +0000 (10:06 +0100)]
i386: Fix a peephole2 for -mavx512vl -mno-avx512bw [PR99321]

As the testcase shows, the
(define_peephole2
  [(set (match_operand 0 "sse_reg_operand")
        (match_operand 1 "sse_reg_operand"))
   (set (match_dup 0)
        (match_operator 3 "commutative_operator"
          [(match_dup 0)
           (match_operand 2 "memory_operand")]))]
peephole2 can for AVX512VL without AVX512BW (I guess it is a hyphothetical
CPU, but unfortunately they are separate CPUID bits and we have separate
options for them) turn something that is valid without that peephole2
into something that is invalid (and in this case ICEs).
The problem is that the vpadd[bw], vpmullw, vpmin[su][bw] and vpmax[su][bw]
instructions require both AVX512BW and AVX512VL when they have
16-byte or 32-byte operands.  If operands[0] is %[xy]mm0 .. %[xy]mm15
but operands[1] is %[xy]mm16 .. %[xy]mm31, then before we have
a vector move which uses vmovdqa{32,64} and doesn't need AVX512BW,
AVX512VL is I think implied from HARD_REGNO_MODE_OK only supporting
V{16Q,32Q,8H,16H}imode in EXT_REX_SSE_REGNO_P regs with AVX512VL, and then
we have a commutative operation with that %[xy]mm0 .. %[xy]mm15 destination
and one source and a memory operand, so VEX encoded operation.
And, the peephole2 wants to replace it with a load into the destination
register from memory (ok) and then the commutative arith instruction.
But that needs EVEX encoding because of the high register and so requires
AVX512BW which might not be enabled.
The exception is and/ior/xor, because the hw doesn't have
vp{and,or,xor}{b,w} instructions at all, it uses vp{and,or,xor}d instead
and that of course doesn't need AVX512BW.

BTW, there are other bugs I need to look at, while the vp{min,max}ub with
16-byte operands instruction properly requires avx512bw for v constraints
and otherwise uses x, e.g. the vpadd[bw] etc. instructions don't.
I'll try to handle that incrementally later this week.

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

PR target/99321
* config/i386/predicates.md (logic_operator): New define_predicate.
* config/i386/i386.md (mov + mem using comm arith peephole2):
Punt if operands[1] is EXT_REX_SSE_REGNO_P, AVX512BW is not enabled
and the inner mode is [QH]Imode.

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

3 years agoc-family: Avoid ICE on va_arg [PR99324]
Jakub Jelinek [Wed, 3 Mar 2021 08:55:19 +0000 (09:55 +0100)]
c-family: Avoid ICE on va_arg [PR99324]

build_va_arg calls the middle-end mark_addressable, which e.g. requires that
cfun is non-NULL.  The following patch calls instead c_common_mark_addressable_vec
which is the c-family variant similarly to the FE c_mark_addressable and
cxx_mark_addressable, except that it doesn't error on addresses of register
variables.  As the taking of the address is artificial for the .VA_ARG
ifn and when that is lowered goes away, it is similar case to the vector
subscripting for which c_common_mark_addressable_vec has been added.

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

PR c/99324
* c-common.c (build_va_arg): Call c_common_mark_addressable_vec
instead of mark_addressable.  Fix a comment typo -
neutrallly -> neutrally.

* gcc.c-torture/compile/pr99324.c: New test.

3 years agodwarf2out: Fix -gsplit-dwarf on riscv or other non-.uleb128 targets [PR99090]
Jakub Jelinek [Wed, 3 Mar 2021 08:53:58 +0000 (09:53 +0100)]
dwarf2out: Fix -gsplit-dwarf on riscv or other non-.uleb128 targets [PR99090]

As mentioned in the PR, riscv* only supports .uleb128 with constant
arguments, doesn't support difference of two labels because of aggressive
linker relaxations.  But I bet various other targets, especially those not
using GNU assembler, might suffer from the same problem.
As the FIXME comment in output_loc_list indicates, we ICE on
-gsplit-dwarf on those targets whenever we need .debug_loclists, because
we only emit DW_LLE_startx_length which requires working .uleb128 delta
of 2 code section labels.  We can't use DW_LLE_base_addressx
once followed by DW_LLE_offset_pair either because the latter suffers
from the same issue - need .uleb128 difference of code section labels
(and in that case not just for the second operand but also for the first).

So, this patch implements what the comment said and emits DW_LLE_startx_endx
instead, which wastes more space in .debug_addr, but will work.

Bootstrapped/regtested on x86_64-linux and i686-linux and as written in the
PR, Jim has tested it on riscv*linux.  Ok for trunk?

BTW, for HAVE_AS_LEB128 -gdwarf-5 -gsplit-dwarf, maybe we should consider
instead of always emitting DW_LLE_startx_length do all the optimizations
that we do for HAVE_AS_LEB128 -gdwarf-5, or at least a subset of them.
For !have_multiple_function_sections, we in that case emit just
DW_LLE_offset_pair (that can certainly be a win for small TUs, we wouldn't
need any .debug_addr entry in that case; on the other side, just using
DW_LLE_offset_pair can be harmful for very large TUs especially if the
loclist has many entries, emitting in that case a single DW_LLE_base_address
or for -gsplit-dwarf DW_LLE_base_addressx followed by DW_LLE_offset_pair
might be much smaller), and for have_multiple_function_sections figuring
out if DW_LLE_base_address followed by DW_LLE_offset_pair entries
or DW_LLE_start_length is bettter.  So perhaps a middle-ground for
-gsplit-dwarf would be to always do the have_multiple_function_sections
behavior, i.e. DW_LLE_base_addressx followed by DW_LLE_offset_pair vs.
DW_LLE_startx_length decisions based on the ranges and their counts.
And perhaps dwz could optimize afterwards, on linked binaries or shared
libraries it knows all the offsets and could figure out optimal DW_LLE_*.

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

PR debug/99090
* dwarf2out.c (dw_loc_list_struct): Add end_entry member.
(new_loc_list): Clear end_entry.
(output_loc_list): Only use DW_LLE_startx_length for -gsplit-dwarf
if HAVE_AS_LEB128, otherwise use DW_LLE_startx_endx.  Fix comment
typo.
(index_location_lists): For dwarf_version >= 5 without HAVE_AS_LEB128,
initialize also end_entry.

3 years agocfgrtl: Fix up fixup_partitions caused ICE [PR99085]
Jakub Jelinek [Wed, 3 Mar 2021 08:51:54 +0000 (09:51 +0100)]
cfgrtl: Fix up fixup_partitions caused ICE [PR99085]

fixup_partitions sometimes changes some basic blocks from hot partition to
cold partition, in particular if after unreachable block removal or other
optimizations a hot partition block is dominated by cold partition block(s).
It fixes up the edges and jumps on those edges, but when after reorder
blocks and in rtl (non-cfglayout) mode that is clearly not enough, because
it keeps the block order the same and so we can end up with more than
1 hot/cold section transition in the same function.

So, this patch fixes that up too.

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

PR target/99085
* cfgrtl.c (fixup_partitions): When changing some bbs from hot to cold
partitions, if in non-layout mode after reorder_blocks also move
affected blocks to ensure a single partition transition.

* gcc.dg/graphite/pr99085.c: New test.

3 years agolibgfortran: Fix negation for largest integer [PR81986]
Tobias Burnus [Wed, 3 Mar 2021 07:05:45 +0000 (08:05 +0100)]
libgfortran: Fix negation for largest integer [PR81986]

libgfortran/ChangeLog:
2021-03-01  Vittorio Zecca  <zeccav@gmail.com>
    Tobias Burnus  <tobias@codesourcery.com>

PR libfortran/81986
* runtime/string.c (gfc_itoa): Cast to unsigned before
negating.

3 years agocgraph: flatten and same_body aliases [PR96078]
Jason Merrill [Fri, 12 Feb 2021 03:01:19 +0000 (22:01 -0500)]
cgraph: flatten and same_body aliases [PR96078]

The patch for PR92372 made us start warning about a flatten attribute on an
alias.  But in the case of C++ 'tor base/complete variants, the user didn't
create the alias.  If the alias target also has the attribute, the alias
points to a flattened function, so we shouldn't warn.

gcc/ChangeLog:

PR c++/96078
* cgraphunit.c (process_function_and_variable_attributes): Don't
warn about flatten on an alias if the target also has it.
* cgraph.h (symtab_node::get_alias_target_tree): New.

gcc/testsuite/ChangeLog:

PR c++/96078
* g++.dg/ext/attr-flatten1.C: New test.

3 years agolibbacktrace: don't special case file 0
Ian Lance Taylor [Wed, 3 Mar 2021 02:14:55 +0000 (18:14 -0800)]
libbacktrace: don't special case file 0

It's no longer necessary as file 0 is now set up in all cases.

* dwarf.c (read_line_program): Don't special case file 0.
(read_function_entry): Likewise.

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

3 years agoaix: Fix TLS thread pointer function names.
David Edelsohn [Tue, 2 Mar 2021 15:11:47 +0000 (10:11 -0500)]
aix: Fix TLS thread pointer function names.

This patch adds missing periods to the symbol name for TLS helper functions.

gcc/ChangeLog:

* config/rs6000/rs6000.md (tls_get_tpointer_internal): Prepend
period to symbol name.
(tls_get_addr_internal<mode>): Same.

3 years agooutputs.exp: skip @file -save-temps if target has -L or -I
Hans-Peter Nilsson [Thu, 25 Feb 2021 04:07:37 +0000 (05:07 +0100)]
outputs.exp: skip @file -save-temps if target has -L or -I

The outputs.exp tests check what temporary files are created
and left behind with e.g. -save-temps.

Additional files are created in presence of @file option.
Adding an -I or -L option causes *another* temporary file to
appear.  I take it that's deliberate, as there are tests for
that behavior.

For native testing, the default test-framework baseboard
file unix.exp doesn't add any -I or -L options and all tests
pass.  For a newlib target however, you'll have a couple of
-L options (see the nopts handling in outputs.exp), leading
to:

Running /x/gcc/gcc/testsuite/gcc.misc-tests/outputs.exp ...
FAIL: outputs exe savetmp namedb: extra
outputs.args.1
FAIL: outputs exe savetmp named2: extra
outputs.args.1
FAIL: outputs exe savetmp named2: extra
outputs.args.3
FAIL: outputs lto sing unnamed: extra
a.args.1

The failing tests are among the actual tests that check the
behavior of @file, and are confused by the additional -L.

Identify presence of -I or -L from the test framework and
skip those tests.

Tested cris-elf and x86_64-pc-linux-gnu.

gcc/testsuite:
* gcc.misc-tests/outputs.exp: Skip @file -save-temps
tests if target test-framework has -L or -I options.

3 years ago[PATCH] Fix Ada bootstrap failure on Cygwin since switch to C++11 (PR98590)
Mikael Pettersson [Tue, 2 Mar 2021 22:20:06 +0000 (15:20 -0700)]
[PATCH] Fix Ada bootstrap failure on Cygwin since switch to C++11 (PR98590)

gcc/ada
PR bootstrap/98590
* cstreams.c: Ensure fileno_unlocked() is visible on Cygwin.

3 years agocompiler: allow //go:embed in files underscore-importing embed
Michael Matloob [Tue, 2 Mar 2021 00:02:38 +0000 (19:02 -0500)]
compiler: allow //go:embed in files underscore-importing embed

The embed spec allows for //go:embed to be used in files that
underscore-import package "embed". This is useful for embeds to
[]byte and string vars because the embed.FS type may not be referenced
if those are the only types of embeds in a file. Because the compiler
previously checked whether there were any aliases to the embed
package to decide if //go:embed could be used, it would reject
files with only underscore imports of embed. Instead, record
whether the embed import is encountered at all, similar to what
is done with unsafe, to decide whether //go:embed is allowed.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/297553

3 years agolibbacktrace: pass -1 to error callback for unrecognized DWARF
Ian Lance Taylor [Tue, 2 Mar 2021 21:45:56 +0000 (13:45 -0800)]
libbacktrace: pass -1 to error callback for unrecognized DWARF

PR libbacktrace/98818
* dwarf.c (dwarf_buf_error): Add errnum parameter.  Change all
callers.
* backtrace.h: Update backtrace_error_callback comment.

3 years agodiagnostics: fix ICE on fix-it hints on very long lines [PR99323]
David Malcolm [Tue, 2 Mar 2021 20:46:06 +0000 (15:46 -0500)]
diagnostics: fix ICE on fix-it hints on very long lines [PR99323]

PR c/99323 describes an ICE due to a failed assertion deep inside the
fix-it printing machinery, where the fix-it hints on one line have not
been properly sorted in layout's constructor.

The underlying issue occurs when multiple fix-it hints affect a line
wider that LINE_MAP_MAX_COLUMN_NUMBER, where the location_t values for
characters after that threshold fall back to having column zero.

It's not meaningful to try to handle fix-it hints without column
information, so this patch rejects them as they are added to the
rich_location, falling back to the "no fix-it hints on this diagnostic"
case, fixing the crash.

gcc/ChangeLog:
PR c/99323
* diagnostic-show-locus.c
(selftest::test_one_liner_many_fixits_2): Fix accidental usage of
column 0.

gcc/testsuite/ChangeLog:
PR c/99323
* gcc.dg/pr99323-1.c: New test.
* gcc.dg/pr99323-2.c: New test.

libcpp/ChangeLog:
PR c/99323
* line-map.c (rich_location::maybe_add_fixit): Reject fix-it hints
at column 0.

3 years agoPR middle-end/99276 - grammar in diagnostics for overflowing the destination
Martin Sebor [Tue, 2 Mar 2021 20:37:01 +0000 (13:37 -0700)]
PR middle-end/99276 - grammar in diagnostics for overflowing the destination

gcc/ChangeLog:

PR middle-end/99276
* builtins.c (warn_for_access): Remove stray warning text.

3 years agoPR middle-end/99295 - documentation on __attribute__((malloc)) is wrong
Martin Sebor [Tue, 2 Mar 2021 18:19:49 +0000 (11:19 -0700)]
PR middle-end/99295 - documentation on __attribute__((malloc)) is wrong

gcc/ChangeLog:

PR middle-end/99295
* doc/extend.texi (attribute malloc): Reword and clarify nonaliasing
property.

3 years agoPR c++/99251 - inconsistent -Wnonnull warning behaviour with dynamic_cast
Martin Sebor [Tue, 2 Mar 2021 18:12:50 +0000 (11:12 -0700)]
PR c++/99251 - inconsistent -Wnonnull warning behaviour with dynamic_cast

gcc/cp/ChangeLog:

PR c++/99251
* class.c (build_base_path): Call build_if_nonnull.
* cp-tree.h (build_if_nonnull): Declare.
* rtti.c (ifnonnull): Rename...
(build_if_nonnull): ...to this.  Set no-warning bit on COND_EXPR.
(build_dynamic_cast_1): Adjust to name change.

gcc/testsuite/ChangeLog:

PR c++/99251
* g++.dg/warn/Wnonnull9.C: Expect no warnings.
* g++.dg/warn/Wnonnull12.C: New test.

3 years agodwarf2out: Fix up split-dwarf .debug_macro handling [PR99319]
Jakub Jelinek [Tue, 2 Mar 2021 17:25:45 +0000 (18:25 +0100)]
dwarf2out: Fix up split-dwarf .debug_macro handling [PR99319]

The -gsplit-dwarf changes came a few months after .debug_macro
and the r0-120109 changes just changed the 2nd operand of
DW_MACRO_GNU_{define,undef}_indirect from the usual .debug_str
section offset argument to leb128 index into .debug_str_offsets
without changing the opcodes.

DWARF5 standardized different opcodes for those, but GCC hasn't been changed
yet for that.
This patch starts using DW_MACRO_define_strx and DW_MACRO_undef_strx
instead of DW_MACRO_define_strp and DW_MACRO_undef_strp when -gsplit-dwarf
-gdwarf-5 -g3.  I'm not sure what to do if anything with the -gdwarf-4
-gsplit-dwarf -g3 -gno-strict-dwarf case, we've been emitting it that way
for 8 years and it is an extension, so presumably the consumers that cared
have already hacks to handle DW_MACRO_GNU_{define,undef}_indirect
differently in .debug_macro 4 sections depending on if it is
.debug_macro.dwo or .debug_macro.
Another change the patch does is that it will use
DW_MACRO_{define,undef}_str{p,x} even with -gdwarf-5 -gstrict-dwarf -g3,
for DWARF 4 we were doing that only for -gno-strict-dwarf as we've emitted
.debug_macro section only in that case.

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

PR debug/99319
* dwarf2out.c (output_macinfo_op): Use DW_MACRO_*_str* even with
-gdwarf-5 -gstrict-dwarf.  For -gsplit-dwarf -gdwarf-5 use
DW_MACRO_*_strx instead of DW_MACRO_*_strp.  Handle
DW_MACRO_define_strx and DW_MACRO_undef_strx.
(save_macinfo_strings): Use DW_MACRO_*_str* even with
-gdwarf-5 -gstrict-dwarf.  Handle DW_MACRO_define_strx and
DW_MACRO_undef_strx.

3 years agoFix PR ada/99095
Eric Botcazou [Tue, 2 Mar 2021 16:58:46 +0000 (17:58 +0100)]
Fix PR ada/99095

This is a regression present on the mainline and 10 branch, where we fail
to make the bounds explicit for the return value of a function returning
an unconstrained array of a limited record type.

gcc/ada/
PR ada/99095
* sem_ch8.adb (Check_Constrained_Object): Restrict again the special
optimization for limited types to non-array types except in the case
of an extended return statement.
gcc/testsuite/
* gnat.dg/limited5.adb: New test.

3 years agoanalyzer: remove dead code
Martin Liska [Tue, 2 Mar 2021 10:37:05 +0000 (11:37 +0100)]
analyzer: remove dead code

The issue is reported by Clang:

warning: private field 'm_engine' is not used [-Wunused-private-field]

gcc/analyzer/ChangeLog:

* diagnostic-manager.cc (diagnostic_manager::emit_saved_diagnostics):
Do not pass engine.

3 years agoc++: Fix satisfaction of placeholder type constraints [PR96443]
Patrick Palka [Tue, 2 Mar 2021 12:49:29 +0000 (07:49 -0500)]
c++: Fix satisfaction of placeholder type constraints [PR96443]

This fixes the way we check satisfaction of constraints on placeholder
types in various deduction contexts, and in particular when the
constraint is dependent.

Firstly, when evaluating the return type requirement of a compound
requirement, we currently substitute the outer template arguments into
the constraint before checking satisfaction. But we should instead be
passing in the complete set of template arguments to satisfaction and
not do a prior separate substitution.  Our current approach leads to us
incorrectly rejecting the testcase concepts-return-req2.C below.

Secondly, when checking the constraints on a placeholder variable or
return type, we don't consider the template arguments of the enclosing
context at all.  This leads to bogus errors during satisfaction when the
constraint is dependent as in the testcase concepts-placeholder3.C
below.

In order to fix these two issues, we need to be able to normalize the
constraints on a placeholder 'auto' on demand, which in turn requires us
to know the template parameters that were in scope where the 'auto' was
introduced.  This information currently doesn't seem to be easily available
when we need it, so this patch turns PLACEHOLDER_TYPE_CONSTRAINTS into a
TREE_LIST whose TREE_PURPOSE additionally holds the value of
current_template_parms whence a constrained 'auto' was formed.

This patch also removes some seemingly wrong handling of placeholder
type arguments from tsubst_parameter_mapping.  The code doesn't trigger
with the example used in the comments, because type_uses_auto doesn't
look inside non-deduced contexts such as the operand of decltype.  And
the call to do_auto_deduction seems confused because if 'arg' is a type,
then so is 'parm', and therefore 'init' too is a type, but
do_auto_deduction expects it to be an expression.  Before this patch,
this code was dead (as far as our testsuite can tell), but now it breaks
other parts of this patch, so let's remove it.

gcc/cp/ChangeLog:

PR c++/96443
PR c++/96960
* constraint.cc (type_deducible_p): Don't substitute into the
constraints, and instead just pass 'args' to do_auto_deduction
as the outer template arguments.
(tsubst_parameter_mapping): Remove confused code for handling
placeholder type arguments.
(normalize_placeholder_type_constraint): Define.
(satisfy_constraint_expression): Use it to handle placeholder
'auto' types.
* cp-tree.h (PLACEHOLDER_TYPE_CONSTRAINTS_INFO): Define.
(PLACEHOLDER_TYPE_CONSTRAINTS): Redefine in terms of the above.
* pt.c (tsubst) <case TEMPLATE_TYPE_PARM>: Use
PLACEHOLDER_TYPE_CONSTRAINTS_INFO instead.
(make_constrained_placeholder_type): Set
PLACEHOLDER_TYPE_CONSTRAINTS_INFO instead.
(do_auto_deduction): Clarify comments about the outer_targs
parameter.  Rework satisfaction of a placeholder type constraint
to pass in the complete set of template arguments directly to
constraints_satisfied_p.
(splice_late_return_type): Use PLACEHOLDER_TYPE_CONSTRAINTS_INFO
instead.  Also rebuild the the constraint info on the new auto.

gcc/testsuite/ChangeLog:

PR c++/96443
PR c++/96960
* g++.dg/concepts/abbrev9.C: New test.
* g++.dg/cpp2a/concepts-lambda15.C: New test.
* g++.dg/cpp2a/concepts-placeholder3.C: New test.
* g++.dg/cpp2a/concepts-return-req2.C: New test.
* g++.dg/cpp2a/concepts-ts1.C: Add dg-bogus directive to the
call to f15 that we expect to accept.

3 years agoc++: Delay normalizing nested requirements until satisfaction
Patrick Palka [Tue, 2 Mar 2021 12:38:41 +0000 (07:38 -0500)]
c++: Delay normalizing nested requirements until satisfaction

This sets up the functionality for controlling the initial set of
template parameters to pass to normalization when dealing with a
constraint-expression that is not associated with some constrained
declaration, for instance when normalizing a nested requirement of a
requires expression, or the constraints on a placeholder type.

The main new ingredient here is the data member norm_info::initial_parms
which can be set by callers of the normalization routines to communicate
the in-scope template parameters for the supplied constraint-expression,
rather than always falling back to using current_template_parms.

This patch then uses this functionality in our handling of nested
requirements so that we can delay normalizing them until needed for
satisfaction.  We currently immediately normalize nested requirements at
parse time, where we have the necessary template context, and cache the
normal form in their TREE_TYPE node.  With this patch, we now delay
normalization until needed (as with other constraint expressions), and
instead store the current value of current_template_parms in their
TREE_TYPE node (which we use to restore the template context at
normalization time).

In the subsequent patch, this functionality will also be used to
normalize placeholder type constraints during auto deduction.

gcc/cp/ChangeLog:

* constraint.cc (build_parameter_mapping): Rely on the caller to
determine the in-scope template parameters.
(norm_info::norm_info): Delegate the tsubst_flags_t constructor
to the two-parameter constructor.  In the two-parameter
constructor, fold in the definition of make_context, set
initial_parms appropriately, and don't set the now-removed
orig_decl member.
(norm_info::make_context): Remove, now that its only use is
inlined into the caller.
(norm_info::update_context): Adjust call to
build_parameter_mapping to pass in the relevant set of in-scope
template parameters.
(norm_info::ctx_parms): Define this member function.
(norm_info::context): Initialize to NULL_TREE.
(norm_info::orig_decl): Remove this data member.
(norm_info::initial_parms): Define this data member.
(normalize_atom): Adjust call to build_parameter_mapping to pass
in the relevant set of in-scope template parameters.  Use
info.initial_parms instead of info.orig_decl.
(normalize_constraint_expression): Take a norm_info object
instead of a bool.  Cache the result of normalization.
(tsubst_nested_requirement): Call satisfy_constraint_expression
instead of satisfy_constraint, so that we normalize on demand.
(satisfy_constraint_expression): Handle a NESTED_REQ argument.
Adjust call to normalize_constraint_expression.
(finish_nested_requirement): Set the TREE_TYPE of the NESTED_REQ
to current_template_parms.
(diagnose_nested_requirements): Go through
satisfy_constraint_expression, as with tsubst_nested_requirement.

3 years agoc++: Some preparatory type canonicalization fixes
Patrick Palka [Tue, 2 Mar 2021 12:38:37 +0000 (07:38 -0500)]
c++: Some preparatory type canonicalization fixes

The patches that follow revealed some latent type canonicalization
issues during normalization/satisfaction, due to normalization of
some constraint-expressions now being performed in different contexts
and more frequently (since the normalization caches get frequently
emptied in a checking compiler).  The issues are:

1. In tsubst_parameter_mapping, we canonicalize the arguments of a
   substituted TYPE_ARGUMENT_PACK only if the argument we started with
   wasn't a TYPE_ARGUMENT_PACK.  We should canonicalize a substituted
   TYPE_ARGUMENT_PACK regardless of what we started with.

2. We currently set DECL_CONTEXT and CONSTRAINT_VAR_P on each of the
   parameters introduced in a requires expression _after_ we're done
   processing the requirements.  But meanwhile we may have already
   built and computed the canonical form of a type that uses one of
   these PARM_DECLs (as say an operand to decltype).  But the canonical
   form depends on the result of cp_tree_equal, which in turn depends on
   the value of CONSTRAINT_VAR_P and DECL_CONTEXT.  So we must set these
   fields earlier, before processing requirements.

3. In do_auto_deduction, we use the result of finish_decltype_type later
   as a template argument, so we should canonicalize the result too.
   (While we're here, we should pass 'complain' to finish_decltype_type,
   which fixes the testcase auto1.C below.)

gcc/cp/ChangeLog:

* constraint.cc (tsubst_parameter_mapping): Canonicalize the
arguments of a substituted TYPE_ARGUMENT_PACK even if we've
started with a TYPE_ARGUMENT_PACK.
(finish_requires_expr): Don't set DECL_CONTEXT and
CONSTRAINT_VAR_P on each of the introduced parameters here.
* parser.c (cp_parser_requirement_parameter_list): Instead set
these fields earlier, here.
* pt.c (do_auto_deduction): Canonicalize the result of
do_auto_deduction.  Pass 'complain' to finish_decltype_type.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/auto1.C: New test.

3 years agoc++: Avoid building garbage trees from tsubst_requires_expr
Patrick Palka [Tue, 2 Mar 2021 12:38:13 +0000 (07:38 -0500)]
c++: Avoid building garbage trees from tsubst_requires_expr

Since we no longer partially instantiate REQUIRES_EXPRs, we don't need
to rebuild its requirements during tsubst_requires_expr.

gcc/cp/ChangeLog:

* constraint.cc (tsubst_simple_requirement): Just return
boolean_true_node on success.
(tsubst_type_requirement): Likewise.
(tsubst_compound_requirement): Likewise.
(tsubst_nested_requirement): Likewise.
(tsubst_requirement_body): Remove.
(check_constaint_variables): Rename to ...
(check_constraint_variables): ... this.
(tsubst_constraint_variables): Adjust.
(tsubst_requires_expr): Fold tsubst_requirement_body into here.

3 years agoIBM Z: arch14: New instrinsics
Andreas Krebbel [Tue, 2 Mar 2021 10:43:31 +0000 (11:43 +0100)]
IBM Z: arch14: New instrinsics

This adds support for 5 new builtins.

gcc/ChangeLog:

* config/s390/s390-builtin-types.def (BT_FN_V4SF_V8HI_UINT): New
builtin signature.
(BT_FN_V8HI_V8HI_UINT): Likewise.
(BT_FN_V8HI_V4SF_V4SF_UINT): Likewise.
* config/s390/s390-builtins.def (B_NNPA): New macro definition.
(s390_vclfnhs, s390_vclfnls, s390_vcrnfs, s390_vcfn, s390_vcnf):
New builtin definitions.
* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Bump
vector extension version.
* config/s390/s390.c (s390_expand_builtin): Check if builtins are
available with current -march level.
* config/s390/s390.md (UNSPEC_NNPA_VCLFNHS_V8HI)
(UNSPEC_NNPA_VCLFNLS_V8HI, UNSPEC_NNPA_VCRNFS_V8HI)
(UNSPEC_NNPA_VCFN_V8HI, UNSPEC_NNPA_VCNF_V8HI): New constants.
* config/s390/vecintrin.h (vec_extend_to_fp32_hi): New macro.
(vec_extend_to_fp32_lo): Likewise.
(vec_round_from_fp32): Likewise.
(vec_convert_to_fp16): Likewise.
(vec_convert_from_fp16): Likewise.
* config/s390/vx-builtins.md (vclfnhs_v8hi): New insn pattern.
(vclfnls_v8hi): Likewise.
(vcrnfs_v8hi): Likewise.
(vcfn_v8hi): Likewise.
(vcnf_v8hi): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/s390/zvector/vec-nnpa-fp16-convert.c: New test.
* gcc.target/s390/zvector/vec-nnpa-fp32-convert-1.c: New test.
* gcc.target/s390/zvector/vec_convert_from_fp16.c: New test.
* gcc.target/s390/zvector/vec_convert_to_fp16.c: New test.
* gcc.target/s390/zvector/vec_extend_to_fp32_hi.c: New test.
* gcc.target/s390/zvector/vec_extend_to_fp32_lo.c: New test.
* gcc.target/s390/zvector/vec_round_from_fp32.c: New test.

3 years agoIBM Z: arch14: Add command line options
Andreas Krebbel [Tue, 2 Mar 2021 10:43:30 +0000 (11:43 +0100)]
IBM Z: arch14: Add command line options

Prepare GCC for a future architecture extension.

gcc/ChangeLog:

* common/config/s390/s390-common.c (processor_flags_table): New entry.
* config.gcc: Enable arch14 for --with-arch and --with-tune.
* config/s390/driver-native.c (s390_host_detect_local_cpu): Pick
arch14 for unknown CPU models.
* config/s390/s390-opts.h (enum processor_type): Add PROCESSOR_ARCH14.
* config/s390/s390.c (s390_issue_rate): Add case for PROCESSOR_ARCH14.
(s390_get_sched_attrmask): Likewise.
(s390_get_unit_mask): Likewise.
* config/s390/s390.h (enum processor_flags): Add PF_NNPA and PF_ARCH14.
(TARGET_CPU_ARCH14, TARGET_CPU_ARCH14_P, TARGET_CPU_NNPA)
(TARGET_CPU_NNPA_P, TARGET_ARCH14, TARGET_ARCH14_P, TARGET_NNPA)
(TARGET_NNPA_P): New macro definitions.
* config/s390/s390.md ("cpu_facility", "enabled"): Add arch14 and nnpa.
* config/s390/s390.opt: Add PROCESSOR_ARCH14.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Add check for nnpa facility.

3 years agovrp: Improve register_edge_assert_for [PR95757]
Jakub Jelinek [Tue, 2 Mar 2021 10:49:12 +0000 (11:49 +0100)]
vrp: Improve register_edge_assert_for [PR95757]

The Wstringop-overflow-25.c testcase doesn't emit one of the expected
warnings on targets that don't do short curcuiting due to target costs
(or e.g. with --param=logical-op-non-short-circuit=0 on all targets).

The problem is that only reassoc2 optimizes:
  _49 ={v} unsigned_value_source;
  if (_49 == 0)
    goto <bb 7>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 5> [local count: 536870913]:
  if (_49 > 2)
    goto <bb 7>; [50.00%]
  else
    goto <bb 6>; [50.00%]

  <bb 6> [local count: 268435457]:
  _53 = _49 + 1;
into:
  _49 ={v} unsigned_value_source;
  _48 = _49 + 18446744073709551615;
  _1 = _48 > 1;
  if (_1 != 0)
    goto <bb 6>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 5> [local count: 268435457]:
  _53 = _49 + 1;
(but, note the _1 = _48 > 1; if (_1 != 0)),
then dom3 is run and because of that if (_1 != 0) vs. if (_48 > 1) doesn't
register edge asserts for _48 and _49) and so we don't get
SSA_NAME_RANGE_INFO for _53 (and ditto for vrp2) and only afterwards comes
forwprop4 that canonicalizes it to if (_48 > 1).  While with
--param=logical-op-non-short-circuit=1 it is already reassoc1 that optimizes
it and forwprop3 that propagates it, so we have on the SSA_NAME
corresponding to _53 above SSA_NAME_RANGE_INFO and during expansion we warn.

The following patch fixes it by handling those not yet propagated
comparisons into GIMPLE_COND in register_edge_assert_for.  We already
have all the infrastructure there to handle the --param=logical-op-non-short-circuit=1
| and &s.

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

PR middle-end/95757
* tree-vrp.c (register_edge_assert_for): Remove superfluous ()s around
condition.  Call register_edge_assert_for_1 for == 0, != 0, == 1 and
!= 1 comparisons if name is lhs of a comparison.

3 years agoIBM Z: Run mul-signed-overflow tests only on z14
Andreas Krebbel [Tue, 2 Mar 2021 09:55:25 +0000 (10:55 +0100)]
IBM Z: Run mul-signed-overflow tests only on z14

gcc/testsuite/ChangeLog:

* gcc.target/s390/mul-signed-overflow-1.c: Run only on z14.
* gcc.target/s390/mul-signed-overflow-2.c: Run only on z14.

3 years agoFix __sprintfkf prototype in libgcc.
Michael Meissner [Tue, 2 Mar 2021 03:13:33 +0000 (22:13 -0500)]
Fix __sprintfkf prototype in libgcc.

The prototype of __sprintfkf in _sprintfkf.h did not match the function in
_sprintfkf.c.  This patch fixes the prototype.  I also included the
_sprintfkf.h file in _sprintfkf.c to make sure the prototype is correct and to
eliminate a warning about declaring the function without a previous
declaration.

libgcc/
2021-03-01  Michael Meissner  <meissner@linux.ibm.com>

* config/rs6000/_sprintfkf.h (__sprintfkf): Fix prototype to match
the function.
* config/rs6000/_sprintfkf.c: Include _sprintfkf.h.

3 years agoDaily bump.
GCC Administrator [Tue, 2 Mar 2021 00:16:32 +0000 (00:16 +0000)]
Daily bump.

3 years agoDo not call Set_Cloned_Subtype on private type
Eric Botcazou [Tue, 2 Mar 2021 00:04:10 +0000 (01:04 +0100)]
Do not call Set_Cloned_Subtype on private type

Build_Discriminated_Subtype may be invoked on a E_Record_Type_With_Private,
in which case it builds a E_Record_Subtype_With_Private which does not have
the Cloned_Subtype field.

gcc/ada/
PR ada/99020
* sem_ch3.adb (Build_Discriminated_Subtype): Set the Cloned_Subtype
only if the type is not private.

3 years agodwarf2unwind : Force the CFA after remember/restore pairs [44107/48097].
Iain Sandoe [Mon, 18 Jan 2021 20:09:10 +0000 (20:09 +0000)]
dwarf2unwind : Force the CFA after remember/restore pairs [44107/48097].

This address one of the more long-standing and serious regressions
for Darwin.  GCC emits unwind code by default on the assumption that
the unwinder will be (of have the same capability) as the one in the
current libgcc_s.  For Darwin platforms, this is not the case - some
of them are based on the libgcc_s from GCC-4.2.1 and some are using
the unwinder provided by libunwind (part of the LLVM project). The
latter implementation has gradually adopted a section that deals with
GNU unwind.

The most serious problem for some of the platform versions is in
handling DW_CFA_remember/restore_state pairs.  The DWARF description
talks about these in terms of saving/restoring register rows; this is
what GCC originally did (and is what the unwinders do for the Darwin
versions based on libgcc_s).

However, in r118068, this was changed so that not only the registers
but also the current frame address expression were saved.  The unwind
code assumes that the unwinder will do this; some of Darwin's unwinders
do not, leading to lockups etc.  To date, the only solution has been
to replace the system libgcc_s with a newer one which is not a viable
solution for many end-users (since that means overwritting the one
provided with the system installation).

The fix here provides a target hook that allows the target to specify
that the CFA should be reinstated after a DW_CFA_restore.  This fixes
the issue (and also the closed WONTFIX of 44107).

(As a matter of record, it also fixes reported Java issues if
 backported to GCC-5).

gcc/ChangeLog:

PR target/44107
PR target/48097
* config/darwin-protos.h (darwin_should_restore_cfa_state): New.
* config/darwin.c (darwin_should_restore_cfa_state): New.
* config/darwin.h (TARGET_ASM_SHOULD_RESTORE_CFA_STATE): New.
* doc/tm.texi: Regenerated.
* doc/tm.texi.in: Document TARGET_ASM_SHOULD_RESTORE_CFA_STATE.
* dwarf2cfi.c (connect_traces): If the target requests, restore
the CFA expression after a DW_CFA_restore.
* target.def (TARGET_ASM_SHOULD_RESTORE_CFA_STATE): New hook.

3 years agos390: add exceptions for param modified by target pragma
Martin Liska [Mon, 1 Mar 2021 14:41:14 +0000 (15:41 +0100)]
s390: add exceptions for param modified by target pragma

gcc/ChangeLog:

PR target/99313
* optc-save-gen.awk: Add 4 more exceptions.

gcc/testsuite/ChangeLog:

PR target/99313
* gcc.target/s390/target-attribute/pr99313.c: New test.

3 years agoc++: Completeness of typedef structs [PR 99294]
Nathan Sidwell [Mon, 1 Mar 2021 13:41:10 +0000 (05:41 -0800)]
c++: Completeness of typedef structs [PR 99294]

When we read in a class definition, we use fixup_type_variants to
propagate the now-completed fields of the class's TYPE to other
variants.  Unfortunately that doesn't propagate all of them, and in
this case we had a typedef to an (incomplete) instantiation.  That
typedef ended up with a VOIDmode, which blew up gimple expansion as
the type itself isn't VOID.  Without modules, that information is
propagated in finalize_type_size when laying out the class.  But that
doesn't happen with stream-in -- we already know the layout.  There is
already some overlap between the two functions, now there's a bit
more.  In fixup_type_variants, I pay attention to the TYPE_NAME to
decide whether to override a user's TYPE_ALIGN -- variants of the
main-variant typedef just copy the main-variant.  Other variants
recalculate.  Overaligning is still permitted.

I also added a TYPE_ALIGN_RAW accessor, and fixed a bug in the
alignment streaming I noticed.  I did not refactor TYPE_ALIGN beyond
using the new accessor.  (It could be written as ((1 << align_raw) >>
1), rather than use the conditional.)

PR c++/99294
gcc/
* tree.h (TYPE_ALIGN_RAW): New accessor.
(TYPE_ALIGN): Use it.
gcc/cp/
* class.c (fixup_type_variants): Propagate mode, precision,
alignment & emptiness.
* module.cc (trees_out::type_node): Use TYPE_ALIGN_RAW.
(trees_in::tree_node): Rematerialize alignment here.
gcc/testsuite/
* g++.dg/modules/pr99294.h: New.
* g++.dg/modules/pr99294_a.C: New.
* g++.dg/modules/pr99294_b.C: New.

3 years agoFix ICE in compute_fn_summary
Jan Hubicka [Mon, 1 Mar 2021 13:36:11 +0000 (14:36 +0100)]
Fix ICE in compute_fn_summary

PR ipa/98338
* ipa-fnsummary.c (compute_fn_summary): Fix sanity check.

3 years agoFix wrong result for 1.0/3.0 at -O2 -fno-omit-frame-pointer -frounding-math
Eric Botcazou [Mon, 1 Mar 2021 06:53:05 +0000 (07:53 +0100)]
Fix wrong result for 1.0/3.0 at -O2 -fno-omit-frame-pointer -frounding-math

This wrong-code PR for the C++ compiler on x86-64/Windows is a regression
in GCC 9 and later, but the underlying issue has probably been there since
SEH was implemented and is exposed by this comment in config/i386/winnt.c:

  /* SEH records saves relative to the "current" stack pointer, whether
     or not there's a frame pointer in place.  This tracks the current
     stack pointer offset from the CFA.  */
  HOST_WIDE_INT sp_offset;

That's not what the (current) Microsoft documentation says; instead it says:

  /* SEH records offsets relative to the lowest address of the fixed stack
     allocation.  If there is no frame pointer, these offsets are from the
     stack pointer; if there is a frame pointer, these offsets are from the
     value of the stack pointer when the frame pointer was established, i.e.
     the frame pointer minus the offset in the .seh_setframe directive.  */

That's why the implementation is correct only under the condition that the
frame pointer be established *after* the fixed stack allocation; as a matter
of fact, that's clearly the model underpinning SEH, but is the opposite of
what is done e.g. on Linux.

However the issue is mostly papered over in practice because:

  1. SEH forces use_fast_prologue_epilogue to false, which in turns forces
save_regs_using_mov to false, so the general regs are always pushed when
they need to be saved, which eliminates the offset computation for them.

  2. As soon as a frame is larger than 240 bytes, the frame pointer is fixed
arbitrarily to 128 bytes above the stack pointer, which of course requires
that it be established after the fixed stack allocation.

So you need a small frame clobbering one of the call-saved XMM registers in
order to generate wrong SEH unwind info.

The attached fix makes sure that the frame pointer is always established
after the fixed stack allocation by pointing it at or below the lowest used
register save area, i.e. the SSE save area, and removing the special early
saves in the prologue; the end result is a uniform prologue sequence for
SEH whatever the frame size.  And it avoids a discrepancy between cases
where the number of saved general regs is even and cases where it is odd.

gcc/
PR target/99234
* config/i386/i386.c (ix86_compute_frame_layout): For a SEH target,
point the hard frame pointer to the SSE register save area instead
of the general register save area.  Perform only minimal adjustment
for small frames if it is initially not correctly aligned.
(ix86_expand_prologue): Remove early saves for a SEH target.
* config/i386/winnt.c (struct seh_frame_state): Document constraint.
gcc/testsuite/
* g++.dg/eh/seh-xmm-unwind.C: New test.

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

3 years agoUpdate gcc de.po, sv.po.
Joseph Myers [Sun, 28 Feb 2021 22:34:05 +0000 (22:34 +0000)]
Update gcc de.po, sv.po.

* de.po, sv.po: Update.

3 years agotestsuite, coroutines : Mark final awaiters and co_await operators noexcept.
Iain Sandoe [Sun, 28 Feb 2021 01:13:50 +0000 (01:13 +0000)]
testsuite, coroutines : Mark final awaiters and co_await operators noexcept.

This is part of the requirement of [dcl.fct.def.coroutine]/15.

In addition to promise final_suspend() calls, the following cases must
also be noexcept as per discussion in PR95616.

- finalSuspendObj.operator co_await()
- finalSuspendAwaiter.await_ready()
- finalSuspendAwaiter.await_suspend()
- finalSuspendAwaiter.await_resume()
- finalSuspedObj destructor
- finalSuspendAwaiter destructor

Fixed for missing cases in the testsuite as a prerequisite to fixing
PR95616.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr94879-folly-1.C: Make final suspend
expression components noexcept.
* g++.dg/coroutines/pr94883-folly-2.C: Likewise.
* g++.dg/coroutines/pr95345.C: Likewise.

3 years agoc++: Fix attr-lambda3.C
Jason Merrill [Sun, 28 Feb 2021 14:17:10 +0000 (09:17 -0500)]
c++: Fix attr-lambda3.C

Some testcase for a change I was testing had an unnecessary ; at the end of
a line that caused a test failure on the 10 branch, so I mistakenly removed
it from this one.  Oops.

gcc/testsuite/ChangeLog:

* g++.dg/ext/attr-lambda3.C: Add missing ;

3 years agofortran: Fix up wording of 3 OpenMP diagnostic messages [PR99303]
Jakub Jelinek [Sun, 28 Feb 2021 10:16:33 +0000 (11:16 +0100)]
fortran: Fix up wording of 3 OpenMP diagnostic messages [PR99303]

As reported in the PR, some diagnostic messages need wording improvements.

2021-02-28  Jakub Jelinek  <jakub@redhat.com>

PR fortran/99303
* openmp.c (gfc_omp_requires_add_clause): Fix up diagnostic message
wordings.
(resolve_omp_clauses): Likewise.

3 years agofortran: Replace double space in diagnostic with a single one [PR99300]
Jakub Jelinek [Sun, 28 Feb 2021 10:14:24 +0000 (11:14 +0100)]
fortran: Replace double space in diagnostic with a single one [PR99300]

The diagnostic had "  " in it instead of just " ".

2021-02-28  Jakub Jelinek  <jakub@redhat.com>

PR fortran/99300
* frontend-passes.c (doloop_code): Replace double space in diagnostics
with a single space.

3 years agotypos: Fix various typos - mainly misspelled reference* [PR99304]
Jakub Jelinek [Sun, 28 Feb 2021 10:10:44 +0000 (11:10 +0100)]
typos: Fix various typos - mainly misspelled reference* [PR99304]

The PR is about a typo in handle_malloc_attribute diagnostic message,
but grepping around I found many other cases and while fixing those I've
noticed a couple of other typos.

2021-02-28  Jakub Jelinek  <jakub@redhat.com>

PR c/99304
* ipa.c (symbol_table::remove_unreachable_nodes): Fix a comment
typo - referneced -> referenced.
* tree.c (component_ref_size): Fix comment typo -
refernce -> reference.
* tree-ssa-alias.c (access_path_may_continue_p): Fix comment typo -
traling -> trailing.
(aliasing_component_refs_p): Fix comment typos -
refernce -> reference and refernece -> reference and
traling -> trailing.
(nonoverlapping_refs_since_match_p): Fix comment typo -
referneces -> references.
* doc/invoke.texi (--param modref-max-bases): Fix a typo -
referneces -> references.
gcc/c-family/
* c-attribs.c (handle_malloc_attribute): Fix a typo in inform
message - refernced -> referenced.  Remove superfluous space before
closing paren of function calls.
gcc/lto/
* lto-symtab.c (lto_symtab_prevailing_virtual_decl): Fix comment
typos - refernced -> referenced and
devirtualizaiton -> devirtualization.

3 years agoDaily bump.
GCC Administrator [Sun, 28 Feb 2021 00:16:18 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: Allow GNU attributes before lambda -> [PR90333]
Jason Merrill [Fri, 26 Feb 2021 10:45:02 +0000 (05:45 -0500)]
c++: Allow GNU attributes before lambda -> [PR90333]

In my 9.3/10 patch for 90333 I allowed attributes between [] and (), and
after the trailing return type, but not in the place that GCC 8 expected
them, and we've gotten several bug reports about that.  So let's allow them
there, as well.

gcc/cp/ChangeLog:

PR c++/90333
* parser.c (cp_parser_lambda_declarator_opt): Accept GNU attributes
between () and ->.

gcc/testsuite/ChangeLog:

PR c++/90333
* g++.dg/ext/attr-lambda3.C: New test.

3 years agoDarwin : Update a disgnostic message [NFC].
Iain Sandoe [Sat, 27 Feb 2021 14:48:12 +0000 (14:48 +0000)]
Darwin : Update a disgnostic message [NFC].

The avoids a contraction and a format diagnostic warning.

gcc/ChangeLog:

* config/host-darwin.c (darwin_gt_pch_use_address): Modify
diagnostic message to avoid use of a contraction and format
warning.

3 years agolibgomp, testsuite : Require alias support for PR96390 testcase.
Iain Sandoe [Sat, 27 Feb 2021 14:52:20 +0000 (14:52 +0000)]
libgomp, testsuite : Require alias support for PR96390 testcase.

This fails everywhere on Darwin, which does not have support for
symbol aliases.  Add a dg-require-alias to UNSUPPORT it.

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/pr96390.c: Require alias
support from the target.

3 years agolibstdc++: Fix conversions from date types to integers [PR 99301]
Jonathan Wakely [Sat, 27 Feb 2021 12:50:53 +0000 (12:50 +0000)]
libstdc++: Fix conversions from date types to integers [PR 99301]

The conversions to integer types are explicit, so need to use the
correct type. Converting to uint32_t only works if that is the same type
as unsigned.

libstdc++-v3/ChangeLog:

PR libstdc++/99301
* include/std/chrono (year_month_day::_M_days_since_epoch()):
Convert chrono::month and chrono::day to unsigned before
converting to uint32_t.

3 years agogcse, ipa-devirt: Use %wd/%wu instead of HOST_WIDE_INT_PRINT* in diagnostics [PR99288]
Jakub Jelinek [Sat, 27 Feb 2021 09:43:28 +0000 (10:43 +0100)]
gcse, ipa-devirt: Use %wd/%wu instead of HOST_WIDE_INT_PRINT* in diagnostics [PR99288]

HOST_WIDE_INT_PRINT* in the string literals of warning/error/inform etc.
make those messages non-translatable, and we have a perfectly fine
alternative when not using system *printf - %w{d,u}.

2021-02-27  Jakub Jelinek  <jakub@redhat.com>

PR other/99288
* gcse.c (gcse_or_cprop_is_too_expensive): Use %wu instead of
HOST_WIDE_INT_PRINT_UNSIGNED in warning format string.
* ipa-devirt.c (ipa_odr_read_section): Use %wd instead of
HOST_WIDE_INT_PRINT_DEC in inform format string.  Fix comment
typos.

3 years agoDaily bump.
GCC Administrator [Sat, 27 Feb 2021 00:16:23 +0000 (00:16 +0000)]
Daily bump.

3 years agoanalyzer: implement exploded_path copy ctor
David Malcolm [Fri, 26 Feb 2021 21:35:32 +0000 (16:35 -0500)]
analyzer: implement exploded_path copy ctor

gcc/analyzer/ChangeLog:
* engine.cc (exploded_path::exploded_path): New copy-ctor.
* exploded-graph.h (exploded_path::operator=): Drop decl.

3 years agoUpdate gcc de.po.
Joseph Myers [Fri, 26 Feb 2021 19:32:34 +0000 (19:32 +0000)]
Update gcc de.po.

* de.po: Update.

3 years agorevert just-added duplicate fpic target requirement
Alexandre Oliva [Fri, 26 Feb 2021 15:27:55 +0000 (12:27 -0300)]
revert just-added duplicate fpic target requirement

A moment after pushing the previous patch, I noticed the fpic target
requirement markers had already been added to some of the files in the
patch from long ago that I've just contributed.  This patch reverts
the duplicates.

for  gcc/testsuite/ChangeLog

* gcc.target/powerpc/pr67789.c: Revert fpic target requirement
duplication.
* gcc.target/powerpc/pr83629.c: Likewise.
* gcc.target/powerpc/pr84112.c: Likewise.

3 years agoAdd missing dg-require-effective-target fpic directives to powerpc tests
Olivier Hainque [Fri, 26 Feb 2021 15:09:27 +0000 (12:09 -0300)]
Add missing dg-require-effective-target fpic directives to powerpc tests

for  gcc/testsuite/ChangeLog

* gcc.target/powerpc/compress-float-ppc-pic.c: Add
dg-require-effective-target fpic.
* gcc.target/powerpc/ppc-eabi.c: Likewise.
* gcc.target/powerpc/pr26350.c: Likewise.
* gcc.target/powerpc/pr67789.c: Likewise.
* gcc.target/powerpc/pr79439-1.c: Likewise.
* gcc.target/powerpc/pr79439-2.c: Likewise.
* gcc.target/powerpc/pr79439-3.c: Likewise.
* gcc.target/powerpc/pr83629.c: Likewise.
* gcc.target/powerpc/pr84112.c: Likewise.

3 years agomiddle-end/99281 - avoid bitfield stores into addressable types
Richard Biener [Fri, 26 Feb 2021 07:45:36 +0000 (08:45 +0100)]
middle-end/99281 - avoid bitfield stores into addressable types

This avoids doing bitfield stores into the return object of calls
when using return-slot optimization and the type is addressable.
Instead we have to pass down the original target RTX to the call
expansion which otherwise tries to create a new temporary.

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

PR middle-end/99281
* expr.c (store_field): For calls with return-slot optimization
and addressable return type expand the store directly.

* g++.dg/pr99218.C: New testcase.

3 years agoc++: Implement P1102R2 - Down with ()!
Jakub Jelinek [Fri, 26 Feb 2021 09:44:52 +0000 (10:44 +0100)]
c++: Implement P1102R2 - Down with ()!

The following patch implements P1102R2.
For attributes, we have already attribute parsing before the parameter
declarations and so when that is omitted, if the attributes are first we
already accept it.

2021-02-26  Jakub Jelinek  <jakub@redhat.com>

* parser.c (cp_parser_lambda_declarator_opt): Implement
P1102R2 - Down with ()! Make ()s optional before lambda specifiers
for -std={c,gnu}++2b or with pedwarn in earlier versions.

* g++.dg/cpp23/lambda-specifiers1.C: New test.

3 years agoc++: Fix operator() lookup in lambdas [PR95451]
Jakub Jelinek [Fri, 26 Feb 2021 09:43:28 +0000 (10:43 +0100)]
c++: Fix operator() lookup in lambdas [PR95451]

During name lookup, name-lookup.c uses:
            if (!(!iter->type && HIDDEN_TYPE_BINDING_P (iter))
                && (bool (want & LOOK_want::HIDDEN_LAMBDA)
                    || !is_lambda_ignored_entity (iter->value))
                && qualify_lookup (iter->value, want))
              binding = iter->value;
Unfortunately as the following testcase shows, this doesn't work in
generic lambdas, where we on the auto b = ... lambda ICE and on the
auto d = lambda reject it even when it should be valid.  The problem
is that the binding doesn't have a FUNCTION_DECL with
LAMBDA_FUNCTION_P for the operator(), but an OVERLOAD with
TEMPLATE_DECL for such FUNCTION_DECL.

The following patch fixes that in is_lambda_ignored_entity, other
possibility would be to do that before calling is_lambda_ignored_entity
in name-lookup.c.

2021-02-26  Jakub Jelinek  <jakub@redhat.com>

PR c++/95451
* lambda.c (is_lambda_ignored_entity): Before checking for
LAMBDA_FUNCTION_P, use OVL_FIRST.  Drop FUNCTION_DECL check.

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

3 years agoc/99275 - fix missing space in diagnostic
Richard Biener [Fri, 26 Feb 2021 07:50:17 +0000 (08:50 +0100)]
c/99275 - fix missing space in diagnostic

This fixes a missing space as reported by translators.

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

PR c/99275
* builtins.c (warn_string_no_nul): Fix diagnostic formatting.

3 years agoc++: Fix class NTTP constness handling [PR98810]
Jason Merrill [Thu, 25 Feb 2021 21:47:53 +0000 (16:47 -0500)]
c++: Fix class NTTP constness handling [PR98810]

Here, when substituting still-dependent args into an alias template, we see
a non-const type because the default argument is non-const, and is not a
template parm object because it's still dependent.

gcc/cp/ChangeLog:

PR c++/98810
* pt.c (tsubst_copy) [VIEW_CONVERT_EXPR]: Add const
to a class non-type template argument that needs it.

gcc/testsuite/ChangeLog:

PR c++/98810
* g++.dg/cpp2a/nontype-class-defarg1.C: New test.

3 years agors6000: Fix ICE in rs6000_init_builtins when compiling with -mcpu=440 [PR99279]
Peter Bergner [Fri, 26 Feb 2021 03:35:28 +0000 (21:35 -0600)]
rs6000: Fix ICE in rs6000_init_builtins when compiling with -mcpu=440 [PR99279]

The initialization of compat builtins assumes the builtin we are creating
a compatible builtin for exists and ICEs if it doesn't.  However, there are
valid reasons why some builtins are disabled for a particular compile.
In this case, the MMA builtins are disabled for -mcpu=440 (and other cpus),
so instead of ICEing, we should just skip adding the MMA compat builtin.

2021-02-25  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR target/99279
* config/rs6000/rs6000-call.c (rs6000_init_builtins): Replace assert
with an "if" test.

3 years agoOptimize pcrel access of globals
Aaron Sawdey [Wed, 7 Oct 2020 23:27:45 +0000 (18:27 -0500)]
Optimize pcrel access of globals

This patch implements a RTL pass that looks for pc-relative loads of the
address of an external variable using the PCREL_GOT relocation and a
single load or store that uses that external address.

Produced by a cast of thousands:
 * Michael Meissner
 * Peter Bergner
 * Bill Schmidt
 * Alan Modra
 * Segher Boessenkool
 * Aaron Sawdey

gcc/ChangeLog:

* config.gcc: Add rs6000-pcrel-opt.o.
* config/rs6000/rs6000-pcrel-opt.c: New file.
* config/rs6000/pcrel-opt.md: New file.
* config/rs6000/predicates.md: Add d_form_memory predicate.
* config/rs6000/rs6000-cpus.def: Add OPTION_MASK_PCREL_OPT.
* config/rs6000/rs6000-passes.def: Add pass_pcrel_opt.
* config/rs6000/rs6000-protos.h: Add reg_to_non_prefixed(),
pcrel_opt_valid_mem_p(), output_pcrel_opt_reloc(),
and make_pass_pcrel_opt().
* config/rs6000/rs6000.c (reg_to_non_prefixed): Make global.
(rs6000_option_override_internal): Add pcrel-opt.
(rs6000_delegitimize_address): Support pcrel-opt.
(rs6000_opt_masks): Add pcrel-opt.
(pcrel_opt_valid_mem_p): New function.
(reg_to_non_prefixed): Make global.
(rs6000_asm_output_opcode): Reset prepend_p_to_next_insn.
(output_pcrel_opt_reloc): New function.
* config/rs6000/rs6000.md (loads_extern_addr): New attr.
(pcrel_extern_addr): Set loads_extern_addr.
Add include for pcrel-opt.md.
* config/rs6000/rs6000.opt: Add -mpcrel-opt.
* config/rs6000/t-rs6000: Add rules for pcrel-opt.c and
pcrel-opt.md.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pcrel-opt-inc-di.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-df.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-di.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-hi.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-qi.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-sf.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-si.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-vector.c: New test.
* gcc.target/powerpc/pcrel-opt-st-df.c: New test.
* gcc.target/powerpc/pcrel-opt-st-di.c: New test.
* gcc.target/powerpc/pcrel-opt-st-hi.c: New test.
* gcc.target/powerpc/pcrel-opt-st-qi.c: New test.
* gcc.target/powerpc/pcrel-opt-st-sf.c: New test.
* gcc.target/powerpc/pcrel-opt-st-si.c: New test.
* gcc.target/powerpc/pcrel-opt-st-vector.c: New test.

3 years ago[PATCH v4 1/2] MIPS: unaligned load: use SImode for SUBREG if OK (PR98996) [PATCH...
YunQiang Su [Fri, 26 Feb 2021 02:55:10 +0000 (19:55 -0700)]
[PATCH v4 1/2] MIPS: unaligned load: use SImode for SUBREG if OK (PR98996) [PATCH v4 2/2] ada: add 128bit operation for MIPS N32 and N64

gcc/ChangeLog:

PR target/98996
* config/mips/mips.c (mips_expand_ext_as_unaligned_load):
If TARGET_64BIT and dest is SUBREG, we check the width, if it
equal to SImode, we use SImode operation, just like what we are
doing for REG one.

gcc/ada/ChangeLog:

PR ada/98996
* Makefile.rtl: <mips*-*-linux*>
add 128Bit operation file for MIPS N64 and N32 to
LIBGNAT_TARGET_PAIRS and EXTRA_GNATRTL_NONTASKING_OBJS

3 years agobuiltins: Fix typos in warn_for_access [PR99278]
Marek Polacek [Fri, 26 Feb 2021 00:12:52 +0000 (19:12 -0500)]
builtins: Fix typos in warn_for_access [PR99278]

gcc/ChangeLog:

* builtins.c (warn_for_access): Fix typos.

3 years agolibgo: ensure memmove, memset 8 byte atomicity on ppc64x
Lynn Boger [Mon, 22 Feb 2021 15:12:01 +0000 (09:12 -0600)]
libgo: ensure memmove, memset 8 byte atomicity on ppc64x

Go requires that pointer moves are done 8 bytes at a time,
but gccgo uses libc's memmove and memset which does not require
that, and there are some cases where an 8 byte move might be
done as 4+4.

To enforce 8 byte moves for memmove and memset, this adds a
C implementation in libgo/runtime for memmove and memset to be
used on ppc64le and ppc64. Asm implementations were considered
but discarded to avoid different implementations for different
target ISAs.

Fixes golang/go#41428

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/294931

3 years agoanalyzer: eliminate dedupe_candidate [PR96374]
David Malcolm [Fri, 26 Feb 2021 01:00:12 +0000 (20:00 -0500)]
analyzer: eliminate dedupe_candidate [PR96374]

In gcc/analyzer/diagnostic-manager.cc the code partitions
saved_diagnostic instances by dedupe_key, and tries to find the "best"
saved_diagnostic for each dedupe_key.

Ideally we would find the shortest feasible path for each
saved_diagnostic and pick the winner in each deduplication set.

Currently we merely approximate that by finding the shortest path for
each saved_diagnostic, and checking to see if it feasible, rejecting
the saved_diagnostic if it is not.  The "shortest path, or nothing if
it's infeasible" is not the same as the "shortest feasible path", and
this leads to false negatives, where we reject valid diagnostics,
tracked as PR analyzer/96374.

I have been attempting various fixes for this, but in doing so I
found that the existing structure of the code makes things unnecessarily
awkward: each dedupe_set had a a dedupe_candidate which stored the
best epath for that set, creating it from the shortest path when that
dedupe_candidate was constructed.

This patch eliminates the dedupe_candidate, instead storing the best
epath for each saved_diagnostic within the saved_diagnostic itself,
along with any feasibility_problem, and eliminating a redundant "status"
field.  The logic for finding the best epath is moved to a new
epath_finder::get_best_epath subroutine, introducing an epath_finder
class to give a place to cache state.

This patch merely copies over the existing logic to
epath_finder::get_best_epath, so no functional change is intended,
but the patch simplifies the logic and makes it much easier to
experiment with alternate implementations as I try to fix
PR analyzer/96374.

I attempted another version of this patch in which I added a dedupe_set
class and partitioned saved_diagnostics into them as the diagnostics were
added, but in this earlier iteration of the patch there were regressions
e.g. from gcc.dg/analyzer/zlib-4.c where 4 deduplication sets became 3.
The issue was that the deduplication logic needs source locations, which
need gimple statements, and the stmt_finder needs epaths to run.  Finding
the epaths needs the full egraph (as opposed to the egraph in its state
at the time when the diagnostic is saved).  Hence the partitioning needs to
happen after the egraph is fully explored.  I backed up the earlier patch
kit to:
  https://dmalcolm.fedorapeople.org/gcc/2021-02-23/feasibility-v0.3-relative-to-72d78655a91bb2f89ac4432cfd6374380d6f9987/

gcc/analyzer/ChangeLog:
PR analyzer/96374
* diagnostic-manager.cc (class epath_finder): New.
(epath_finder::get_best_epath): New.
(saved_diagnostic::saved_diagnostic): Update for replacement of
m_state and m_epath_length with m_best_epath.
(saved_diagnostic::~saved_diagnostic): Delete m_best_epath.
(saved_diagnostic::to_json): Update "path_length" to be optional.
(saved_diagnostic::calc_best_epath): New, based on
dedupe_winners::add and parts of dedupe_key::dedupe_key.
(saved_diagnostic::get_epath_length): New.
(saved_diagnostic::add_duplicate): New.
(dedupe_key::dedupe_key): Drop epath param.  Move invocation of
stmt_finder to saved_diagnostic::calc_best_epath.
(class dedupe_candidate): Delete.
(class dedupe_hash_map_traits): Update to use saved_diagnotic *
rather than dedupe_candidate * as the value_type/compare_type.
(dedupe_winners::~dedupe_winners): Don't delete the values.
(dedupe_winners::add): Convert param from shortest_exploded_paths to
epath_finder.  Drop "eg" param.  Drop dedupe_candidate, moving
path generation and feasiblity checking to
epath_finder::get_best_epath.  Update winner-selection for move
of epaths from dedupe_candidate to saved_diagnostic.
(dedupe_winners::emit_best):  Update for removal of class
dedupe_candidate.
(dedupe_winners::map_t): Update to use saved_diagnotic * rather
than dedupe_candidate * as the value_type/compare_type.
(diagnostic_manager::emit_saved_diagnostics): Move
shortest_exploded_paths instance into epath_finder and pass that
around instead.
(diagnostic_manager::emit_saved_diagnostic): Drop epath, stmt
and num_dupes params, instead getting these from the
saved_diagnostic.  Use correct location in inform_n call.
* diagnostic-manager.h (class epath_finder): New forward decl.
(saved_diagnostic::status): Drop enum.
(saved_diagnostic::set_feasible): Drop.
(saved_diagnostic::set_infeasible): Drop.
(saved_diagnostic::get_status): Drop.
(saved_diagnostic::calc_best_epath): New decl.
(saved_diagnostic::get_best_epath): New decl.
(saved_diagnostic::get_epath_length): New decl.
(saved_diagnostic::set_epath_length): Drop.
(saved_diagnostic::get_epath_length): Drop inline implementation.
(saved_diagnostic::add_duplicate): New.
(saved_diagnostic::get_num_dupes): New.
(saved_diagnostic::m_d): Document ownership.
(saved_diagnostic::m_trailing_eedge): Make const.
(saved_diagnostic::m_status): Drop field.
(saved_diagnostic::m_epath_length): Drop field.
(saved_diagnostic::m_best_epath): New field.
(saved_diagnostic::m_problem): Document ownership.
(saved_diagnostic::m_duplicates): New field.
(diagnostic_manager::emit_saved_diagnostic): Drop params epath,
stmt, and num_dupes.
* engine.cc (exploded_graph_annotator::print_saved_diagnostic):
Update for changes to saved_diagnostic class.
* exploded-graph.h (exploded_path::feasible_p): Drop unused
overloaded decl.

3 years agoc++: abbreviated function template return type rewriting [PR98990]
Patrick Palka [Fri, 26 Feb 2021 00:55:43 +0000 (19:55 -0500)]
c++: abbreviated function template return type rewriting [PR98990]

When an abbreviated function template has a complex placeholder return
type such auto& or auto**, the level adjustment performed by
splice_late_return_type directly replaces the 'auto' inside the original
return type with the level-adjusted 'auto', but that breaks
TYPE_CANONICAL caching.  Instead, we should rebuild the entire return
type using the adjusted 'auto'.

This patch makes this happen by tsubsting the original return type with
an argument vector that maps the original 'auto' to the adjusted 'auto'.
In passing, this patch also reverts the misguided changes to
find_type_usage in r10-6571 that made find_type_usage return a tree*
instead of a tree so as to discourage this kind of in-place type
modification.

It occurred to me that the constraint also needs to be rebuilt so that
it refers to the adjusted 'auto', but this oversight doesn't seem to
cause any issues at the moment due to how do_auto_deduction "manually"
substitutes the 'auto' inside the constraint before performing
satisfaction.  So this'll be fixed later as part of a rework of
placeholder type constraint checking.

gcc/cp/ChangeLog:

PR c++/98990
* pt.c (splice_late_return_type): Rebuild the entire return type
if we have to adjust the level of an auto within.
(type_uses_auto): Adjust call to find_type_usage.
* type-utils.h (find_type_usage): Revert r10-6571 change that
made this function return a pointer to the auto node.

gcc/testsuite/ChangeLog:

PR c++/98990
* g++.dg/concepts/abbrev8.C: New test.

3 years agoDaily bump.
GCC Administrator [Fri, 26 Feb 2021 00:16:36 +0000 (00:16 +0000)]
Daily bump.

3 years agoopenmp: Fix intermittent hanging of task-detach-6 libgomp tests [PR98738]
Kwok Cheung Yeung [Thu, 21 Jan 2021 13:38:47 +0000 (05:38 -0800)]
openmp: Fix intermittent hanging of task-detach-6 libgomp tests [PR98738]

This adds support for the task detach clause to taskwait and taskgroup, and
simplifies the handling of the detach clause by moving most of the extra
handling required for detach tasks to omp_fulfill_event.

2021-02-25  Kwok Cheung Yeung  <kcy@codesourcery.com>
    Jakub Jelinek  <jakub@redhat.com>

libgomp/

PR libgomp/98738
* libgomp.h (enum gomp_task_kind): Add GOMP_TASK_DETACHED.
(struct gomp_task): Replace detach and completion_sem fields with
union containing completion_sem and detach_team.  Add deferred_p
field.
(struct gomp_team): Remove task_detach_queue.
* task.c: Include assert.h.
(gomp_init_task): Initialize deferred_p and completion_sem fields.
Rearrange initialization order of fields.
(task_fulfilled_p): Delete.
(GOMP_task): Use address of task as the event handle.  Remove
initialization of detach field.  Initialize deferred_p field.
Use automatic local for completion_sem.  Initialize detach_team field
for deferred tasks.
(gomp_barrier_handle_tasks): Remove handling of task_detach_queue.
Set kind of suspended detach task to GOMP_TASK_DETACHED and
decrement task_running_count.  Move finish_cancelled block out of
else branch.  Relocate call to gomp_team_barrier_done.
(GOMP_taskwait): Handle tasks with completion events that have not
been fulfilled.
(GOMP_taskgroup_end): Likewise.
(omp_fulfill_event): Use address of task as event handle.  Post to
completion_sem for undeferred tasks.  Clear detach_team if task
has not finished.  For finished tasks, handle post-execution tasks,
call gomp_team_barrier_wake if necessary, and free task.
* team.c (gomp_new_team): Remove initialization of task_detach_queue.
(free_team): Remove free of task_detach_queue.
* testsuite/libgomp.c-c++-common/task-detach-1.c: Fix formatting.
* testsuite/libgomp.c-c++-common/task-detach-2.c: Fix formatting.
* testsuite/libgomp.c-c++-common/task-detach-3.c: Fix formatting.
* testsuite/libgomp.c-c++-common/task-detach-4.c: Fix formatting.
* testsuite/libgomp.c-c++-common/task-detach-5.c: Fix formatting.
Change data-sharing of detach events on enclosing parallel to private.
* testsuite/libgomp.c-c++-common/task-detach-6.c: Likewise.  Remove
taskwait directive.
* testsuite/libgomp.c-c++-common/task-detach-7.c: New.
* testsuite/libgomp.c-c++-common/task-detach-8.c: New.
* testsuite/libgomp.c-c++-common/task-detach-9.c: New.
* testsuite/libgomp.c-c++-common/task-detach-10.c: New.
* testsuite/libgomp.c-c++-common/task-detach-11.c: New.
* testsuite/libgomp.fortran/task-detach-1.f90: Fix formatting.
* testsuite/libgomp.fortran/task-detach-2.f90: Fix formatting.
* testsuite/libgomp.fortran/task-detach-3.f90: Fix formatting.
* testsuite/libgomp.fortran/task-detach-4.f90: Fix formatting.
* testsuite/libgomp.fortran/task-detach-5.f90: Fix formatting.
Change data-sharing of detach events on enclosing parallel to private.
* testsuite/libgomp.fortran/task-detach-6.f90: Likewise.  Remove
taskwait directive.
* testsuite/libgomp.fortran/task-detach-7.f90: New.
* testsuite/libgomp.fortran/task-detach-8.f90: New.
* testsuite/libgomp.fortran/task-detach-9.f90: New.
* testsuite/libgomp.fortran/task-detach-10.f90: New.
* testsuite/libgomp.fortran/task-detach-11.f90: New.

3 years agoc++: Fix pretty printing the context of local class [PR99213]
Patrick Palka [Thu, 25 Feb 2021 21:44:34 +0000 (16:44 -0500)]
c++: Fix pretty printing the context of local class [PR99213]

My r10-7705 patch for PR94521 made us set TFF_NO_FUNCTION_ARGUMENTS when
pretty printing the function scope of a local class type in order to
eliminate infinite recursion with a function signature that contains
decltype([]{}).  But due to the way dump_function_decl works, this
change regressed our pretty printing of local class types whose context
contains a class template specialization, as in the testcase below, in
which we wrongly pretty print the two local types as 'A<T>::f<char>::S1'
and 'B<T>::f<int>::S2'.

This patch makes dump_scope pass TFF_NO_TEMPLATE_BINDINGS instead of
TFF_NO_FUNCTION_ARGUMENTS when pretty printing a function scope.  It
appears this is the strictly better flag to use: it avoids the infinite
recursion issue, it restores pretty printing of the function parameter
list, and it stops dump_function_decl from trying to print a function
template specialization in its own weird way.

Summary of pretty printing differences for the below testcase:

  r10-7704:   A<T>::f() [with U = char; T = int]::S1
              B<T>::f() [with T = int]::S2

  r10-7705:   A<T>::f<char>::S1
              B<T>::f<int>::S2

  this patch: A<int>::f<char>()::S1
              B<int>::f()::S2

gcc/cp/ChangeLog:

PR c++/99213
PR c++/94521
* error.c (dump_scope): Pass TFF_NO_TEMPLATE_BINDINGS instead of
TFF_NO_FUNCTION_ARGUMENTS when dumping a function scope.

gcc/testsuite/ChangeLog:

PR c++/99213
PR c++/94521
* g++.dg/diagnostic/local1.C: New test.

3 years agoc++: Fix CTAD of single-element initializer list [PR99103]
Patrick Palka [Thu, 25 Feb 2021 21:38:08 +0000 (16:38 -0500)]
c++: Fix CTAD of single-element initializer list [PR99103]

When determining whether to rule out initializer-list constructors
during CTAD with a single-element initializer list (as per P0702), the
element type's cv-qualifiers should be irrelevant.  This patch fixes
this by making is_spec_or_derived strip cv-qualifiers from the supplied
expression type.

In passing, I noticed in maybe_aggr_guide we were calling
is_spec_or_derived with swapped arguments.  This led us to prefer the
aggregate deduction candidate over copying deduction in the second
testcase below with -std=c++20.

gcc/cp/ChangeLog:

PR c++/99103
* pt.c (is_spec_or_derived): Drop cv-qualifiers from 'etype'.
(maybe_aggr_guide): Fix order of arguments to is_spec_or_derived.

gcc/testsuite/ChangeLog:

PR c++/99103
* g++.dg/cpp1z/class-deduction79.C: New test.
* g++.dg/cpp1z/class-deduction80.C: New test.

3 years agoc++: const_cast of null pointer in constant expr [PR99176]
Marek Polacek [Wed, 24 Feb 2021 15:08:44 +0000 (10:08 -0500)]
c++: const_cast of null pointer in constant expr [PR99176]

Here we reject

  constexpr const int *p = nullptr;
  constexpr int *q = const_cast<int*>(p);

with "conversion of 'const int*' null pointer to 'int*' is not a
constant expression", which seems bogus.  This code has been rejected
since r238909 which added the can_convert check when converting a null
pointer.  I'm not finding any standard rule that this check was supposed
to enforce.  The original discussion was here
<https://gcc.gnu.org/legacy-ml/gcc-patches/2016-06/msg01447.html>
and here
<https://gcc.gnu.org/legacy-ml/gcc-patches/2016-07/msg00280.html>.

Since can_convert never assumes a C-style cast, it rejects casting
away constness as in the test above and in:

  constexpr int *q = (int *)(const int *) nullptr;

Removing the check only breaks constexpr-nullptr-2.C by not giving any
diagnostic for line 229:

  constexpr B *pb2 = static_cast<B*>(pa0);  // { dg-error "not a constant expression" }

but the cast seems to be valid: we do [expr.static.cast]/7, and
[expr.const] only says that a reinterpreter_cast and converting from
void* is invalid in constexpr.  The can_convert check rejected convering
from void *, but only when converting from a null pointer, so it's not
good enough.  So I've added a check to catch conversions from cv void*.
I realize it's not a great time to be adding additional checking, but
removing the can_convert check would then technically be a regression.

Let's limit the new check to only trigger for integer_zerop and then remove
it in GCC 12.

gcc/cp/ChangeLog:

DR 1312
PR c++/99176
* constexpr.c (is_std_construct_at): New overload.
(is_std_allocator_allocate): New overload.
(cxx_eval_call_expression): Use the new overloads.
(cxx_eval_constant_expression): Reject casting
from void * as per DR 1312.  Don't check can_convert.

gcc/testsuite/ChangeLog:

DR 1312
PR c++/99176
* g++.dg/cpp0x/constexpr-nullptr-2.C: Adjust dg-error.
* g++.dg/cpp0x/constexpr-cast2.C: New test.
* g++.dg/cpp0x/constexpr-cast3.C: New test.

3 years agocoroutines : Call promise CTOR with parm copies [PR97587].
Iain Sandoe [Mon, 15 Feb 2021 16:13:36 +0000 (16:13 +0000)]
coroutines : Call promise CTOR with parm copies [PR97587].

As the PR notes, we were calling the promise CTOR with the original
function parameters, not the copy (as pointed, a previous wording of
the section was unambiguous).  Fixed thus.

gcc/cp/ChangeLog:

PR c++/97587
* coroutines.cc (struct param_info): Track rvalue refs.
(morph_fn_to_coro): Track rvalue refs, and call the promise
CTOR with the frame copy of passed parms.

gcc/testsuite/ChangeLog:

PR c++/97587
* g++.dg/coroutines/coro1-refs-and-ctors.h: Add a CTOR with two
reference parms, to distinguish the rvalue ref. variant.
* g++.dg/coroutines/pr97587.C: New test.

3 years agocoroutines : Remove throwing_cleanup marks from the ramp [PR95822].
Iain Sandoe [Tue, 16 Feb 2021 09:07:32 +0000 (09:07 +0000)]
coroutines : Remove throwing_cleanup marks from the ramp [PR95822].

The FE contains a mechanism for cleaning up return expressions if a
function throws during the execution of cleanups prior to the return.

If the original function has a return value with a non-trivial DTOR
and the body contains a var with a DTOR that might throw, the function
decl is marked "throwing_cleanup".

However, we do not [in the coroutine ramp function, which is
synthesised], use any body var types with DTORs that might throw.

The original body [which will then contain the type with the throwing
DTOR] is transformed into the actor function which only contains void
returns, and is also wrapped in a try-catch block.

So (a) the 'throwing_cleanup' is no longer correct for the ramp and
   (b) we do not need to transfer it to the actor which only contains
       void returns.

gcc/cp/ChangeLog:

PR c++/95822
* coroutines.cc (morph_fn_to_coro): Unconditionally remove any
set throwing_cleanup marker.

gcc/testsuite/ChangeLog:

PR c++/95822
* g++.dg/coroutines/pr95822.C: New test.