]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
9 months agotestsuite: Sanitize pacbti test cases for Cortex-M
Torbjörn SVENSSON [Tue, 3 Sep 2024 09:23:57 +0000 (11:23 +0200)] 
testsuite: Sanitize pacbti test cases for Cortex-M

Some of the test cases were scanning for "bti", but it would,
incorrectly, match the ".arch_extenssion pacbti".

gcc/testsuite/ChangeLog:

* gcc.target/arm/bti-1.c: Check for asm instructions starting
with a tab.
* gcc.target/arm/bti-2.c: Likewise.
* gcc.target/arm/pac-1.c: Likewise.
* gcc.target/arm/pac-2.c: Likewise.
* gcc.target/arm/pac-3.c: Likewise.
* gcc.target/arm/pac-4.c: Likewise.
* gcc.target/arm/pac-6.c: Likewise.
* gcc.target/arm/pac-7.c: Likewise.
* gcc.target/arm/pac-8.c: Likewise.
* gcc.target/arm/pac-9.c: Likewise.
* gcc.target/arm/pac-10.c: Likewise.
* gcc.target/arm/pac-11.c: Likewise.
* gcc.target/arm/pac-15.c: Likewise.
* gcc.target/arm/pac-sibcall.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
9 months agoDaily bump.
GCC Administrator [Sun, 27 Oct 2024 00:17:28 +0000 (00:17 +0000)] 
Daily bump.

9 months agodoc, fortran: Add a missing menu item.
Iain Sandoe [Sat, 26 Oct 2024 22:06:09 +0000 (23:06 +0100)] 
doc, fortran: Add a missing menu item.

The changes in r15-4697-g4727bfb37701 omit a menu entry which causes a
bootstrap fail when Frotran is included for at least makeinfo 6.7.
Fixed thus.

gcc/fortran/ChangeLog:

* intrinsic.texi: Add menu item for UINT.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
9 months agotree: Mark PAREN_EXPR and VEC_DUPLICATE_EXPR as non-trapping [PR117234]
Andrew Pinski [Sat, 26 Oct 2024 09:14:18 +0000 (02:14 -0700)] 
tree: Mark PAREN_EXPR and VEC_DUPLICATE_EXPR as non-trapping [PR117234]

While looking to fix a possible trapping issue in PHI-OPT's factor,
I noticed that some tree codes could be marked as trapping even
though they don't have a possibility to trap. In the case of PAREN_EXPR,
it is basically a nop except when it comes to association across it so
it can't trap.
In the case of VEC_DUPLICATE_EXPR, it is similar to a CONSTRUCTOR, so it
can't trap.

This fixes those 2 issues and adds 4 testcases, 2 which are specific to aarch64
since the only way to get a VEC_DUPLICATE_EXPR is to use intrinsics currently.

Build and tested for aarch64-linux-gnu.

PR tree-optimization/117234

gcc/ChangeLog:

* tree-eh.cc (operation_could_trap_helper_p): Treat
PAREN_EXPR and VEC_DUPLICATE_EXPR like constructing
expressions.

gcc/testsuite/ChangeLog:

* g++.dg/eh/noncall-fp-1.C: New test.
* g++.target/aarch64/sve/noncall-eh-fp-1.C: New test.
* gcc.dg/tree-ssa/trapping-1.c: New test.
* gcc.target/aarch64/sve/trapping-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
9 months agoAdd UNSIGNED for intrinsics.
Thomas Koenig [Sat, 26 Oct 2024 17:20:14 +0000 (19:20 +0200)] 
Add UNSIGNED for intrinsics.

gcc/fortran/ChangeLog:

* gfortran.texi: Correct reference to make clear that UNSIGNED
will not be part of F202Y.
Other clarifications.
Extend table of intrinsics, add links.
* intrinsic.texi: Add descriptions for UNSIGNED arguments.
* invoke.texi: Add anchor for -funsigned.

9 months agoFix old glitch in the GNAT Reference Manual
Eric Botcazou [Sat, 26 Oct 2024 13:16:57 +0000 (15:16 +0200)] 
Fix old glitch in the GNAT Reference Manual

gcc/ada
PR ada/62122
* doc/gnat_rm/implementation_defined_attributes.rst
(Unrestricted_Access): Remove null exclusion.
* gnat_rm.texi: Regenerate.

9 months agoAssert finished vectorizer pattern COND_EXPR transition
Richard Biener [Fri, 25 Oct 2024 12:27:37 +0000 (14:27 +0200)] 
Assert finished vectorizer pattern COND_EXPR transition

The following places a few strathegic asserts so we do not end up
with COND_EXPRs with a comparison as the first operand during
vectorization.

* tree-vect-slp.cc (vect_get_operand_map): Mark
COMPARISON_CLASS_P COND_EXPR condition path unreachable.
* tree-vect-stmts.cc (vect_is_simple_use): Likewise.
(vectorizable_condition): Assert the COND_EXPR condition isn't
COMPARISON_CLASS_P.

9 months agoFinish vectorizer pattern proper COND_EXPR transition
Richard Biener [Fri, 25 Oct 2024 12:20:23 +0000 (14:20 +0200)] 
Finish vectorizer pattern proper COND_EXPR transition

This fixes up vect_recog_ctz_ffs_pattern.

* tree-vect-patterns.cc (vect_recog_ctz_ffs_pattern): Create
a separate pattern stmt for the comparison in the generated
COND_EXPR.

9 months agoFinish vectorizer pattern proper COND_EXPR transition
Richard Biener [Fri, 25 Oct 2024 11:42:08 +0000 (13:42 +0200)] 
Finish vectorizer pattern proper COND_EXPR transition

The following tries to finish building proper GIMPLE COND_EXPRs
in vectorizer pattern recognition.

* tree-vect-patterns.cc (vect_recog_divmod_pattern): Build
separate comparion pattern for the condition of a COND_EXPR
pattern.

9 months agotestsuite: fixup tbaa test again
Sam James [Sat, 26 Oct 2024 01:03:43 +0000 (02:03 +0100)] 
testsuite: fixup tbaa test again

Test was broken until r15-4684-g2d1d6be00257c5 which made it actually
run and r15-4685-g091e45b4e97d1e which applied fixes other than the
trivial rename.

But more is needed: this gets the test working properly in terms of scanning
the dump and handling the interaction w/ LTO with not producing an executable
(did try ltrans scan but that didn't work either).

Unfortunately, the test seems to fail for me on godbolt even going back to
GCC 7.1 or thereabouts, hence XFAIL. However, if I revert r9-3870-g2a98b4bfc3d952,
I do get an ICE in fld_incomplete_type_of -- because we do far more checking
with LTO now on (in)complete types. And reverting it on releases/gcc-9 actually
makes it give 0.

In summary: fix the test fully so it really does run and we get a check
for ICEing at least, and mark the dg-final scan as XFAIL so Honza can
comment on that.

gcc/testsuite/ChangeLog:
PR testsuite/117299

* gcc.dg/lto/tbaa_0.c: Move to...
* gcc.dg/tbaa.c: ...here.

9 months agoDaily bump.
GCC Administrator [Sat, 26 Oct 2024 00:19:39 +0000 (00:19 +0000)] 
Daily bump.

9 months agolibbacktrace: recognize new Mach-O DWARF sections
Ian Lance Taylor [Fri, 25 Oct 2024 22:17:15 +0000 (15:17 -0700)] 
libbacktrace: recognize new Mach-O DWARF sections

Patch from Pavel Safonov.

These sections are used on macOS Sequoia.

Fixes https://github.com/ianlancetaylor/libbacktrace/issues/136

* macho.c (dwarf_section_names): Add __debug_addr and
__debug_line_str.

9 months agosimplify-rtx: Handle `a != 0 ? -a : 0` [PR58195]
Andrew Pinski [Sun, 20 Oct 2024 17:44:14 +0000 (10:44 -0700)] 
simplify-rtx: Handle `a != 0 ? -a : 0` [PR58195]

The gimple (and generic) levels have this optmization since r12-2041-g7d6979197274a662da7bdc5.
It seems like a good idea to add a similar one to rtl just in case it is not caught at the
gimple level.

Note the loop case in csel-neg-1.c is not handled at the gimple level (even with phiopt turned back on),
this is because of casts to avoid signed integer overflow; a patch to fix this at the gimple level will be
submitted seperately.

Changes since v1:
* v2: Use `CONST0_RTX (mode)` instead of const0_rtx. Add csel-neg-2.c for float testcase which now passes.

Build and tested for aarch64-linux-gnu.

PR rtl-optimization/58195

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_ternary_operation): Handle
`a != 0 ? -a : 0` and `a == 0 ? 0 : -a`.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/csel-neg-1.c: New test.
* gcc.target/aarch64/csel-neg-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
9 months agotestsuite: lto: fix pr47333 test
Sam James [Fri, 25 Oct 2024 20:12:21 +0000 (21:12 +0100)] 
testsuite: lto: fix pr47333 test

This failure was hidden until we started to run the test by fixing
the filename earlier: ignore -Wtemplate-body using a pragma like
e.g. g++.dg/lto/20101010-1_0.C does because lto.exp doesn't support
dg-additional-options.

gcc/testsuite/ChangeLog:
PR lto/47333

* g++.dg/lto/pr47333_0.C: Ignore -Wtemplate-body.

9 months agotestsuite: lto: fix pr62026 test
Sam James [Fri, 25 Oct 2024 19:55:39 +0000 (20:55 +0100)] 
testsuite: lto: fix pr62026 test

This failure was hidden until we started to run the test by fixing
the filename earlier: pass -Wno-return-type.

gcc/testsuite/ChangeLog:
PR lto/62026

* g++.dg/lto/pr62026_0.C: Pass -Wno-return-type.

9 months agotestsuite: lto: fix pr95677 test
Sam James [Fri, 25 Oct 2024 17:02:06 +0000 (18:02 +0100)] 
testsuite: lto: fix pr95677 test

These failures were hidden until we started to run the test by fixing
the filename earlier: use dg-lto directives.

gcc/testsuite/ChangeLog:
PR c++/95677

* g++.dg/lto/pr95677_0.C: Use dg-lto-*.

9 months agotestsuite: lto: fix tbaa_0 test
Sam James [Fri, 25 Oct 2024 16:59:31 +0000 (17:59 +0100)] 
testsuite: lto: fix tbaa_0 test

These failures were hidden until we started to run the test by fixing
the filename earlier: use dg-lto directives, pass -std=gnu89 for
implicit-int, and use -flto-partition=none like c-c++-common/hwasan/builtin-special-handling.c.

gcc/testsuite/ChangeLog:

* gcc.dg/lto/tbaa_0.c: Use dg-lto directives, pass -std=gnu89, and
use -flto-partition=none.

9 months agotestsuite: lto: rename tbaa-1 test
Sam James [Fri, 25 Oct 2024 15:31:32 +0000 (16:31 +0100)] 
testsuite: lto: rename tbaa-1 test

This was being ignored previously. Rename it per README.

gcc/testsuite/ChangeLog:

* gcc.dg/lto/tbaa-1.c: Move to...
* gcc.dg/lto/tbaa_0.c: ...here.

9 months agotestsuite: lto: rename pr47333 test
Sam James [Fri, 25 Oct 2024 15:31:01 +0000 (16:31 +0100)] 
testsuite: lto: rename pr47333 test

This was being ignored previously. Rename it per README.

gcc/testsuite/ChangeLog:
PR target/47333

* g++.dg/lto/pr47333.C: Move to...
* g++.dg/lto/pr47333_0.C: ...here.

9 months agotestsuite: lto: rename pr62026 test
Sam James [Fri, 25 Oct 2024 15:30:49 +0000 (16:30 +0100)] 
testsuite: lto: rename pr62026 test

This was being ignored previously. Rename it per README.

gcc/testsuite/ChangeLog:
PR lto/62026

* g++.dg/lto/pr62026.C: Move to...
* g++.dg/lto/pr62026_0.C: ...here.

9 months agotestsuite: lto: rename pr95677 test
Sam James [Mon, 21 Oct 2024 11:13:34 +0000 (12:13 +0100)] 
testsuite: lto: rename pr95677 test

This was being ignored previously. Rename it per README.

gcc/testsuite/ChangeLog:
PR c++/95677

* g++.dg/lto/pr95677.C: Move to...
* g++.dg/lto/pr95677_0.C: ...here.

9 months agotoplevel: Error out if using --disable-libstdcxx with bootstrap [PR105474]
Andrew Pinski [Thu, 22 Aug 2024 21:34:03 +0000 (14:34 -0700)] 
toplevel: Error out if using --disable-libstdcxx with bootstrap [PR105474]

Bootstrapping and using --disable-libstdcxx will cause a build failure deep in compiling
stage2 so instead error out early in the toplevel configure so it is more user friendly.

Bootstrapped and tested on x86_64-linux-gnu.
Also made sure --disable-libstdcxx without --disable-bootstrap failed.

PR bootstrap/105474

ChangeLog:

* configure: Regenerate.
* configure.ac: Error out if libstdc++ is not enabled
with bootstrapping.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
9 months agoaarch64: Support multiple variants including up to 3
Andrew Pinski [Sat, 4 May 2024 09:03:16 +0000 (02:03 -0700)] 
aarch64: Support multiple variants including up to 3

On some of the Qualcomm's SoC that includes oryon-1 core, the variant
will be different on the cores due to big.little config. Though
the difference between big and little is not significant enough
to have seperate cost/scheduling models for them and the feature set
is the same across all variants.

Also on some SoCs, there are 3 variants of the core, big.middle.little
so this increases the support there for up to 3 cores and 3 variants
in the original parsing loop but it does not change the support for max
of 2 different cores.

After this patch and the patch that adds oryon-1, -mcpu=native works
on the SoCs I am working with.

Bootstrapped and tested on aarch64-linux-gnu with no regressions.

gcc/ChangeLog:

* config/aarch64/driver-aarch64.cc (host_detect_local_cpu): Support
3 cores and 3 variants. If there is one core but multiple variant,
then treat the variant as being all.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/cpunative/info_25: New file.
* gcc.target/aarch64/cpunative/info_26: New file.
* gcc.target/aarch64/cpunative/native_cpu_25.c: New test.
* gcc.target/aarch64/cpunative/native_cpu_26.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
9 months agoAArch64: Add more accurate constraint [PR117292]
Wilco Dijkstra [Fri, 25 Oct 2024 14:53:58 +0000 (14:53 +0000)] 
AArch64: Add more accurate constraint [PR117292]

As shown in the PR, reload may only check the constraint in some cases and
and not check the predicate is still valid for the resulting instruction.
To fix the issue, add a new constraint which matches the predicate exactly.

gcc/ChangeLog:
PR target/117292
* config/aarch64/aarch64-simd.md (xor<mode>3<vczle><vczbe>): Use
'De' constraint.
* config/aarch64/constraints.md (De): Add new constraint.

gcc/testsuite/ChangeLog:
PR target/117292
* gcc.target/aarch64/sve/single_5.c: Remove xfails.
* gcc.target/aarch64/pr117292.c: New test.

9 months agoFortran: Fix ICE with structure constructor in data statement [PR79685]
Paul Thomas [Fri, 25 Oct 2024 16:59:03 +0000 (17:59 +0100)] 
Fortran: Fix ICE with structure constructor in data statement [PR79685]

2024-10-25  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/79685
* decl.cc (match_data_constant): Find the symtree instead of
the symbol so the use renamed symbols are found. Pass this and
the derived type to gfc_match_structure_constructor.
* match.h: Update prototype of gfc_match_structure_contructor.
* primary.cc (gfc_match_structure_constructor): Remove call to
gfc_get_ha_sym_tree and use caller supplied symtree instead.

gcc/testsuite/
PR fortran/79685
* gfortran.dg/use_rename_13.f90: New test.

9 months agotestsuite: add testcase for fixed PR115933
Sam James [Sun, 20 Oct 2024 07:28:59 +0000 (08:28 +0100)] 
testsuite: add testcase for fixed PR115933

gcc/testsuite/ChangeLog:
PR rtl-optimization/115933

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

9 months agoaarch64: Add mfloat vreinterpret intrinsics
Andrew Carlotti [Mon, 21 Oct 2024 15:22:43 +0000 (16:22 +0100)] 
aarch64: Add mfloat vreinterpret intrinsics

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc (MODE_d_mf8): New.
(MODE_q_mf8): New.
(QUAL_mf8): New.
(VREINTERPRET_BUILTINS1): Add mf8 entry.
(VREINTERPRET_BUILTINS): Ditto.
(VREINTERPRETQ_BUILTINS1): Ditto.
(VREINTERPRETQ_BUILTINS): Ditto.
(aarch64_lookup_simd_type_in_table): Match modal_float bit

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/advsimd-intrinsics/mf8-reinterpret.c: New test.

9 months agoaarch64: Add support for mfloat8x{8|16}_t types
Andrew Carlotti [Mon, 21 Oct 2024 15:22:09 +0000 (16:22 +0100)] 
aarch64: Add support for mfloat8x{8|16}_t types

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc
(aarch64_init_simd_builtin_types): Initialise FP8 simd types.
* config/aarch64/aarch64-builtins.h
(enum aarch64_type_qualifiers): Add qualifier_modal_float bit.
* config/aarch64/aarch64-simd-builtin-types.def:
Add Mfloat8x{8|16}_t types.
* config/aarch64/arm_neon.h: Add mfloat8x{8|16}_t typedefs.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/movv16qi_2.c: Test mfloat as well.
* gcc.target/aarch64/movv16qi_3.c: Ditto.
* gcc.target/aarch64/movv2x16qi_1.c: Ditto.
* gcc.target/aarch64/movv3x16qi_1.c: Ditto.
* gcc.target/aarch64/movv4x16qi_1.c: Ditto.
* gcc.target/aarch64/movv8qi_2.c: Ditto.
* gcc.target/aarch64/movv8qi_3.c: Ditto.
* gcc.target/aarch64/mfloat-init-1.c: New test.

9 months agomatch.pd: Add std::pow folding optimizations.
Jennifer Schmitz [Thu, 17 Oct 2024 15:40:34 +0000 (08:40 -0700)] 
match.pd: Add std::pow folding optimizations.

This patch adds the following two simplifications in match.pd for
POW_ALL and POWI:
- pow (1.0/x, y) to pow (x, -y), avoiding the division
- pow (0.0, x) to 0.0, avoiding the call to pow.
The patterns are guarded by flag_unsafe_math_optimizations,
!flag_trapping_math, and !HONOR_INFINITIES.
The POW_ALL patterns are also gated under !flag_errno_math.
The second pattern is also guarded by !HONOR_NANS and
!HONOR_SIGNED_ZEROS.

Tests were added to confirm the application of the transform for
builtins pow, powf, powl, powi, powif, powil, and powf16.

The patch was bootstrapped and regtested on aarch64-linux-gnu and
x86_64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
* match.pd: Fold pow (1.0/x, y) -> pow (x, -y) and
pow (0.0, x) -> 0.0.

gcc/testsuite/
* gcc.dg/tree-ssa/pow_fold_1.c: New test.

9 months agoMatch: Simplify branch form 3 of unsigned SAT_ADD into branchless
Pan Li [Thu, 24 Oct 2024 13:57:04 +0000 (21:57 +0800)] 
Match: Simplify branch form 3 of unsigned SAT_ADD into branchless

There are sorts of forms for the unsigned SAT_ADD.  Some of them are
complicated while others are cheap.  This patch would like to simplify
the complicated form into the cheap ones.  For example as below:

From the form 3 (branch):
  SAT_U_ADD = (X + Y) >= x ? (X + Y) : -1.

To (branchless):
  SAT_U_ADD = (X + Y) | - ((X + Y) < X).

  #define T uint8_t

  T sat_add_u_1 (T x, T y)
  {
    return (T)(x + y) >= x ? (x + y) : -1;
  }

Before this patch:
   1   │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y)
   2   │ {
   3   │   uint8_t D.2809;
   4   │
   5   │   _1 = x + y;
   6   │   if (x <= _1) goto <D.2810>; else goto <D.2811>;
   7   │   <D.2810>:
   8   │   D.2809 = x + y;
   9   │   goto <D.2812>;
  10   │   <D.2811>:
  11   │   D.2809 = 255;
  12   │   <D.2812>:
  13   │   return D.2809;
  14   │ }

