]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 days agoImprove mergability of CSWTCH [PR120523]
Andrew Pinski [Fri, 25 Jul 2025 23:16:36 +0000 (16:16 -0700)] 
Improve mergability of CSWTCH [PR120523]

When I did r16-1067-gaa935ce40a7, I thought it would be
enough to mark the decl as mergable to get it to merge on
all targets. Turns out a few things needed to be changed
to support it being mergable on all targets.
The first thing is improve the selecting of the mergable
section and instead of basing it on the DECL's mode, it
should be based on the size instead.
The second thing that needed to be happen is change the
alignment of the CSWTCH decl to be aligned to the next power
of 2 compared to the size if the size is less than 32bytes
(the max mergable size that is supported).

With these changes, cswtch-6.c passes on ia32 and other targets.
And the new testcase cswtch-7.c will pass now too.

Note I noticed the darwin's darwin_mergeable_constant_section could
be "fixed" up to use DECL_SIZE instead of the DECL_MODE but I am not
sure it makes a huge difference.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/120523
gcc/ChangeLog:

* output.h (mergeable_constant_section): New declaration taking
unsigned HOST_WIDE_INT for the size.
* tree-switch-conversion.cc (switch_conversion::build_one_array):
Increase the alignment of CSWTCH for sizes less than 32bytes.
* varasm.cc (mergeable_constant_section): Split out twice.
One that takes the size in unsigned HOST_WIDE_INT and the
other size in a tree.
(default_elf_select_section): Pass DECL_SIZE instead of
DECL_MODE to mergeable_constant_section.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/cswtch-7.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 days agoUn-factor vectorizable_load parts
Richard Biener [Mon, 28 Jul 2025 13:04:01 +0000 (15:04 +0200)] 
Un-factor vectorizable_load parts

When the costing refactoring happened we ended up with some strange
inter-mixing of VMAT unrelated code.  The following moves stuff
closer to where it's actually used, at the expense of duplicating
some lines.

* tree-vect-stmts.cc (vectorizable_load): Un-factor VMAT
specific code to their handling blocks.

2 days agoEliminate gather-scatter-info offset_dt member
Richard Biener [Mon, 28 Jul 2025 12:22:44 +0000 (14:22 +0200)] 
Eliminate gather-scatter-info offset_dt member

The following removes this only set member.  Sligthly complicated
by the hoops get_group_load_store_type jumps through.  I've simplified
that, noting the offset vector type that's relevant is that of the
actual offset SLP node, not of what vect_check_gather_scatter (re-)computes.

* tree-vectorizer.h (gather_scatter_info::offset_dt): Remove.
* tree-vect-data-refs.cc (vect_describe_gather_scatter_call):
Do not set it.
(vect_check_gather_scatter): Likewise.
* tree-vect-stmts.cc (vect_truncate_gather_scatter_offset):
Likewise.
(get_group_load_store_type): Use the vector type of the offset
SLP child.  Do not re-check vect_is_simple_use validated by
SLP build.

2 days agoDaily bump.
GCC Administrator [Tue, 29 Jul 2025 00:19:24 +0000 (00:19 +0000)] 
Daily bump.

3 days agoAVR: target/121277 - Don't load 0x800000 with const __flashx *x = NULL.
Georg-Johann Lay [Mon, 28 Jul 2025 19:44:06 +0000 (21:44 +0200)] 
AVR: target/121277 - Don't load 0x800000 with const __flashx *x = NULL.

Converting from generic AS to __flashx used the same rule like
for __memx, which tags RAM (generic AS) locations by setting bit 23.
The justification was that generic isn't a subset of __flashx, though
that lead to surprises with code like const __flashx *x = NULL.

The natural thing to do is to just load 0x000000 in that case,
so that the null pointer works in __flashx as expected.

Apart from that, converting NULL to __flashx (or __flash) no more
raises a -Waddr-space-convert diagnostic.

gcc/
PR target/121277
* config/avr/avr.cc (avr_addr_space_convert): When converting
from generic AS to __flashx, don't set bit 23.
(avr_convert_to_type): Don't -Waddr-space-convert when NULL
is converted to __flashx or to __flash.

3 days agoifcvt: Fix ifcvt for multiple phi nodes after factoring operator [PR121236]
Andrew Pinski [Fri, 25 Jul 2025 20:54:32 +0000 (13:54 -0700)] 
ifcvt: Fix ifcvt for multiple phi nodes after factoring operator [PR121236]

When I added the factor operations to ifcvt, I messed how handling of removing
the phi nodes. The fix is we need to remove the phi node that was factored out
as we factored out the operator because otherwise scev can go when it comes
to detecting if the new args are from a reduction.

Also the need to change the interface for is_cond_scalar_reduction as the
phi node that was being passed after the factoring no longer exists so need
to pass the parts that were being used.

PR tree-optimization/121236

gcc/ChangeLog:

* tree-if-conv.cc (is_cond_scalar_reduction): Instead of phi argument,
pass bb and res of the phi.
(factor_out_operators): Add iterator for the phi. Remove the phi
if this is the first time. Return if we had removed the phi.
(predicate_scalar_phi): Add the phi iterator argument.
Update call to is_cond_scalar_reduction.
Update call to factor_out_operators and set the return value to true
when factor_out_operators returns true.
(predicate_all_scalar_phis): Don't remove the phi if predicate_scalar_phi
already removed it.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr121236-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 days agox86: Disallow -mtls-dialect=gnu with no_caller_saved_registers
H.J. Lu [Thu, 24 Jul 2025 14:38:13 +0000 (07:38 -0700)] 
x86: Disallow -mtls-dialect=gnu with no_caller_saved_registers

__tls_get_addr doesn't preserve vector registers.  When a function
with no_caller_saved_registers attribute calls __tls_get_addr, YMM
and ZMM registers will be clobbered.  Issue an error and suggest
-mtls-dialect=gnu2 in this case.

gcc/

PR target/121208
* config/i386/i386.cc (ix86_tls_get_addr): Issue an error for
-mtls-dialect=gnu with no_caller_saved_registers attribute and
suggest -mtls-dialect=gnu2.

gcc/testsuite/

PR target/121208
* gcc.target/i386/pr121208-1a.c: New test.
* gcc.target/i386/pr121208-1b.c: Likewise.
* gcc.target/i386/pr121208-2a.c: Likewise.
* gcc.target/i386/pr121208-2b.c: Likewise.
* gcc.target/i386/pr121208-3a.c: Likewise.
* gcc.target/i386/pr121208-3b.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agolibstdc++: Teach std::distance and std::advance about C++20 iterators [PR102181]
Jonathan Wakely [Fri, 18 Jul 2025 17:42:20 +0000 (18:42 +0100)] 
libstdc++: Teach std::distance and std::advance about C++20 iterators [PR102181]

When the C++98 std::distance and std::advance functions (and C++11
std::next and std::prev) are used with C++20 iterators there can be
unexpected results, ranging from compilation failure to decreased
performance to undefined behaviour.

An iterator which satisfies std::input_iterator but does not meet the
Cpp17InputIterator requirements might have std::output_iterator_tag for
its std::iterator_traits<I>::iterator_category, which means it currently
cannot be used with std::advance at all. However, the implementation of
std::advance for a Cpp17InputIterator doesn't do anything that isn't
valid for iterator types satsifying C++20 std::input_iterator.

Similarly, a type satisfying C++20 std::bidirectional_iterator might be
usable with std::prev, if it weren't for the fact that its C++17
iterator_category is std::input_iterator_tag.

Finally, a type satisfying C++20 std::random_access_iterator might use a
slower implementation for std::distance or std::advance if its C++17
iterator_category is not std::random_access_iterator_tag.

This commit adds a __promotable_iterator concept to detect C++20
iterators which explicitly define an iterator_concept member, and which
either have no iterator_category, or their iterator_category is weaker
than their iterator_concept. This is used by std::distance and
std::advance to detect iterators which should dispatch based on their
iterator_concept instead of their iterator_category. This means that
those functions just work and do the right thing for C++20 iterators
which would otherwise fail to compile or have suboptimal performance.

This is related to LWG 3197, which considers making it undefined to use
std::prev with types which do not meet the Cpp17BidirectionalIterator
requirements.  I think making it work, as in this commit, is a better
solution than banning it (or rejecting it at compile-time as libc++
does).

PR libstdc++/102181

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator_base_funcs.h (distance, advance):
Check C++20 iterator concepts and handle appropriately.
(__detail::__iter_category_converts_to_concept): New concept.
(__detail::__promotable_iterator): New concept.
* testsuite/24_iterators/operations/cxx20_iterators.cc: New
test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 days agogit_commit.py: add "diagnostics" to bug components
David Malcolm [Mon, 28 Jul 2025 14:56:07 +0000 (10:56 -0400)] 
git_commit.py: add "diagnostics" to bug components

contrib/ChangeLog
* gcc-changelog/git_commit.py: Add "diagnostics" to bug
components.

3 days agorestore bootstrap with --enable-checking=release [PR121260]
Mikael Pettersson [Mon, 28 Jul 2025 11:44:46 +0000 (13:44 +0200)] 
restore bootstrap with --enable-checking=release [PR121260]

Current trunk doesn't bootstrap with --enable-checking=release
due to improper nesting of namespaces and #if CHECKING_P blocks.
This corrects that.

gcc/
PR other/121260
* diagnostics/changes.cc: Correct nesting of namespaces
and #if CHECKING_P blocks.
* diagnostics/context.cc: Likewise.
* diagnostics/html-sink.cc: Likewise.
* diagnostics/output-spec.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.

Signed-off-by: Mikael Pettersson <mikpelinux@gmail.com>
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 days agonvptx/nvptx.opt: Update -march-map= for newer sm_xxx: test cases
Thomas Schwinge [Mon, 28 Jul 2025 13:55:24 +0000 (15:55 +0200)] 
nvptx/nvptx.opt: Update -march-map= for newer sm_xxx: test cases

Test cases for commit 60ba2b61af23e6d561c5cbab8df57ea093ade3b3
"nvptx/nvptx.opt: Update -march-map= for newer sm_xxx".

gcc/testsuite/
* gcc.target/nvptx/march-map=sm_100.c: New.
* gcc.target/nvptx/march-map=sm_100a.c: Likewise.
* gcc.target/nvptx/march-map=sm_100f.c: Likewise.
* gcc.target/nvptx/march-map=sm_101.c: Likewise.
* gcc.target/nvptx/march-map=sm_101a.c: Likewise.
* gcc.target/nvptx/march-map=sm_101f.c: Likewise.
* gcc.target/nvptx/march-map=sm_103.c: Likewise.
* gcc.target/nvptx/march-map=sm_103a.c: Likewise.
* gcc.target/nvptx/march-map=sm_103f.c: Likewise.
* gcc.target/nvptx/march-map=sm_120.c: Likewise.
* gcc.target/nvptx/march-map=sm_120a.c: Likewise.
* gcc.target/nvptx/march-map=sm_120f.c: Likewise.
* gcc.target/nvptx/march-map=sm_121.c: Likewise.
* gcc.target/nvptx/march-map=sm_121a.c: Likewise.
* gcc.target/nvptx/march-map=sm_121f.c: Likewise.

3 days agonvptx/nvptx.opt: Update -march-map= for newer sm_xxx
Tobias Burnus [Mon, 12 May 2025 15:12:36 +0000 (17:12 +0200)] 
nvptx/nvptx.opt: Update -march-map= for newer sm_xxx

Usage of the -march-map=: "Select the closest available '-march=' value
that is not more capable."

As PTX ISA 8.6/8.7 (= unreleased CUDA 12.7 + CUDA 12.8) added the
Nvidia Blackwell GPUs SM_100, SM_101, and SM_120, it makes sense to
add them as well. Note that all three come as sm_XXX and sm_XXXa.

PTX ISA 8.8 (CUDA 12.9) added SM_103 and SM_121 and the new 'f' suffix
for all SM_1xx.

Internally, GCC currently generates the same code for >= sm_80 (Ampere);
however, as GCC's -march= also supports sm_89 (Ada), the here added
sm_1xxs (Blackwell) will map to sm_89.

[Naming note: while ptx code generated for sm_X can also run with sm_Y
if Y > X, code generated for sm_XXXa can (generally) only run on
the specific hardware; and sm_XXXf implies compatibility with only
subsequent targets in the same family.]

gcc/ChangeLog:

* config/nvptx/nvptx.opt (march-map=): Add sm_100{,f,a},
sm_101{,f,a}, sm_103{,a,f}, sm_120{,a,f} and sm_121{,f,a}.

3 days agogcn: Fix CDNA3 atomics' buffer invalidation
Tobias Burnus [Mon, 28 Jul 2025 13:45:06 +0000 (15:45 +0200)] 
gcn: Fix CDNA3 atomics' buffer invalidation

For device (agent) scope atomics - as needed when there is more than one teams,
a buffer_wbl2 followed by s_waitcnt is required. When doing the initial porting,
the pre-atomic instruction got accidentally replaced by buffer_inv sc1, which is
not quite the right instruction.

gcc/ChangeLog:

* config/gcn/gcn.md (atomic_load, atomic_store, atomic_exchange):
Fix CDNA3 L2 cache write-back before atomic instructions.

3 days agoConst correctness for gather-scatter info
Richard Biener [Mon, 28 Jul 2025 11:46:18 +0000 (13:46 +0200)] 
Const correctness for gather-scatter info

The following adds const qualification to gather_scatter_info *
parameters for various APIs in the vectorizer.

* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Make *gs_info const.
(vect_build_one_gather_load_call): Likewise.
(vect_build_one_scatter_store_call): Likewise.
(vect_get_gather_scatter_ops): Likewise.
(vect_get_strided_load_store_ops): Likewise.

3 days agogcn: Add more s_nop for MI300
Tobias Burnus [Mon, 28 Jul 2025 13:15:24 +0000 (15:15 +0200)] 
gcn: Add more s_nop for MI300

Implement another case where the CDNA3 ISA documentation requires s_nop,
add a comment why another case does not need to be handled. And add one
case where an s_nop is required by MI300A hardware but seems to be not
mentioned in the CDNA3 ISA documentation.

gcc/ChangeLog:

* config/gcn/gcn.md  (define_attr "vcmp"): Add with values
vcmp/vcmpx/no.
(*movbi, cstoredi4.., cstore<mode>4): Set it.
* config/gcn/gcn-valu.md (vec_cmp<mode>...): Likewise.
* config/gcn/gcn.cc (gcn_cmpx_insn_p): Remove.
(gcn_md_reorg): Add two new conditions for MI300.

3 days agogcn: Add 'nops' insn, extend comments
Tobias Burnus [Mon, 28 Jul 2025 10:16:02 +0000 (12:16 +0200)] 
gcn: Add 'nops' insn, extend comments

Use 's_nops' with a number instead of multiple of 's_nop' when
manually adding 1 to 5 wait state. This helps with
the instruction cache and helps a tiny bit with PR119367 where
a two-byte variable overflows in the debugging location view handling.

Add a comment about 'sc0' to TARGET_GLC_NAME as for atomics it is
unrelated to the scope but to whether the result is stored; i.e.
using e.g. 'sc1' instead of 'sc0' will have undesired consequences!

Update the comment above print_operand_address to document 'R' and 'V';
those are used below as "Temporary hack.", but it makes sense to see
them in the list.

gcc/ChangeLog:

* config/gcn/gcn-opts.h (enum hsaco_attr_type): Add comment
about 'sc0'.
* config/gcn/gcn.cc (gcn_md_reorg): Use gen_nops instead of gen_nop.
(print_operand_address): Document 'R' and 'V' in the
pre-function comment as well.
* config/gcn/gcn.md (nops): Add.

3 days agolibstdc++: provide debug impl of P2697 ctor [PR119742]
Nathan Myers [Mon, 7 Jul 2025 20:54:26 +0000 (16:54 -0400)] 
libstdc++: provide debug impl of P2697 ctor [PR119742]

This adds the new bitset constructor from string_view
defined in P2697 to the debug version of the type.

libstdc++-v3/Changelog:
PR libstdc++/119742
* include/debug/bitset: Add new ctor.

3 days agotree-optimization/121256 - properly support SLP in vectorizable recurrence
Richard Biener [Sun, 27 Jul 2025 16:42:25 +0000 (18:42 +0200)] 
tree-optimization/121256 - properly support SLP in vectorizable recurrence

We failed to build the correct initialization vector.  For VLA
vectors and a non-uniform initialization vector this rejects
vectorization for now.

