Commit Graph

214759 Commits

Author SHA1 Message Date
GCC Administrator
c232f92161 Daily bump. 2024-10-26 00:19:39 +00:00
Ian Lance Taylor
bab7a64c1a 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.
2024-10-25 15:20:55 -07:00
Andrew Pinski
35bf490452 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>
2024-10-25 15:15:34 -07:00
Sam James
2266e38cfd
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.
2024-10-25 22:10:24 +01:00
Sam James
908b306909
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.
2024-10-25 22:10:23 +01:00
Sam James
e87c1af38d
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-*.
2024-10-25 22:10:23 +01:00
Sam James
091e45b4e9
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.
2024-10-25 22:10:22 +01:00
Sam James
2d1d6be002
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.
2024-10-25 22:10:22 +01:00
Sam James
04e0fbbc34
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.
2024-10-25 22:10:21 +01:00
Sam James
03ff420aa0
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.
2024-10-25 22:10:20 +01:00
Sam James
96110c14cf
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.
2024-10-25 22:10:20 +01:00
Andrew Pinski
48b22a3f05 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>
2024-10-25 13:09:04 -07:00
Andrew Pinski
c8138acb99 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>
2024-10-25 10:36:06 -07:00
Wilco Dijkstra
7c17058eac 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.
2024-10-25 17:13:03 +00:00
Paul Thomas
6cb1da72ca 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.
2024-10-25 17:59:50 +01:00
Sam James
68e7ced1c7
testsuite: add testcase for fixed PR115933
gcc/testsuite/ChangeLog:
	PR rtl-optimization/115933

	* gcc.dg/pr115933.c: New test.
2024-10-25 17:57:55 +01:00
Andrew Carlotti
17d7a4b01a 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.
2024-10-25 17:28:14 +01:00
Andrew Carlotti
d74b0c698c 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.
2024-10-25 17:28:11 +01:00
Jennifer Schmitz
07a8538d90 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.
2024-10-25 15:56:41 +02:00
Pan Li
df4af89bc3 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>
2024-10-25 21:52:43 +08:00
Jakub Jelinek
e2a8772c93 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.
2024-10-25 14:09:42 +02:00
Jakub Jelinek
432044b24a 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.
2024-10-25 14:05:37 +02:00
Richard Biener
35c3aac80e 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.
2024-10-25 13:44:33 +02:00
Richard Sandiford
a0e37a6bf6 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.
2024-10-25 12:25:42 +01:00
Eric Botcazou
4d72cfaadf Add regression test
gcc/testsuite
	PR ada/116551
	* gnat.dg/specs/vfa3.ads: New test.
2024-10-25 13:14:22 +02:00
Jonathan Wakely
a4931587cb
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.
2024-10-25 10:23:56 +01:00
Giuseppe D'Angelo
813afa280c
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>
2024-10-25 10:23:56 +01:00
Richard Biener
967939055c 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.
2024-10-25 11:14:42 +02:00
Richard Biener
482d5a7b1a 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.
2024-10-25 11:14:42 +02:00
Richard Biener
7b2fb7ddc7 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.
2024-10-25 11:14:42 +02:00
Richard Biener
07c357eae8 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.
2024-10-25 11:14:42 +02:00
Tom Tromey
7124671cad 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.
2024-10-25 11:09:04 +02:00
Tom Tromey
a60e728935 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.
2024-10-25 11:09:04 +02:00
Tom Tromey
88715b9480 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.
2024-10-25 11:09:04 +02:00
Tom Tromey
125a6e4117 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.
2024-10-25 11:09:04 +02:00
Tom Tromey
0eb688077f 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.
2024-10-25 11:09:04 +02:00
Tom Tromey
b857742bc8 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.
2024-10-25 11:09:04 +02:00
Tom Tromey
c895db1080 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.
2024-10-25 11:09:03 +02:00
Eric Botcazou
11e06dd243 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.
2024-10-25 11:09:03 +02:00
Eric Botcazou
de8d682937 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.
2024-10-25 11:09:03 +02:00
Bob Duff
12d625e3f0 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.
2024-10-25 11:09:03 +02:00
Bob Duff
58e34ecbe5 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.
2024-10-25 11:09:03 +02:00
Tom Tromey
5f583c94e5 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.
2024-10-25 11:09:03 +02:00
Eric Botcazou
0b972c87ac 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.
2024-10-25 11:09:02 +02:00
Javier Miranda
13a4eb2548 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.
2024-10-25 11:09:02 +02:00
Richard Kenner
257d0d7769 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.
2024-10-25 11:09:02 +02:00
Eric Botcazou
8af9169fcf 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.
2024-10-25 11:09:02 +02:00
Eric Botcazou
2e3d527fe3 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.
2024-10-25 11:09:01 +02:00
Javier Miranda
c2d4ca9c1d 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.
2024-10-25 11:09:01 +02:00
Javier Miranda
d0a072e1f8 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.
2024-10-25 11:09:01 +02:00