Commit Graph

224640 Commits

Author SHA1 Message Date
GCC Administrator
0e9ccae269 Daily bump. 2025-11-04 00:20:26 +00:00
Eric Botcazou
7bdac5a4a5 Ada: Fix segfault for instantiation on function call returning string
The problem is that a transient scope is created during the analysis of the
actual parameters of the instantiation and this discombobulates the complex
handling of scopes in Sem_Ch12.

gcc/ada/
	PR ada/78175
	* sem_ch12.adb (Hide_Current_Scope): Deal with a transient scope
	as current scope.
	(Remove_Parent): Likewise.

gcc/testsuite/
	* gnat.dg/generic_inst15.adb: New test.
	* gnat.dg/generic_inst15_pkg-g.ads: New helper.
	* gnat.dg/generic_inst15_pkg.ads: Likewise.
2025-11-04 00:42:46 +01:00
Eric Botcazou
f4367c6b7b Ada: Fix misleading diagnostic about abstract new in type derivation
The current error message is:

abstract1.ads:7:13: error: "abstract" not allowed here, ignored

but "abstract" is indeed allowed there if you complete the declaration.

The patch changes it to:

abstract1.ads:7:13: error: "abstract" allowed only for record extension, ...

gcc/ada/
	PR ada/55324
	* par-ch3.adb (P_Type_Declaration): Give a better error message
	for illegal "abstract" in a type derivation.

gcc/testsuite/
	* gnat.dg/specs/abstract1.ads: New test.
2025-11-04 00:42:46 +01:00
Uros Bizjak
584f50a6e4 i386: Allow memory op in operand 1 predicate of *test<mode>_1 insn patterns [PR122534]
Combine tries to combine AND RTX with memory operand:

Trying 12 -> 13:
   12: {r106:DI=r99:DI&[r100:DI*0x8+r103:DI];clobber flags:CC;}
      REG_UNUSED flags:CC
   13: flags:CCZ=cmp(r106:DI,0)
      REG_DEAD r106:DI

but fails to match instruction:

(set (reg:CCZ 17 flags)
    (compare:CCZ (and:DI (reg:DI 99 [ shifttmp_6 ])
            (mem:DI (plus:DI (mult:DI (reg/v:DI 100 [ i ])
                        (const_int 8 [0x8]))
                    (reg/v/f:DI 103 [ p ])) [1 MEM[(long unsigned int *)p_8(D) + i_14 * 8]+0 S8 A64]))
        (const_int 0 [0])))

because corresponding *test<mode>_1 pattern doesn't allow memory operand 1.

Allow memory operand 1 by matching operand predicates of *test<mode>_1 family
of insns with corresponding *and<mode>_2 insn patterns.

The testcase improves from:

	movl	%esi, %ecx
	movl	$1, %eax
	salq	%cl, %rax
	movq	%rax, %rcx
	xorl	%eax, %eax
.L4:
	movq	%rcx, %rdx
	andq	(%rdi,%rax,8), %rdx
	jne	.L1
	...

to:
	movl	$1, %edx
	movl	%esi, %ecx
	xorl	%eax, %eax
	salq	%cl, %rdx
.L4:
	testq	%rdx, (%rdi,%rax,8)
	jne	.L1
	...

Also improve pentium pairing in *testqi_1_maybe_si insn pattern.

	PR target/122534

gcc/ChangeLog:

	* config/i386/i386.md (@test<mode>_ccno_1):
	Use <general_szext_operand> as operand 1 predicate.
	(testqi_ccz_1): Use general_operand as operand 1 predicate.
	(*testdi_1): Use x86_64_szext_general_operand as operand 1 predicate.
	(*testqi_1_maybe_si): Use general_operand as operand 1 predicate.
	Add (n,*a) alternative to allow UV pairing for pentium processor.
	(*test<mode>_1): Use <general_operand> as operand 1 predicate.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr122534.c: New test.
2025-11-03 21:52:23 +01:00
Robin Dapp
c5d658eb0b RISC-V: testsuite: Fix pr119115.c.
pr119115.c is broken (since it was added?) but because we only
attempt to compile/run it on a 256b target I never noticed it.

This patch adds -std=gnu99 to make it compile.

Regtested on rv64gcv_zvl512b.  Going to push after the CI run.

Regards
 Robin

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/pr119115.c: Add -std=gnu99.
2025-11-03 13:36:09 -07:00
Steve Kargl
ffe538c831 Fortran: Fix check on locality spec DO CONCURRENT
PR fortran/122513

gcc/fortran/ChangeLog:

	* resolve.cc (check_default_none_expr): Do not allow an
	iterator in a locality spec. Allow a named constant to be
	used within the loop.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr122513.f90: New test.
2025-11-03 12:31:10 -08:00
Sam James
f8bb20167f gcc: sync top-level with binutils-gdb
This just pulls in Alan's:

commit 87b6078fc212ccba5f043399c6370ee20f6b355a
Author:     Alan Modra <amodra@gmail.com>
AuthorDate: Mon Nov 3 10:59:50 2025 +1030
Commit:     Alan Modra <amodra@gmail.com>
CommitDate: Mon Nov 3 10:59:50 2025 +1030

    tidy m4 plugin config support

    ...

It tidies up the configure test output.

config/ChangeLog:

	* clang-plugin.m4: Sync with binutils.
	* gcc-plugin.m4: Ditto.

ChangeLog:

	* configure: Regenerate.

gcc/ChangeLog:

	* configure: Regenerate.

