197485 Commits

Author SHA1 Message Date
GCC Administrator
92bc361757 Daily bump. 2022-12-18 00:16:57 +00:00
Segher Boessenkool
f80f540e39 rs6000: Add Rust support to traceback table
Use 0 for the "lang" identifier for Rust, just like we do for all other
source languages without assigned language code (0 means "C").

Tested on powerpc64-linux.  Without this patch there are ICEs galore in
the gm2 testsuite for 64-bit Linux targets, and with the ptch there are
just a few FAILs.

2022-12-17  Segher Boessenkool  <segher@kernel.crashing.org>

	* config/rs6000/rs6000-logue.cc (rs6000_output_function_epilogue):
	Handle GNU Rust for the tbtab lang field.
2022-12-17 20:56:13 +00:00
Patrick Palka
982629bea4 c++: constantness of non-dependent NTTP argument [PR107437]
Here we're rejecting the use of the lambda capture of 't' (of empty
type) as a template argument ultimately because convert_nontype_argument
checks constantness using is_constant_expression, which returns false
for lambda captures since want_rval=false.  But in this case I believe
an lvalue-to-rvalue conversion of the argument is implied, so we should
be using is_rvalue_constant_expression instead (which would return true
here).

However, it doesn't seem necessary to consider constantness at all
when deciding whether to instantiate a non-dependent argument in
convert_nontype_argument.  So this patch gets rid of the problematic
constantness test altogether, which incidentally also fixes the similar
dg-ice'd testcase from PR87765.  This is in line with a similar
change we made to finish_decltype_type in r12-7564-gec0f53a3a542e7.

	PR c++/107437
	PR c++/87765

gcc/cp/ChangeLog:

	* pt.cc (convert_nontype_argument): Relax is_nondep_const_expr
	test to !inst_dep_expr_p.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/lambda-generic-107437.C: New test.
	* g++.dg/cpp1z/constexpr-lambda26.C: Remove dg-ice.
2022-12-17 11:24:44 -05:00
Ian Lance Taylor
b1f91819e3 libbacktrace: unpack literals into output buffer
* elf.c (elf_fetch_backward_init): New static function.
	(ZSTD_TABLE_SIZE): Use huffman scratch space size rather than
	literal size.
	(ZSTD_TABLE_WORK_LIT_SIZE): Don't define.
	(elf_zstd_read_huff): Use elf_fetch_backward_init.
	(elf_zstd_read_literals): New static function.
	(ZSTD_LIT_RAW, ZSTD_LIT_RLE, ZSTD_LIT_HUFF): Don't define.
	(struct elf_zstd_literals): Don't define.
	(elf_zstd_literal_output): Remove static function.
	(elf_zstd_decompress): Use elf_fetch_backward_init and
	elf_zstd_read_literals.  Rewrite literal copying.<
2022-12-16 18:48:04 -08:00
GCC Administrator
5fb1e67453 Daily bump. 2022-12-17 00:17:56 +00:00
Thomas Neumann
6e56633daa initialize fde objects lazily
When registering an unwind frame with __register_frame_info_bases
we currently initialize that fde object eagerly. This has the
advantage that it is immutable afterwards and we can safely
access it from multiple threads, but it has the disadvantage
that we pay the initialization cost even if the application
never throws an exception.

This commit changes the logic to initialize the objects lazily.
The objects themselves are inserted into the b-tree when
registering the frame, but the sorted fde_vector is
not constructed yet. Only on the first time that an
exception tries to pass through the registered code the
object is initialized. We notice that with a double checking,
first doing a relaxed load of the sorted bit and then re-checking
under a mutex when the object was not initialized yet.

Note that the check must implicitly be safe concering a concurrent
frame deregistration, as trying the deregister a frame that is
on the unwinding path of a concurrent exception is inherently racy.

libgcc/ChangeLog:
	* unwind-dw2-fde.c: Initialize fde object lazily when
	the first exception tries to pass through.
2022-12-17 00:48:25 +01:00
Thomas Neumann
1c118c9970 speed up end_fde_sort using radix sort
When registering a dynamic unwinding frame the fde list is sorted.
Previously, we split the list into a sorted and an unsorted part,
sorted the later using heap sort, and merged both. That can be
quite slow due to the large number of (expensive) comparisons.

This patch replaces that logic with a radix sort instead. The
radix sort uses the same amount of memory as the old logic,
using the second list as auxiliary space, and it includes two
techniques to speed up sorting: First, it computes the pointer
addresses for blocks of values, reducing the decoding overhead.
And it recognizes when the data has reached a sorted state,
allowing for early termination. When running out of memory
we fall back to pure heap sort, as before.