PR tree-optimization/121256
* tree-vect-loop.cc (vectorizable_recurr): Build a correct
initialization vector for SLP_TREE_LANES > 1.

* gcc.dg/vect/vect-recurr-pr121256.c: New testcase.
* gcc.dg/vect/vect-recurr-pr121256-2.c: Likewise.

3 days agolibstdc++: Fix style issues in <mdspan>.
Luc Grosheintz [Sun, 27 Jul 2025 12:40:10 +0000 (14:40 +0200)] 
libstdc++: Fix style issues in <mdspan>.

libstdc++-v3/ChangeLog:

* include/std/mdspan: Small stylistic adjustments.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
3 days agoMove STMT_VINFO_TYPE to SLP_TREE_TYPE
Richard Biener [Sun, 27 Jul 2025 16:42:18 +0000 (18:42 +0200)] 
Move STMT_VINFO_TYPE to SLP_TREE_TYPE

I am at a point where I want to store additional information from
analysis (from loads and stores) to re-use them at transform stage
without repeating the analysis.  I do not want to add to
stmt_vec_info at this point, so this starts adding kind specific
sub-structures by moving the STMT_VINFO_TYPE field to the SLP
tree and adding a (dummy for now) union tagged by it to receive
such data.

The change is largely mechanical after RISC-V has been prepared
to have a SLP node around.

I have settled for a union (supposed to get pointers to data).

As followup this enables getting rid of SLP_TREE_CODE and making
VEC_PERM therein a separate type, unifying its handling.

* tree-vectorizer.h (_slp_tree::type): Add.
(_slp_tree::u): Likewise.
(_stmt_vec_info::type): Remove.
(STMT_VINFO_TYPE): Likewise.
(SLP_TREE_TYPE): New.
* tree-vectorizer.cc (vec_info::new_stmt_vec_info): Do not
initialize type.
* tree-vect-slp.cc (_slp_tree::_slp_tree): Initialize type.
(vect_slp_analyze_node_operations): Adjust.
(vect_schedule_slp_node): Likewise.
* tree-vect-patterns.cc (vect_init_pattern_stmt): Do not
copy STMT_VINFO_TYPE.
* tree-vect-loop.cc: Set SLP_TREE_TYPE instead of
STMT_VINFO_TYPE everywhere.
(vect_create_loop_vinfo): Do not set STMT_VINFO_TYPE on
loop conditions.
* tree-vect-stmts.cc: Set SLP_TREE_TYPE instead of
STMT_VINFO_TYPE everywhere.
(vect_analyze_stmt): Adjust.
(vect_transform_stmt): Likewise.
* config/aarch64/aarch64.cc (aarch64_vector_costs::count_ops):
Access SLP_TREE_TYPE instead of STMT_VINFO_TYPE.
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
Remove non-SLP element-wise load/store matching.
* config/rs6000/rs6000.cc
(rs6000_cost_data::update_target_cost_per_stmt): Pass in
the SLP node.  Use that to get at the memory access
kind and type.
(rs6000_cost_data::add_stmt_cost): Pass down SLP node.
* config/riscv/riscv-vector-costs.cc (variable_vectorized_p):
Use SLP_TREE_TYPE.
(costs::need_additional_vector_vars_p): Likewise.
(costs::update_local_live_ranges): Likewise.

3 days agoada: Minor typo fix in comment
Marc Poulhiès [Thu, 17 Jul 2025 13:00:25 +0000 (15:00 +0200)] 
ada: Minor typo fix in comment

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (gnat_to_gnu): Fix typo in comment.

3 days agoaarch64: Add tuning model for Olympus core.
Jennifer Schmitz [Mon, 21 Jul 2025 17:07:20 +0000 (10:07 -0700)] 
aarch64: Add tuning model for Olympus core.

This patch adds a new tuning model for the NVIDIA Olympus core.
The values used here are based on the Software Optimization Guide
that will be published imminently.

Bootstrapped and tested on aarch64-linux-gnu, no regression.

OK for trunk?
OK to backport to GCC 15?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
Co-Authored-By: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (olympus): Use olympus tuning
model.
* config/aarch64/aarch64.cc: Include olympus.h.
* config/aarch64/tuning_models/olympus.h: New file.

3 days agolibstdc++: Refactor tests for mdspan related accessors.
Luc Grosheintz [Sun, 27 Jul 2025 13:37:56 +0000 (15:37 +0200)] 
libstdc++: Refactor tests for mdspan related accessors.

Versions 1, 2 and 3 of the patch for adding aligned_accessor had a
bug in the constraints that allowed conversion of

  aligned_accessor<T, N> a = aligned_accessor<const T, N>{};

and prevented the reverse.

The file mdspan/accessors/generic.cc already contains code that checks
all variation of the constraint. This commit allows passing in two
different accessors. Enabling it to be reused more widely.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/mdspan/accessors/generic.cc: Refactor
test_ctor.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
3 days agolibstdc++: Support braces as arguments for std::erase on inplace_vector [PR121196]
Tomasz Kamiński [Fri, 25 Jul 2025 12:50:26 +0000 (14:50 +0200)] 
libstdc++: Support braces as arguments for std::erase on inplace_vector [PR121196]

PR libstdc++/121196

libstdc++-v3/ChangeLog:

* include/std/inplace_vector (std::erase): Provide default argument
for _Up parameter.
* testsuite/23_containers/inplace_vector/erasure.cc: Add test for
using braces-init-list as arguments to erase_if and use function
to verify content of inplace_vector

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 days agoLoongArch: Remove the definition of CASE_VECTOR_SHORTEN_MODE.
Lulu Cheng [Thu, 24 Jul 2025 11:07:25 +0000 (19:07 +0800)] 
LoongArch: Remove the definition of CASE_VECTOR_SHORTEN_MODE.

On LoongArch, the switch jump-table always stores absolute
addresses, so there is no need to define the macro
CASE_VECTOR_SHORTEN_MODE.

gcc/ChangeLog:

* config/loongarch/loongarch.h
(CASE_VECTOR_SHORTEN_MODE): Delete.

3 days agoxtensa: Fix remaining inaccuracies in xtensa_is_insn_L32R_p()
Takayuki 'January June' Suwa [Fri, 25 Jul 2025 01:40:42 +0000 (10:40 +0900)] 
xtensa: Fix remaining inaccuracies in xtensa_is_insn_L32R_p()

The previous fix also had some flaws:

- The TARGET_CONST16 check was a bit premature
- It didn't take into account the possibility of the RTL expression
   "(set (reg:SF gpr) (const_int))", especially when TARGET_AUTOLITPOOLS is
   configured

This patch fixes the above.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xtensa_is_insn_L32R_p):
Re-rewrite to more accurately capture insns that could be L32R machine
instructions wherever possible, and add comments that help understand
the intent of the process.

3 days agoDaily bump.
GCC Administrator [Mon, 28 Jul 2025 00:17:10 +0000 (00:17 +0000)] 
Daily bump.

4 days agofortran: Consistently use the same assignment reallocation condition [PR121185]
Mikael Morin [Sun, 27 Jul 2025 15:11:58 +0000 (17:11 +0200)] 
fortran: Consistently use the same assignment reallocation condition [PR121185]

This is a follow-up to:
r16-2248-gac8e536526393580bc9a4339bab2f8603eff8a47
fortran: Delay evaluation of array bounds after reallocation

That revision delayed the evaluation of array bounds, with changes in
two places: in the scalarizer where we save expressions without
evaluating their values to variables, and in the reallocation code where
we evaluate to variables the expressions previously saved.  The effect
should not have been visible in scalarized code, as the saving to a
variable was only delayed after reallocation.

Unfortunately, it's actually not the case, and there are cases where
expressions that were saved to variables before the change, are no
longer after it.  The reason for that is differing conditions guarding
the omission of the evaluation to variables in the scalarizer on one
hand, and the emission of reallocation code with the saving to variables
on the other hand.  There is an additional check that avoids the
emission of reallocation code if we can prove at compile time that both
sides of the assignment are conformable.

This change moves up the reallocation code condition definition, so that
it can be used as well to flag the left hand side array as
reallocatable, and omit the evaluation of expressions in the exact same
conditions where the reallocation code would catch those unevaluated
expressions.

An explicit call to gfc_fix_class_refs is added before the evaluation of
the reallocation code condition.  It was implicit before, by the call to
gfc_walk_expr.

This is not a correctness issue, but PR #121185, that made the problem
apparent, exhibited wrong code examples where the lack of an
intermediary variable was making visible a class container at the
beginning of an array reference, causing the non-polymorphic array
reference to be evaluated in a polymorphic way.

The preceding commits have already fixed the PR #121185 test, so I
haven't found any addition to the testsuite that would reliably test
this change.

PR fortran/121185

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_trans_assignment_1): Use the same condition
to set the is_alloc_lhs flag and to decide to generate
reallocation code.  Add explicit call to gfc_fix_class_refs
before evaluating the condition.

4 days agofortran: Trigger reference saving on pointer dereference [PR121185]
Mikael Morin [Sun, 27 Jul 2025 15:11:50 +0000 (17:11 +0200)] 
fortran: Trigger reference saving on pointer dereference [PR121185]

This is a follow-up to revision:
r16-2371-g8f41c87654fd819e48c9f6f1ac3d87e35794d310
fortran: Factor array descriptor references

That revision introduced new variables to limit repeated subexpressions
in array descriptor references.  The change added a walk along the
reference from child to parent, that selected subreferences worth
saving and applied the saving if the reference proved non-trivial
enough.  Trivialness was defined in a comment as: only made of a DECL
and NOPs and COMPONENTs.  But the case of a pointer derefence didn't
trigger the saving, so the code was also considering a dereference as if
it was trivial.

This change triggers the reference saving on pointer dereferences,
making the trivialness as defined by the code aligned with the comment.

This change is not strictly speaking a bug fix, but PR #121185 exhibited
wrong code examples where the lack of a variable hiding the polymorphic
leading part of a non-polymorphic array reference was causing the latter
to be evaluated in a polymorphic way.

PR fortran/121185

gcc/fortran/ChangeLog:

* trans-array.cc (set_factored_descriptor_value): Also trigger
the saving of the previously selected reference on encountering
an INDIRECT_REF.  Extract the saving code...
(save_ref): ... here as a new function.

gcc/testsuite/ChangeLog:

* gfortran.dg/assign_14.f90: New test.

4 days agofortran: Bound class container lookup after array descriptor [PR121185]
Mikael Morin [Sun, 27 Jul 2025 15:11:40 +0000 (17:11 +0200)] 
fortran: Bound class container lookup after array descriptor [PR121185]

Don't look for a class container too far after an array descriptor.
This avoids generating a polymorphic array reference, using the virtual
table of a parent object, to access a non-polymorphic child having a
type unrelated to that of the parent.

PR fortran/121185

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_get_class_from_expr): Give up class
container lookup on the second COMPONENT_REF after an array
descriptor.

gcc/testsuite/ChangeLog:

* gfortran.dg/assign_13.f90: New test.

4 days agoRISC-V: Add test case for vaadd.vx combine polluting VXRM
Pan Li [Fri, 25 Jul 2025 13:29:29 +0000 (21:29 +0800)] 
RISC-V: Add test case for vaadd.vx combine polluting VXRM

Add asm check to make sure vx combine of vaadd.vx will not pollute
the vxrm.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-fixed-vxrm-1-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-fixed-vxrm-1-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-fixed-vxrm-1-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-fixed-vxrm-1-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 days agoRISC-V: Add test for vec_duplicate + vaadd.vv combine case 1 with GR2VR cost 0, 1...
Pan Li [Fri, 25 Jul 2025 13:28:24 +0000 (21:28 +0800)] 
RISC-V: Add test for vec_duplicate + vaadd.vv combine case 1 with GR2VR cost 0, 1 and 2

Add asm dump check test for vec_duplicate + vaadd.vv combine to
vaadd.vx, with the GR2VR cost is 0, 1 and 2

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i16.c: Add asm check.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 days agoRISC-V: Add test for vec_duplicate + vaadd.vv combine case 0 with GR2VR cost 0, 1...
Pan Li [Fri, 25 Jul 2025 13:26:27 +0000 (21:26 +0800)] 
RISC-V: Add test for vec_duplicate + vaadd.vv combine case 0 with GR2VR cost 0, 1 and 15

Add asm dump check and run test for vec_duplicate + vaadd.vv
combine to vaadd.vx, with the GR2VR cost is 0, 2 and 15

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i16.c: Add asm check.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test helper
macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vaadd-run-1-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vaadd-run-1-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vaadd-run-1-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vaadd-run-1-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 days agoRISC-V: Combine vec_duplicate + vaadd.vv to vaadd.vx on GR2VR cost
Pan Li [Fri, 25 Jul 2025 13:22:47 +0000 (21:22 +0800)] 
RISC-V: Combine vec_duplicate + vaadd.vv to vaadd.vx on GR2VR cost

This patch would like to combine the vec_duplicate + vaadd.vv to the
vaadd.vx.  From example as below code.  The related pattern will depend
on the cost of vec_duplicate from GR2VR.  Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.

Assume we have example code like below, GR2VR cost is 0.

  #define DEF_AVG_FLOOR(NT, WT)        \
  NT                                   \
  test_##NT##_avg_floor(NT x, NT y)    \
  {                                    \
    return (NT)(((WT)x + (WT)y) >> 1); \
  }

  #define AVG_FLOOR_FUNC(T)      test_##T##_avg_floor

  DEF_AVG_FLOOR(int32_t, int64_t)
  DEF_VX_BINARY_CASE_2_WRAP(T, AVG_FLOOR_FUNC(T), avg_floor)

Before this patch:
  11   │     beq a3,zero,.L8
  12   │     vsetvli a5,zero,e32,m1,ta,ma
  13   │     vmv.v.x v2,a2
  14   │     slli    a3,a3,32
  15   │     srli    a3,a3,32
  16   │ .L3:
  17   │     vsetvli a5,a3,e32,m1,ta,ma
  18   │     vle32.v v1,0(a1)
  19   │     slli    a4,a5,2
  20   │     sub a3,a3,a5
  21   │     add a1,a1,a4
  22   │     vaadd.vv v1,v1,v2
  23   │     vse32.v v1,0(a0)
  24   │     add a0,a0,a4
  25   │     bne a3,zero,.L3

After this patch:
  11   │     beq a3,zero,.L8
  12   │     slli    a3,a3,32
  13   │     srli    a3,a3,32
  14   │ .L3:
  15   │     vsetvli a5,a3,e32,m1,ta,ma
  16   │     vle32.v v1,0(a1)
  17   │     slli    a4,a5,2
  18   │     sub a3,a3,a5
  19   │     add a1,a1,a4
  20   │     vaadd.vx v1,v1,a2
  21   │     vse32.v v1,0(a0)
  22   │     add a0,a0,a4
  23   │     bne a3,zero,.L3

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vx_binary_vxrm_vec_vec_dup):
Add new case UNSPEC_VAADD.
(expand_vx_binary_vxrm_vec_dup_vec): Ditto.
* config/riscv/riscv.cc (riscv_rtx_costs): Ditto.
* config/riscv/vector-iterators.md: Add new case UNSPEC_VAADD to
iterator.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 days agoRISC-V: Fix another vf FP16 combine run test failures
Pan Li [Fri, 25 Jul 2025 14:11:13 +0000 (22:11 +0800)] 
RISC-V: Fix another vf FP16 combine run test failures

Like Robin's fix for vf combine f16.c run tests, there is still
another failures similar.  This patch would like to fix it as
previous.

will commit it directly if the CI agrees.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwnmacc-run-1-f16.c:
Add zvfh requirements and options.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwnmsac-run-1-f16.c:
Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 days agoDaily bump.
GCC Administrator [Sun, 27 Jul 2025 00:16:31 +0000 (00:16 +0000)] 
Daily bump.

4 days agoPrevent mixups of IDENTIFIER_TRANSPARENT_ALIAS and IDENTIFIER_INTERNAL_P better ...
Nathaniel Shead [Wed, 23 Jul 2025 23:41:00 +0000 (09:41 +1000)] 
Prevent mixups of IDENTIFIER_TRANSPARENT_ALIAS and IDENTIFIER_INTERNAL_P better [PR120855]

The assertion failure on ASM_OUTPUT_WEAKREF targets since my r16-1738
was caused because the 'TREE_CHAIN (id)' check in assemble_name_resolve
no longer implies that ID is a transparent alias, since internal
identifiers can have a TREE_CHAIN as well.