After this patch:
   1   │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y)
   2   │ {
   3   │   uint8_t D.2809;
   4   │
   5   │   _1 = x + y;
   6   │   _2 = x + y;
   7   │   _3 = x > _2;
   8   │   _4 = (unsigned char) _3;
   9   │   _5 = -_4;
  10   │   D.2809 = _1 | _5;
  11   │   return D.2809;
  12   │ }

The simplify doesn't need to check if target support the SAT_ADD, it
is somehow the optimization in gimple level.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Remove unsigned branch form 3 for SAT_ADD, and
add simplify to branchless instead.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c: New test.
* gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c: New test.
* gcc.dg/tree-ssa/sat_u_add-simplify-1-u64.c: New test.
* gcc.dg/tree-ssa/sat_u_add-simplify-1-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
9 months agoAssorted --disable-checking fixes [PR117249]
Jakub Jelinek [Fri, 25 Oct 2024 12:09:42 +0000 (14:09 +0200)] 
Assorted --disable-checking fixes [PR117249]

We have currently 3 different definitions of gcc_assert macro, one used most
of the time (unless --disable-checking) which evaluates the condition at
runtime and also checks it at runtime, then one for --disable-checking GCC 4.5+
which looks like
((void)(UNLIKELY (!(EXPR)) ? __builtin_unreachable (), 0 : 0))
and a fallback one
((void)(0 && (EXPR)))
Now, the last one actually doesn't evaluate any of the side-effects in the
argument, just quiets up unused var/parameter warnings.
I've tried to replace the middle definition with
({ [[assume (EXPR)]]; (void) 0; })
for compilers which support assume attribute and statement expressions
(surprisingly quite a few spots use gcc_assert inside of comma expressions),
but ran into PR117287, so for now such a change isn't being proposed.

The following patch attempts to move important side-effects from gcc_assert
arguments.

Bootstrapped/regtested on x86_64-linux and i686-linux with normal
--enable-checking=yes,rtl,extra, plus additionally I've attempted to do
x86_64-linux bootstrap with --disable-checking and gcc_assert changed to the
((void)(0 && (EXPR)))
version when --disable-checking.  That version ran into spurious middle-end
warnings
../../gcc/../include/libiberty.h:733:36: error: argument to ‘alloca’ is too large [-Werror=alloca-larger-than=]
../../gcc/tree-ssa-reassoc.cc:5659:20: note: in expansion of macro ‘XALLOCAVEC’
  int op_num = ops.length ();
  int op_normal_num = op_num;
  gcc_assert (op_num > 0);
  int stmt_num = op_num - 1;
  gimple **stmts = XALLOCAVEC (gimple *, stmt_num);
where we have gcc_assert exactly to work-around middle-end warnings.
Guess I'd need to also disable -Werror for this experiment, which actually
isn't a problem with unmodified system.h, because even for
--disable-checking we use the __builtin_unreachable at least in
stage2/stage3 and so the warnings aren't emitted, and even if it used
[[assume ()]]; it would work too because in stage2/stage3 we could again
rely on assume and statement expression support.

2024-10-25  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/117249
* tree-ssa-structalias.cc (insert_vi_for_tree): Move put calls out of
gcc_assert.
* lto-cgraph.cc (lto_symtab_encoder_delete_node): Likewise.
* gimple-ssa-strength-reduction.cc (get_alternative_base,
add_cand_for_stmt): Likewise.
* tree-eh.cc (add_stmt_to_eh_lp_fn): Likewise.
* except.cc (duplicate_eh_regions_1): Likewise.
* tree-ssa-reassoc.cc (insert_operand_rank): Likewise.
* config/nvptx/nvptx.cc (nvptx_expand_call): Use == rather than = in
gcc_assert.
* opts-common.cc (jobserver_info::disconnect): Call close outside of
gcc_assert and only check result in it.
(jobserver_info::return_token): Call write outside of gcc_assert and
only check result in it.
* genautomata.cc (output_default_latencies): Move j++ side-effect
outside of gcc_assert.
* tree-ssa-loop-ivopts.cc (get_alias_ptr_type_for_ptr_address): Use
== rather than = in gcc_assert.
* cgraph.cc (symbol_table::create_edge): Move ++edges_max_uid
side-effect outside of gcc_assert.

9 months agolto: Handle RAW_DATA_CST in compare_tree_sccs_1 [PR117201]
Jakub Jelinek [Fri, 25 Oct 2024 12:05:37 +0000 (14:05 +0200)] 
lto: Handle RAW_DATA_CST in compare_tree_sccs_1 [PR117201]

I've missed I need to add RAW_DATA_CST support in compare_tree_sccs_1,
because without that it considers all RAW_DATA_CSTs to be equivalent,
regardless of their length or content.

2024-10-24  Jakub Jelinek  <jakub@redhat.com>

PR lto/117201
PR lto/117288
* lto-common.cc (compare_tree_sccs_1): Handle RAW_DATA_CST.

* gcc.dg/lto/pr117201_0.c: New test.
* gcc.dg/lto/pr117288_0.c: New test.

9 months agoDefault expand_vec_cond_expr_p code to ERROR_MARK
Richard Biener [Fri, 25 Oct 2024 10:38:24 +0000 (12:38 +0200)] 
Default expand_vec_cond_expr_p code to ERROR_MARK

As we want to transition to only vcond_mask expanders the following
makes it possible to easier distinguish queries that rely on
vcond queries for expand_vec_cond_expr_p from those of vcond_mask
by for the latter having the comparison code defaulted to ERROR_MARK.

* optabs-tree.h (expand_vec_cond_expr_p): Default the
comparison code to ERROR_MARK.
* match.pd: Remove unneded expand_vec_cond_expr_p args.
* tree-vect-generic.cc (expand_vector_condition): Likewise.
* tree-vect-loop.cc (vect_reduction_update_partial_vector_usage):
Likewise.
* tree-vect-stmts.cc (vectorizable_simd_clone_call): Likewise.
(scan_store_can_perm_p): Likewise.
(vectorizable_condition): Likewise.

9 months agotestsuite: Generalise tree-ssa/shifts-3.c regexp
Richard Sandiford [Fri, 25 Oct 2024 11:25:42 +0000 (12:25 +0100)] 
testsuite: Generalise tree-ssa/shifts-3.c regexp

My recent gcc.dg/tree-ssa/shifts-3.c test failed on arm-linux-gnu
because it used widen_mult_expr to do a multiplication on chars.
This patch generalises the regexp in the same way as for f3.

gcc/testsuite/
* gcc.dg/tree-ssa/shifts-3.c: Accept widen_mult for f2 too.

9 months agoAdd regression test
Eric Botcazou [Fri, 25 Oct 2024 11:14:22 +0000 (13:14 +0200)] 
Add regression test

gcc/testsuite
PR ada/116551
* gnat.dg/specs/vfa3.ads: New test.

9 months agolibstdc++: Disable parts of new test that depend on constexpr std::string
Jonathan Wakely [Thu, 24 Oct 2024 19:12:08 +0000 (20:12 +0100)] 
libstdc++: Disable parts of new test that depend on constexpr std::string

The compile-time assertions don't work with -D_GLIBCXX_USE_CXX11_ABI=0.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc:
Check __cpp_lib_constexpr_string.

9 months agolibstdc++: implement concatenation of strings and string_views
Giuseppe D'Angelo [Tue, 30 Jul 2024 18:09:12 +0000 (20:09 +0200)] 
libstdc++: implement concatenation of strings and string_views

This adds support for P2591R5, merged for C++26.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: Implement the four operator+
overloads between basic_string and (types convertible to)
basic_string_view.
* include/bits/version.def: Bump the feature-testing macro.
* include/bits/version.h: Regenerate.
* testsuite/21_strings/basic_string/operators/char/op_plus_fspath_neg.cc: New test.
* testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc: New test.
* testsuite/21_strings/basic_string/operators/char/op_plus_string_view_compat.cc:
New test.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
9 months agoRestrict :c to commutative ops as intended
Richard Biener [Thu, 24 Oct 2024 15:06:29 +0000 (17:06 +0200)] 
Restrict :c to commutative ops as intended

genmatch was supposed to restrict :c to verifiable commutative
operations while leaving :C to the "I know what I'm doing" case.
The following enforces this, cleaning up parsing and amending
the commutative_op helper.  There's one pattern that needs adjustment,
the pattern optimizing fmax (x, NaN) or fmax (NaN, x) to x since
fmax isn't commutative.

* genmatch.cc (commutative_op): Add paramter to indicate whether
all compares should be considered commutative.  Handle
hypot, add_overflow and mul_overflow.
(parser::parse_expr): Simplify 'c' handling by using
commutative_op and error out when the operation is not.
* match.pd ((minmax:c @0 NaN@1) -> @0): Use :C, we know
what we are doing.

9 months agotree-optimization/117277 - remove CLOBBERs before SLP code generation
Richard Biener [Thu, 24 Oct 2024 14:15:43 +0000 (16:15 +0200)] 
tree-optimization/117277 - remove CLOBBERs before SLP code generation

We have to remove CLOBBERs before SLP is code generated since for
store-lanes we are inserting our own CLOBBERs that we want to survive.
So the following refactors vect_transform_loop to remove unwanted
stmts first.

This resolves the gcc.target/aarch64/sve/store_lane_spill_1.c FAIL.

PR tree-optimization/117277
* tree-vect-loop.cc (vect_transform_loop): Remove CLOBBERs
and prefetches before doing any code generation.

9 months agotree-optimization/116575 - SLP masked load-lanes discovery
Richard Biener [Wed, 23 Oct 2024 11:56:55 +0000 (13:56 +0200)] 
tree-optimization/116575 - SLP masked load-lanes discovery

The following implements masked load-lane discovery for SLP.  The
challenge here is that a masked load has a full-width mask with
group-size number of elements when this becomes a masked load-lanes
instruction one mask element gates all group members.  We already
have some discovery hints in place, namely STMT_VINFO_SLP_VECT_ONLY
to guard non-uniform masks, but we need to choose a way for SLP
discovery to handle possible masked load-lanes SLP trees.

I have this time chosen to handle load-lanes discovery where we
have performed permute optimization already and conveniently got
the graph with predecessor edges built.  This is because unlike
non-masked loads masked loads with a load_permutation are never
produced by SLP discovery (because load permutation handling doesn't
handle un-permuting the mask) and thus the load-permutation lowering
which handles non-masked load-lanes discovery doesn't trigger.

With this SLP discovery for a possible masked load-lanes, thus
a masked load with uniform mask, produces a splat of a single-lane
sub-graph as the mask SLP operand.  This is a representation that
shouldn't pessimize the mask load case and allows the masked load-lanes
transform to simply elide this splat.

This fixes the aarch64-sve.exp mask_struct_load*.c testcases with
--param vect-force-slp=1

PR tree-optimization/116575
* tree-vect-slp.cc (vect_get_and_check_slp_defs): Handle
gaps, aka NULL scalar stmt.
(vect_build_slp_tree_2): Allow gaps in the middle of a
grouped mask load.  When the mask of a grouped mask load
is uniform do single-lane discovery for the mask and
insert a splat VEC_PERM_EXPR node.
(vect_optimize_slp_pass::decide_masked_load_lanes): New
function.
(vect_optimize_slp_pass::run): Call it.

9 months agoRelax vect_check_scalar_mask check
Richard Biener [Wed, 23 Oct 2024 09:55:31 +0000 (11:55 +0200)] 
Relax vect_check_scalar_mask check

When the mask is not a constant or external def there's no need to
check the scalar type, in particular with SLP and the mask being
a VEC_PERM_EXPR there isn't a scalar operand ready to check
(not one vect_is_simple_use will get you).  We later check the
vector type and reject non-mask types there.

* tree-vect-stmts.cc (vect_check_scalar_mask): Only check
the scalar type for constant or extern defs.

9 months agoada: Change scope of XUB type
Tom Tromey [Wed, 31 Jul 2024 15:01:45 +0000 (09:01 -0600)] 
ada: Change scope of XUB type

An earlier patch in the "nameless" series caused a regression with
-fgnat-encodings=all.  Previously, all artificial types were emitted
in the CU scope in the DWARF, but with the patch, an "XUB" type is
emitted in the function scope.  This causes gdb lookups to erroneously
find the XUB type rather than the type that gdb expects to find.

Note that I don't know why the earlier code worked, because decl.cc
clearly sets the XUB type's context to be the current function.

This patch changes the type's context so that it is nested in a type
that is conveniently available.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Use gnu_fat_type as the type
context for a XUB type.

9 months agoada: Set DECL_NAMELESS in create_type_decl
Tom Tromey [Tue, 9 Jul 2024 15:36:26 +0000 (09:36 -0600)] 
ada: Set DECL_NAMELESS in create_type_decl

When using minimal encodings, most artificial types do not need to
have their names emitted in the DWARF.  This patch changes the
compiler to generally omit these names.

However, a subset of names are needed: when the compiler creates an
artificial type for certain kinds of arrays, the name is needed by
gdb.  So, a new parameter is added to create_type_decl to allow this
omission to be disabled.

Note that simply passing 'false' as the artificial_p argument to
create_type_decl doesn't work properly -- other parts of the compiler
seem to rely on this flag being set, and so making this change causes
ICEs.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Update some calls to
create_type_decl.
* gcc-interface/gigi.h (create_type_decl): Add can_be_nameless parameter.
* gcc-interface/utils.cc (create_type_decl): Add can_be_nameless
parameter.  Set DECL_NAMELESS on type decl.

9 months agoada: Mark some type decls as nameless
Tom Tromey [Wed, 10 Jul 2024 17:54:25 +0000 (11:54 -0600)] 
ada: Mark some type decls as nameless

The types created by record_builtin_type and create_type_stub_decl can
be marked as nameless when using minimal encodings.  In this
situation, gdb does not need these type names.

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (record_builtin_type, create_type_stub_decl):
Set DECL_NAMELESS on type decls.

9 months agoada: Mark XUA types as artificial
Tom Tromey [Wed, 10 Jul 2024 17:52:17 +0000 (11:52 -0600)] 
ada: Mark XUA types as artificial

gdb does not need the name of XUA types.  This patch changes the
compiler to unconditionally mark these as artificial; a subsequent
patch will arrange for the name to be omitted.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Pass 'true' to
create_type_decl when creating XUA type.

9 months agoada: Mark XUB types as nameless
Tom Tromey [Wed, 10 Jul 2024 17:38:55 +0000 (11:38 -0600)] 
ada: Mark XUB types as nameless

gdb does not need the name of XUB types.  This patch changes the
compiler to omit these names from the DWARF when minimal encodings are
in use.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Set TYPE_NAMELESS on
XUB types.

9 months agoada: Add 'artificial_p' parameter to build_unc_object_type
Tom Tromey [Wed, 10 Jul 2024 17:46:57 +0000 (11:46 -0600)] 
ada: Add 'artificial_p' parameter to build_unc_object_type

This adds an 'artificial_p' parameter to build_unc_object_type, so
that the artificiality of the type can be propagated to
create_type_decl.  This will affect the namelessness of the type in a
subsequent patch.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Pass artificial_p to
build_unc_object_type.
* gcc-interface/gigi.h (build_unc_object_type): Update.
* gcc-interface/utils.cc (build_unc_object_type) Add artificial_p
parameter.
(build_unc_object_type_from_ptr): Update.

9 months agoada: Standard types are not artificial
Tom Tromey [Wed, 10 Jul 2024 17:29:11 +0000 (11:29 -0600)] 
ada: Standard types are not artificial

This changes gigi so that standard types are no longer marked
artificial.  This change is needed to prevent subsequent patches from
causing standard types to have their names elided.  Also, although
DWARF says that DW_AT_artificial is used for "the declaration of an
object or type artificially generated by a compiler and not explicitly
declared by the source program", it seems to me that types provided by
the language should not be marked as such; and this is what the C and
C++ compilers do.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (is_artificial): New function.
(gnat_to_gnu_entity): Use it.

9 months agoada: Fix fallout of change in parameter passing out of aliasing considerations
Eric Botcazou [Wed, 18 Sep 2024 06:24:32 +0000 (08:24 +0200)] 
ada: Fix fallout of change in parameter passing out of aliasing considerations

If an actual parameter that is a type conversion is passed by reference but
not addressable, the temporary that is created and whose address is passed
instead may need to be in the target type of the conversion to fulfill the
requirements of strict aliasing.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (Call_to_gnu): If the formal is passed by
reference and the actual is a type conversion but not addressable,
create the temporary in the target type of the conversion if this
is needed to enforce strict aliasing.

9 months agoada: Fix internal error on bit-packed array type with Volatile_Full_Access
Eric Botcazou [Wed, 11 Sep 2024 17:53:12 +0000 (19:53 +0200)] 
ada: Fix internal error on bit-packed array type with Volatile_Full_Access

The problem occurs when the component type is a record type with default
values for the initialization procedure of the (base) array type, because
the compiler is trying to generate a full access for a parameter of the
base array type, which does not make sense.

gcc/ada/ChangeLog:

PR ada/116551
* gcc-interface/trans.cc (node_is_atomic) <N_Identifier>: Return
false if the type of the entity is an unconstrained array type.
(node_is_volatile_full_access) <N_Identifier>: Likewise.

9 months agoada: Back out part of previous change -- disable warning
Bob Duff [Tue, 1 Oct 2024 20:31:10 +0000 (16:31 -0400)] 
ada: Back out part of previous change -- disable warning

Temporarily disable the warning, because it breaks
SPARK continuous builder

gcc/ada/ChangeLog:

* sem_ch10.adb (Analyze_With_Clause): Temporarily disable warning.

9 months agoada: Disable self-referential with_clauses
Bob Duff [Tue, 1 Oct 2024 15:29:34 +0000 (11:29 -0400)] 
ada: Disable self-referential with_clauses

Self-referential with_clauses (as in package body X says "with X;")
cause trouble, such as duplicate nested instantiations when using
container packages. This patch disables most of the processing by
setting the Is_Implicit_With flag. It's not really implicit, but the
subsequent processing behaves as if it is, and coming up with a more
accurate (and much longer) name for the flag doesn't seem beneficial for
such an obscure case. Note that the spec of X will be processed later,
rather than upon seeing "with X;".

Other cleanups, such as renaming Implicit_With to be Is_Implicit_With.

gcc/ada/ChangeLog:

* sem_ch10.adb: (Analyze_With_Clause): Check for self-referential
with clause. Give a warning, and set Is_Implicit_With, which we
are reusing in this obscure case even though it's not really
implicit.
(Analyze_Context): Remove check for self-referential with clause.
It wasn't correct -- it only triggered for Acts_As_Spec
subprograms. Corrected check is now in Analyze_With_Clause.
(Implicit_With): Rename to be Is_Implicit_With. Misc cleanup,
comment fixes.
(Process_Spec_Clauses): Remove default for Exit_On_Self parameter.
Use "exit when" instead of if statement.
* sinfo.ads (Implicit_With): Rename to be Is_Implicit_With.
Document new use for self-referential withs.
* ali.adb (Scan_ALI): Use an aggregate to initialize Withs entry.
* exp_put_image.adb (Preload_Root_Buffer_Type): Make this a
once-only procedure.
* sem_util.ads (Is_Ancestor_Package): Fix comment -- a libraryunit
is an ancestor of itself, but this doesn't return True in that
case.
* sem_util.adb (Is_Ancestor_Package): Better to initialize things
on their declaration.
* lib-load.adb: Minor comment fix.
* sem_prag.adb: Implicit_With --> Is_Implicit_With. Minor comment
fix.
* gen_il-fields.ads: Implicit_With --> Is_Implicit_With.
* gen_il-gen-gen_nodes.adb: Likewise
* lib.adb: Likewise
* lib-writ.adb: Likewise
* rtsfind.adb: Likewise
* sem_cat.adb: Likewise
* sem_ch12.adb: Likewise
* sem_ch8.adb: Likewise
* sem_elab.adb: Likewise
* sem_warn.adb: Likewise
* gcc-interface/trans.cc: (Implicit_With): Rename to be
Is_Implicit_With.

9 months agoada: Emit DWARF for Ada 'with' and 'use' clauses
Tom Tromey [Wed, 24 Apr 2024 19:13:08 +0000 (13:13 -0600)] 
ada: Emit DWARF for Ada 'with' and 'use' clauses

This changes the Ada compiler to emit DWARF information for Ada 'with'
and 'use' clauses.  In particular, code like:

    with Pck; use Pck;