For this test program

\#include <cstdio>
int main(int argc, char** argv) {
     return 0;
}

compiled with g++ -O -o hello -static hello.c we get with
perf stat -r 200 on a 5950X the following performance numbers:

old logic:

              0,20 msec task-clock
           930.834      cycles
         3.079.765      instructions
        0,00030478 +- 0,00000237 seconds time elapsed

new logic:

              0,10 msec task-clock
           473.269      cycles
         1.239.077      instructions
        0,00021119 +- 0,00000168 seconds time elapsed

libgcc/ChangeLog:
	* unwind-dw2-fde.c: Use radix sort instead of split+sort+merge.
2022-12-17 00:48:16 +01:00
John David Anglin
e51c5d5aa2 Update baseline symbols for hppa-linux.
2022-12-16  John David Anglin  <danglin@gcc.gnu.org>

libstdc++-v3/ChangeLog:

	* config/abi/post/hppa-linux-gnu/baseline_symbols.txt: Update.
2022-12-16 22:23:16 +00:00
John David Anglin
1dea4fc642 Suppress -fstack-protector warning on hppa.
Some package builds enable -fstack-protector and -Werror. Since
-fstack-protector is not supported on hppa because the stack grows
up, these packages must check for the warning generated by
-fstack-protector and suppress it on hppa. This is problematic
since hppa is the only significant architecture where the stack
grows up.

2022-12-16  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	* config/pa/pa.cc (pa_option_override): Disable -fstack-protector.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp (check_effective_target_static): Return 0
	on hppa*-*-*.
2022-12-16 21:44:40 +00:00
Jonathan Wakely
8d9e2776a6 libstdc++: Add monadic operations to std::expected for C++23 (P2505R5)
This was approved for C++23 last month in Kona.

libstdc++-v3/ChangeLog:

	* include/std/expected (expected): Add monadic operations.
	(expected<void, E>): Likewise.
	* include/std/version (__cpp_lib_expected): Bump value.
	* testsuite/20_util/expected/synopsis.cc: Adjust expected macro
	value.
	* testsuite/20_util/expected/version.cc: Likewise.
	* testsuite/20_util/expected/illformed_neg.cc: Prune additional
	errors from ill-formed monadic operations.
	* testsuite/20_util/expected/observers.cc: Check error_or.
	* testsuite/20_util/expected/monadic.cc: New test.
2022-12-16 20:59:19 +00:00
Jonathan Wakely
59822c3920 libstdc++: Fixes for std::expected
This fixes some bugs in the swap functions for std::expected.

It also disables the noexcept-specifiers for equality operators, because
those are problematic when querying whether a std::expected is equality
comparable. The operator==(const expected<T,E>&, const U&) function is
not constrained, so is viable for comparing expected<T,E> with
expected<void,G>, but then we get an error from the noexcept-specifier.

libstdc++-v3/ChangeLog:

	* include/std/expected (expected::_M_swap_val_unex): Guard the
	correct object.
	(expected::swap): Move is_swappable
	requirement from static_assert to constraint.
	(swap): Likewise.
	(operator==): Remove noexcept-specifier.
	* testsuite/20_util/expected/swap.cc: Check swapping of
	types without non-throwing move constructor. Check constraints
	on swap.
	* testsuite/20_util/expected/unexpected.cc: Check constraints on
	swap.
	* testsuite/20_util/expected/equality.cc: New test.
2022-12-16 20:58:09 +00:00
Jonathan Wakely
64c986b495 libstdc++: Diagnose broken allocator rebind members
This adds a static assertion to std::allocator_traits::rebind_alloc to
diagnose violations of the rule that rebinding an allocator to its own
value type yields the same allocator type.

