]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 years agoubsan: Fix ICEs with DECL_REGISTER tests [PR101624]
Jakub Jelinek [Wed, 28 Jul 2021 16:43:15 +0000 (18:43 +0200)] 
ubsan: Fix ICEs with DECL_REGISTER tests [PR101624]

The following testcase ICEs, because the base is a CONST_DECL for
the Fortran parameter, and ubsan/sanopt uses DECL_REGISTER macro on it.
 /* In VAR_DECL and PARM_DECL nodes, nonzero means declared `register'.  */
 #define DECL_REGISTER(NODE) (DECL_WRTL_CHECK (NODE)->decl_common.decl_flag_0)
while CONST_DECL doesn't satisfy DECL_WRTL_CHECK.

The following patch checks explicitly for VAR_DECL/PARM_DECL/RESULT_DECL
only before using DECL_REGISTER, assumes other decls aren't DECL_REGISTER.
Not really sure about RESULT_DECL but it at least satisfies DECL_WRTL_CHECK...

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

PR middle-end/101624
* ubsan.c (maybe_instrument_pointer_overflow,
instrument_object_size): Only test DECL_REGISTER on VAR_DECLs,
PARM_DECLs or RESULT_DECLs.
* sanopt.c (maybe_optimize_ubsan_ptr_ifn): Likewise.

* gfortran.dg/ubsan/ubsan.exp: New file.
* gfortran.dg/ubsan/pr101624.f90: New test.

(cherry picked from commit 49e28c02a95a4bee981e69a80950309869580151)

3 years agoc++: constexpr std::construct_at on empty field [PR101663]
Patrick Palka [Thu, 12 Aug 2021 00:59:53 +0000 (20:59 -0400)] 
c++: constexpr std::construct_at on empty field [PR101663]

Here during constexpr evaluation of

  std::construct_at(&a._M_value)

we find ourselves in cxx_eval_store_expression where the target object
is 'a._M_value' and the initializer is {}.  Since _M_value is an empty
[[no_unique_address]] member we don't create a sub-CONSTRUCTOR for it,
so we end up in the early exit code path for empty stores with mismatched
types and trip over the assert therein

  gcc_assert (is_empty_class (TREE_TYPE (init)) && !lval);

because lval is true.  The reason it's true is because the INIT_EXPR in
question is the LHS of a COMPOUND_EXPR, and evaluation of the LHS is
always performed with lval=true (to indicate there's no lvalue-to-rvalue
conversion).

This patch makes the code path in question handle the lval=true case
appropriately rather than asserting.  In passing, it also consolidates
the duplicate implementations of std::construct_at/destroy_at in some
of the C++20 constexpr tests into a common header file.

PR c++/101663

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_store_expression): Handle the lval=true
case in the early exit code path for empty stores with mismatched
types.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/construct_at.h: New convenience header file that
defines minimal implementations of std::construct_at/destroy_at,
split out from ...
* g++.dg/cpp2a/constexpr-new5.C: ... here.
* g++.dg/cpp2a/constexpr-new6.C: Use the header.
* g++.dg/cpp2a/constexpr-new14.C: Likewise.
* g++.dg/cpp2a/constexpr-new20.C: New test.

(cherry picked from commit 21fd62e5ca9967bba8f97fd6244a8c6a564c2146)

3 years agoMake -no-pie option work for native Windows
Eric Botcazou [Thu, 12 Aug 2021 07:30:31 +0000 (09:30 +0200)] 
Make -no-pie option work for native Windows

Binutils 2.36/2.37 generate PIE executables by default on native Windows
(because --dynamicbase is the default) so it makes sense to have a simple
way to counter that and -no-pie seems appropriate, all the more so that
it is automatically passed when building the compiler itself.

gcc/
* configure.ac (PE linker --disable-dynamicbase support): New check.
* configure: Regenerate.
* config.in: Likewise.
* config/i386/mingw32.h (LINK_SPEC_DISABLE_DYNAMICBASE): New define.
(LINK_SPEC): Use it.
* config/i386/mingw-w64.h (LINK_SPEC_DISABLE_DYNAMICBASE): Likewise.
(LINK_SPEC): Likewise.

3 years agoDaily bump.
GCC Administrator [Thu, 12 Aug 2021 00:18:06 +0000 (00:18 +0000)] 
Daily bump.

3 years agolibstdc++: Fix test that fails randomly [PR101866]
Jonathan Wakely [Wed, 11 Aug 2021 21:11:19 +0000 (22:11 +0100)] 
libstdc++: Fix test that fails randomly [PR101866]

This test assumes that the same sequence of three values cannot occur,
which is incorect. It's unlikely, but not impossible.

Perform the check in a loop, so that in the unlikely event of an
identical sequence, we retry. If the library code is buggy it will keep
producing the same sequence and the test will time out. If the code is
working correctly then we will usually break out of the loop after one
iteration, or very rarely after two or three.

libstdc++-v3/ChangeLog:

PR libstdc++/101866
* testsuite/experimental/random/randint.cc: Loop and retry if
reseed() produces the same sequence.

(cherry picked from commit 93f1dbc7cdcc4b31ea4061efb4c2acf2d4f81eb8)

4 years agoc++: parameterized requires-expr as default argument [PR101725]
Patrick Palka [Wed, 11 Aug 2021 20:53:53 +0000 (16:53 -0400)] 
c++: parameterized requires-expr as default argument [PR101725]

Here we're rejecting the default template argument

  requires (T t) { x(t); }

because we consider the 't' in the requirement to be a local variable
(according to local_variable_p), and we generally forbid local variables
from appearing inside default arguments.  We can perhaps fix this by
giving special treatment to parameters introduced by requires-expressions,
but DR 2082 relaxed the restriction about local variables appearing within
default arguments to permit them inside unevaluated operands thereof.
So this patch just implements DR 2082 which also fixes this PR since a
requires-expression is an unevaluated context.

PR c++/101725
DR 2082

gcc/cp/ChangeLog:

* cp-tree.h (unevaluated_p): Return true for REQUIRES_EXPR.
* decl.c (local_variable_p_walkfn): Don't walk into unevaluated
operands.
* parser.c (cp_parser_primary_expression) <case CPP_NAME>: Never
reject uses of local variables in unevaluated contexts.
* tree.c (cp_walk_subtrees) <case REQUIRES_EXPR>: Increment
cp_unevaluated_operand.  Use cp_walk_tree directly instead of
WALK_SUBTREE to avoid the goto.  Use REQUIRES_EXPR_REQS instead
of TREE_OPERAND directly.

gcc/testsuite/ChangeLog:

* g++.dg/DRs/dr2082.C: New test.
* g++.dg/cpp2a/concepts-uneval4.C: New test.

(cherry picked from commit 9707d2e5dbb92d2bc990c922461a5a16ae652319)

4 years agoFortran: ICE in resolve_allocate_deallocate for invalid STAT argument
Harald Anlauf [Wed, 28 Jul 2021 17:11:27 +0000 (19:11 +0200)] 
Fortran: ICE in resolve_allocate_deallocate for invalid STAT argument

gcc/fortran/ChangeLog:

PR fortran/101564
* expr.c (gfc_check_vardef_context): Add check for KIND and LEN
parameter inquiries.
* match.c (gfc_match): Fix comment for %v code.
(gfc_match_allocate, gfc_match_deallocate): Replace use of %v code
by %e in gfc_match to allow for function references as STAT and
ERRMSG arguments.
* resolve.c (resolve_allocate_deallocate): Avoid NULL pointer
dereferences and shortcut for bad STAT and ERRMSG argument to
(DE)ALLOCATE.  Remove bogus parts of checks for STAT and ERRMSG.

gcc/testsuite/ChangeLog:

PR fortran/101564
* gfortran.dg/allocate_stat_3.f90: New test.
* gfortran.dg/allocate_stat.f90: Adjust error messages.
* gfortran.dg/implicit_11.f90: Likewise.
* gfortran.dg/inquiry_type_ref_3.f90: Likewise.

(cherry picked from commit 7bf582e6cfcef922a087b1b2b42aa04ea9cb2d94)

4 years agoc++: Improve memory usage of subsumption [PR100828]
Patrick Palka [Mon, 2 Aug 2021 13:59:56 +0000 (09:59 -0400)] 
c++: Improve memory usage of subsumption [PR100828]

Constraint subsumption is implemented in two steps.  The first step
computes the disjunctive (or conjunctive) normal form of one of the
constraints, and the second step verifies that each clause in the
decomposed form implies the other constraint.   Performing these two
steps separately is problematic because in the first step the DNF/CNF
can be exponentially larger than the original constraint, and by
computing it ahead of time we'd have to keep all of it in memory.

This patch fixes this exponential blowup in memory usage by interleaving
the two steps, so that as soon as we decompose one clause we check
implication for it.  In turn, memory usage during subsumption is now
worst case linear in the size of the constraints rather than
exponential, and so we can safely remove the hard limit of 16 clauses
without introducing runaway memory usage on some inputs.  (Note the
_time_ complexity of subsumption is still exponential in the worst case.)

In order for this to work we need to make formula::branch() insert the
copy of the current clause directly after the current clause rather than
at the end of the list, so that we fully decompose a clause shortly
after creating it.  Otherwise we'd end up accumulating exponentially
many (partially decomposed) clauses in memory anyway.

PR c++/100828

gcc/cp/ChangeLog:

* logic.cc (formula::formula): Use emplace_back instead of
push_back.
(formula::branch): Insert a copy of m_current directly after
m_current instead of at the end of the list.
(formula::erase): Define.
(decompose_formula): Remove.
(decompose_antecedents): Remove.
(decompose_consequents): Remove.
(derive_proofs): Remove.
(max_problem_size): Remove.
(diagnose_constraint_size): Remove.
(subsumes_constraints_nonnull): Rewrite directly in terms of
decompose_clause and derive_proof, interleaving decomposition
with implication checking.  Remove limit on constraint complexity.
Use formula::erase to free the current clause before moving on to
the next one.

(cherry picked from commit f48c3cd2e3f9cd9e3c329eb2d3185bd26e7c7607)

4 years agolibstdc++: Fix create_directories to resolve symlinks [PR101510]
Jonathan Wakely [Tue, 20 Jul 2021 17:15:48 +0000 (18:15 +0100)] 
libstdc++: Fix create_directories to resolve symlinks [PR101510]

When filesystem__create_directories checks to see if the path already
exists and resolves to a directory, it uses filesystem::symlink_status,
which means it reports an error if the path is a symlink. It should use
filesystem::status, so that the target directory is detected, and no
error is reported.

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

PR libstdc++/101510
* src/c++17/fs_ops.cc (fs::create_directories): Use status
instead of symlink_status.
* src/filesystem/ops.cc (fs::create_directories): Likewise.
* testsuite/27_io/filesystem/operations/create_directories.cc:
Check symlink to existing directory.
* testsuite/27_io/filesystem/operations/create_directory.cc: Do
not test with symlinks on Windows.
* testsuite/experimental/filesystem/operations/create_directories.cc:
Check symlink to existing directory.
* testsuite/experimental/filesystem/operations/create_directory.cc:
Do not test with symlinks on Windows.

(cherry picked from commit 124eaa50e0a34f5f89572c1aa812c50979da58fc)

4 years agolibstdc++: Add more tests for filesystem::create_directory [PR101510]
Jonathan Wakely [Tue, 20 Jul 2021 11:35:37 +0000 (12:35 +0100)] 
libstdc++: Add more tests for filesystem::create_directory [PR101510]

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

PR libstdc++/101510
* src/c++17/fs_ops.cc (create_dir): Adjust whitespace.
* testsuite/27_io/filesystem/operations/create_directory.cc:
Test creating directory with name of existing symlink to
directory.
* testsuite/experimental/filesystem/operations/create_directory.cc:
Likewise.

(cherry picked from commit 0c4ae4ff46b1d7633f1e06f57d348b5817b8f640)

4 years agolibstdc++: Implement LWG 3465 for std::compare_partial_order_fallback [PR101056]
Jonathan Wakely [Mon, 14 Jun 2021 11:30:52 +0000 (12:30 +0100)] 
libstdc++: Implement LWG 3465 for std::compare_partial_order_fallback [PR101056]

libstdc++-v3/ChangeLog:

PR libstdc++/101056
* libsupc++/compare (compare_partial_order_fallback): Add
constraint using reversed parameter order, as per LWG 3465.
* testsuite/18_support/comparisons/algorithms/fallback.cc:
Adjust expected result.

(cherry picked from commit b76a529c095f076c4780df0c913cf6d2391bcbc9)

4 years agolibstdc++: Change [cmp.alg] assertions to constraints
Jonathan Wakely [Mon, 14 Jun 2021 11:25:43 +0000 (12:25 +0100)] 
libstdc++: Change [cmp.alg] assertions to constraints

This moves the same_as<decay_t<_Tp>, decay_t<_Up>> checks from the
[cmp.alg] function bodies into their constraints.

Also add a test for the compare_xxx_order_fallback algorithms.

libstdc++-v3/ChangeLog:

* libsupc++/compare (__decayed_same_as): New helper concept.
(strong_order, weak_order, partial_order): Constrain with new
concept instead of using static_assert.
(compare_strong_order_fallback, compare_weak_order_fallback)
(compare_partial_order_fallback): Likewise. Do not deduce return
types. Remove redundant if-constexpr checks.
* testsuite/18_support/comparisons/algorithms/fallback.cc: New test.

(cherry picked from commit e2c79b968ff95421c31a5a9a1b80b11321fe70d2)

4 years agolibstdc++: Improvements to Doxygen markup
Jonathan Wakely [Wed, 30 Jun 2021 23:30:54 +0000 (00:30 +0100)] 
libstdc++: Improvements to Doxygen markup

This attempts to improve the doxygen output to work around what seems to
be some bugs in doxygen (issues 8635 and 8638).

The @addtogroup command doesn't work for entities inside a nested
namespace (see 8635) so we need to close and reopen groups on entering
and elaving nested namespaces. This fixes the problem that
chrono::duration and chrono::time_point were not documented in the
"Time" documentation group. I am unable to make the path classes appear
as part of their relevant groups (File System and Filesystem TS), nor
the contents of <exception> or <system_error>. I have made some minor
improvements to the docs for those types, including starting to address
PR 97001 by adding @since to the doxygen comments.

This change also excludes the <experimental/bits/net.h> header from
Doxygen processing, so we don't get an unwanted "Networking-ts" group
in the documentation.

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

* doc/doxygen/doxygroups.cc: Fix docs for std::literals.
* doc/doxygen/user.cfg.in: Exclude the Networking TS header.
Add some more predefined macros.
* include/bits/fs_fwd.h: Move @addtogroup commands inside
namespaces. Add better documentation.
* include/bits/fs_path.h: Likewise.
* include/experimental/bits/fs_fwd.h: Likewise.
* include/experimental/bits/fs_path.h: Likewise.
* include/ext/throw_allocator.h: Fix typo and improve docs.
* include/std/chrono: Move @addtogroup commands.
* include/std/system_error: Move @addtogroup commands.
* libsupc++/exception: Improve documentation.
* libsupc++/exception.h: Add @since documentation.

(cherry picked from commit f2ce64b53fa76a4c192fe51b2f6c5a863a3b1241)

4 years agolibstdc++: Improve Doxygen documentation groups [PR 101258]
Jonathan Wakely [Wed, 30 Jun 2021 15:00:58 +0000 (16:00 +0100)] 
libstdc++: Improve Doxygen documentation groups [PR 101258]

This defines some new Doxygen groups for C++17 variable templates and
for the contents of <experimental/type_traits>. By documenting the group
as a whole and adding each template to a group we don't need to document
them individually.

Also mark more internals with "@cond undocumented" so that Doxygen
ignores them by default. Also make Doxygen process <experimental/simd>.

For some reason, many of the class templates in <type_traits> do not
appear in the "Metaprogramming" group. For example, add_cv,
remove_extent, and all the is_xxx_constructible and is_xxx_assignable
traits. For some reason, Doxygen doesn't include them in the group,
despite doing it correctly for other traits in the same header.

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

PR libstdc++/101258
* doc/doxygen/user.cfg.in (INPUT): Add <experimental/simd>.
(COLS_IN_ALPHA_INDEX): Remove obsolete tag.
(PREDEFINED): Add/fix some more macros that need to be expanded.
* include/bits/random.h: Stop Doxygen from documenting internal
implementation details.
* include/bits/random.tcc: Likewise.
* include/bits/this_thread_sleep.h: Fix @file name.
* include/experimental/bits/simd.h: Add to Doxygen group. Do not
document internal implementation details.
* include/experimental/bits/simd_detail.h: Do not document
internal implementation details.
* include/experimental/simd: Define Doxygen groups.
* include/experimental/type_traits: Improve documentation for
the header file. Define groups. Use @since commands.
* include/std/scoped_allocator (scoped_allocator_adaptor): Move
declaration before undocumented region.
* include/std/type_traits (true_type, false_type): Use using
declaration instead of typedef.
(is_invocable_v, is_nothrow_invocable_v, is_invocable_r_v)
(is_nothrow_invocable_r_v): Move definitions next to other C++17
variable templates.
Do not document internal implementation details. Move misplaced
group-end command. Define group for variable templates.
* include/std/variant: Do not document internal implementation
details.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line number.

(cherry picked from commit 6963c3b9ed1308bf5d2d8877956e56fec92853a7)

4 years agoDaily bump.
GCC Administrator [Wed, 11 Aug 2021 00:18:04 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Tue, 10 Aug 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Mon, 9 Aug 2021 00:18:16 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sun, 8 Aug 2021 00:18:08 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 7 Aug 2021 00:18:16 +0000 (00:18 +0000)] 
Daily bump.

4 years agoaarch64: Add -mtune=neoverse-512tvb
Richard Sandiford [Fri, 6 Aug 2021 14:36:58 +0000 (15:36 +0100)] 
aarch64: Add -mtune=neoverse-512tvb

This patch adds an option to tune for Neoverse cores that have
a total vector bandwidth of 512 bits (4x128 for Advanced SIMD
and a vector-length-dependent equivalent for SVE).  This is intended
to be a compromise between tuning aggressively for a single core like
Neoverse V1 (which can be too narrow) and tuning for AArch64 cores
in general (which can be too wide).

-mcpu=neoverse-512tvb is equivalent to -mcpu=neoverse-v1
-mtune=neoverse-512tvb.

gcc/
* doc/invoke.texi: Document -mtune=neoverse-512tvb and
-mcpu=neoverse-512tvb.
* config/aarch64/aarch64-cores.def (neoverse-512tvb): New entry.
* config/aarch64/aarch64-tune.md: Regenerate.
* config/aarch64/aarch64.c (neoverse512tvb_sve_vector_cost)
(neoverse512tvb_sve_issue_info, neoverse512tvb_vec_issue_info)
(neoverse512tvb_vector_cost, neoverse512tvb_tunings): New structures.
(aarch64_adjust_body_cost_sve): Handle -mtune=neoverse-512tvb.
(aarch64_adjust_body_cost): Likewise.