will be emitted as:

 <1><146a>: Abbrev Number: 23 (DW_TAG_module)
    <146b>   DW_AT_name        : pck
    <146f>   DW_AT_decl_file   : 1
    <1470>   DW_AT_decl_line   : 16
    <1471>   DW_AT_decl_column : 6
 <1><1472>: Abbrev Number: 24 (DW_TAG_imported_module)
    <1473>   DW_AT_decl_file   : 1
    <1474>   DW_AT_decl_line   : 16
    <1475>   DW_AT_decl_column : 11
    <1476>   DW_AT_import      : <0x146a>

That is, DW_TAG_module is used to represent a 'with' clause, and
DW_TAG_imported_module is used to represent 'use'.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (namespace_map): New global.
(Compilation_Unit_to_gnu): Also handle N_With_Clause and
N_Use_Package_Clause.
(get_or_create_namespace, get_namespace): New functions.
(gnat_to_gnu) <N_Package_Renaming_Declaration>: Call
get_namespace.
<N_Use_Package_Clause, N_With_Clause>: Likewise.

9 months agoada: Small adjustments to commentary after latest change
Eric Botcazou [Tue, 1 Oct 2024 07:19:36 +0000 (09:19 +0200)] 
ada: Small adjustments to commentary after latest change

This removes the enumeration of the various cases in the comment associated
with the declaration of In_Expanded_Body to prevent synchronization issues.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Expression.In_Expanded_Body): Tweak comments.

9 months agoada: Pragma Pre_Class and Post_Class have no effect at runtime
Javier Miranda [Mon, 30 Sep 2024 09:08:04 +0000 (09:08 +0000)] 
ada: Pragma Pre_Class and Post_Class have no effect at runtime

The pragmas Pre_Class and Post_Class are accepted by the compiler
but have no effect at runtime.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Entity): If the entity is an access-to-subprogram
type declaration that pre/postcondition contracts, build the
wrapper
(if not previously done as part of processing aspects).
* sem_ch3.adb (Build_Access_Subprogram_Wrapper): Add missing support
for building the wrapper when the access type has pragmas
Pre_Class/Post_Class.
(Build_Access_Subprogram_Wrapper_Declaration): New subprogram.
* sem_ch3.ads (Build_Access_Subprogram_Wrapper): Spec moved to the
public part of the package.
* sem_prag.adb (Analyze_Pre_Post_Condition): Store in the tree copy of
class-wide pre/postcondition expression; required to merge it with
inherited conditions.
(Is_Valid_Assertion_Kind): Added Pre_Class and Post_Class.

9 months agoada: Update GNAT UG
Richard Kenner [Thu, 5 Sep 2024 17:37:33 +0000 (13:37 -0400)] 
ada: Update GNAT UG

Also add some LLVM-specific information.

gcc/ada/ChangeLog:

* doc/gnat_ugn/about_this_guide.rst: Numerous changes to language
and style and add some LLVM-specific information.
* doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Likewise.
* doc/gnat_ugn/example_of_binder_output.rst: Likewise.
* doc/gnat_ugn/getting_started_with_gnat.rst: Likewise.
* doc/gnat_ugn/gnat_and_program_execution.rst: Likewise.
* doc/gnat_ugn/gnat_utility_programs.rst: Likewise.
* doc/gnat_ugn/inline_assembler.rst: Likewise.
* doc/gnat_ugn/platform_specific_information.rst: Likewise.
* doc/gnat_ugn/the_gnat_compilation_model.rst: Likewise.
* gnat_ugn.texi: Regenerate.

9 months agoada: Fix ATC with timed delay from Ada.Real_Time
Eric Botcazou [Fri, 27 Sep 2024 07:36:17 +0000 (09:36 +0200)] 
ada: Fix ATC with timed delay from Ada.Real_Time

An Asynchronous Transfer of Control blocks with a timed delay that is
computed by means of the Ada.Real_Time unit (instead of the default
Ada.Calendar unit) because of a missing abort deferral in the unit.

gcc/ada/ChangeLog:

PR ada/43485
* libgnarl/a-retide.adb: Add with clause for System.Soft_Links.
(Delay_Until): Defer and undefer abort around the call to the
Timed_Delay routine of System.Task_Primitives.Operations.

9 months agoada: Fix internal error on function call in class-wide precondition
Eric Botcazou [Fri, 27 Sep 2024 10:19:14 +0000 (12:19 +0200)] 
ada: Fix internal error on function call in class-wide precondition

This occurs when the call is to a function that is declared in a package
that is nested in the scope where the type declaration is located.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Expression.In_Expanded_Body): Also return True
for the body of a helper/wrapper built for class-wide preconditions.

9 months agoada: Pragmas Pre_Class/Post_Class rejected for abstract subprograms
Javier Miranda [Thu, 26 Sep 2024 10:14:10 +0000 (10:14 +0000)] 
ada: Pragmas Pre_Class/Post_Class rejected for abstract subprograms

The Pre_Class/Post_Class pragmas are rejected at compile time
for abstract subprograms.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Pre_Post_Condition): Allow the use of
pragma Pre_Class/Post_Class with abstract subprograms.

9 months agoada: Spurious error when compiling in Syntax and Semantics Only mode
Javier Miranda [Thu, 26 Sep 2024 09:18:48 +0000 (09:18 +0000)] 
ada: Spurious error when compiling in Syntax and Semantics Only mode

Compiling under switch -gnatc, the frontend reports spurious errors
accessing components of class-wide tagged types.

gcc/ada/ChangeLog:

* sem_ch3.adb (Record_Type_Definition): For tagged types, add
the missing decoration to the First_Entity in the corresponding
class-wide type entity.

9 months agoada: Adjust documentation of External_Initialization
Ronan Desplanques [Mon, 23 Sep 2024 08:36:29 +0000 (10:36 +0200)] 
ada: Adjust documentation of External_Initialization

The parameters Maximum_Size and If_Empty were mentioned during the
request for comments phase but are not implemented, at least for now.
This patch changes the GNAT reference manual accordingly. It also makes
a minor punctuation change.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst: Adjust documentation.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

9 months agoada: Update Compiler_Error documentation
Richard Kenner [Mon, 27 May 2024 15:52:16 +0000 (11:52 -0400)] 
ada: Update Compiler_Error documentation

Since we usually build without assertions, we force a bugbox by
raising Program_Error, not an always-false assertion.

gcc/ada/ChangeLog:

* comperr.ads (Compiler_Error): Update documentation.

9 months agoada: Add Type_Size_For function to Uintp package
Eric Botcazou [Fri, 13 Sep 2024 09:53:00 +0000 (11:53 +0200)] 
ada: Add Type_Size_For function to Uintp package

It computes the size of an integer type that can accommodate the input.

gcc/ada/ChangeLog:

* uintp.ads (Type_Size_For): New function declaration.
* uintp.adb (Type_Size_For): New function body.
* exp_imgv.adb (Rewrite_Object_Image): Call Type_Size_For to get
the size of a narrower integer type.

9 months agoada: Update simpler accessibility model doc
Tonu Naks [Fri, 13 Sep 2024 14:59:55 +0000 (14:59 +0000)] 
ada: Update simpler accessibility model doc

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst: update
simpler accessibility model
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

9 months agoada: Misc improvements to gnat RM
Bob Duff [Wed, 18 Sep 2024 20:28:34 +0000 (16:28 -0400)] 
ada: Misc improvements to gnat RM

...in the "GNAT language extensions" section.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst:
Minor wording improvments.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

9 months agoada: Increase stack size for Windows tasking programs
squirek [Thu, 12 Sep 2024 14:37:49 +0000 (14:37 +0000)] 
ada: Increase stack size for Windows tasking programs

This patch increases the default tasking stack size for Windows tasking
program to 8 mb to avoid use of pragma Linker_Options in the general case.

gcc/ada/ChangeLog:

* libgnarl/s-taprop__mingw.adb: Modify stack size and update
documentation.

9 months agoada: Constraint error not raised in ACATS test c413007
Javier Miranda [Tue, 17 Sep 2024 11:53:06 +0000 (11:53 +0000)] 
ada: Constraint error not raised in ACATS test c413007

The Constraint_Error exception is not raised when a subprogram
is called using prefix notation, and the prefix of the call is
an access-to-subprogram type with a null value. This new check
is enabled by switch -gnatd_P

gcc/ada/ChangeLog:

* gen_il-fields.ads: New node field (Is_Expanded_Prefixed_Call).
* gen_il-gen-gen_nodes.adb: New semantic field for N_Function_Call
and N_Procedure_Call_Statement nodes.
* sem_ch4.adb (Complete_Object_Operation): Mark the rewritten node
with the Is_Expanded_Prefixed_Call flag.
* sem_res.adb (Check_Prefixed_Call): Code cleanup and addition of
documentation.
(Resolve_Actuals): Add a null-exclusion check on the
prefix of the call when it is an access-type.
* sinfo.ads: Adding new semantic flag (Is_Expanded_Prefixed_Call)
to N_Function_Call and N_Procedure_Call_Statement nodes.
* debug.adb: Adding documentation for switch d_P.

9 months agoada: Put Finalizable aspect in -gnatX
Raphaël AMIARD [Fri, 13 Sep 2024 13:30:03 +0000 (15:30 +0200)] 
ada: Put Finalizable aspect in -gnatX

gcc/ada/ChangeLog:

* sem_ch13.adb (Analyze_One_Aspect): change the call to
`Error_Msg_GNAT_Extension` to allow this aspect in core
extensions. Put the code path in core extensions.
* exp_util.adb (Name_Of_Controlled_Prim_Op): Put the code path
in core extensions

9 months agoada: Fix internal error on ambiguous operands of comparison operator
Eric Botcazou [Mon, 16 Sep 2024 06:31:57 +0000 (08:31 +0200)] 
ada: Fix internal error on ambiguous operands of comparison operator

This is a regression introduced when the diagnosis of ambiguous operands
for comparison and equality operators was moved from the analysis to the
resolution phase in order to avoid spurious ambiguities in specific cases.

When an ambiguity is detected for the operands of predefined comparison
and equality operators during analysis, it needs to be recorded so that
later calls to the disambiguation routine know about this ambiguity for
the case where the context has been resolved to boolean.

gcc/ada/ChangeLog:

* sem_type.ads (Interp ): Add Opnd_Typ component and remove default
value for Abstract_Op component.
(Add_One_Interp): Rename Opnd_Type parameter to Opnd_Typ.
* sem_type.adb (Add_One_Interp): Likewise.
(Add_One_Interp.Add_Entry): Record the operand type as well.
(Collect_Interp): Record Empty for the operand type.
(Disambiguate.Is_Ambiguous_Boolean_Operator): New predicate.
(Disambiguate): Use it to detect recorded ambiguity cases.
* sem_ch4.adb (Find_Comparison_Equality_Types): Add commentary.

9 months agoada: Spurious error compiling CC51011
Javier Miranda [Mon, 16 Sep 2024 11:40:06 +0000 (11:40 +0000)] 
ada: Spurious error compiling CC51011

Adjust the check of 13.14(10.2/3) to avoid reporting an error
on unfrozen incomplete types, as they are never frozen
(AI12-0155-1).

gcc/ada/ChangeLog:

* sem_ch8.adb (Freeze_Actual_Profile): Do not report error
on incomplete types, since they do not cause freezing.

9 months agoada: Fix wrong handling of wide wide characters in Append_Decoded_With_Brackets
Eric Botcazou [Sat, 14 Sep 2024 12:48:24 +0000 (14:48 +0200)] 
ada: Fix wrong handling of wide wide characters in Append_Decoded_With_Brackets

This only shows up at link time when the name of a compilation unit contains
a wide wide character.

gcc/ada/ChangeLog:

* namet.adb (Append_Decoded_With_Brackets): Fix condition for the
cheap test at the beginning of the loop.

9 months agoada: Fix fallout of change to 'Wide_Wide_Value for enumeration types
Eric Botcazou [Fri, 13 Sep 2024 19:09:31 +0000 (21:09 +0200)] 
ada: Fix fallout of change to 'Wide_Wide_Value for enumeration types

The literals of enumeration types are always normalized, even though they
contain wide characters (but the normalization leaves these unchanged),
so a normalization routine that is aware of wide characters must be run
on the input string for 'Wide_Wide_Value.

gcc/ada/ChangeLog:

PR ada/115507
* rtsfind.ads (RE_Id): Add RE_Enum_[Wide_]Wide_String_To_String.
(RE_Unit_Table): Add entries for the new values.
* exp_attr.adb (Is_User_Defined_Enumeration_Type): New predicate.
(Expand_N_Attribute_Reference) <Attribute_Wide_Value>: Build a call
to RE_Enum_Wide_String_To_String for user-defined enumeration types.
<Attribute_Wide_Wide_Value>: Likewise with
RE_Enum_Wide_Wide_String_To_String.
* exp_imgv.adb (Expand_Value_Attribute): Adjust to above.
* libgnat/s-wchwts.ads (Enum_Wide_String_To_String): New function.
(Enum_Wide_Wide_String_To_String): Likewise.
* libgnat/s-wchwts.adb: Add clauses for System.Case_Util.
(Normalize_String): New local procedure.
(Enum_Wide_String_To_String): New function body.
(Enum_Wide_Wide_String_To_String): Likewise.

9 months agoada: Untagged incomplete view not detected in ACATS test b3a1a060
Javier Miranda [Fri, 13 Sep 2024 07:02:02 +0000 (07:02 +0000)] 
ada: Untagged incomplete view not detected in ACATS test b3a1a060

Adding checks for RM 3.10.1(10): An actual parameter cannot be
of an untagged incomplete view; the result object of a function
call cannot be of an incomplete view.

gcc/ada/ChangeLog:

* sem_res.adb (Resolve_Actuals): Add checks for incomplete
type actuals.

9 months agoada: Forbid repr clauses for decls in handled_stmts
Raphaël AMIARD [Tue, 10 Sep 2024 09:10:21 +0000 (11:10 +0200)] 
ada: Forbid repr clauses for decls in handled_stmts

gcc/ada/ChangeLog:

* par-ch5.adb (P_Sequence_Of_Statements): Forbid repr clauses in
handled_statements.

9 months agoada: Inspect deferred constant completions in missing contexts
Raphaël AMIARD [Wed, 4 Sep 2024 08:24:26 +0000 (08:24 +0000)] 
ada: Inspect deferred constant completions in missing contexts

Namely declare expressions and statement lists, which can have object
declarations in -gnatX mode.

gcc/ada/ChangeLog:

* sem_util.ads: Introduce Inspect_Deferred_Constant_Completion
on a single object declaration, to better factorize the code
* sem_util.adb: Introduce aforementioned overload
* sem_ch4.adb (Analyze_Expression_With_Actions): Check deferred
constant completions
* sem_ch5.adb (Analyze_Statements): Check deferred constant
completions

9 months agoada: Pass parameters of full access unconstrained array types by copy in calls
Eric Botcazou [Thu, 12 Sep 2024 14:11:47 +0000 (16:11 +0200)] 
ada: Pass parameters of full access unconstrained array types by copy in calls

When a full access array type is declared, either Volatile_Full_Access in
Ada 2012 or Atomic in Ada 2022, an implicit base array type is built by the
compiler with the Full_Access flag set, although full accesses cannot be
generated for objects of this type because the size is not known statically.

If the component type is a record with default values, an initialization
procedure taking a parameter of the base array type is built. Given that
full accesses cannot be generated for the parameter inside the procedure,
we need to pass the actual parameter by copy to the procedure in order to
implement the full access semantics.

gcc/ada/ChangeLog:

* exp_ch6.adb (Expand_Actuals.Is_Legal_Copy): Return True for an
initialization procedure with a full access formal parameter.
(Expand_Actuals.Requires_Atomic_Or_Volatile_Copy): Return True if
the formal parameter is of a full access unconstrained array type.

9 months agonon-gcc: Remove trailing whitespace
Jakub Jelinek [Fri, 25 Oct 2024 07:44:10 +0000 (09:44 +0200)] 
non-gcc: Remove trailing whitespace

I've tried to build stage3 with
-Wleading-whitespace=blanks -Wtrailing-whitespace=blank -Wno-error=leading-whitespace=blanks -Wno-error=trailing-whitespace=blank
added to STRICT_WARN and that expectably resulted in about
2744 unique trailing whitespace warnings and 124837 leading whitespace
warnings when excluding *.md files (which obviously is in big part a
generator issue).  Others from that are generator related, I think those
need to be solved later.

The following patch just fixes up the easy case (trailing whitespace),
which could be easily automated:
for i in `find . -name \*.h -o -name \*.cc -o -name \*.c | xargs grep -l '[  ]$' | grep -v testsuite/`; do sed -i -e 's/[  ]*$//' $i; done
I've excluded files which I knew are obviously generated or go FE.

Is there anything else we'd want to avoid the changes?

Due to patch size, I've split it between gcc/ part
and rest (include/, libiberty/, libgcc/, libcpp/, libstdc++-v3/;
this part).

2024-10-24  Jakub Jelinek  <jakub@redhat.com>