This helps to catch the easy mistake of deriving from std::allocator but
forgetting to override the rebind behaviour (no longer an issue in C++20
as std::allocator doesn't have a rebind member that can be inherited).
It also catches bugs like in 23_containers/vector/52591.cc where a typo
means the rebound allocator is a completely different type.

I initially wanted to put this static assert into the body of
allocator_traits:

      static_assert(is_same<rebind_alloc<value_type>, _Alloc>::value,
		    "rebind_alloc<value_type> must be Alloc");

However, this causes a regression in the test for PR libstdc++/72792.
It seems that instantiating std::allocator_traits should be allowed for
invalid allocator types as long as you don't try to rebind them. To
support that, only assert in the __allocator_traits_base::__rebind class
template (in both the primary template and the partial specialization).
As a result, the bug in 20_util/scoped_allocator/outermost.cc is not
diagnosed, because nothing in that test rebinds the allocator.

libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h (__allocator_traits_base::__rebind):
	Add static assert for rebind requirement.
	* testsuite/20_util/allocator_traits/members/rebind_alloc.cc:
	Fix invalid rebind member in test allocator.
	* testsuite/20_util/allocator_traits/requirements/rebind_neg.cc:
	New test.
	* testsuite/20_util/scoped_allocator/outermost.cc: Add rebind to
	test allocator.
	* testsuite/23_containers/forward_list/48101_neg.cc: Prune new
	static assert error.
	* testsuite/23_containers/unordered_multiset/48101_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/48101_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/52591.cc: Fix typo in rebind.
2022-12-16 20:58:09 +00:00
Andrew Pinski
0b1d66658e coroutines: Build pointer initializers with nullptr_node [PR107768]
The PR reports that using integer_zero_node triggers a warning for
-Wzero-as-null-pointer-constant which comes from compiler-generated code so
makes no sense to the end user.

Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>

	PR c++/107768

gcc/cp/ChangeLog:

	* coroutines.cc (coro_rewrite_function_body): Initialize pointers
	from nullptr_node.  (morph_fn_to_coro): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr107768.C: New test.
2022-12-16 20:15:59 +00:00
David Malcolm
2fdc8546b5 analyzer: add src_region param to region_model::check_for_poison [PR106479]
PR analyzer/106479 notes that we don't always show the region-creation
event for a memmove from an uninitialized stack region.  This occurs
when using kf_memcpy_memmove.  Fix by passing a src_region hint to
region_model::check_for_poison.

gcc/analyzer/ChangeLog:
	PR analyzer/106479
	* kf.cc (kf_memcpy_memmove::impl_call_pre): Pass in source region
	to region_model::check_for_poison.
	* region-model-asm.cc (region_model::on_asm_stmt): Pass NULL
	region to region_model::check_for_poison.
	* region-model.cc (region_model::check_for_poison): Add
	"src_region" param, and pass it to poisoned_value_diagnostic.
	(region_model::on_assignment): Pass NULL region to
	region_model::check_for_poison.
	(region_model::get_rvalue): Likewise.
	* region-model.h (region_model::check_for_poison): Add
	"src_region" param.
	* sm-fd.cc (fd_state_machine::on_accept): Pass in source region
	to region_model::check_for_poison.
	* varargs.cc (kf_va_copy::impl_call_pre): Pass NULL region to
	region_model::check_for_poison.
	(kf_va_arg::impl_call_pre): Pass in source region to
	region_model::check_for_poison.

gcc/testsuite/ChangeLog:
	PR analyzer/106479
	* gcc.dg/analyzer/pr104308.c (test_memmove_within_uninit): Remove
	xfail on region creation event.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-12-16 14:50:07 -05:00
Vladimir N. Makarov
b50fe16a3b Revert "IRA: Check that reg classes contain a hard reg of given mode in reg move cost calculation"
The patch resulted in new PRs:

	PR target/108145
	PR testsuite/108141

So I am reverting the patch.

This reverts commit 12abd5a7d13209f79664ea603b3f3517f71b8c4f.
2022-12-16 13:22:38 -05:00
Qing Zhao
2a27ae32fa Add a new warning option -Wstrict-flex-arrays.
'-Wstrict-flex-arrays'
     Warn about inproper usages of flexible array members according to
     the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to
     the trailing array field of a structure if it's available,
     otherwise according to the LEVEL of the option
     '-fstrict-flex-arrays=LEVEL'.

     This option is effective only when LEVEL is bigger than 0.
     Otherwise, it will be ignored with a warning.

     when LEVEL=1, warnings will be issued for a trailing array
     reference of a structure that have 2 or more elements if the
     trailing array is referenced as a flexible array member.

     when LEVEL=2, in addition to LEVEL=1, additional warnings will be
     issued for a trailing one-element array reference of a structure if
     the array is referenced as a flexible array member.

     when LEVEL=3, in addition to LEVEL=2, additional warnings will be
     issued for a trailing zero-length array reference of a structure if
     the array is referenced as a flexible array member.

gcc/ChangeLog:

	* doc/invoke.texi: Document -Wstrict-flex-arrays option.
	* gimple-array-bounds.cc (check_out_of_bounds_and_warn): Add two more
	arguments.
	(array_bounds_checker::check_array_ref): Issue warnings for
	-Wstrict-flex-arrays.
	* opts.cc (finish_options): Issue warning for unsupported combination
	of -Wstrict_flex_arrays and -fstrict-flex-array.
	* tree-vrp.cc (execute_ranger_vrp): Enable the pass when
	warn_strict_flex_array is true.

gcc/c-family/ChangeLog:

	* c.opt (Wstrict-flex-arrays): New option.

gcc/testsuite/ChangeLog:

	* gcc.dg/Warray-bounds-flex-arrays-1.c: Update testing case with
	-Wstrict-flex-arrays.
	* gcc.dg/Warray-bounds-flex-arrays-2.c: Likewise.
	* gcc.dg/Warray-bounds-flex-arrays-3.c: Likewise.
	* gcc.dg/Warray-bounds-flex-arrays-4.c: Likewise.
	* gcc.dg/Warray-bounds-flex-arrays-5.c: Likewise.
	* gcc.dg/Warray-bounds-flex-arrays-6.c: Likewise.
	* c-c++-common/Wstrict-flex-arrays.c: New test.
	* gcc.dg/Wstrict-flex-arrays-2.c: New test.
	* gcc.dg/Wstrict-flex-arrays-3.c: New test.
	* gcc.dg/Wstrict-flex-arrays.c: New test.
2022-12-16 17:25:42 +00:00
Palmer Dabbelt
9bb7864877
RISC-V: Fix up some wording in the mcpu/mtune comment
gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_option_override): Fix comment
	wording.