(cherry picked from commit 048039c49b96875144f67e7789fdea54abf7710b)

4 years agoaarch64: Restrict issue heuristics to inner vector loop
Richard Sandiford [Fri, 6 Aug 2021 14:36:57 +0000 (15:36 +0100)] 
aarch64: Restrict issue heuristics to inner vector loop

The AArch64 vector costs try to take issue rates into account.
However, when vectorising an outer loop, we lumped the inner
and outer operations together, which is somewhat meaningless.
This patch restricts the heuristic to the inner loop.

gcc/
* config/aarch64/aarch64.c (aarch64_add_stmt_cost): Only
record issue information for operations that occur in the
innermost loop.

(cherry picked from commit 9690309baf8294b0512b55b133bc102dc0dac5b5)

4 years agoaarch64: Tweak MLA vector costs
Richard Sandiford [Fri, 6 Aug 2021 14:36:56 +0000 (15:36 +0100)] 
aarch64: Tweak MLA vector costs

The issue-based vector costs currently assume that a multiply-add
sequence can be implemented using a single instruction.  This is
generally true for scalars (which have a 4-operand instruction)
and SVE (which allows the output to be tied to any input).
However, for Advanced SIMD, multiplying two values and adding
an invariant will end up being a move and an MLA.

The only target to use the issue-based vector costs is Neoverse V1,
which would generally prefer SVE in this case anyway.  I therefore
don't have a self-contained testcase.  However, the distinction
becomes more important with a later patch.

gcc/
* config/aarch64/aarch64.c (aarch64_multiply_add_p): Add a vec_flags
parameter.  Detect cases in which an Advanced SIMD MLA would almost
certainly require a MOV.
(aarch64_count_ops): Update accordingly.

(cherry picked from commit 028059b46ec9aef7dd447792c579f35396751068)

4 years agoaarch64: Tweak the cost of elementwise stores
Richard Sandiford [Fri, 6 Aug 2021 14:36:55 +0000 (15:36 +0100)] 
aarch64: Tweak the cost of elementwise stores

When the vectoriser scalarises a strided store, it counts one
scalar_store for each element plus one vec_to_scalar extraction
for each element.  However, extracting element 0 is free on AArch64,
so it should have zero cost.

I don't have a testcase that requires this for existing -mtune
options, but it becomes more important with a later patch.

gcc/
* config/aarch64/aarch64.c (aarch64_is_store_elt_extraction): New
function, split out from...
(aarch64_detect_vector_stmt_subtype): ...here.
(aarch64_add_stmt_cost): Treat extracting element 0 as free.

(cherry picked from commit 537afb0857c8f60c2b60a09fad4660420cd13e8f)

4 years agoaarch64: Add gather_load_xNN_cost tuning fields
Richard Sandiford [Fri, 6 Aug 2021 14:36:55 +0000 (15:36 +0100)] 
aarch64: Add gather_load_xNN_cost tuning fields

This patch adds tuning fields for the total cost of a gather load
instruction.  Until now, we've costed them as one scalar load
per element instead.  Those scalar_load-based values are also
what the patch uses to fill in the new fields for existing
cost structures.

gcc/
* config/aarch64/aarch64-protos.h (sve_vec_cost):
Add gather_load_x32_cost and gather_load_x64_cost.
* config/aarch64/aarch64.c (generic_sve_vector_cost)
(a64fx_sve_vector_cost, neoversev1_sve_vector_cost): Update
accordingly, using the values given by the scalar_load * number
of elements calculation that we used previously.
(aarch64_detect_vector_stmt_subtype): Use the new fields.

(cherry picked from commit 78770e0e5d9fef70679e1db4eb2fb06596fbb2f8)

4 years agoaarch64: Split out aarch64_adjust_body_cost_sve
Richard Sandiford [Fri, 6 Aug 2021 14:36:54 +0000 (15:36 +0100)] 
aarch64: Split out aarch64_adjust_body_cost_sve

This patch splits the SVE-specific part of aarch64_adjust_body_cost
out into its own subroutine, so that a future patch can call it
more than once.  I wondered about using a lambda to avoid having
to pass all the arguments, but in the end this way seemed clearer.

gcc/
* config/aarch64/aarch64.c (aarch64_adjust_body_cost_sve): New
function, split out from...
(aarch64_adjust_body_cost): ...here.

(cherry picked from commit b585f0112f293ace8fadc0c7ace59230140b7472)

4 years agoaarch64: Add a simple fixed-point class for costing
Richard Sandiford [Fri, 6 Aug 2021 14:36:53 +0000 (15:36 +0100)] 
aarch64: Add a simple fixed-point class for costing

This patch adds a simple fixed-point class for holding fractional
cost values.  It can exactly represent the reciprocal of any
single-vector SVE element count (including the non-power-of-2 ones).
This means that it can also hold 1/N for all N in [1, 16], which should
be enough for the various *_per_cycle fields.

For now the assumption is that the number of possible reciprocals
is fixed at compile time and so the class should always be able
to hold an exact value.

The class uses a uint64_t to hold the fixed-point value, which means
that it can hold any scaled uint32_t cost.  Normally we don't worry
about overflow when manipulating raw uint32_t costs, but just to be
on the safe side, the class uses saturating arithmetic for all
operations.

As far as the changes to the cost routines themselves go:

- The changes to aarch64_add_stmt_cost and its subroutines are
  just laying groundwork for future patches; no functional change
  intended.

- The changes to aarch64_adjust_body_cost mean that we now
  take fractional differences into account.

gcc/
* config/aarch64/fractional-cost.h: New file.
* config/aarch64/aarch64.c: Include <algorithm> (indirectly)
and cost_fraction.h.
(vec_cost_fraction): New typedef.
(aarch64_detect_scalar_stmt_subtype): Use it for statement costs.
(aarch64_detect_vector_stmt_subtype): Likewise.
(aarch64_sve_adjust_stmt_cost, aarch64_adjust_stmt_cost): Likewise.
(aarch64_estimate_min_cycles_per_iter): Use vec_cost_fraction
for cycle counts.
(aarch64_adjust_body_cost): Likewise.
(aarch64_test_cost_fraction): New function.
(aarch64_run_selftests): Call it.

(cherry picked from commit 83d796d3e58badcb864d179b882979f714ffd162)

4 years agoaarch64: Turn sve_width tuning field into a bitmask
Richard Sandiford [Fri, 6 Aug 2021 14:36:52 +0000 (15:36 +0100)] 
aarch64: Turn sve_width tuning field into a bitmask

The tuning structures have an sve_width field that specifies the
number of bits in an SVE vector (or SVE_NOT_IMPLEMENTED if not
applicable).  This patch turns the field into a bitmask so that
it can specify multiple widths at the same time.  For now we
always treat the mininum width as the likely width.

An alternative would have been to add extra fields, which would
have coped correctly with non-power-of-2 widths.  However,
we're very far from supporting constant non-power-of-2 vectors
in GCC, so I think the non-power-of-2 case will in reality always
have to be hidden behind VLA.

gcc/
* config/aarch64/aarch64-protos.h (tune_params::sve_width): Turn
into a bitmask.
* config/aarch64/aarch64.c (aarch64_cmp_autovec_modes): Update
accordingly.
(aarch64_estimated_poly_value): Likewise.  Use the least significant
set bit for the minimum and likely values.  Use the most significant
set bit for the maximum value.

(cherry picked from commit fa3ca6151ccac0e215727641eee36abf6e437b26)

4 years agotree-optimization/101505 - properly determine stmt precision for PHIs
Richard Biener [Mon, 19 Jul 2021 11:29:16 +0000 (13:29 +0200)] 
tree-optimization/101505 - properly determine stmt precision for PHIs

Loop vectorization pattern recog fails to walk PHIs when determining
stmt precisions.  This fails to recognize non-mask uses for bools
in PHIs and outer loop vectorization.

2021-07-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101505
* tree-vect-patterns.c (vect_determine_precisions): Walk
PHIs also for loop vectorization.

* gcc.dg/vect/pr101505.c: New testcase.

(cherry picked from commit 8df3ee8f7d85d0708f3c3ca96b55c9230c2ae9f0)

4 years agoc/101512 - fix missing address-taking in c_common_mark_addressable_vec
Richard Biener [Wed, 21 Jul 2021 07:14:24 +0000 (09:14 +0200)] 
c/101512 - fix missing address-taking in c_common_mark_addressable_vec

c_common_mark_addressable_vec fails to look through C_MAYBE_CONST_EXPR
in the case it isn't at the toplevel.

2021-07-21  Richard Biener  <rguenther@suse.de>

PR c/101512
gcc/c-family/
* c-common.c (c_common_mark_addressable_vec): Look through
C_MAYBE_CONST_EXPR even if not at the toplevel.

gcc/testsuite/
* gcc.dg/torture/pr101512.c: New testcase.

(cherry picked from commit e63d76234d18cac731c4f3610d513bd8b39b5520)

4 years agoDaily bump.
GCC Administrator [Fri, 6 Aug 2021 00:18:03 +0000 (00:18 +0000)] 
Daily bump.

4 years agosanitizer: cherry pick 414482751452e54710f16bae58458c66298aaf69
Martin Liska [Thu, 5 Aug 2021 08:43:17 +0000 (10:43 +0200)] 
sanitizer: cherry pick 414482751452e54710f16bae58458c66298aaf69

The patch is needed in order to support recent glibc (2.34).

libsanitizer/ChangeLog:

PR sanitizer/101749
* sanitizer_common/sanitizer_posix_libcdep.cpp: Prevent
generation of dependency on _cxa_guard for static
initialization.