include/
* dyn-string.h: Remove trailing whitespace.
* libiberty.h: Likewise.
* xregex.h: Likewise.
* splay-tree.h: Likewise.
* partition.h: Likewise.
* plugin-api.h: Likewise.
* demangle.h: Likewise.
* vtv-change-permission.h: Likewise.
* fibheap.h: Likewise.
* hsa_ext_image.h: Likewise.
* hashtab.h: Likewise.
* libcollector.h: Likewise.
* sort.h: Likewise.
* symcat.h: Likewise.
* hsa_ext_amd.h: Likewise.
libcpp/
* directives.cc: Remove trailing whitespace.
* mkdeps.cc: Likewise.
* line-map.cc: Likewise.
* internal.h: Likewise.
* files.cc: Likewise.
* init.cc: Likewise.
* makeucnid.cc: Likewise.
* system.h: Likewise.
* include/line-map.h: Likewise.
* include/symtab.h: Likewise.
* include/cpplib.h: Likewise.
* expr.cc: Likewise.
* charset.cc: Likewise.
* macro.cc: Likewise.
* errors.cc: Likewise.
* lex.cc: Likewise.
* traditional.cc: Likewise.
libgcc/
* crtstuff.c: Remove trailing whitespace.
* libgcov.h: Likewise.
* config/alpha/crtfastmath.c: Likewise.
* config/alpha/vms-gcc_shell_handler.c: Likewise.
* config/alpha/vms-unwind.h: Likewise.
* config/pa/linux-atomic.c: Likewise.
* config/pa/linux-unwind.h: Likewise.
* config/pa/quadlib.c: Likewise.
* config/pa/fptr.c: Likewise.
* config/s390/32/_fixsfdi.c: Likewise.
* config/s390/32/_fixunssfdi.c: Likewise.
* config/s390/32/_fixunsdfdi.c: Likewise.
* config/c6x/pr-support.c: Likewise.
* config/lm32/_udivsi3.c: Likewise.
* config/lm32/libgcc_lm32.h: Likewise.
* config/lm32/_udivmodsi4.c: Likewise.
* config/lm32/_mulsi3.c: Likewise.
* config/lm32/_modsi3.c: Likewise.
* config/lm32/_umodsi3.c: Likewise.
* config/lm32/_divsi3.c: Likewise.
* config/darwin-crt3.c: Likewise.
* config/msp430/mpy.c: Likewise.
* config/ia64/tf-signs.c: Likewise.
* config/ia64/fde-vms.c: Likewise.
* config/ia64/unwind-ia64.c: Likewise.
* config/ia64/vms-unwind.h: Likewise.
* config/ia64/sfp-exceptions.c: Likewise.
* config/ia64/quadlib.c: Likewise.
* config/ia64/unwind-ia64.h: Likewise.
* config/rl78/vregs.h: Likewise.
* config/arm/bpabi.c: Likewise.
* config/arm/unwind-arm.c: Likewise.
* config/arm/pr-support.c: Likewise.
* config/arm/linux-atomic.c: Likewise.
* config/arm/bpabi-lib.h: Likewise.
* config/frv/frvend.c: Likewise.
* config/frv/cmovw.c: Likewise.
* config/frv/frvbegin.c: Likewise.
* config/frv/cmovd.c: Likewise.
* config/frv/cmovh.c: Likewise.
* config/aarch64/cpuinfo.c: Likewise.
* config/i386/crtfastmath.c: Likewise.
* config/i386/cygming-crtend.c: Likewise.
* config/i386/32/tf-signs.c: Likewise.
* config/i386/crtprec.c: Likewise.
* config/i386/sfp-exceptions.c: Likewise.
* config/i386/w32-unwind.h: Likewise.
* config/m32r/initfini.c: Likewise.
* config/sparc/crtfastmath.c: Likewise.
* config/gcn/amdgcn_veclib.h: Likewise.
* config/nios2/linux-atomic.c: Likewise.
* config/nios2/linux-unwind.h: Likewise.
* config/nios2/lib2-mul.c: Likewise.
* config/nios2/lib2-nios2.h: Likewise.
* config/xtensa/unwind-dw2-xtensa.c: Likewise.
* config/rs6000/darwin-fallback.c: Likewise.
* config/rs6000/ibm-ldouble.c: Likewise.
* config/rs6000/sfp-machine.h: Likewise.
* config/rs6000/darwin-asm.h: Likewise.
* config/rs6000/darwin-crt2.c: Likewise.
* config/rs6000/aix-unwind.h: Likewise.
* config/rs6000/sfp-exceptions.c: Likewise.
* config/gthr-vxworks.c: Likewise.
* config/riscv/atomic.c: Likewise.
* config/visium/memcpy.c: Likewise.
* config/darwin-crt-tm.c: Likewise.
* config/stormy16/lib2funcs.c: Likewise.
* config/arc/ieee-754/divtab-arc-sf.c: Likewise.
* config/arc/ieee-754/divtab-arc-df.c: Likewise.
* config/arc/initfini.c: Likewise.
* config/sol2/gmon.c: Likewise.
* config/microblaze/divsi3_table.c: Likewise.
* config/m68k/fpgnulib.c: Likewise.
* libgcov-driver.c: Likewise.
* unwind-dw2.c: Likewise.
* fp-bit.c: Likewise.
* dfp-bit.h: Likewise.
* dfp-bit.c: Likewise.
* libgcov-driver-system.c: Likewise.
libgcc/config/libbid/
* _le_td.c: Remove trailing whitespace.
* bid128_compare.c: Likewise.
* bid_div_macros.h: Likewise.
* bid64_to_bid128.c: Likewise.
* bid64_to_uint32.c: Likewise.
* bid128_to_uint64.c: Likewise.
* bid64_div.c: Likewise.
* bid128_round_integral.c: Likewise.
* bid_binarydecimal.c: Likewise.
* bid128_string.c: Likewise.
* bid_flag_operations.c: Likewise.
* bid128_to_int64.c: Likewise.
* _mul_sd.c: Likewise.
* bid64_mul.c: Likewise.
* bid128_noncomp.c: Likewise.
* _gt_dd.c: Likewise.
* bid64_add.c: Likewise.
* bid64_string.c: Likewise.
* bid_from_int.c: Likewise.
* bid128.c: Likewise.
* _ge_dd.c: Likewise.
* _ne_sd.c: Likewise.
* _dd_to_td.c: Likewise.
* _unord_sd.c: Likewise.
* bid64_to_uint64.c: Likewise.
* _gt_sd.c: Likewise.
* _sd_to_td.c: Likewise.
* _addsub_td.c: Likewise.
* _ne_td.c: Likewise.
* bid_dpd.c: Likewise.
* bid128_add.c: Likewise.
* bid128_next.c: Likewise.
* _lt_sd.c: Likewise.
* bid64_next.c: Likewise.
* bid128_mul.c: Likewise.
* _lt_dd.c: Likewise.
* _ge_td.c: Likewise.
* _unord_dd.c: Likewise.
* bid64_sqrt.c: Likewise.
* bid_sqrt_macros.h: Likewise.
* bid64_fma.c: Likewise.
* _sd_to_dd.c: Likewise.
* bid_conf.h: Likewise.
* bid64_noncomp.c: Likewise.
* bid_gcc_intrinsics.h: Likewise.
* _gt_td.c: Likewise.
* _ge_sd.c: Likewise.
* bid128_minmax.c: Likewise.
* bid128_quantize.c: Likewise.
* bid32_to_bid64.c: Likewise.
* bid_round.c: Likewise.
* _td_to_sd.c: Likewise.
* bid_inline_add.h: Likewise.
* bid128_fma.c: Likewise.
* _eq_td.c: Likewise.
* bid32_to_bid128.c: Likewise.
* bid64_rem.c: Likewise.
* bid128_2_str_tables.c: Likewise.
* _mul_dd.c: Likewise.
* _dd_to_sd.c: Likewise.
* bid128_div.c: Likewise.
* _lt_td.c: Likewise.
* bid64_compare.c: Likewise.
* bid64_to_int32.c: Likewise.
* _unord_td.c: Likewise.
* bid128_rem.c: Likewise.
* bid_internal.h: Likewise.
* bid64_to_int64.c: Likewise.
* _eq_dd.c: Likewise.
* _td_to_dd.c: Likewise.
* bid128_to_int32.c: Likewise.
* bid128_to_uint32.c: Likewise.
* _ne_dd.c: Likewise.
* bid64_quantize.c: Likewise.
* _le_dd.c: Likewise.
* bid64_round_integral.c: Likewise.
* _le_sd.c: Likewise.
* bid64_minmax.c: Likewise.
libgcc/config/avr/libf7/
* f7-renames.h: Remove trailing whitespace.
libstdc++-v3/
* include/debug/debug.h: Remove trailing whitespace.
* include/parallel/base.h: Likewise.
* include/parallel/types.h: Likewise.
* include/parallel/settings.h: Likewise.
* include/parallel/multiseq_selection.h: Likewise.
* include/parallel/partition.h: Likewise.
* include/parallel/random_number.h: Likewise.
* include/parallel/find_selectors.h: Likewise.
* include/parallel/partial_sum.h: Likewise.
* include/parallel/list_partition.h: Likewise.
* include/parallel/search.h: Likewise.
* include/parallel/algorithmfwd.h: Likewise.
* include/parallel/random_shuffle.h: Likewise.
* include/parallel/multiway_mergesort.h: Likewise.
* include/parallel/sort.h: Likewise.
* include/parallel/algobase.h: Likewise.
* include/parallel/numericfwd.h: Likewise.
* include/parallel/multiway_merge.h: Likewise.
* include/parallel/losertree.h: Likewise.
* include/bits/basic_ios.h: Likewise.
* include/bits/stringfwd.h: Likewise.
* include/bits/ostream_insert.h: Likewise.
* include/bits/stl_heap.h: Likewise.
* include/bits/unordered_map.h: Likewise.
* include/bits/hashtable_policy.h: Likewise.
* include/bits/stl_iterator_base_funcs.h: Likewise.
* include/bits/valarray_before.h: Likewise.
* include/bits/regex.h: Likewise.
* include/bits/postypes.h: Likewise.
* include/bits/stl_iterator.h: Likewise.
* include/bits/localefwd.h: Likewise.
* include/bits/stl_algo.h: Likewise.
* include/bits/ios_base.h: Likewise.
* include/bits/stl_function.h: Likewise.
* include/bits/basic_string.h: Likewise.
* include/bits/hashtable.h: Likewise.
* include/bits/valarray_after.h: Likewise.
* include/bits/char_traits.h: Likewise.
* include/bits/gslice.h: Likewise.
* include/bits/locale_facets_nonio.h: Likewise.
* include/bits/mask_array.h: Likewise.
* include/bits/specfun.h: Likewise.
* include/bits/random.h: Likewise.
* include/bits/slice_array.h: Likewise.
* include/bits/valarray_array.h: Likewise.
* include/tr1/float.h: Likewise.
* include/tr1/functional_hash.h: Likewise.
* include/tr1/math.h: Likewise.
* include/tr1/hashtable_policy.h: Likewise.
* include/tr1/stdio.h: Likewise.
* include/tr1/complex.h: Likewise.
* include/tr1/stdbool.h: Likewise.
* include/tr1/stdarg.h: Likewise.
* include/tr1/inttypes.h: Likewise.
* include/tr1/fenv.h: Likewise.
* include/tr1/stdlib.h: Likewise.
* include/tr1/wchar.h: Likewise.
* include/tr1/tgmath.h: Likewise.
* include/tr1/limits.h: Likewise.
* include/tr1/wctype.h: Likewise.
* include/tr1/stdint.h: Likewise.
* include/tr1/ctype.h: Likewise.
* include/tr1/random.h: Likewise.
* include/tr1/shared_ptr.h: Likewise.
* include/ext/mt_allocator.h: Likewise.
* include/ext/sso_string_base.h: Likewise.
* include/ext/debug_allocator.h: Likewise.
* include/ext/vstring_fwd.h: Likewise.
* include/ext/pointer.h: Likewise.
* include/ext/pod_char_traits.h: Likewise.
* include/ext/malloc_allocator.h: Likewise.
* include/ext/vstring.h: Likewise.
* include/ext/bitmap_allocator.h: Likewise.
* include/ext/pool_allocator.h: Likewise.
* include/ext/type_traits.h: Likewise.
* include/ext/ropeimpl.h: Likewise.
* include/ext/codecvt_specializations.h: Likewise.
* include/ext/throw_allocator.h: Likewise.
* include/ext/extptr_allocator.h: Likewise.
* include/ext/atomicity.h: Likewise.
* include/ext/concurrence.h: Likewise.
* include/c_compatibility/wchar.h: Likewise.
* include/c_compatibility/stdint.h: Likewise.
* include/backward/hash_fun.h: Likewise.
* include/backward/binders.h: Likewise.
* include/backward/hashtable.h: Likewise.
* include/backward/auto_ptr.h: Likewise.
* libsupc++/eh_arm.cc: Likewise.
* libsupc++/unwind-cxx.h: Likewise.
* libsupc++/si_class_type_info.cc: Likewise.
* libsupc++/vec.cc: Likewise.
* libsupc++/class_type_info.cc: Likewise.
* libsupc++/vmi_class_type_info.cc: Likewise.
* libsupc++/guard_error.cc: Likewise.
* libsupc++/bad_typeid.cc: Likewise.
* libsupc++/eh_personality.cc: Likewise.
* libsupc++/atexit_arm.cc: Likewise.
* libsupc++/pmem_type_info.cc: Likewise.
* libsupc++/vterminate.cc: Likewise.
* libsupc++/eh_terminate.cc: Likewise.
* libsupc++/bad_cast.cc: Likewise.
* libsupc++/exception_ptr.h: Likewise.
* libsupc++/eh_throw.cc: Likewise.
* libsupc++/bad_alloc.cc: Likewise.
* libsupc++/nested_exception.cc: Likewise.
* libsupc++/pointer_type_info.cc: Likewise.
* libsupc++/pbase_type_info.cc: Likewise.
* libsupc++/bad_array_new.cc: Likewise.
* libsupc++/pure.cc: Likewise.
* libsupc++/eh_exception.cc: Likewise.
* libsupc++/bad_array_length.cc: Likewise.
* libsupc++/cxxabi.h: Likewise.
* libsupc++/guard.cc: Likewise.
* libsupc++/eh_catch.cc: Likewise.
* libsupc++/cxxabi_forced.h: Likewise.
* libsupc++/tinfo.h: Likewise.

9 months agogcc: Remove trailing whitespace
Jakub Jelinek [Fri, 25 Oct 2024 07:41:46 +0000 (09:41 +0200)] 
gcc: Remove trailing whitespace

I've tried to build stage3 with
-Wleading-whitespace=blanks -Wtrailing-whitespace=blank -Wno-error=leading-whitespace=blanks -Wno-error=trailing-whitespace=blank
added to STRICT_WARN and that expectably resulted in about
2744 unique trailing whitespace warnings and 124837 leading whitespace
warnings when excluding *.md files (which obviously is in big part a
generator issue).  Others from that are generator related, I think those
need to be solved later.

The following patch just fixes up the easy case (trailing whitespace),
which could be easily automated:
for i in `find . -name \*.h -o -name \*.cc -o -name \*.c | xargs grep -l '[  ]$' | grep -v testsuite/`; do sed -i -e 's/[  ]*$//' $i; done
I've excluded files which I knew are obviously generated or go FE.

Is there anything else we'd want to avoid the changes?

Due to patch size, I've split it between gcc/ part (this patch)
and rest (include/, libiberty/, libgcc/, libcpp/, libstdc++-v3/).

2024-10-24  Jakub Jelinek  <jakub@redhat.com>