2022-12-16 08:46:54 -08:00
Palmer Dabbelt
df049cb215
RISC-V: Note that __builtin_riscv_pause() implies Xgnuzihintpausestate
gcc/ChangeLog:

	* doc/extend.texi (__builtin_riscv_pause): Imply
	Xgnuzihintpausestate.
2022-12-16 08:45:47 -08:00
Jonathan Wakely
92eb0adc14 libstdc++: Fix self-move for std::weak_ptr [PR108118]
I think an alternative fix would be something like:

  _M_ptr = std::exchange(rhs._M_ptr, nullptr);
  _M_refcount = std::move(rhs._M_refcount);

The standard's move-and-swap implementation generates smaller code at
all levels except -O0 and -Og, so it seems simplest to just do what the
standard says.

libstdc++-v3/ChangeLog:

	PR libstdc++/108118
	* include/bits/shared_ptr_base.h (weak_ptr::operator=):
	Implement as move-and-swap exactly as specified in the standard.
	* testsuite/20_util/weak_ptr/cons/self_move.cc: New test.
2022-12-16 12:59:08 +00:00
Martin Liska
d386d39920 contrib: make warnings unique in filter-clang-warnings.py
contrib/ChangeLog:

	* filter-clang-warnings.py: Print each warning only one time.
2022-12-16 13:07:27 +01:00
Richard Biener
da85bfc750 middle-end/108086 - avoid unshare_expr when remapping SSA names
r0-89280-g129a37fc319db8 added unsharing to remap_ssa_name but
that wasn't in the version of the patch posted.  That has some
non-trivial cost through mostly_copy_tree_r and copy_tree_r but
more importantly it doesn't seem to be necessary.  I've successfully
bootstrapped and tested with an assert we only get
tree_node_can_be_shared trees here.

Bootstrapped and tested on x86_64-unknown-linux-gnu with all
languages.

	PR middle-end/108086
	* tree-inline.cc (remap_ssa_name): Do not unshare the
	result from the decl_map.
2022-12-16 13:05:48 +01:00
Martin Liska
66c2f03d4c gcc-changelog: do not use PatchSet.from_filename
Use rather PatchSet constructor where we can pass
properly opened file with newline='\n'.

contrib/ChangeLog:

	* gcc-changelog/git_email.py: Use PatchSet constructor
	as newline argument is not supported with older unidiff
	library.
2022-12-16 12:21:59 +01:00
Tobias Burnus
8f2a8be579 gcc-changelog/git_email.py: Support older unidiff.PatchSet
Commit "unidiff: use newline='\n' argument",
r13-4603-gb045179973161115c7ea029b2788f5156fc55cda, added support CR
on a line, but that broke support for older unidiff.PatchSet.

This patch uses a fallback for git_email.py (drop argument) if not
available (TypeError exception) but keeps using it in test_email.py
unconditionally.

contrib/ChangeLog:

	* gcc-changelog/git_email.py (GitEmail:__init__): Support older
	unidiff.PatchSet that do not have a newline= argument
	of from_filename.
2022-12-16 11:02:24 +01:00
Richard Biener
340ddeae66 middle-end/108086 - remove PR28238 fix superseeded by PR34018 fix
There's quite special code in copy_bb that handles inline substitution
of a non-invariant address in place of an invariant one that's
now handled by more generic handling of this case in remap_gimple_op_r
so this removes the special casing that happens in a hot path, providing
a small speedup.

	PR middle-end/108086
	* tree-inline.cc (copy_bb): Remove handling of (foo *)&this->m
	substitution which is done in remap_gimple_op_r via
	re-gimplifying.