libatomic/ChangeLog:

	* configure: Regenerate.

libbacktrace/ChangeLog:

	* configure: Regenerate.

libcc1/ChangeLog:

	* configure: Regenerate.

libffi/ChangeLog:

	* configure: Regenerate.

libgcobol/ChangeLog:

	* configure: Regenerate.

libgfortran/ChangeLog:

	* configure: Regenerate.

libgm2/ChangeLog:

	* configure: Regenerate.

libgomp/ChangeLog:

	* configure: Regenerate.

libgrust/ChangeLog:

	* configure: Regenerate.

libiberty/ChangeLog:

	* configure: Regenerate.

libitm/ChangeLog:

	* configure: Regenerate.

libobjc/ChangeLog:

	* configure: Regenerate.

libphobos/ChangeLog:

	* configure: Regenerate.

libquadmath/ChangeLog:

	* configure: Regenerate.

libsanitizer/ChangeLog:

	* configure: Regenerate.

libssp/ChangeLog:

	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.

libvtv/ChangeLog:

	* configure: Regenerate.

lto-plugin/ChangeLog:

	* configure: Regenerate.

zlib/ChangeLog:

	* configure: Regenerate.
2025-11-03 20:25:00 +00:00
Jeff Law
0f4afd8bb1 [PR rtl-optimization/122536] Fix guard against variable bit extracts in RTL simplifier
While I haven't been able to reproduce the failure Sam reported, based on the
RTL checking failure point and the code in question it was pretty clear the
code that was supposed to guard against a variable bit extract was just
checking the wrong argument to verify it was a constant integer -- it missed a
level of XEXP object extraction.

I passed this patch along to Sam and he verified it fixes his kernel build.
I've bootstrapped and regression tested on x86_64.  Pushing to the trunk.

Pushing to the trunk.

	PR rtl-optimization/122536
gcc/
	* simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Fix
	guard against variable bit extracts in recent change.
2025-11-03 12:46:23 -07:00
Jason Merrill
8f6c9ebc7d c++: ADL finds all friends (P1787)
Some libstdc++ tests were failing with import std because ADL didn't find
rethrow_exception, even though it's a friend.  The problem turned out to be
because it's not in the same namespace, and in C++17 ADL only makes hidden
friends visible.  But in C++20 P1787 changed [basic.lookup.argdep]/4.2 to
directly include all friends in the lookup.

Note that my change still excludes class members, even though the standard
doesn't specify that; including implicit object member functions would just
break, and even foreign static/xobj member functions seem like they would be
strange to include.

gcc/cp/ChangeLog:

	* name-lookup.cc (name_lookup::adl_class_fns): Include all
	namespace-scope friends.

gcc/testsuite/ChangeLog:

	* g++.dg/lookup/koenig16.C: New test.
2025-11-03 21:32:26 +03:00
Jason Merrill
3ce8734508 c++/modules: import confict with builtin
27_io/headers/iostream/synopsis.cc was failing with modules because pushdecl
called update_binding for a redeclared import while passing the built-in
clog as "old".  This could also be fixed by discarding the builtin in
e.g. import_module_binding, but this seems straightforward.

gcc/cp/ChangeLog:

	* name-lookup.cc (pushdecl): Discard built-in sooner.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/builtin-9_a.C: New test.
	* g++.dg/modules/builtin-9_b.C: New test.
2025-11-03 21:32:26 +03:00
Jason Merrill
5926cc99ae libstdc++: add ADL friends
Since the implementation namespaces __detail and __exception_ptr aren't
exported from std, ADL can't find these functions there.  Adding friend
declarations makes it work.

libstdc++-v3/ChangeLog:

	* include/bits/quoted_string.h: Add ADL friends.
	* libsupc++/exception_ptr.h: Add ADL friend.
2025-11-03 21:32:25 +03:00
Tobias Burnus
28d20a591d libgomp.fortran/omp_target_memset.f90 - Avoid implicit mapping by an uninit size [PR122543]
In OpenMP, pointers are implicitly mapped - which means for Fortran that
their pointer target is also mapped. However, for uninitialized memory,
this means that some random pointee with some random amount of memory is
copied - in the good case, size == 0, but if not, odd things can happen.

Solution: Use 'fptr => null()' before the target mapping or - as done here -
declare the pointer inside the region.

libgomp/ChangeLog:

	PR libgomp/122543
	* testsuite/libgomp.fortran/omp_target_memset.f90: Move fptr inside
	the target to avoid implicit mapping of its uninit pointee.
	* testsuite/libgomp.fortran/omp_target_memset-2.f90: Likewise.
2025-11-03 18:30:07 +01:00
Jason Merrill
237a83da19 libstdc++: adjust std module TBB workaround
Messing with macros before possibly importing the stdc++.h header unit is
bad form; better to mess with (other) macros afterward.

libstdc++-v3/ChangeLog:

	* src/c++23/std.cc.in: Move TBB macro shenanigans after
	bits/stdc++.h.
2025-11-03 18:55:06 +03:00
Jason Merrill
eaf6b40f76 libstdc++: remove cassert from stdc++.h
<cassert> isn't suitable for a header unit, because by design it depends on
the user NDEBUG macro.  So let's not include it in <bits/stdc++.h>.

libstdc++-v3/ChangeLog:

	* include/precompiled/stdc++.h: Remove <cassert>.
	* testsuite/util/exception/safety.h: Add <cassert>.
	* testsuite/17_intro/headers/c++1998/stdc++_assert_neg.cc:
	Don't define _GLIBCXX_NO_ASSERT.