I still don't think it's possible for a transparent alias to be an
internal identifier in the sense added, so this patch simply constrains
the assertion better so that it doesn't fail spuriously.  I also added a
couple of other assertions to help validate this assumption.

PR middle-end/120855

gcc/ChangeLog:

* cgraphunit.cc (symbol_table::compile): Assert a transparent
alias is not an internal identifier.
* symtab.cc (symbol_table::change_decl_assembler_name):
Likewise.
* varasm.cc (assemble_name_resolve): Check for
IDENTIFIER_TRANSPARENT_ALIAS instead of just TREE_CHAIN.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 days agoc++/modules: Stream some missing lang_type flags
Nathaniel Shead [Thu, 24 Jul 2025 22:21:55 +0000 (08:21 +1000)] 
c++/modules: Stream some missing lang_type flags

I noticed that trivial relocation didn't work in modules yet, and there
are a couple of other flags that seem potentially useful we weren't
streaming.  This streams those flags and adds a comment to cp-tree.h in
the hope that people will remember about modules when adding more!

As a drive-by improvement, update gcc_assert with gcc_checking_assert in
lang_type_bools streaming.

gcc/cp/ChangeLog:

* cp-tree.h (struct lang_type): Add comment mentioning modules.
* module.cc (trees_out::lang_type_bools): Stream new flags, use
gcc_checking_assert.
(trees_in::lang_type_bools): Likewise.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
5 days agodiagnostics: move diagnostic.c to diagnostics/context.cc: restore build with GCC 5
Thomas Schwinge [Sat, 26 Jul 2025 13:31:33 +0000 (15:31 +0200)] 
diagnostics: move diagnostic.c to diagnostics/context.cc: restore build with GCC 5

Building with GCC 5, with commit 8d9d9515f5db9bab758e484f3956033150931de5
"diagnostics: move diagnostic.c to diagnostics/context.cc", we got:

    ../../source-gcc/gcc/diagnostics/context.cc: In member function ‘bool diagnostics::context::diagnostic_impl(rich_location*, const diagnostics::metadata*, diagnostics::option_id, const char*, __va_list_tag (*)[1], diagnostics::kind)’:
    ../../source-gcc/gcc/diagnostics/context.cc:1514:15: error: ‘kind’ is not a class, namespace, or enumeration
       if (kind == kind::permerror)
                   ^
    ../../source-gcc/gcc/diagnostics/context.cc:1517:22: error: ‘kind’ is not a class, namespace, or enumeration
           m_permissive ? kind::warning : kind::error);
                          ^
    ../../source-gcc/gcc/diagnostics/context.cc:1517:38: error: ‘kind’ is not a class, namespace, or enumeration
           m_permissive ? kind::warning : kind::error);
                                          ^
    ../../source-gcc/gcc/diagnostics/context.cc:1523:19: error: ‘kind’ is not a class, namespace, or enumeration
           if (kind == kind::warning || kind == kind::pedwarn)
                       ^
    ../../source-gcc/gcc/diagnostics/context.cc:1523:44: error: ‘kind’ is not a class, namespace, or enumeration
           if (kind == kind::warning || kind == kind::pedwarn)
                                                ^
    ../../source-gcc/gcc/diagnostics/context.cc: In member function ‘bool diagnostics::context::diagnostic_n_impl(rich_location*, const diagnostics::metadata*, diagnostics::option_id, long unsigned int, const char*, const char*, __va_list_tag (*)[1], diagnostics::kind)’:
    ../../source-gcc/gcc/diagnostics/context.cc:1554:15: error: ‘kind’ is not a class, namespace, or enumeration
       if (kind == kind::warning)
                   ^
    make[2]: *** [Makefile:1212: diagnostics/context.o] Error 1

Resolve this similar to, for example,
commit r14-4521-g08d0f840dc7ad212ab75d094373b01cbfc004e67
"analyzer: fix build with gcc < 6".

gcc/
* diagnostics/context.cc (context::diagnostic_impl)
(context::diagnostic_n_impl): In presence of formal parameter
'kind', explicitly state 'diagnostics::' scope for 'kind' enum.

5 days agodiagnostics: convert diagnostic_t to enum class diagnostics::kind: restore build...
Thomas Schwinge [Sat, 26 Jul 2025 13:31:33 +0000 (15:31 +0200)] 
diagnostics: convert diagnostic_t to enum class diagnostics::kind: restore build with GCC 5

Building with GCC 5, with commit 3cc27ed5b6fb4253d3fe2139dcc6295e85372a3a
"diagnostics: convert diagnostic_t to enum class diagnostics::kind", we got:

    ../../source-gcc/gcc/diagnostics/option-classifier.cc: In member function ‘diagnostics::kind diagnostics::option_classifier::update_effective_level_from_pragmas(diagnostics::diagnostic_info*) const’:
    ../../source-gcc/gcc/diagnostics/option-classifier.cc:212:20: error: ‘kind’ is not a class, namespace, or enumeration
            if (kind != kind::unspecified)
                        ^
    make[2]: *** [Makefile:1212: diagnostics/option-classifier.o] Error 1

Resolve this similar to, for example,
commit r14-4521-g08d0f840dc7ad212ab75d094373b01cbfc004e67
"analyzer: fix build with gcc < 6".

gcc/
* diagnostics/option-classifier.cc
(update_effective_level_from_pragmas): In presence of local
variable 'kind', explicitly state 'diagnostics::' scope for 'kind'
enum.

5 days agoRISC-V: riscv-ext.def: Add allocated group IDs and group bit positions
Christoph Müllner [Tue, 10 Jun 2025 08:53:54 +0000 (10:53 +0200)] 
RISC-V: riscv-ext.def: Add allocated group IDs and group bit positions

The riscv-c-api-doc defines a group ID and and a bit position for some
extension.  Most of them are set in riscv-ext.def, but some are missing
and one bit position (for Zilsd) is wrong.

This patch replaces the `BITMASK_NOT_YET_ALLOCATED` value for the actual
allocated value wherever possible and fixes the bit position for Zilsd.

Currently, we don't have any infrastructure to utilize the information
that is placed into riscv_ext_info_t::m_bitmask_group_id and
riscv_ext_info_t::m_bitmask_group_bit_pos.  This also means we can't
test.

gcc/ChangeLog:

* config/riscv/riscv-ext.def: Add allocated group IDs and
group bit positions.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
5 days agoDaily bump.
GCC Administrator [Sat, 26 Jul 2025 00:19:51 +0000 (00:19 +0000)] 
Daily bump.

6 days agoIntroduce lazily-created.h
David Malcolm [Fri, 25 Jul 2025 19:13:46 +0000 (15:13 -0400)] 
Introduce lazily-created.h

No functional change intended.

gcc/ChangeLog:
* diagnostics/context.cc: Eliminate digraphs::lazy_digraph in
favor of lazily_created template.
* diagnostics/context.h: Likewise.
* diagnostics/digraphs.cc: Likewise, also digraphs::lazy_digraphs.
* diagnostics/digraphs.h: Likewise.
* diagnostics/html-sink.cc: Likewise.
* diagnostics/metadata.h: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/sink.h: Likewise.
* diagnostics/text-sink.h: Likewise.
* lazily-created.h: New file.
* libgdiagnostics.cc: Eliminate digraphs::lazy_digraph in
favor of lazily_created template.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc: Eliminate
digraphs::lazy_digraph and digraphs::lazy_digraphs in favor of
lazily_created template.
* gcc.dg/plugin/diagnostic_plugin_test_metadata.cc: Define
INCLUDE_VECTOR since diagnostics/metadata.h now requires it.
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: avoid using "sink" for things that aren't a diagnostics::sink
David Malcolm [Fri, 25 Jul 2025 19:13:46 +0000 (15:13 -0400)] 
diagnostics: avoid using "sink" for things that aren't a diagnostics::sink

No functional change intended.

gcc/ChangeLog:
* diagnostic.h: Use TextOrHtml rather than Sink for template
params.
* diagnostics/context.h: Likewise.
* diagnostics/selftest-context.cc: Use "html_or_text" rather than
"sink".
* diagnostics/source-printing.cc: Use TextOrHtml rather than Sink
for template params.  Use "text_out" and "html_out" rather than
"sink".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: make context::m_source_printing private
David Malcolm [Fri, 25 Jul 2025 19:13:45 +0000 (15:13 -0400)] 
diagnostics: make context::m_source_printing private

No functional change intended.

gcc/ada/ChangeLog:
* gcc-interface/misc.cc: Make
diagnostics::context::m_source_printing private.

gcc/analyzer/ChangeLog:
* program-point.cc: Make diagnostics::context::m_source_printing
private.

gcc/c-family/ChangeLog:
* c-common.cc: Make diagnostics::context::m_source_printing
private.
* c-format.cc: Likewise.
* c-opts.cc: Likewise.

gcc/ChangeLog:
* diagnostic.h (diagnostic_set_caret_max_width): Drop forward
decl.
(diagnostic_same_line): Make
diagnostics::context::m_source_printing private.
* diagnostics/context.cc (diagnostic_set_caret_max_width): Convert
to...
(diagnostics::context::set_caret_max_width): ...this.
* diagnostics/context.h
(diagnostics::context::get_source_printing_options): New
accessors.
(diagnostics::context::m_source_printing): Make private.
* diagnostics/html-sink.cc: Make
diagnostics::context::m_source_printing private.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/selftest-context.cc: Likewise.
* diagnostics/selftest-context.h
(diagnostics::selftest::test_context::colorize_source): New.
(diagnostics::selftest::test_context::show_labels): New.
(diagnostics::selftest::test_context::show_line_numbers): New.
(diagnostics::selftest::test_context::show_ruler): New.
(diagnostics::selftest::test_context::show_event_links): New.
(diagnostics::selftest::test_context::set_caret_char): New.
* diagnostics/source-printing.cc: Make
diagnostics::context::m_source_printing private.
* diagnostics/text-sink.h: Likewise.
* libgdiagnostics.cc: Likewise.
* opts.cc: Likewise.
* toplev.cc: Likewise.

gcc/fortran/ChangeLog:
* error.cc: Make diagnostics::context::m_source_printing private.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_show_trees.cc: Make
diagnostics::context::m_source_printing private.
* gcc.dg/plugin/diagnostic_plugin_test_inlining.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_string_literals.cc:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.cc:
Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: eliminate ::diagnostic_info typedef
David Malcolm [Fri, 25 Jul 2025 19:13:45 +0000 (15:13 -0400)] 
diagnostics: eliminate ::diagnostic_info typedef

No functional change intended.

gcc/c-family/ChangeLog:
* c-common.cc: Update usage of "diagnostic_info" to explicitly
refer to "diagnostics::diagnostic_info".
* c-opts.cc: Likewise.

gcc/c/ChangeLog:
* c-errors.cc: Update usage of "diagnostic_info" to explicitly
refer to "diagnostics::diagnostic_info".

gcc/cp/ChangeLog:
* constexpr.cc: Update usage of "diagnostic_info" to explicitly
refer to "diagnostics::diagnostic_info".
* cp-tree.h: Likewise.
* error.cc: Likewise.
* module.cc: Likewise.

gcc/d/ChangeLog:
* d-diagnostic.cc: Likewise.

gcc/ChangeLog:
* diagnostic.h: Eliminate "diagnostic_info" typedef.
* diagnostics/context.cc: Update usage of "diagnostic_info" to
explicitly refer to "diagnostics::diagnostic_info".
* langhooks.cc: Likewise.
* libgdiagnostics.cc: Likewise.
* rtl-error.cc: Likewise.
* substring-locations.cc: Likewise.
* toplev.cc: Likewise.
* tree-diagnostic.cc: Likewise.
* tree-diagnostic.h: Likewise.

gcc/fortran/ChangeLog:
* cpp.cc: Update usage of "diagnostic_info" to explicitly refer to
"diagnostics::diagnostic_info".
* error.cc: Likewise.

gcc/jit/ChangeLog:
* dummy-frontend.cc: Update usage of "diagnostic_info" to
explicitly refer to "diagnostics::diagnostic_info".

gcc/m2/ChangeLog:
* gm2-gcc/m2linemap.cc: Update usage of "diagnostic_info" to
explicitly refer to "diagnostics::diagnostic_info".
* gm2-gcc/rtegraph.cc: Likewise.

gcc/rust/ChangeLog:
* resolve/rust-ice-finalizer.cc: Update usage of "diagnostic_info"
to explicitly refer to "diagnostics::diagnostic_info".
* resolve/rust-ice-finalizer.h: Likewise.

gcc/testsuite/ChangeLog:
* g++.dg/plugin/show_template_tree_color_plugin.cc: Update usage
of "diagnostic_info" to explicitly refer to
"diagnostics::diagnostic_info".
* gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.

libcc1/ChangeLog:
* context.cc: Update usage of "diagnostic_info" to explicitly
refer to "diagnostics::diagnostic_info".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: introduce context-options.h
David Malcolm [Fri, 25 Jul 2025 19:13:44 +0000 (15:13 -0400)] 
diagnostics: introduce context-options.h

No functional change intended.

gcc/ChangeLog:
* diagnostic.h (enum diagnostics_column_unit): Move to
diagnostics/context-options.h.
(enum diagnostics_escape_format): Likewise.
(enum diagnostics_output_format): Likewise.
(enum diagnostic_path_format): Likewise.
(enum diagnostics_extra_output_kind): Likewise.
(enum diagnostic_text_art_charset): Likewise.
* diagnostics/context-options.h: New file, based on the above
material.
* diagnostics/context.h: Include it.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move file_cache from input.{cc,h} to diagnostics/file-cache.{cc,h}
David Malcolm [Fri, 25 Jul 2025 19:13:44 +0000 (15:13 -0400)] 
diagnostics: move file_cache from input.{cc,h} to diagnostics/file-cache.{cc,h}

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add diagnostics/file-cache.o.
* diagnostics/changes.cc: Update for file_cache and char_span
moving from input.h to diagnostics/file-cache.h and into the
"diagnostics::" namespace.
* diagnostics/context.cc: Likewise.
* diagnostics/diagnostics-selftests.cc: Likewise.
* diagnostics/diagnostics-selftests.h: Likewise.
* diagnostics/file-cache.cc: New file, based on the file_cache
and file_cache_slot material in input.cc.
* diagnostics/file-cache.h: Likewise for input.h.
* diagnostics/selftest-source-printing.h: Update for file_cache
and char_span moving from input.h to diagnostics/file-cache.h and
into the "diagnostics::" namespace.
* diagnostics/source-printing.cc: Likewise.
* final.cc: Likewise.
* gcc-rich-location.cc: Likewise.
* input.cc (default_charset_callback): Move to
diagnostics/file-cache.cc.
(file_cache::initialize_input_context): Likewise.
(class file_cache_slot): Likewise.
(file_cache::tune): Likewise.
(file_cache::lookup_file): Likewise.
(file_cache::forcibly_evict_file): Likewise.
(file_cache::missing_trailing_newline_p): Likewise.
(file_cache::add_buffered_content): Likewise.
(file_cache::evicted_cache_tab_entry): Likewise.
(file_cache::add_file): Likewise.
(file_cache::file_cache): Likewise.
(file_cache::dump): Likewise.
(file_cache::dump): Likewise.
(file_cache::lookup_or_add_file): Likewise.
(find_end_of_line): Likewise.
(file_cache::get_source_line): Likewise.
(check_line): Likewise.
(test_replacement): Likewise.
(test_reading_source_line): Likewise.
(test_reading_source_buffer): Likewise.
* input.h (class char_span): Move to diagnostics/file-cache.h and
into the "diagnostics::" namespace.
(class file_cache_slot): Likewise.
(class file_cache): Likewise.
* libgdiagnostics.cc: Update for file_cache and char_span moving
from input.h to diagnostics/file-cache.h and into the
"diagnostics::" namespace.
* selftest.cc: Likewise.
* selftest.h: Likewise.
* substring-locations.h: Likewise.
* toplev.cc: Likewise.

gcc/c-family/ChangeLog:
* c-format.cc: Update for file_cache and char_span moving from
input.h to diagnostics/file-cache.h and into the "diagnostics::"
namespace.
* c-indentation.cc: Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update for
file_cache and char_span moving from input.h to
diagnostics/file-cache.h and into the "diagnostics::" namespace.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: eliminate some redundant includes
David Malcolm [Fri, 25 Jul 2025 19:13:44 +0000 (15:13 -0400)] 
diagnostics: eliminate some redundant includes