2022-12-16 10:29:02 +01:00
Jakub Jelinek
ddcaa60983 loop-invariant: Split preheader edge if the preheader bb ends with jump [PR106751]
The RTL loop passes only request simple preheaders, but don't require
fallthru preheaders, while move_invariant_reg apparently assumes the
latter, that it can just append instruction(s) to the end of the preheader
basic block.

The following patch fixes that by splitting the preheader edge if
the preheader bb ends with a JUMP_INSN (asm goto in this case).
Without that we get control flow in the middle of a bb.

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

	PR rtl-optimization/106751
	* loop-invariant.cc (move_invariant_reg): If preheader bb ends
	with a JUMP_INSN, split the preheader edge and emit invariants
	into the new preheader basic block.

	* gcc.c-torture/compile/pr106751.c: New test.
2022-12-16 10:19:22 +01:00
Richard Biener
711e0acdbb middle-end/108086 - more operand scanner reduction in inlining
There's another round of redundant operand scanning in
remap_gimple_stmt.  The following removes this and also improves
one special-case to call a cheaper inline function.

	PR middle-end/108086
	* tree-inline.cc (remap_gimple_stmt): Add stmts to the
	sequence without updating them.  Simplify x == x detection.
2022-12-16 09:29:55 +01:00
Tobias Burnus
18af26fc37 Remove libgomp/testsuite/libgomp.fortran/allocate-4.f90 [PR108056]
Commit r13-4716-ge205ec03f0794aeac3e8a89e947c12624d5a274e accidentally
included a testcase of another patch that is pending review:
https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608401.html

libgomp/
	PR libfortran/108056

	* testsuite/libgomp.fortran/allocate-4.f90: Remove
	accidentally added file.
2022-12-16 08:56:03 +01:00
Haochen Jiang
fb33e104f4 Fix intrin name in Intel CMPccXADD
We usually use only one "_" but not two "__" as prefix in intrin.

This patch aims to fix the intrin name for CMPccXADD.

gcc/ChangeLog:

	* config/i386/cmpccxaddintrin.h
	(__cmpccxadd_epi32): Rename to _cmpccxadd_epi32.
	(__cmpccxadd_epi64): Rename to _cmpccxadd_epi64.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/cmpccxadd-1.c: Fix intrin name.
	* gcc.target/i386/cmpccxadd-2.c: Ditto.
2022-12-16 10:34:02 +08:00
GCC Administrator
c8f767b2c0 Daily bump. 2022-12-16 00:17:46 +00:00
Patrick Palka
e79d519633 c++: variadic using-decl with parm pack in terminal name [PR102104]
There's a curious corner case with variadic member using-decls: the
terminal name can also contain a parameter pack, and only through naming
a conversion function, e.g.

  using A<Ts>::operator Ts...;

We currently only handle parameter packs appearing in the qualifying
scope of a variadic using-decl; this patch adds support for the above
case as well, representing such a using-decl via two pack expansions,
one for the qualifying scope and one for the terminal name (despite
logically there being just one).  Then at instantiation time we manually
merge them.

	PR c++/102104
	PR c++/108090

gcc/cp/ChangeLog:

	* error.cc (dump_decl) <case USING_DECL>: Look through a
	pack expansion in the name as well.
	* parser.cc (cp_parser_using_declaration): Handle a parameter
	pack appearing in the terminal name of a variadic using-decl.
	* pt.cc (tsubst_decl) <case USING_DECL>: Likewise.  Combine the
	handling of variadic and non-variadic using-decls.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/using-variadic1.C: New test.
	* g++.dg/cpp1z/using-variadic1a.C: New test.
	* g++.dg/cpp1z/using-variadic1b.C: New test.
	* g++.dg/cpp1z/using-variadic1c.C: New test.
	* g++.dg/cpp1z/using-variadic2.C: New test.
	* g++.dg/cpp1z/using-variadic3.C: New test.
2022-12-15 18:50:16 -05:00
Jason Merrill
57ab3714b6 c++: rename parameter
gcc/cp/ChangeLog:

	* init.cc (build_vec_init): Rename "flags" to "cleanup_flags"
	to distinguish from LOOKUP_*.
2022-12-15 16:48:00 -05:00
Arsen Arsenović
52e7ff23ff c++: mangle contracts in write_mangled_name
This fixes contract-checked extern "C" functions.

gcc/cp/ChangeLog:

	* mangle.cc (write_encoding): Move contract pre/post function
	mangling from here...
	(write_mangled_name): ... to here, and make it happen always.