2025-11-03 18:55:06 +03:00
Jason Merrill
725ce34b6c libstdc++: add attributes to more ios_base types
In r15-3499 I added attributes to _Ios_Openmode to avoid -Wswitch false
positives; let's do the same for the other enums in ios_base.

It also seems to me that with these attributes, the tests don't need to
include the end/max/min cases.

libstdc++-v3/ChangeLog:

	* include/bits/ios_base.h: Add attribs to _Ios_Fmtflags,
	_Ios_Iostate, _ios_seekdir.
	* testsuite/27_io/ios_base/types/fmtflags/case_label.cc: Remove
	unneeded cases.
	* testsuite/27_io/ios_base/types/iostate/case_label.cc: Likewise.
	* testsuite/27_io/ios_base/types/openmode/case_label.cc: Likewise.
	* testsuite/27_io/ios_base/types/seekdir/case_label.cc: Likewise.
2025-11-03 18:55:06 +03:00
Jason Merrill
9f428ffbd4 c++: modules, clones, and overload resolution
21_strings/basic_string_view/cons/wchar_t/3.cc was failing with import std
because as in the reduced testcase, the module includes an instantiation of
the template constructor for <const char *, const char *>, and importing the
module was wrongly adding that instantiation to CLASSTYPE_MEMBER_VEC, so it
became part of the overload set independent of its template.
tsubst_function_decl doesn't add to CLASSTYPE_MEMBER_VEC, and importing
should work the same.

gcc/cp/ChangeLog:

	* module.cc (trees_in::decl_value): Don't add an instantiation to
	CLASSTYPE_MEMBER_VEC.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/clone-5_a.C: New test.
	* g++.dg/modules/clone-5_b.C: New test.
2025-11-03 17:51:38 +03:00
Jason Merrill
ca55458128 c++: modules and deprecated namespaces
20_util/rel_ops.cc was failing because the gcm didn't represent
[[deprecated]] on a namespace.  Are there any other attributes we're
missing?

gcc/cp/ChangeLog:

	* module.cc (module_state::write_namespaces): Handle
	TREE_DEPRECATED.
	(module_state::read_namespaces): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/namespace-15_a.C: New test.
	* g++.dg/modules/namespace-15_b.C: New test.
2025-11-03 17:51:38 +03:00
Thomas Schwinge
7a25badc5d Fix 'libgomp.c/pr122281.c' for non-USM offloading execution [PR122281]
... where it currently runs into:

    libgomp: cuCtxSynchronize error: an illegal memory access was encountered

... for nvptx, or similarly for GCN:

    Memory access fault by GPU node-1 (Agent handle: 0x34d77290) on address 0x7fff3c553000. Reason: Page not present or supervisor privilege.

Fix-up for commit r16-4961-ge2cbcd1b27c0da92bdcd96664064d3d0c1d44e6f
"Fix gimple_copy for OpenMP atomic load/store [PR122281, PR105001]".

	PR libgomp/122281
	libgomp/
	* testsuite/libgomp.c/pr122281.c: Fix for non-USM offloading
	execution.
2025-11-03 15:29:11 +01:00
Piotr Trojanek
85b6344379 ada: Guard compile-time evaluator against rewritten if-expressions
A hopefully temporary fix for if-expression that has been rewritten into an
if-statement, where a object reference has the if-statement as its parent,
but is not part of the condition, then statements or else statements.

gcc/ada/ChangeLog:

	* exp_util.adb (Get_Current_Value_Condition): Guard against orphaned
	references in rewritten if-expressions.
2025-11-03 15:15:18 +01:00
Eric Botcazou
fd7b43f5f4 ada: Restore alignment check for address clause given with alignment clause
The alignment check for address clauses had historically been performed
universally by GNAT, until a decade ago when it was disabled by default
on non-strict-alignment platforms.

This seems questionable when an alignment clause is also given for the
entity since the intent is clear, so the change restores it as well as
its associated warning.

Moreover, this alignment check had historically been subsumed into the
language-defined Range_Check, until two decades ago when it became the
implementation-defined Alignment_Check, while still being part of the
Range_Check to ease the transition.  Now is probably a good time to cut
the apron strings and make Alignment_Check standalone.

gcc/ada/ChangeLog:

	* doc/gnat_rm/representation_clauses_and_pragmas.rst (Address
	Clauses): Adjust description of alignment checks.
	* sem_ch13.adb (Address_Clause_Check_Record): Remove now unused
	Alignment_Checks_Suppressed component.
	(Alignment_Checks_Suppressed): Delete.
	(Analyze_Attribute_Definition_Clause) <Attribute_Alignment>: Do not
	consider the status of range checks to decide whether to generate an
	alignment check.  Always generate it if an alignment clause is also
	given for the entity.
	<Attribute_Alignment>: Generate an alignment check if an address
	clause is also given for the entity.
	(Register_Address_Clause_Check): Adjust for above removal.
	(Validate_Address_Clauses): Test the Check_Address_Alignment flag
	on the clause to decide whether to give the warning.
	* gnat_rm.texi: Regenerate.
	* gnat_ugn.texi: Regenerate.
2025-11-03 15:15:18 +01:00
Eric Botcazou
c22f8e1c41 ada: Adjust outdated reference in comment
The Apply_Alignment_Check procedure no longer exists.