No functional change intended.

gcc/ChangeLog:
* diagnostics/selftest-paths.cc: Don't include "demangle.h"
and "backtrace.h".
* diagnostics/source-printing.cc: Likewise.
* diagnostics/state-graphs.cc: Don't include "graphviz.h",
"xml.h", "xml-printer.h", or "intl.h".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: simplify header files
David Malcolm [Fri, 25 Jul 2025 19:13:43 +0000 (15:13 -0400)] 
diagnostics: simplify header files

No functional change intended.

gcc/ChangeLog:
* diagnostic.h: Move include of "unique-argv.h"
and various forward decls into...
* diagnostics/context.h: ...here.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move diagnostic.c to diagnostics/context.cc
David Malcolm [Fri, 25 Jul 2025 19:13:43 +0000 (15:13 -0400)] 
diagnostics: move diagnostic.c to diagnostics/context.cc

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace diagnostic.o with
diagnostics/context.o.

gcc/c-family/ChangeLog:
* c-common.cc (c_family_tests): Add include of
"diagnostics/diagnostics-selftests.h".  Replace
c_diagnostic_cc_tests with
diagnostics::selftest::context_cc_tests.
* c-common.h: Drop c_diagnostic_cc_tests decl.

gcc/ChangeLog:
* diagnostic.h (num_digits): Move to...
(diagnostics::num_digits): ...here.
(get_cwe_url): Move to...
(diagnostics::get_cwe_url): ...here.
(maybe_line_and_column): Move to...
(diagnostics::maybe_line_and_column): ...here.
* diagnostic.cc: Move to...
* diagnostics/context.cc: ...here.
* diagnostics/diagnostics-selftests.cc
(run_diagnostics_selftests): Add comment about context_cc_tests.
* diagnostics/diagnostics-selftests.h: Add context_cc_tests decl.
* diagnostics/sarif-sink.cc: Update for file rename.
* diagnostics/source-printing.cc: Update for num_digits moving to
diagnostics::num_digits.
* errors.cc: Update for file rename.
* input.cc: Update for num_digits moving to
diagnostics::num_digits.

libcpp/ChangeLog:
* charset.cc: Update comment for file rename.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: convert diagnostic_t to enum class diagnostics::kind
David Malcolm [Fri, 25 Jul 2025 19:13:43 +0000 (15:13 -0400)] 
diagnostics: convert diagnostic_t to enum class diagnostics::kind

No functional change intended.

gcc/ChangeLog:
* Makefile.in: Replace diagnostic.def with diagnostics/kinds.def.
* config/aarch64/aarch64.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* config/i386/i386-options.cc: Likewise.
* config/s390/s390.cc: Likewise.
* diagnostic-core.h: Replace typedef diagnostic_t with
enum class diagnostics::kind in diagnostics/kinds.h and include
it.
* diagnostic-global-context.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostics/buffering.cc: Likewise.
* diagnostics/buffering.h: Likewise.
* diagnostics/context.h: Likewise.
* diagnostics/diagnostic-info.h: Likewise.
* diagnostics/html-sink.cc: Likewise.
* diagnostic.def: Move to...
* diagnostics/kinds.def: ...here and update for diagnostic_t
becoming enum class diagnostics::kind.
* diagnostics/kinds.h: New file, based on material in
diagnostic-core.h.
* diagnostics/lazy-paths.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* diagnostics/option-classifier.cc: Likewise.
* diagnostics/option-classifier.h: Likewise.
* diagnostics/output-spec.h: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/selftest-context.cc: Likewise.
* diagnostics/selftest-context.h: Likewise.
* diagnostics/sink.h: Likewise.
* diagnostics/source-printing.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* diagnostics/text-sink.h: Likewise.
* gcc.cc: Likewise.
* libgdiagnostics.cc: Likewise.
* lto-wrapper.cc: Likewise.
* opts-common.cc: Likewise.
* opts-diagnostic.h: Likewise.
* opts.cc: Likewise.
* rtl-error.cc: Likewise.
* substring-locations.cc: Likewise.
* toplev.cc: Likewise.

gcc/ada/ChangeLog:
* gcc-interface/trans.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.

gcc/analyzer/ChangeLog:
* pending-diagnostic.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* program-point.cc: Likewise.

gcc/c-family/ChangeLog:
* c-common.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* c-format.cc: Likewise.
* c-lex.cc: Likewise.
* c-opts.cc: Likewise.
* c-pragma.cc: Likewise.
* c-warn.cc: Likewise.

gcc/c/ChangeLog:
* c-errors.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* c-parser.cc: Likewise.
* c-typeck.cc: Likewise.

gcc/cobol/ChangeLog:
* util.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.

gcc/cp/ChangeLog:
* call.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* constexpr.cc: Likewise.
* cp-tree.h: Likewise.
* decl.cc: Likewise.
* error.cc: Likewise.
* init.cc: Likewise.
* method.cc: Likewise.
* module.cc: Likewise.
* parser.cc: Likewise.
* pt.cc: Likewise.
* semantics.cc: Likewise.
* typeck.cc: Likewise.
* typeck2.cc: Likewise.

gcc/d/ChangeLog:
* d-diagnostic.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.

gcc/fortran/ChangeLog:
* cpp.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* error.cc: Likewise.
* options.cc: Likewise.

gcc/jit/ChangeLog:
* dummy-frontend.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.

gcc/m2/ChangeLog:
* gm2-gcc/m2linemap.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* gm2-gcc/rtegraph.cc: Likewise.

gcc/rust/ChangeLog:
* backend/rust-tree.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* backend/rust-tree.h: Likewise.
* resolve/rust-ast-resolve-expr.cc: Likewise.
* resolve/rust-ice-finalizer.cc: Likewise.
* resolve/rust-ice-finalizer.h: Likewise.
* resolve/rust-late-name-resolver-2.0.cc: Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update for
diagnostic_t becoming enum class diagnostics::kind.
* gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.
* lib/gcc-dg.exp: Likewise.

libcpp/ChangeLog:
* internal.h: Update comment for diagnostic_t becoming
enum class diagnostics::kind.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: rename diagnostic_option_id to diagnostics::option_id and move to its...
David Malcolm [Fri, 25 Jul 2025 19:13:42 +0000 (15:13 -0400)] 
diagnostics: rename diagnostic_option_id to diagnostics::option_id and move to its own header

No functional change intended.

gcc/c-family/ChangeLog:
* c-common.cc: Update for renaming of diagnostic_option_id to
diagnostics::option_id.
* c-common.h: Likewise.
* c-cppbuiltin.cc: Likewise.
* known-headers.cc: Likewise.
* known-headers.h: Likewise.

gcc/c/ChangeLog:
* c-decl.cc: Update for renaming of diagnostic_option_id to
diagnostics::option_id.
* c-errors.cc: Likewise.
* c-tree.h: Likewise.

gcc/cobol/ChangeLog:
* util.cc: Update for renaming of diagnostic_option_id to
diagnostics::option_id.

gcc/cp/ChangeLog:
* cp-tree.h: Update for renaming of diagnostic_option_id to
diagnostics::option_id.
* decl.cc: Likewise.
* error.cc: Likewise.
* name-lookup.cc: Likewise.

gcc/ChangeLog:
* diagnostic-core.h: Include "diagnostics/option-id.h".
(struct diagnostic_option_id): Move there, renaming to
diagnostics::option_id.
* diagnostic-global-context.cc: Update for renaming of
diagnostic_option_id to diagnostics::option_id.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostics/context.h: Likewise.
* diagnostics/diagnostic-info.h: Likewise.
* diagnostics/lazy-paths.cc: Likewise.
* diagnostics/option-classifier.cc: Likewise.
* diagnostics/option-classifier.h: Likewise.
* diagnostics/option-id.h: New file, taken from material in
diagnostic-core.h.
* diagnostics/selftest-context.cc: Update for renaming of
diagnostic_option_id to diagnostics::option_id.
* diagnostics/selftest-context.h: Likewise.
* ipa-pure-const.cc: Likewise.
* lto-wrapper.cc: Likewise.
* opts-common.cc: Likewise.
* opts-diagnostic.h: Likewise.
* opts.cc: Likewise.
* substring-locations.cc: Likewise.
* substring-locations.h: Likewise.

gcc/fortran/ChangeLog:
* cpp.cc: Update for renaming of
diagnostic_option_id to diagnostics::option_id.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agoRename diagnostic-spec.{cc,h} to gcc-diagnostic-spec.{cc,h}
David Malcolm [Fri, 25 Jul 2025 19:13:41 +0000 (15:13 -0400)] 
Rename diagnostic-spec.{cc,h} to gcc-diagnostic-spec.{cc,h}

This has GCC-specific stuff in it (options and "GTY"), and so should
not be in the "diagnostics/" subdir, and should avoid a "diagnostics"
prefix in its name.

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace diagnostic-spec.o with
gcc-diagnostic-spec.o.
(GTFILES): Replace diagnostic-spec.h with gcc-diagnostic-spec.h.
* diagnostic-spec.cc: Move to...
* gcc-diagnostic-spec.cc: ...here.
* diagnostic-spec.h: Move to...
* gcc-diagnostic-spec.h: ...here.
* gengtype.cc (open_base_files): Replace diagnostic-spec.h with
gcc-diagnostic-spec.h.
* warning-control.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move diagnostics::edit_context -> diagnostics::changes::change_set
David Malcolm [Fri, 25 Jul 2025 19:13:41 +0000 (15:13 -0400)] 
diagnostics: move diagnostics::edit_context -> diagnostics::changes::change_set

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace diagnostics/changes.o with
diagnostics/edit-context.o.
* diagnostic.cc: Update for move of diagnostics/edit-context.h to
diagnostics/changes.h.
(diagnostics::context::initialize): Update for renaming of
m_edit_context_ptr to m_fixits_change_set.
(diagnostics::context::finish): Likewise.
(diagnostics::context::create_edit_context): Rename to...
(diagnostics::context::initialize_fixits_change_set): ...this and
update for other renamings.
(diagnostics::context::report_diagnostic): Update for renaming of
m_edit_context_ptr to m_fixits_change_set.
* diagnostic.h (diagnostics::edit_context): Drop forward decl
* diagnostics/edit-context.cc: Move to...
* diagnostics/changes.cc: ...here.  Update for move of
diagnostics/edit-context.h to diagnostics/changes.h.
Rename diagnostics::edit_context to
diagnostics::changes::change_set.  Rename diagnostics::edited_file
to diagnostics::changes::changed_file.  Rename
diagnostics::edited_line to diagnostics::changes::changed_line.
* diagnostics/edit-context.h: Move to...
* diagnostics/changes.h: ...here, renaming as above.
* diagnostics/context.h (diagnostics::changes::change_set): New
forward decl.
(diagnostics::context::create_edit_context): Rename to...
(diagnostics::context::initialize_fixits_change_set): ...this.
(diagnostics::context::get_edit_context): Rename to...
(diagnostics::context::get_fixits_change_set): ...this.
(diagnostics::context::m_edit_context_ptr): Rename to...
(diagnostics::context::m_fixits_change_set): ..this and update
type.
* diagnostics/diagnostics-selftests.cc: Update for renaming.
* diagnostics/diagnostics-selftests.h: Likewise.
* diagnostics/html-sink.cc: Update for above changes.
* libgdiagnostics.cc: Likewise.
* toplev.cc: Likewise.

gcc/c-family/ChangeLog:
* c-common.cc: Update comment for renaming of edit_context.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/expensive_selftests_plugin.cc: Update for change
from edit-context.h to changes.h.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: reorganize selftests
David Malcolm [Fri, 25 Jul 2025 19:13:41 +0000 (15:13 -0400)] 
diagnostics: reorganize selftests

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS): Move diagnostics/lazy-paths.o to...
(OBJS-libcommon): ...here.  Add
diagnostics/diagnostics-selftests.o.
* diagnostic.cc: Update for move of
selftest::test_diagnostic_context to
diagnostics::selftest::test_context.
* diagnostics/color.cc: Move selftests from selftest:: to
diagnostics::selftest::.
* diagnostics/diagnostics-selftests.cc: New file.
* diagnostics/diagnostics-selftests.h: New file.
* diagnostics/digraphs.cc: Move selftests from selftest:: to
diagnostics::selftest::.
* diagnostics/edit-context.cc: Likewise.
* diagnostics/html-sink.cc: Likewise.
* diagnostics/lazy-paths.cc: Likewise.  Eliminate use of "tree"
by porting selftests from simple-diagnostic-path.h to
diagnostics/selftest-paths.h.
* diagnostics/output-spec.cc: Move selftests from selftest:: to
diagnostics::selftest::.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/selftest-context.cc: Move
selftest::test_diagnostic_context to
diagnostics::selftest::test_context.
* diagnostics/selftest-context.h: Likewise.
* diagnostics/selftest-logical-locations.cc: Move selftests from
selftest:: to diagnostics::logical_locations::selftest::.
* diagnostics/selftest-logical-locations.h: Move
selftest::logical_location_manager to
diagnostics::logical_locations::selftest::logical_location_manager.
* diagnostics/selftest-paths.cc: Move
selftest::test_diagnostic_path to
diagnostics::paths::selftest::test_path.  Move
selftest::test_diagnostic_event to
diagnostics::paths::selftest::test_event.
* diagnostics/selftest-paths.h: Likewise, and move
selftest::test_diagnostic_thread to
diagnostics::paths::selftest::test_thread.
* diagnostics/selftest-source-printing.h: Move
selftest::diagnostic_show_locus_fixture to
diagnostics::selftest::source_printing_fixture.
* diagnostics/source-printing.cc: Move selftests from selftest::
to diagnostics::selftest:: and update for renames.
* diagnostics/state-graphs.cc: Likewise.
* selftest-run-tests.cc: Include
"diagnostics/diagnostics-selftests.h".
(selftest::run_tests): Replace invocation of the various diagnostics
selftests with a call to
diagnostics::selftest::run_diagnostics_selftests.
* selftest.h: Move decls of the various per-file diagnostics
invocation functions to diagnostics/diagnostics-selftests.h,
renaming due to diagostics prefix being implied by namespace.

gcc/c-family/ChangeLog:
* c-format.cc (test_type_mismatch_range_labels): Update for
move of selftest::test_diagnostic_context to
diagnostics::selftest::test_context.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/expensive_selftests_plugin.cc: Update for move of
selftest::test_diagnostic_context to
diagnostics::selftest::test_context.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: gcc/diagnostic-url.h -> gcc/diagnostics/url.h
David Malcolm [Fri, 25 Jul 2025 19:13:40 +0000 (15:13 -0400)] 
diagnostics: gcc/diagnostic-url.h -> gcc/diagnostics/url.h

No functional change intended.

gcc/ChangeLog:
* common.opt: Update for move of diagnostic-url.h to
diagnostics/url.h.
* diagnostic.cc: Likewise.
* diagnostics/color.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* diagnostic-url.h: Move to...
* diagnostics/url.h: ...here.
* libgdiagnostics.cc: Update for move of diagnostic-url.h to
diagnostics/url.h.
* pretty-print.h: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move gcc/diagnostic-color.{h,cc} to gcc/diagnostics/color.{h,cc}
David Malcolm [Fri, 25 Jul 2025 19:13:40 +0000 (15:13 -0400)] 
diagnostics: move gcc/diagnostic-color.{h,cc} to gcc/diagnostics/color.{h,cc}

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace diagnostic-color.o with
diagnostics/color.o.
(PLUGIN_HEADERS): Remove diagnostic-color.h in favor of glob.
* common.opt: Update for move of diagnostic-color.h to
diagnostics/color.h.
* diagnostic.cc: Likewise.
* diagnostic-color.cc: Move to...
* diagnostics/color.cc: ...here.
* diagnostic-color.h: Move to...
* diagnostics/color.h: ...here.
* diagnostics/edit-context.cc: Update for move of
diagnostic-color.h to diagnostics/color.h.
* diagnostics/output-spec.cc: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/source-printing.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* libgdiagnostics.cc: Likewise.
* opts.cc: Likewise.
* pretty-print-markup.h: Likewise.
* pretty-print.cc: Likewise.
* selftest-run-tests.cc: Likewise.
* selftest.h: Likewise.
* text-art/style.cc: Likewise.

gcc/cp/ChangeLog:
* error.cc: Update for move of diagnostic-color.h to
diagnostics/color.h.

