Robert Dubner [Sat, 20 Jun 2026 01:21:48 +0000 (21:21 -0400)]
cobol: Improve binary conversion from packed-decimal and numeric-display.
There are routines that create GENERIC conversion routines that convert
packed-decimal and numeric-display variables to binary. Some are in
libgcobol, and some have direct GENERIC implementations. All have been
updated to use faster divide-and-conquer algorithms.
The new routines are ten to twenty times faster than the prior versions.
gcc/cobol/ChangeLog:
* genapi.cc (parser_enter_file): Establish a var_decl for the
common packed-decimal to binary conversion table.
* genutil.cc (digit): Divide-and conquer numeric-display converter.
(num_disp_dive): Likewise.
(pd_dive): Divide-and-conqure packed-decimal converter.
(get_pd_value): Likewise.
(get_binary_value_tree): Use the new routines.
(binary_from_FldNumericBinary): Divide-and conquer numeric-display
converter.
* genutil.h: Declaration for var_decl_dp2bin.
* move.cc (mh_little_endian): Allow FldPacked as a source.
libgcobol/ChangeLog:
* charmaps.cc: Eliminate rt_encoding_t.
* libgcobol.cc (console_init): Change how __gg__console_encoding is
established.
(initialize_program_state): Likewise.
(get_binary_value_local): Use new conversion algorithms.
(__gg__move): Likewise.
* stringbin.cc (__gg__numeric_display_to_binary): Likewise.
(digit_rt): Likewise.
(num_disp_dive_rt): Likewise.
(pd_dive_rt): Likewise.
(__gg__packed_to_binary): Likewise.
* stringbin.h (STRINGBIN_H_): Declaration for __gg__dp2bin.
(__gg__numeric_display_to_binary): Use new algorithms.
(__gg__packed_to_binary): Likewise.
Kees Cook [Thu, 18 Jun 2026 19:56:51 +0000 (12:56 -0700)]
c: handle .ACCESS_WITH_SIZE in build_unary_op for !/+/- [PR125604]
PR123569 fixed wrong code with the counted_by attribute on a pointer
member by suppressing creation of the .ACCESS_WITH_SIZE wrapper in the
parser's pre/post-increment paths, and added a checking assertion in
build_unary_op to ensure no .ACCESS_WITH_SIZE call reaches it.
The other rvalue-consuming unary operators (!, -, +) still
rvalue-convert their operand via convert_lvalue_to_rvalue, which
produces the .ACCESS_WITH_SIZE wrapper as before. They then reach
parser_build_unary_op then build_unary_op carrying the wrapper and
trip the assertion. A minimal reproducer:
struct s {
int n;
char *p __attribute__((__counted_by__(n)));
};
int f (struct s *o) { return !o->p; }
Unwrap the .ACCESS_WITH_SIZE call at the top of build_unary_op via
get_ref_from_access_with_size. These unary operators consume the
pointer rvalue rather than the pointed-to data, so the bounds-checking
wrapper is not load-bearing here. The assertion is retained: after
the unwrap it documents the post-condition the rest of the function
relies on.
PR c/125604
gcc/c/ChangeLog:
* c-typeck.cc (build_unary_op): Unwrap .ACCESS_WITH_SIZE
from the operand before further processing.
Andrew Pinski [Thu, 18 Jun 2026 21:16:04 +0000 (14:16 -0700)]
ipa: Don't record return value ranges for pranges with non ipa-invariant [PR125857]
Now that pranges can have invariants in it, we need to make sure the
return value range does not record non-ipa invariants; otherwise we
might prop the address of a local variable from one function to
another.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/125857
gcc/ChangeLog:
* ipa-prop.cc (ipa_record_return_value_range_1): Don't record
pranges which have non ipa-invariants in it.
gcc/testsuite/ChangeLog:
* gcc.dg/pr125857-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Iain Sandoe [Fri, 19 Jun 2026 18:54:53 +0000 (19:54 +0100)]
aarch64: Handle vec_deconstruct in vector_costs code.
r17-1655-g7d351b07e5b85c introduces 'vec_deconstruct' which needs to
be handled in the aarch64_vector_costs::count_ops code, leading to a
bootstrap fail.
gcc/ChangeLog:
* config/aarch64/aarch64.cc
(aarch64_vector_costs::count_ops): Treat vec_deconstruct in the
same way as vec_construct.
Peter Bergner [Thu, 18 Jun 2026 04:33:03 +0000 (04:33 +0000)]
riscv: Change tt-ascalon-d8 to tt-ascalon-x
The Ascalon cpu's official marketing name is Ascalon X. Change the -mcpu=
and -mtune= options to accept tt-ascalon-x as the cpu's canonical name.
Create an alias name so the old option names are still accepted.
2026-06-17 Peter Bergner <bergner@tenstorrent.com>
gcc/
* config/riscv/riscv-cores.def (RISCV_TUNE)<tt-ascalon-d8>: Rename from
this...
(RISCV_TUNE)<tt-ascalon-x>: ...to this.
(RISCV_CORE)<tt-ascalon-d8>: Likewise.
(RISCV_CORE)<tt-ascalon-x>: Likewise.
(RISCV_CORE_ALIAS): Add tt-ascalon-d8 alias for tt-ascalon-x.
* doc/riscv-mcpu.texi: Document the name change.
* doc/riscv-mtune.texi: Likewise.
Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
Peter Bergner [Thu, 18 Jun 2026 04:11:09 +0000 (04:11 +0000)]
riscv: Add support for alias names for cpus
Some cpus are known by multiple names or have their name changed after
support has already been added to GCC. Add support to the riscv port
that allows setting up alternate names or aliases for a cpu's canonical
name.
2026-06-17 Peter Bergner <bergner@tenstorrent.com>
gcc/
* common/config/riscv/riscv-common.cc (struct riscv_cpu_alias_info):
New struct.
(riscv_cpu_alias_table): New.
(riscv_find_cpu): Add support for cpu alias names.
(riscv_get_valid_option_values): Likewise.
Add an early loop exit if we found a duplicate name.
* config/riscv/riscv-cores.def (RISCV_CORE_ALIAS): New macro.
Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
Kanishka Solanki [Fri, 19 Jun 2026 16:25:51 +0000 (21:55 +0530)]
a68: remove redundant HAS_ROWS check from caller side of a68_low_dup
This patch removes redundant caller-side HAS_ROWS checks before calls to
a68_low_dup.
a68_low_dup originally always performed a deep copy, so callers avoided
invoking it for values without rows by checking HAS_ROWS beforehand.
a68_low_dup now performs its own HAS_ROWS check and returns the original
expression unchanged when a deep copy is not required. Remove the
remaining caller-side HAS_ROWS checks, as they are redundant.
gcc/algol68/ChangeLog
* a68-low-clauses.cc (a68_lower_collateral_clause): Do not check
for rows before calling a68_low_dup.
* a68-low-units.cc (collect_call_arguments): Likewise.
Andrew Pinski [Wed, 17 Jun 2026 23:09:40 +0000 (16:09 -0700)]
phiopt: Add support for non-zero offsets for load factoring [PR122193]
This extends the factor_out_conditional_load to support non-zero offsets
for the MEM_REF. And fixes PR 122193.
It tries not to create gimple statements that don't need to be created.
E.g. If the base is the same then it creates the pointer plus in the join
bb rather than the in the middle bbs. Also uses gimple_build for the pointer
plus so that the if one of the offsets was 0, a new statement is not created.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/122193
gcc/ChangeLog:
* tree-ssa-phiopt.cc (factor_out_conditional_load): Support non-zero
offsets.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/factor_op_phi-load-offsets-1.c: New test.
* gcc.dg/tree-ssa/factor_op_phi-load-offsets-2.c: New test.
* gcc.dg/tree-ssa/factor_op_phi-load-offsets-3.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Mon, 15 Jun 2026 05:23:00 +0000 (22:23 -0700)]
phiopt: Allow factoring out loads even if there are stores
This is a small improvement to the code where we allow factoring
out loads even with stores (or calls) before hand, this will allow
for store elimination (store factoring) to happen too.
factor_op_phi-load-stores-1.c is one such example.
Also adds the cost model to factoring out loads.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-phiopt.cc (is_factor_profitable): Change arg_op
to operands and opcount.
(factor_out_conditional_operation): Update call to
is_factor_profitable.
(factor_out_conditional_load): Support when merge has
a virtual phi. The load's vuse needs to be the arguments
to the virtual phi. Call is_factor_profitable on the new phi
arguments. Update the vuse on the new load to the virtual phi.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/factor_op_phi-load-stores-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Fri, 12 Jun 2026 19:52:18 +0000 (12:52 -0700)]
phiopt: Simplified factoring of loads [PR125557]
This is a simplified version that I was mentioning.
It is based on https://gcc.gnu.org/pipermail/gcc-patches/2026-June/720170.html
but only handing in phi-opt. It is able to optimize
what is requested and will not have the regression dealing
with vectorization. There are some more tweaks we can do
to handle some more stuff.
Like before vectorization, if the two pointers are the same we should do
the factoring. Or handling stores before the load which will allow
us to iterate better with cs-elim limited. We can also tweak the
before vectorization cost to be rather based on if it just inside
a loop into what was done in the full patch. For the benchmark improvement
that was not needed.
Changes since v1:
* v2: the factoring needs to be done on a diamond only, and the loads need to
come from the middle bbs.
PR tree-optimization/125557
gcc/ChangeLog:
* tree-ssa-phiopt.cc (factor_out_conditional_load): New function.
(factor_out_all): Call factor_out_conditional_load.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/scc-diamond-1.c: New test.
* gcc.dg/tree-ssa/scc-diamond-3.c: New test.
* gcc.dg/tree-ssa/scc-diamond-4.c: New test.
* gcc.target/aarch64/scc-diamond-2.c: New test.
Eric Botcazou [Tue, 9 Jun 2026 09:11:54 +0000 (11:11 +0200)]
ada: Fix spurious error on Ada 2022 declare expression of limited type
The underlying problem is that declare expressions are implemented by means
of a temporary in most cases and that's incompatible with limited types.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Expression_With_Actions): Create a temporary
only for types that can be copied, and replace the EWA node by its
expression for other types.
* exp_ch6.adb (Expand_Ctrl_Function_Call): Bail out when the parent
is an EWA node.
* sem_ch3.adb (OK_For_Limited_Init_In_05): Recurse on the expression
of an EWA node.
The Build_And_Insert_Type_Attr_Subp procedure sometimes uses the
declaration list of a subprogram body ancestor even when the point of
reference is inside the statement list. Before this patch, this caused
an assertion failure (and a failure to hoist with assertions disabled)
when the declaration list of the body was empty. This patch fixes this.
gcc/ada/ChangeLog:
* exp_attr.adb (Spot, Spot_Kind): New types.
(Build_And_Insert_Type_Attr_Subp, Skip_Non_Source_Subps,
Find_Insertion_Point_For_Ancestor): Handle case of empty body
declaration list.
Eric Botcazou [Fri, 5 Jun 2026 21:24:59 +0000 (23:24 +0200)]
ada: Fix long-standing issue in static accessibility check for allocators
This has been exposed by the latest change made to Resolve_Allocator: the
constraints of a subtype indication are not necessarily given in the same
order as the discriminants of the base type in the source code.
gcc/ada/ChangeLog:
* sem_res.adb (Check_Discriminant_Use): Rename PN local variable as
Par and apply minor formatting tweaks.
(Resolve_Allocator): For the subtype indication form, make sure to
take the constraints of a subtype into account instead of those of
the indication in order to implement the static accessibility check.
Olivier Hainque [Thu, 4 Jun 2026 12:02:23 +0000 (12:02 +0000)]
ada: Straigthen Call_Chain and __gnat_backtrace processing
Work on cross-testsuite/ta20_015__exc_traceback exposed
that calls to GNAT.Traceback.Call_Chain, in some configurations,
yield a first entry within Call_Chain rather than at the
call point.
This is supposed to be controlled by a careful computation
of a number of frames to skip, passed down as the SKIP_FRAMES
parameter to __gnat_backtrace in tracebak.c.
Roughly:
```
subprogramA
calls subprogramB
calls GNAT.TB.Call_Chain (Skip_Frames => 1)
calls System.TB.Chain (Skip_Frames => 2)
calls __gnat_backtrace (skip_frames => 3)
Actual backtrace at this point is
1 __gnat_backtrace
2 System.TB.Call_Chain
3 GNAT.TB.Call_Chain
4 spB
5 spA
Skip the first 3 frames -> return
[spB, spA]
```
Within tracebak.c, the skip operation is influenced
by micro details of the semantics of a BASE_SKIP macro,
which was imprecisely documented.
I first thought the fault was in the value for this macro
in a couple of configurations, while it was entirely elswehere.
There were two issues aside from the BASE_SKIP documentation
(in)accuracy:
1 GNAT.Traceback exposes a Call_Chain procedure and a Call_Chain
function.
The function has a Skip_Frames parameter, with a default value,
and a description of how it operates wrt that parameter.
The procedure doesn't accept a parameter, the spec was imprecise
and the behavior was different from that of the function with
the default parameter value.
2 The way Skip_Frames values propagate down to __gnat_backtrace
require the internal calls within the runtime to materialze as actual
calls (and call frames) at run-time. This requires preventing
inlining and sibling call optimization, which was achieved with
dedicated compilation switches for s-traceb.adb and overlooked
for g-traceb.adb.
This patch addresses these combined points together:
gcc/ada/ChangeLog:
* tracebak.c: Improve documentation of BASE_SKIP.
* libgnat/g-traceb.ads (Call_Chain procedure): Clarify the
expected behavior wrt Call_Chain itself.
* libgnat/g-traceb.adb (Call_Chain procedure): Propagate
a Skip_Frames value to System.TB.Call_Chain accordingly.
* libgnat/libgnat.gpr: Use the same special switches for
g-traceb.adb as for s-traceb.adb.
* Makefile.rtl: Likewise.
* libgnat/s-traceb.adb: Reword top comment on the need
to prevent optimizations. No need to specify how to do it
here.
Eric Botcazou [Sun, 7 Jun 2026 20:30:56 +0000 (22:30 +0200)]
ada: Fix missing names for 'Image of enumeration type
This is a freezing issue introduced by the recent coupling of assertions and
Ghost mode, which are supposed to use different paths in the freezing code.
In light of this, it appears to be wise to undo the coupling and restore the
clear separation between the two different mechanisms. The price to pay is
the loss of the "assertion would fail at run time" warning for non-static
assertions that are disabled (it is still present for static assertions),
which seems to be an acceptable trade-off to avoid nasty freezing issues.
gcc/ada/ChangeLog:
* expander.adb (Expand): Revert latest change.
* ghost.adb (Set_Ghost_Mode): Likewise.
* sem_ch3.adb (Analyze_Subtype_Declaration): Also copy the RM size
for floating-point types.
* sem_prag.adb (Analyze_Pragma) <Pragma_Check>: Do not mark the
pragma as Ghost when expander is active and the pragma is ignored.
Preanalyze it instead of analyzing it, and rewrite it as a null
statement at the end of the processing.
Init_Or_Norm_Scalars was a global variable used to store the boolean
disjunction of two other global variables. This patch replaces it with
an expression function to make things simpler.
Restructure mem_ref_hasher::equal so the non-decomposed fallback
and the decomposed comparison path are explicit. The non-decomposed
lookup still compares the original refs with operand_equal_p, while
the decomposed path keeps the same base, offset, size, max_size,
volatile, alias-set, and type checks as before. This matches the split
in gather_mem_refs_stmt, where non-decomposed references are marked
with an unknown max_size and decomposed references are hashed from
base, offset, and size.
* tree-ssa-loop-im.cc (mem_ref_hasher::equal): Refactor
for clarity.
Arsen Arsenović [Fri, 19 Jun 2026 09:13:21 +0000 (11:13 +0200)]
gcc/doc: Move @anchor-s referring to top of node after their @node
Previously, the anchors would end up generating redirects to the end of
unrelated nodes, rather than to the start of nodes we intended to
target. This fixes that.
gcc/ChangeLog:
* doc/extend.texi: Move @anchor-s referring to tops of nodes
after their corresponding @node lines.
* doc/invoke.texi: Ditto.
Reported-by: Alexander Monakov <amonakov@ispras.ru>
Eric Botcazou [Thu, 18 Jun 2026 09:08:39 +0000 (11:08 +0200)]
Adjust configure machinery to abi32 targets
The machinery would still consider them as 64-bit targets in a few cases.
gcc/
* acinclude.m4 (gcc_GAS_FLAGS): Set to --32 for abi32 targets.
* configure.ac (TLS support): Use 32-bit sequence for abi32 targets.
* configure: Regenerate.
Eric Botcazou [Wed, 17 Jun 2026 08:07:41 +0000 (10:07 +0200)]
Fix wrong optimization of array manipulation at -O2 or above
This occurs when the array is declared in a subprogram and manipulated from
within a second subprogram nested in the first: in this case, the array is
allocated in the special frame structure of the first subprogram as a field
with the DECL_NONADDRESSABLE_P flag set if the TREE_ADDRESSABLE flag is not
set for the original array variable. But the array may contain addressable
(sub)components whose address can be taken, thus fooling the computation of
alias sets when strict aliasing is enabled.
The fix is in keeping with the usage of DECL_NONADDRESSABLE_P on fields of
record types by the Ada compiler, which is the main user of both the flag
and the machinery implemented in the tree-nested.cc file.
gcc/
* tree-nested.cc (lookup_field_for_decl): In the non-pointer case,
clear DECL_NONADDRESSABLE_P if the DECL is of an aggregate type.
gcc/testsuite/
* gnat.dg/opt108.adb: New test.
* gnat.dg/opt108_pkg.ads, gnat.dg/opt108_pkg.adb: New helper.
[PATCH] match: Optimize bit_ior/bit_and {bit_not} rshift to min/max [PR125641]
Fold x | (x >> (TYPE_PRECISION (type) - 1)) to max (x, -1)
Fold x | (~ (x >> (TYPE_PRECISION (type) - 1))) to min (x, -1)
Fold x & (x >> (TYPE_PRECISION (type) - 1)) to min (x, 0)
Fold x & (~ (x >> (TYPE_PRECISION (type) - 1))) to max (x, 0)
Bootstrapped and tested on x86_64-pc-linux-gnu
PR tree-optimization/125641
gcc/ChangeLog:
PR tree-optimization/125641
* match.pd: Add bit_ior/bit_and {bit_not} rshift to min/max.
gcc/testsuite/ChangeLog:
PR tree-optimization/125641
* gcc.dg/pr125641.c: New test.
Léo Hardt [Tue, 9 Jun 2026 01:59:40 +0000 (22:59 -0300)]
clean: Removed orphaned comments from deleted imports.
Hello!
This patch removes comments that used to refer to imports, which
were deleted in some import clean-ups that happened years ago.
I did a brief tour of the code and did not notice any other such
orphaned comment.
For convenience of reviewing, here are the links to the mentioned
commits. Notice that these diffs created the orphaned comments.
- For ddg.h:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=60393bbc
- For sel-sched-ir.h:
gcc.gnu.org/git/?p=gcc.git;a=commit;h=c7131fb
- For trans-intrinsic, objc-act, objc-encoding:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=69f293c
As for testing, I don't think comments could affect the target
binary, but I have nevertheless successfully bootstrapped gcc
with these changes applied.
gcc/ChangeLog:
* ddg.h (GCC_DDG_H): Removed orphaned comment from 60393bbc
* sel-sched-ir.h (GCC_SEL_SCHED_IR_H): Removed orphaned comment from c7131fb
gcc/fortran/ChangeLog:
* trans-intrinsic.cc: Removed orphaned comment from 69f293c
gcc/objc/ChangeLog:
* objc-act.cc: Removed orphaned comment from 69f293c
* objc-encoding.cc: Removed orphaned comment from 69f293c
Milan Tripkovic [Thu, 18 Jun 2026 23:51:59 +0000 (17:51 -0600)]
[PATCH] PR tree-optimization/125405: Missed optimization: mask/sub sign-extension idiom not canonicalized to sign extension
This patch implement new pattern for match.pd that recognize the
sign-extension idiom (x & low_bits) - (x & sign_bit) and tests that covers it.
Pattern is based on conversation from bug report.
TRUNK riscv output:
sext8_hd:
andi a5,a0,127
andi a0,a0,128
sub a0,a5,a0
ret
sext16_hd:
slli a5,a0,49
li a4,32768
srli a5,a5,49
and a0,a0,a4
sub a0,a5,a0
ret
NEW riscv output:
sext8_hd:
slliw a0,a0,24
sraiw a0,a0,24
ret
sext16_hd:
slliw a0,a0,16
sraiw a0,a0,16
ret
TRUNK x86 output:
"sext8_hd":
mov rax, rdi
and edi, 128
and eax, 127
sub rax, rdi
ret
"sext16_hd":
mov rax, rdi
and edi, 32768
and eax, 32767
sub rax, rdi
ret
new x86 output:
sext8_hd:
movsbq %dil, %rax
ret
sext16_hd:
movswq %di, %rax
ret
PR target/125405
gcc/ChangeLog:
* match.pd: New pattern added.
gcc/testsuite/ChangeLog:
* gcc.dg/pr125405-bitint.c: New test.
* gcc.dg/tree-ssa/pr125405.c: New test.
* gcc.target/riscv/pr125405.c: New test.
Jeff Law [Thu, 18 Jun 2026 22:56:31 +0000 (16:56 -0600)]
[RISC-V] Split X eq/ne C where -C is a small constant
This was something I found while analyzing paths forward for a patch from
Daniel.
Amazingly, RISC-V does not have anything like a setCC style insn that compares
a register against a constant. Instead we negate the constant and add it to
the source value. That gives us zero (equal) or nonzero (not equal). We
follow that with a snez/seqz to give us 0/1 like other setCC style
instructions.
If we have a 3 or more insns that ultimately combine into something like:
(set (dest) (eq (srcreg) (const_int))
We can use a define_split to rewrite that into a two instruction sequence which
is a small win. I'd suspected there was some value in this kind of splitter
for a while, but never had a testcase that could actually be improved. I wrote
the splitter and tested with Daniel's code, but more importantly, once I had
the basic splitter working, I could do a before/after comparison and look for
differences which I was able to find.
While the testcase came from 502.gcc, it's not hot at all. But it does clearly
show how the splitter can improve code.
Tested on riscv32-elf and riscv64-elf. Bootstraps on the K3 and c920 are in
flight. I'll wait for the bootstrap/regression tests as well as the pre-commit
CI testing before moving forward.
gcc/
* config/riscv/riscv.md (splitter for equality test): New splitter.
gcc/testsuite/
* gcc.target/riscv/test-equal.c: New test.
Thomas Schwinge [Mon, 11 May 2026 20:07:13 +0000 (22:07 +0200)]
libgomp: Prototype "accel" 'GOMP_INDIRECT_ADDR_MAP', 'GOMP_INDIRECT_ADDR_HMAP' in 'target-indirect.h'
..., instead of repeating 'extern' prototypes in all "accel" 'team.c' files
for 'GOMP_INDIRECT_ADDR_MAP' vs. no prototype for 'GOMP_INDIRECT_ADDR_HMAP',
as done in commit da5803c794d16deb461c93588461856fbf6e54ac
"libgomp: Init hash table for 'indirect'-clause of 'declare target' on the host [PR114445, PR119857]".
Thomas Schwinge [Mon, 11 May 2026 19:58:30 +0000 (21:58 +0200)]
libgomp: Prototype "accel" 'build_indirect_map' in new 'target-indirect.h'
..., instead of repeating 'extern' prototypes in all "accel" 'team.c'
files, as done in commit a49c7d3193bb0fd5589e12e725f5a130725ae171
"openmp: Add support for the 'indirect' clause in C/C++".
Thomas Schwinge [Mon, 11 May 2026 19:42:11 +0000 (21:42 +0200)]
libgomp: '#include "libgomp.h"' in 'libgomp/target-indirect.c'
..., as libgomp implementation files generally do. This gets us
'#include "libgomp_g.h"', which contains the prototype for
'GOMP_target_map_indirect_ptr'. Minor fix-up for
commit a49c7d3193bb0fd5589e12e725f5a130725ae171
"openmp: Add support for the 'indirect' clause in C/C++".
Thomas Schwinge [Mon, 11 May 2026 14:07:43 +0000 (16:07 +0200)]
libgomp: Drop unused 'ialias'es from 'libgomp/oacc-init.c'
They've always been unused, and, curiously, no 'ialias'es had ever gotten
added for any other 'libgomp/oacc-[...].c' files. Minor fix-up for
Subversion r219682 (Git commit 41dbbb3789850dfea98dd8984f69806284f87b6e)
"Merge current set of OpenACC changes from gomp-4_0-branch".
For no good reason, libgomp/GCN currently compiles the "full" (host)
'oacc-parallel.c', instead of the empty "accel" one. Minor fix-up for
Subversion r278132 (Git commit b3d14b3aa343eb7fc656e7f4d3c9b2dc04be63be)
"Move generic libgomp files from nvptx to accel", which moved other files
from 'libgomp/config/nvptx/' to 'libgomp/config/accel/'.
Paul Iannetta [Thu, 6 Oct 2022 14:34:00 +0000 (16:34 +0200)]
Make 'gcc/tree.h:ENCODE_QUAL_ADDR_SPACE' safer to use
As pointed out by Paul Iannetta in his
"[RFC] c++: parser - Support for target address spaces in C++". Fix-up for
Subversion r153572 (Git commit 09e881c9e21a9209b2092e400ea4c38948614f78)
"Named address spaces: core middle-end support".
Jerry DeLisle [Fri, 12 Jun 2026 01:50:37 +0000 (18:50 -0700)]
fortran: [PR125535] Plug remaining leak in implied-do array constructor with allocatable components
Follow-up to the PR fortran/125535 wrong-code fix (commit 1b8421e9d5b,
already pushed): that fix corrected the *values* produced by an
implied-do array constructor of derived-type function results with
allocatable components, but left a separate memory leak in the same
code path.
An array constructor whose implied-do produces function results of a
derived type with allocatable components moves each result into the
constructor temporary, so the temporary owns those components. The
per-element finalization in gfc_trans_array_ctor_element only freed
the single slot referenced by the final loop offset, leaking the
allocatable components of every other element the loop produced.
A whole-array sweep is the only way to free every slot written by an
implied-do, but it may be used only when every element is an owned
function result: a variable element is shallow-copied into the
temporary and its components are aliased rather than owned, so freeing
them would double free. Add gfc_constructor_is_owned_alloc_comp to
detect the all-owned case and, when it holds, suppress the per-element
finalization and emit a single gfc_deallocate_alloc_comp_no_caf over
the whole temporary.
PR fortran/125535
gcc/fortran/ChangeLog:
* trans-array.cc (gfc_constructor_is_owned_alloc_comp): New function.
(gfc_trans_array_constructor_value): Add OWNED_SWEEP parameter and,
when set, suppress the per-element finalization. Pass it through the
recursive call.
(trans_array_constructor): Compute OWNED_SWEEP and, when set,
deallocate the allocatable components of the whole temporary in one
sweep.
gcc/testsuite/ChangeLog:
* gfortran.dg/asan/implied_do_alloc_comp_leak_1.f90: New test.
Thomas Koenig [Sun, 14 Jun 2026 06:43:00 +0000 (08:43 +0200)]
Mark variables in references for variable definition context as used.
Code like "a(i) = 42" would not mark i as used, leading to false
positives for warnings with -Wunused-but-set-variable. This is fixed
in the attached patch. It also removes some default arguments to
make sure that the caller side provides correct information.
Robert Dubner [Thu, 18 Jun 2026 15:25:57 +0000 (11:25 -0400)]
cobol: Improved MOVE routines.
Faster routine for converting numeric-display numerical strings to
binary values. Improved conversion of binary values to big-endian
COMP-4 values.
gcc/cobol/ChangeLog:
* cbldiag.h (current_program_index): Suppress cppcheck warning.
(struct cbl_loc_t): Likewise.
* genutil.cc (get_depending_on_value_from_odo): Check subscript
against occurs-depending-on value.
(get_data_offset): Likewise.
(digit): Fast string-to-binary routine.
(num_disp_dive): Likewise.
(get_binary_value_tree): Likewise.
(copy_little_endian_into_place): Move the function to move.cc.
(get_location): Normalize use of "data" pointer versus using the
address of a known variable.
* genutil.h (copy_little_endian_into_place): Remove declarations.
* move.cc (get_reference_to_data): Eliminate function.
(mh_identical): Simplify the logic that uses get_location.
(copy_little_endian_into_place): Use the routine for both little-
and big-endian targets. Take absolute value of signed inputs when
the target is unsigned.
(mh_little_endian): Handle both little- and big-endian targets.
* symbols.cc (cbl_alphabet_t::cbl_alphabet_t): Suppress
cppcheck warning.
backprop: Don't try to delete default defs [PR125872]
In this PR, -fno-tree-dce meant that backprop was presented with code
that was completely dead. The pass's internal DCE then tried to delete
the function parameter's definition.
Andrew MacLeod [Wed, 17 Jun 2026 20:51:15 +0000 (16:51 -0400)]
Do not invoke a different range query from within fold_stmt.
fold_using_range works on a specified range_query object. IF this
object is not the current_range_query (cfun) object, do not invoke
the general gimple fold routines as they may call into the current
query.
PR tree-optimization/125854
gcc/
* gimple-range-fold.cc (fold_using_range::fold_stmt): Check if the
range_query matches the current one before invoking fold.
Marek Polacek [Wed, 17 Jun 2026 18:20:53 +0000 (14:20 -0400)]
c++: simplify condition in check_initializer
This condition has become unwieldy and hard to read.
In <https://gcc.gnu.org/pipermail/gcc-patches/2026-June/720712.html>
I tried to factor it out into a separate function but it works to
just drop the complicated inner disjunction. I ran the testsuite
checking if we exercise the case where the new and old conditions
evaluate to different values and many tests triggered that.
gcc/cp/ChangeLog:
* decl.cc (check_initializer): Don't call
build_aggr_init_full_exprs for {} of an aggregate.
Martin Jambor [Thu, 18 Jun 2026 12:55:33 +0000 (14:55 +0200)]
ipa-cp: Fix ipa-vr intersection in wrong type (PR124128)
Function ipa_vr_intersect_with_arith_jfunc in ipa-cp.cc contains a
check
if (src_type == dst_type)
which should have been
if (operation_type == dst_type)
which lead to an ICE in the ranger machinery as it tried to intersect
a signed and an unsigned integer when compiling the testcases from
PR124128.
The condition itself is basically an early exit to avoid calling yet
another ipa_vr_operation_and_type_effects to type-convert the value
range when we already can simply compare the types and see we already
have the righ thing. A better place for it is however just before
that conversion, where it can also avoid the call when dealing with
the most simple of pass-through jump functions (and where it generally
"makes more sense") so this is what the patch does.
gcc/ChangeLog:
2026-06-04 Martin Jambor <mjambor@suse.cz>
PR ipa/124128
* ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Move the check if
the final type conversion needs to happen before the conversion.
Martin Jambor [Thu, 18 Jun 2026 12:17:14 +0000 (14:17 +0200)]
fortran: Fix UBSAN error member access within null pointer (PR125860)
With UBSAN instrumented compiler, compiling the testcase
gfortran.dg/altreturn_5.f90 at -O3 fails with:
/home/worker/buildworker/ubsan/build/gcc/fortran/interface.cc:4717:27: runtime error: member access within null pointer of type 'struct gfc_expr'
This patch adds the necessary guard to avoid passing an invalid LOC to
gfc_value_set_and_used even when the EXPR parameter is NULL and the
function will just return. I have left the NULL-check in
gfc_value_set_and_used intact so that the behavior of the function is
consistent with gfc_value_used_expr (and possibly other functions).
gcc/fortran/ChangeLog:
2026-06-16 Martin Jambor <mjambor@suse.cz>
PR fortran/125860
* interface.cc (gfc_procedure_use): Check a->expr is not NULL before
calling gfc_value_set_and_used.
Richard Biener [Tue, 12 May 2026 12:48:41 +0000 (14:48 +0200)]
use recorded vector composition type for costing
We're making vector construction extra costly but too much
because we up to now do not know the actual vector composition
type used. This makes use of this now available information.
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
Use vector construction scaling also for mult-lane
VMAT_STRIDED_SLP but use vector composition type recorded
to avoid excessive over-costing.
Richard Biener [Wed, 13 May 2026 12:14:19 +0000 (14:14 +0200)]
Split out ix86_vector_cd_cost
This implements costing of vector construction and decomposition
to a custom (possibly vector) element type to be used for vectorizer
costing of the corresponding operations when dealing with
VMAT_STRIDED_SLP loads and stores.
* config/i386/i386.cc (ix86_vector_cd_cost): New function,
enhanced and split out from ...
(ix86_default_vector_cost): ... here.
Richard Biener [Wed, 17 Jun 2026 11:19:56 +0000 (13:19 +0200)]
Add vec_deconstruct costing kind
The following adds vec_decostruct to replace nunits * vec_to_scalar
which allows for more precise costing whenever vectorization
needs to decompose a vector to pieces, like for emulated gather/scatter
but also for strided [SLP] loads/stores.
This requires changes across targets, both for the different kind
but also for the difference in expected count. For now this adjusts
them all to handle vec_deconstruct like vec_construct to avoid ICEing.
Richard Biener [Wed, 13 May 2026 12:22:01 +0000 (14:22 +0200)]
Also record ls element type for costing
I've realized that on x86 we get vector types as vector composition
element types, so just recording the ls_type isn't enough to
realize we're constructing a V4SI from V2SI elements. The following
adds such a field.
* tree-vectorizer.h (vect_load_store_data::ls_eltype): New field.
* tree-vect-stmts.cc (vectorizable_load): Record ltype
as ls_eltype for VMAT_STRIDED_SLP.
(vectorizable_store): Likewise.
Eric Botcazou [Fri, 5 Jun 2026 19:55:29 +0000 (21:55 +0200)]
ada: Fix missing accessibility check for allocator with access discriminant
This implements the last part of the RM 4.8(10.1) rule about allocators
for types with access discriminants. The implementation is modeled on
that of returns for types with access discriminants, given that the set
of rules applying to them is the same (RM 3.10.2(12-12.4)).
The change also streamlines the latter by applying the RM 3.10.2(12.4)
rule in Apply_Accessibility_Check_For_Discriminated_Return.
Piotr Trojanek [Wed, 6 May 2026 14:48:46 +0000 (16:48 +0200)]
ada: Support new Modifies contract for SPARK
Basic support for a new contract. References to SPARK RM will be completed once
the contract is documented there. Legality checks for modified objects being
outputs need to be completed as well (or implemented in GNATprove).
All the code is copied and adapted from the Subprogram_Variant aspect, just
like with other contracts for SPARK, but with notable differences: this
contract requires a dedicated parsing and has no expansion. Currently it is
only supported as an aspect, despite having a corresponding pragma (which is
required to handle it like other contracts).
gcc/ada/ChangeLog:
* aspects.ads (Aspect_Id, Implementation_Defined_Aspect,
Aspect_Argument, Is_Representation_Aspect, Aspect_Names, Aspect_Delay):
Add new aspect and its basic characteristics.
* contracts.adb (Add_Contract_Item,
Analyze_Entry_Or_Subprogram_Contract,
Analyze_Entry_Or_Subprogram_Body_Contract,
Analyze_Subprogram_Body_Stub_Contract): Handle new aspect.
* contracts.ads (Add_Contract_Item,
Analyze_Entry_Or_Subprogram_Contract,
Analyze_Entry_Or_Subprogram_Body_Contract,
Analyze_Subprogram_Body_Stub_Contract): Likewise.
* doc/gnat_rm/implementation_defined_aspects.rst (Aspect Modifies):
Document new aspect.
* doc/gnat_rm/implementation_defined_pragmas.rst (Pragma Modifies):
Document corresponding pragma.
* einfo-utils.adb
(Get_Pragma): Handle new pragma
* einfo-utils.ads
(Get_Pragma): Likewise.
* inline.adb (Remove_Aspects_And_Pragmas): Handle new pragma.
* par-ch13.adb (P_Modifies_Specification): Parse special aspect syntax.
(Get_Aspect_Specifications): Parse new aspect.
* par-prag.adb (Prag): Temporarily accept new pragma.
* sem_ch12.adb (Implementation of Generic Contracts): Update list of
supported contracts.
* sem_ch13.adb (Analyze_One_Aspect, Analyze_Aspect_Specifications,
Check_Aspect_At_Freeze_Point): Analyze new aspect.
* sem_ch8.adb (In_Abstract_View_Pragma): Abstract states can appear in
new contract.
* sem_prag.adb (Contract_Freeze_Error, Ensure_Aggregate_Form): Update
list of supported contracts.
(Analyze_Modifies_In_Decl_Part, Analyze_Pragma): Analyze new pragma.
(Sig_Flags): Support new pragma.
* sem_prag.ads (Aspect_Specifying_Pragma, Assertion_Expression_Pragma,
Pragma_Significant_To_Subprograms, Find_Related_Declaration_Or_Body):
Handle new pragma.
(Analyze_Modifies_In_Decl_Part): Analyze new pragma.
* sem_util.adb, sem_util.ads (Is_Subprogram_Contract_Annotation):
Handle new contract.
* sinfo.ads (Is_Generic_Contract_Pragma, Contract): New contract is
a generic contract.
* snames.ads-tmpl: New contract name and new pragma.
* gnat_rm.texi: Regenerate.
Eric Botcazou [Thu, 4 Jun 2026 13:45:53 +0000 (15:45 +0200)]
ada: Fix missing dynamic accessibility checks for subpool access type
The checks are those prescribed by the RM 13.11.4(24-27) rules, which are
part of dynamic semantics but can be applied statically for the most part.
While the current implementation is incomplete, the fix is straightforward
and mostly boils down to redoing the associated static accessibility checks
of RM 13.11.4(22-23) without too much duplication in the implementation.
gcc/ada/ChangeLog:
* sem_util.ads (Get_Pool_Object_Or_Dereference): New function.
* sem_util.adb (Get_Pool_Object_Or_Dereference): Likewise, mostly
taken from...
* sem_ch13.adb (Analyze_Attribute_Definition_Clause) <Object_From>:
...here.
<Attribute_Storage_Pool>: Call Get_Pool_Object_Or_Dereference.
* exp_ch3.adb (Freeze_Type): Add missing checks of RM 13.11.4(24-27)
and apply them to all regular pools not statically descendants from
Root_Storage_Pool_With_Subpools when its unit has been loaded.
Eric Botcazou [Wed, 3 Jun 2026 21:16:41 +0000 (23:16 +0200)]
ada: Remove obsolete two-pronged implementation of static accessibility checks
For type conversions in instance bodies. It's barely maintainable and the
raise statements are directly inserted for these checks in other contexts.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Type_Conversion): Do not apply again static
accessibility checks in instance bodies.
* sem_res.adb (Valid_Conversion): Insert the raise statements for
the failure of static accessibility checks in instance bodies.
Before this patch, In_Package_Body had two different meanings depending
on whether it was applied to a package or to some other entity. This
extracts the second meaning to a new field, Declared_In_Package_Body, and
ties the maintenance of this field to the Scope field, which actually
becomes a thin wrapper over a new internal Gen_IL field.
A new Gen_IL contract is added to help enforce that In_Package_Body is
now only used with package entities.
One might wonder why the conceptually similar In_Private_Part field is
not given the same treatment. One reason is that it has combined the two
different meanings for much longer than In_Package_Body has, so it's much
more work to categorize the call sites. One other reason is that a change
I have in my pipeline is made possible by just this change to
In_Package_Body.
Also update all call sites that previously used Is_Package_Body_Entity to
use the new Declared_In_Package_Body field, remove Is_Package_Body_Entity,
and make print_node display Scope instead of the internal
Scope_Gen_IL_Private field.
gcc/ada/ChangeLog:
* gen_il-fields.ads (Declared_In_Package_Body): New field.
(Scope): Rename into...
(Scope_Gen_IL_Private): ...this.
* einfo-utils.ads (Scope, Set_Scope): New subprograms.
* einfo-utils.adb (Set_Scope): New subprogram.
* einfo.ads (In_Package_Body): Update documentation.
(Declared_In_Package_Body): Add documentation.
(Is_Package_Body_Entity): Remove.
* fe.h (Scope): New macro.
* gen_il-gen-gen_entities.adb (Gen_Entities): New field.
New contract. Remove Sm (Is_Package_Body_Entity).
* gen_il-gen-gen_nodes.adb (Gen_Nodes): Adapt to renaming.
* gen_il-gen.adb (Compute_Field_Offsets): Adapt to renaming.
* gen_il-internals.adb (Image): Adapt to renaming.
* lib-load.adb, lib.adb: Add with clauses.
* sem_ch3.adb (Analyze_Object_Declaration): Remove field update.
* sem_ch6.adb (Enter_Overloaded_Entity): Likewise.
* sem_util.adb (Collect_Primitive_Operations): Use new field.
(Enter_Name): Replace Is_Package_Body_Entity with
Declared_In_Package_Body.
* treepr.adb (Image): Add F_Scope_Gen_IL_Private alternative
that returns Scope.
* exp_dbug.adb (Is_BNPE): Replace Is_Package_Body_Entity with
Declared_In_Package_Body.
* sem_ch12.adb (Check_Generic_Actuals): Likewise.
* sem_warn.adb (Generic_Package_Spec_Entity): Likewise.
* sem_ch7.adb (Analyze_Package_Body_Helper): Replace
Set_Is_Package_Body_Entity with Set_Declared_In_Package_Body.
Viljar Indus [Wed, 3 Jun 2026 12:15:56 +0000 (15:15 +0300)]
ada: Use correct warning char for unconditional elab warning
Warning messages from Check_Internal_Call_Continue were
not actually conditional on the -gnatwl flag and were
emitted always.
Use the switchless warning character for those messages
and refactor Output_Calls in order to handle all of the
possible warning characters in the continuation messages.
gcc/ada/ChangeLog:
* sem_elab.adb (Output_Calls): Apply correct warning
characeter for each continuation message.
(Check_Internal_Call_Continue): Use regular warning
character in error messages.
Eric Botcazou [Wed, 3 Jun 2026 10:50:58 +0000 (12:50 +0200)]
ada: Fix missing error on formal with access discriminant in allocator and -gnatc
The problem is that the relevant part of the RM 4.8(5.3) rule is implemented
in the expander (the other part being implemented in the analyzer), so this
merges the former with the latter and streamlines the result in the process.
This also tweaks the Accessibility_Level function to make it more robust in
the presence of errors, as well as adjusts the new error message given by
the Check_Return_Construct_Accessibility procedure, which was a mouthful
and not really in keeping with other error messages about accessibility.
gcc/ada/ChangeLog:
* accessibility.adb (Accessibility_Level): Also deal with SAOOAAATs
without extra accessibility object alongside formal parameters.
(Check_Return_Construct_Accessibility): Streamline the error message
and adjust it to expression functions.
* exp_ch4.adb (Expand_Allocator_Expression): Do not perform a static
accessibility check here.
* sem_res.adb (Resolve_Allocator): Streamline the implementation of
the static accessibility check of RM 4.8(5.3), use a more consistent
error message, adjust it to instantiation bodies, and specifically
deal with formal parameters.
ada: Make subprogram insertion code easier to understand
This extracts part of the statement sequence of the
Build_And_Insert_Type_Attr_Subp procedure into a helper function. The
intent is to make it easier to tell when the objects declared inside the
procedure are mutated.
gcc/ada/ChangeLog:
* exp_attr.adb (Skip_Non_Source_Subps): Move before local object
declarations and add formals.
(Build): Move before local object declarations.
(Find_Insertion_Point_For_Ancestor): New local function.
(Build_And_Insert_Type_Attr_Subp): Use new function.
Piotr Trojanek [Tue, 26 May 2026 09:20:20 +0000 (11:20 +0200)]
ada: Fix missing context for class-wide contract expressions
The copies of class-wide pre- and postconditions are now attached to the
original pragma, so that legality checks, like the one for 'Old, can find the
original context of where those expressions appeared.
gcc/ada/ChangeLog:
* sem_attr.adb (Uneval_Old_Msg): Attribute Old never occurs outside of
a pragma.
* sem_ch13.adb (Analyze_One_Aspect): Attach expression copy of a
class-wide aspect to the corresponding pragma.
* sem_prag.adb (Analyze_Pre_Post_Condition): Likewise for a class-wide
pragma.
Eric Botcazou [Sat, 30 May 2026 19:11:44 +0000 (21:11 +0200)]
ada: Fix assertion failure on access to uninitialized package entity
It occurs during the analysis of a generic package declared in a structural
instance of a parent generic package, on accessing the uninitialized entity
of the current semantic unit. But this access is unnecessary because what
happens within an instance does not affect the current semantic unit here.
The change also adds the missing call to Unit_Requires_Body already present
in the generic subprogram case to the generic package case.
gcc/ada/ChangeLog:
* sem_ch12.adb (Analyze_Generic_Package_Declaration): Do not set the
Body_Needed_For_Inlining flag on the current semantic unit if the
package is declared within an instance or does not require a body.
(Analyze_Generic_Subprogram_Declaration): Similarly, do not set the
Body_Needed_For_Inlining flag on the current semantic unit if the
subprogram is declared within an instance.
Javier Miranda [Thu, 28 May 2026 16:58:09 +0000 (16:58 +0000)]
ada: Crash on allocator for tagged object with constructor
This patch fixed a compiler crash when allocating a tagged record
types through class-wide access type.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Allocator): For a class-wide designated
type with a constructor initializer, add a type conversion to
the specific type to avoid a dispatching call (since contructors
are not dispatching primitives).
* sem_ch13.adb (Analyze_Aspect_Specifications)
<Aspect_Initialize>: Avoid reporting a spurious error.
Eric Botcazou [Mon, 25 May 2026 09:22:10 +0000 (11:22 +0200)]
ada: Fix missing error on nonaliased formal with access discriminants in return
The construct must fail the static accessibility check of 6.5(5.9) because
the accessibility level of the anonymous access type of the discriminants
is that of the invocation of the function, which is too deep for a return.
The change also gets rid of the implementation of this check in the routine
Apply_Accessibility_Check_For_Anonymous_Return because 1) this routine is
meant for the corresponding dynamic accessibility check 6.5(21) and, thus,
only invoked when expansion is active, and 2) the check is implemented in
other routines, e.g. Check_Return_Construct_Accessibility for discriminants.
The change also implements the 6.8(5) rule, which is the counterpart of the
6.5(5.9) rule for access discriminants in expression functions.
gcc/ada/ChangeLog:
* accessibility.ads (Check_Return_Construct_Accessibility): Document
that it also implements the 6.8(5) rule.
* accessibility.adb (Accessibility_Message): Remove dead return.
(Apply_Accessibility_Check_For_Anonymous_Return): Do not apply the
static check of 6.5(5.9) here.
(Check_Return_Construct_Accessibility): Do not use "return object"
in the error message. Do not reject synthesized return statements
when the function comes from source to handle expression funtions.
Robustify processing and explicitly deal with formal parameters.
Eric Botcazou [Fri, 29 May 2026 06:34:39 +0000 (08:34 +0200)]
ada: Fix dangling reference with Bounded_Indefinite_Holders and Empty_Holder
The issue is that the finalization of an empty container does not deallocate
its subpool, thus creating a dangling reference to it from the global pool.
gcc/ada/ChangeLog:
* libgnat/a-cbinho.adb (Clear): Deallocate the subpool even if the
container is empty.
Viljar Indus [Thu, 28 May 2026 12:26:12 +0000 (15:26 +0300)]
ada: Fix diagnostics inteneded as continuations
The diagnostic messages fixed here were using the | insertion
character instead of the \ used for continuations. Even though
they were clearly intended to supplement the previous message.
Javier Miranda [Tue, 26 May 2026 16:06:49 +0000 (16:06 +0000)]
ada: Improve error reported for wrong constructor call
This patch improves the error reported when the invoked constructor is
not available. This is a common error because constructors are not
inherited; this means that a constructor for a given tagged type may
not exist for its derived types. Fix also a crash in the initialization
of a limited record type.
gcc/ada/ChangeLog:
* sem_attr.adb (Analyze_Attribute): Report an error when the number
of actual parameters for a constructor do not match any available
constructor.
* exp_ch6.adb (Make_Init_Proc_Call): Add the _Init_Level accessibility
level formal when building a call to the init proc of a limited record
type.
(Prepend_Constructor_Procedure_Prologue): Restrict the initialization
of the _parent component to cases where a Super aspect is present
or a parameterless parent constructor exists.
Marek Polacek [Fri, 12 Jun 2026 15:44:15 +0000 (11:44 -0400)]
c++/reflection: ICE in get_reflection on INDIRECT_REF [PR125759]
We crash here in outer_var_p on:
/* These should have been stripped or otherwise handled by the caller. */
gcc_checking_assert (!REFERENCE_REF_P (decl));
because we never stripped the INDIRECT_REF in get_reflection. I don't
think stripping it only for the outer_automatic_var_p call would be
right so I'm doing it at the top of the function.
PR c++/125759
gcc/cp/ChangeLog:
* reflect.cc (get_reflection): Do STRIP_REFERENCE_REF.
Wang Jinghao [Wed, 17 Jun 2026 15:17:47 +0000 (11:17 -0400)]
c++/reflection: Handle stale parameter decarations in eval_is_explicit_object_parameter
eval_is_explicit_object_parameter() determines whether a parameter is
an explicit object parameter by checking whether the passed-in tree
node is the first parameter in its parameter chain. As described in
the comment for maybe_update_function_parm(), if the sequence is
declaration -> reflection -> definition, the old PARM_DECL will be
compared against the new PARM_DECL, causing the check to produce an
incorrect result.
Calling maybe_update_function_parm() before the comparison updates
the old reflection to the new PARM_DECL in the chain, thereby
avoiding this error.
gcc/cp/ChangeLog:
* reflect.cc (eval_is_explicit_object_parameter): Call
maybe_update_function_parm before checking the parameter
against DECL_ARGUMENTS.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/is_explicit_object_parameter2.C: New test.
Signed-off-by: Wang Jinghao <zheng.xianyuwang@gmail.com> Reviewed-by: Patrick Palka <ppalka@redhat.com>
Antoni Boucher [Fri, 5 Sep 2025 14:32:40 +0000 (10:32 -0400)]
libgccjit: Add gcc_jit_type_is_floating_point
gcc/jit/ChangeLog:
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_38): New ABI tag.
* docs/topics/types.rst: Document gcc_jit_type_is_floating_point.
* libgccjit.cc (gcc_jit_type_is_floating_point): New function.
* libgccjit.h (gcc_jit_type_is_floating_point): New function.
* libgccjit.map: New function.
* libgccjit.exports: New function.
gcc/testsuite/ChangeLog:
* jit.dg/test-reflection.c: Add test for
gcc_jit_type_is_floating_point.
Co-authored-by: Robert Zakrzewski <robert.zakrzewski1@stellantis.com>
Marek Polacek [Fri, 5 Jun 2026 17:42:06 +0000 (13:42 -0400)]
c++: explicit instantiation and noexcept-specifier [PR125613]
This patch implements this part of [except.spec]: In an explicit
instantiation a noexcept-specifier may be specified, but is not required.
If a noexcept-specifier is specified in an explicit instantiation, the
exception specification shall be the same as the exception specification
of all other declarations of that function.
But we are not checking this, and are the only compiler that accepts:
Marek Polacek [Fri, 5 Jun 2026 21:25:36 +0000 (17:25 -0400)]
libstdc++: adjust explicit inst of std::basic_string::data()
r15-2650 removed noexcept from non-const std::basic_string::data()
in bits/cow_string.h, but the explicit instantiations in string-inst.cc
kept their noexcept. [except.spec] says that in an explicit instantiation
a noexcept-specifier may be specified, but is not required, but when it
is specified, it must be the same as the exception specification of all
other declarations of that function. So I think we should just remove it.
Wilco Dijkstra [Wed, 17 Jun 2026 13:32:25 +0000 (13:32 +0000)]
libffi: Update LOCAL_PATCHES
Add commit:
commit 94c5f47d21aa5f144a690189222cc08b86a00505 (origin/master, origin/HEAD)
Author: Muhammad Kamran <muhammad.kamran@arm.com>
Date: Wed Jun 17 13:25:31 2026 +0000
libffi: Mark AArch64 BTI and PAC with build attributes
This is an adapted backport of the BTI/PAC parts of upstream libffi commit 547449d705258ea490aa8787dc084c5b38dbe722, which emits AArch64 feature build
attributes when assembler support is available and keeps the existing GNU
property note as the fallback.
GCC's current libffi copy does not include the upstream GCS support, so
this backport only covers the existing BTI and PAC feature marking.
Muhammad Kamran [Wed, 17 Jun 2026 13:25:31 +0000 (13:25 +0000)]
libffi: Mark AArch64 BTI and PAC with build attributes
This is an adapted backport of the BTI/PAC parts of upstream libffi commit 547449d705258ea490aa8787dc084c5b38dbe722, which emits AArch64 feature build
attributes when assembler support is available and keeps the existing GNU
property note as the fallback.
GCC's current libffi copy does not include the upstream GCS support, so
this backport only covers the existing BTI and PAC feature marking.
libffi/ChangeLog:
* src/aarch64/internal.h (AARCH64_POINTER_AUTH): Rename from
GNU_PROPERTY_AARCH64_POINTER_AUTH.
* src/aarch64/sysv.S (AARCH64_BTI): Rename from
GNU_PROPERTY_AARCH64_BTI.
(GNU_PROPERTY): New macro.
(FEATURE_1_AND_MARK): Likewise.
Emit BTI and PAC feature build attributes when
__ARM_BUILDATTR64_FV is defined.
Muhammad Kamran [Wed, 17 Jun 2026 13:23:56 +0000 (13:23 +0000)]
libitm: Mark AArch64 asm features with build attributes
Emit AArch64 build attributes for BTI and PAC from libitm's hand-written
AArch64 assembly when __ARM_BUILDATTR64_FV is available. Keep the
existing GNU property note emission as the fallback for toolchains that do
not support the new attribute form.
libitm/ChangeLog:
* config/aarch64/sjlj.S (FEATURE_1_AND_MARK): Define. Use
AArch64 build attributes when __ARM_BUILDATTR64_FV is available,
otherwise emit a GNU property note.
Muhammad Kamran [Wed, 17 Jun 2026 13:23:50 +0000 (13:23 +0000)]
libatomic: Mark AArch64 asm features with build attributes
Use AArch64 build attributes to record BTI, PAC and GCS feature bits when
__ARM_BUILDATTR64_FV is available. Fall back to the existing GNU property
note emission otherwise.
libatomic/ChangeLog:
* config/linux/aarch64/atomic_16.S (FEATURE_1_AND_MARK): Define.
Use AArch64 build attributes when __ARM_BUILDATTR64_FV is
available, otherwise emit a GNU property note.
Muhammad Kamran [Wed, 17 Jun 2026 13:23:42 +0000 (13:23 +0000)]
libgcc: Mark AArch64 asm features with build attributes
Emit AArch64 build attributes for BTI, PAC and GCS when
__ARM_BUILDATTR64_FV is available. Keep the existing GNU property note
emission as the fallback for toolchains that do not support the new
attribute form.
libgcc/ChangeLog:
* config/aarch64/aarch64-asm.h (FEATURE_1_AND_MARK): Define.
Use AArch64 build attributes when __ARM_BUILDATTR64_FV is
available, otherwise emit a GNU property note.
Tamar Christina [Wed, 17 Jun 2026 11:09:22 +0000 (12:09 +0100)]
vect: Fix early break in PEELED cases [PR125804]
When a loop is LOOP_VINFO_EARLY_BREAKS_VECT_PEELED && ! LOOP_VINFO_EARLY_BRK_NEEDS_EPILOG
then we still need the epilog loop for the main latch edge.
The early exits themselves when LOOP_VINFO_EARLY_BRK_NEEDS_EPILOG don't need to
go to scalar code.
Allowing bound_epilog to still be set to VF when
LOOP_VINFO_EARLY_BREAKS_VECT_PEELED we get to the desired effect that the early
exits do not require an epilog when !LOOP_VINFO_EARLY_BRK_NEEDS_EPILOG but
the main edge still does if LOOP_VINFO_EARLY_BREAKS_VECT_PEELED.
gcc/ChangeLog:
PR tree-optimization/125804
* tree-vect-loop-manip.cc (vect_do_peeling): Have
LOOP_VINFO_EARLY_BREAKS_VECT_PEELED require epilog.
gcc/testsuite/ChangeLog:
PR tree-optimization/125804
* gcc.dg/vect/vect-early-break_144-pr125804.c: New test.