gcc/
* lra-assigns.cc: Remove trailing whitespace.
* symtab.cc: Likewise.
* stmt.cc: Likewise.
* cgraphbuild.cc: Likewise.
* cfgcleanup.cc: Likewise.
* loop-init.cc: Likewise.
* df-problems.cc: Likewise.
* diagnostic-macro-unwinding.cc: Likewise.
* langhooks.h: Likewise.
* except.cc: Likewise.
* tree-vect-loop.cc: Likewise.
* coverage.cc: Likewise.
* hash-table.cc: Likewise.
* ggc-page.cc: Likewise.
* gimple-ssa-strength-reduction.cc: Likewise.
* tree-parloops.cc: Likewise.
* internal-fn.cc: Likewise.
* ipa-split.cc: Likewise.
* calls.cc: Likewise.
* reorg.cc: Likewise.
* sbitmap.h: Likewise.
* omp-offload.cc: Likewise.
* cfgrtl.cc: Likewise.
* reginfo.cc: Likewise.
* gengtype.h: Likewise.
* omp-general.h: Likewise.
* ipa-comdats.cc: Likewise.
* gimple-range-edge.h: Likewise.
* tree-ssa-structalias.cc: Likewise.
* target.def: Likewise.
* basic-block.h: Likewise.
* graphite-isl-ast-to-gimple.cc: Likewise.
* auto-profile.cc: Likewise.
* optabs.cc: Likewise.
* gengtype-lex.l: Likewise.
* optabs.def: Likewise.
* ira-build.cc: Likewise.
* ira.cc: Likewise.
* function.h: Likewise.
* tree-ssa-propagate.cc: Likewise.
* gcov-io.cc: Likewise.
* builtin-types.def: Likewise.
* ddg.cc: Likewise.
* lra-spills.cc: Likewise.
* cfg.cc: Likewise.
* bitmap.cc: Likewise.
* gimple-range-gori.h: Likewise.
* tree-ssa-loop-im.cc: Likewise.
* cfghooks.h: Likewise.
* genmatch.cc: Likewise.
* explow.cc: Likewise.
* lto-streamer-in.cc: Likewise.
* graphite-scop-detection.cc: Likewise.
* ipa-prop.cc: Likewise.
* gcc.cc: Likewise.
* vec.h: Likewise.
* cfgexpand.cc: Likewise.
* config/alpha/vms.h: Likewise.
* config/alpha/alpha.cc: Likewise.
* config/alpha/driver-alpha.cc: Likewise.
* config/alpha/elf.h: Likewise.
* config/iq2000/iq2000.h: Likewise.
* config/iq2000/iq2000.cc: Likewise.
* config/pa/pa-64.h: Likewise.
* config/pa/som.h: Likewise.
* config/pa/pa.cc: Likewise.
* config/pa/pa.h: Likewise.
* config/pa/pa32-regs.h: Likewise.
* config/c6x/c6x.cc: Likewise.
* config/openbsd-stdint.h: Likewise.
* config/elfos.h: Likewise.
* config/lm32/lm32.cc: Likewise.
* config/lm32/lm32.h: Likewise.
* config/lm32/lm32-protos.h: Likewise.
* config/darwin-c.cc: Likewise.
* config/rx/rx.cc: Likewise.
* config/host-darwin.h: Likewise.
* config/netbsd.h: Likewise.
* config/ia64/ia64.cc: Likewise.
* config/ia64/freebsd.h: Likewise.
* config/avr/avr-c.cc: Likewise.
* config/avr/avr.cc: Likewise.
* config/avr/avr-arch.h: Likewise.
* config/avr/avr.h: Likewise.
* config/avr/stdfix.h: Likewise.
* config/avr/gen-avr-mmcu-specs.cc: Likewise.
* config/avr/avr-log.cc: Likewise.
* config/avr/elf.h: Likewise.
* config/avr/gen-avr-mmcu-texi.cc: Likewise.
* config/avr/avr-devices.cc: Likewise.
* config/nvptx/nvptx.cc: Likewise.
* config/vx-common.h: Likewise.
* config/sol2.cc: Likewise.
* config/rl78/rl78.cc: Likewise.
* config/cris/cris.cc: Likewise.
* config/arm/symbian.h: Likewise.
* config/arm/unknown-elf.h: Likewise.
* config/arm/linux-eabi.h: Likewise.
* config/arm/arm.cc: Likewise.
* config/arm/arm-mve-builtins.h: Likewise.
* config/arm/bpabi.h: Likewise.
* config/arm/vxworks.h: Likewise.
* config/arm/arm.h: Likewise.
* config/arm/aout.h: Likewise.
* config/arm/elf.h: Likewise.
* config/host-linux.cc: Likewise.
* config/sh/sh_treg_combine.cc: Likewise.
* config/sh/vxworks.h: Likewise.
* config/sh/elf.h: Likewise.
* config/sh/netbsd-elf.h: Likewise.
* config/sh/sh.cc: Likewise.
* config/sh/embed-elf.h: Likewise.
* config/sh/sh.h: Likewise.
* config/darwin-driver.cc: Likewise.
* config/m32c/m32c.cc: Likewise.
* config/frv/frv.cc: Likewise.
* config/openbsd.h: Likewise.
* config/aarch64/aarch64-protos.h: Likewise.
* config/aarch64/aarch64-builtins.cc: Likewise.
* config/aarch64/aarch64-cost-tables.h: Likewise.
* config/aarch64/aarch64.cc: Likewise.
* config/bfin/bfin.cc: Likewise.
* config/bfin/bfin.h: Likewise.
* config/bfin/bfin-protos.h: Likewise.
* config/i386/gmm_malloc.h: Likewise.
* config/i386/djgpp.h: Likewise.
* config/i386/sol2.h: Likewise.
* config/i386/stringop.def: Likewise.
* config/i386/i386-features.cc: Likewise.
* config/i386/openbsdelf.h: Likewise.
* config/i386/cpuid.h: Likewise.
* config/i386/i386.h: Likewise.
* config/i386/smmintrin.h: Likewise.
* config/i386/avx10_2-512convertintrin.h: Likewise.
* config/i386/i386-options.cc: Likewise.
* config/i386/i386-opts.h: Likewise.
* config/i386/i386-expand.cc: Likewise.
* config/i386/avx512dqintrin.h: Likewise.
* config/i386/wmmintrin.h: Likewise.
* config/i386/gnu-user.h: Likewise.
* config/i386/host-mingw32.cc: Likewise.
* config/i386/avx10_2bf16intrin.h: Likewise.
* config/i386/cygwin.h: Likewise.
* config/i386/driver-i386.cc: Likewise.
* config/i386/biarch64.h: Likewise.
* config/i386/host-cygwin.cc: Likewise.
* config/i386/cygming.h: Likewise.
* config/i386/i386-builtins.cc: Likewise.
* config/i386/avx10_2convertintrin.h: Likewise.
* config/i386/i386.cc: Likewise.
* config/i386/gas.h: Likewise.
* config/i386/freebsd.h: Likewise.
* config/mingw/winnt-cxx.cc: Likewise.
* config/mingw/winnt.cc: Likewise.
* config/h8300/h8300.cc: Likewise.
* config/host-solaris.cc: Likewise.
* config/m32r/m32r.h: Likewise.
* config/m32r/m32r.cc: Likewise.
* config/darwin.h: Likewise.
* config/sparc/linux64.h: Likewise.
* config/sparc/sparc-protos.h: Likewise.
* config/sparc/sysv4.h: Likewise.
* config/sparc/sparc.h: Likewise.
* config/sparc/linux.h: Likewise.
* config/sparc/freebsd.h: Likewise.
* config/sparc/sparc.cc: Likewise.
* config/gcn/gcn-run.cc: Likewise.
* config/gcn/gcn.cc: Likewise.
* config/gcn/gcn-tree.cc: Likewise.
* config/kopensolaris-gnu.h: Likewise.
* config/nios2/nios2.h: Likewise.
* config/nios2/elf.h: Likewise.
* config/nios2/nios2.cc: Likewise.
* config/host-netbsd.cc: Likewise.
* config/rtems.h: Likewise.
* config/pdp11/pdp11.cc: Likewise.
* config/pdp11/pdp11.h: Likewise.
* config/mn10300/mn10300.cc: Likewise.
* config/mn10300/linux.h: Likewise.
* config/moxie/moxie.h: Likewise.
* config/moxie/moxie.cc: Likewise.
* config/rs6000/aix71.h: Likewise.
* config/rs6000/vec_types.h: Likewise.
* config/rs6000/xcoff.h: Likewise.
* config/rs6000/rs6000.cc: Likewise.
* config/rs6000/rs6000-internal.h: Likewise.
* config/rs6000/rs6000-p8swap.cc: Likewise.
* config/rs6000/rs6000-c.cc: Likewise.
* config/rs6000/aix.h: Likewise.
* config/rs6000/rs6000-logue.cc: Likewise.
* config/rs6000/rs6000-string.cc: Likewise.
* config/rs6000/rs6000-call.cc: Likewise.
* config/rs6000/ppu_intrinsics.h: Likewise.
* config/rs6000/altivec.h: Likewise.
* config/rs6000/darwin.h: Likewise.
* config/rs6000/host-darwin.cc: Likewise.
* config/rs6000/freebsd64.h: Likewise.
* config/rs6000/spu2vmx.h: Likewise.
* config/rs6000/linux.h: Likewise.
* config/rs6000/si2vmx.h: Likewise.
* config/rs6000/driver-rs6000.cc: Likewise.
* config/rs6000/freebsd.h: Likewise.
* config/vxworksae.h: Likewise.
* config/mips/frame-header-opt.cc: Likewise.
* config/mips/mips.h: Likewise.
* config/mips/mips.cc: Likewise.
* config/mips/sde.h: Likewise.
* config/darwin-protos.h: Likewise.
* config/mcore/mcore-elf.h: Likewise.
* config/mcore/mcore.h: Likewise.
* config/mcore/mcore.cc: Likewise.
* config/epiphany/epiphany.cc: Likewise.
* config/fr30/fr30.h: Likewise.
* config/fr30/fr30.cc: Likewise.
* config/riscv/riscv-vector-builtins-shapes.cc: Likewise.
* config/riscv/riscv-vector-builtins-bases.cc: Likewise.
* config/visium/visium.h: Likewise.
* config/mmix/mmix.cc: Likewise.
* config/v850/v850.cc: Likewise.
* config/v850/v850-c.cc: Likewise.
* config/v850/v850.h: Likewise.
* config/stormy16/stormy16.cc: Likewise.
* config/stormy16/stormy16-protos.h: Likewise.
* config/stormy16/stormy16.h: Likewise.
* config/arc/arc.cc: Likewise.
* config/vxworks.cc: Likewise.
* config/microblaze/microblaze-c.cc: Likewise.
* config/microblaze/microblaze-protos.h: Likewise.
* config/microblaze/microblaze.h: Likewise.
* config/microblaze/microblaze.cc: Likewise.
* config/freebsd-spec.h: Likewise.
* config/m68k/m68kelf.h: Likewise.
* config/m68k/m68k.cc: Likewise.
* config/m68k/netbsd-elf.h: Likewise.
* config/m68k/linux.h: Likewise.
* config/freebsd.h: Likewise.
* config/host-openbsd.cc: Likewise.
* regcprop.cc: Likewise.
* dumpfile.cc: Likewise.
* combine.cc: Likewise.
* tree-ssa-forwprop.cc: Likewise.
* ipa-profile.cc: Likewise.
* hw-doloop.cc: Likewise.
* opts.cc: Likewise.
* gcc-ar.cc: Likewise.
* tree-cfg.cc: Likewise.
* incpath.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.
* function.cc: Likewise.
* genattrtab.cc: Likewise.
* rtl.def: Likewise.
* genchecksum.cc: Likewise.
* profile.cc: Likewise.
* df-core.cc: Likewise.
* tree-pretty-print.cc: Likewise.
* tree.h: Likewise.
* plugin.cc: Likewise.
* tree-ssa-loop-ch.cc: Likewise.
* emit-rtl.cc: Likewise.
* haifa-sched.cc: Likewise.
* gimple-range-edge.cc: Likewise.
* range-op.cc: Likewise.
* tree-ssa-ccp.cc: Likewise.
* dwarf2cfi.cc: Likewise.
* recog.cc: Likewise.
* vtable-verify.cc: Likewise.
* system.h: Likewise.
* regrename.cc: Likewise.
* tree-ssa-dom.cc: Likewise.
* loop-unroll.cc: Likewise.
* lra-constraints.cc: Likewise.
* pretty-print.cc: Likewise.
* ifcvt.cc: Likewise.
* ipa.cc: Likewise.
* alloc-pool.h: Likewise.
* collect2.cc: Likewise.
* pointer-query.cc: Likewise.
* cfgloop.cc: Likewise.
* toplev.cc: Likewise.
* sese.cc: Likewise.
* gengtype.cc: Likewise.
* gimplify-me.cc: Likewise.
* double-int.cc: Likewise.
* bb-reorder.cc: Likewise.
* dwarf2out.cc: Likewise.
* tree-ssa-loop-ivcanon.cc: Likewise.
* tree-ssa-reassoc.cc: Likewise.
* cgraph.cc: Likewise.
* sel-sched.cc: Likewise.
* attribs.cc: Likewise.
* expr.cc: Likewise.
* tree-ssa-scopedtables.h: Likewise.
* gimple-range-cache.cc: Likewise.
* ipa-pure-const.cc: Likewise.
* tree-inline.cc: Likewise.
* genhooks.cc: Likewise.
* gimple-range-phi.h: Likewise.
* shrink-wrap.cc: Likewise.
* tree.cc: Likewise.
* gimple.cc: Likewise.
* backend.h: Likewise.
* opts-common.cc: Likewise.
* cfg-flags.def: Likewise.
* gcse-common.cc: Likewise.
* tree-ssa-scopedtables.cc: Likewise.
* ccmp.cc: Likewise.
* builtins.def: Likewise.
* builtin-attrs.def: Likewise.
* postreload.cc: Likewise.
* sched-deps.cc: Likewise.
* ipa-inline-transform.cc: Likewise.
* tree-vect-generic.cc: Likewise.
* ipa-polymorphic-call.cc: Likewise.
* builtins.cc: Likewise.
* sel-sched-ir.cc: Likewise.
* trans-mem.cc: Likewise.
* ipa-visibility.cc: Likewise.
* cgraph.h: Likewise.
* tree-ssa-phiopt.cc: Likewise.
* genopinit.cc: Likewise.
* ipa-inline.cc: Likewise.
* omp-low.cc: Likewise.
* ipa-utils.cc: Likewise.
* tree-ssa-math-opts.cc: Likewise.
* tree-ssa-ifcombine.cc: Likewise.
* gimple-range.cc: Likewise.
* ipa-fnsummary.cc: Likewise.
* ira-color.cc: Likewise.
* value-prof.cc: Likewise.
* varasm.cc: Likewise.
* ipa-icf.cc: Likewise.
* ira-emit.cc: Likewise.
* lto-streamer.h: Likewise.
* lto-wrapper.cc: Likewise.
* regs.h: Likewise.
* gengtype-parse.cc: Likewise.
* alias.cc: Likewise.
* lto-streamer.cc: Likewise.
* real.h: Likewise.
* wide-int.h: Likewise.
* targhooks.cc: Likewise.
* gimple-ssa-warn-access.cc: Likewise.
* real.cc: Likewise.
* ipa-reference.cc: Likewise.
* bitmap.h: Likewise.
* ginclude/float.h: Likewise.
* ginclude/stddef.h: Likewise.
* ginclude/stdarg.h: Likewise.
* ginclude/stdatomic.h: Likewise.
* optabs.h: Likewise.
* sel-sched-ir.h: Likewise.
* convert.cc: Likewise.
* cgraphunit.cc: Likewise.
* lra-remat.cc: Likewise.
* tree-if-conv.cc: Likewise.
* gcov-dump.cc: Likewise.
* tree-predcom.cc: Likewise.
* dominance.cc: Likewise.
* gimple-range-cache.h: Likewise.
* ipa-devirt.cc: Likewise.
* rtl.h: Likewise.
* ubsan.cc: Likewise.
* tree-ssa.cc: Likewise.
* ssa.h: Likewise.
* cse.cc: Likewise.
* jump.cc: Likewise.
* hwint.h: Likewise.
* caller-save.cc: Likewise.
* coretypes.h: Likewise.
* ipa-fnsummary.h: Likewise.
* tree-ssa-strlen.cc: Likewise.
* modulo-sched.cc: Likewise.
* cgraphclones.cc: Likewise.
* lto-cgraph.cc: Likewise.
* hw-doloop.h: Likewise.
* data-streamer.h: Likewise.
* compare-elim.cc: Likewise.
* profile-count.h: Likewise.
* tree-vect-loop-manip.cc: Likewise.
* ree.cc: Likewise.
* reload.cc: Likewise.
* tree-ssa-loop-split.cc: Likewise.
* tree-into-ssa.cc: Likewise.
* gcse.cc: Likewise.
* cfgloopmanip.cc: Likewise.
* df.h: Likewise.
* fold-const.cc: Likewise.
* wide-int.cc: Likewise.
* gengtype-state.cc: Likewise.
* sanitizer.def: Likewise.
* tree-ssa-sink.cc: Likewise.
* target-hooks-macros.h: Likewise.
* tree-ssa-pre.cc: Likewise.
* gimple-pretty-print.cc: Likewise.
* ipa-utils.h: Likewise.
* tree-outof-ssa.cc: Likewise.
* tree-ssa-coalesce.cc: Likewise.
* gimple-match.h: Likewise.
* tree-ssa-loop-niter.cc: Likewise.
* tree-loop-distribution.cc: Likewise.
* tree-emutls.cc: Likewise.
* tree-eh.cc: Likewise.
* varpool.cc: Likewise.
* ssa-iterators.h: Likewise.
* asan.cc: Likewise.
* reload1.cc: Likewise.
* cfgloopanal.cc: Likewise.
* tree-vectorizer.cc: Likewise.
* simplify-rtx.cc: Likewise.
* opts-global.cc: Likewise.
* gimple-ssa-store-merging.cc: Likewise.
* expmed.cc: Likewise.
* tree-ssa-loop-prefetch.cc: Likewise.
* tree-ssa-dse.h: Likewise.
* tree-vect-stmts.cc: Likewise.
* gimple-fold.cc: Likewise.
* lra-coalesce.cc: Likewise.
* data-streamer-out.cc: Likewise.
* diagnostic.cc: Likewise.
* tree-ssa-alias.cc: Likewise.
* tree-vect-patterns.cc: Likewise.
* common/common-target.def: Likewise.
* common/config/rx/rx-common.cc: Likewise.
* common/config/msp430/msp430-common.cc: Likewise.
* common/config/avr/avr-common.cc: Likewise.
* common/config/i386/i386-common.cc: Likewise.
* common/config/pdp11/pdp11-common.cc: Likewise.
* common/config/rs6000/rs6000-common.cc: Likewise.
* common/config/mcore/mcore-common.cc: Likewise.
* graphite.cc: Likewise.
* gimple-low.cc: Likewise.
* genmodes.cc: Likewise.
* gimple-loop-jam.cc: Likewise.
* lto-streamer-out.cc: Likewise.
* predict.cc: Likewise.
* omp-expand.cc: Likewise.
* gimple-array-bounds.cc: Likewise.
* predict.def: Likewise.
* opts.h: Likewise.
* tree-stdarg.cc: Likewise.
* gimplify.cc: Likewise.
* ira-lives.cc: Likewise.
* loop-doloop.cc: Likewise.
* lra.cc: Likewise.
* gimple-iterator.h: Likewise.
* tree-sra.cc: Likewise.
gcc/fortran/
* trans-openmp.cc: Remove trailing whitespace.
* trans-common.cc: Likewise.
* match.h: Likewise.
* scanner.cc: Likewise.
* gfortranspec.cc: Likewise.
* io.cc: Likewise.
* iso-c-binding.def: Likewise.
* iso-fortran-env.def: Likewise.
* types.def: Likewise.
* openmp.cc: Likewise.
* f95-lang.cc: Likewise.
gcc/analyzer/
* state-purge.cc: Remove trailing whitespace.
* region-model.h: Likewise.
* region-model.cc: Likewise.
* program-point.cc: Likewise.
* exploded-graph.h: Likewise.
* program-state.cc: Likewise.
* supergraph.cc: Likewise.
gcc/c-family/
* c-ubsan.cc: Remove trailing whitespace.
* stub-objc.cc: Likewise.
* c-pragma.cc: Likewise.
* c-ppoutput.cc: Likewise.
* c-indentation.cc: Likewise.
* c-ada-spec.cc: Likewise.
* c-opts.cc: Likewise.
* c-common.cc: Likewise.
* c-format.cc: Likewise.
* c-omp.cc: Likewise.
* c-objc.h: Likewise.
* c-cppbuiltin.cc: Likewise.
* c-attribs.cc: Likewise.
* c-target.def: Likewise.
* c-common.h: Likewise.
gcc/c/
* c-typeck.cc: Remove trailing whitespace.
* gimple-parser.cc: Likewise.
* c-parser.cc: Likewise.
* c-decl.cc: Likewise.
gcc/cp/
* vtable-class-hierarchy.cc: Remove trailing whitespace.
* typeck2.cc: Likewise.
* decl.cc: Likewise.
* init.cc: Likewise.
* semantics.cc: Likewise.
* module.cc: Likewise.
* rtti.cc: Likewise.
* cxx-pretty-print.cc: Likewise.
* cvt.cc: Likewise.
* mangle.cc: Likewise.
* name-lookup.h: Likewise.
* coroutines.cc: Likewise.
* error.cc: Likewise.
* lambda.cc: Likewise.
* tree.cc: Likewise.
* g++spec.cc: Likewise.
* decl2.cc: Likewise.
* cp-tree.h: Likewise.
* parser.cc: Likewise.
* pt.cc: Likewise.
* call.cc: Likewise.
* lex.cc: Likewise.
* cp-lang.cc: Likewise.
* cp-tree.def: Likewise.
* constexpr.cc: Likewise.
* typeck.cc: Likewise.
* name-lookup.cc: Likewise.
* optimize.cc: Likewise.
* search.cc: Likewise.
* mapper-client.cc: Likewise.
* ptree.cc: Likewise.
* class.cc: Likewise.
gcc/jit/
* docs/examples/tut04-toyvm/toyvm.cc: Remove trailing whitespace.
gcc/lto/
* lto-object.cc: Remove trailing whitespace.
* lto-symtab.cc: Likewise.
* lto-partition.cc: Likewise.
* lang-specs.h: Likewise.
* lto-lang.cc: Likewise.
gcc/objc/
* objc-encoding.cc: Remove trailing whitespace.
* objc-map.h: Likewise.
* objc-next-runtime-abi-01.cc: Likewise.
* objc-act.cc: Likewise.
* objc-map.cc: Likewise.
gcc/objcp/
* objcp-decl.cc: Remove trailing whitespace.
* objcp-lang.cc: Likewise.
* objcp-decl.h: Likewise.
gcc/rust/
* util/optional.h: Remove trailing whitespace.
* util/expected.h: Likewise.
* util/rust-unicode-data.h: Likewise.
gcc/m2/
* mc-boot/GFpuIO.cc: Remove trailing whitespace.
* mc-boot/GFIO.cc: Likewise.
* mc-boot/GFormatStrings.cc: Likewise.
* mc-boot/GCmdArgs.cc: Likewise.
* mc-boot/GDebug.h: Likewise.
* mc-boot/GM2Dependent.cc: Likewise.
* mc-boot/GRTint.cc: Likewise.
* mc-boot/GDebug.cc: Likewise.
* mc-boot/GmcError.cc: Likewise.
* mc-boot/Gmcp4.cc: Likewise.
* mc-boot/GM2RTS.cc: Likewise.
* mc-boot/GIO.cc: Likewise.
* mc-boot/Gmcp5.cc: Likewise.
* mc-boot/GDynamicStrings.cc: Likewise.
* mc-boot/Gmcp1.cc: Likewise.
* mc-boot/GFormatStrings.h: Likewise.
* mc-boot/Gmcp2.cc: Likewise.
* mc-boot/Gmcp3.cc: Likewise.
* pge-boot/GFIO.cc: Likewise.
* pge-boot/GDebug.h: Likewise.
* pge-boot/GM2Dependent.cc: Likewise.
* pge-boot/GDebug.cc: Likewise.
* pge-boot/GM2RTS.cc: Likewise.
* pge-boot/GSymbolKey.cc: Likewise.
* pge-boot/GIO.cc: Likewise.
* pge-boot/GIndexing.cc: Likewise.
* pge-boot/GDynamicStrings.cc: Likewise.
* pge-boot/GFormatStrings.h: Likewise.
gcc/go/
* go-gcc.cc: Remove trailing whitespace.
* gospec.cc: Likewise.

9 months agoSVE intrinsics: Fold svaba with op1 all zeros to svabd.
Jennifer Schmitz [Thu, 24 Oct 2024 12:11:31 +0000 (05:11 -0700)] 
SVE intrinsics: Fold svaba with op1 all zeros to svabd.

Similar to
https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665780.html,
this patch implements folding of svaba to svabd if op1 is all zeros,
resulting in the use of UABD/SABD instructions instead of UABA/SABA.
Tests were added to check the produced assembly for use of UABD/SABD,
also for the _n case.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
* config/aarch64/aarch64-sve-builtins-sve2.cc
(svaba_impl::fold): Fold svaba to svabd if op1 is all zeros.

gcc/testsuite/
* gcc.target/aarch64/sve2/acle/asm/aba_s32.c: New tests.
* gcc.target/aarch64/sve2/acle/asm/aba_s64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/aba_u32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/aba_u64.c: Likewise.

9 months agoc++/modules: Propagate some missing flags on type definitions
Nathaniel Shead [Thu, 24 Oct 2024 07:10:52 +0000 (18:10 +1100)] 
c++/modules: Propagate some missing flags on type definitions

Noticed while testing my fix for PR c++/113814.  Not all of these are
easily testable but I've tested a couple that were straight-forward.

For consistency also adds a new TYPE_WARN_IF_NOT_ALIGN_RAW flag to match
the decl version Nathan added.

gcc/cp/ChangeLog:

* module.cc (trees_in::read_class_def): Propagate some missing
flags from the streamed-in definition.

gcc/ChangeLog:

* tree.h (TYPE_WARN_IF_NOT_ALIGN_RAW): New accessor.
(TYPE_WARN_IF_NOT_ALIGN): Use it.
(SET_TYPE_WARN_IF_NOT_ALIGN): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/class-10_a.H: New test.
* g++.dg/modules/class-10_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
9 months agoc++/modules: Support decloned cdtors
Nathaniel Shead [Tue, 20 Aug 2024 15:08:36 +0000 (01:08 +1000)] 
c++/modules: Support decloned cdtors

When compiling with '-fdeclone-ctor-dtor' (enabled by default with -Os),
we run into issues where we don't correctly emit the underlying
functions.  We also need to ensure that COMDAT constructors are marked
as such before 'maybe_clone_body' attempts to propagate COMDAT groups to
the new thunks.

gcc/cp/ChangeLog:

* module.cc (post_load_processing): Mark COMDAT as needed, emit
declarations if maybe_clone_body fails.

gcc/testsuite/ChangeLog:

* g++.dg/modules/clone-2_a.C: New test.
* g++.dg/modules/clone-2_b.C: New test.
* g++.dg/modules/clone-3_a.C: New test.
* g++.dg/modules/clone-3_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
9 months agoc++/modules: Prevent maybe_clone_decl being called multiple times [PR115007]
Nathaniel Shead [Tue, 20 Aug 2024 14:50:53 +0000 (00:50 +1000)] 
c++/modules: Prevent maybe_clone_decl being called multiple times [PR115007]

The ICE in the linked PR is caused because maybe_clone_decl is not
prepared to be called on a declaration that has already had clones
created; what happens otherwise is that start_preparsed_function early
exits and never sets up cfun, causing a segfault later on.

To fix this we ensure that post_load_processing only calls
maybe_clone_decl if TREE_ASM_WRITTEN has not been marked on the
declaration yet, and (if maybe_clone_decls succeeds) marks this flag on
the decl so that it doesn't get called again later when finalising
deferred vague linkage declarations in c_parse_final_cleanups.

As a bonus this now allows us to only keep the DECL_SAVED_TREE around in
expand_or_defer_fn_1 for modules which have CMIs, which will have
benefits for LTO performance in non-interface TUs.