gcc/ada/ChangeLog:

	* checks.adb (Apply_Address_Clause_Check): Adjust self-reference in
	the opening comment.
2025-11-03 15:15:18 +01:00
Piotr Trojanek
efa7ec80d9 ada: Decouple compile-time evaluation from while loop source locations
The compile-time evaluation relied on source locations to decide whether a
variable reference occurs within a WHILE loop where the evaluation can
assume the loop condition. Now this relies exclusively on the AST structure.

gcc/ada/ChangeLog:

	* exp_util.adb (Find_In_Enclosing_Context): Refactor from handling of
	IF statements.
	(Get_Current_Value_Condition): Reuse IF code for WHILE statements.
2025-11-03 15:15:18 +01:00
Piotr Trojanek
48d09de92b ada: Decouple compile-time evaluation from if_statement source locations
The compile-time evaluation relied on source locations to decide whether a
variable reference occurs within an IF statement where the evaluation can
assume the IF condition. This was unreliable, especially for rewritten and
internally generated IF statements, whose End_Span is typically left as zero.

This patch makes the evaluation exclusively dependent on the AST structure
itself, while the source location and the span of an if statement is only used
in assertion.

gcc/ada/ChangeLog:

	* exp_util.adb (Get_Current_Value_Condition): Rewrite to not rely on
	Sloc and End_Span of an if statement.
2025-11-03 15:15:18 +01:00
Piotr Trojanek
4d98d5e454 ada: Preserve AST structure when copying tree with discrete types
When copying AST we created an orphaned copy of a scalar range. This was
confusing the compile-time evaluator, because we couldn't determine location of
a scalar range within an IF statement by looking at its parenthood chain.

gcc/ada/ChangeLog:

	* sem_util.adb (Update_Semantic_Fields): Preserve tree structure when
	copying scalar range of a discrete type.
2025-11-03 15:15:18 +01:00
Piotr Trojanek
0c320ec602 ada: Keep source locations for inlined subprograms from predefined units
Frontend inlining, which is now deprecated and only enabled with switch -gnatN
is used, used to reset source locations for subprograms from predefined units.
This was a workaround to prevent the debugger from visiting internal code in
Ada.Tags, but this problem no longer occurs (even when switch -gnatN is used)
and is no longer needed. This patch removes it, because it confused
compile-time evaluation, which makes use of source locations to recognize code
within IF statements.

gcc/ada/ChangeLog:

	* inline.adb (Process_Sloc): Remove.
2025-11-03 15:15:17 +01:00
Eric Botcazou
2671814409 ada: Fix box accepted as second association of a generic formal package
The syntax is plain invalid because a box can be accepted as a positional
parameter only in the first place.

gcc/ada/ChangeLog:

	PR ada/61127
	* sem_ch12.adb (Associations.Match_Positional): Remove the always
	false condition that guards the error on a positional box.
2025-11-03 15:15:17 +01:00
Gary Dismukes
4ff0bd5f98 ada: Crash on call to a dispatching op with if_expr and tag-indeterminate calls
The compiler can crash with a Storage_Error for a failed precondition
when compiling a call to a dispatching subprogram where an actual for a
controlling formal is given by an if_expression whose dependent expressions
are tag-indeterminate calls.  This problem showed up on a build of Alire
(on the compilation of alire-roots.adb) done during a build_gnat_world
mailserver (as well as having been noticed and reported separately by
another engineering team).

The code in Sem_Disp.Check_Dispatching_Call for checking nondispatching
procedure calls for actuals that are calls to abstract tag-indeterminate
functions did not account for conditional expressions, and attempted to
retrieve the (nonexistent) Expression field from an N_If_Expression node,
failing the precondition for Expression.  It was discovered that none of
the code checking for illegal calls to abstract tag-indeterminate functions
in procedure calls is needed, and the whole related "elsif" part is removed
by this change.  (Note that there is separate checking done separately
within Check_Dispatching_Call that will catch nondispatching calls to
abstract functions.)

gcc/ada/ChangeLog:

	* sem_disp.adb (Check_Dispatching_Call): Remove "elsif" that does error
	checking for abstract tag-indeterminate calls (seems to be no longer
	needed).
2025-11-03 15:15:17 +01:00
Marc Poulhiès
2c77eeb8d8 ada: Fix another incorrectly nested procedure
When unnesting a loop, its body is moved inside a procedure, and inner
entities have their scope adjusted. The current GNAT Tree at this stage
is incoherent wrt scope information, and some nested entities are
incorrectly scoped, possibly leading to a crash of the unnester.

The existing Fixup_Inner_Scopes procedure has been added to adjust the
incoherences after the fact because fixing them earlier has proven to be
more complex than expected. This change adds one more adjustment by this
procedure for TSS (Type Support Subprogram) that may be embedded within
N_Freeze_Entity nodes.

gcc/ada/ChangeLog:

	* exp_ch7.adb (Fixup_Inner_Scopes): Adjust to handle N_Freeze_Entity nodes.
	* exp_unst.adb (Get_Level): Assert when the function didn't find the
	nested level (indicates that inner sub has scope pointing higher in
	the stack)
2025-11-03 15:15:17 +01:00
Ronan Desplanques
e818a8e8bf ada: Tweak Is_Predefined_File_Name
This patch extends the set of names recognized by
Is_Predefined_File_Name so that names that start with "a-" and are longer
than 12 characters are considered predefined.