gcc/testsuite/ChangeLog:

	* g++.dg/contracts/contracts-externC.C: New test.
2022-12-15 16:48:00 -05:00
Patrick Palka
147e276b58 c++: class-scope qualified constrained auto [PR107188]
Here when parsing the class-scope auto constrained by a qualified
concept-id, we first tentatively parse the overall member-declaration as
a deprecated access-declaration, during which we parse C<int> as a
standalone TEMPLATE_ID_EXPR (separate from the auto) and end up emitting
the stray error

concepts-placeholder11.C:9:6: error: wrong number of template arguments (1, should be 2)
    9 |   N::C<int> auto f() { return 0; }
      |      ^~~~~~
concepts-placeholder11.C:5:34: note: provided for ‘template<class, class> concept N::C’
    5 |   template<class, class> concept C = true;
      |                                  ^

from build_concept_id called from cp_parser_template_id_expr.

We could fix this by adding a complain parameter to build_concept_id and
passing tf_none when parsing tentatively.  However, it seems this can
also be fixed in a more general way that might benefit non-concepts
code: when tentatively parsing an access-declaration, abort the parse
early if the qualifying scope isn't possibly a class or enumeration
type, so that we avoid parsing C<int> as a TEMPLATE_ID_EXPR here in the
first place.  This patch takes this latter approach.

	PR c++/107188

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_using_declaration): Give up early if the
	scope of an access-declaration isn't possibly a class type.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-placeholder11.C: New test.
2022-12-15 16:07:09 -05:00
Patrick Palka
18499b9f84 c++: extract_local_specs and unevaluated contexts [PR100295]
Here during partial instantiation of the constexpr if, extra_local_specs
walks the statement looking for local specializations within to capture.
However, we're thwarted by the fact that 'ts' first appears inside an
unevaluated context, and so the calls to process_outer_var_ref for its
local specializations are a no-op.  And since we walk each tree exactly
once, we end up not capturing the local specializations despite 'ts'
later occurring in an evaluated context.

This patch fixes this by making extract_local_specs walk evaluated
contexts first before walking unevaluated contexts.  We could probably
get away with not walking unevaluated contexts at all, but this approach
seems more clearly safe.

	PR c++/100295
	PR c++/107579

gcc/cp/ChangeLog:

	* pt.cc (el_data::skip_unevaluated_operands): New data member.
	(extract_locals_r): If skip_unevaluated_operands is true,
	don't walk into unevaluated contexts.
	(extract_local_specs): Walk the pattern twice, first with
	skip_unevaluated_operands true followed by it set to false.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/constexpr-if-lambda5.C: New test.
2022-12-15 16:02:05 -05:00
Patrick Palka
be124477b3 c++: local alias in typename in lambda [PR105518]
We substitute the qualifying scope of a TYPENAME_TYPE directly using
tsubst_aggr_type (so that we can pass entering_scope=true) instead of
going through tsubst, which means we don't properly reuse typedefs
during this substitution.  This ends up causing us to reject the below
testcase because we substitute the TYPENAME_TYPE alias::type as if it
were written without the A<t> alias, and thus we expect the non-capturing
lambda to capture t.

This patch fixes this by making tsubst_aggr_type delegate typedefs
to tsubst so that get consistently reused, and then adjusting the result
appropriately if entering_scope is true.  In passing, this refactors
tsubst_aggr_type into two functions, one that's intended to be called
directly and a more minimal one that's intended to be called only from
the RECORD/UNION/ENUMERAL_TYPE cases of tsubst (and contains only the
necessary bits for that call site).

	PR c++/105518

gcc/cp/ChangeLog:

	* pt.cc (tsubst_aggr_type): Handle typedefs by delegating to
	tsubst and adjusting the result if entering_scope.  Split out
	the main part of the function into ...
	(tsubst_aggr_type_1) ... here.
	(tsubst): Use tsubst_aggr_type_1 instead of tsubst_aggr_type.
	Handle TYPE_PTRMEMFUNC_P RECORD_TYPEs here instead of in
	tsubst_aggr_type_1.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/lambda/lambda-alias1.C: New test.
2022-12-15 15:54:31 -05:00
Patrick Palka
38304846d1 c++: partial ordering with memfn ptr cst [PR108104]
Here we're triggering an overzealous assert in unify during partial
ordering since the member function pointer constants are represented as
ordinary CONSTRUCTORs (with TYPE_PTRMEMFUNC_P TREE_TYPE) but the assert
expects COMPOUND_LITERAL_P constructors.

	PR c++/108104

gcc/cp/ChangeLog:

	* pt.cc (unify) <default>: Relax assert to accept any
	CONSTRUCTOR parm, not just COMPOUND_LITERAL_P one.