For clarity we also update the streaming code to do post_load_decls for
maybe in-charge cdtors rather than any DECL_ABSTRACT_P declaration, as
this is more accurate to the decls affected by maybe_clone_body.

PR c++/115007

gcc/cp/ChangeLog:

* module.cc (module_state::read_cluster): Replace
DECL_ABSTRACT_P with DECL_MAYBE_IN_CHARGE_CDTOR_P.
(post_load_processing): Check and mark TREE_ASM_WRITTEN.
* semantics.cc (expand_or_defer_fn_1): Use the more specific
module_maybe_has_cmi_p instead of modules_p.

gcc/testsuite/ChangeLog:

* g++.dg/modules/virt-6_a.C: New test.
* g++.dg/modules/virt-6_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
9 months agoc++: Handle ABI for non-polymorphic dynamic classes
Nathaniel Shead [Tue, 20 Aug 2024 14:42:42 +0000 (00:42 +1000)] 
c++: Handle ABI for non-polymorphic dynamic classes

The Itanium ABI has specific rules for when virtual tables for dynamic
classes should be emitted.  However we didn't consider structures with
virtual inheritance but no virtual members as dynamic classes for ABI
purposes; this patch fixes this.

gcc/cp/ChangeLog:

* decl2.cc (import_export_class): Use TYPE_CONTAINS_VPTR_P
instead of TYPE_POLYMORPHIC_P.
(import_export_decl): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/virt-5_a.C: New test.
* g++.dg/modules/virt-5_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
9 months agoAVR: target/116953 - Restore recog_data after calling jump_over_one_insn_p.
Georg-Johann Lay [Tue, 22 Oct 2024 09:51:44 +0000 (11:51 +0200)] 
AVR: target/116953 - Restore recog_data after calling jump_over_one_insn_p.

The previous fix for PR116953 is incomplete because references to
recog_data are escaping avr_out_sbxx_branch() in the form of %-operands
in the returned asm code template.  This patch reverts the previous fix,
and re-extracts the operands by means of extract_constrain_insn_cached()
after the call of jump_over_one_insn_p().

PR target/116953
gcc/
* config/avr/avr.cc (avr_out_sbxx_branch): Revert previous fix
for PR116953 (r15-4078).  Run extract_constrain_insn_cached
on the current insn after calling jump_over_one_insn_p.

9 months agoanalyzer: avoid implicit use of global_dc's pretty_printer [PR116613]
David Malcolm [Thu, 24 Oct 2024 19:52:29 +0000 (15:52 -0400)] 
analyzer: avoid implicit use of global_dc's pretty_printer [PR116613]

Previously, various places in the analyzer generated message strings
by cloning the diagnostic_context's pretty_printer, printing to that
pretty_printer's buffer, and then returning a copy of the buffer
contents.

This implicit use of a particular pretty printer doesn't work well for
the "multiple diagnostic output formats" case (PR other/116613), such as
differences in colorization, or in how phase 3 of formatting works.
Hence as enabling work towards that, the following patch reworks the
various functions returning a label_text string in favor of functions
that print to a specific pretty_printer, such as diagnotic_event's
"get_desc" vfunc, which becomes "print_desc".  This makes the particular
pretty_printer in use explicit in each case.

Previously, the various pending_diagnostic::describe_* vfuncs returned a
label_text, with the return of an empty string signifying that no
description could be generated.  With this patch, these vfuncs gain a
"pretty_printer &" param and a bool return value and now either print to
the pretty_printer and return true, or return false to signify the
"no description available" case.

No functional change intended.

gcc/analyzer/ChangeLog:
PR other/116613
* bounds-checking.cc
(concrete_buffer_overflow::describe_final_event): Convert return
type from label_text to bool.  Add "pp" param and either print to
it and return true, or return false.
(concrete_buffer_overflow::describe_final_event_as_bytes): Convert
to print to a pp rather than returning a label_text.
(concrete_buffer_overflow::describe_final_event_as_bits):
Likewise.
(class concrete_buffer_over_read): Analogous changes to above.
(class concrete_buffer_underwrite): Likewise.
(class concrete_buffer_under_read): Likewise.
(class symbolic_buffer_overflow): Likewise.
(class symbolic_buffer_over_read): Likewise.
* call-details.cc (class overlapping_buffers): Likewise.
* call-info.cc (call_info::print): Reimplement.
(class call_info::add_events_to_path::call_event): Convert
"get_desc" vfunc to "print_desc", dropping return type, adding
"pp" param, and printing to it.
(class succeed_or_fail_call_info): Likewise.
* call-info.h (class call_info): Likewise.
(class succeed_or_fail_call_info): Likewise.
* checker-event.cc (checker_event::dump): Reimplement.
(checker_event::prepare_for_emission): Update for change from
get_desc to print_desc.
(debug_event::get_desc): Convert to...
(debug_event::print_desc): ...this.
(precanned_custom_event::get_desc): Convert to...
(precanned_custom_event::print_desc): ...this.
(statement_event::get_desc): Convert to...
(statement_event::print_desc): ...this.
(region_creation_event_memory_space::get_desc): Convert to...
(region_creation_event_memory_space::print_desc): ...this.
(region_creation_event_capacity::get_desc): Convert to...
(region_creation_event_capacity::print_desc): ...this.
(region_creation_event_allocation_size::get_desc): Convert to...
(region_creation_event_allocation_size::print_desc): ...this.
(region_creation_event_debug::get_desc): Convert to...
(region_creation_event_debug::print_desc): ...this.
(function_entry_event::get_desc): Convert to...
(function_entry_event::print_desc): ...this.
(state_change_event::get_desc): Convert to...
(state_change_event::print_desc): ...this.
(state_change_event::get_meaning): Update for change to
pending_diagnostic::get_meaning_for_state_change.
(superedge_event::should_filter_p): Convert from usage of get_desc
to print_desc.
(start_cfg_edge_event::get_desc): Convert to...
(start_cfg_edge_event::print_desc): ...this.
(call_event::get_desc): Convert to...
(call_event::print_desc): ...this.
(return_event::get_desc): Convert to...
(return_event::print_desc): ...this.
(start_consolidated_cfg_edges_event::get_desc): Convert to...
(start_consolidated_cfg_edges_event::print_desc): ...this.
(inlined_call_event::get_desc): Convert to...
(inlined_call_event::print_desc): ...this.
(setjmp_event::get_desc): Convert to...
(setjmp_event::print_desc): ...this.
(rewind_from_longjmp_event::get_desc): Convert to...
(rewind_from_longjmp_event::print_desc): ...this.
(rewind_to_setjmp_event::get_desc): Convert to...
(rewind_to_setjmp_event::print_desc): ...this.
(warning_event::get_desc): Convert to...
(warning_event::print_desc): ...this.
* checker-event.h: Convert the various "get_desc" vfunc decls to
"print_desc".
* checker-path.cc (checker_path::dump): Convert to usage of
checker_event::print_desc.
(checker_path::debug): Convert to debug form of
checker_event::get_desc.
* diagnostic-manager.cc
(diagnostic_manager::prune_interproc_events): Likewise.
(diagnostic_manager::prune_system_headers): Likewise.
* engine.cc (call_summary_edge_info::get_desc): Convert to...
(call_summary_edge_info::print_desc): ...this.
(stale_jmp_buf::describe_final_event): Update for change to
this vfunc.
(tainted_args_function_custom_event::get_desc): Convert to...
(tainted_args_function_custom_event::print_desc): ...this.
(tainted_args_field_custom_event::get_desc): Convert to...
(tainted_args_field_custom_event::print_desc): ...this.
(tainted_args_callback_custom_event::get_desc): Convert to...
(tainted_args_callback_custom_event::print_desc): ...this.
(jump_through_null::describe_final_event): Update for change to
this vfunc.
* infinite-loop.cc (perpetual_start_cfg_edge_event::get_desc):
Convert to...
(perpetual_start_cfg_edge_event::print_desc): ...this.
(looping_back_event::get_desc): Convert to...
(looping_back_event::print_desc): ...this.
(looping_back_event::describe_final_event): Update for change to
this vfunc.
* infinite-recursion.cc (class infinite_recursion_diagnostic):
Update for changes to pending_diagnostic.
* kf.cc (class putenv_of_auto_var): Likewise.
(kf_realloc::impl_call_post): Update for changes to call_info.
(kf_strchr::impl_call_post): Likewise.
(kf_strncpy::impl_call_post): Likewise.
(kf_strstr::impl_call_post): Likewise.
(class kf_strtok::undefined_behavior): Update for changes to
pending_diagnostic.
(class strtok_call_info): Update for changes to call_info.
* pending-diagnostic.cc (evdesc::event_desc::formatted_print):
Delete.
* pending-diagnostic.h (struct event_desc): Delete.
(struct state_change): Drop event_desc base class.
(struct call_with_state): Likewise.
(struct return_of_state): Likewise.
(struct final_event): Likewise.
(pending_event::describe_state_change): Convert return
type from label_text to bool.  Add "pp" param and either print to
it and return true, or return false.  Do the latter for the base
class implementation.
(pending_event::describe_call_with_state): Likewise.
(pending_event::describe_return_of_state): Likewise.
(pending_event::describe_final_event): Likewise.
* region-model.cc
(poisoned_value_diagnostic::describe_final_event): Update for
change to this vfunc.
(shift_count_negative_diagnostic::describe_final_event): Likewise.
(shift_count_overflow_diagnostic::describe_final_event): Likewise.
(ptrdiff_region_creation_event::get_desc): Convert to...
(ptrdiff_region_creation_event::print_desc): ...this.
(undefined_ptrdiff_diagnostic::describe_final_event): Update for
change to this vfunc.
(write_to_const_diagnostic::describe_final_event): Likewise.
(write_to_string_literal_diagnostic::describe_final_event):
Likewise.
(dubious_allocation_size::describe_final_event): Likewise.
(null_terminator_check_event::get_desc): Convert to...
(null_terminator_check_event::print_desc): ...this.
(float_as_size_arg::describe_final_event): Update for change to
this vfunc.
(exposure_through_uninit_copy::describe_final_event): Likewise.
* sm-fd.cc: Include "diagnostic-core.h".  Update throughout for
changes to pending_diagnostic vfuncs.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* varargs.cc: Likewise.

gcc/ChangeLog:
PR other/116613
* diagnostic-format-json.cc (make_json_for_path): Add "ref_pp"
param and use when obtaining event descriptions.
(json_output_format::on_report_diagnostic): Pass this format's
printer as the above.
* diagnostic-format-sarif.cc
(sarif_builder::make_location_object): Clone this format's printer
and use it to obtain the text of the message.
* diagnostic-path.cc: Include "pretty-print-markup.h".
(diagnostic_event::get_desc): New.
(path_label::get_text): Update for changes to diagnostic_event.
(event_range::print): Likewise.
(class element_event_desc): New.
(diagnostic_text_output_format::print_path): Update for changes to
diagnostic_event.
* diagnostic-path.h (diagnostic_event::get_desc): Replace with...
(diagnostic_event::print_desc): ...this.
(diagnostic_event::get_desc): Add this back for debugging, without
the bool param.
* pretty-print.cc (pp_printf_n): New.
* pretty-print.h (pp_printf_n): New decl.
* selftest-diagnostic-path.h (test_diagnostic_event::get_desc):
Convert to...
(test_diagnostic_event::print_desc): ...this.
* simple-diagnostic-path.cc (simple_diagnostic_event::print_desc):
New.
(selftest::test_intraprocedural_path): Use debug form of get_desc.
* simple-diagnostic-path.h (simple_diagnostic_event::get_desc):
Convert to...
(simple_diagnostic_event::print_desc): ...this, moving
implementation to test_diagnostic_event.

gcc/testsuite/ChangeLog:
PR other/116613
* gcc.dg/plugin/analyzer_cpython_plugin.c: Convert call outcomes
from "get_desc" to print_desc".
* gcc.dg/plugin/analyzer_gil_plugin.c: Update for changes to
pending_diagnostic vfuncs.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months agotestsuite: Use -fno-ipa-icf in gcc.dg/stack-check-2.c
Joseph Myers [Thu, 24 Oct 2024 19:41:26 +0000 (19:41 +0000)] 
testsuite: Use -fno-ipa-icf in gcc.dg/stack-check-2.c

One test failing with a -std=gnu23 default that I wanted to
investigate further is gcc.dg/stack-check-2.c.  The failures are

FAIL: gcc.dg/stack-check-2.c scan-tree-dump-not optimized "tail call"
FAIL: gcc.dg/stack-check-2.c scan-tree-dump-not tailc "tail call"

but it turns out the tail calls in question are not the ones that test
is actually checking for.  Rather, when () is interpreted as (void) in
C23 mode, ICF notices that certain functions are identical and so
turns test_indirect_2 into a tail call to text_indirect_1 and
test_indirect_casted_2 into a tail call to test_indirect_casted_1
(which it didn't do previously when one function used () and one used
(void)).

To avoid these spurious failures, make the test use -fno-ipa-icf
rather than relying on () and (void) giving different function types
to avoid ICF.

Tested for x86_64-pc-linux-gnu.

* gcc.dg/stack-check-2.c: Use -fno-ipa-icf.

9 months agoUse unique_ptr in more places in pretty_printer/diagnostics: 'gcc/config/gcn/mkoffloa...
Thomas Schwinge [Thu, 24 Oct 2024 18:56:21 +0000 (20:56 +0200)] 
Use unique_ptr in more places in pretty_printer/diagnostics: 'gcc/config/gcn/mkoffload.cc' [PR116613]

After recent commit bf43fe6aa966eaf397ea3b8ebd6408d3d124e285
"Use unique_ptr in more places in pretty_printer/diagnostics [PR116613]":

    [...]
    In file included from ../../source-gcc/gcc/config/gcn/mkoffload.cc:31:0:
    ../../source-gcc/gcc/diagnostic.h:29:3: error: #error "You must define INCLUDE_MEMORY before including system.h to use diagnostic.h"
     # error "You must define INCLUDE_MEMORY before including system.h to use diagnostic.h"
       ^
    In file included from ../../source-gcc/gcc/diagnostic.h:34:0,
                     from ../../source-gcc/gcc/config/gcn/mkoffload.cc:31:
    ../../source-gcc/gcc/pretty-print.h:29:3: error: #error "You must define INCLUDE_MEMORY before including system.h to use pretty-print.h"
     # error "You must define INCLUDE_MEMORY before including system.h to use pretty-print.h"
       ^
    In file included from ../../source-gcc/gcc/diagnostic.h:34:0,
                     from ../../source-gcc/gcc/config/gcn/mkoffload.cc:31:
    ../../source-gcc/gcc/pretty-print.h:280:16: error: 'unique_ptr' in namespace 'std' does not name a template type
       virtual std::unique_ptr<pretty_printer> clone () const;
                    ^
    In file included from ../../source-gcc/gcc/config/gcn/mkoffload.cc:31:0:
    ../../source-gcc/gcc/diagnostic.h:585:32: error: 'std::unique_ptr' has not been declared
       void set_output_format (std::unique_ptr<diagnostic_output_format> output_format);
                                    ^
    [...]

PR other/116613
gcc/
* config/gcn/mkoffload.cc: Add '#define INCLUDE_MEMORY'.

9 months agolibstdc++: Fix test broken when using COW std::string
François Dumont [Thu, 24 Oct 2024 18:30:16 +0000 (20:30 +0200)] 
libstdc++: Fix test broken when using COW std::string

libstdc++-v3/ChangeLog:

* testsuite/23_containers/unordered_map/96088.cc (test03): Fix increments
value when _GLIBCXX_USE_CXX11_ABI is equal to 0.

9 months agolibstdc++: Fix typos in tests using macros for std::float128_t support
Jonathan Wakely [Thu, 24 Oct 2024 10:38:39 +0000 (11:38 +0100)] 
libstdc++: Fix typos in tests using macros for std::float128_t support

These tests check `_GLIBCXX_DOUBLE_IS_IEEE_BINARY128` but that's never
defined, it should be "LDOUBLE" not "DOUBLE".

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/complex/ext_c++23.cc: Fix typo in macro.
* testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc:
Likewise.
* testsuite/26_numerics/headers/cmath/functions_std_c++23.cc:
Likewise.
* testsuite/26_numerics/headers/cmath/nextafter_c++23.cc:
Likewise.

9 months agotestsuite: Require effective target pie for pr113197
Dimitar Dimitrov [Thu, 24 Oct 2024 16:59:42 +0000 (19:59 +0300)] 
testsuite: Require effective target pie for pr113197

The test for PR113197 explicitly enables PIE.  But targets without PIE
emit warnings when -fpie is passed (e.g. pru and avr), which causes the
test to fail.

Fix by adding an effective target requirement for PIE.

With this patch, the test now is marked as unsupported for
pru-unknown-elf.  Testing for x86_64-pc-linux-gnu passes with current
mainline, and fails if the fix from r15-4018-g02f4efe3c12cf7 is
reverted.

PR ipa/113197

gcc/testsuite/ChangeLog:

* gcc.dg/lto/pr113197_0.c: Require effective target pie.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
9 months agolibstdc++: Simplify std::__throw_bad_variant_access
Jonathan Wakely [Tue, 22 Oct 2024 15:06:12 +0000 (16:06 +0100)] 
libstdc++: Simplify std::__throw_bad_variant_access

This removes the overload of __throw_bad_variant_access that must be
called with a string literal. This avoids a potential source of
undefined behaviour if that function got misused. The other overload
that takes a bool parameter can be adjusted to take an integer index
selecting one of the four possible string literals to use, ensuring
that the std::bad_variant_access constructor is only called with those
literals.

Passing an index outside the range [0,3] is bogus, but will still select
a valid string literal and avoid undefined behaviour.

libstdc++-v3/ChangeLog:

* include/std/variant (__throw_bad_variant_access(unsigned)):
Define new function as inline friend, with namespace-scope
declaration using noreturn attribute.
(__throw_bad_variant_access(const char*)): Remove.
(__throw_bad_variant_access(bool)): Remove.
(visit, visit<R>): Adjust calls to __throw_bad_variant_access.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
9 months agoUse unique_ptr in more places in pretty_printer/diagnostics [PR116613]
David Malcolm [Thu, 24 Oct 2024 15:48:01 +0000 (11:48 -0400)] 
Use unique_ptr in more places in pretty_printer/diagnostics [PR116613]

My forthcoming patches for PR other/116613 make much more use of
cloning of pretty_printers than before, so it makes sense as a
preliminary patch for the result of pretty_printer::clone to be a
std::unique_ptr, rather than add more manual uses of "delete".

On doing so, I noticed various other places where naked new/delete is
used for run-time configuration of diagnostics:
* the output format (text vs SARIF)
* client data hooks
* the option manager
* the URLifier

Hence this patch also makes use of std::unique_ptr and ::make_unique for
managing such client policy classes, and also for diagnostic_buffer's
per-format implementations.

Unfortunately we can't directly include <memory> in our internal headers
but instead any of our TUs that make use of std::unique_ptr must #define
INCLUDE_MEMORY before including system.h.

Hence the bulk of this patch is taken up with adding a define of
INCLUDE_MEMORY to hundreds of source files: everything that includes
diagnostic.h or pretty-print.h (and thus anything transitively such as
includers of lto-wrapper.h, c-tree.h, cp-tree.h and rtl-ssa.h).

Thanks to Gaius Mulley for the parts of the patch that regenerated the
m2 files.

gcc/ada/ChangeLog:
PR other/116613
* gcc-interface/misc.cc: Add #define INCLUDE_MEMORY
* gcc-interface/trans.cc: Likewise.
* gcc-interface/utils.cc: Likewise.

gcc/analyzer/ChangeLog:
PR other/116613
* analyzer-logging.cc: Add #define INCLUDE_MEMORY
(logger::logger): Update for m_pp becoming a unique_ptr.
(logger::~logger): Likewise.
(logger::log_va_partial): Likewise.
(logger::end_log_line): Likewise.
* analyzer-logging.h (logger::get_printer): Likewise.
(logger::m_pp): Convert to a unique_ptr.
* analyzer.cc (make_label_text): Use
diagnostic_context::clone_printer and use unique_ptr.
(make_label_text_n): Likewise.
* bar-chart.cc: Add #define INCLUDE_MEMORY
* pending-diagnostic.cc (evdesc::event_desc::formatted_print):
Use diagnostic_context::clone_printer and use unique_ptr.
* sm-malloc.cc (sufficiently_similar_p): Likewise.
* supergraph.cc (supergraph::dump_dot_to_file): Likewise.