gcc/fortran/ChangeLog:
* error.cc: Update for move of diagnostic-color.h to
diagnostics/color.h.

gcc/m2/ChangeLog:
* gm2-gcc/m2color.cc: Update for move of diagnostic-color.h to
diagnostics/color.h.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Update for move of
diagnostic-color.h to diagnostics/color.h.
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move gcc/selftest-diagnostic.{h,cc} -> gcc/diagnostics/selftest-context...
David Malcolm [Fri, 25 Jul 2025 19:13:40 +0000 (15:13 -0400)] 
diagnostics: move gcc/selftest-diagnostic.{h,cc} -> gcc/diagnostics/selftest-context.{h,cc}

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace selftest-diagnostic.o with
diagnostics/selftest-context.o.
* diagnostic.cc: Update for move of selftest-diagnostic.h to
diagnostics/selftest-context.h.
* diagnostics/html-sink.cc: Likewise.
* diagnostics/lazy-paths.cc: Likewise.
* diagnostics/output-spec.cc: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* selftest-diagnostic.cc: Move to...
* diagnostics/selftest-context.cc: ...here and update for move of
header file.
* selftest-diagnostic.h: Move to...
* diagnostics/selftest-context.h: ...here.
* diagnostics/source-printing.cc: Update for move of
selftest-diagnostic.h to diagnostics/selftest-context.h.

gcc/c-family/ChangeLog:
* c-format.cc: Update for move of selftest-diagnostic.h to
diagnostics/selftest-context.h.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/expensive_selftests_plugin.cc: Update for move of
selftest-diagnostic.h to diagnostics/selftest-context.h.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move buffering code to its own .cc file
David Malcolm [Fri, 25 Jul 2025 19:13:39 +0000 (15:13 -0400)] 
diagnostics: move buffering code to its own .cc file

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add diagnostics/buffering.o.
* diagnostic.cc (diagnostics::context::set_diagnostic_buffer): Move to
diagnostics/buffering.cc.
(diagnostics::context::clear_diagnostic_buffer): Likewise.
(diagnostics::context::flush_diagnostic_buffer): Likewise.
(diagnostics::buffer::buffer): Likewise.
(diagnostics::buffer::~buffer): Likewise.
(diagnostics::buffer::dump): Likewise.
(diagnostics::buffer::empty_p): Likewise.
(diagnostics::buffer::move_to): Likewise.
(diagnostics::buffer::ensure_per_sink_buffers): Likewise.
* diagnostics/buffering.cc: New file, from material in diagnostic.cc.
* diagnostics/buffering.h: Fix comment.
* diagnostics/text-sink.h: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move option_classifier to its own files
David Malcolm [Fri, 25 Jul 2025 19:13:39 +0000 (15:13 -0400)] 
diagnostics: move option_classifier to its own files

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add
diagnostics/option-classifier.o.
* diagnostic.cc (diagnostics::option_classifier::init): Move to
diagnostics/option-classifier.cc.
(diagnostics::option_classifier::fini): Likewise.
(diagnostics::option_classifier::pch_save): Likewise.
(diagnostics::option_classifier::pch_restore): Likewise.
(diagnostics::option_classifier::push): Likewise.
(diagnostics::option_classifier::pop): Likewise.
(diagnostics::option_classifier::classify_diagnostic): Likewise.
(diagnostics::option_classifier::update_effective_level_from_pragmas):
Likewise.
* diagnostics/context.h: Include
"diagnostics/option-classifier.h".
(class option_classifier): Move to
diagnostics/option-classifier.h.
* diagnostics/option-classifier.cc: New file, based on material
from diagnostic.cc.
* diagnostics/option-classifier.h: New file, based on material
from diagnostics/context.h.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move diagnostic_context to diagnostics::context in its own header
David Malcolm [Fri, 25 Jul 2025 19:13:39 +0000 (15:13 -0400)] 
diagnostics: move diagnostic_context to diagnostics::context in its own header

No functional change intended.

gcc/ada/ChangeLog:
* gcc-interface/misc.cc: Update for diagnostic_context becoming
diagnostics::context.

gcc/analyzer/ChangeLog:
* program-point.cc: : Update for diagnostic_context becoming
diagnostics::context, and for diagnostic_source_print_policy
becoming diagnostics::source_print_policy.

gcc/c-family/ChangeLog:
* c-common.h: Update for diagnostic_context becoming
diagnostics::context.
* c-opts.cc: Likewise.

gcc/c/ChangeLog:
* c-objc-common.cc: Update for diagnostic_context becoming
diagnostics::context.
* c-tree.h: Likewise.

gcc/ChangeLog:
* coretypes.h: Update for diagnostic_context becoming
diagnostics::context.
* diagnostic-global-context.cc: Likewise.
* diagnostic.cc: Likewise.  Also for diagnostic_option_classifier
becoming diagnostics::option_classifier.
* diagnostic.h (diagnostic_text_starter_fn): Rename to...
(diagnostics::text_starter_fn): ...this, and move to
diagnostics/context.h.
(get_printer): Rename to...
(diagnostics::get_printer): ...this, and move to
diagnostics/context.h.
(class diagnostic_option_manager): Rename to...
(class diagnostics::option_manager): ...this, and move to
diagnostics/context.h.
(class diagnostic_option_classifier): Rename to...
(class diagnostics::option_classifier): ...this, and move to
diagnostics/context.h.
(struct diagnostic_source_printing_options): Rename to...
(struct diagnostics::source_printing_options): ...this, and move
to diagnostics/context.h.
(class diagnostic_column_policy): Rename to...
(class diagnostics::column_policy): ...this, and move to
diagnostics/context.h.
(class diagnostic_location_print_policy): Rename to...
(class diagnostics::location_print_policy): ...this, and move to
diagnostics/context.h.
(class html_label_writer): Rename to...
(class diagnostics::html_label_writer): ...this, and move to
diagnostics/context.h.
(class diagnostic_source_print_policy): Rename to...
(class diagnostics::source_print_policy): ...this, and move to
diagnostics/context.h.
(struct diagnostic_counters): Rename to...
(struct diagnostics::counters): ...this, and move to
diagnostics/context.h.
(class diagnostic_context): Rename to...
(class diagnostics::context): ...this, and move to
diagnostics/context.h.
(diagnostic_text_starter): Rename to...
(diagnostics::text_starter): ...this, and move to
diagnostics/context.h.
(diagnostic_start_span): Rename to...
(diagnostics::start_span): ...this, and move to
diagnostics/context.h.
(diagnostic_text_finalizer): Rename to...
(diagnostics::text_finalizer): ...this, and move to
diagnostics/context.h.
Include "diagnostics/context.h".
* diagnostics/buffering.h: Update for diagnostic_context becoming
diagnostics::context; similarly for diagnostic_counters.
* diagnostics/client-data-hooks.h: Likewise.
* diagnostics/context.h: New file, taken from material in
diagnostic.h.
* diagnostics/html-sink.cc: : Update for diagnostic_context
becoming diagnostics::context.
* diagnostics/html-sink.h: Likewise.
* diagnostics/lazy-paths.cc: Likewise for
diagnostic_option_manager.
* diagnostics/output-file.h: Likewise for diagnostic_context.
* diagnostics/output-spec.cc: Likewise.
* diagnostics/output-spec.h: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/sarif-sink.h: Likewise.
* diagnostics/sink.h: Likewise.
* diagnostics/source-printing.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* diagnostics/text-sink.h: Likewise.
* gcc-rich-location.h: Likewise.
* gcc.cc: Likewise.
* gdbinit.in: Likewise.
* langhooks-def.h: Likewise.
* langhooks.cc: Likewise.
* langhooks.h: Likewise.
* libgdiagnostics.cc: Likewise.
* optc-gen.awk: Likewise.
* opth-gen.awk: Likewise.
* opts-common.cc: Likewise.
* opts-diagnostic.cc: Likewise.
* opts-diagnostic.h: Likewise.
* opts-global.cc: Likewise.
* opts.cc: Likewise.
* opts.h: Likewise.
* selftest-diagnostic.cc: Likewise.
* selftest-diagnostic.h: Likewise.
* toplev.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
* tree-diagnostic.cc: Likewise.
* tree-diagnostic.h: Likewise.

gcc/cp/ChangeLog:
* cp-tree.h: Update for diagnostic_context becoming
diagnostics::context.
* error.cc: Likewise.
* module.cc: Likewise.

gcc/fortran/ChangeLog:
* error.cc: Update for diagnostic_context becoming
diagnostics::context.

gcc/jit/ChangeLog:
* dummy-frontend.cc: Update for diagnostic_context becoming
diagnostics::context.
* jit-playback.h: Likewise.

gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc: Update for diagnostic_text_finalizer
becoming diagnostics::text_finalizer.
* resolve/rust-late-name-resolver-2.0.cc: Likewise.

gcc/testsuite/ChangeLog:
* g++.dg/plugin/show_template_tree_color_plugin.cc: Update for
moves to namespace diagnostics.
* gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move diagnostic_info to its own header
David Malcolm [Fri, 25 Jul 2025 19:13:38 +0000 (15:13 -0400)] 
diagnostics: move diagnostic_info to its own header

No functional change intended.

gcc/ChangeLog:
* diagnostic.h (struct diagnostic_info): Move to
diagnostics/diagnostic-info.h as diagnostics::diagnostic_info.
Add typedef bringing it back into root namespace, for now.
* diagnostics/diagnostic-info.h: New file, based on the above.
* langhooks-def.h: Update for diagnostic_info moving into
namespace diagnostics.
* langhooks.h: Likewise.

gcc/jit/ChangeLog:
* jit-playback.cc: Update for diagnostic_info moving into
namespace diagnostics.
* jit-playback.h: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: add m_ prefix to fields of diagnostic_info
David Malcolm [Fri, 25 Jul 2025 19:13:38 +0000 (15:13 -0400)] 
diagnostics: add m_ prefix to fields of diagnostic_info

No functional change intended.

gcc/c-family/ChangeLog:
* c-opts.cc (c_diagnostic_text_finalizer): Add "m_" prefix to
fields of diagnostic_info.

gcc/c/ChangeLog:
* c-errors.cc: Update to add "m_" prefix to fields of
diagnostic_info throughout.

gcc/cp/ChangeLog:
* constexpr.cc: Update to add "m_" prefix to fields of
diagnostic_info throughout.
* error.cc: Likewise.

gcc/d/ChangeLog:
* d-diagnostic.cc (d_diagnostic_report_diagnostic): Update to add
"m_" prefix to fields of diagnostic_info throughout.

gcc/ChangeLog:
* diagnostic.cc: Update to add "m_" prefix to fields of
diagnostic_info throughout.
* diagnostic.h: Likewise.
* diagnostics/html-sink.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* libgdiagnostics.cc: Likewise.
* substring-locations.cc: Likewise.
* tree-diagnostic.cc: Likewise.

gcc/fortran/ChangeLog:
* error.cc: Update to add "m_" prefix to fields of
diagnostic_info throughout.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update to
add "m_" prefix to fields of diagnostic_info throughout.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move diagnostic-macro-unwinding.{cc,h} -> diagnostics/macro-unwinding...
David Malcolm [Fri, 25 Jul 2025 19:13:38 +0000 (15:13 -0400)] 
diagnostics: move diagnostic-macro-unwinding.{cc,h} -> diagnostics/macro-unwinding.{cc,h}

gcc/ChangeLog:
* Makefile.in (OBJS): Replace diagnostic-macro-unwinding.o with
diagnostics/macro-unwinding.o.
* diagnostic-macro-unwinding.cc: Move to...
* diagnostics/macro-unwinding.cc: ...here, moving content into
namespace diagnostics.
* diagnostic-macro-unwinding.h: Move to...
* diagnostics/macro-unwinding.h: ...here, moving content into
namespace diagnostics.
* diagnostics/paths-output.cc: Update for move of
"diagnostic-macro-unwinding.h" to "diagnostics/macro-unwinding.h".

gcc/c-family/ChangeLog:
* c-opts.cc: Update for move of "diagnostic-macro-unwinding.h"
to "diagnostics/macro-unwinding.h".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: introduce diagnostics/source-printing.cc
David Malcolm [Fri, 25 Jul 2025 19:13:37 +0000 (15:13 -0400)] 
diagnostics: introduce diagnostics/source-printing.cc

Move diagnostic-show-locus.cc to diagnostics/source-printing.cc

Move diagnostic-label-effects.h to diagnostics/source-printing-effects.h

Move selftest-diagnostic-show-locus.h
  to diagnostics/selftest-source-printing.h

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS): Replace diagnostic-show-locus.o with
diagnostics/source-printing.o.
* diagnostic.h (class diagnostic_source_effect_info): Replace
with...
(class diagnotics::source_effect_info): ...this.
* diagnostics/paths-output.cc: Likewise.  Update for move of
"diagnostic-label-effects.h" to
"diagnostics/source-printing-effects.h".
* diagnostics/sarif-sink.cc: Update for move of
"selftest-diagnostic-show-locus.h" to
"diagnostics/selftest-source-printing.h".
* selftest-diagnostic-show-locus.h: Move to...
* diagnostics/selftest-source-printing.h: ...here.
* diagnostic-label-effects.h: Move to...
* diagnostics/source-printing-effects.h: ...here, updating
for above changes.
* diagnostic-show-locus.cc: Move to...
* diagnostics/source-printing.cc: ...here.
* gcc-rich-location.h: Likewise.
* selftest-run-tests.cc: Likewise.
* selftest.h: Likewise.

gcc/testsuite/ChangeLog:
* g++.dg/plugin/show-template-tree-color-labels.C: Update for
moves to "source-printing".
* gcc.dg/plugin/diagnostic-test-show-locus.py: Likewise.

libcpp/ChangeLog:
* include/cpplib.h: Update for moves to "source-printing".
* include/rich-location.h (class label_effects): Move to...
(class diagnostics::label_effects): ...here.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move/rename output formats to diagnostics as "sinks"
David Malcolm [Fri, 25 Jul 2025 19:13:37 +0000 (15:13 -0400)] 
diagnostics: move/rename output formats to diagnostics as "sinks"

Within gcc/
  move diagnostic-buffer.h to diagnostics/buffering.h
  move diagnostic-format-html.cc to diagnostics/html-sink.cc
  move diagnostic-format-html.h to diagnostics/html-sink.h
  move diagnostic-format-sarif.cc to diagnostics/sarif-sink.cc
  move diagnostic-format-sarif.h to diagnostics/sarif-sink.h
  move diagnostic-format.h to diagnostics/sink.h
  move diagnostic-format-text.cc to diagnostics/text-sink.cc
  move diagnostic-format-text.h to diagnostics/text-sink.h

renaming various types including:
  Old name:                       New name:
  diagnostic_output_format        diagnostics::sink
  diagnostic_buffer               diagnostics::buffer
  diagnostic_per_format_buffer    diagnostics::per_sink_buffer
  diagnostic_text_output_format   diagnostics::text_sink
  sarif_output_format             diagnostics::sarif_sink
  diagnostic_sarif_format_buffer  diagnostics::sarif_sink_buffer
  html_output_format              diagnostics::html_sink
  diagnostic_html_format_buffer   diagnostics::html_sink_buffer

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS): Replace diagnostic-format-html.o with
diagnostics/html-sink.o, diagnostic-format-sarif.o with
diagnostics/sarif-sink.o, and diagnostic-format-text.o with
diagnostics/text-sink.o.
* coretypes.h (class diagnostic_text_output_format): Replace
with...
(class diagnostics::text_sink): ...this.
* diagnostic-global-context.cc: Update for move of diagnostics
output formats into namespace "diagnostics", as "sinks".
* diagnostic-macro-unwinding.cc: Likewise.
* diagnostic-macro-unwinding.h: Likewise.
* diagnostic-show-locus.cc: Likewise.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostic-buffer.h: Rename to...
* diagnostics/buffering.h: ...this, updating for above changes.
* diagnostics/client-data-hooks.h: Likewise.
* diagnostics/digraphs.cc: Likewise.
* diagnostic-format-html.cc: Rename to...
* diagnostics/html-sink.cc: ...this, updating for above changes.
* diagnostic-format-html.h: Rename to...
* diagnostics/html-sink.h: ...this, updating for above changes.
* diagnostics/lazy-paths.cc: Likewise.
* diagnostics/metadata.h: Likewise.
* diagnostics/output-spec.cc: Likewise.
* diagnostics/output-spec.h: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/paths.h: Likewise.
* diagnostic-format-sarif.cc: Rename to...
* diagnostics/sarif-sink.cc: ...this, updating for above changes.
* diagnostic-format-sarif.h: Rename to...
* diagnostics/sarif-sink.h: ...this, updating for above changes.
* diagnostic-format.h: Rename to...
* diagnostics/sink.h: ...this, updating for above changes.
* diagnostics/state-graphs-to-dot.cc: Likewise.
* diagnostic-format-text.cc: Rename to...
* diagnostics/text-sink.cc: ...this, updating for above changes.
* diagnostic-format-text.h: Rename to...
* diagnostics/text-sink.h: ...this, updating for above changes.
* gcc.cc: Likewise.
* langhooks-def.h: Likewise.
* langhooks.cc: Likewise.
* langhooks.h: Likewise.
* libgdiagnostics.cc: Likewise.
* opts-diagnostic.cc: Likewise.
* opts.cc: Likewise.
* selftest-diagnostic.cc: Likewise.
* selftest-run-tests.cc: Likewise.
* selftest.h: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
* tree-diagnostic.cc: Likewise.