gcc/testsuite/ChangeLog:

	* g++.dg/template/ptrmem33.C: New test.
2022-12-15 15:38:47 -05:00
Vladimir N. Makarov
12abd5a7d1 IRA: Check that reg classes contain a hard reg of given mode in reg move cost calculation
IRA calculates wrong AVR costs for moving general hard regs of SFmode.  To
calculate the costs we did not exclude sub-classes which do not contain
hard regs of given mode.  This was the reason for spilling a pseudo in the
PR. The patch fixes this.

        PR rtl-optimization/90706

gcc/ChangeLog:

	* ira-costs.cc: Include print-rtl.h.
	(record_reg_classes, scan_one_insn): Add code to print debug info.
	* ira.cc (ira_init_register_move_cost): Check that at least one hard
	reg of the mode are in the class contents to calculate the
	register move costs.

gcc/testsuite/ChangeLog:

	* gcc.target/avr/pr90706.c: New.
2022-12-15 14:19:19 -05:00
Jakub Jelinek
8b775b4c48 c++: Ensure !!var is not an lvalue [PR107065]
The TRUTH_NOT_EXPR case in cp_build_unary_op is one of the spots where
we somewhat fold immediately using invert_truthvalue_loc.
I've tried using
  return build1_loc (location, TRUTH_NOT_EXPR, boolean_type_node, arg);
in there instead, but unfortunately that regressed
Wlogical-not-parentheses-*.c pr49706.c pr62199.c pr65120.c sequence-pt-1.C
tests, so at least for backporting that doesn't seem to be a way to go.

So, this patch instead wraps it into NON_LVALUE_EXPR if needed (which also
need a tweak for some tests in the pr47906.c test, but nothing major),
with the intent to make it backportable, and later I'll try to do further
steps to avoid folding here prematurely.  Most of the problems with
build1 TRUTH_NOT_EXPR are that it doesn't even invert comparisons as most
common case and lots of warning code isn't able to deal with ! around
comparisons; so perhaps one way to do this would be fold by hand only
invertable comparisons and for the rest create TRUTH_NOT_EXPR.

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

	PR c++/107065
gcc/cp/
	* typeck.cc (cp_build_unary_op) <case TRUTH_NOT_EXPR>: If
	invert_truthvalue_loc returns obvalue_p, wrap it into NON_LVALUE_EXPR.
	* parser.cc (cp_parser_binary_expression): Don't call
	warn_logical_not_parentheses if current.lhs is a NON_LVALUE_EXPR
	of a decl with boolean type.
gcc/testsuite/
	* g++.dg/cpp0x/pr107065.C: New test.
2022-12-15 19:17:45 +01:00
Siddhesh Poyarekar
f5300d28bf doc: Fix documentation for __builtin_dynamic_object_size
__builtin_dynamic_object_size is missing from the full list of builtins,
so add it.  Also mention it alongside __builtin_object_size in the
passes description.

gcc/ChangeLog:

	* doc/extend.texi (__builtin_dynamic_object_size): Document
	builtin.
	* doc/passes.texi
	(Optimize calls to @code{__builtin_object_size}): Also mention
	__builtin_dynamic_object_size.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2022-12-15 12:52:42 -05:00
Siddhesh Poyarekar
7283380a58 middle-end/70090: Document that -fsanitize=object-size uses dynamic size
Fix the documentation to say that object sizes are deduced using
__builtin_dynamic_object_size.

gcc/ChangeLog:

	PR middle-end/70090
	* doc/invoke.texi (-fsanitize=object-size): Use
	__builtin_dynamic_object_size instead of
	__builtin_object_size.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2022-12-15 12:52:42 -05:00
Richard Biener
d49b2a3a1d middle-end/108086 - avoid quadraticness in copy_edges_for_bb
For the testcase in PR108086 it's visible that we split blocks
multiple times when inlining and that causes us to adjust the
block tail stmt BBs multiple times, once for each split.  The
fix is to walk backwards and split from the tail instead.

For a reduced testcase this improves compile-time at -O by 4%.

	PR middle-end/108086
	* tree-inline.cc (copy_edges_for_bb): Walk stmts backwards for
	splitting the block to avoid quadratic behavior with setting
	stmts BB on multliple splits.
2022-12-15 18:42:52 +01:00
Jakub Jelinek
3f101e32e2 c++, libstdc++: Add typeinfo for _Float{16,32,64,128,32x,64x} and __bf16 types [PR108075]
The following patch adds typeinfos for the extended floating point
types and _Float{32,64}x.

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

	PR libstdc++/108075