4 years agoDaily bump.
GCC Administrator [Thu, 5 Aug 2021 00:18:41 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Wed, 4 Aug 2021 00:18:24 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Tue, 3 Aug 2021 07:50:56 +0000 (07:50 +0000)] 
Daily bump.

4 years agoFix execution failure of parity_1.f90 on P10 [PR100952]
Haochen Gui [Mon, 2 Aug 2021 03:14:15 +0000 (11:14 +0800)] 
Fix execution failure of parity_1.f90 on P10 [PR100952]

gcc/
PR target/100952
* config/rs6000/rs6000.md (cstore<mode>4): Fix wrong fall through.

(cherry picked from commit 3382846558e02044598556e66e5ea1cb3115429d)

4 years agoUpdate gcc fr.po.
Joseph Myers [Sat, 31 Jul 2021 19:31:09 +0000 (19:31 +0000)] 
Update gcc fr.po.

* fr.po: Update.

4 years agomips: Fix up mips_atomic_assign_expand_fenv [PR94780]
Xi Ruoyao [Fri, 30 Jul 2021 15:44:14 +0000 (23:44 +0800)] 
mips: Fix up mips_atomic_assign_expand_fenv [PR94780]

Commit message shamelessly copied from 1777beb6b129 by jakub:

This function, because it is sometimes called even outside of function
bodies, uses create_tmp_var_raw rather than create_tmp_var.  But in order
for that to work, when first referenced, the VAR_DECLs need to appear in a
TARGET_EXPR so that during gimplification the var gets the right
DECL_CONTEXT and is added to local decls.

gcc/

PR target/94780
* config/mips/mips.c (mips_atomic_assign_expand_fenv): Use
  TARGET_EXPR instead of MODIFY_EXPR.

(cherry picked from commit 2065654435e3d97676366f82b939bc9273382dbe)

4 years agomips: add MSA vec_cmp and vec_cmpu expand pattern [PR101132]
Xi Ruoyao [Sun, 20 Jun 2021 07:21:39 +0000 (15:21 +0800)] 
mips: add MSA vec_cmp and vec_cmpu expand pattern [PR101132]

Middle-end started to emit vec_cmp and vec_cmpu since GCC 11, causing
ICE on MIPS with MSA enabled.  Add the pattern to prevent it.

gcc/

PR target/101132
* config/mips/mips-protos.h (mips_expand_vec_cmp_expr): Declare.
* config/mips/mips.c (mips_expand_vec_cmp_expr): New function.
* config/mips/mips-msa.md (vec_cmp<MSA:mode><mode_i>): New
  expander.
  (vec_cmpu<IMSA:mode><mode_i>): New expander.

gcc/testsuite/

PR target/101132
* gcc.target/mips/pr101132.c: New test.

(cherry picked from commit 45cb789e6adf5d571c574a94b77413c845fed106)

4 years agoUpdate gcc de.po.
Joseph Myers [Fri, 30 Jul 2021 14:49:24 +0000 (14:49 +0000)] 
Update gcc de.po.

* de.po: Update.

4 years agoUpdate gcc .po files.
Joseph Myers [Thu, 29 Jul 2021 21:18:59 +0000 (21:18 +0000)] 
Update gcc .po files.

* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
ja.po, nl.po, ru.po, sr.po, sv.po, zh_CN.po, zh_TW.po: Update.

4 years agors6000: Add int128 target check to pr101129.c (PR101531)
Bill Schmidt [Thu, 29 Jul 2021 15:24:27 +0000 (10:24 -0500)] 
rs6000: Add int128 target check to pr101129.c (PR101531)

Backport from mainline.

2021-07-21  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/testsuite/
PR target/101531
* gcc.target/powerpc/pr101129.c: Adjust.

4 years agod: Return the correct value for C++ constructor calls (PR101664)
Iain Buclaw [Mon, 26 Jul 2021 17:34:33 +0000 (19:34 +0200)] 
d: Return the correct value for C++ constructor calls (PR101664)

C++ constructors return void, even though the front-end semantic treats
them as implicitly returning `this'.  To handle this correctly, the
object reference is cached and used as the result of the expression.

PR d/101664

gcc/d/ChangeLog:

* expr.cc (ExprVisitor::visit (CallExp *)): Use object expression as
result for C++ constructor calls.

gcc/testsuite/ChangeLog:

* gdc.dg/extern-c++/extern-c++.exp: New.
* gdc.dg/extern-c++/pr101664.d: New test.
* gdc.dg/extern-c++/pr101664_1.cc: New test.

(cherry picked from commit 7616ed6307c90b5bbf1bf53550d33cc674ab4b6f)

4 years agod: Ensure casting from bool results in either 0 or 1 (PR96435)
Iain Buclaw [Mon, 26 Jul 2021 17:28:02 +0000 (19:28 +0200)] 
d: Ensure casting from bool results in either 0 or 1 (PR96435)

If casting from bool, the result is either 0 or 1, any other value
violates @safe code, so enforce that it is never invalid.

PR d/96435

gcc/d/ChangeLog:

* d-convert.cc (convert_for_rvalue): New function.
* d-tree.h (convert_for_rvalue): Declare.
* expr.cc (ExprVisitor::visit (CastExp *)): Use convert_for_rvalue.
(build_return_dtor): Likewise.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr96435.d: New test.

(cherry picked from commit 5c9b7408dc578cb2ae142a5c1b724c183497bdb2)

4 years agoDaily bump.
GCC Administrator [Thu, 29 Jul 2021 00:18:27 +0000 (00:18 +0000)] 
Daily bump.

4 years agoCorrect a mistake in a warnung for -Wnonnull.
Martin Uecker [Wed, 28 Jul 2021 06:41:38 +0000 (08:41 +0200)] 
Correct a mistake in a warnung for -Wnonnull.

In the warning for -Wnonnull when warning about array parameters
with bounds > 0 and which are NULL the numbers referring to the
two arguments are switched. This patch corrects the mistake.

2021-07-28  Martin Uecker  <muecker@gwdg.de>

gcc/
* calls.c (maybe_warn_rdwr_sizes): Correct argument
numbers in warning that were switched.

gcc/testsuite/
* gcc.dg/Wnonnull-4.c: Correct argument numbers in warnings.

4 years agoFortran: extend check for array arguments and reject CLASS array elements.
Harald Anlauf [Fri, 23 Jul 2021 19:00:10 +0000 (21:00 +0200)] 
Fortran: extend check for array arguments and reject CLASS array elements.

gcc/fortran/ChangeLog:

PR fortran/101536
* check.c (array_check): Adjust check for the case of CLASS
arrays.

gcc/testsuite/ChangeLog:

PR fortran/101536
* gfortran.dg/pr101536.f90: New test.

(cherry picked from commit e314cfc371d8b2405a1d81e51b90f9fb24b9061f)

4 years agoFortran: ICE, OOM while calculating sizes of derived type array components
Harald Anlauf [Wed, 21 Jul 2021 16:54:00 +0000 (18:54 +0200)] 
Fortran: ICE, OOM while calculating sizes of derived type array components

gcc/fortran/ChangeLog:

PR fortran/101514
* target-memory.c (gfc_interpret_derived): Size of array component
of derived type can only be computed here for explicit shape.
* trans-types.c (gfc_get_nodesc_array_type): Do not dereference
NULL pointers.

gcc/testsuite/ChangeLog:

PR fortran/101514
* gfortran.dg/pr101514.f90: New test.

(cherry picked from commit c2b15fe27e6a0e42b108111d51acce69628593b4)

4 years agoFortran: reject FORMAT tag of unknown type.
Harald Anlauf [Sun, 18 Jul 2021 19:35:53 +0000 (21:35 +0200)] 
Fortran: reject FORMAT tag of unknown type.

gcc/fortran/ChangeLog:

PR fortran/101084
* io.c (resolve_tag_format): Extend FORMAT check to unknown type.

gcc/testsuite/ChangeLog:

PR fortran/101084
* gfortran.dg/fmt_nonchar_3.f90: New test.

(cherry picked from commit f527b8233498b40c8a2c616b82265f2e58aba42a)

4 years agod: Wrong evaluation order of binary expressions (PR101640)
Iain Buclaw [Tue, 27 Jul 2021 11:24:34 +0000 (13:24 +0200)] 
d: Wrong evaluation order of binary expressions (PR101640)

The use of fold_build2 can in some cases swap the order of its operands
if that is the more optimal thing to do.  However this breaks semantic
guarantee of left-to-right evaluation in D.

PR d/101640

gcc/d/ChangeLog:

* expr.cc (binary_op): Use build2 instead of fold_build2.

gcc/testsuite/ChangeLog:

* gdc.dg/pr96429.d: Update test.
* gdc.dg/pr101640.d: New test.

(cherry picked from commit 54ec50bada94a8ff92edb04ee5216c27fa4bf942)

4 years agod: fix ICE at convert_expr(tree_node*, Type*, Type*) (PR101490)
Iain Buclaw [Mon, 26 Jul 2021 13:11:42 +0000 (15:11 +0200)] 
d: fix ICE at convert_expr(tree_node*, Type*, Type*) (PR101490)

Both the front-end and code generator had a modulo by zero bug when testing if
a conversion from a static array to dynamic array was valid.

PR d/101490

gcc/d/ChangeLog:

* d-codegen.cc (build_array_index): Handle void arrays same as byte.
* d-convert.cc (convert_expr): Handle converting to zero-sized arrays.
* dmd/dcast.c (castTo): Handle casting to zero-sized arrays.

gcc/testsuite/ChangeLog:

* gdc.dg/pr101490.d: New test.
* gdc.test/fail_compilation/fail22144.d: New test.

(cherry picked from commit c936c39f86c74b3bfc6831f694b3165296c99dc0)

4 years agod: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast (PR101441)
Iain Buclaw [Mon, 26 Jul 2021 13:24:12 +0000 (15:24 +0200)] 
d: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast (PR101441)

Backports fix from upstream to allow __FUNCTION__ and
__PRETTY_FUNCTION__ to be used as C string literals.

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

PR d/101441

gcc/d/ChangeLog:

* dmd/expression.c (FuncInitExp::resolveLoc): Set type as `string'.
(PrettyFuncInitExp::resolveLoc): Likewise.