This is motivated by the need to make gprname work with the in-tree
a-strunb__shared.ads file that uses GNAT syntax extensions but whose name
wasn't considered predefined before this patch.

gcc/ada/ChangeLog:

	* fname.adb (Is_Predefined_File_Name): Tweak.
2025-11-03 15:15:17 +01:00
Bob Duff
39ba3bb913 ada: Get rid of Sy/Sm mixing (Expression)
We should not mix "syntactic" and "semantic" for the same field
in different node kinds.

The Expression field was both syntactic (in N_Exception_Declaration) and
semantic (in all other node kinds). This patch makes it always
syntactic.

Expression is the last such field, so we remove all code and comments
that allowed for such mixing.

The Expression field in N_Exception_Declaration was never properly
documented; fix that.

No change in overall compiler behavior.

An alternative would be to change the name of this Expression
field to be something else (Exception_Declaration_Expression?),
and keep it as "semantic". That would cause an earthquake in gigi,
because gigi wants to treat exception declarations more-or-less
like normal object declarations, with the Expression field being
the initialization expression. So we don't do that.

gcc/ada/ChangeLog:

	* gen_il-gen-gen_nodes.adb (N_Exception_Declaration):
	Change Expression from Sm to Sy, to match other Expression fields.
	* gen_il-gen.adb (Setter_Needs_Parent):
	Expression no longer needs to be a special case.
	(Check_For_Syntactic_Field_Mismatch):
	Do not exempt Expression from the Sy/Sm mixing rule.
	This was the last such case, so remove all the exemption code.
	* gen_il-gen.ads: Update comments to match new code.
	* sinfo.ads (N_Exception_Declaration):
	Document the meaning of the Expression field, because it
	doesn't follow from the RM syntax of exception_declaration.
	* exp_ch11.adb: Minor comment fixes.
2025-11-03 15:15:17 +01:00
Eric Botcazou
d5c0cf67b5 ada: Reject nonconfirming size clauses on objects of floating-point types
The RM 13.1(7/5) subclause contains the following sentences: "If the size
of an object is greater than that of its subtype, the additional bits are
padding bits. For an elementary object, these padding bits are normally
read and updated along with the others."

GNAT implements it only for objects of integer and fixed-point types.
For objects of floating-point types, the padding bits are ignored (and
therefore not initialized) with a warning:

  warning: 32 bits of "F" unused [enabled by default]

Implementing it for objects of floating-point types does not seem worth the
hassle, so rejecting nonconfirming size clauses is probably the cleanest
approach (clauses giving the object a size lower than that of its subtype
are already rejected for objects of floating-point types).

gcc/ada/ChangeLog:

	* sem_ch13.adb (Analyze_Attribute_Definition_Clause)
	<Attribute_Size>: Tweak wording of existing error message for the
	size of all elementary objects.  Move error handling for aliased
	objects into the block for objects and give a similar error for
	(nonaliased) floating-point objects.
2025-11-03 15:15:17 +01:00
Piotr Trojanek
1c484bd921 ada: Fix spurious check on 'Put_Image for an array of characters
gcc/ada/ChangeLog:

	* exp_attr.adb (Rewrite_Attribute_Proc_Call)<Attribute_Put_Image>:
	Fix call to Analyze.
2025-11-03 15:15:17 +01:00
Piotr Trojanek
fbdaed53ea ada: Remove workaround for a freezing issue with address of a slice
Rewriting of an address of a slice, e.g. "X (Low .. High)'Address" into an
address of an indexed component, e.g. "X (Low)'Address", was only done as a
workaround for some freezing issue. Apparently this freezing issue is now
solved and the rewriting is causing problems for GNATprove. (This rewriting,
if needed, should be rather done in expansion and not resolution.)

gcc/ada/ChangeLog:

	* sem_attr.adb (Resolve_Attribute): Remove rewriting of a slice
	address expression.
2025-11-03 15:15:17 +01:00
Viljar Indus
43ce88299a ada: Fix Put_Image for Multiway_Trees
Put_Image should start printing the tree from the Root instead
of the First_Child.

gcc/ada/ChangeLog:

	* libgnat/a-cbmutr.adb (Put_Image): Fix the condition and starting point
	for printing the tree.
	* libgnat/a-cimutr.adb (Put_Image): Likewise.
	* libgnat/a-comutr.adb (Put_Image): Likewise.
2025-11-03 15:15:17 +01:00
Viljar Indus
6a331103e7 ada: Avoid Ignored ghost code behavior in Codepeer_Mode
When the frontend is called by it should treat all ghost
code as checked. Avoid removing expansion in ignored ghost code regions
when Codepeer_Mode is active.

gcc/ada/ChangeLog:

	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Avoid disabling
	the expander for ignored ghost regions if Codepeer_Mode is active.
	* sem_ch7.adb (Analyze_Package_Body_Helper): Likewise.
	* freeze.adb (Freeze_Entity): Avoid triggering special freezing
	action for entities within ignored ghost regions in Codepeer_Mode.
2025-11-03 15:15:16 +01:00
Viljar Indus
a740ac2bf8 ada: Avoid triggering ghost context errors on prefixed names
Errors for ghost incompatibilities of qualified names should not
be applied to prefixes but rather only the final selector.

gcc/ada/ChangeLog:

	* ghost.adb (Is_Ok_Context): consider ghost prefix to always
	be a valid ghost context.