gcc/analyzer/ChangeLog:
* ana-state-to-diagnostic-state.cc: Update for move of
diagnostics output formats into namespace "diagnostics" as
"sinks".
* bounds-checking.cc: Likewise.
* call-details.cc: Likewise.
* checker-event.cc: Likewise.
* checker-event.h: Likewise.
* diagnostic-manager.cc: Likewise.
* diagnostic-manager.h: Likewise.
* infinite-loop.cc: Likewise.
* infinite-recursion.cc: Likewise.
* pending-diagnostic.h: Likewise.
* region-model.cc: Likewise.
* sm-taint.cc: Likewise.

gcc/c-family/ChangeLog:
* c-opts.cc: Update for move of diagnostics output formats into
namespace "diagnostics" as "sinks".

gcc/cp/ChangeLog:
* cp-tree.h: Update for move of diagnostics output formats into
namespace "diagnostics" as "sinks".
* error.cc: Likewise.

gcc/fortran/ChangeLog:
* error.cc: Update for move of diagnostics output formats into
namespace "diagnostics" as "sinks".
* gfortran.h: Likewise.

gcc/jit/ChangeLog:
* dummy-frontend.cc: Update for move of diagnostics output formats
into namespace "diagnostics" as "sinks".

gcc/rust/ChangeLog:
* resolve/rust-ice-finalizer.cc: Update for move of diagnostics
output formats into namespace "diagnostics" as "sinks".
* resolve/rust-ice-finalizer.h: Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_group_plugin.cc: Update for move of
diagnostics output formats into namespace "diagnostics" as
"sinks".
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.

libcc1/ChangeLog:
* context.cc: Update for move of diagnostics output formats into
namespace "diagnostics" as "sinks".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: introduce namespace diagnostics::paths
David Malcolm [Fri, 25 Jul 2025 19:13:36 +0000 (15:13 -0400)] 
diagnostics: introduce namespace diagnostics::paths

Move more diagnostic-specific code from gcc/ to gcc/diagnostics/

No functional change intended.

contrib/ChangeLog:
* filter-clang-warnings.py: Update for move of
diagnostic-path-output.cc to diagnostics/paths-output.cc.

gcc/ChangeLog:
* Makefile.in (OBJS): Replace lazy-diagnostic-path.o with
diagnostics/lazy-paths.o.
(OBJS-libcommon): Replace diagnostic-path.o with
diagnostics/paths.o, diagnostic-path-output.o with
diagnostics/paths-output.o, and selftest-diagnostic-path.o with
diagnostics/selftest-paths.o.
(EXTRA_BACKEND_OBJS): Replace lazy-diagnostic-path.o with
diagnostics/lazy-paths.o.
* diagnostic-format-html.cc: Update #include for
"diagnostic-path.h" moving to "diagnostics/paths.h",
diagnostic_thread_id_t to diagnostics::paths::thread_id_t,
diagnostic_event_id_t to diagnostics::paths::event_id_t,
diagnostic_path to diagnostics::paths::path, and
diagnostic_thread to diagnostics::paths::thread, and
diagnostic_event to diagnostics::paths::event.
* diagnostic-format-html.h: Likewise.
* diagnostic-format-sarif.cc: Likewise.  Update PROPERTY_PREFIX
for threadFlowLocations from "gcc/diagnostic_event/" to
"gcc/diagnostics/paths/event/".
* diagnostic-format-text.cc: Likewise.
* diagnostic-format-text.h: Likewise.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostic-event-id.h: Move to...
* diagnostics/event-id.h: ...here, updating header guard.
(diagnostics:paths:event_id_t): New typedef.
(diagnostic_thread_id_t): Replace with...
(diagnostics:paths:thread_id_t): New typedef.
* lazy-diagnostic-path.cc: Move to...
* diagnostics/lazy-paths.cc: ...here.  Update for above changes,
lazy_diagnostic_path becomes diagnostics::paths::lazy_path.
(lazy_diagnostic_path_cc_tests): Rename to...
(diagnostics_lazy_paths_cc_tests): ...this.
* lazy-diagnostic-path.h: Move to...
* diagnostics/lazy-paths.h: ...here, updating header guard.
Update for above changes.
* diagnostic-path-output.cc: Move to...
* diagnostics/paths-output.cc: ...here.  Update for above changes.
(diagnostic_path_output_cc_tests): Rename to...
(diagnostics_paths_output_cc_tests): ...this.
* diagnostic-path.cc: Move to...
* diagnostics/paths.cc: ...here.  Update for above changes.
* diagnostic-path.h: Move to...
* diagnostics/paths.h: ...here, updating header guard.
Update #include for moving "diagnostic-event-id.h" to
"diagnostics/event-id.h".
(class diagnostic_event): Convert to...
(class diagnostics::paths::event): ...this.
(class diagnostic_thread): Convert to...
(class diagnostics::paths::thread): ...this.
(class diagnostic_path): Convert to...
(class diagnostics::paths::path): ...this.
* diagnostic-show-locus.cc: Update for above changes.
* doc/analyzer.texi: Likewise.
* selftest-diagnostic-path.cc: Move to...
* diagnostics/selftest-paths.cc: ...here.  Update for
above changes, and for "selftest-diagnostic-path.h" moving to
"diagnostics/selftest-paths.h".
* selftest-diagnostic-path.h: Move to...
* diagnostics/selftest-paths.h: ...here, updating header guard.
Update for above changes.
* libgdiagnostics.cc: Update for above changes.
* libsarifreplay.cc: Update property prefix for
threadFlowLocations from "gcc/diagnostic_event/" to
"gcc/diagnostics/paths/event/".
* pretty-print-format-impl.h: Update for above changes.
* pretty-print.cc: Likewise.
* selftest-run-tests.cc (selftest::run_tests): Update for
renaming of lazy_diagnostic_path_cc_tests to
diagnostics_lazy_paths_cc_tests, and of
diagnostic_path_output_cc_tests to
diagnostics_paths_output_cc_tests.
* selftest.h (lazy_diagnostic_path_cc_tests): Replace decl with...
(diagnostics_lazy_paths_cc_tests): ...this.
(diagnostic_path_output_cc_tests): Replace decl with...
(diagnostics_paths_output_cc_tests): ...this.
* simple-diagnostic-path.cc: Clarify that this relates to "tree"
and thus shouldn't be in "diagnostics".  Update for above changes.
* simple-diagnostic-path.h: Likewise.

gcc/analyzer/ChangeLog:
* access-diagram.cc: Update for changes to diagnostic paths:
"diagnostic-path.h" moving to "diagnostics/paths.h",
"diagnostic-event-id.h" moving to "diagnostics/event-id.h",
diagnostic_event_id_t to diagnostics::paths::event_id_t,
diagnostic_path to diagnostics::paths::path, and
diagnostic_event to diagnostics::paths::event.
* access-diagram.h: Likewise.
* analyzer.cc: Likewise.
* bounds-checking.cc: Likewise.
* call-info.cc: Likewise.
* checker-event.cc: Likewise.
* checker-event.h: Likewise.
* checker-path.cc: Likewise.
* checker-path.h: Likewise.
* common.h: Likewise.
* diagnostic-manager.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* pending-diagnostic.h: Likewise.
* program-point.cc: Likewise.
* program-state.cc: Likewise.
* region-model.cc: Likewise.
* sm-fd.cc: Likewise.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-pattern-test.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* varargs.cc: Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.cc: Update #include for
"diagnostic-path.h" moving to "diagnostics/paths.h",
diagnostic_thread_id_t to diagnostics::paths::thread_id_t,
diagnostic_event_id_t to diagnostics::paths::event_id_t,
diagnostic_path to diagnostics::paths::path, and
diagnostic_thread to diagnostics::paths::thread, and
diagnostic_event to diagnostics::paths::event.
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise.
* lib/sarif.py (get_state_graph): Update property prefix for
threadFlowLocations from "gcc/diagnostic_event/" to
"gcc/diagnostics/paths/event/".
* gcc.dg/sarif-output/include-chain-2.h: Update comment.

libcpp/ChangeLog:
* include/rich-location.h: Replace diagnostic_path with
diagnostics::paths::path.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move diagnostics_output_spec to diagnostics::output_spec
David Malcolm [Fri, 25 Jul 2025 19:13:36 +0000 (15:13 -0400)] 
diagnostics: move diagnostics_output_spec to diagnostics::output_spec

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace diagnostic-output-spec.o
with diagnostics/output-spec.o.
* diagnostic-output-spec.cc: Move to...
* diagnostics/output-spec.cc: ...here.  Update #include for
move of diagnostic-output-spec.h to diagnostics/output-spec.h.
(namespace::diagnostics_output_spec): Replace with...
(namespace diagnostics::output_spec): ...this, removing redundant
prefixes.
(diagnostics_output_spec::gcc_spec_context): Replace with...
(diagnostics::output_spec::dc_spec_context): ...this.
(diagnostic_output_spec_cc_tests): Rename to...
(diagnostics_output_spec_cc_tests): ...this.
* diagnostic-output-spec.h: Move to...
* diagnostics/output-spec.h: ...here and update inclusion guard.
(namespace::diagnostics_output_spec): Replace with...
(namespace diagnostics::output_spec): ...this, removing redundant
prefixes.
(diagnostics_output_spec::gcc_spec_context): Replace with...
(diagnostics::output_spec::dc_spec_context): ...this.
* libgdiagnostics.cc: Update #include for move of
diagnostic-output-spec.h to diagnostics/output-spec.h.
* opts-diagnostic.cc: Likewise.  Update for namespace and name
changes.
* selftest-run-tests.cc (selftest::run_tests): Update for renaming
of diagnostic_output_spec_cc_tests to
diagnostics_output_spec_cc_tests.
* selftest.h (diagnostic_output_spec_cc_tests): Rename decl to...
(diagnostics_output_spec_cc_tests): ...this.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: rename diagnostic_output_file to diagnostics::output_file
David Malcolm [Fri, 25 Jul 2025 19:13:36 +0000 (15:13 -0400)] 
diagnostics: rename diagnostic_output_file to diagnostics::output_file

No functional change intended.

gcc/ChangeLog:
* diagnostic-format-html.cc: Update #include for move of
diagnostic-output-file.h to diagnostics/output-file.h.  Update for
move of diagnostic_output_file to diagnostics::output_file.
* diagnostic-format-html.h: Likewise.
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-sarif.h: Likewise.
* diagnostic-output-spec.cc: Likewise.
* diagnostic-output-spec.h (along): Likewise.
* diagnostic-output-file.h: Move to...
* diagnostics/output-file.h: ...here, updating header guard.
(class diagnostic_output_file): Move to...
(class diagnostics::output_file): ...here.
* libgdiagnostics.cc (sarif_sink::sarif_sink): Update for
move of diagnostic_output_file to diagnostics::output_file.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move client data hooks into namespace/dir "diagnostics"
David Malcolm [Fri, 25 Jul 2025 19:13:36 +0000 (15:13 -0400)] 
diagnostics: move client data hooks into namespace/dir "diagnostics"

No functional change intended.

Note that the tree-*.cc implementations are *not* moved into namespace
diagnostics.

gcc/ChangeLog:
* diagnostic-format-html.cc: Update #include for move of
diagnostic-client-data-hooks.h to diagnostics/client-data-hooks.h.
* diagnostic-format-sarif.cc: Likewise.  Update for move of
diagnostic_client_plugin_info to diagnostics::client_plugin_info.
* diagnostic-format-text.cc: Likewise.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostic-client-data-hooks.h: Move to...
* diagnostics/client-data-hooks.h: ...here, updating header guard.
(class diagnostic_client_data_hooks): Move to...
(class diagnostics::client_data_hooks): ...here.  Remove redundant
"diagnostics::" prefixes.
(class diagnostic_client_plugin_info): Move to...
(class diagnostics::client_plugin_info): ...here.
* libgdiagnostics.cc: : Update #include for move of
diagnostic-client-data-hooks.h to diagnostics/client-data-hooks.h.
Update for move of diagnostic_client_data_hooks to
diagnostics::client_data_hooks, and for move of
diagnostic_client_version_info to diagnostics::client_version_info.
* tree-diagnostic-client-data-hooks.cc: Likewise.
* tree-diagnostic.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move edit_context to namespace/dir "diagnostics"
David Malcolm [Fri, 25 Jul 2025 19:13:35 +0000 (15:13 -0400)] 
diagnostics: move edit_context to namespace/dir "diagnostics"

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace edit-context.o with
diagnostics/edit-context.o.
* diagnostic-format-html.cc: Update #include for move
of edit-context.h to diagnostics subdir.
* diagnostic.cc: Likewise.  Update for move of edit_context to
diagnostics::edit_context.
* diagnostic.h: Likewise.
* edit-context.cc: Move to...
* diagnostics/edit-context.cc: ...here.  Update #include for move
of edit-context.h to diagnostics subdir.  Move all code
within namespace diagnostics.
* edit-context.h: Move to...
* diagnostics/edit-context.h: ...here, updating header guard.
Move all code within namespace diagnostics.
* libgdiagnostics.cc: Update #include for move of edit-context.h
to diagnostics subdir.  Update for move of edit_context
to diagnostics::edit_context.
* toplev.cc: Update #include for move of edit-context.h
to diagnostics subdir.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/expensive_selftests_plugin.cc: Update #include for
move of edit-context.h to diagnostics subdir.  Update
for move of edit_context to diagnostics::edit_context.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move diagnostic_diagram to diagnostics::diagram
David Malcolm [Fri, 25 Jul 2025 19:13:35 +0000 (15:13 -0400)] 
diagnostics: move diagnostic_diagram to diagnostics::diagram

No functional change intended.

gcc/analyzer/ChangeLog:
* bounds-checking.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for
move of diagnostic_diagram to diagnostics::diagram.

gcc/ChangeLog:
* diagnostic-format-html.cc: Update for move of diagnostic_diagram
to diagnostics::diagram.
* diagnostic-format-sarif.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for move
of diagnostic_diagram to diagnostics::diagram.
* diagnostic-format-text.cc: Likewise.
* diagnostic-format-text.h: Update for move of diagnostic_diagram
to diagnostics::diagram.
* diagnostic-format.h: Likewise.
* diagnostic.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for move
of diagnostic_diagram to diagnostics::diagram.
* diagnostic.h: Update for move of diagnostic_diagram to
diagnostics::diagram.
* diagnostic-diagram.h: Move to...
* diagnostics/diagram.h: ...here.
(class diagnostic_diagram): Convert to...
(class diagnostics::diagram): ...this.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_text_art.cc: Update
#include for move of "diagnostic-diagram.h" to
"diagnostics/diagram.h". Update for move of diagnostic_diagram to
diagnostics::diagram.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move diagnostic_metadata to diagnostics::metadata
David Malcolm [Fri, 25 Jul 2025 19:13:35 +0000 (15:13 -0400)] 
diagnostics: move diagnostic_metadata to diagnostics::metadata

renamed: gcc/diagnostic-metadata.h -> gcc/diagnostics/metadata.h

No functional change intended.

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc: Update for move of diagnostic_metadata to
diagnostics::metadata.
* kf.cc: Likewise.
* pending-diagnostic.h: Likewise; also, update #include for move
of "diagnostic-metadata.h" to "diagnostics/metadata.h".

gcc/cobol/ChangeLog:
* util.cc: Remove redundant #includes