gcc/testsuite/ChangeLog:

* gdc.test/compilable/b19002.d: New test.

(cherry picked from commit 1a2306ffe79df89389cc850ce85c586d0f1c8264)

4 years agod: Compile-time reflection for supported built-ins (PR101127)
Iain Buclaw [Sun, 25 Jul 2021 21:19:36 +0000 (23:19 +0200)] 
d: Compile-time reflection for supported built-ins (PR101127)

In order to allow user-code to determine whether a back-end builtin is
available without error, LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE has been
defined to delay putting back-end builtin functions until the ISA that
defines them has been declared.

However in D, there is no global namespace.  All builtins get pushed
into the `gcc.builtins' module, which is constructed during the semantic
analysis pass, which has already finished by the time target attributes
are evaluated.  So builtins are not pushed by the new langhook because
they would be ultimately ignored.  Builtins exposed to D code then can
now only be altered by the command-line.

PR d/101127

gcc/d/ChangeLog:

* d-builtins.cc (d_builtin_function_ext_scope): New function.
* d-lang.cc (LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE): Define.
* d-tree.h (d_builtin_function_ext_scope): Declare.

gcc/testsuite/ChangeLog:

* gdc.dg/pr101127a.d: New test.
* gdc.dg/pr101127b.d: New test.

(cherry picked from commit b2f6e1de242fff5713763cd3146dcf3f9dee51ca)

4 years agod: Change in DotTemplateExp type semantics leading to regression (PR101619)
Iain Buclaw [Sun, 25 Jul 2021 17:54:08 +0000 (19:54 +0200)] 
d: Change in DotTemplateExp type semantics leading to regression (PR101619)

By giving dot templates a type, meant that properry resolving silently
started passing for code that should never have passed.  The simple fix
is to provide implementations for checkType and checkValue that give an
error about dot templates having neither a value nor type.

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

PR d/101619

gcc/d/ChangeLog:

* dmd/expression.c (DotTemplateExp::checkType): New function.
(DotTemplateExp::checkValue): New function.
* dmd/expression.h (class DotTemplateExp): Declare checkType and
checkValue.

gcc/testsuite/ChangeLog:

* gdc.test/fail_compilation/fail7424b.d: Update test.
* gdc.test/fail_compilation/fail7424c.d: Update test.
* gdc.test/fail_compilation/fail7424d.d: Update test.
* gdc.test/fail_compilation/fail7424e.d: Update test.
* gdc.test/fail_compilation/fail7424f.d: Update test.
* gdc.test/fail_compilation/fail7424g.d: Update test.
* gdc.test/fail_compilation/fail7424h.d: Update test.
* gdc.test/fail_compilation/fail7424i.d: Update test.
* gdc.test/compilable/test22133.d: New test.
* gdc.test/fail_compilation/fail22133.d: New test.

(cherry picked from commit 3e2136117487fa839f7601c3e22a2856978fb9d0)

4 years agogimple-fold: Fix up __builtin_clear_padding on classes with virtual inheritence ...
Jakub Jelinek [Tue, 27 Jul 2021 07:59:37 +0000 (09:59 +0200)] 
gimple-fold: Fix up __builtin_clear_padding on classes with virtual inheritence [PR101586]

For the following testcase, B is 16-byte type, containing 8-byte
virtual pointer and 1-byte A member, and C contains two FIELD_DECLs,
one with B type and size of just 8-byte and then a field with type
A and 1-byte size.
The __builtin_clear_padding code was upset about the B typed FIELD_DECL
containing FIELD_DECLs beyond the field size and triggered
assertion failure.
This patch makes it ignore all FIELD_DECLs that are (fully) beyond the sz
passed from the caller (except for the flexible array member
diagnostics that is kept).

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

PR middle-end/101586
* gimple-fold.c (clear_padding_type): Ignore FIELD_DECLs with byte
positions above or equal to sz except for diagnostics of flexible
array members.

* g++.dg/torture/builtin-clear-padding-4.C: New test.

(cherry picked from commit a21bd3cebd6f54af70a37c18b8fbeae933fb6515)

4 years agoexpmed: Fix store_integral_bit_field [PR101562]
Jakub Jelinek [Fri, 23 Jul 2021 17:55:16 +0000 (19:55 +0200)] 
expmed: Fix store_integral_bit_field [PR101562]

Our documentation says that paradoxical subregs shouldn't appear
in strict_low_part:
'(strict_low_part (subreg:M (reg:N R) 0))'
     This expression code is used in only one context: as the
     destination operand of a 'set' expression.  In addition, the
     operand of this expression must be a non-paradoxical 'subreg'
     expression.
but on the testcase below that triggers UB at runtime
store_integral_bit_field emits exactly that.

The following patch fixes it by ensuring the requirement is satisfied.

2021-07-23  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/101562
* expmed.c (store_integral_bit_field): Only use movstrict_optab
if the operand isn't paradoxical.

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

(cherry picked from commit 8408d34570c9fe9f3d22a25a76df2a4c64f08477)

4 years agoUpdate BASE-VER to 11.2.1
Richard Biener [Wed, 28 Jul 2021 07:07:20 +0000 (09:07 +0200)] 
Update BASE-VER to 11.2.1

This updates BASE-VER to 11.2.1 after the 11.2 release.

2021-07-28  Richard Biener  <rguenther@suse.de>

* BASE-VER: Set to 11.2.1

4 years agoUpdate ChangeLog and version files for release releases/gcc-11.2.0
Richard Biener [Wed, 28 Jul 2021 06:55:28 +0000 (06:55 +0000)] 
Update ChangeLog and version files for release

4 years agoDaily bump.
GCC Administrator [Wed, 28 Jul 2021 00:17:58 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Tue, 27 Jul 2021 00:18:03 +0000 (00:18 +0000)] 
Daily bump.

4 years agoRegenerate gcc.pot.
Joseph Myers [Mon, 26 Jul 2021 15:23:30 +0000 (15:23 +0000)] 
Regenerate gcc.pot.

* gcc.pot: Regenerate.

4 years agoDaily bump.
GCC Administrator [Mon, 26 Jul 2021 00:18:03 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sun, 25 Jul 2021 00:17:50 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 24 Jul 2021 00:18:18 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Fri, 23 Jul 2021 00:18:07 +0000 (00:18 +0000)] 
Daily bump.

4 years ago[POWER10] __morestack calls from pcrel code
Alan Modra [Tue, 29 Jun 2021 04:01:45 +0000 (13:31 +0930)] 
[POWER10] __morestack calls from pcrel code

Compiling gcc/testsuite/gcc.dg/split-*.c and others with -mcpu=power10
and linking with a non-pcrel libgcc results in crashes due to the
power10 pcrel code not having r2 set for the generic-morestack.c
functions called from __morestack.  There is also a problem when
non-pcrel code calls a pcrel libgcc.  See the patch comments.

A similar situation theoretically occurs with ELFv1 multi-toc
executables, when __morestack might be located in a different toc
group to its caller.  This patch makes no attempt to fix that, since
the gold linker does not support multi-toc (gold is needed for proper
support of -fsplit-stack code) nor does gcc emit __morestack calls
that support multi-toc.

* config/rs6000/morestack.S (R2_SAVE): Define.
(__morestack): Save and restore r2.  Set up r2 for called
functions.

(cherry picked from commit cd6ca96f5d530e4ee07b65ac8b075119ba5bb035)

4 years agoDaily bump.
GCC Administrator [Thu, 22 Jul 2021 00:18:23 +0000 (00:18 +0000)] 
Daily bump.

4 years agoopenmp: Fix up omp_check_private [PR101535]
Jakub Jelinek [Wed, 21 Jul 2021 07:45:02 +0000 (09:45 +0200)] 
openmp: Fix up omp_check_private [PR101535]

The target data construct shouldn't affect omp_check_private, unless
the decl there is privatized (use_device_* clauses).  The routine
had some code for that, but it just did continue; in a loop that looped
only if the region type is one of selected 4 kinds, so effectively resulted
in return false; instead of looping again.  And not diagnosing lastprivate
(or reduction etc.) on a variable that is private to containing parallel
results in ICEs later on, as there is no original list item to which store
the last result.
The target construct is unclear as it has an implicit parallel region
and it is not obvious if the data privatization clauses on the construct
shall be treated as data privatization on the implicit parallel or just
on the target.  For now treat those as privatization on the implicit
parallel, but treat map clauses as shared on the implicit parallel.

2021-07-21  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/101535
* gimplify.c (omp_check_private): Properly skip ORT_TARGET_DATA
contexts in which decl isn't privatized and for ORT_TARGET return
false if decl is mapped.

* c-c++-common/gomp/pr101535-1.c: New test.
* c-c++-common/gomp/pr101535-2.c: New test.

(cherry picked from commit b136b7a78774107943fe94051c42b5a968a3ad3f)

4 years agoc++: Ensure OpenMP reduction with reference type references complete type [PR101516]
Jakub Jelinek [Wed, 21 Jul 2021 07:38:59 +0000 (09:38 +0200)] 
c++: Ensure OpenMP reduction with reference type references complete type [PR101516]

The following testcase ICEs because we haven't verified if reduction decl
has reference type that TREE_TYPE of the reference is a complete type,
require_complete_type on the decl doesn't ensure that.

2021-07-21  Jakub Jelinek  <jakub@redhat.com>

PR c++/101516
* semantics.c (finish_omp_reduction_clause): Also call
complete_type_or_else and return true if it fails.

* g++.dg/gomp/pr101516.C: New test.

(cherry picked from commit aea199f96cf116ba4c81426207acde371556610c)

4 years agoDaily bump.
GCC Administrator [Wed, 21 Jul 2021 00:18:30 +0000 (00:18 +0000)] 
Daily bump.

4 years agors6000: Fix up easy_vector_constant_msb handling [PR101384]
Jakub Jelinek [Tue, 20 Jul 2021 14:41:29 +0000 (16:41 +0200)] 
rs6000: Fix up easy_vector_constant_msb handling [PR101384]

The following gcc.dg/pr101384.c testcase is miscompiled on
powerpc64le-linux.
easy_altivec_constant has code to try construct vector constants with
different element sizes, perhaps different from CONST_VECTOR's mode.  But as
written, that works fine for vspltis[bhw] cases, but not for the vspltisw
x,-1; vsl[bhw] x,x,x case, because that creates always a V16QImode, V8HImode
or V4SImode constant containing broadcasted constant with just the MSB set.
The vspltis_constant function etc. expects the vspltis[bhw] instructions
where the small [-16..15] or even [-32..30] constant is sign-extended to the
remaining step bytes, but that is not the case for the 0x80...00 constants,
with step 1 we can't handle e.g.
{ 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff }
vectors but do want to handle e.g.
{ 0, 0, 0, 0x80, 0, 0, 0, 0x80, 0, 0, 0, 0x80, 0, 0, 0, 0x80 }
and similarly with copies 1 we do want to handle e.g.
{ 0x80808080, 0x80808080, 0x80808080, 0x80808080 }.

This is a simpler version of the fix for backports, which limits the EASY_VECTOR_MSB case
matching to step == 1 && copies == 1, because that is the only case the
splitter handles correctly.

2021-07-20  Jakub Jelinek  <jakub@redhat.com>

PR target/101384
* config/rs6000/rs6000.c (vspltis_constant): Accept EASY_VECTOR_MSB
only if step and copies are equal to 1.

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

4 years agoX86: Provide a CTOR for stringop_algs [PR100246].
Iain Sandoe [Sat, 3 Jul 2021 18:47:48 +0000 (19:47 +0100)] 
X86: Provide a CTOR for stringop_algs [PR100246].

Several older compilers fail to build modern GCC because of missing
or incomplete C++11 support.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR bootstrap/100246 - [11/12 Regression] GCC will not bootstrap with clang 3.4/3.5 [xcode 5/6, Darwin 12/13]

PR bootstrap/100246

gcc/ChangeLog:

* config/i386/i386.h (struct stringop_algs): Define a CTOR for
this type.

(cherry picked from commit f99f6eb58e1f894dae024f63cc2fe30fa7605e59)

4 years agocoroutines: Adjust outlined function names [PR95520].
Iain Sandoe [Thu, 8 Jul 2021 08:42:49 +0000 (09:42 +0100)] 
coroutines: Adjust outlined function names [PR95520].

The mechanism used to date for uniquing the coroutine helper
functions (actor, destroy) was over-complicating things and
leading to the noted PR and also difficulties in setting
breakpoints on these functions (so this will help PR99215 as
well).

This implementation delegates the adjustment to the mangling
to write_encoding() which necessitates some book-keeping so
that it is possible to determine which of the coroutine
helper names is to be mangled.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/95520 - [coroutines] __builtin_FUNCTION() returns mangled .actor instead of original function name

PR c++/95520

gcc/cp/ChangeLog:

* coroutines.cc (struct coroutine_info): Add fields for
actor and destroy function decls.
(to_ramp): New.
(coro_get_ramp_function): New.
(coro_get_actor_function): New.
(coro_get_destroy_function): New.
(act_des_fn): Set up mapping between ramp, actor and
destroy functions.
(morph_fn_to_coro): Adjust interface to the builder for
helper function decls.
* cp-tree.h (DECL_ACTOR_FN, DECL_DESTROY_FN, DECL_RAMP_FN,
JOIN_STR): New.
* mangle.c (write_encoding): Handle coroutine helpers.
(write_unqualified_name): Handle lambda coroutine helpers.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr95520.C: New test.

(cherry picked from commit 237ab3ee49e2f3110accfcc03b6c0df8b4889f15)

4 years agocoroutines: Factor code. Match original source location in helpers [NFC].
Iain Sandoe [Wed, 7 Jul 2021 18:56:20 +0000 (19:56 +0100)] 
coroutines: Factor code. Match original source location in helpers [NFC].

This is primarily a source code refactoring, the only change is to
ensure that the outlined functions are marked to begin at the same
line as the original.  Otherwise, they get the default (which seems
to be input_location, which corresponds to the closing brace at the
point that this is done).  Having the source location point to that
confuses some debuggers.

This is a contributory fix to:
PR c++/99215 - coroutines: debugging with gdb

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/ChangeLog:

* coroutines.cc (build_actor_fn): Move common code to
act_des_fn.
(build_destroy_fn): Likewise.
(act_des_fn): Build the void return here.  Ensure that the
source location matches the original function.

(cherry picked from commit d5b1bb0d197f9141a0f0e510f8d1b598c3df9552)

4 years agocoroutines: Fix a typo in rewriting the function.
Iain Sandoe [Wed, 23 Jun 2021 07:13:22 +0000 (08:13 +0100)] 
coroutines: Fix a typo in rewriting the function.

When amending the function re-write code, I made a typo in
the block connections.  This has not shown up in any test
fails (as far as can be seen) but is a regression in debug
info.

Fixed thus.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/ChangeLog:

* coroutines.cc
(coro_rewrite_function_body): Connect the replacement
function block to the block nest correctly.

(cherry picked from commit 0d5db79a61af150cba48612c9fbc3267262adb93)

4 years agoDarwin, X86: Adjust call clobbers to allow for lazy-binding [PR 100152].
Iain Sandoe [Mon, 3 May 2021 07:22:53 +0000 (08:22 +0100)] 
Darwin, X86: Adjust call clobbers to allow for lazy-binding [PR 100152].

We allow public functions defined in a TU to bind locally for PIC
code (the default) on 64bit Mach-O.

If such functions are not inlined, we cannot tell at compile-time if
they might be called via the lazy symbol resolver (this can depend on
options given at link-time).  Therefore, we must assume that the lazy
resolver could be used which clobbers R11 and R10.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

PR target/100152
* config/i386/i386-expand.c (ix86_expand_call): If a call is
to a non-local-binding, or local but to a public symbol, then
assume that it might be indirected via the lazy symbol binder.
Mark R10 and R10 as clobbered in that case.

(cherry picked from commit 41bd1b190358fce213f5add8396faf14a32d5c23)

4 years agoi386: Remove atomic_storedi_fpu and atomic_loaddi_fpu peepholes [PR100182]
Uros Bizjak [Tue, 20 Jul 2021 04:29:39 +0000 (06:29 +0200)] 
i386: Remove atomic_storedi_fpu and atomic_loaddi_fpu peepholes [PR100182]

These patterns result in non-atomic sequence.

2021-07-21  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/100182
* config/i386/sync.md (define_peephole2 atomic_storedi_fpu):
Remove.
(define_peephole2 atomic_loaddi_fpu): Ditto.

gcc/testsuite/
PR target/100182
* gcc.target/i386/pr71245-1.c: Remove.
* gcc.target/i386/pr71245-2.c: Ditto.

4 years agoDaily bump.
GCC Administrator [Tue, 20 Jul 2021 00:18:11 +0000 (00:18 +0000)] 
Daily bump.

4 years agocompiler: avoid aliases in receiver types
Ian Lance Taylor [Mon, 19 Jul 2021 23:47:05 +0000 (16:47 -0700)] 
compiler: avoid aliases in receiver types

If a package declares a method on an alias type, the alias would be
used in the export data.  This would then trigger a compiler
assertion on import: we should not be adding methods to aliases.

Fix the problem by ensuring that receiver types do not use alias types.
This seems preferable to consistently avoiding aliases in export data,
as aliases can cross packages.  And it's painful to try to patch this
while writing the export data, as at that point all the types are known.

Test case is https://golang.org/cl/335172.

Fixes golang/go#47131

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

4 years agors6000: Don't let swaps pass break multiply low-part (PR101129)
Bill Schmidt [Mon, 19 Jul 2021 17:49:17 +0000 (12:49 -0500)] 
rs6000: Don't let swaps pass break multiply low-part (PR101129)

Backport from mainline.

2021-07-15  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
PR target/101129
* config/rs6000/rs6000-p8swap.c (has_part_mult): New.
(rs6000_analyze_swaps): Insns containing a subreg of a mult are
not swappable.

gcc/testsuite/
PR target/101129
* gcc.target/powerpc/pr101129.c: New.

4 years agolibstdc++: Fix some problems in PSTL tests
Jonathan Wakely [Wed, 12 May 2021 10:21:51 +0000 (11:21 +0100)] 
libstdc++: Fix some problems in PSTL tests

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc:
Increase dg-timeout-factor to 4. Fix -Wunused-parameter
warnings. Replace bitwise AND with logical AND in loop
condition.
* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc:
Replace bitwise AND with logical AND in loop condition.
* testsuite/util/pstl/test_utils.h: Remove unused parameter
names.

(cherry picked from commit d1adbe5c1bd3f3ba098ff112eed9b61515e2dc20)

4 years agolibstdc++: Remove precondition checks from ranges::subrange
Jonathan Wakely [Tue, 15 Jun 2021 14:07:25 +0000 (15:07 +0100)] 
libstdc++: Remove precondition checks from ranges::subrange

The assertion in the subrange constructor causes semantic changes,
because the call to ranges::distance performs additional operations that
are not part of the constructor's specification. That will fail to
compile if the iterator is move-only, because the argument to
ranges::distance is passed by value. It will modify the subrange if the
iterator is not a forward iterator, because incrementing the copy also
affects the _M_begin member. Those problems could be prevented by using
if-constexpr to only do the assertion for copyable forward iterators,
but the call to ranges::distance can also prevent the constructor being
usable in constant expressions. If the member initializers are usable in
constant expressions, but iterator increments of equality comparisons
are not, then the checks done by __glibcxx_assert might
make constant evaluation fail.

This change removes the assertion. Additionally, a new typedef is
introduced to simplify the declarations using __make_unsigned_like_t on
the iterator's difference type.

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

* include/bits/ranges_util.h (subrange): Add __size_type typedef
and use it to simplify declarations.
(subrange(i, s, n)): Remove assertion.
* testsuite/std/ranges/subrange/constexpr.cc: New test.

(cherry picked from commit a88fc03ba7e52d9a072f25d42bb9619fedb7892e)

4 years agolibstdc++: Fix std::get<T> for std::tuple [PR101427]
Jonathan Wakely [Wed, 14 Jul 2021 19:14:14 +0000 (20:14 +0100)] 
libstdc++: Fix std::get<T> for std::tuple [PR101427]

The std::get<T> functions relied on deduction failing if more than one
base class existed for the type T.  However the implementation of Core
DR 2303 (in r11-4693) made deduction succeed (and select the
more-derived base class).

This rewrites the implementation of std::get<T> to explicitly check for
more than one occurrence of T in the tuple elements, making it
ill-formed again. Additionally, the large wall of overload resolution
errors described in PR c++/101460 is avoided by making std::get<T> use
__get_helper<I> directly instead of calling std::get<I>, and by adding a
deleted overload of __get_helper<N> for out-of-range N.

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

PR libstdc++/101427
* include/std/tuple (tuple_element): Improve static_assert text.
(__get_helper): Add deleted overload.
(get<i>(tuple<T...>&&), get<i>(const tuple<T...>&&)): Use
__get_helper directly.
(__get_helper2): Remove.
(__find_uniq_type_in_pack): New constexpr helper function.
(get<T>): Use __find_uniq_type_in_pack and __get_helper instead
of __get_helper2.
* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust
expected errors.
* testsuite/20_util/tuple/element_access/101427.cc: New test.

(cherry picked from commit 17855eed7fc76b2cee7fbbc26f84d3c8b99be13c)

4 years agoDaily bump.
GCC Administrator [Mon, 19 Jul 2021 00:18:25 +0000 (00:18 +0000)] 
Daily bump.

4 years agog++.dg/gomp/clause-3.C: Fix - missing in r12-438-g1580fc7 [PR100422]
Tobias Burnus [Wed, 5 May 2021 06:50:15 +0000 (08:50 +0200)] 
g++.dg/gomp/clause-3.C: Fix - missing in r12-438-g1580fc7 [PR100422]

gcc/testsuite/
PR testsuite/100422
* g++.dg/gomp/clause-3.C: Use 'reduction(&:..)' instead of '...(&&:..)'.

(cherry picked from commit af4e4d35f0b84d7c2f57a7b682a09116e9911142)

4 years agoopenmp - Fix up && and || reductions [PR94366]
Jakub Jelinek [Thu, 1 Jul 2021 06:55:49 +0000 (08:55 +0200)] 
openmp - Fix up && and || reductions [PR94366]

As the testcase shows, the special treatment of && and || reduction combiners
where we expand them as omp_out = (omp_out != 0) && (omp_in != 0) (or with ||)
is not needed just for &&/|| on floating point or complex types, but for all
&&/|| reductions - when expanded as omp_out = omp_out && omp_in (not in C but
GENERIC) it is actually gimplified into NOP_EXPRs to bool from both operands,
which turns non-zero values multiple of 2 into 0 rather than 1.

This patch just treats all &&/|| the same and furthermore uses bool type
instead of int for the comparisons.

2021-07-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/94366
gcc/
* omp-low.c (lower_rec_input_clauses): Rename is_fp_and_or to
is_truth_op, set it for TRUTH_*IF_EXPR regardless of new_var's type,
use boolean_type_node instead of integer_type_node as NE_EXPR type.
(lower_reduction_clauses): Likewise.
libgomp/
* testsuite/libgomp.c-c++-common/pr94366.c: New test.

(cherry picked from commit 91c771ec8a3b649765de3e0a7b04cf946c6649ef)

4 years agoOpenMP: Support complex/float in && and || reduction
Tobias Burnus [Tue, 4 May 2021 11:38:03 +0000 (13:38 +0200)] 
OpenMP: Support complex/float in && and || reduction

C/C++ permit logical AND and logical OR also with floating-point or complex
arguments by doing an unequal zero comparison; the result is an 'int' with
value one or zero.  Hence, those are also permitted as reduction variable,
even though it is not the most sensible thing to do.

gcc/c/ChangeLog:

* c-typeck.c (c_finish_omp_clauses): Accept float + complex
for || and && reductions.

gcc/cp/ChangeLog:

* semantics.c (finish_omp_reduction_clause): Accept float + complex
for || and && reductions.

gcc/ChangeLog:

* omp-low.c (lower_rec_input_clauses, lower_reduction_clauses): Handle
&& and || with floating-point and complex arguments.

gcc/testsuite/ChangeLog:

* gcc.dg/gomp/clause-1.c: Use 'reduction(&:..)' instead of '...(&&:..)'.

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/reduction-1.c: New test.
* testsuite/libgomp.c-c++-common/reduction-2.c: New test.
* testsuite/libgomp.c-c++-common/reduction-3.c: New test.

(cherry picked from commit 1580fc764423bf89e9b853aaa8c65999e37ccb8b)

4 years agoc++: Optimize away NULLPTR_TYPE comparisons [PR101443]
Jakub Jelinek [Thu, 15 Jul 2021 16:53:20 +0000 (18:53 +0200)] 
c++: Optimize away NULLPTR_TYPE comparisons [PR101443]

Comparisons of NULLPTR_TYPE operands cause all kinds of problems in the
middle-end and in fold-const.c, various optimizations assume that if they
see e.g. a non-equality comparison with one of the operands being
INTEGER_CST and it is not INTEGRAL_TYPE_P (which has TYPE_{MIN,MAX}_VALUE),
they can build_int_cst (type, 1) to find a successor.

The following patch fixes it by making sure they don't appear in the IL,
optimize them away at cp_fold time as all can be folded.

Though, I've just noticed that clang++ rejects the non-equality comparisons
instead, foo () > 0 with
invalid operands to binary expression ('decltype(nullptr)' (aka 'nullptr_t') and 'int')
and foo () > nullptr with
invalid operands to binary expression ('decltype(nullptr)' (aka 'nullptr_t') and 'nullptr_t')

Shall we reject those too, in addition or instead of parts of this patch?
If so, wouldn't this patch be still useful for backports, I bet we don't
want to start reject it on the release branches when we used to accept it.

2021-07-15  Jakub Jelinek  <jakub@redhat.com>

PR c++/101443
* cp-gimplify.c (cp_fold): For comparisons with NULLPTR_TYPE
operands, fold them right away to true or false.

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

(cherry picked from commit 7094a69bd62a14dfa311eaa2fea468f221c7c9f3)

4 years agogodump: Fix -fdump-go-spec= reproduceability issue [PR101407]
Jakub Jelinek [Wed, 14 Jul 2021 08:22:50 +0000 (10:22 +0200)] 
godump: Fix -fdump-go-spec= reproduceability issue [PR101407]

pot_dummy_types is a hash_set from whose traversal the code prints some type
lines.  hash_set normally uses default_hash_traits which for pointer types
(the hash set hashes const char *) uses pointer_hash which hashes the
addresses of the pointers except of the least significant 3 bits.
With address space randomization, that results in non-determinism in the
-fdump-go-specs= generated file, each invocation can have different order of
the lines emitted from pot_dummy_types traversal.

This patch fixes it by hashing the string contents instead to make the
hashes reproduceable.

2021-07-14  Jakub Jelinek  <jakub@redhat.com>

PR go/101407
* godump.c (godump_str_hash): New type.
(godump_container::pot_dummy_types): Use string_hash instead of
ptr_hash in the hash_set.

(cherry picked from commit 3be762c2ed79e36b9c8faaea2be04725c967a34e)

4 years agolibgomp: Don't include limits.h instead of hidden visibility block
Jakub Jelinek [Tue, 13 Jul 2021 07:50:49 +0000 (09:50 +0200)] 
libgomp: Don't include limits.h instead of hidden visibility block

sem.h is included in between # pragma GCC visibility push(hidden)
and # pragma GCC visibility pop and includes limits.h there, which
since the introduction of sysconf declaration in recent glibcs
in there causes trouble.  libgomp assumes it is compiled by gcc,
so we don't really need to include limits.h there and can use
-__INT_MAX__ - 1 instead (which clang and icc support too for years).

2021-07-13  Jakub Jelinek  <jakub@redhat.com>
    Florian Weimer  <fweimer@redhat.com>

* config/linux/sem.h: Don't include limits.h.
(SEM_WAIT): Define to -__INT_MAX__ - 1 instead of INT_MIN.
* config/linux/affinity.c: Include limits.h.

(cherry picked from commit 42f10ba5b57250506d69a0391ea7771c843ea286)

4 years agodwarf2out: Handle COMPOUND_LITERAL_EXPR in loc_list_from_tree_1 [PR101266]
Jakub Jelinek [Thu, 1 Jul 2021 07:45:02 +0000 (09:45 +0200)] 
dwarf2out: Handle COMPOUND_LITERAL_EXPR in loc_list_from_tree_1 [PR101266]

In this case dwarf2out_decl is called from the FEs with GENERIC but not
yet gimplified expressions in it.

As loc_list_from_tree_1 has an exhaustive list of tree codes it wants to
handle and for checking asserts no other codes makes it in, we should
handle even GENERIC trees that shouldn't be valid in GIMPLE.

The following patch handles COMPOUND_LITERAL_EXPR by hnadling it like the
underlying VAR_DECL temporary.

Verified the emitted DWARF is correct (but unoptimized, we emit
DW_OP_lit1 DW_OP_lit1 DW_OP_minus for the upper bound).

2021-07-01  Jakub Jelinek  <jakub@redhat.com>

PR debug/101266
* dwarf2out.c (loc_list_from_tree_1): Handle COMPOUND_LITERAL_EXPR.

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

(cherry picked from commit b0ab968999c9af88d45acf552ca673ef3960306a)

4 years agomatch.pd: Avoid (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST opt in GENERIC when...
Jakub Jelinek [Tue, 29 Jun 2021 09:24:38 +0000 (11:24 +0200)] 
match.pd: Avoid (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST opt in GENERIC when sanitizing [PR101210]

When we have (intptr_t) x == cst where x has REFERENCE_TYPE, this
optimization creates x == cst out of it where cst has REFERENCE_TYPE.
If it is done in GENERIC folding, it can results in ubsan failures
where the INTEGER_CST with REFERENCE_TYPE is instrumented.

Fixed by deferring it to GIMPLE folding in this case.

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

PR c++/101210
* match.pd ((intptr_t)x eq/ne CST to x eq/ne (typeof x) CST): Don't
perform the optimization in GENERIC when sanitizing and x has a
reference type.

* g++.dg/ubsan/pr101210.C: New test.

(cherry picked from commit 53fd7544aff6d0a18869017cb9bb921a7f5dcd04)

4 years agoc: Fix up c_parser_has_attribute_expression [PR101176]
Jakub Jelinek [Thu, 24 Jun 2021 13:58:02 +0000 (15:58 +0200)] 
c: Fix up c_parser_has_attribute_expression [PR101176]

This function keeps src_range member of the result uninitialized, which at
least under valgrind can show up later when those uninitialized location_t's
can make it into the IL or location_t hash tables.

2021-06-24  Jakub Jelinek  <jakub@redhat.com>

PR c/101176
* c-parser.c (c_parser_has_attribute_expression): Set source range for
the result.

(cherry picked from commit 178fb8df9315f2f8f45b7fe5faf11a9c2912cc28)

4 years agoc: Fix C cast error-recovery [PR101171]
Jakub Jelinek [Thu, 24 Jun 2021 13:55:28 +0000 (15:55 +0200)] 
c: Fix C cast error-recovery [PR101171]

The following testcase ICEs during error-recovery, as build_c_cast calls
note_integer_operands on error_mark_node and that wraps it into
C_MAYBE_CONST_EXPR which is unexpected and causes ICE later on.
Seems most other callers of note_integer_operands check early if something
is error_mark_node and return before calling note_integer_operands on it.

The following patch fixes it by not calling on error_mark_node, another
possibility would be to handle error_mark_node in note_integer_operands and
just return it.

2021-06-24  Jakub Jelinek  <jakub@redhat.com>

PR c/101171
* c-typeck.c (build_c_cast): Don't call note_integer_operands on
error_mark_node.

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

(cherry picked from commit fdc5522fb04b4a820b28c4d1f16f54897f5978de)

4 years agostor-layout: Avoid DECL_BIT_FIELD_REPRESENTATIVE with NULL TREE_TYPE [PR101172]
Jakub Jelinek [Thu, 24 Jun 2021 10:22:14 +0000 (12:22 +0200)] 
stor-layout: Avoid DECL_BIT_FIELD_REPRESENTATIVE with NULL TREE_TYPE [PR101172]

finish_bitfield_representative has an early out if the field after a
bitfield has error_mark_node type, but that early out leads to TREE_TYPE
of the DECL_BIT_FIELD_REPRESENTATIVE being NULL, which breaks assumptions
on code that uses the DECL_BIT_FIELD_REPRESENTATIVE during error-recovery.

The following patch instead sets TREE_TYPE of the representative to
error_mark_node, something the users can deal with better.  At this point
the representative can be set as DECL_BIT_FIELD_REPRESENTATIVE for multiple
bitfields, so making sure that we clear the DECL_BIT_FIELD_REPRESENTATIVE
instead would be harder (but doable, e.g. with the error_mark_node TREE_TYPE
set by this patch set some flag in the caller and if the flag is there, walk
all the fields once again and clear all DECL_BIT_FIELD_REPRESENTATIVE that
have error_mark_node TREE_TYPE).

2021-06-24  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/101172
* stor-layout.c (finish_bitfield_representative): If nextf has
error_mark_node type, set repr type to error_mark_node too.

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

(cherry picked from commit 65371066d8967560e3508af4a804e0ddb90acee7)

4 years agoDaily bump.
GCC Administrator [Sun, 18 Jul 2021 00:17:54 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 17 Jul 2021 00:18:12 +0000 (00:18 +0000)] 
Daily bump.

4 years agoc++: alias CTAD in unevaluated context [PR101233]
Patrick Palka [Fri, 16 Jul 2021 20:21:13 +0000 (16:21 -0400)] 
c++: alias CTAD in unevaluated context [PR101233]

This is the alias CTAD version of the CTAD bug PR93248, and the fix is
the same: clear cp_unevaluated_operand so that the entire chain of
DECL_ARGUMENTS gets substituted.

PR c++/101233

gcc/cp/ChangeLog:

* pt.c (alias_ctad_tweaks): Clear cp_unevaluated_operand for
substituting DECL_ARGUMENTS.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias10.C: New test.

(cherry picked from commit a8b3861496bffae8b813ea196c1c5b27f79fbe69)

4 years agoc++: fn parm pack expansion inside constraint [PR100138]
Patrick Palka [Tue, 11 May 2021 02:33:04 +0000 (22:33 -0400)] 
c++: fn parm pack expansion inside constraint [PR100138]

This PR is about CTAD but the underlying problems are more general;
CTAD is a good trigger for them because of the necessary substitution
into constraints that deduction guide generation entails.

In the testcase below, when generating the implicit deduction guide for
the constrained constructor template for A, we substitute the generic
flattening map 'tsubst_args' into the constructor's constraints.  During
this substitution, tsubst_pack_expansion returns a rebuilt pack
expansion for sizeof...(xs), but doesn't carry over the
PACK_EXPANSION_LOCAL_P (and PACK_EXPANSION_SIZEOF_P) flag from the
original tree to the rebuilt one.  The flag is otherwise unset on the
original tree but gets set for the rebuilt tree from make_pack_expansion
since at_function_scope_p() is true (we're inside main).  This leads to
a crash during satisfaction when substituting into the pack expansion
because we don't have local_specializations set up (and it'd be set up
for us if PACK_EXPANSION_LOCAL_P is unset)

Similarly, tsubst_constraint needs to set cp_unevaluated so that the
substitution performed therein doesn't rely on local_specializations.
This avoids a crash during CTAD for C below.

gcc/cp/ChangeLog:

PR c++/100138
* constraint.cc (tsubst_constraint): Set up cp_unevaluated.
(satisfy_atom): Set up iloc_sentinel before calling
cxx_constant_value.
* pt.c (tsubst_pack_expansion): When returning a rebuilt pack
expansion, carry over PACK_EXPANSION_LOCAL_P and
PACK_EXPANSION_SIZEOF_P from the original pack expansion.

gcc/testsuite/ChangeLog:

PR c++/100138
* g++.dg/cpp2a/concepts-ctad4.C: New test.

(cherry picked from commit e7a9f085ffd34b0d7bc4b803c182b41494f609aa)

4 years agolibstdc++: Use function object for __decay_copy helper
Jonathan Wakely [Tue, 15 Jun 2021 13:39:02 +0000 (14:39 +0100)] 
libstdc++: Use function object for __decay_copy helper

By changing __cust_access::__decay_copy from a function template to a
function object we avoid ADL. That means it's fine to call it
unqualified (the compiler won't waste time doing ADL in associated
namespaces, and won't try to complete associated types).

This also makes some other minor simplications to other concepts for the
[range.access] CPOs.

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

* include/bits/iterator_concepts.h (__cust_access::__decay_copy):
Replace with function object.
(__cust_access::__member_begin, ___cust_access::_adl_begin): Use
__decay_copy unqualified.
* include/bits/ranges_base.h (__member_end, __adl_end):
Likewise. Use __range_iter_t for type of ranges::begin.
(__member_rend): Use correct value category for rbegin argument.
(__member_data): Use __decay_copy unqualified.
(__begin_data): Use __range_iter_t for type of ranges::begin.

(cherry picked from commit cb326a6442f09cb36b05ce556fc91e10bfeb0cf6)

4 years agoDaily bump.
GCC Administrator [Fri, 16 Jul 2021 00:17:59 +0000 (00:17 +0000)] 
Daily bump.