Back in r78875 mrs added cpp_get_path/dir accessors for _cpp_file in order
to interface with the darwin framework system. But now I notice that the
latter duplicates the better-named _cpp_get_file_dir, and I'm inclined to
rename the former to match.
Perhaps we should drop the initial underscore since these are no
longer internal interfaces; OTOH, _cpp_hashnode_value and
_cpp_backup_tokens still have the initial underscore in cpplib.h.
libcpp/ChangeLog:
* include/cpplib.h (cpp_get_path, cpp_get_dir): Remove.
(_cpp_get_file_path, _cpp_get_file_name, _cpp_get_file_stat)
(_cpp_get_file_dir): Move prototypes from...
* internal.h: ...here.
* files.cc (_cpp_get_file_path): Rename from...
(cpp_get_path): ...this.
(cpp_get_dir): Remove.
gcc/ChangeLog:
* config/darwin-c.cc (find_subframework_header): Use
_cpp_get_file_*.
Rework dump_cselib_table to not crash when cselib_preserved_hash_table
is not allocated, and to remove the extraneous indirection from
dump_cselib_val that made it inconvenient to call from a debugger.
for gcc/ChangeLog
* cselib.cc (dump_cselib_val): Split out of and rename to...
(dump_cselib_val_ptr): ... this.
(dump_cselib_table): Adjust. Skip cselib_preserved_hash_table
when not allocated.
Since we may delete stores that are found to be redundant in
postreload cse, we need cselib to invalidate argument stores at calls,
and to that end we need CALL_INSN_FUNCTION_USAGE to mention all MEM
stack space that may be legitimately modified by a const/pure callee,
i.e., all arguments passed to it on the stack.
When ACCUMULATE_OUTGOING_ARGS, each on-stack argument gets its own
usage information, but when it's not, each argument is pushed
incrementally, without precomputed stack slots.
Since we only mentioned such precomputed stack slots in
CALL_INSN_FUNCTION_USAGE, non-ACCUMULATE_OUTGOING_ARGS configurations
miss the stack usage data, and cselib fails to invalidate the stores.
Stores in such slots are anonymous, and they often invalidate other
anonymous slots, even part of the same object, but as the testcase
demonstrates, we may occasionally be unlucky that consecutive calls
have the stores to multi-word objects reordered by scheduling in such
a way that the last store for the first call survives the call in the
cselib tables, and then it is found to be redundant with the first
store for the subsequent call, as in the testcase.
So, if we haven't preallocated outgoing arguments for a call (which
would give us preassigned stack slots), and we have used any stack
space, add function call usage covering the entire stack range where
arguments were stored.
for gcc/ChangeLog
PR rtl-optimization/122947
* calls.cc (expand_call): Add stack function usage in
non-ACCUMULATE_OUTGOING_ARGS configurations.
for gcc/testsuite/ChangeLog
PR rtl-optimization/122947
* gcc.dg/pr122947.c: New.
When computing an address plus a large offset on riscv64 with a
PC-relative sequence, we may hit the range limit for auipc and get a
relocation overflow, where on riscv32 the computation wraps around.
Since -mcmodel=medany requires the entire program to fit in a 2GiB
address range, a +/-1GiB+ offset added to an in-range symbol in a
barely-fitting program is more likely than not to be out-of-range.
Since such large constants are unlikely to come up by chance, separate
them from the symbol so as to avoid the relocation overflow.
for gcc/ChangeLog
PR target/91420
* config/riscv/riscv.cc (riscv_symbolic_constant_p): Require
offsets smaller than +/- 1GiB for PCREL symbols.
for gcc/testsuite/ChangeLog
PR target/91420
* gcc.target/riscv/pr91420.c: New.
If the reducer is a function and the accumulator type isn't constrained,
at runtime the reduction will likely raise a Constraint_Error since the
reducer is repeatedly assigned to the accumulator variable (likely changing
its length). However, if the reducer is a procedure, no such assignment
occurs, and thus the runtime error only depends on the reducer logic.
This patch prevents the spurious warning in that case.
gcc/ada/
* sem_attr.adb (Resolve_Attribute): Check if the reducer is a
procedure before giving the warning.
Just a minor update to Dimitar's patch for the RISC-V testcase.
The cfi directives are not emitted for the -elf configurations causing the new
test to fail. The cfi directives (and associated labels) don't seem relevant
to the test at hand, so this just drops them.
Pushing to the trunk.
PR rtl-optimization/122675
gcc/testsuite
* gcc.target/riscv/pr122675-1.c: Adjust expected output.
compile-std1.C was breaking on arm-eabi because these interfaces aren't
declared. So for exporting let's check the same macros that control
declaring them.
libstdc++-v3/ChangeLog:
* src/c++23/std.cc.in: Add more #if.
This is another thing discussed in the 1/9 Reflection thread,
also not dependent on reflection.
decl_attributes calls simple_cst_equal on TREE_VALUEs of the
current and preexisting attributes, but that is just a small
part of how attribute values should be compared.
The following patch fixes that.
2025-12-06 Jakub Jelinek <jakub@redhat.com>
* attribs.cc (decl_attributes): Use attribute_value_equal to
compare attribute values instead of simple_cst_equal.
This has been discussed in the 1/9 Reflection thread, but doesn't depend on
reglection in any way.
cp_parser_std_attribute calls lookup_attribute_spec as:
const attribute_spec *as
= lookup_attribute_spec (TREE_PURPOSE (attribute));
so with TREE_LIST where TREE_VALUE is attribute name and TREE_PURPOSE
attribute ns. Similarly c_parser_std_attribute. And for
attribute_takes_identifier_p those do:
else if (attr_ns == gnu_identifier
&& attribute_takes_identifier_p (attr_id))
and
bool takes_identifier
= (ns != NULL_TREE
&& strcmp (IDENTIFIER_POINTER (ns), "gnu") == 0
&& attribute_takes_identifier_p (name));
when handling std attributes (for GNU attributes they just call those
with the IDENTIFIER_NODE name.
is_late_template_attribute and tsubst_attribute pass to these functions
just get_attribute_name though, so handle attributes in all namespaces
as GNU attributes only, which means that lookup_attribute_spec can
return NULL or find a different attribute if it is not from gnu:: or
say standard attribute mapped to gnu::, or attribute_takes_identifier_p
can return true even for attributes for which it shouldn't.
I thought about changing attribute_takes_identifier_p to take optionally
TREE_LIST, but that would mean handling it in the target hooks too and
they only care about GNU attributes right now, so given the above
parser.cc/c-parser.cc snippets, the following patch just follow
what they do.
2025-12-06 Jakub Jelinek <jakub@redhat.com>
* decl2.cc (is_late_template_attribute): Call lookup_attribute_spec
on TREE_PURPOSE (attr) rather than name. Only call
attribute_takes_identifier_p if get_attribute_namespace (attr) is
gnu_identifier.
* pt.cc (tsubst_attribute): Only call attribute_takes_identifier_p
if get_attribute_namespace (t) is gnu_identifier.
2025-12-06 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122693
* array.cc (gfc_match_array_constructor): Stash and restore
gfc_current_ns after the call to 'gfc_match_type_spec'.
gcc/testsuite
PR fortran/122693
* gfortran.dg/pdt_75.f03: New test.
2025-12-06 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122670
* decl.cc (gfc_get_pdt_instance): Ensure that, in an interface
body, PDT instances imported implicitly if the template has
been explicitly imported.
* module.cc (read_module): If a PDT template appears in a use
only statement, implicitly add the instances as well.
gcc/testsuite
PR fortran/122670
* gfortran.dg/pdt_74.f03: New test.
2025-12-06 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122669
* resolve.cc (resolve_allocate_deallocate): Mold expressions
with an array reference and a constant size must be resolved
for each allocate object.
gcc/testsuite
PR fortran/122669
* gfortran.dg/pdt_73.f03: New test.
2025-12-06 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122578
* primary.cc (gfc_match_varspec): Try to resolve a typebound
generic procedure selector expression to provide the associate
name with a type. Also, resolve component calls. In both cases,
make a copy of the selector expression to guard against changes
made by gfc_resolve_expr.
gcc/testsuite
PR fortran/122578
* gfortran.dg/pdt_72.f03: New test.
From: Mark Zhuang <mark.zhuang@spacemit.com>
The previous commit added --default-prefix to handle non-default git
prefix configurations, but this option is not available in older git
versions. This patch adds a compatibility check.
contrib/ChangeLog:
* prepare-commit-msg: check --default-prefix
Starting with r16-4438-ga93f80feeef744, the edge sorting order was
switched to lowest execution frequency first. But the "bbro"
optimization pass chooses the first edge as a fallthrough. Thus the
most unlikely branches were optimized to fallthroughs.
Fix by restoring the sorting order prior to r16-4438-ga93f80feeef744.
Now the branches most likely to be executed are picked as fallthroughs.
There are no regressions for C and C++ on x86_64-pc-linux-gnu.
The new tests fail for the respective targets without this patch, and
pass with it.
PR rtl-optimization/122675
gcc/ChangeLog:
* bb-reorder.cc (edge_order): Fix BB edge ordering to be
descending.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/pr122675-1.c: New test.
* gcc.target/i386/pr122675-1.c: New test.
* gcc.target/riscv/pr122675-1.c: New test.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
Implement the forwarding performed by std::bind via deducing this when
available, instead of needing 4 operator() overloads. Using deducing
this here is more complicated than in other standard call wrappers
because std::bind is not really "perfect forwarding": it doesn't
consider value category, and along with const-ness it also forwards
volatile-ness (until C++20).
The old implementation suffers from the same problem that other
pre-C++23 SFINAE-friendly call wrappers have which is solved by using
deducing this (see p5.5 of the deducing this paper P0847R7).
PR libstdc++/80564
libstdc++-v3/ChangeLog:
* include/std/functional (__cv_like): New.
(_Bind::_Res_type): Don't define when not needed.
(_Bind::__dependent): Likewise.
(_Bind::_Res_type_cv): Likewise.
(_Bind::operator()) [_GLIBCXX_EXPLICIT_THIS_PARAMETER]:
Define as two instead of four overloads using deducing
this.
* testsuite/20_util/bind/cv_quals_2.cc: Ignore SFINAE
diagnostics inside headers.
* testsuite/20_util/bind/ref_neg.cc: Likewise.
* testsuite/20_util/bind/80564.cc: New test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
When I wrote this testcase I forgot to check if the target
supports __int128. This adds the simple check.
Pushed as obvious after testing the testcase.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr99782-1.c: Require intt128 target.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Register filters are used in one loop of improve_allocation to ignore some
hard regs for cost calculation but it is missed in the subsequent loop
using the costs. This results in usage of random (undefined) register costs
and in sporadic code generation for riscv32 which uses the filters.
gcc/ChangeLog:
PR rtl-optimization/122215
* ira-color.cc (improve_allocation): Use register filter for all
loop on hard regs.
gcc/testsuite/ChangeLog:
PR rtl-optimization/122215
* gcc.target/riscv/pr122215.c: New.
* lib/target-supports.exp (check_effective_target_valgrind): New.
PR fortran/122977
gcc/fortran/ChangeLog:
* expr.cc (gfc_is_simply_contiguous): For an associate variable
check whether the associate target is contiguous.
* resolve.cc (resolve_symbol): Skip array type check for an
associate variable when the target has the contiguous attribute.
gcc/testsuite/ChangeLog:
* gfortran.dg/contiguous_16.f90: New test.
PR libstdc++/120446
libstdc++-v3/ChangeLog:
* include/bits/refwrap.h (__detail::__is_ref_wrapper):
Define as per P2655R3 for C++20.
(__detail::__ref_wrap_common_reference_exists_with): Likewise.
(basic_common_reference): Define partial specializations using
the above as per P2655R3 for C++20.
* include/bits/version.def (common_reference_wrapper): New.
* include/bits/version.h: Regenerate.
* include/std/functional (__glibcxx_want_common_reference_wrapper):
Define.
* testsuite/20_util/reference_wrapper/p2655r3.cc: New test.
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
We implement this paper as a DR against C++20 (as do MSVC and libc++).
PR libstdc++/120446
libstdc++-v3/ChangeLog:
* include/bits/version.def (common_reference): New.
* include/bits/version.h: Regenerate.
* include/std/type_traits (__glibcxx_want_common_reference):
Define.
(__common_reference_impl<T1, T2, 1>): Add pointer convertibility
constraints as per P2655R3.
* testsuite/20_util/common_reference/p2655r3.cc: New test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
... and in passing use requires-clauses instead of void_t based SFINAE.
This is a non-functional change that'll simplify implementing the
P2655R3 change to common_reference.
PR c++/120446
libstdc++-v3/ChangeLog:
* include/std/type_traits (__common_reference_impl): Rewrite
partial specializations to use requires-clause instead of
an additional void_t template parameter. Consolidate the
partial specializations corresponding to bullet 1.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Use deducing this to implement perfect forwarding even in C++20 mode
by using the _GLIBCXX_EXPLICIT_THIS_PARAMETER internal FTM instead of
the standard __cpp_explicit_this_parameter. This fixes the original
testcase from this PR even in C++20 mode.
PR libstdc++/111550
libstdc++-v3/ChangeLog:
* include/std/ranges (views::__adaptor::_Partial::operator())
[_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Also use deducing this
in C++20 mode when possible.
(views::__adaptor::_Pipe::Operator())
[_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Likewise.
* testsuite/std/ranges/adaptors/take.cc (test07): New test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/111327
libstdc++-v3/ChangeLog:
* include/bits/binders.h (_Binder::operator())
[_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Also use deducing this in
C++20 mode when possible.
* testsuite/20_util/function_objects/bind_front/111327.cc:
Expect error inside header even in C++20 mode.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Implement the perfect forwarding required by std::not_fn using deducing
this when available, instead of needing 8 operator() overloads. This
also fixes Jiang An's test from this PR which would be messy to fix in
the old implementation.
PR libstdc++/111327
libstdc++-v3/ChangeLog:
* include/std/functional (_Not_fn::operator())
[_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Define as a single
overload using deducing this.
* testsuite/20_util/function_objects/not_fn/111327.cc: Extend test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
This FTM is like __cpp_explicit_this_parameter but is also defined
in earlier C++ modes if deducing this is supported as an extension
by the compiler. Currently only GCC supports this, Clang doesn't.
libstdc++-v3/ChangeLog:
* include/bits/c++config (_GLIBCXX_EXPLICIT_THIS_PARAMETER):
New.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
There was UB in arm_canonicalize_comparison if it is called with
both operands of type VOIDmode. Avoid this by first handling
floating-point types, then returning if we are left with anything
other than an integer mode. For belt-and-braces also check that
the mode does not require a mask larger than HOST_WIDE_INT.
gcc/ChangeLog:
PR target/122999
* config/arm/arm.cc (arm_canonicalize_comparison): Defer
initializing maxval until we know we are dealing with an
integer mode.
The code assuming that peeling for gaps can be elided by means of
knowing niters and prologue peeling is wrong. Peeling for gaps
means we need an epilog.
* tree-vect-loop.cc (vect_need_peeling_or_partial_vectors_p):
When peeling for gaps we always need an epilog.
The following removes an optimization that wrongly triggers right now
because it accesses LOOP_VINFO_COST_MODEL_THRESHOLD which might not be
computed yet and uses guessed likely max stmt executions.
It also refactors the code to make the default conservative.
PR tree-optimization/120939
* tree-vect-loop.cc (vect_need_peeling_or_partial_vectors_p):
Remove eliding an epilogue based on not computed
LOOP_VINFO_COST_MODEL_THRESHOLD and estimated max stmt executions.
* gcc.dg/torture/pr113026-1.c: Skip when -ftracer.
The following avoids VRP to access the constant initializer.
PR tree-optimization/123002
* gcc.dg/vect/vect-pr123002.c: Make global data non-const
and non-static.
This patch changes a table in the reference manual so that the Ada code
inside is properly highlighted and uses the usual casing conventions.
gcc/ada/ChangeLog:
* doc/gnat_rm/representation_clauses_and_pragmas.rst: Improve table.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
Get_Cursor_Type fails if a classwide container type
is passed to it as it cannot correctly identify the
cursor type since it is expecting the iteration functions
to have a container argument with a classwide container type.
gcc/ada/ChangeLog:
* sem_util.adb (Get_Cursor_Type): use the
specific type for classwide container checks.
It runs afoul of the pragma Initialize_Scalars + -gnatVa combination.
gcc/ada/ChangeLog:
* sem_ch12.adb (Remove_Parent): Only set the Is_Transient component
of the local scope stack entry.
The description of the floating-point overflow behavior is already
documented in other sections: remove the duplication.
This removal also removes confusing/wrong informations
gcc/ada/ChangeLog:
* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(-gnato??): Remove redundant/confusing doc on floating-point
overflow.
* gnat_ugn.texi: Regenerate.
This patch ensures that, during the 'Reduce attribute resolution phase, the
selected reducer subprogram exists, is not ambiguous, and has the proper reducer
profile. Before we could have selected a wrong interpretation.
gcc/ada/ChangeLog:
* sem_attr.adb
(Analyze_Attribute): Set the type of the attribute expression only when
not ambiguous (it will later be resolved correctly). Emit an error in
case the type is limited.
(Resolve_Attribute): Emit an error if the reducer has no entity.
(Get_Value_Subtype): Try to resolve the Value_Subtype of the aggregate
expression, and if it succeeds, set the candidate reducer subprogram.
(Is_Reducer_Subprogram): Check whether the selected candidate has a
proper reducer profile.
(Make_Array_Type): Return simple array type to resolve the array
aggregate against it.
(Resolve_Attribute): Reimplement the resolution of Reduce attribute,
including its prefix.
* sem_res.adb (Resolve_Declare_Expression): Save and restore variables
that may be hidden by the local declaration. Only setting the new
entities is problematic when dealing with copied trees where the ref is
lost (eg. when resolving array aggregates).
* exp_attr.adb (Expand_N_Attribute_Reference): Remove tricks to resolve
the reducer in case of faulty resolution as not needed anymore.
gcc/testsuite/ChangeLog:
* gnat.dg/reduce1.adb: Adjust expected error message.
The following moves the incomplete validity check to use
WIDEN_MULT_{EVEN,ODD} to the caller of supportable_widening_operation
where we have access to more (but not enough) information. I have
made the test conservative enough I hope. For the testcase what was
broken is that it uses a SLP reduction where lane-swizzling isn't
valid.
PR tree-optimization/123002
* tree-vectorizer.h (supportable_widening_operation): Remove
vinfo and stmt_info parameters, add flag to indicate whether
the context would allow OP_{EVEN,ODD}.
* tree-vect-patterns.cc (vect_recog_abd_pattern): Adjust
and pass false.
(vect_recog_widen_op_pattern): Likewise.
(vect_recog_widen_abd_pattern): Likewise.
* tree-vect-stmts.cc (vectorizable_conversion): Move
even/odd validity check here, from supportable_widening_operation.
Adjust it to be conservative.
(supportable_widening_operation): Get flag whether even/odd
is OK to use and remove then unused parameters and code.
* gcc.dg/vect/vect-pr123002.c: New testcase.
The following adds clique/base on __MEM to the GIMPLE parser and
to -gimple dumping.
gcc/c/
* gimple-parser.cc (c_parser_gimple_postfix_expression):
Parse optional clique : base specifier on __MEM.
gcc/
* tree-pretty-print.cc (dump_mem_ref): Dump clique : base
specifier for MEM_REF and TARGET_MEM_REF when dumping
GIMPLE format.
gcc/testsuite/
* gcc.dg/gimplefe-58.c: New testcase.
The generic Posix code does not match the layout of the pthread entities
in the Darwin _pthread_types.h. So, let's make a Darwin-specific version
and use it.
PR ada/115305
gcc/ada/ChangeLog:
* Makefile.rtl: Use s-oslock__darwin instead of the Posix version.
* libgnat/s-oslock__darwin.ads: New file.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>