gcc/c-family/ChangeLog:
PR other/116613
* c-ada-spec.cc: Add #define INCLUDE_MEMORY.
* c-attribs.cc: Likewise.
* c-common.cc: Likewise.
* c-format.cc: Likewise.
* c-gimplify.cc: Likewise.
* c-indentation.cc: Likewise.
* c-opts.cc: Likewise.
* c-pch.cc: Likewise.
* c-pragma.cc: Likewise.
* c-pretty-print.cc: Likewise.  Add #include "make-unique.h".
(c_pretty_printer::clone): Use std::unique_ptr and ::make_unique.
* c-pretty-print.h (c_pretty_printer::clone): Use std::unique_ptr.
* c-type-mismatch.cc: Add #define INCLUDE_MEMORY.
* c-warn.cc: Likewise.

gcc/c/ChangeLog:
PR other/116613
* c-aux-info.cc: Add #define INCLUDE_MEMORY.
* c-convert.cc: Likewise.
* c-errors.cc: Likewise.
* c-fold.cc: Likewise.
* c-lang.cc: Likewise.
* c-objc-common.cc: Likewise.
(pp_markup::element_quoted_type::print_type): Use unique_ptr.
* c-typeck.cc: Add #define INCLUDE_MEMORY.
* gimple-parser.cc: Likewise.

gcc/cp/ChangeLog:
PR other/116613
* call.cc: Add #define INCLUDE_MEMORY.
* class.cc: Likewise.
* constexpr.cc: Likewise.
* constraint.cc: Likewise.
* contracts.cc: Likewise.
* coroutines.cc: Likewise.
* cp-gimplify.cc: Likewise.
* cp-lang.cc: Likewise.
* cp-objcp-common.cc: Likewise.
* cp-ubsan.cc: Likewise.
* cvt.cc: Likewise.
* cxx-pretty-print.cc: Likewise.  Add #include "cp-tree.h".
(cxx_pretty_printer::clone): Use std::unique_ptr and
::make_unique.
* cxx-pretty-print.h (cxx_pretty_printer::clone): Use
std::unique_ptr.
* decl2.cc: Add #define INCLUDE_MEMORY.
* dump.cc: Likewise.
* except.cc: Likewise.
* expr.cc: Likewise.
* friend.cc: Likewise.
* init.cc: Likewise.
* lambda.cc: Likewise.
* logic.cc: Likewise.
* mangle.cc: Likewise.
* method.cc: Likewise.
* optimize.cc: Likewise.
* pt.cc: Likewise.
* ptree.cc: Likewise.
* rtti.cc: Likewise.
* search.cc: Likewise.
* semantics.cc: Likewise.
* tree.cc: Likewise.
* typeck.cc: Likewise.
* typeck2.cc: Likewise.
* vtable-class-hierarchy.cc: Likewise.

gcc/d/ChangeLog:
PR other/116613
* d-attribs.cc: Add #define INCLUDE_MEMORY.
* d-builtins.cc: Likewise.
* d-codegen.cc: Likewise.
* d-convert.cc: Likewise.
* d-diagnostic.cc: Likewise.
* d-frontend.cc: Likewise.
* d-lang.cc: Likewise.
* d-longdouble.cc: Likewise.
* d-target.cc: Likewise.
* decl.cc: Likewise.
* expr.cc: Likewise.
* intrinsics.cc: Likewise.
* modules.cc: Likewise.
* toir.cc: Likewise.
* typeinfo.cc: Likewise.
* types.cc: Likewise.

gcc/fortran/ChangeLog:
PR other/116613
* arith.cc: Add #define INCLUDE_MEMORY.
* array.cc: Likewise.
* bbt.cc: Likewise.
* check.cc: Likewise.
* class.cc: Likewise.
* constructor.cc: Likewise.
* convert.cc: Likewise.
* cpp.cc: Likewise.
* data.cc: Likewise.
* decl.cc: Likewise.
* dependency.cc: Likewise.
* dump-parse-tree.cc: Likewise.
* error.cc: Likewise.
* expr.cc: Likewise.
* f95-lang.cc: Likewise.
* frontend-passes.cc: Likewise.
* interface.cc: Likewise.
* intrinsic.cc: Likewise.
* io.cc: Likewise.
* iresolve.cc: Likewise.
* match.cc: Likewise.
* matchexp.cc: Likewise.
* misc.cc: Likewise.
* module.cc: Likewise.
* openmp.cc: Likewise.
* options.cc: Likewise.
* parse.cc: Likewise.
* primary.cc: Likewise.
* resolve.cc: Likewise.
* scanner.cc: Likewise.
* simplify.cc: Likewise.
* st.cc: Likewise.
* symbol.cc: Likewise.
* target-memory.cc: Likewise.
* trans-array.cc: Likewise.
* trans-common.cc: Likewise.
* trans-const.cc: Likewise.
* trans-decl.cc: Likewise.
* trans-expr.cc: Likewise.
* trans-intrinsic.cc: Likewise.
* trans-io.cc: Likewise.
* trans-openmp.cc: Likewise.
* trans-stmt.cc: Likewise.
* trans-types.cc: Likewise.
* trans.cc: Likewise.

gcc/go/ChangeLog:
PR other/116613
* go-backend.cc: Add #define INCLUDE_MEMORY.
* go-lang.cc: Likewise.

gcc/jit/ChangeLog:
PR other/116613
* dummy-frontend.cc: Add #define INCLUDE_MEMORY.
* jit-playback.cc: Likewise.
* jit-recording.cc: Likewise.

gcc/lto/ChangeLog:
PR other/116613
* lto-common.cc: Add #define INCLUDE_MEMORY.
* lto-dump.cc: Likewise.
* lto-partition.cc: Likewise.
* lto-symtab.cc: Likewise.
* lto.cc: Likewise.

gcc/m2/ChangeLog:
PR other/116613
* gm2-gcc/gcc-consolidation.h: Add #define INCLUDE_MEMORY.
* gm2-gcc/m2configure.cc: Likewise.
* mc-boot/GASCII.cc: Regenerate.
* mc-boot/GASCII.h: Ditto.
* mc-boot/GArgs.cc: Ditto.
* mc-boot/GArgs.h: Ditto.
* mc-boot/GAssertion.cc: Ditto.
* mc-boot/GAssertion.h: Ditto.
* mc-boot/GBreak.cc: Ditto.
* mc-boot/GBreak.h: Ditto.
* mc-boot/GCOROUTINES.h: Ditto.
* mc-boot/GCmdArgs.cc: Ditto.
* mc-boot/GCmdArgs.h: Ditto.
* mc-boot/GDebug.cc: Ditto.
* mc-boot/GDebug.h: Ditto.
* mc-boot/GDynamicStrings.cc: Ditto.
* mc-boot/GDynamicStrings.h: Ditto.
* mc-boot/GEnvironment.cc: Ditto.
* mc-boot/GEnvironment.h: Ditto.
* mc-boot/GFIO.cc: Ditto.
* mc-boot/GFIO.h: Ditto.
* mc-boot/GFormatStrings.cc: Ditto.
* mc-boot/GFormatStrings.h: Ditto.
* mc-boot/GFpuIO.cc: Ditto.
* mc-boot/GFpuIO.h: Ditto.
* mc-boot/GIO.cc: Ditto.
* mc-boot/GIO.h: Ditto.
* mc-boot/GIndexing.cc: Ditto.
* mc-boot/GIndexing.h: Ditto.
* mc-boot/GM2Dependent.cc: Ditto.
* mc-boot/GM2Dependent.h: Ditto.
* mc-boot/GM2EXCEPTION.cc: Ditto.
* mc-boot/GM2EXCEPTION.h: Ditto.
* mc-boot/GM2RTS.cc: Ditto.
* mc-boot/GM2RTS.h: Ditto.
* mc-boot/GMemUtils.cc: Ditto.
* mc-boot/GMemUtils.h: Ditto.
* mc-boot/GNumberIO.cc: Ditto.
* mc-boot/GNumberIO.h: Ditto.
* mc-boot/GPushBackInput.cc: Ditto.
* mc-boot/GPushBackInput.h: Ditto.
* mc-boot/GRTExceptions.cc: Ditto.
* mc-boot/GRTExceptions.h: Ditto.
* mc-boot/GRTco.h: Ditto.
* mc-boot/GRTentity.h: Ditto.
* mc-boot/GRTint.cc: Ditto.
* mc-boot/GRTint.h: Ditto.
* mc-boot/GSArgs.cc: Ditto.
* mc-boot/GSArgs.h: Ditto.
* mc-boot/GSFIO.cc: Ditto.
* mc-boot/GSFIO.h: Ditto.
* mc-boot/GSYSTEM.h: Ditto.
* mc-boot/GSelective.h: Ditto.
* mc-boot/GStdIO.cc: Ditto.
* mc-boot/GStdIO.h: Ditto.
* mc-boot/GStorage.cc: Ditto.
* mc-boot/GStorage.h: Ditto.
* mc-boot/GStrCase.cc: Ditto.
* mc-boot/GStrCase.h: Ditto.
* mc-boot/GStrIO.cc: Ditto.
* mc-boot/GStrIO.h: Ditto.
* mc-boot/GStrLib.cc: Ditto.
* mc-boot/GStrLib.h: Ditto.
* mc-boot/GStringConvert.cc: Ditto.
* mc-boot/GStringConvert.h: Ditto.
* mc-boot/GSysExceptions.h: Ditto.
* mc-boot/GSysStorage.cc: Ditto.
* mc-boot/GSysStorage.h: Ditto.
* mc-boot/GTimeString.cc: Ditto.
* mc-boot/GTimeString.h: Ditto.
* mc-boot/GUnixArgs.h: Ditto.
* mc-boot/Galists.cc: Ditto.
* mc-boot/Galists.h: Ditto.
* mc-boot/Gdecl.cc: Ditto.
* mc-boot/Gdecl.h: Ditto.
* mc-boot/Gdtoa.h: Ditto.
* mc-boot/Gerrno.h: Ditto.
* mc-boot/Gkeyc.cc: Ditto.
* mc-boot/Gkeyc.h: Ditto.
* mc-boot/Gldtoa.h: Ditto.
* mc-boot/Glibc.h: Ditto.
* mc-boot/Glibm.h: Ditto.
* mc-boot/Glists.cc: Ditto.
* mc-boot/Glists.h: Ditto.
* mc-boot/GmcComment.cc: Ditto.
* mc-boot/GmcComment.h: Ditto.
* mc-boot/GmcComp.cc: Ditto.
* mc-boot/GmcComp.h: Ditto.
* mc-boot/GmcDebug.cc: Ditto.
* mc-boot/GmcDebug.h: Ditto.
* mc-boot/GmcError.cc: Ditto.
* mc-boot/GmcError.h: Ditto.
* mc-boot/GmcFileName.cc: Ditto.
* mc-boot/GmcFileName.h: Ditto.
* mc-boot/GmcLexBuf.cc: Ditto.
* mc-boot/GmcLexBuf.h: Ditto.
* mc-boot/GmcMetaError.cc: Ditto.
* mc-boot/GmcMetaError.h: Ditto.
* mc-boot/GmcOptions.cc: Ditto.
* mc-boot/GmcOptions.h: Ditto.
* mc-boot/GmcPreprocess.cc: Ditto.
* mc-boot/GmcPreprocess.h: Ditto.
* mc-boot/GmcPretty.cc: Ditto.
* mc-boot/GmcPretty.h: Ditto.
* mc-boot/GmcPrintf.cc: Ditto.
* mc-boot/GmcPrintf.h: Ditto.
* mc-boot/GmcQuiet.cc: Ditto.
* mc-boot/GmcQuiet.h: Ditto.
* mc-boot/GmcReserved.cc: Ditto.
* mc-boot/GmcReserved.h: Ditto.
* mc-boot/GmcSearch.cc: Ditto.
* mc-boot/GmcSearch.h: Ditto.
* mc-boot/GmcStack.cc: Ditto.
* mc-boot/GmcStack.h: Ditto.
* mc-boot/GmcStream.cc: Ditto.
* mc-boot/GmcStream.h: Ditto.
* mc-boot/Gmcflex.h: Ditto.
* mc-boot/Gmcp1.cc: Ditto.
* mc-boot/Gmcp1.h: Ditto.
* mc-boot/Gmcp2.cc: Ditto.
* mc-boot/Gmcp2.h: Ditto.
* mc-boot/Gmcp3.cc: Ditto.
* mc-boot/Gmcp3.h: Ditto.
* mc-boot/Gmcp4.cc: Ditto.
* mc-boot/Gmcp4.h: Ditto.
* mc-boot/Gmcp5.cc: Ditto.
* mc-boot/Gmcp5.h: Ditto.
* mc-boot/GnameKey.cc: Ditto.
* mc-boot/GnameKey.h: Ditto.
* mc-boot/GsymbolKey.cc: Ditto.
* mc-boot/GsymbolKey.h: Ditto.
* mc-boot/Gtermios.h: Ditto.
* mc-boot/Gtop.cc: Ditto.
* mc-boot/Gvarargs.cc: Ditto.
* mc-boot/Gvarargs.h: Ditto.
* mc-boot/Gwlists.cc: Ditto.
* mc-boot/Gwlists.h: Ditto.
* mc-boot/Gwrapc.h: Ditto.
* mc/keyc.mod (checkGccConfigSystem): Add
#define INCLUDE_MEMORY.
* pge-boot/GASCII.cc: Regenerate.
* pge-boot/GASCII.h: Ditto.
* pge-boot/GArgs.cc: Ditto.
* pge-boot/GArgs.h: Ditto.
* pge-boot/GAssertion.cc: Ditto.
* pge-boot/GAssertion.h: Ditto.
* pge-boot/GBreak.h: Ditto.
* pge-boot/GCmdArgs.h: Ditto.
* pge-boot/GDebug.cc: Ditto.
* pge-boot/GDebug.h: Ditto.
* pge-boot/GDynamicStrings.cc: Ditto.
* pge-boot/GDynamicStrings.h: Ditto.
* pge-boot/GEnvironment.h: Ditto.
* pge-boot/GFIO.cc: Ditto.
* pge-boot/GFIO.h: Ditto.
* pge-boot/GFormatStrings.h: Ditto.
* pge-boot/GFpuIO.h: Ditto.
* pge-boot/GIO.cc: Ditto.
* pge-boot/GIO.h: Ditto.
* pge-boot/GIndexing.cc: Ditto.
* pge-boot/GIndexing.h: Ditto.
* pge-boot/GLists.cc: Ditto.
* pge-boot/GLists.h: Ditto.
* pge-boot/GM2Dependent.cc: Ditto.
* pge-boot/GM2Dependent.h: Ditto.
* pge-boot/GM2EXCEPTION.cc: Ditto.
* pge-boot/GM2EXCEPTION.h: Ditto.
* pge-boot/GM2RTS.cc: Ditto.
* pge-boot/GM2RTS.h: Ditto.
* pge-boot/GNameKey.cc: Ditto.
* pge-boot/GNameKey.h: Ditto.
* pge-boot/GNumberIO.cc: Ditto.
* pge-boot/GNumberIO.h: Ditto.
* pge-boot/GOutput.cc: Ditto.
* pge-boot/GOutput.h: Ditto.
* pge-boot/GPushBackInput.cc: Ditto.
* pge-boot/GPushBackInput.h: Ditto.
* pge-boot/GRTExceptions.cc: Ditto.
* pge-boot/GRTExceptions.h: Ditto.
* pge-boot/GSArgs.h: Ditto.
* pge-boot/GSEnvironment.h: Ditto.
* pge-boot/GSFIO.cc: Ditto.
* pge-boot/GSFIO.h: Ditto.
* pge-boot/GSYSTEM.h: Ditto.
* pge-boot/GScan.h: Ditto.
* pge-boot/GStdIO.cc: Ditto.
* pge-boot/GStdIO.h: Ditto.
* pge-boot/GStorage.cc: Ditto.
* pge-boot/GStorage.h: Ditto.
* pge-boot/GStrCase.cc: Ditto.
* pge-boot/GStrCase.h: Ditto.
* pge-boot/GStrIO.cc: Ditto.
* pge-boot/GStrIO.h: Ditto.
* pge-boot/GStrLib.cc: Ditto.
* pge-boot/GStrLib.h: Ditto.
* pge-boot/GStringConvert.h: Ditto.
* pge-boot/GSymbolKey.cc: Ditto.
* pge-boot/GSymbolKey.h: Ditto.
* pge-boot/GSysExceptions.h: Ditto.
* pge-boot/GSysStorage.cc: Ditto.
* pge-boot/GSysStorage.h: Ditto.
* pge-boot/GTimeString.h: Ditto.
* pge-boot/GUnixArgs.h: Ditto.
* pge-boot/Gbnflex.cc: Ditto.
* pge-boot/Gbnflex.h: Ditto.
* pge-boot/Gdtoa.h: Ditto.
* pge-boot/Gerrno.h: Ditto.
* pge-boot/Gldtoa.h: Ditto.
* pge-boot/Glibc.h: Ditto.
* pge-boot/Glibm.h: Ditto.
* pge-boot/Gpge.cc: Ditto.
* pge-boot/Gtermios.h: Ditto.
* pge-boot/Gwrapc.h: Ditto.

gcc/objc/ChangeLog:
PR other/116613
* objc-act.cc: Add #define INCLUDE_MEMORY.
* objc-encoding.cc: Likewise.
* objc-gnu-runtime-abi-01.cc: Likewise.
* objc-lang.cc: Likewise.
* objc-next-runtime-abi-01.cc: Likewise.
* objc-next-runtime-abi-02.cc: Likewise.
* objc-runtime-shared-support.cc: Likewise.

gcc/objcp/ChangeLog:: Add #define INCLUDE_MEMORY.
PR other/116613
* objcp-decl.cc
* objcp-lang.cc: Likewise.

gcc/rust/ChangeLog:
PR other/116613
* resolve/rust-ast-resolve-expr.cc: Add #define INCLUDE_MEMORY.
* rust-attribs.cc: Likewise.
* rust-system.h: Likewise.