2025-11-03 15:15:16 +01:00
Denis Mazzucato
f5836f73b1 ada: Direct attribute definition for constructors
This patch introduces the 'Constructor attribute and implements its direct
attribute definition syntax within subprogram specification. This new shorthand
avoids having to come up with an arbitrary subprogram name and to type out the
constructor aspect. Before, constructors where defined through the aspect
Constructor, which has been removed.

Furthermore, this patch prepares for the expansion of direct attribute
definitions to other attributes.

gcc/ada/ChangeLog:

	* errout.adb (Set_Msg_Node): Support N_Attribute_Reference and
	nodes that denotes direct attribute definitions.
	* exp_dbug.ads: Description for the encoding of direct attribute
	definitions as tick are hard to deal in entity names.
	* erroutc.adb
	(Set_Msg_Insertion_Name): Replace underscore between prefix and
	attribute name in direct attribute definitions; at this point we
	lost the semantic information of node type and we resort to match
	the string name as described in exp_dbug.adb.
	* exp_aggr.adb (Convert_To_Positional): Use Needs_Construction and
	Has_Default_Constructor.
	* exp_ch3.adb (Build_Record_Init_Proc)
	(Expand_N_Object_Declaration): Likewise.
	* exp_attr.adb (Expand_N_Attribute_Reference): Likewise.
	* exp_ch4.adb (Expand_N_Allocator): Likewise.
	* exp_ch6.adb
	(Prepend_Constructor_Procedure_Prologue): Use
	Is_Constructor_Procedure.
	(Make_Parent_Constructor_Call): Use
	Direct_Attribute_Definition_Name.
	* gen_il-fields.ads: Remove Constructor_List and Constructor_Name.
	* gen_il-gen-gen_entities.adb: Likewise.
	* einfo.ads (Needs_Construction): Add description.
	(Has_Delayed_Aspects): Adjust indentation.
	* par-ch13.adb (P_Attribute_Designators): Parse attribute
	designators.
	(P_Representation_Clause): Use P_Attribute_Designators.
	* par-ch6.adb (P_Subprogram): Support attribute designators in
	subprogram name.
	(Rewrites_Entity_If_Direct_Attribute_Def): Fix the specification
	node in case of direct attribute definitions.
	* par-endh.adb (Check_End, Same_Label): Likewise.
	* par.adb (P_Attribute_Designators): Specification.
	* sem_attr.adb (Analyze_Attribute): Error when using 'Constructor
	outside procedure specification.
	(Analyze_Attribute): Add error handling code.
	* sem_ch3.adb (Analyze_Aspect_Specifications): Likewise.
	* sem_ch6.adb (Analyze_Direct_Attribute_Definition): Handle direct
	attribute definitions. Add error handling code for the
	'Construction attribute and set constructor flags when necessary.
	(Analyze_Subprogram_Specification): Use
	Analyze_Direct_Attribute_Definition.
	* sem_util.adb (Direct_Attribute_Definition_Name): Name of
	entities created for direct attribute definitions. We emit an
	error if multiple attributes.
	(Is_Direct_Attribute_Subp_Spec): Helper to check whether a
	subprogram specification is a direct attribute definition.
	(Is_Constructor_Procedure): Helper to check whether a subprogram
	is a constructor procedure.
	(Has_Default_Constructor): Check whether the default constructor
	exists.
	(Default_Constructor): Not used anymore.
	(Parameter_Count): Likewise.
	(Process_End_Label): Get_Attribute_Reference_Name_String encodes
	also direct attribute definition end labels.
	* sem_util.ads: Likewise.
	* snames.ads-tmpl: Support for 'Constructor attribute.
	* snames.adb-tmpl (Is_Direct_Attribute_Definition_Name): Helper to
	check attributes allowed in direct attribute definitions.
	* aspects.ads: Remove constructor aspect.
	* sem_ch13.adb: Likewise.
2025-11-03 15:15:16 +01:00
Eric Botcazou
987d94ebf0 ada: Tidy up code dealing with visibility in instances of formal packages
The actuals for parameters of formal packages are visible in the instance
if the formal packages either are declared with a box or contain defaulted
parameters.  This is essentially implemented in Check_Generic_Actuals and
Restore_Private_Views, with the help of the Is_Visible_Formal flag.

This documents more prominently the processing and streamlines it, as well
as removes a couple of questionable calls to Set_Is_Hidden, thus plugging
a couple more loopholes in the implementation.

gcc/ada/ChangeLog:

	PR ada/122161
	* sem_ch12.adb: Improve the description of Check_Generic_Actuals,
	Restore_Private_Views and Switch_View, and alphabetize them.
	(Check_Generic_Actuals): Make actuals visible only if needed.
	(Install_Formal_Packages): Pass exact Is_Formal_Box parameter and
	remove call to Set_Is_Hidden.
	(Instantiate_Formal_Package): Use Next_Non_Pragma consistently in
	the loop computing the visibility of actuals.
	(Analyze_Package_Instantiation): Use named second parameter in the
	call to Restore_Private_Views.
	(Analyze_Subprogram_Instantiation): Likewise.
	(Instantiate_Package_Body): Likewise and for Check_Generic_Actuals.
	(Instantiate_Subprogram_Body): Likewise.
	(Restore_Env): Replace call to Restore_Private_Views.
	(Restore_Private_Views): Remove default value for second parameter
	and test of presence for first parameter.  Consistently clear the
	Is_Potentially_Use_Visible flag when setting the Is_Hidden flag.
	Remove call to Set_Is_Hidden for a formal package of the enclosing
	generic unit, if any.