gcc/ChangeLog:
* diagnostic-core.h: Update for move of diagnostic_metadata to
diagnostics::metadata.
* diagnostic-format-html.cc: Likewise; also, update #include for
move of "diagnostic-metadata.h" to "diagnostics/metadata.h".
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-text.cc: Likewise.
* diagnostic-global-context.cc: Likewise.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostic-metadata.h: Move to...
* diagnostics/metadata.h: ...here, updating header guard.
(class diagnostic_metadata): Move to...
(class diagnostics::metadata): ...here.  Drop redundant
"diagnostics::" qualifiers.
* libgdiagnostics.cc: : Update #include for move of
"diagnostic-metadata.h" to "diagnostics/metadata.h", and update
for move of diagnostic_metadata to diagnostics::metadata.
* selftest-diagnostic.cc: Update for move of diagnostic_metadata
to diagnostics::metadata.
* selftest-diagnostic.h: Likewise.

gcc/rust/ChangeLog:
* rust-diagnostics.cc: Update #include for move of
"diagnostic-metadata.h" to "diagnostics/metadata.h", and update
for move of diagnostic_metadata to diagnostics::metadata.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: : Update #include for
move of "diagnostic-metadata.h" to "diagnostics/metadata.h"
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc: Likewise.  Also
update for move of diagnostic_metadata to diagnostics::metadata.
* gcc.dg/plugin/diagnostic_plugin_test_metadata.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: move logical locations into "diagnostics"
David Malcolm [Fri, 25 Jul 2025 19:13:34 +0000 (15:13 -0400)] 
diagnostics: move logical locations into "diagnostics"

This patch moves gcc/logical-locations.h into gcc/diagnostics
and moves the classes into "namespace diagnostics", to better
indicate that this is part of the shared diagnostics code.

The type "logical_location" becomes diagnostics::logical_locations::key,
the class logical_location_manager becomes
class diagnostics::logical_locations::manager, and the enum
enum logical_location_kind becomes
enum diagnostics::logical_locations::kind.

Note that tree-logical-locations.{h,cc} are *not* part
of "namespace diagnostics", as they use tree.

  renamed:    gcc/logical-location.h -> gcc/diagnostics/logical-locations.h
  renamed:    gcc/selftest-logical-location.cc -> gcc/diagnostics/selftest-logical-locations.cc
  renamed:    gcc/selftest-logical-location.h -> gcc/diagnostics/selftest-logical-locations.h

No functional change intended.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Replace
selftest-logical-location.o with
diagnostics/selftest-logical-locations.o.
* diagnostic-client-data-hooks.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, and of logical_location
to diagnostics::logical_locations::key.
* diagnostic-format-html.cc: Add "using namespace diagnostics;",
and drop now-redundant "diagnostics::" prefixes.
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* diagnostic-format-sarif.cc: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".  Add
"using namespace diagnostics;", and drop now-redundant
"diagnostics::" prefixes.
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* diagnostic-format-sarif.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location to
diagnostics::logical_locations::key.
* diagnostic-path-output.cc: Add "using namespace diagnostics;".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, and
of logical_location to diagnostics::logical_locations::key,
* diagnostic-path.cc: Add "using namespace diagnostics;".
Update for conversion of logical_location to
diagnostics::logical_locations::key.
* diagnostic-path.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, and of logical_location
to diagnostics::logical_locations::key,
* diagnostic.cc: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* diagnostic.h: Reorganize forward decls.
(class logical_location_manager): Replace this forward decl
with...
(class diagnostics::logical_locations::manager): ...this.
(diagnostic_context::get_logical_location_manager): Update
return type.
* diagnostics/digraphs.h: : Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location to
diagnostics::logical_locations::key.
* logical-location.h: Move to...
* diagnostics/logical-locations.h: ...here.
(enum class logical_location_kind): Convert to...
(enum class diagnostics::logical_locations::kind): ... this.
(class logical_location_manager::key): Convert to...
(class diagnostics::logical_locations::key): ... this.
(class logical_location_manager): Convert to...
(class diagnostics::logical_locations::manager): ... this.
(logical_location): Drop this typedef in favor of
diagnostics::logical_locations::key.
* selftest-logical-location.cc: Move to...
* diagnostics/selftest-logical-locations.cc: ...here.
Update #include for move of "selftest-logical-location.h" to
"diagnostics/selftest-logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
(selftest_logical_location_cc_tests): Rename to...
(diagnostics_selftest_logical_locations_cc_tests): ...this.
* selftest-logical-location.h: Move to...
* diagnostics/selftest-logical-locations.h: ...here, updating
include guard.
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* diagnostics/state-graphs-to-dot.cc: Add
"using namespace diagnostics;" and drop now-redundant
"diagnostics::" prefixes.
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager.
* diagnostics/state-graphs.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager,
of logical_location to diagnostics::logical_locations::key.
* libgdiagnostics.cc: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, and of logical_location
to diagnostics::logical_locations::key.
* selftest-diagnostic-path.cc: Update for conversion of
logical_location to diagnostics::logical_locations::key.
* selftest-diagnostic-path.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location to
diagnostics::logical_locations::key.
* selftest-run-tests.cc (selftest::run_tests): Update for
renaming of selftest_logical_location_cc_tests to
diagnostics_selftest_logical_locations_cc_tests.
* selftest.h: Likewise.
* simple-diagnostic-path.h: Update for conversion of
logical_location to diagnostics::logical_locations::key.
* tree-diagnostic-client-data-hooks.cc: Update for conversion of
logical_location_manager to
diagnostics::logical_locations::manager, and of logical_location
to diagnostics::logical_locations::key.
* tree-logical-location.cc: Update for conversions.
Update for conversion of logical_location to
diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.
* tree-logical-location.h: Update #include for move of
"logical-location.h" to "diagnostics/logical-locations.h".
Update for conversion of logical_location_manager to
diagnostics::logical_locations::manager, of logical_location
to diagnostics::logical_locations::key, and of
enum logical_location_kind to
enum diagnostics::logical_locations::kind.

gcc/analyzer/ChangeLog:
* checker-event.h (checker_event::get_logical_location): Update
for conversion of logical_location to
diagnostics::logical_locations::key.
(checker_event::m_logical_loc): Likewise.
* diagnostic-manager.cc
(diagnostic_manager::get_logical_location_manager): Likewise.
* diagnostic-manager.h
(diagnostic_manager::get_logical_location_manager): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agodiagnostics: introduce a "gcc/diagnostics" subdirectory
David Malcolm [Fri, 25 Jul 2025 19:13:34 +0000 (15:13 -0400)] 
diagnostics: introduce a "gcc/diagnostics" subdirectory

The "gcc" subdirectory of our source tree currently contains a total
of almost 1000 .cc and .h files, enough to hit rate-limiting in some
git web UIs, and obscuring the logical relationships between subsystems.

In r16-2211-ga5d9debedd2f46 I started introducing a
"namespace diagnostics" so it makes sense to move such code
into a new "gcc/diagnostics" subdirectory.

My intent is for the "diagnostics" namespace/directory to contain
shared parts of the diagnostics code that are in libcommon, in
particular which don't have knowledge of trees.

This patch begins moving of the existing code within
"namespace diagnostics" into a new "gcc/diagnostics" subdirectory.

No functional change intended.

  renamed:    gcc/diagnostic-digraphs.cc -> gcc/diagnostics/digraphs.cc
  renamed:    gcc/diagnostic-digraphs.h -> gcc/diagnostics/digraphs.h
  renamed:    gcc/diagnostic-state-to-dot.cc -> gcc/diagnostics/state-graphs-to-dot.cc
  renamed:    gcc/diagnostic-state-graphs.cc -> gcc/diagnostics/state-graphs.cc
  renamed:    gcc/diagnostic-state-graphs.h -> gcc/diagnostics/state-graphs.h

