aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-08-05gccrs: nr2.0: late: Correctly initialize funny_error memberArthur Cohen1-1/+3
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::Late): False initialize the funny_error field.
2025-08-05fortran: Use array descriptor offset setter when possibleMikael Morin2-6/+5
Regression-tested on x86_64-pc-linux-gnu. OK for master? -- >8 -- In some places, a write to an array descriptor offset field was generated simply by adding a modification of a reference to it that was already available. This change uses the existing setter function instead in those places, to generate the same code. It makes it more explicit that in those areas a write to the field is generated. gcc/fortran/ChangeLog: * trans-array.cc (gfc_alloc_allocatable_for_assignment): Use the offset setter instead of generating a write to the offset. (gfc_conv_array_parameter): Use the offset setter instead of generating a write to the value returned by the offset getter. * trans-expr.cc (gfc_trans_alloc_subarray_assign): Likewise.
2025-08-05fortran: Remove array descriptor data address accessor functionMikael Morin3-13/+1
Regression-tested on x86_64-pc-linux-gnu. OK for master? -- >8 -- The function gfc_conv_descriptor_data_addr generates an address to the data field of an array descriptor. It is only used once, and in the single place where it is used, the address is immediately dereferenced. This change replaces the single usage with a plain access to the data field, and removes the function. As the previous patch removed the usage of the data field to write to it, the data getter can be used. gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_descriptor_data_addr): Remove. * trans-array.h (gfc_conv_descriptor_data_addr): Remove. * trans-decl.cc (gfc_trans_deferred_vars): Use gfc_conv_descriptor_data_get.
2025-08-05fortran: Use array descriptor data setter when possibleMikael Morin3-9/+24
Regression-tested on x86_64-pc-linux-gnu. OK for master? -- >8 -- In some places, a write to an array descriptor data field was generated simply by adding a modification of a reference to it that was already available. This change uses the existing setter function instead in those places, to generate the same code. It makes it more explicit that in those areas a write to the field is generated. We have to be careful because in some of the places, the pointer that is to be modified is an array descriptor field only under some conditions. Add a conditional in those places to separate the cases, and keep generating the reference modification as before if the conditions are not met. gcc/fortran/ChangeLog: * trans.cc (gfc_finalize_tree_expr): Use the data setter instead of writing to the value returned by the data getter. * trans-decl.cc (gfc_trans_deferred_vars): Likewise. * trans-stmt.cc (trans_associate_var): Use the data setter instead of writing to the value dereferenced from the data address.
2025-08-05i386: Extend recognition of high-reg rvalues [PR121306]Richard Sandiford2-245/+161
The i386 high-register patterns used things like: (match_operator:SWI248 2 "extract_operator" [(match_operand 0 "int248_register_operand" "Q") (const_int 8) (const_int 8)]) to match an extraction of a high register such as AH from AX/EAX/RAX. This construct is used in contexts where only the low 8 bits of the value matter. This is either done explicitly using a (subreg:QI ... 0) or implicitly by assigning to an 8-bit zero_extract destination. extract_operator therefore matches both sign_extract and zero_extract, since the signedness of the extension beyond 8 bits is irrelevant. But the fact that only the low 8 bits of the value are significant means that a shift right by 8 is as good as an extraction. Shifts right would already be used for things like: struct s { long a:8; long b:8; long c:48; }; struct s f(struct s x, long y, long z) { x.b = (y & z) >> 8; return x; } but are used more after g:965564eafb721f8000013a3112f1bba8d8fae32b. This patch therefore replaces extract_operator with a new predicate called extract_high_operator that matches both extractions and shifts. The predicate checks the extraction field and shift amount itself, so that patterns only need to match the first operand. Splitters used match_op_dup to preserve the choice of extraction. But the fact that the extractions (and now shifts) are equivalent means that we can just as easily canonicalise on one of them. (In theory, canonicalisation would also promote CSE, although that's unlikely in practice.) The patch goes for zero_extract, for consistency with destinations. gcc/ PR target/121306 * config/i386/predicates.md (extract_operator): Replace with... (extract_high_operator): ...this new predicate. * config/i386/i386.md (*cmpqi_ext<mode>_1, *cmpqi_ext<mode>_2) (*cmpqi_ext<mode>_3, *cmpqi_ext<mode>_4, *movstrictqi_ext<mode>_1) (*extzv<mode>, *insvqi_2, *extendqi<SWI24:mode>_ext_1) (*addqi_ext<mode>_1_slp, *addqi_ext<mode>_1_slp, *addqi_ext<mode>_0) (*addqi_ext2<mode>_0, *addqi_ext<mode>_1, *<insn>qi_ext<mode>_2) (*subqi_ext<mode>_1_slp, *subqi_ext<mode>_2_slp, *subqi_ext<mode>_0) (*subqi_ext2<mode>_0, *subqi_ext<mode>_1, *testqi_ext<mode>_1) (*testqi_ext<mode>_2, *<code>qi_ext<mode>_1_slp) (*<code>qi_ext<mode>_2_slp. *<code>qi_ext<mode>_0) (*<code>qi_ext2<mode>_0, *<code>qi_ext<mode>_1) (*<code>qi_ext<mode>_1_cc, *<code>qi_ext<mode>_1_cc) (*<code>qi_ext<mode>_2, *<code>qi_ext<mode>_3, *negqi_ext<mode>_1) (*one_cmplqi_ext<mode>_1, *ashlqi_ext<mode>_1, *<insn>qi_ext<mode>_1) (define_peephole2): Replace uses of extract_operator with extract_high_operator, matching only the first operand. Use zero_extract rather than match_op_dup when splitting.
2025-08-05Remove hybrid SLP detectionRichard Biener3-230/+2
The following removes hybrid SLP detection - it existed as sanity check that all stmts are covered by SLP, but it proved itself incomplete at that. Its job is taken by early terminating SLP build when SLP discovery fails for one root and the hope that we now do catch all of them. * tree-vectorizer.h (vect_relevant::hybrid): Remove. * tree-vect-loop.cc (vect_analyze_loop_2): Do not call vect_detect_hybrid_slp. * tree-vect-slp.cc (maybe_push_to_hybrid_worklist): Remove. (vect_detect_hybrid_slp): Likewise.
2025-08-05AVR: target/121359: Remove -mlra and remains of reload.Georg-Johann Lay9-182/+8
PR target/121359 gcc/ * config/avr/avr.h: Remove -mlra and remains of reload. * config/avr/avr.cc: Same. * config/avr/avr.md: Same. * config/avr/avr-log.cc: Same. * config/avr/avr-protos.h: Same. * config/avr/avr.opt: Same. * config/avr/avr.opt.urls: Same. gcc/testsuite/ * gcc.target/avr/torture/pr118591-1.c: Remove -mlra. * gcc.target/avr/torture/pr118591-2.c: Same.
2025-08-05x86: Update *one_cmplqi_ext<mode>_1H.J. Lu1-12/+7
After commit 965564eafb721f8000013a3112f1bba8d8fae32b Author: Richard Sandiford <richard.sandiford@arm.com> Date: Tue Jul 29 15:58:34 2025 +0100 simplify-rtx: Simplify subregs of logic ops combine generates (set (zero_extract:SI (reg/v:SI 101 [ a ]) (const_int 8 [0x8]) (const_int 8 [0x8])) (not:SI (sign_extract:SI (reg:SI 107 [ b ]) (const_int 8 [0x8]) (const_int 8 [0x8])))) instead of (set (zero_extract:SI (reg/v:SI 101 [ a ]) (const_int 8 [0x8]) (const_int 8 [0x8])) (subreg:SI (not:QI (subreg:QI (sign_extract:SI (reg:SI 107 [ b ]) (const_int 8 [0x8]) (const_int 8 [0x8])) 0)) 0)) Update *one_cmplqi_ext<mode>_1 to support the new pattern. PR target/121306 * config/i386/i386.md (*one_cmplqi_ext<mode>_1): Updated to support the new pattern. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-05tree-optimization/121395 - SLP of SIMD calls w/o LHSRichard Biener4-10/+42
The following records the alternate SLP instance entries coming from stmts with stores that have no SSA def, like OMP SIMD calls without LHS. There's a bit of fallout with having a SLP tree with a NULL vectype, but nothing too gross. PR tree-optimization/121395 * tree-vectorizer.h (_loop_vec_info::alternate_defs): New member. (LOOP_VINFO_ALTERNATE_DEFS): New. * tree-vect-stmts.cc (vect_stmt_relevant_p): Populate it. (vectorizable_simd_clone_call): Do not register a SLP def when there is none. * tree-vect-slp.cc (vect_build_slp_tree_1): Allow a NULL vectype when there's no LHS. Allow all calls w/o LHS. (vect_analyze_slp): Process LOOP_VINFO_ALTERNATE_DEFS as SLP graph entries. (vect_make_slp_decision): Handle a NULL SLP_TREE_VECTYPE. (vect_slp_analyze_node_operations_1): Likewise. (vect_schedule_slp_node): Likewise. * gcc.dg/vect/pr59984.c: Adjust.
2025-08-05Rename loop_vect SLP_TYPE and clarify docsRichard Biener3-23/+9
The following renames loop_vect to not_vect, removes the unused HYBRID_SLP_STMT macro and rewords the slp_vect_type docs to clarify STMT_SLP_TYPE is mainly used for BB vectorization, tracking what is vectorized and what not. * tree-vectorizer.h (enum slp_vect_type): Rename loop_vect to not_vect, clarify docs. (HYBRID_SLP_STMT): Remove. * tree-vectorizer.cc (vec_info::new_stmt_vec_info): Adjust. * tree-vect-loop.cc (vect_analyze_loop_2): Likewise.
2025-08-05Prune some unnecessary PURE_SLP_STMT checksRichard Biener3-15/+2
We now never have hybrid SLP (if we have, we fail immediately). * tree-vect-data-refs.cc (vect_get_data_access_cost): Use ncopies == 1. * tree-vect-slp.cc (vect_remove_slp_scalar_calls): Remove hybrid/loop SLP skip. * tree-vect-stmts.cc (vectorizable_store): Remove pure SLP assert.
2025-08-05tree-optimization/121382 - avoid UB in IVOPTs inserted step computationRichard Biener2-1/+42
IVOPTs, when replacing an IV, inserts the computation of the new IVs step in the loop preheader without considering the case of the loop not iterating. This means we have to ensure the step computation does not invoke UB. There is also SCEV which does not care about signed arithmetic UB when re-associating expressions to form CHRECs, so even when we know the loop iterates this is required. PR tree-optimization/121382 * tree-ssa-loop-ivopts.cc (create_new_iv): Rewrite the IV step to defined form. * gcc.dg/torture/pr121382.c: New testcase.
2025-08-05tree-optimization/121370 - avoid UB in building a CHRECRichard Biener2-0/+36
When there is obvious UB involved in the process of re-associating a series of IV increments to build up a CHREC, fail. This catches a few degenerate cases where SCEV introduces UB with its inherent re-associating of IV increments. PR tree-optimization/121370 * tree-scalar-evolution.cc (scev_dfs::add_to_evolution_1): Avoid UB integer overflow in accumulating CHREC_RIGHT. * gcc.dg/torture/pr121370.c: New testcase.
2025-08-05bitint: Allow unused bits when testing extended _BitInt ABIsYang Yujie1-2/+20
In LoongArch psABI, large _BitInt(N) (N > 64) objects are only extended to fill the highest 8-byte chunk that contains any used bit, but the size of such a large _BitInt type is a multiple of their 16-byte alignment. So there may be an entire unused 8-byte chunk that is not filled by extension, and this chunk shouldn't be checked when testing if the object is properly extended. The original bitintext.h assumed that all bits within sizeof(_BitInt(N)) beyond used bits are filled by extension. This patch changes that for LoongArch and possibly any future ports with a similar behavior. P.S. For encoding this test as well as type-generic programming, it would be nice to have a builtin function to obtain "N" at compile time from _BitInt(N)-typed expressions. But here we stick to existing ones (__builtin_clrsbg / __builtin_clzg). * gcc.dg/bitintext.h (S, CEIL, PROMOTED_SIZE): Define. (BEXTC): Generalize to only check extension within PROMOTED_SIZE bits.
2025-08-05expand: Reduce unneeded _BitInt extensionsYang Yujie3-0/+20
For targets that set the "extended" flag in TARGET_C_BITINT_TYPE_INFO, we assume small _BitInts to be internally extended after arithmetic operations. In this case, an extra extension during RTL expansion can be avoided. * expr.cc (expand_expr_real_1): Do not call reduce_to_bit_field_precision if the target assumes the _BitInt results to be already extended. (EXTEND_BITINT): Same. * expr.h (bitint_extended): Declare the cache variable. * function.cc (prepare_function_start): Initialize it.
2025-08-05bitint: Allow mode promotion of _BitInt typesYang Yujie1-0/+24
For targets that treat small _BitInts like the fundamental integral types, we should allow their machine modes to be promoted in the same way. * explow.cc (promote_function_mode): Add a case for small/medium _BitInts. (promote_mode): Same.
2025-08-05libcpp: Add testcase for CWG2579 [PR120778]Jakub Jelinek7-13/+22
Another easy part from the paper. Part of the CWG2579 has been already done in an earlier paper (with test commits by Marek) and the remaining part is implemented correctly, we diagnose as error when token pasting doesn't form a valid token. Except that message pasting """" and """" does not give a valid preprocessing token looked weird and so I've updated the message to use %< and %> instead of \" quoting. 2025-08-05 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * macro.cc (paste_tokens): Use %< and %> instead of \" in diagnostics around %.*s. * g++.dg/DRs/dr2579.C: New test. * c-c++-common/cpp/va-opt-6.c: Expect ' rather than \" around tokens in incorrect pasting diagnostics. * gcc.dg/c23-attr-syntax-6.c: Likewise. * gcc.dg/cpp/paste12.c: Likewise. * gcc.dg/cpp/paste12-2.c: Likewise. * gcc.dg/cpp/paste14.c: Likewise. * gcc.dg/cpp/paste14-2.c: Likewise.
2025-08-05doc: Mark up function name in installation docsGerald Pfeifer1-2/+2
gcc: PR target/69374 * doc/install.texi (Configuration): Mark up atexit as code.
2025-08-05RISC-V: Fix scalar code-gen of unsigned SAT_MULPan Li3-2/+5
The previous code-gen of scalar unsigned SAT_MUL, aka usmul. Leverage the mulhs by mistake, it should be mulhu for the hight bit result of mul. Thus, this patch would like to make it correct. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_expand_xmode_usmul): Take umulhu for high bits mul result. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat/sat_u_mul-1-u32-from-u64.c: Add mulhu asm check. * gcc.target/riscv/sat/sat_u_mul-1-u64-from-u128.c: Ditto. Signed-off-by: Pan Li <pan2.li@intel.com>
2025-08-05Daily bump.GCC Administrator5-1/+628
2025-08-04c++: add another testcase [PR121351]Patrick Palka1-0/+20
Here's a previously accepted testcase that is now ambiguous after r16-2771-gb9f1cc4e119da, since the uninstantiated constraints are equivalent but the partially instantiated constraints aren't, so the two member functions no longer correspond. PR c++/121351 gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-using6.C: New test.
2025-08-04c++: constrained memfn vs corresponding using [PR121351]Patrick Palka3-1/+63
The b.f(42) calls in the below testcases started to get rejected as ambiguous after r15-3740 which corrected our inheritedness tiebreaker to only apply to constructors (and not all member functions) as per CWG2273. But arguably these calls should still be valid regardless of the tiebreaker because B::f corresponds to and therefore hides A::f, so there should only be a single candidate in the first place. This doesn't happen because when determining correspondence we compare the members' uninstantiated constraints instead of their partially substituted constraints as in other declaration matching situations. It doesn't really make sense to compare uninstantiated constraints from two different template contexts. This patch fixes this by substituting in outer template arguments before comparing constraints of two potentially corresponding member functions. PR c++/121351 PR c++/119859 gcc/cp/ChangeLog: * class.cc (add_method): Substitute outer template arguments into constraints before comparing them if the declarations are from different classes. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-using5.C: New test. * g++.dg/cpp2a/concepts-using5a.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-08-04c++: constexpr evaluation of abi::__dynamic_cast [PR120620]Patrick Palka3-1/+21
r13-3299 changed our internal declaration of __dynamic_cast to reside inside the abi/__cxxabiv1:: namespace instead of the global namespace, matching the real declaration. This inadvertently made us now attempt constexpr evaluation of user-written calls to abi::__dynamic_cast since cxx_dynamic_cast_fn_p now also returns true for them, but we're not prepared to handle arbitrary calls to __dynamic_cast, and therefore ICE. This patch restores cxx_dynamic_cast_fn_p to return true only for synthesized calls to __dynamic_cast, which can be distinguished by DECL_ARTIFICIAL, since apparently the synthesized declaration of __dynamic_cast doesn't get merged with the actual declaration. PR c++/120620 gcc/cp/ChangeLog: * constexpr.cc (cxx_dynamic_cast_fn_p): Return true only for synthesized __dynamic_cast. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-dynamic19.C: New test. * g++.dg/cpp2a/constexpr-dynamic1a.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-08-04defaults.h: Default MAX_FIXED_MODE_SIZE to MAX (BITS_PER_WORD * 2, 64)Hans-Peter Nilsson3-9/+9
The old GET_MODE_SIZE (DImode) (i.e. 64) made sense before 64-bitters. Now the default is just a trap: when using the default 64, things like TImode (128 bits) still mostly works, but general corner cases related to computing large-size objects numbers, like (1 << 64)/8 break, as exposed by gcc.dg/pr105094.c. So, keep the floor at 64 for 32-bitters and smaller targets, but for larger targets, make it 2 * BITS_PER_WORD. Also, express it more directly with focus on BITS_PER_WORD, not the size of a mode. Add "by GCC internally" in an attempt to tell that this is when gcc cooks something up, not when plain input uses a type with such a mode. * defaults.h (MAX_FIXED_MODE_SIZE): Default to 2 * BITS_PER_WORD for larger-than-32-bitters. * doc/tm.texi.in (MAX_FIXED_MODE_SIZE): Adjust accordingly. Tweak wording. * doc/tm.texi: Regenerate.
2025-08-04optinfo: use enum classDavid Malcolm6-88/+90
Modernization; no functional change intended. gcc/ChangeLog: * dump-context.h: Convert "enum optinfo_item_kind" into "enum class kind" within class optinfo_item. * dumpfile.cc: Likewise. Use "auto" in a few places. Convert "enum optinfo_kind" to "enum class kind" within class optinfo. * opt-problem.cc: Likewise. * optinfo-emit-json.cc: Likewise. * optinfo.cc: Likewise. * optinfo.h: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: improve support for nesting levels [PR116253]David Malcolm17-10/+408
This patch adds support to sarif-replay for "nestingLevel" from "P3358R0 SARIF for Structured Diagnostics" https://wg21.link/P3358R0 Doing so revealed a bug where libgdiagnostics was always creating new location_t values (and thus also diagnostic_physical_location instances), rather than reusing existing location_t values, leading to excess source printing. The patch also fixes this bug, adding a new flag to libgdiagnostics for debugging physical locations, and exposing this in sarif-replay via a new "-fdebug-physical-locations" maintainer option. Finally, the patch adds test coverage for the HTML sink's output of nested diagnostics (both from a GCC plugin, and from sarif-replay). gcc/ChangeLog: PR diagnostics/116253 * diagnostics/context.cc (context::set_nesting_level): New. * diagnostics/context.h (context::set_nesting_level): New decl. * doc/libgdiagnostics/topics/compatibility.rst (LIBGDIAGNOSTICS_ABI_5): New. * doc/libgdiagnostics/topics/physical-locations.rst (diagnostic_manager_set_debug_physical_locations): New. * libgdiagnostics++.h (manager::set_debug_physical_locations): New. * libgdiagnostics-private.h (private_diagnostic_set_nesting_level): New decl. * libgdiagnostics.cc (diagnostic_manager::diagnostic_manager): Initialize m_debug_physical_locations. (diagnostic_manager::new_location_from_file_and_line): Add debug printing. (diagnostic_manager::new_location_from_file_line_column): Likewise. (diagnostic_manager::new_location_from_range): Likewise. (diagnostic_manager::set_debug_physical_locations): New. (diagnostic_manager::ensure_linemap_for_file_and_line): Avoid redundant calls to linemap_add. (diagnostic_manager::new_location): Add debug printing. (diagnostic_manager::m_debug_physical_locations): New field. (diagnostic::diagnostic): Initialize m_nesting_level. (diagnostic::get_nesting_level): New accessor. (diagnostic::set_nesting_level): New. (diagnostic::m_nesting_level): New field. (diagnostic_manager::emit_va): Set and reset the nesting level of the context from that of the diagnostic. (diagnostic_manager_set_debug_physical_locations): New. (private_diagnostic_set_nesting_level): New. * libgdiagnostics.h (diagnostic_manager_set_debug_physical_locations): New decl. * libgdiagnostics.map (LIBGDIAGNOSTICS_ABI_5): New. * libsarifreplay.cc (sarif_replayer::handle_result_obj): Support the "nestingLevel" property. * libsarifreplay.h (replay_options::m_debug_physical_locations): New field. * sarif-replay.cc: Add -fdebug-physical-locations. gcc/testsuite/ChangeLog: PR diagnostics/116253 * gcc.dg/plugin/diagnostic-test-nesting-html.c: New test. * gcc.dg/plugin/diagnostic-test-nesting-html.py: New test script. * gcc.dg/plugin/plugin.exp: Add it. * libgdiagnostics.dg/test-multiple-lines.c: Update expected output to show fix-it hint. * sarif-replay.dg/2.1.0-valid/nested-diagnostics-1.sarif: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: avoid stray trailing space in html sink in sarif-replay [PR116792]David Malcolm4-7/+11
For the common case where a diagnostic has no metadata, sarif-replay's html output was adding a stray space followed by an empty <div> for the metadata. Fixed thusly. gcc/ChangeLog: PR diagnostics/116792 * diagnostics/html-sink.cc (html_builder::make_element_for_diagnostic): Don't add the metadata element if it's empty. (html_builder::make_element_for_metadata): Return null rather than an empty element. gcc/testsuite/ChangeLog: PR diagnostics/116792 * gcc.dg/plugin/diagnostic-test-graphs-html.py: Remove trailing space from expected text of message. * sarif-replay.dg/2.1.0-valid/embedded-links-check-html.py: Likewise. * sarif-replay.dg/2.1.0-valid/graphs-check-html.py: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: move diagnostics::counters to its own headerDavid Malcolm2-22/+52
gcc/ChangeLog: * diagnostics/context.h: Move struct counters to its own header and include it. * diagnostics/counters.h: New file, from the above. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: split source_printing_options out into its own headerDavid Malcolm2-49/+77
No functional change intended. gcc/ChangeLog: * diagnostics/context.h: Split struct source_printing_options out into "diagnostics/source-printing-options.h" and include it. * diagnostics/source-printing-options.h: New file, from the above. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: rename option_manager to option_id_manager and split out from ↵David Malcolm9-73/+103
context.h This patch splits out class option_manager to its own header, and renames it to class option_id_manager to better describe its purpose. No functional change intended. gcc/ChangeLog: * diagnostics/context.cc: Update for renaming of option_manager to option_id_manager and of context::m_option_mgr to context::m_option_id_mgr. * diagnostics/context.h: Likewise, moving class declaration to a new diagnostics/option-id-manager.h. * diagnostics/lazy-paths.cc: Likewise. * diagnostics/option-id-manager.h: New file, from material in diagnostics/context.h. * lto-wrapper.cc: Update for renaming of option_manager to option_id_manager. * opts-common.cc: Likewise. * opts-diagnostic.h: Likewise. * opts.cc: Likewise. * toplev.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: fix comment in buffering.hDavid Malcolm1-5/+5
gcc/ChangeLog: * diagnostics/buffering.h: Update comment to refer to output sinks rather than output formats. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04gimple-warn-recursion.cc: add missing auto_diagnostic_groupDavid Malcolm1-0/+1
gcc/ChangeLog: * gimple-warn-recursion.cc (pass_warn_recursion::execute): Add missing auto_diagnostic_group. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04asf: Fix null pointer dereference in is_store_forwarding [PR121303]Konstantinos Eleftheriou2-1/+34
We were calling `is_store_forwarding` with a NULL value for `off_val`, which was causing a null pointer dereference in `is_constant`, leading to an ICE. This patch updates the call to `is_constant` in `is_store_forwarding` and adds a check for `off_val`, in order to update it with the right value. Bootstrapped/regtested on AArch64 and x86_64. PR rtl-optimization/121303 gcc/ChangeLog: * avoid-store-forwarding.cc (is_store_forwarding): Add check for `off_val` in `is_store_forwarding`. gcc/testsuite/ChangeLog: * gcc.target/i386/pr121303.c: New test.
2025-08-04c++: Add #line testcase for CWG2580 [PR120778]Jakub Jelinek1-0/+87
Contrary to what the paper says, I think for #line directives we diagnose everything we should (sure, some diagnostics are pedwarns). 2025-08-04 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * g++.dg/DRs/dr2580.C: New test.
2025-08-04ada: Update Assertion_Policy handling in GNATProve modeViljar Indus14-77/+87
Previously in GNATProve_Mode the frontend would overwrite all of the assertion policies to check in order to force the generation of all of the assertions. This however prevents GNATProve from performing policy related checks in the tool. Since they are all artificially changed to check. This patch removes the modifications to the applicable assertion policies and instead prevents code from ignored entities being removed when in GNATProve_Mode. gcc/ada/ChangeLog: * contracts.adb: Use Is_Ignored_In_Codegen instead of just using Is_Ignored. * exp_ch6.adb: Likewise. * exp_prag.adb: Likewise. * exp_util.adb: Likewise. * frontend.adb: Avoid removal of ignored nodes in GNATProve_Mode. * gnat1drv.adb: Avoid forcing Assertions_Enabled in GNATProve_Mode. * lib-writ.adb (Write_With_File_Names): Avoid early exit with ignored entities in GNATProve_Mode. * lib-xref.adb: Likewise. * opt.adb: Remove check for Assertions_Enabled. * sem_attr.adb: Use Is_Ignored_In_Codegen instead of Is_Ignored. * sem_ch13.adb: Likewise. Additionally always add predicates in GNATProve_Mode. * sem_prag.adb: Likewise. Additionally remove modifications to applied policies in GNATProve_Mode. * sem_util.adb (Is_Ignored_In_Codegen): New function that overrides Is_Ignored in GNATProve_Mode and Codepeer_Mode. (Is_Ignored_Ghost_Pragma_In_Codegen): Likewise for Is_Ignored_Ghost_Pragma. (Is_Ignored_Ghost_Entity_In_Codegen): Likewise for Is_Ignored_Ghost_Entity. (Policy_In_List): Remove overriding of policies in GNATProve_Mode. * sem_util.ads: Add specs for new functions. * (Predicates_Enabled): Always generate predicates in GNATProve_Mode.
2025-08-04ada: Make pp and friends more robustBob Duff1-9/+7
Print_Node_Ref, which is called by pp, sometimes calls Compile_Time_Known_Value, which blows up if Entity (N) is empty. Rearrange the tests here, and test for Present (Entity (N)) before calling Compile_Time_Known_Value. Remove test "Nkind (N) in N_Subexpr", which is redundant with other tests. We don't want to make Compile_Time_Known_Value more robust; you shouldn't call it on half-baked nodes. But ideally pp should be able to print such nodes. This change fixes one of many such cases. gcc/ada/ChangeLog: * treepr.adb (Print_Node_Ref): Protect against Entity (N) being empty before calling Compile_Time_Known_Value.
2025-08-04ada: Check Compile_Time_Errors removed in Ghost codeViljar Indus1-0/+8
gcc/ada/ChangeLog: * sem_prag.adb (Validate_Compile_Time_Warning_Errors): Check if the original compile time pragma was replaced and validate the original node instead.
2025-08-04ada: Refactor Validate_Compile_Time_Warning_Or_ErrorViljar Indus1-90/+102
Simplify the creation of the control characters in Validate_Compile_Time_Warning_Or_Error. gcc/ada/ChangeLog: * sem_prag.adb (Validate_Compile_Time_Warning_Or_Error): simplify the implementation.
2025-08-04ada: Implement accessibility legality check for discriminated function result.Steve Baird1-1/+11
If a function result type has an access discriminant, then we already generate a run-time accessibility check for a return statement. But if we know statically that the check (if executed) is going to fail, then that should be rejected at compile-time as a violation of RM 6.5(5.9). Add this additional compile-time check. gcc/ada/ChangeLog: * exp_ch6.adb (Apply_Access_Discrims_Accessibility_Check): If the accessibility level being checked is known statically, then statically check it against the level of the function being returned from.
2025-08-04ada: Keep Ghost_Mode related variables in a recordViljar Indus20-156/+128
Simplify the storing process for ghost mode related variables and make the process more extendable if new ghost mode related features are added. gcc/ada/ChangeLog: * atree.adb: update references to Ghost_Mode. * exp_ch3.adb: use a structure type to store all of the existing ghost mode related state variables. * exp_disp.adb: Likewise. * exp_spark.adb: Likewise. * exp_util.adb: Likewise. * expander.adb: Likewise. * freeze.adb: Likewise and replace references to existing ghost mode variables. * ghost.adb (Install_Ghost_Region): install the changes of the region in to the new Ghost_Config structure. (Restore_Ghost_Region): Use the new Ghost_Config instead. In general replace all references to the existing ghost mode variables with the new structure equivalent. * ghost.ads (Restore_Ghost_Region): update the spec. * opt.ads (Ghost_Config_Type): A new type that has two of the previous ghost code related global variables as memembers - Ghost_Mode and Ignored_Ghost_Region. (Ghost_Config) New variable to store the previous Ghost_Mode and Ignored_Ghost_Region info. * rtsfind.adb: Replace references to existing ghost mode variables. * sem.adb: Likewise. * sem_ch12.adb: Likewise. * sem_ch13.adb: Likewise. * sem_ch3.adb: Likewise. * sem_ch5.adb: Likewise. * sem_ch6.adb: Likewise. * sem_ch7.adb: Likewise. * sem_prag.adb: Likewise. * sem_util.adb: Likewise.
2025-08-04ada: Avoid generating incorrect warningSteve Baird1-0/+2
Do not generate a warning stating that the size of a formal parameter is 8 bits unless the size of the formal parameter is 8 bits. gcc/ada/ChangeLog: * freeze.adb (Freeze_Profile): Do not emit a warning stating that a formal parameter's size is 8 if the parameter's size is not 8.
2025-08-04ada: Fix code quality issue in table.adbViljar Indus2-3/+3
gcc/ada/ChangeLog: * table.adb (Max): Move variable to the body and initialize it with the same value as in the Init function. * table.ads (Max): Likewise.
2025-08-04ada: Misc parser cleanupBob Duff5-229/+236
...which might make it easier to deal with incorrectly shared subtrees created during parsing. There were several Idents arrays, with duplicated code and commentary. And the related code had somewhat diverged -- different comments, different index subtypes (Pos vs. Int), etc. DRY: Move at least some of the code into Par.Util. Raise Program_Error if the array overflows; there is really no reason not to check, along with several comments saying we don't check. In the unlikely event that the array overflows, the compiler will now crash, which seems better than erroneous execution (which could conceivably cause bad code to be generated). Move the block comments titled "Handling Semicolon Used in Place of IS" and "Handling IS Used in Place of Semicolon" so they are together, which seems obviously desirable. Rewrite the latter comment. No need to denigrate other parsers. gcc/ada/ChangeLog: * par.adb: Move and rewrite some comments. (Util): Shared code and comments for dealing with defining_identifier_lists. * par-util.adb (Append): Shared code for appending one identifier onto Defining_Identifiers. (P_Def_Ids): Shared code for parsing a defining_identifier_list. Unfortunately, this is not used in all cases, because some of them mix in sophisticated error recovery, which we do not modify here. * par-ch12.adb (P_Formal_Object_Declarations): Use Defining_Identifiers and related code. * par-ch3.adb (P_Identifier_Declarations): Likewise. (P_Known_Discriminant_Part_Opt): Likewise. (P_Component_Items): Likewise. * par-ch6.adb (P_Formal_Part): Likewise.
2025-08-04Fail early when SLP instance build failsRichard Biener1-32/+56
The following makes us fail earlier when parts of the SLP build fails. Currently we rely on hybrid stmt detection later to discover not all stmts are covered by SLP, but this code should go away. I've also seen a case of a missed gcond SLP build that went undetected. So the following makes us fail during vect_analyze_slp if any of the SLP instances we expect to discover fails. * tree-vect-slp.cc (vect_analyze_slp): When analyzing a loop and slp instance discovery fails, immediately fail the whole process.
2025-08-04libcpp: Use pedwarn instead of warning for CWG2578 diagnostics [PR120778]Jakub Jelinek1-0/+10
This is another case which changed from compile time undefined behavior to ill-formed, diagnostic required. Now, we warn on this, so pedantically that is good enough, maybe all we need is a testcase, but the following patch changes it to a pedwarn for C++26. 2025-08-04 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * macro.cc (stringify_arg): For C++26 emit a pedarn instead of warning for \ at the end of stringification. * g++.dg/DRs/dr2578.C: New test.
2025-08-04aarch64: Check the mode of SVE ACLE function resultsRichard Sandiford1-1/+21
After previous patches, we should always get a VNx16BI result for ACLE intrinsics that return svbool_t. This patch adds an assert that checks a more general condition than that. gcc/ * config/aarch64/aarch64-sve-builtins.cc (function_expander::expand): Assert that the return value has an appropriate mode.
2025-08-04aarch64: Use VNx16BI for svdupq_b*Richard Sandiford4-13/+63
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the predicate forms of svdupq. The general predicate expansion builds an equivalent integer vector and then compares it with zero. This patch therefore relies on the earlier patches to the comparison patterns. gcc/ * config/aarch64/aarch64-protos.h (aarch64_convert_sve_data_to_pred): Remove the mode argument. * config/aarch64/aarch64.cc (aarch64_sve_emit_int_cmp): Allow PRED_MODE to be VNx16BI or the natural predicate mode for the data mode. (aarch64_convert_sve_data_to_pred): Remove the mode argument and instead always create a VNx16BI result. (aarch64_expand_sve_const_pred): Update call accordingly. * config/aarch64/aarch64-sve-builtins-base.cc (svdupq_impl::expand): Likewise, ensuring that the result has mode VNx16BI. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/dupq_13.c: New test.
2025-08-04aarch64: Use VNx16BI for svdup_b*Richard Sandiford5-5/+87
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the predicate forms of svdup. gcc/ * config/aarch64/aarch64-protos.h (aarch64_emit_sve_pred_vec_duplicate): Declare. * config/aarch64/aarch64.cc (aarch64_emit_sve_pred_vec_duplicate): New function. * config/aarch64/aarch64-sve.md (vec_duplicate<PRED_ALL:mode>): Use it. * config/aarch64/aarch64-sve-builtins-base.cc (svdup_impl::expand): Handle boolean values specially. Check for constants and fall back on aarch64_emit_sve_pred_vec_duplicate for the variable case, ensuring that the result has mode VNx16BI. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/dup_1.c: New test.
2025-08-04aarch64: Use VNx16BI for svpnext*Richard Sandiford3-5/+204
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svpnext* intrinsics. gcc/ * config/aarch64/iterators.md (PNEXT_ONLY): New int iterator. * config/aarch64/aarch64-sve.md (@aarch64_sve_<sve_pred_op><mode>): Restrict SVE_PITER pattern to VNx16BI_ONLY. (@aarch64_sve_<sve_pred_op><mode>): New PNEXT_ONLY pattern for PRED_HSD. (*aarch64_sve_<sve_pred_op><mode>): Likewise. (*aarch64_sve_<sve_pred_op><mode>_cc): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/pnext_3.c: New test.
2025-08-04aarch64: Use VNx16BI for sv(n)match*Richard Sandiford3-2/+146
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svmatch* and svnmatch* intrinsics. gcc/ * config/aarch64/aarch64-sve2.md (@aarch64_pred_<sve_int_op><mode>): Split SVE2_MATCH pattern into a VNx16QI_ONLY define_ins and a VNx8HI_ONLY define_expand. Use a VNx16BI destination for the latter. (*aarch64_pred_<sve_int_op><mode>): New SVE2_MATCH pattern for VNx8HI_ONLY. (*aarch64_pred_<sve_int_op><mode>_cc): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve2/acle/general/match_4.c: New test. * gcc.target/aarch64/sve2/acle/general/nmatch_1.c: Likewise.