2025-11-03 15:15:16 +01:00
Bob Duff
256263b1d9 ada: Get rid of Sy/Sm mixing (Actions)
We should not mix "syntactic" and "semantic" for the same field
in different node kinds.

The Actions field is both syntactic and semantic. This patch
makes it always syntactic.

No change in overall compiler behavior.

gcc/ada/ChangeLog:

	* gen_il-gen.adb (N_Short_Circuit):
	Make Actions syntactic.
	(N_Case_Expression_Alternative): Likewise.
	* gen_il-gen-gen_nodes.adb (Create_Type):
	No longer exempt Actions from the syntactic/semantic ordering rule.
	(Check_For_Syntactic_Field_Mismatch):
	No longer exempt Actions from the syntactic/semantic mixing rule.
	* sinfo.ads (N_Compound_Statement):
	Add comment.
2025-11-03 15:15:16 +01:00
Marc Poulhiès
3b28ad158e ada: Remove outdated comment
The comment has been documenting a 'Present(S)' that has been long
gone (>17y).

gcc/ada/ChangeLog:

	* sem_aux.adb (Enclosing_Dynamic_Scope): Remove comment.
2025-11-03 15:15:16 +01:00
Bob Duff
7a6df736e1 ada: Get rid of unused node/entity fields (neither set nor get)
The following fields are not used in GNAT nor in any of its clients.
Neither the setters nor the getters are called.

    Node fields:
        Do_Storage_Check
        Enclosing_Variant
        Handler_List_Entry
        Is_Subprogram_Descriptor
        Renaming_Exception
        Default_Expression

    Entity fields:
        Is_Unimplemented

This patch removes all of them.

gcc/ada/ChangeLog:

	* einfo.ads: Remove unused fields.
	* gen_il-fields.ads: Likewise.
	* gen_il-gen-gen_entities.adb: Likewise.
	* gen_il-gen-gen_nodes.adb: Likewise.
	* sinfo.ads: Likewise.
	* gen_il-gen.adb (Compile): Remove obsolete comment.
2025-11-03 15:15:16 +01:00
Ronan Desplanques
96ac78a1b9 ada: Add missing runtime procedure for CHERI
A recent patch added a procedure in the spec of System.Stream_Attributes
but failed to add the corresponding body in the CHERI-specific body of
this package. This patch fixes this.

gcc/ada/ChangeLog:

	* libgnat/s-stratt__cheri.adb (W_80IEEE): New procedure.
2025-11-03 15:15:16 +01:00
Ronan Desplanques
ebfc39db7f ada: Move constant declaration
This patch reduces the scope of a recently introduced variable because
it was much larger than it needed to be.

gcc/ada/ChangeLog:

	* libgnat/s-stratt.adb (W_80IEEE): Make constant local.
2025-11-03 15:15:16 +01:00
Bob Duff
280d165843 ada: Get rid of unused node/entity fields (Set_ only)
The following fields are Set_ but not used in GNAT. We get rid of them
or document them as follows:

    - Has_Pragma_Controlled
	Remove.
    - Corresponding_Entry_Body
	Document that it is used by codepeer.
    - Is_Activation_Record
	Document that it is used by llvm.
    - Is_Discriminant_Check_Function
	Document that it is used by codepeer.
    - Original_Access_Type
	No change (already documented that it is used by codepeer).

gcc/ada/ChangeLog:

	* einfo.ads (Has_Pragma_Controlled): Remove.
	(Is_Activation_Record): Document usage by llvm.
	* gen_il-fields.ads (Opt_Field_Enum):
	Remove Has_Pragma_Controlled.
	* gen_il-gen-gen_entities.adb (Access_Kind):
	Remove Has_Pragma_Controlled.
	* sem_prag.adb:
	Remove setting of Has_Pragma_Controlled.
	* sinfo.ads (Corresponding_Entry_Body):
	Document usage by codepeer.
2025-11-03 15:15:15 +01:00
Alexandre Oliva
77691b9ff5 ada: Add ctor call after address clause
An object initialized by a C++-imported constructor call has the
constructor function call transformed into a procedure call, and the
call is inserted after the object declaration.

If the object has say an address clause, that transformation separates
the declaration from the address clause, causing the translation of
the call to fail.

Keep such clauses next to the declaration by inserting the constructor
procedure call after them.

gcc/ada/ChangeLog:

	* exp_ch3.adb (Expand_N_Object_Declaration): Insert ctor call
	after representation clauses.
2025-11-03 15:15:15 +01:00
Bob Duff
966d132b0a ada: Remove exception handler in Check_Vanishing_Fields
Check_Vanishing_Fields calls Same_Node_To_Fetch_From, which was calling
Node_To_Fetch_From, which will raise an exception (as it should) on
..._Type_Only fields if called early (when the Base_Type,
Implementation_Base_Type, or Root_Type has not yet been set).
Other exceptions can also be raised when Check_Vanishing_Fields
is called early.

An exception handler was used to ignore any such exceptions. That was
correct, but it is annoying in gdb with "catch exception". (Note that
efficiency doesn't matter much, because Check_Vanishing_Fields is not
done in production mode.)

We now call Node_To_Fetch_From_If_Set, remove other potential raises,
and remove the now-unnecessary exception handler.

Note that other calls to Node_To_Fetch_From will still raise an
exception (as they should) for such "early" calls.