contrib/ChangeLog:
* gcc.doxy (INPUT): Add gcc/diagnostics subdir.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Rename diagnostic-digraphs.o to
diagnostics/digraphs.o.  Rename diagnostic-state-graphs.o to
diagnostics/state-graphs.o.  Rename diagnostic-state-to-dot.o to
diagnostics/state-graphs-to-dot.o.
(PLUGIN_HEADERS): Add $(srcdir)/diagnostics/*.h.
(install-plugin:): Likewise.
* configure: Regenerate.
* configure.ac (gccdepdir): Add "diagnostics" to directories.
* diagnostic-format-html.cc: Update #includes for move of
"diagnostic-digraphs.h" to "diagnostics/digraphs.h" and of
move of "diagnostic-state-graphs.h" to
"diagnostics/state-graphs.h".
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-path.cc: Likewise for state-graphs.h
* diagnostic-digraphs.cc: Move...
* diagnostics/digraphs.cc: ...to here.  Update #include
for renaming of digraphs.h.
(selftest::diagnostic_digraphs_cc_tests): Rename to...
(selftest::diagnostics_digraphs_cc_tests): ...this.
* diagnostic-digraphs.h: Move...
* diagnostics/digraphs.h: ...to here, updating header guard.
* diagnostic-state-to-dot.cc: Move...
* diagnostics/state-graphs-to-dot.cc: ...to here.  Update #include
of state-graphs.h.
* diagnostic-state-graphs.cc: Move...
* diagnostics/state-graphs.cc: ...to here.  Update #include
of state-graphs.h.
(selftest::diagnostic_state_graphs_cc_tests): Rename...
(selftest::diagnostics_state_graphs_cc_tests): ...to this.
* diagnostic-state-graphs.h: Move...
* diagnostics/state-graphs.h: ...to here, updating header guard.
* libgdiagnostics.cc: Update #includes for move of
"diagnostic-digraphs.h" to "diagnostics/digraphs.h" and of
move of "diagnostic-state-graphs.h" to
"diagnostics/state-graphs.h".
* selftest-run-tests.cc (selftest::run_tests): Update for
function renamings that reflect file renamings.
* selftest.h (selftest::diagnostic_digraphs_cc_tests): Rename
to...
(selftest::diagnostics_digraphs_cc_tests): ...this.
(selftest::diagnostic_state_graphs_cc_tests): Rename...
(selftest::diagnostics_state_graphs_cc_tests): ...to this.

gcc/analyzer/ChangeLog:
* ana-state-to-diagnostic-state.cc: Update #include for move of
"diagnostic-state-graphs.h" to "diagnostics/state-graphs.h".
* ana-state-to-diagnostic-state.h: Likewise.
* checker-event.cc: Likewise.
* checker-event.h: Update #include for move of
"diagnostic-digraphs.h" to "diagnostics/digraphs.h".
* program-state.cc: : Update #include for move of
"diagnostic-state-graphs.h" to "diagnostics/state-graphs.h".

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc: Update #include
for move of "diagnostic-digraphs.h" to "diagnostics/digraphs.h".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
6 days agoc++: more name lookup for non-dep rewritten cmp ops
Patrick Palka [Fri, 25 Jul 2025 14:55:35 +0000 (10:55 -0400)] 
c++: more name lookup for non-dep rewritten cmp ops

As a follow-up to r16-2448-g7590c14b53a762, this patch attempts to teach
build_min_non_dep_op_overload how to rebuild all rewritten comparison
operators, not just != -> == ones, so that we don't incorrectly repeat
the unqualified name lookup at instantiation time.

Note that changes how we mangle such comparison ops, in a way that is
overall more consistent with how we've been mangling non-rewritten
operators, see PR c++/121239.

gcc/cp/ChangeLog:

* call.cc (build_new_op): If the selected candidate is
rewritten, communicate the LOOKUP_REWRITTEN/REVERSED flags to
the caller via the 'overload' out-parameter, and stop clearing
'*overload' in that case.
* tree.cc (build_min_non_dep_op_overload): Handle rebuilding all
C++20 rewritten comparison operator expressions.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/operator-8.C: Remove XFAILs and properly
suppress all -Wunused-result warnings.

Reviewed-by: Jason Merrill <jason@redhat.com>
6 days agoRemove now redundant vect_get_vec_defs overload
Richard Biener [Fri, 25 Jul 2025 13:03:36 +0000 (15:03 +0200)] 
Remove now redundant vect_get_vec_defs overload

The following removes the vect_get_vec_defs overload receiving
a vector type to be used for the possibly constant/invariant
operand.  This was used for non-SLP code generation as there
constants/invariants are generated on the fly.  It also elides
the stmt_vec_info and ncopies argument which are not required
for SLP.

* tree-vectorizer.h (vect_get_vec_defs): Remove overload
with operand vector type.  Remove stmt_vec_info and
ncopies argument.
* tree-vect-stmts.cc (vect_get_vec_defs): Likewise.
(vectorizable_conversion): Adjust by not passing in
vector types, stmt_vec_info and ncopies.
(vectorizable_bswap): Likewise.
(vectorizable_assignment): Likewise.
(vectorizable_shift): Likewise.
(vectorizable_operation): Likewise.
(vectorizable_scan_store): Likewise.
(vectorizable_store): Likewise.
(vectorizable_condition): Likewise.
(vectorizable_comparison_1): Likewise.
* tree-vect-loop.cc (vect_transform_reduction): Likewise.
(vect_transform_lc_phi): Likewise.

6 days agoTidy vect_is_simple_use API for SLP only
Richard Biener [Fri, 25 Jul 2025 12:04:50 +0000 (14:04 +0200)] 
Tidy vect_is_simple_use API for SLP only

The following removes one vect_is_simple_use overload that shouldn't
be used anymore after removing the single remaining use related
to gather handling in get_group_load_store_type.  It also removes
the dual-purpose of the overload getting both SLP node and
stmt_vec_info and removes the latter argument.

That leaves us with a SLP overload handling vector code and the
stmt_info overload handling scalar code.  In theory the former
is only convenience and it should never fail given SLP build
checks the constraint already, but there's the 'op' argument
we have to get rid of first.

* tree-vectorizer.h (vect_is_simple_use): Remove stmt-info
with vectype output overload and remove stmt-info argument
from SLP based API.
* tree-vect-loop.cc (vectorizable_lane_reducing): Remove
unused def_stmt_info output argument to vect_is_simple_use.
Adjust.
* tree-vect-stmts.cc (get_group_load_store_type): Get
the gather/scatter offset vector type from the SLP child.
(vect_check_scalar_mask): Remove stmt_info argument.  Adjust.
(vect_check_store_rhs): Likewise.
(vectorizable_call): Likewise.
(vectorizable_simd_clone_call): Likewise.
(vectorizable_conversion): Likewise.
(vectorizable_assignment): Likewise.
(vectorizable_shift): Likewise.
(vectorizable_operation): Likewise.
(vectorizable_load): Likewise.
(vect_is_simple_cond): Remove stmt_info argument.  Adjust.
(vectorizable_condition): Likewise.
(vectorizable_comparison_1): Likewise.
(vectorizable_store): Likewise.
(vect_is_simple_use): Remove overload and non-SLP path.

6 days agoFix and simplify vect_model_simple_cost
Richard Biener [Fri, 25 Jul 2025 11:38:48 +0000 (13:38 +0200)] 
Fix and simplify vect_model_simple_cost

There's no longer any call without SLP node so we don't need dts.
I also figured based on the callers that some expect to cost
more than one stmt but still N times so this changes what we cost.

* tree-vect-stmts.cc (vect_model_simple_cost): Removed code
when no SLP node is passed, remove then unused dt and ndts
parameters and fix the number of vector stmts calculation.
(vectorizable_call): Adjust.
(vectorizable_simd_clone_call): Likewise.
(vectorizable_conversion): Likewise.
(vectorizable_assignment): Likewise.
(vectorizable_shift): Likewise.
(vectorizable_operation): Likewise.
(vectorizable_condition): Likewise.
(vectorizable_comparison_1): Likewise.

6 days agoRISC-V: Prepare dynamic LMUL heuristic for SLP.
Robin Dapp [Mon, 21 Jul 2025 14:00:51 +0000 (16:00 +0200)] 
RISC-V: Prepare dynamic LMUL heuristic for SLP.

This patch prepares the dynamic LMUL vector costing to use the coming
SLP_TREE_TYPE instead of the (to-be-removed) STMT_VINFO_TYPE.

Even though the whole approach should be reviewed and adjusted at some
point, the patch chooses the path of least resistance and uses a hash
map for the stmt_info -> slp node relationship.  A node is mapped to the
accompanying stmt_info during add_stmt_cost.  In finish_cost we go
through all statements as before, and obtain the corresponding slp nodes
as well as their types.

This allows us to operate largely as before.  We don't yet do the switch
over from STMT_VINFO_TYPE to SLP_TREE_TYPE, though but only take care
of the necessary refactoring upfront.

Regtested on rv64gcv_zvl512b with -mrvv-max-lmul=dynamic.  There are a
few regressions but nothing worse than what we already have.  I'd rather
accept these now and take it as an incentive to work on the heuristic
later than block the SLP work until it is fixed.

gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc (get_live_range):
Move compute_local_program_points to cost class.
(variable_vectorized_p): Add slp node parameter.
(need_additional_vector_vars_p): Move from here...
(costs::need_additional_vector_vars_p): ... to here and add slp
parameter.
(compute_estimated_lmul): Move update_local_live_ranges to cost
class.
(has_unexpected_spills_p): Move from here...
(costs::has_unexpected_spills_p): ... to here.
(costs::record_lmul_spills): New function.
(costs::add_stmt_cost): Add stmt_info, slp mapping.
(costs::finish_cost): Analyze loop.
* config/riscv/riscv-vector-costs.h: Move declarations to class.

6 days agolibstdc++: doc: Rectify referencing of non-existent type
Tuur Martens [Tue, 22 Jul 2025 08:02:53 +0000 (08:02 +0000)] 
libstdc++: doc: Rectify referencing of non-existent type

The unordered_map header incorrectly refers to a non-existent template parameter
_Value in default template argument descriptions. They should refer to _Key instead.

This patch fixes these descriptions to match the actual template parameters.

libstdc++-v3/ChangeLog:

* include/bits/unordered_map.h: Rectify referencing of
non-existent type.

6 days agoReduce the number of STMT_VINFO_VECTYPE uses
Richard Biener [Fri, 25 Jul 2025 10:34:44 +0000 (12:34 +0200)] 
Reduce the number of STMT_VINFO_VECTYPE uses

The following adjusts uses of STMT_VINFO_VECTYPE to look elsewhere
where obvious.

* tree-vect-loop.cc (vect_analyze_loop_2): Get vectype
from the SLP node.
(vectorize_fold_left_reduction): Likewise.
(vect_transform_reduction): Likewise.
(vect_transform_cycle_phi): Likewise.
(vect_transform_lc_phi): Likewise.
* tree-vect-slp.cc (vect_analyze_slp): Likewise.
* tree-vect-stmts.cc (vect_truncate_gather_scatter_offset):
Pass in vectype and use that.
(vect_use_strided_gather_scatters_p): Likewise.
(get_group_load_store_type): Adjust.
(vect_check_scalar_mask): We always have a SLP node.
Use vectype from the SLP node.
(vect_check_store_rhs): Likewise.
(vect_build_one_gather_load_call): Pass in the vector type
and use that.
(vect_get_strided_load_store_ops): Likewise.
(vectorizable_store): Adjust.
(vectorizable_load): Use the vector type from the SLP node
and adjust.

6 days agoRemove unused stmt_vectype
Richard Biener [Fri, 25 Jul 2025 09:45:17 +0000 (11:45 +0200)] 
Remove unused stmt_vectype

The following removes an unused accessor to data that should go away.

* target.h (stmt_vectype): Remove.
* tree-vect-stmts.cc (stmt_vectype): Likewise.

6 days agoc++, coroutines: Handle allocation fail returns [PR121219].
Iain Sandoe [Wed, 23 Jul 2025 15:22:32 +0000 (16:22 +0100)] 
c++, coroutines: Handle allocation fail returns [PR121219].

The current implementation was returning the result of the g_r_o_o_a_f
call independently of the return expressions for 'normal' cases.

This prevents the NVRO that we need to guarantee copy elision for the
ramp return values - when these are initialised from a temporary of the
same type.

The solution here reorders the code so that the regular return expression
appears before the allocation-failed case.  Ensure that the g_r_o and
associated code appears in a distinct scope.  These steps are to meet the
constaints of NRV.

PR c++/121219

gcc/cp/ChangeLog:

* coroutines.cc
(cp_coroutine_transform::build_ramp_function): Reorder the return
expressions for the 'normal' and 'allocation failed' cases so that
NRV constraints are met.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/pr121219.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
6 days agoRISC-V: Remove user-level interrupts
Christoph Müllner [Fri, 25 Jul 2025 08:27:59 +0000 (10:27 +0200)] 
RISC-V: Remove user-level interrupts

There was once a RISC-V extension draft ("N"), which introduced
user-level interrupts.  However, it was never ratified and the
specification draft has been removed from the RISC-V ISA manual
in commit `b6cade07034` with the comment "it'll likely need to
be redesigned".

Support for a N extension never made it to GCC, but we support
fuction attributes for user-level interrupt handlers that use
the URET instruction.

The "user" interrupt attribute was documented in the RISC-V C API,
but has been removed in PR #106 in May 2025 (driven by LLVM devs/
maintainers and ack'ed by at least one GCC maintainer).

Let's drop URET support from GCC as well.

gcc/ChangeLog:

* config/riscv/riscv.cc (enum riscv_privilege_levels): Remove USER_MODE.
(riscv_handle_type_attribute): Remove "user" interrupts.
(riscv_expand_epilogue): Likewise.
(riscv_get_interrupt_type): Likewise.
* config/riscv/riscv.md (riscv_uret): Remove URET pattern.
* doc/extend.texi: Remove documentation of user interrupts.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/interrupt-conflict-mode.c: Remove "user"
interrupts.
* gcc.target/riscv/xtheadint-push-pop.c: Likewise.
* gcc.target/riscv/interrupt-umode.c: Removed.

Reported-by: Sam Elliott <quic_aelliott@quicinc.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
6 days agoRemove STMT_VINFO_VEC_STMTS
Richard Biener [Fri, 25 Jul 2025 07:50:18 +0000 (09:50 +0200)] 
Remove STMT_VINFO_VEC_STMTS

The following removes the last uses of STMT_VINFO_VEC_STMTS and
the vector itself.  Vector stmts are recorded in SLP nodes now.

The last use is a bit strange - it was introduced by
Richard S. in r8-6064-ga57776a1136962 and affects only
power7 and below (the re-align optimized load path).  The
check should have never been true since vect_vfa_access_size
is only ever invoked before stmt transform.  I have done
the "conservative" change of making it always true now
(so the code is now entered).  I can as well remove it, but
I wonder if you remember anything about this ...

* tree-vectorizer.h (_stmt_vec_info::vec_stmts): Remove.
(STMT_VINFO_VEC_STMTS): Likewise.
* tree-vectorizer.cc (vec_info::new_stmt_vec_info): Do not
initialize it.
(vec_info::free_stmt_vec_info): Nor free it.
* tree-vect-data-refs.cc (vect_vfa_access_size): Remove
check on STMT_VINFO_VEC_STMTS.

6 days agoRemove load interleaving code
Richard Biener [Fri, 25 Jul 2025 07:34:32 +0000 (09:34 +0200)] 
Remove load interleaving code

The following removes the non-SLP load interleaving code which was
almost unused.

* tree-vectorizer.h (vect_transform_grouped_load): Remove.
(vect_record_grouped_load_vectors): Likewise.
* tree-vect-data-refs.cc (vect_permute_load_chain): Likewise.
(vect_shift_permute_load_chain): Likewise.
(vect_transform_grouped_load): Likewise.
(vect_record_grouped_load_vectors): Likewise.
* tree-vect-stmts.cc (vectorizable_load): Remove comments
about load interleaving.

6 days agoRemove store interleaving support
Richard Biener [Fri, 25 Jul 2025 07:40:27 +0000 (09:40 +0200)] 
Remove store interleaving support

The following removes the non-SLP store interleaving support which
was already almost unused.

* tree-vectorizer.h (vect_permute_store_chain): Remove.
* tree-vect-data-refs.cc (vect_permute_store_chain): Likewise.
* tree-vect-stmts.cc (vectorizable_store): Remove comment
about store interleaving.

6 days agoRemove vect_get_vec_defs_for_operand
Richard Biener [Fri, 25 Jul 2025 07:19:47 +0000 (09:19 +0200)] 
Remove vect_get_vec_defs_for_operand

This removes vect_get_vec_defs_for_operand and its remaining uses.
It also removes some remaining non-SLP paths in preparation to
elide STMT_VINFO_VEC_STMTS.

* tree-vectorizer.h (vect_get_vec_defs_for_operand): Remove.
* tree-vect-stmts.cc (vect_get_vec_defs_for_operand): Likewise.
(vect_get_vec_defs): Remove non-SLP path.
(check_load_store_for_partial_vectors): We always have an
SLP node.
(vect_check_store_rhs): Likewise.
(vect_get_gather_scatter_ops): Likewise.
(vect_create_vectorized_demotion_stmts): Likewise.
(vectorizable_store): Adjust.
(vectorizable_load): Likewise.

6 days agoRemove VMAT_CONTIGUOUS_PERMUTE
Richard Biener [Fri, 25 Jul 2025 07:09:35 +0000 (09:09 +0200)] 
Remove VMAT_CONTIGUOUS_PERMUTE

This VMAT was used for interleaving which was non-SLP only.  The
following removes code gated by it (code selecting it is already gone).

* tree-vectorizer.h (VMAT_CONTIGUOUS_PERMUTE): Remove.
* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Remove checks on VMAT_CONTIGUOUS_PERMUTE.
(vectorizable_load): Likewise.
(vectorizable_store): Likewise.  Prune dead code.

6 days agoRemove dead code from vectorizable_store
Richard Biener [Fri, 25 Jul 2025 07:04:49 +0000 (09:04 +0200)] 
Remove dead code from vectorizable_store

There's dead code in the else block of a if (!costing_p) block,
after trivial pruning only setting of 'op' remains but that has
no further uses downstream.  I found this looking for remaining
(must-be-dead) uses of vect_get_vec_defs_for_operand.

* tree-vect-stmts.cc (vectorizable_store): Remove trivially
dead code.

6 days agogcn: Add "s_nop"s for MI300
Tobias Burnus [Fri, 25 Jul 2025 09:24:22 +0000 (11:24 +0200)] 
gcn: Add "s_nop"s for MI300

MI300 requires some additional s_nop to be added between some instructions.
* As 'v_readlane' and 'v_writelane' have to be distinguished, the
  'laneselect' attribute was changed from no/yes to no/read/write.
* Add some missing 'laneselect' attributes for v_(read,write)lane.
* Replace 'delayeduse' by 'flatmemaccess' which is more explicit,
  especially as some uses have to destinguished more details.
  (Alongside, one off-by-two delayeduse has been fixed.)

On the other hand, RDNA 2, 3, and 3.5 do not require any added s_nop;
thus, there is no need to walk the instructions for them to insert
pointless S_NOP. (RDNA4 (not yet in GCC) requires it in a few cases.)

gcc/ChangeLog:

* config/gcn/gcn-opts.h (TARGET_NO_MANUAL_NOPS,
TARGET_CDNA3_NOPS): Define.
* config/gcn/gcn.md (define_attr "laneselect): Change 'yes' to
'read' and 'write'.
(define_attr "flatmemaccess"): Add with values store, storex34,
load, atomic, atomicwait, cmpswapx2, and no. Replacing ...
(define_attr "delayeduse"): Remove.
(define_attr "transop"): Add with values yes and no.
(various insns): Update 'laneselect', add flatmemaccess and transop,
remove delayeduse; fixing an issue for s_load_dwordx4 vs.
flat_store_dwordx4 related to delayeduse (now: flatmemaccess).
* config/gcn/gcn-valu.md: Update laneselect attribute and add
flatmemaccess.
* config/gcn/gcn.cc (gcn_cmpx_insn_p): New.
(gcn_md_reorg): Update for MI300 to add additional s_nop.
Skip s_nop-insertion part for RDNA{2,3}; add "VALU writes EXEC
followed by VALU DPP" unconditionally for CDNA2/CDNA3/GCN5.

6 days agoDetermine CONSTRAINT_LEN at run-time [PR121214]
Stefan Schulze Frielinghaus [Fri, 25 Jul 2025 09:04:38 +0000 (11:04 +0200)] 
Determine CONSTRAINT_LEN at run-time [PR121214]

Tests gcc.dg/asm-hard-reg-error-{4,5}.c ICE on sparc*-sun-solaris2.11
since in tm-preds.h we end up with

  #define CONSTRAINT_LEN(c_,s_) 1

and, therefore, do not parse hard register constraints correctly.
Hard register constraints are non-single character constraints and
require insn_constraint_len() in order to determine the length.

In write_tm_preds_h() from genpreds.cc, previously variable
constraint_max_namelen was used in order to decide whether we have
single or non-single character constraints.  The distinction shouldn't
be done anymore and we always must call into insn_constraint_len().

While being on it, remove guard constraint_max_namelen>0 since we always
have some constraints coming from common.md.  This leaves
constraint_max_namelen without users so remove it.

gcc/ChangeLog:

PR middle-end/121214
* genpreds.cc (constraint_max_namelen): Delete.
(write_tm_preds_h): Always write insn_constraint_len() and
define CONSTRAINT_LEN to it, i.e., remove guard
constraint_max_namelen>1.  Remove outer guard
constraint_max_namelen>0 and re-indent.
(write_insn_preds_c): Remove guard
constraint_max_namelen>0 and re-indent.

6 days agoada: Minor cleanup
Marc Poulhiès [Tue, 15 Jul 2025 08:22:09 +0000 (10:22 +0200)] 
ada: Minor cleanup

Renamed local variables to make it easier to read.

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (update_pointer_to): Renamed ptr/old_ptr, ref/old_ref.

6 days agoada: ppc-vx6: pthread clocks and headers for decls
Alexandre Oliva [Wed, 16 Jul 2025 05:01:59 +0000 (02:01 -0300)] 
ada: ppc-vx6: pthread clocks and headers for decls

VxWorks 6 lacks pthread_condattr_setclock, so define CLOCK_RT_Ada to
CLOCK_REALTIME to use the dummy definition of
__gnat_pthread_condattr_setup in libgnarl/thread.c.

socket.c and sysdep.c use FD_ZERO, that relies on bzero on VxWorks 6.
We need to include strings.h to get a declaration for bzero, but don't
require strings.h to exist, since it's nonstandard.

gcc/ada/ChangeLog:

* s-oscons-tmplt.c (CLOCK_RT_Ada) [__vxworks]: Define to
CLOCK_REALTIME on VxWorks6.
* gsocket.h [__vxworks]: Include strings.h if available.
* sysdep.c [__vxworks]: Likewise.

6 days agoada: Follow up fixes.
Steve Baird [Wed, 16 Jul 2025 20:37:44 +0000 (13:37 -0700)] 
ada: Follow up fixes.

Two follow-up fixes for the previous change for this issue.

gcc/ada/ChangeLog:

* exp_ch6.adb (Apply_Access_Discrims_Accessibility_Check): Do
nothing and simply return if either Ada_Version <= Ada_95 or if
the function being returned from lacks the extra formal parameter
needed to perform the check (typically because the result is
tagged).

6 days agoada: Bug in Indefinite_Holders instance passed to formal package
Bob Duff [Wed, 16 Jul 2025 14:29:01 +0000 (10:29 -0400)] 
ada: Bug in Indefinite_Holders instance passed to formal package

Fix bug when an instance of Indefinite_Holders with a class-wide type is
passed as a generic formal package; Program_Error was raised when
dealing with the implicit "=" function.

The fix is to disable legality checks in formal packages when the
entity is an E_Subprogram_Body, because these are implicitly generated
for class-wide predefined functions when passed to generics.

gcc/ada/ChangeLog:

* sem_ch12.adb (Check_Formal_Package_Instance):
Do nothing in case of E_Subprogram_Body.

6 days agoada: Update comments
Ronan Desplanques [Wed, 16 Jul 2025 13:27:03 +0000 (15:27 +0200)] 
ada: Update comments

A previous patch changed the mechanism of early usage detection for
discriminants but failed to update a couple of surrounding comments
accordingly. This patch fixes this omission.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Discriminants): Update comments

6 days agoada: Fix regression of finalization primitive selection
Ronan Desplanques [Fri, 11 Jul 2025 09:28:35 +0000 (11:28 +0200)] 
ada: Fix regression of finalization primitive selection

A recent patch introduced a new flag to mark the types for which looking
up finalization primitives needs special handling. But there was one
place in Build_Derived_Record_Type where the flag was not set when it
should, which introduced a regression in some cases.

This patch adds the missing setting of the flag.

gcc/ada/ChangeLog:

* sem_ch3.adb (Build_Derived_Record_Type): Set flag appropriately.