gcc/ChangeLog:
PR other/116613
* asan.cc: Add #define INCLUDE_MEMORY.
* attribs.cc: Likewise.
(attr_access::array_as_string): Use
diagnostic_context::clone_printer and use unique_ptr.
* auto-profile.cc: Add #define INCLUDE_MEMORY.
* calls.cc: Likewise.
* cfganal.cc: Likewise.
* cfgexpand.cc: Likewise.
* cfghooks.cc: Likewise.
* cfgloop.cc: Likewise.
* cgraph.cc: Likewise.
* cgraphclones.cc: Likewise.
* cgraphunit.cc: Likewise.
* collect-utils.cc: Likewise.
* collect2.cc: Likewise.
* common/config/aarch64/aarch64-common.cc: Likewise.
* common/config/arm/arm-common.cc: Likewise.
* common/config/avr/avr-common.cc: Likewise.
* config/aarch64/aarch64-cc-fusion.cc: Likewise.
* config/aarch64/aarch64-early-ra.cc: Likewise.
* config/aarch64/aarch64-sve-builtins.cc: Likewise.
* config/arc/arc.cc: Likewise.
* config/arm/aarch-common.cc: Likewise.
* config/arm/arm-mve-builtins.cc: Likewise.
* config/avr/avr-devices.cc: Likewise.
* config/avr/driver-avr.cc: Likewise.
* config/bpf/bpf.cc: Likewise.
* config/bpf/btfext-out.cc: Likewise.
* config/bpf/core-builtins.cc: Likewise.
* config/darwin.cc: Likewise.
* config/i386/driver-i386.cc: Likewise.
* config/i386/i386-builtins.cc: Likewise.
* config/i386/i386-expand.cc: Likewise.
* config/i386/i386-features.cc: Likewise.
* config/i386/i386-options.cc: Likewise.
* config/loongarch/loongarch-builtins.cc: Likewise.
* config/mingw/winnt-cxx.cc: Likewise.
* config/mingw/winnt.cc: Likewise.
* config/mips/mips.cc: Likewise.
* config/msp430/driver-msp430.cc: Likewise.
* config/nvptx/mkoffload.cc: Likewise.
* config/nvptx/nvptx.cc: Likewise.
* config/riscv/riscv-avlprop.cc: Likewise.
* config/riscv/riscv-vector-builtins.cc: Likewise.
* config/riscv/riscv-vsetvl.cc: Likewise.
* config/rs6000/driver-rs6000.cc: Likewise.
* config/rs6000/host-darwin.cc: Likewise.
* config/rs6000/rs6000-c.cc: Likewise.
* config/s390/s390-c.cc: Likewise.
* config/s390/s390.cc: Likewise.
* config/sol2-cxx.cc: Likewise.
* config/vms/vms-c.cc: Likewise.
* config/xtensa/xtensa-dynconfig.cc: Likewise.
* coroutine-passes.cc: Likewise.
* coverage.cc: Likewise.
* data-streamer-in.cc: Likewise.
* data-streamer-out.cc: Likewise.
* data-streamer.cc: Likewise.
* diagnostic-buffer.h (diagnostic_buffer::~diagnostic_buffer):
Delete.
(diagnostic_buffer::m_per_format_buffer): Use std::unique_ptr.
* diagnostic-client-data-hooks.h (make_compiler_data_hooks): Use
std::unique_ptr for return type.
* diagnostic-format-json.cc
(json_output_format::make_per_format_buffer): Likewise.
(diagnostic_output_format_init_json): Update for usage of
std::unique_ptr in set_output_format.
* diagnostic-format-sarif.cc
(sarif_output_format::make_per_format_buffer): Use std::unique_ptr
for return type.
(diagnostic_output_format_init_sarif): Update for usage of
std::unique_ptr.
(test_message_with_embedded_link): Likewise for set_urlifier.
* diagnostic-format-text.cc: Add #define INCLUDE_MEMORY.  Include
"make-unique.h".
(diagnostic_text_output_format::set_buffer): Use std::unique_ptr.
* diagnostic-format-text.h
(diagnostic_text_output_format::set_buffer): Likewise.
* diagnostic-format.h
(diagnostic_output_format::make_per_format_buffer): Likewise.
* diagnostic-global-context.cc:
* diagnostic-macro-unwinding.cc: Likewise.
* diagnostic-show-locus.cc: Likewise.
* diagnostic-spec.cc: Likewise.
* diagnostic.cc (diagnostic_context::set_output_format): Use
std::unique_ptr for input.
(diagnostic_context::set_client_data_hooks): Likewise.
(diagnostic_context::set_option_manager): Likewise.
(diagnostic_context::set_urlifier): Likewise.
(diagnostic_context::set_diagnostic_buffer): Update for use of
std::unique_ptr.
(diagnostic_buffer::diagnostic_buffer): Likewise.
(diagnostic_buffer::~diagnostic_buffer): Delete.
* diagnostic.h: Complain if INCLUDE_MEMORY was not defined.
(diagnostic_context::set_output_format): Use std::unique_ptr for
input.
(diagnostic_context::set_client_data_hooks): Likewise.
(diagnostic_context::set_option_manager): Likewise.
(diagnostic_context::set_urlifier): Likewise.
(diagnostic_context::clone_printer): New.
(diagnostic_context::m_printer): Update comment.
(diagnostic_context::m_option_mgr): Likewise.
(diagnostic_context::m_urlifier): Likewise.
(diagnostic_context::m_edit_context_ptr): Likewise.
(diagnostic_context::m_output_format): Likewise.
(diagnostic_context::m_client_data_hooks): Likewise.
(diagnostic_context::m_theme): Likewise.
* digraph.cc: Add #define INCLUDE_MEMORY.
* dwarf2out.cc: Likewise.
* edit-context.cc: Likewise.
* except.cc: Likewise.
* expr.cc: Likewise.
* file-prefix-map.cc: Likewise.
* final.cc: Likewise.
* fwprop.cc: Likewise.
* gcc-plugin.h: Likewise.
* gcc-rich-location.cc: Likewise.
* gcc-urlifier.cc: Likewise.  Add #include "make-unique.h".
(make_gcc_urlifier): Use std::unique_ptr and ::make_unique.
* gcc-urlifier.h (make_gcc_urlifier): Use std::unique_ptr.
* gcc.cc: Add #define INCLUDE_MEMORY.  Include
"pretty-print-urlifier.h".
* gcov-dump.cc: Add #define INCLUDE_MEMORY.
* gcov-tool.cc: Likewise.
* gengtype.cc (open_base_files): Likewise to output.
* genmatch.cc: Likewise.
* gimple-fold.cc: Likewise.
* gimple-harden-conditionals.cc: Likewise.
* gimple-harden-control-flow.cc: Likewise.
* gimple-if-to-switch.cc: Likewise.
* gimple-lower-bitint.cc: Likewise.
* gimple-predicate-analysis.cc: Likewise.
* gimple-pretty-print.cc: Likewise.
* gimple-range-cache.cc: Likewise.
* gimple-range-edge.cc: Likewise.
* gimple-range-fold.cc: Likewise.
* gimple-range-gori.cc: Likewise.
* gimple-range-infer.cc: Likewise.
* gimple-range-op.cc: Likewise.
* gimple-range-path.cc: Likewise.
* gimple-range-phi.cc: Likewise.
* gimple-range-trace.cc: Likewise.
* gimple-range.cc: Likewise.
* gimple-ssa-backprop.cc: Likewise.
* gimple-ssa-sprintf.cc: Likewise.
* gimple-ssa-store-merging.cc: Likewise.
* gimple-ssa-strength-reduction.cc: Likewise.
* gimple-ssa-warn-access.cc: Likewise.
* gimple-ssa-warn-alloca.cc: Likewise.
* gimple-ssa-warn-restrict.cc: Likewise.
* gimple-streamer-in.cc: Likewise.
* gimple-streamer-out.cc: Likewise.
* gimple.cc: Likewise.
* gimplify.cc: Likewise.
* graph.cc: Likewise.
* graphviz.cc: Likewise.
* input.cc: Likewise.
* ipa-cp.cc: Likewise.
* ipa-devirt.cc: Likewise.
* ipa-fnsummary.cc: Likewise.
* ipa-free-lang-data.cc: Likewise.
* ipa-icf-gimple.cc: Likewise.
* ipa-icf.cc: Likewise.
* ipa-inline-analysis.cc: Likewise.
* ipa-inline.cc: Likewise.
* ipa-modref-tree.cc: Likewise.
* ipa-modref.cc: Likewise.
* ipa-param-manipulation.cc: Likewise.
* ipa-polymorphic-call.cc: Likewise.
* ipa-predicate.cc: Likewise.
* ipa-profile.cc: Likewise.
* ipa-prop.cc: Likewise.
* ipa-pure-const.cc: Likewise.
* ipa-reference.cc: Likewise.
* ipa-split.cc: Likewise.
* ipa-sra.cc: Likewise.
* ipa-strub.cc: Likewise.
* ipa-utils.cc: Likewise.
* langhooks.cc: Likewise.
* late-combine.cc: Likewise.
* lto-cgraph.cc: Likewise.
* lto-compress.cc: Likewise.
* lto-opts.cc: Likewise.
* lto-section-in.cc: Likewise.
* lto-section-out.cc: Likewise.
* lto-streamer-in.cc: Likewise.
* lto-streamer-out.cc: Likewise.
* lto-streamer.cc: Likewise.
* lto-wrapper.cc: Likewise.  Include "make-unique.h".
(main): Use ::make_unique when creating option manager.
* multiple_target.cc: Likewise.
* omp-expand.cc: Likewise.
* omp-general.cc: Likewise.
* omp-low.cc: Likewise.
* omp-oacc-neuter-broadcast.cc: Likewise.
* omp-offload.cc: Likewise.
* omp-simd-clone.cc: Likewise.
* optc-gen.awk: Likewise in output.
* optc-save-gen.awk: Likewise in output.
* options-urls-cc-gen.awk: Likewise in output.
* opts-common.cc: Likewise.
* opts-global.cc: Likewise.
* opts.cc: Likewise.
* pair-fusion.cc: Likewise.
* passes.cc: Likewise.
* pointer-query.cc: Likewise.
* predict.cc: Likewise.
* pretty-print.cc (pretty_printer::clone): Use std::unique_ptr and
::make_unique.
* pretty-print.h: Complain if INCLUDE_MEMORY is not defined.
(pretty_printer::clone): Use std::unique_ptr.
* print-rtl.cc: Add #define INCLUDE_MEMORY.
* print-tree.cc: Likewise.
* profile-count.cc: Likewise.
* range-op-float.cc: Likewise.
* range-op-ptr.cc: Likewise.
* range-op.cc: Likewise.
* range.cc: Likewise.
* read-rtl-function.cc: Likewise.
* rtl-error.cc: Likewise.
* rtl-ssa/accesses.cc: Likewise.
* rtl-ssa/blocks.cc: Likewise.
* rtl-ssa/changes.cc: Likewise.
* rtl-ssa/functions.cc: Likewise.
* rtl-ssa/insns.cc: Likewise.
* rtl-ssa/movement.cc: Likewise.
* rtl-tests.cc: Likewise.
* sanopt.cc: Likewise.
* sched-rgn.cc: Likewise.
* selftest-diagnostic-path.cc: Likewise.
* selftest-diagnostic.cc: Likewise.
* splay-tree-utils.cc: Likewise.
* sreal.cc: Likewise.
* stmt.cc: Likewise.
* substring-locations.cc: Likewise.
* symtab-clones.cc: Likewise.
* symtab-thunks.cc: Likewise.
* symtab.cc: Likewise.
* text-art/box-drawing.cc: Likewise.
* text-art/canvas.cc: Likewise.
* text-art/ruler.cc: Likewise.
* text-art/selftests.cc: Likewise.
* text-art/theme.cc: Likewise.
* toplev.cc: Likewise.  Include "make-unique.h".
(general_init): Use ::make_unique when setting option_manager.
* trans-mem.cc: Add #define INCLUDE_MEMORY.
* tree-affine.cc: Likewise.
* tree-call-cdce.cc: Likewise.
* tree-cfg.cc: Likewise.
* tree-chrec.cc: Likewise.
* tree-dfa.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Include "make-unique.h".
(make_compiler_data_hooks): Use std::unique_ptr and ::make_unique.
* tree-diagnostic.cc: Add #define INCLUDE_MEMORY.
* tree-dump.cc: Likewise.
* tree-inline.cc: Likewise.
* tree-into-ssa.cc: Likewise.
* tree-logical-location.cc: Likewise.
* tree-nested.cc: Likewise.
* tree-nrv.cc: Likewise.
* tree-object-size.cc: Likewise.
* tree-outof-ssa.cc: Likewise.
* tree-pretty-print.cc: Likewise.
* tree-profile.cc: Likewise.
* tree-scalar-evolution.cc: Likewise.
* tree-sra.cc: Likewise.
* tree-ssa-address.cc: Likewise.
* tree-ssa-alias.cc: Likewise.
* tree-ssa-ccp.cc: Likewise.
* tree-ssa-coalesce.cc: Likewise.
* tree-ssa-copy.cc: Likewise.
* tree-ssa-dce.cc: Likewise.
* tree-ssa-dom.cc: Likewise.
* tree-ssa-forwprop.cc: Likewise.
* tree-ssa-ifcombine.cc: Likewise.
* tree-ssa-loop-ch.cc: Likewise.
* tree-ssa-loop-im.cc: Likewise.
* tree-ssa-loop-manip.cc: Likewise.
* tree-ssa-loop-niter.cc: Likewise.
* tree-ssa-loop-split.cc: Likewise.
* tree-ssa-math-opts.cc: Likewise.
* tree-ssa-operands.cc: Likewise.
* tree-ssa-phiprop.cc: Likewise.
* tree-ssa-pre.cc: Likewise.
* tree-ssa-propagate.cc: Likewise.
* tree-ssa-reassoc.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.
* tree-ssa-scopedtables.cc: Likewise.
* tree-ssa-sink.cc: Likewise.
* tree-ssa-strlen.cc: Likewise.
* tree-ssa-structalias.cc: Likewise.
* tree-ssa-ter.cc: Likewise.
* tree-ssa-uninit.cc: Likewise.
* tree-ssa.cc: Likewise.
* tree-ssanames.cc: Likewise.
* tree-stdarg.cc: Likewise.
* tree-streamer-in.cc: Likewise.
* tree-streamer-out.cc: Likewise.
* tree-streamer.cc: Likewise.
* tree-switch-conversion.cc: Likewise.
* tree-tailcall.cc: Likewise.
* tree-vrp.cc: Likewise.
* tree.cc: Likewise.
* ubsan.cc: Likewise.
* value-pointer-equiv.cc: Likewise.
* value-prof.cc: Likewise.
* value-query.cc: Likewise.
* value-range-pretty-print.cc: Likewise.
* value-range-storage.cc: Likewise.
* value-range.cc: Likewise.
* value-relation.cc: Likewise.
* var-tracking.cc: Likewise.
* varpool.cc: Likewise.
* vr-values.cc: Likewise.
* wide-int-print.cc: Likewise.

gcc/testsuite/ChangeLog:
PR other/116613
* gcc.dg/plugin/diagnostic_group_plugin.c: Update for use of
std::unique_ptr.
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Likewise.
* gcc.dg/plugin/ggcplug.c: Likewise.

libgcc/ChangeLog:
PR other/116613
* libgcov-util.c: Add #define INCLUDE_MEMORY.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Co-authored-by: Gaius Mulley <gaiusmod2@gmail.com>
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months agoAdd comment about pp_format to diagnostic_context::report_diagnostic
David Malcolm [Thu, 24 Oct 2024 15:47:30 +0000 (11:47 -0400)] 
Add comment about pp_format to diagnostic_context::report_diagnostic

No functional change intended.

gcc/ChangeLog:
* diagnostic.cc (diagnostic_context::report_diagnostic): Add
comment about interaction of this code with pretty-print
formatting phaes.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months agoaarch64: libstdc++: Use shufflevector instead of shuffle in opt_random.h
Ricardo Jesus [Mon, 14 Oct 2024 13:28:02 +0000 (14:28 +0100)] 
aarch64: libstdc++: Use shufflevector instead of shuffle in opt_random.h

This patch modifies the implementation of the vectorized mersenne
twister random number generator to use __builtin_shufflevector instead
of __builtin_shuffle. This makes it (almost) compatible with Clang.

To make the implementation fully compatible with Clang, Clang will need
to support internal Neon types like __Uint8x16_t and __Uint32x4_t, which
currently it does not. This looks like an oversight in Clang and so will
be addressed separately.

I see no codegen change with this patch.

Bootstrapped and tested on aarch64-none-linux-gnu.

libstdc++-v3/ChangeLog:

* config/cpu/aarch64/opt/ext/opt_random.h (__VEXT): Replace uses
of __builtin_shuffle with __builtin_shufflevector.
(__aarch64_lsl_128): Move shift amount to a template parameter.
(__aarch64_lsr_128): Move shift amount to a template parameter.
(__aarch64_recursion): Update call sites of __aarch64_lsl_128
and __aarch64_lsr_128.

Signed-off-by: Ricardo Jesus <rjj@nvidia.com>
9 months agoRecord nonzero bits in the irange_bitmask of POLY_INT_CSTs
Richard Sandiford [Thu, 24 Oct 2024 13:22:34 +0000 (14:22 +0100)] 
Record nonzero bits in the irange_bitmask of POLY_INT_CSTs

At the moment, ranger punts entirely on POLY_INT_CSTs.  Numerical
ranges are a bit difficult, unless we do start modelling bounds on
the indeterminates.  But we can at least track the nonzero bits.

gcc/
* value-query.cc (range_query::get_tree_range): Use get_nonzero_bits
to populate the irange_bitmask of a POLY_INT_CST.

gcc/testsuite/
* gcc.target/aarch64/sve/cnt_fold_6.c: New test.

9 months agoTry to simplify (X >> C1) * (C2 << C1) -> X * C2
Richard Sandiford [Thu, 24 Oct 2024 13:22:33 +0000 (14:22 +0100)] 
Try to simplify (X >> C1) * (C2 << C1) -> X * C2

This patch adds a rule to simplify (X >> C1) * (C2 << C1) -> X * C2
when the low C1 bits of X are known to be zero.  As with the earlier
X >> C1 << (C2 + C1) patch, any single conversion is allowed between
the shift and the multiplication.

gcc/
* match.pd: Simplify (X >> C1) * (C2 << C1) -> X * C2 if the
low C1 bits of X are zero.

gcc/testsuite/
* gcc.dg/tree-ssa/shifts-3.c: New test.
* gcc.dg/tree-ssa/shifts-4.c: Likewise.
* gcc.target/aarch64/sve/cnt_fold_5.c: Likewise.

9 months agoHandle POLY_INT_CSTs in get_nonzero_bits
Richard Sandiford [Thu, 24 Oct 2024 13:22:33 +0000 (14:22 +0100)] 
Handle POLY_INT_CSTs in get_nonzero_bits

This patch extends get_nonzero_bits to handle POLY_INT_CSTs,
The easiest (but also most useful) case is that the number
of trailing zeros in the runtime value is at least the number
of trailing zeros in each individual component.

In principle, we could do this for coeffs 1 and above only,
and then OR in ceoff 0.  This would give ~0x11 for [14, 32], say.
But that's future work.

gcc/
* tree-ssanames.cc (get_nonzero_bits): Handle POLY_INT_CSTs.
* match.pd (with_possible_nonzero_bits): Likewise.

gcc/testsuite/
* gcc.target/aarch64/sve/cnt_fold_4.c: New test.

9 months agoTry to simplify (X >> C1) << (C1 + C2) -> X << C2
Richard Sandiford [Thu, 24 Oct 2024 13:22:32 +0000 (14:22 +0100)] 
Try to simplify (X >> C1) << (C1 + C2) -> X << C2

This patch adds a rule to simplify (X >> C1) << (C1 + C2) -> X << C2
when the low C1 bits of X are known to be zero.

Any single conversion can take place between the shifts.  E.g. for
a truncating conversion, any extra bits of X that are preserved by
truncating after the shift are immediately lost by the shift left.
And the sign bits used for an extending conversion are the same as
the sign bits used for the rshift.  (A double conversion of say
int->unsigned->uint64_t would be wrong though.)

gcc/
* match.pd: Simplify (X >> C1) << (C1 + C2) -> X << C2 if the
low C1 bits of X are zero.

gcc/testsuite/
* gcc.dg/tree-ssa/shifts-1.c: New test.
* gcc.dg/tree-ssa/shifts-2.c: Likewise.

9 months agoGeneralise ((X /[ex] A) +- B) * A -> X +- A * B rule
Richard Sandiford [Thu, 24 Oct 2024 13:22:32 +0000 (14:22 +0100)] 
Generalise ((X /[ex] A) +- B) * A -> X +- A * B rule

match.pd had a rule to simplify ((X /[ex] A) +- B) * A -> X +- A * B
when A and B are INTEGER_CSTs.  This patch extends it to handle the
case where the outer multiplication is by a factor of A, not just
A itself.  It also handles addition and multiplication of poly_ints.
(Exact division by a poly_int seems unlikely.)

gcc/
* match.pd: Generalise ((X /[ex] A) +- B) * A -> X +- A * B rule
to ((X /[ex] C1) +- C2) * (C1 * C3) -> (X * C3) +- (C1 * C2 * C3).

gcc/testsuite/
* gcc.dg/tree-ssa/mulexactdiv-5.c: New test.
* gcc.dg/tree-ssa/mulexactdiv-6.c: Likewise.
* gcc.dg/tree-ssa/mulexactdiv-7.c: Likewise.
* gcc.dg/tree-ssa/mulexactdiv-8.c: Likewise.
* gcc.target/aarch64/sve/cnt_fold_3.c: Likewise.

9 months agoSimplify (X /[ex] C1) * (C1 * C2) -> X * C2
Richard Sandiford [Thu, 24 Oct 2024 13:22:31 +0000 (14:22 +0100)] 
Simplify (X /[ex] C1) * (C1 * C2) -> X * C2

gcc/
* match.pd: Simplify (X /[ex] C1) * (C1 * C2) -> X * C2.

gcc/testsuite/
* gcc.dg/tree-ssa/mulexactdiv-1.c: New test.
* gcc.dg/tree-ssa/mulexactdiv-2.c: Likewise.
* gcc.dg/tree-ssa/mulexactdiv-3.c: Likewise.
* gcc.dg/tree-ssa/mulexactdiv-4.c: Likewise.
* gcc.target/aarch64/sve/cnt_fold_1.c: Likewise.
* gcc.target/aarch64/sve/cnt_fold_2.c: Likewise.