gcc/ada/ChangeLog:

	* atree.adb (Same_Node_To_Fetch_From):
	Use Node_To_Fetch_From_If_Set, and remove handler.
	* einfo-utils.adb (Root_Type_If_Set):
	Return Empty if Base_Type_If_Set returns Empty.
	Return Empty if we find Etype (T) = Empty.
	(Underlying_Type): Use "Has_Non_Limited_View..." instead
	of "Present (Non_Limited_View...)", because the latter raises
	an exception when given the wrong Ekind.
2025-11-03 15:15:15 +01:00
Ronan Desplanques
3e7ea99b43 ada: Make Long_Long_Float'Write deterministic
On some platforms, Long_Long_Float'Size (and Long_Long_Float'Stream_Size)
is 128 but only 80 bits are effectively used. This pack makes it so
'Write in this case write zeros for the padding bits instead of
unspecified values.

gcc/ada/ChangeLog:

	* gen_il-fields.ads (Is_IEEE_Extended_Precision): New flag.
	* gen_il-gen-gen_entities.adb: Likewise.
	* gen_il-internals.adb (Image): Likewise.
	* treepr.adb (Image): Likewise.
	* einfo.ads: Document new flag.
	* cstand.adb (Copy_Float_Type, Register_Float_Type): Use new flag.
	* libgnat/s-stratt.ads (W_80IEEE): New procedure.
	* libgnat/s-stratt.adb (W_80IEEE): Likewise.
	* exp_strm.adb (Get_Primitives): Select new procedure when
	appropriate.
	* rtsfind.ads: Register new runtime procedure.
	* sem_ch3.adb (Build_Derived_Numeric_Type,
	Analyze_Subtype_Declaration): Propagate new flag.
2025-11-03 15:15:15 +01:00
Eric Botcazou
2c7a70ef2d ada: Fix incorrect static string concatenation with null left string
It comes from the implementation of an optimization for static concatenation
in Resolve_String_Literal, which causes the original subtype of the literal
to be lost.  Now this subtype must be preserved in the case where the left
operand of the concatenation may be null, per the 4.5.3(5) subclause.

gcc/ada/ChangeLog:

	PR ada/122160
	* sem_res.adb (Resolve_Op_Concat_Rest): Do not build the subtype of
	the second operand again if it has already been built.
	(Resolve_String_Literal): Do not defer the creation of the subtype
	for the right operand of a concatenation whose left operand may be
	the null string.
2025-11-03 15:15:15 +01:00
Gary Dismukes
64a6f143a1 ada: Remove dependence on secondary stack for type with controlled component
There are cases where GNAT introduces a dependence on the secondary stack
in a build-in-place function with a result subtype that is definite, when
this dependence could be avoided.  In particular this is done for record
types that requires finalization due to having a controlled component.

At one time such functions required the secondary stack in order to
properly handle cases where the function might raise an exception
(to avoid improper finalization in the caller), but that is no longer
necessary.  We remove the dependence of these functions on the SS,
along with the BIPalloc formal and the generation of the big if_statement
that uses that formal.

An additional small change is to revise the condition for determining when
to generate SS mark/release within functions.

gcc/ada/ChangeLog:

	* exp_ch6.ads (Make_Build_In_Place_Call_In_Allocator): Simplify comment.
	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Remove obsolete
	comment about not being able to allocate fixed-size controlled results
	on the caller side, and replace another obsolete comment with a simpler
	comment. Call Build_Allocate_Deallocate_Proc when the function doesn't
	need a BIPalloc formal to ensure that function results with controlled
	parts allocated on the caller side will be chained for finalization.
	(Make_Build_In_Place_Call_In_Object_Declaration): Call Needs_BIP_Collection
	on the function's Entity_Id rather than the function call.
	(Needs_BIP_Collection): If a BIP function doesn't need a BIPalloc formal
	then it doesn't need a BIP collection either; return False in that case.
	(Needs_BIP_Alloc_Form): Remove test of Needs_BIP_Collection.
	* exp_ch7.adb (Expand_Cleanup_Actions): Move test of Uses_Sec_Stack
	to be the first conjunct in setting of Needs_Sec_Stack_Mark, and put
	the other tests in a disjunction subsidiary to that. Improve preceding
	comment.
2025-11-03 15:15:15 +01:00
Bob Duff
cc2a4ebe88 ada: Get rid of Sy/Sm mixing (Default_Expression)
We should not mix "syntactic" and "semantic" for the same field
in different node kinds.

Change the name of Default_Expression (a syntactic field) on
N_Formal_Object_Declaration to be Expression. This avoids
the conflict with the name-named semantic field of
N_Parameter_Specification.

It is also more uniform with other syntactic categories that
use default_expression in the syntax rules.  See, for example,
COMPONENT_DECLARATION in sinfo.ads, which is presumably intended
to be uniform with OBJECT_DECLARATION.

Fix the comment on N_Formal_Object_Declaration to refer
to the new field name Expression.

gcc/ada/ChangeLog:

	* gen_il-gen-gen_nodes.adb: Rename Default_Expression to be
	Expression.
	* gen_il-gen.adb (Check_For_Syntactic_Field_Mismatch): Do not
	exempt Default_Expression from the rule.
	* par-ch12.adb (P_Formal_Object_Declarations): Use renamed setter.
	* sem_ch12.adb (Default): Use renamed getter.
	(Analyze_Formal_Object_Declaration): Likewise.
	* sprint.adb (Sprint_Node_Actual): Use renamed getter.
	* sinfo.ads: Fix comments.
2025-11-03 15:15:15 +01:00