gcc/cp/
	* rtti.cc (emit_support_tinfos): Add pointers to
	{bfloat16,float{16,32,64,128,32x,64x,128x}}_type_node to fundamentals
	array.
gcc/testsuite/
	* g++.dg/cpp23/ext-floating13.C: New test.
libstdc++-v3/
	* config/abi/pre/gnu.ver (CXXABI_1.3.14): Export
	_ZTIDF[0-9]*[_bx], _ZTIPDF[0-9]*[_bx] and _ZTIPKDF[0-9]*[_bx].
	* testsuite/util/testsuite_abi.cc (check_version): Handle
	CXXABI_1.3.14.
2022-12-15 17:02:55 +01:00
Gaius Mulley
85d0d2683b Subject: [committed, pushed] PR-107607 m2: Remove bdepend on realpath, cut and echo
It can be replaced by a subshell'd cd just fine.
(cd gcc/m2; autoconf-2.69)

gcc/m2/ChangeLog:

	* configure.ac: Stop probing for realpath.
	* tools-src/calcpath: Break dependency on realpath, cut
	and echo.
	* configure: Rebuilt.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2022-12-15 14:27:38 +00:00
Jakub Jelinek
4a16480841 testsuite: Fix up * quoting in glob strings
\* wasn't enough, we need \\* and for ObjC it wasn't done at all.

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

	* lib/target-supports.exp (check_compile): Further quoting
	fixes for /* Assembly, /* ObjC and (* Modula-2 *) checks.
2022-12-15 14:16:20 +01:00
Jakub Jelinek
9cf9f3c762 testsuite: Add support for Rust and Modula-2 effective target tests
This patch allows magic comments also for Rust and Modula-2
for effective target tests etc. and fixes up the Assembly entry
- it is a glob, so /* Assembly can match /whatever Assembly and
not just /* Assembly.

Tested on x86_64-linux with
make check-g++ RUNTESTFLAGS=i386.exp=pr35513*
and verifying it still uses *.S extension for the property_1_needed
effective target test.

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

	* lib/target-supports.exp (check_compile): Add support for
	Rust and Modula-2.  Use \* rather than * for /* comment for
	Assembly.
2022-12-15 13:57:43 +01:00
Jakub Jelinek
32582c190b Adjust ChangeLog entries from m2 merge.
Fix up ChangeLog formatting...
2022-12-15 13:01:07 +01:00
Gaius Mulley
157003d450 PR-108123 gcc/m2/gm2config.h.in
Rebuilt the file gcc/m2/gm2config.h.in with autoheader-2.69.

gcc/m2/ChangeLog:

	* gm2config.h.in: Rebuilt.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2022-12-15 11:49:18 +00:00
Tobias Burnus
e205ec03f0 libgfortran's ISO_Fortran_binding.c: Use GCC11 version for backward-only code [PR108056]
Since GCC 12, the conversion between the array descriptors formats - the
internal (GFC) and the C binding one (CFI) - moved to the compiler itself
such that the cfi_desc_to_gfc_desc/gfc_desc_to_cfi_desc functions are only
used with older code (GCC 9 to 11).  The newly added checks caused asserts
as older code did not pass the proper values (e.g. real(4) as effective
argument arrived as BT_ASSUME type as the effective type got lost inbetween).

As proposed in the PR, revert to the GCC 11 version - known bugs is better
than some fixes and new issues. Still, GCC 12 is much better in terms of
TS29113 support and should really be used.

This patch uses the current libgomp version of the GCC 11 branch, except
it fixes the GFC version number (which is 0), uses calloc instead of malloc,
and sets the lower bound to 1 instead of keeping it as is for
CFI_attribute_other.

libgfortran/ChangeLog:

	PR libfortran/108056
	* runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc,
	gfc_desc_to_cfi_desc): Mostly revert to GCC 11 version for
	those backward-compatiblity-only functions.
2022-12-15 12:26:06 +01:00
Spacetown
c263c3eba8 gcov: annotate uncovered branches [PR107537]
PR gcov-profile/107537

gcc/ChangeLog:
	* gcov.cc (output_branch_count): Add annotation '(fallthrough)'
	or '(throw)' also to uncovered branches.

Signed-off-by: Michael Förderer <michael.foerderer@gmx.de>
2022-12-15 11:58:29 +01:00
Richard Biener
930b3d6948 middle-end/108086 - reduce operand scanner use from inliner
The following avoids a redundant second operand scan on all stmts
during inlining which shows with PR108086.

	PR middle-end/108086
	* tree-inline.cc (copy_edges_for_bb): Do not update all
	stmts again.
2022-12-15 11:32:16 +01:00