]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
10 days agoc++: constrained memfn vs corresponding using [PR121351]
Patrick Palka [Mon, 4 Aug 2025 20:51:00 +0000 (16:51 -0400)] 
c++: constrained memfn vs corresponding using [PR121351]

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>
10 days agoc++: constexpr evaluation of abi::__dynamic_cast [PR120620]
Patrick Palka [Mon, 4 Aug 2025 20:43:33 +0000 (16:43 -0400)] 
c++: constexpr evaluation of abi::__dynamic_cast [PR120620]

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>
10 days agodefaults.h: Default MAX_FIXED_MODE_SIZE to MAX (BITS_PER_WORD * 2, 64)
Hans-Peter Nilsson [Wed, 16 Jul 2025 03:29:05 +0000 (05:29 +0200)] 
defaults.h: Default MAX_FIXED_MODE_SIZE to MAX (BITS_PER_WORD * 2, 64)

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.

10 days agolibstdc++: Add various missing exports [PR121373]
Jakub Jelinek [Mon, 4 Aug 2025 15:12:55 +0000 (17:12 +0200)] 
libstdc++: Add various missing exports [PR121373]

On Sat, Aug 02, 2025 at 09:05:07PM +0200, Jakub Jelinek wrote:
> Wonder how to automatically discover other missing exports (like in PR121373
> std::byteswap), maybe one could dig that stuff somehow from the raw
> dump (look for identifiers in std namespace (and perhaps inlined namespaces
> thereof at least) which don't start with underscore.

To answer that question, I wrote a simple plugin which just dumps the names
(which do not start with underscore) in std namespace (and its inlined
namespaces) and for non-inline namespaces in there which do not start with
underscore also recurses on those namespaces.

Plugin source in
https://gcc.gnu.org/pipermail/libstdc++/2025-August/062859.html

I went through it all now, using cppreference as a quick check for stuff
removed in C++17/C++20 and for everything added verified it is in
corresponding eel.is/c++-draft/*.syn etc. and looked it up in the libstdc++
headers for guarding macros.

After all the additions I've compiled std.cc with -std=c++20, -std=c++23 and
-std=c++26, the first one revealed std::ranges::shift_{left,right} emitted an
error in that case, the patch fixes that too.

2025-08-04  Jakub Jelinek  <jakub@redhat.com>
    hexne  <printfne@gmail.com>

PR libstdc++/121373
* src/c++23/std.cc.in (std::ranges::shift_left,
std::ranges::shift_right): Only export for C++23 and later.
(std::ranges::fold_left_first_with_iter_result,
std::ranges::fold_left_with_iter_result): Export.
(std::byteswap): Export for C++23 and later.
(std::ranges::iter_move, std::ranges::iter_swap): Export.
(std::projected_value_t): Export for C++26 and later.
(std::out_ptr_t, std::inout_ptr_t): Export.
(std::ranges::iota_result): Export.
(std::regex_constants): Export a lot of constants.
(std::is_scoped_enum, std::is_scoped_enum_v): Export.

10 days agooptinfo: use enum class
David Malcolm [Mon, 4 Aug 2025 14:45:31 +0000 (10:45 -0400)] 
optinfo: use enum class

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>
10 days agodiagnostics: improve support for nesting levels [PR116253]
David Malcolm [Mon, 4 Aug 2025 14:45:31 +0000 (10:45 -0400)] 
diagnostics: improve support for nesting levels [PR116253]

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>
10 days agodiagnostics: avoid stray trailing space in html sink in sarif-replay [PR116792]
David Malcolm [Mon, 4 Aug 2025 14:45:31 +0000 (10:45 -0400)] 
diagnostics: avoid stray trailing space in html sink in sarif-replay [PR116792]

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>
10 days agodiagnostics: move diagnostics::counters to its own header
David Malcolm [Mon, 4 Aug 2025 14:45:30 +0000 (10:45 -0400)] 
diagnostics: move diagnostics::counters to its own header

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>
10 days agodiagnostics: split source_printing_options out into its own header
David Malcolm [Mon, 4 Aug 2025 14:45:30 +0000 (10:45 -0400)] 
diagnostics: split source_printing_options out into its own header

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>
10 days agodiagnostics: rename option_manager to option_id_manager and split out from context.h
David Malcolm [Mon, 4 Aug 2025 14:45:30 +0000 (10:45 -0400)] 
diagnostics: rename option_manager to option_id_manager and split out from 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>
10 days agodiagnostics: fix comment in buffering.h
David Malcolm [Mon, 4 Aug 2025 14:45:30 +0000 (10:45 -0400)] 
diagnostics: fix comment in buffering.h

gcc/ChangeLog:
* diagnostics/buffering.h: Update comment to refer to output sinks
rather than output formats.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
10 days agogimple-warn-recursion.cc: add missing auto_diagnostic_group
David Malcolm [Mon, 4 Aug 2025 14:45:29 +0000 (10:45 -0400)] 
gimple-warn-recursion.cc: add missing auto_diagnostic_group

gcc/ChangeLog:
* gimple-warn-recursion.cc (pass_warn_recursion::execute): Add
missing auto_diagnostic_group.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
11 days agoasf: Fix null pointer dereference in is_store_forwarding [PR121303]
Konstantinos Eleftheriou [Wed, 30 Jul 2025 15:06:33 +0000 (17:06 +0200)] 
asf: Fix null pointer dereference in is_store_forwarding [PR121303]

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.

11 days agoc++: Add #line testcase for CWG2580 [PR120778]
Jakub Jelinek [Mon, 4 Aug 2025 13:28:29 +0000 (15:28 +0200)] 
c++: Add #line testcase for CWG2580 [PR120778]

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.

11 days agoada: Update Assertion_Policy handling in GNATProve mode
Viljar Indus [Wed, 16 Jul 2025 11:57:51 +0000 (14:57 +0300)] 
ada: Update Assertion_Policy handling in GNATProve mode

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.

11 days agoada: Make pp and friends more robust
Bob Duff [Wed, 23 Jul 2025 18:46:13 +0000 (14:46 -0400)] 
ada: Make pp and friends more robust

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.

11 days agoada: Check Compile_Time_Errors removed in Ghost code
Viljar Indus [Thu, 24 Jul 2025 07:49:11 +0000 (10:49 +0300)] 
ada: Check Compile_Time_Errors removed in Ghost code

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.

11 days agoada: Refactor Validate_Compile_Time_Warning_Or_Error
Viljar Indus [Thu, 24 Jul 2025 06:55:45 +0000 (09:55 +0300)] 
ada: Refactor Validate_Compile_Time_Warning_Or_Error

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.

11 days agoada: Implement accessibility legality check for discriminated function result.
Steve Baird [Tue, 22 Jul 2025 19:34:50 +0000 (12:34 -0700)] 
ada: Implement accessibility legality check for discriminated function result.

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.

11 days agoada: Keep Ghost_Mode related variables in a record
Viljar Indus [Wed, 23 Jul 2025 08:59:10 +0000 (11:59 +0300)] 
ada: Keep Ghost_Mode related variables in a record

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.

11 days agoada: Avoid generating incorrect warning
Steve Baird [Mon, 21 Jul 2025 23:23:20 +0000 (16:23 -0700)] 
ada: Avoid generating incorrect warning

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.

11 days agoada: Fix code quality issue in table.adb
Viljar Indus [Tue, 22 Jul 2025 07:17:59 +0000 (10:17 +0300)] 
ada: Fix code quality issue in table.adb

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.

11 days agoada: Misc parser cleanup
Bob Duff [Mon, 21 Jul 2025 13:43:24 +0000 (09:43 -0400)] 
ada: Misc parser cleanup

...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.

11 days agoFail early when SLP instance build fails
Richard Biener [Mon, 4 Aug 2025 11:29:16 +0000 (13:29 +0200)] 
Fail early when SLP instance build fails

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.

11 days agolibcpp: Use pedwarn instead of warning for CWG2578 diagnostics [PR120778]
Jakub Jelinek [Mon, 4 Aug 2025 12:27:14 +0000 (14:27 +0200)] 
libcpp: Use pedwarn instead of warning for CWG2578 diagnostics [PR120778]

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.

11 days agolibstdc++: Fix dereferencing of std::indirect xvalues [PR121128]
Tomasz KamiÅ„ski [Fri, 1 Aug 2025 07:21:27 +0000 (09:21 +0200)] 
libstdc++: Fix dereferencing of std::indirect xvalues [PR121128]

Forr rvalues the _Self parameter deduces a non-reference type. Consequently,
((_Self)__self) moved the object to a temporary, which then destroyed on
function exit.

This patch fixes this by using a C-style cast __self to (const indirect&).
This not only resolves the above issue but also correctly handles types that
are derived (publicly and privately) from indirect. Allocator requirements in
[allocator.requirements.general] p22 guarantee that dereferencing const _M_objp
works with equivalent semantics to dereferencing _M_objp.

PR libstdc++/121128

libstdc++-v3/ChangeLog:

* include/bits/indirect.h (indirect::operator*):
Cast __self to approparietly qualified indirect.
* testsuite/std/memory/indirect/access.cc: New test.
* testsuite/std/memory/polymorphic/access.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
11 days agoaarch64: Check the mode of SVE ACLE function results
Richard Sandiford [Mon, 4 Aug 2025 10:45:36 +0000 (11:45 +0100)] 
aarch64: Check the mode of SVE ACLE function results

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.

11 days agoaarch64: Use VNx16BI for svdupq_b*
Richard Sandiford [Mon, 4 Aug 2025 10:45:36 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for svdupq_b*

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.

11 days agoaarch64: Use VNx16BI for svdup_b*
Richard Sandiford [Mon, 4 Aug 2025 10:45:35 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for svdup_b*

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.

11 days agoaarch64: Use VNx16BI for svpnext*
Richard Sandiford [Mon, 4 Aug 2025 10:45:34 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for svpnext*

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.

11 days agoaarch64: Use VNx16BI for sv(n)match*
Richard Sandiford [Mon, 4 Aug 2025 10:45:34 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for sv(n)match*

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.

11 days agoaarch64: Use VNx16BI for svac*
Richard Sandiford [Mon, 4 Aug 2025 10:45:33 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for svac*

This patch continues the work of making ACLE intrinsics use VNx16BI
for svbool_t results.  It deals with the svac* intrinsics (floating-
point compare absolute).

gcc/
* config/aarch64/aarch64-sve.md (@aarch64_pred_fac<cmp_op><mode>):
Replace with...
(@aarch64_pred_fac<cmp_op><mode>_acle): ...this new expander.
(*aarch64_pred_fac<cmp_op><mode>_strict_acle): New pattern.
* config/aarch64/aarch64-sve-builtins-base.cc
(svac_impl::expand): Update accordingly.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/acge_1.c: New test.
* gcc.target/aarch64/sve/acle/general/acgt_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general/acle_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general/aclt_1.c: Likewise.

11 days agoaarch64: Use VNx16BI for floating-point svcmp*
Richard Sandiford [Mon, 4 Aug 2025 10:45:33 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for floating-point svcmp*

This patch continues the work of making ACLE intrinsics use VNx16BI
for svbool_t results.  It deals with the floating-point forms of svcmp*.

gcc/
* config/aarch64/aarch64-sve.md (@aarch64_pred_fcm<cmp_op><mode>_acle)
(*aarch64_pred_fcm<cmp_op><mode>_acle, @aarch64_pred_fcmuo<mode>_acle)
(*aarch64_pred_fcmuo<mode>_acle): New patterns.
* config/aarch64/aarch64-sve-builtins-base.cc
(svcmp_impl::expand, svcmpuo_impl::expand): Use them.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/cmpeq_6.c: New test.
* gcc.target/aarch64/sve/acle/general/cmpge_9.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_9.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_9.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_9.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpne_5.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpuo_1.c: Likewise.

11 days agoaarch64: Use VNx16BI for svcmp*_wide
Richard Sandiford [Mon, 4 Aug 2025 10:45:32 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for svcmp*_wide

This patch continues the work of making ACLE intrinsics use VNx16BI
for svbool_t results.  It deals with the svcmp*_wide intrinsics.

Since the only uses of these patterns are for ACLE intrinsics,
there didn't seem much point adding an "_acle" suffix.

gcc/
* config/aarch64/aarch64-sve.md (@aarch64_pred_cmp<cmp_op><mode>_wide):
Split into VNx16QI_ONLY and SVE_FULL_HSI patterns.  Use VNx16BI
results for both.
(*aarch64_pred_cmp<cmp_op><mode>_wide): New pattern.
(*aarch64_pred_cmp<cmp_op><mode>_wide_cc): Likewise.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/cmpeq_5.c: New test.
* gcc.target/aarch64/sve/acle/general/cmpge_7.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpge_8.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_7.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_8.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_7.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_8.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_7.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_8.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpne_4.c: Likewise.

11 days agoaarch64: Drop unnecessary GPs in svcmp_wide PTEST patterns
Richard Sandiford [Mon, 4 Aug 2025 10:45:32 +0000 (11:45 +0100)] 
aarch64: Drop unnecessary GPs in svcmp_wide PTEST patterns

Patterns that fuse a predicate operation P with a PTEST use
aarch64_sve_same_pred_for_ptest_p to test whether the governing
predicates of P and the PTEST are compatible.  Most patterns were also
written as define_insn_and_rewrites, with the rewrite replacing P's
original governing predicate with PTEST's.  This ensures that we don't,
for example, have both a .H PTRUE for the PTEST and a .B PTRUE for a
comparison that feeds the PTEST.

The svcmp_wide* patterns were missing this rewrite, meaning that we did
have redundant PTRUEs.

gcc/
* config/aarch64/aarch64-sve.md
(*aarch64_pred_cmp<cmp_op><mode>_wide_cc): Turn into a
define_insn_and_rewrite and rewrite the governing predicate
of the comparison so that it is identical to the PTEST's.
(*aarch64_pred_cmp<cmp_op><mode>_wide_ptest): Likewise.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/cmpeq_1.c: Check the number
of PTRUEs.
* gcc.target/aarch64/sve/acle/general/cmpge_5.c: New test.
* gcc.target/aarch64/sve/acle/general/cmpge_6.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_5.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_6.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_5.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_6.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_5.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_6.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpne_3.c: Likewise.

11 days agoaarch64: Use the correct GP mode in the svcmp_wide patterns
Richard Sandiford [Mon, 4 Aug 2025 10:45:31 +0000 (11:45 +0100)] 
aarch64: Use the correct GP mode in the svcmp_wide patterns

The patterns for the svcmp_wide intrinsics used a VNx16BI
input predicate for all modes, instead of the usual <VPRED>.
That unnecessarily made some input bits significant, but more
importantly, it triggered an ICE in aarch64_sve_same_pred_for_ptest_p
when testing whether a comparison pattern could be fused with a PTEST.

A later patch will add tests for other comparisons.

gcc/
* config/aarch64/aarch64-sve.md (@aarch64_pred_cmp<cmp_op><mode>_wide)
(*aarch64_pred_cmp<cmp_op><mode>_wide_cc): Use <VPRED> instead of
VNx16BI for the governing predicate.
(*aarch64_pred_cmp<cmp_op><mode>_wide_ptest): Likewise.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/cmpeq_1.c: Add more tests.

11 days agoaarch64: Use VNx16BI for non-widening integer svcmp*
Richard Sandiford [Mon, 4 Aug 2025 10:45:31 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for non-widening integer svcmp*

This patch continues the work of making ACLE intrinsics use VNx16BI
for svbool_t results.  It deals with the non-widening integer forms
of svcmp*.  The handling of the PTEST patterns is similar to that
for the earlier svwhile* patch.

Unfortunately, on its own, this triggers a failure in the
pred_clobber_*.c tests.  The problem is that, after the patch,
we have a comparison instruction followed by a move into p0.
Combine combines the instructions together, so that the destination
of the comparison is the hard register p0 rather than a pseudo.
This defeats IRA's make_early_clobber_and_input_conflicts, which
requires the source and destination to be pseudo registers.

Before the patch, there was a subreg move between the comparison
and the move into p0, so it was that subreg move that ended up
with a hard register destination.

Arguably the fix for PR87600 should be extended to destination
registers as well as source registers, but in the meantime,
the patch just disables combine for these tests.  The tests are
really testing the constraints and register allocation.

gcc/
* config/aarch64/aarch64-sve.md (@aarch64_pred_cmp<cmp_op><mode>_acle)
(*aarch64_pred_cmp<cmp_op><mode>_acle, *cmp<cmp_op><mode>_acle_cc)
(*cmp<cmp_op><mode>_acle_and): New patterns that yield VNx16BI
results for all element types.
* config/aarch64/aarch64-sve-builtins-base.cc
(svcmp_impl::expand): Use them.
(svcmp_wide_impl::expand): Likewise when implementing an svcmp_wide
against an in-range constant.

gcc/testsuite/
* gcc.target/aarch64/sve/pred_clobber_1.c: Disable combine.
* gcc.target/aarch64/sve/pred_clobber_2.c: Likewise.
* gcc.target/aarch64/sve/pred_clobber_3.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpeq_2.c: Add more cases.
* gcc.target/aarch64/sve/acle/general/cmpeq_4.c: New test.
* gcc.target/aarch64/sve/acle/general/cmpge_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpge_2.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpge_3.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpge_4.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_2.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_3.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpgt_4.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_2.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_3.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmple_4.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_2.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_3.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmplt_4.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpne_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general/cmpne_2.c: Likewise.

11 days agoaarch64: Use VNx16BI for svunpklo/hi_b
Richard Sandiford [Mon, 4 Aug 2025 10:45:30 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for svunpklo/hi_b

This patch continues the work of making ACLE intrinsics use VNx16BI
for svbool_t results.  It deals with the svunpk* intrinsics.

gcc/
* config/aarch64/aarch64-sve.md (@aarch64_sve_punpk<perm_hilo>_acle)
(*aarch64_sve_punpk<perm_hilo>_acle): New patterns.
* config/aarch64/aarch64-sve-builtins-base.cc
(svunpk_impl::expand): Use them for boolean svunpk*.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/unpkhi_1.c: New test.
* gcc.target/aarch64/sve/acle/general/unpklo_1.c: Likewise.

11 days agoaarch64: Use VNx16BI for svrev_b* [PR121294]
Richard Sandiford [Mon, 4 Aug 2025 10:45:29 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for svrev_b* [PR121294]

The previous patch for PR121294 handled svtrn1/2, svuzp1/2, and svzip1/2.
This one extends it to handle svrev intrinsics, where the same kind of
wrong code can be generated.

gcc/
PR target/121294
* config/aarch64/aarch64.md (UNSPEC_REV_PRED): New unspec.
* config/aarch64/aarch64-sve.md (@aarch64_sve_rev<mode>_acle)
(*aarch64_sve_rev<mode>_acle): New patterns.
* config/aarch64/aarch64-sve-builtins-base.cc
(svrev_impl::expand): Use the new patterns for boolean svrev.

gcc/testsuite/
PR target/121294
* gcc.target/aarch64/sve/acle/general/rev_2.c: New test.

11 days agoaarch64: Use VNx16BI for more permutations [PR121294]
Richard Sandiford [Mon, 4 Aug 2025 10:45:29 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for more permutations [PR121294]

The patterns for the predicate forms of svtrn1/2, svuzp1/2,
and svzip1/2 are shared with aarch64_vectorize_vec_perm_const.
The .H, .S, and .D forms operate on VNx8BI, VNx4BI, and VNx2BI
respectively.  Thus, for all four element widths, there is one
significant bit per element, for both the inputs and the output.

That's appropriate for aarch64_vectorize_vec_perm_const but not
for the ACLE intrinsics, where every bit of the output is
significant, and where every bit of the selected input elements
is therefore also significant.  The current expansion can lead
the optimisers to simplify inputs by changing the upper bits
of the input elements (since the current patterns claim that
those bits don't matter), which in turn leads to wrong code.

The ACLE expansion should operate on VNx16BI instead, for all
element widths.

There was already a pattern for a VNx16BI-only form of TRN1, for
constructing certain predicate constants.  The patch generalises it to
handle the other five permutations as well.  For the reasons given in
the comments, this is done by making the permutation unspec an operand
to a new UNSPEC_PERMUTE_PRED, rather than overloading the existing
unspecs, and rather than adding a new unspec for each permutation.

gcc/
PR target/121294
* config/aarch64/iterators.md (UNSPEC_TRN1_CONV): Delete.
(UNSPEC_PERMUTE_PRED): New unspec.
* config/aarch64/aarch64-sve.md (@aarch64_sve_trn1_conv<mode>):
Replace with...
(@aarch64_sve_<perm_insn><mode>_acle)
(*aarch64_sve_<perm_insn><mode>_acle): ...these new patterns.
* config/aarch64/aarch64.cc (aarch64_expand_sve_const_pred_trn):
Update accordingly.
* config/aarch64/aarch64-sve-builtins-functions.h
(binary_permute::expand): Use the new _acle patterns for
predicate operations.

gcc/testsuite/
PR target/121294
* gcc.target/aarch64/sve/acle/general/perm_2.c: New test.
* gcc.target/aarch64/sve/acle/general/perm_3.c: Likewise.
* gcc.target/aarch64/sve/acle/general/perm_4.c: Likewise.
* gcc.target/aarch64/sve/acle/general/perm_5.c: Likewise.
* gcc.target/aarch64/sve/acle/general/perm_6.c: Likewise.
* gcc.target/aarch64/sve/acle/general/perm_7.c: Likewise.

11 days agoaarch64: Use VNx16BI for more SVE WHILE* results [PR121118]
Richard Sandiford [Mon, 4 Aug 2025 10:45:28 +0000 (11:45 +0100)] 
aarch64: Use VNx16BI for more SVE WHILE* results [PR121118]

PR121118 is about a case where we try to construct a predicate
constant using a permutation of a PFALSE and a WHILELO.  The WHILELO
is a .H operation and its result has mode VNx8BI.  However, the
permute instruction expects both inputs to be VNx16BI, leading to
an unrecognisable insn ICE.

VNx8BI is effectively a form of VNx16BI in which every odd-indexed
bit is insignificant.  In the PR's testcase that's OK, since those
bits will be dropped by the permutation.  But if the WHILELO had been a
VNx4BI, so that only every fourth bit is significant, the input to the
permutation would have had undefined bits.  The testcase in the patch
has an example of this.

This feeds into a related ACLE problem that I'd been meaning to
fix for a long time: every bit of an svbool_t result is significant,
and so every ACLE intrinsic that returns an svbool_t should return a
VNx16BI.  That doesn't currently happen for ACLE svwhile* intrinsics.

This patch fixes both issues together.

We still need to keep the current WHILE* patterns for autovectorisation,
where the result mode should match the element width.  The patch
therefore adds a new set of patterns that are defined to return
VNx16BI instead.  For want of a better scheme, it uses an "_acle"
suffix to distinguish these new patterns from the "normal" ones.

The formulation used is:

  (and:VNx16BI (subreg:VNx16BI normal-pattern 0) C)

where C has mode VNx16BI and is a canonical ptrue for normal-pattern's
element width (so that the low bit of each element is set and the upper
bits are clear).

This is a bit clunky, and leads to some repetition.  But it has two
advantages:

* After g:965564eafb721f8000013a3112f1bba8d8fae32b, converting the
  above expression back to normal-pattern's mode will reduce to
  normal-pattern, so that the pattern for testing the result using a
  PTEST doesn't change.

* It gives RTL optimisers a bit more information, as the new tests
  demonstrate.

In the expression above, C is matched using a new "special" predicate
aarch64_ptrue_all_operand, where "special" means that the mode on the
predicate is not necessarily the mode of the expression.  In this case,
C always has mode VNx16BI, but the mode on the predicate indicates which
kind of canonical PTRUE is needed.

gcc/
PR testsuite/121118
* config/aarch64/iterators.md (VNx16BI_ONLY): New mode iterator.
* config/aarch64/predicates.md (aarch64_ptrue_all_operand): New
predicate.
* config/aarch64/aarch64-sve.md
(@aarch64_sve_while_<while_optab_cmp><GPI:mode><VNx16BI_ONLY:mode>_acle)
(@aarch64_sve_while_<while_optab_cmp><GPI:mode><PRED_HSD:mode>_acle)
(*aarch64_sve_while_<while_optab_cmp><GPI:mode><PRED_HSD:mode>_acle)
(*while_<while_optab_cmp><GPI:mode><PRED_HSD:mode>_acle_cc): New
patterns.
* config/aarch64/aarch64-sve-builtins-functions.h
(while_comparison::expand): Use the new _acle patterns that
always return a VNx16BI.
* config/aarch64/aarch64-sve-builtins-sve2.cc
(svwhilerw_svwhilewr_impl::expand): Likewise.
* config/aarch64/aarch64.cc
(aarch64_sve_move_pred_via_while): Likewise.

gcc/testsuite/
PR testsuite/121118
* gcc.target/aarch64/sve/acle/general/pr121118_1.c: New test.
* gcc.target/aarch64/sve/acle/general/whilele_13.c: Likewise.
* gcc.target/aarch64/sve/acle/general/whilelt_6.c: Likewise.
* gcc.target/aarch64/sve2/acle/general/whilege_1.c: Likewise.
* gcc.target/aarch64/sve2/acle/general/whilegt_1.c: Likewise.
* gcc.target/aarch64/sve2/acle/general/whilerw_5.c: Likewise.
* gcc.target/aarch64/sve2/acle/general/whilewr_5.c: Likewise.

11 days agoaarch64: Improve svdupq_lane expension for big-endian [PR121293]
Richard Sandiford [Mon, 4 Aug 2025 10:45:28 +0000 (11:45 +0100)] 
aarch64: Improve svdupq_lane expension for big-endian [PR121293]

If the index to svdupq_lane is variable, or is outside the range of
the .Q form of DUP, the fallback expansion is to convert to VNx2DI and
use TBL.  The problem in this PR was that the conversion used subregs,
and on big-endian targets, a bitcast from VNx2DI to another element size
requires a REV[BHW] in the best case or a spill and reload in the worst
case.  (See the comment at the head of aarch64-sve.md for details.)

Here we want the conversion to act like svreinterpret, so it should
use aarch64_sve_reinterpret instead of subregs.

gcc/
PR target/121293
* config/aarch64/aarch64-sve-builtins-base.cc (svdupq_lane::expand):
Use aarch64_sve_reinterpret instead of subregs.  Explicitly
reinterpret the result back to the required mode, rather than
leaving the caller to take a subreg.

gcc/testsuite/
PR target/121293
* gcc.target/aarch64/sve/acle/general/dupq_lane_9.c: New test.

11 days agotree-optimization/121362 - missed FRE through aggregate copy
Richard Biener [Sun, 3 Aug 2025 10:02:31 +0000 (12:02 +0200)] 
tree-optimization/121362 - missed FRE through aggregate copy

The following streamlines and generalizes how we find the common
base of the lookup ref and a kill ref when looking through
aggregate copies.  In particular this tries to deal with all
variants of punning that happens on the inner MEM_REF after
forwarding of address taken components of the common base.

PR tree-optimization/121362
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Generalize
aggregate copy handling.

* gcc.dg/tree-ssa/ssa-fre-105.c: New testcase.
* gcc.dg/tree-ssa/ssa-fre-106.c: Likewise.

11 days agoinvoke.texi: Update docs of -fdump-{rtl,tree}-<pass>-<options>
Filip Kastl [Mon, 4 Aug 2025 06:32:39 +0000 (08:32 +0200)] 
invoke.texi: Update docs of -fdump-{rtl,tree}-<pass>-<options>

This patch changes two things.  Firstly, we document
-fdump-rtl-<whatever>-graph and other such options under -fdump-tree.
At least write a remark about this under -fdump-rtl.  Secondly, the
documentation incorrectly says that -fdump-tree-<whatever>-graph is not
implemented.  Change that.

gcc/ChangeLog:

* doc/invoke.texi: Add remark about -options being documented
under -fdump-tree.  Remove remark about -graph working only for
RTL.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
11 days agox86: Don't hoist non all 0s/1s vector set outside of loop
H.J. Lu [Fri, 1 Aug 2025 12:02:18 +0000 (05:02 -0700)] 
x86: Don't hoist non all 0s/1s vector set outside of loop

Don't hoist non all 0s/1s vector set outside of the loop to avoid extra
spills.

gcc/

PR target/120941
* config/i386/i386-features.cc (x86_cse_kind): Moved before
ix86_place_single_vector_set.
(redundant_load): Likewise.
(ix86_place_single_vector_set): Replace the last argument to the
pointer to redundant_load.  For X86_CSE_VEC_DUP, don't place the
vector set outside of the loop to avoid extra spills.
(remove_redundant_vector_load): Pass load to
ix86_place_single_vector_set.

gcc/testsuite/

PR target/120941
* gcc.target/i386/pr120941-1.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 days agoDaily bump.
GCC Administrator [Mon, 4 Aug 2025 00:17:36 +0000 (00:17 +0000)] 
Daily bump.

11 days agoc++: Add stringification testcase for CWG1709 [PR120778]
Jakub Jelinek [Sun, 3 Aug 2025 16:32:19 +0000 (18:32 +0200)] 
c++: Add stringification testcase for CWG1709 [PR120778]

The CWG1709 just codifies existing GCC (and clang) behavior, so this
just adds a testcase for that.

2025-08-03  Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/120778
* g++.dg/DRs/dr1709.C: New test.

11 days agolibcpp: Fix up cpp_maybe_module_directive [PR120845]
Jakub Jelinek [Sun, 3 Aug 2025 16:27:42 +0000 (18:27 +0200)] 
libcpp: Fix up cpp_maybe_module_directive [PR120845]

My changes for "Module Declarations Shouldn’t be Macros" paper broke
the following testcase.  The backup handling intentionally tries to
drop CPP_PRAGMA_EOL token if things go wrong, which is desirable for the
case where we haven't committed to the module preprocessing directive
(i.e. changed the first token to the magic one).  In that case there is
no preprocessing directive start and so CPP_PRAGMA_EOL would be wrong.
If there is a premature new-line after we've changed the first token though,
we shouldn't drop CPP_PRAGMA_EOL, because otherwise we ICE in the FE.

While clang++ and MSVC accept the testcase, in my reading it is incorrect
at least in the C++23 and newer wordings and I think the changes have been
a DR, https://eel.is/c++draft/cpp.module has no exception for new-lines
and https://eel.is/c++draft/cpp.pre#1.sentence-2 says that new-line (unless
deleted during phase 2 when after backslash)  ends the preprocessing
directive.

The patch arranges for eol being set only in the not_module case.

2025-08-03  Jakub Jelinek  <jakub@redhat.com>

PR c++/120845
libcpp/
* lex.cc (cpp_maybe_module_directive): Move eol variable declaration
to the start of the function, initialize to false and only set it to
peek->type == CPP_PRAGMA_EOL in the not_module case.  Formatting fix.
gcc/testsuite/
* g++.dg/modules/cpp-21.C: New test.

11 days agolibstdc++: Export std::owner_equal and std::owner_hash from std.cc
Jakub Jelinek [Sun, 3 Aug 2025 15:13:37 +0000 (17:13 +0200)] 
libstdc++: Export std::owner_equal and std::owner_hash from std.cc

I've tried compiling
  #include <bits/stdc++.h>
with -std=c++26 -fdump-lang-all
and
for i in `grep ^Class.std::[^_] *.C.001l.class | sed 's/^Class //;s/[< ].*$//' | sort -u | grep -v ::.*::`; do grep -q $i /usr/src/gcc/libstdc++-v3/src/c++23/std.cc.in || echo $i;
+done
This printed
std::auto_ptr
std::binary_function
std::owner_equal
std::owner_hash
std::unary_function
where auto_ptr, binary_function and unary_function have been removed in earlier
versions of C++ and owner_equal and owner_hash are missing.

The following patch adds them.

Wonder how to automatically discover other missing exports (like in PR121373
std::byteswap), maybe one could dig that stuff somehow from the raw
dump (look for identifiers in std namespace (and perhaps inlined namespaces
thereof at least) which don't start with underscore.

2025-08-03  Jakub Jelinek  <jakub@redhat.com>

* src/c++23/std.cc.in (std::owner_equal, std::owner_hash): Export.

12 days agoAVR: Use avr_add_ccclobber / DONE_ADD_CCC in md instead of repeats.
Georg-Johann Lay [Fri, 1 Aug 2025 13:42:53 +0000 (15:42 +0200)] 
AVR: Use avr_add_ccclobber / DONE_ADD_CCC in md instead of repeats.

There are many post-reload define_insn_and_split's that just append
a  (clobber (reg:CC REG_CC))  to the pattern.  Instead of repeating
the original patterns, avr_add_ccclobber (curr_insn) is used to do
that job.

This avoids repeating patterns all over the place, and splits that do
something different (like using a canonical form) stand out clearly.

gcc/
* config/avr/avr.md (define_insn_and_split) [reload_completed]:
For splits that just append a (clobber (reg:CC REG_CC)) to
the pattern, use avr_add_ccclobber (curr_insn) instead of
repeating the original pattern.
* config/avr/avr-dimode.md: Same.
* config/avr/avr-fixed.md: Same.

12 days agoAVR: Add avr.cc::avr_add_ccclobber().
Georg-Johann Lay [Fri, 1 Aug 2025 10:55:00 +0000 (12:55 +0200)] 
AVR: Add avr.cc::avr_add_ccclobber().

gcc/
* config/avr/avr.cc (avr_add_ccclobber): New function.
* config/avr/avr-protos.h (avr_add_ccclobber): New proto.
(DONE_ADD_CCC): New define.

12 days agotree-optimization/90242 - UBSAN error in vn_reference_compute_hash
Richard Biener [Fri, 1 Aug 2025 13:07:15 +0000 (15:07 +0200)] 
tree-optimization/90242 - UBSAN error in vn_reference_compute_hash

The following plugs possible overflow issues in vn_reference_compute_hash
and possibly in vn_reference_eq.  The inchash "integer" adds are a bit
of a mess, but I know overloads with different integer types can get
messy, so not this time.  For hashing simply truncate to 64bits.

PR tree-optimization/90242
* tree-ssa-sccvn.cc (vn_reference_compute_hash): Use
poly_offset_int for offset accumulation.  For hashing
truncate to 64 bits and also hash 64 bits.
(vn_reference_eq): Likewise.

12 days agoDaily bump.
GCC Administrator [Sun, 3 Aug 2025 00:17:28 +0000 (00:17 +0000)] 
Daily bump.

12 days agodoc: Drop note on 16-bit Windows support
Gerald Pfeifer [Sat, 2 Aug 2025 23:43:03 +0000 (01:43 +0200)] 
doc: Drop note on 16-bit Windows support

gcc:
PR target/69374
* doc/install.texi (Specific) <windows>: Drop note on 16-bit
Windows support. Streamline note on 32-bit support.

13 days agocobol: Use %td in error_msg in 3 spots
Jakub Jelinek [Sat, 2 Aug 2025 07:14:14 +0000 (09:14 +0200)] 
cobol: Use %td in error_msg in 3 spots

On Thu, Jul 31, 2025 at 11:33:07PM +0200, Jakub Jelinek via Gcc wrote:
> > this was all described in excruciating detail in the patch submission
> >
> >     https://gcc.gnu.org/pipermail/gcc-patches/2025-June/687385.html
> >
> > and the commit message.
>
> Looking at that patch, the dbgmsg change looks correct (dbgmsg is
> ATTRIBUTE_PRINTF_1), while the last 3 hunks are suboptimal, they should
> really use %td and keep the ptrdiff_t arguments without casts.

Here it is in patch form.
I couldn't find other similar casts in calls to ATTRIBUTE_GCOBOL_DIAG
functions.

2025-08-02  Jakub Jelinek  <jakub@redhat.com>

* parse.y (intrinsic): Use %td format specifier with no cast on
argument instead of %ld with cast to long.
* scan_ante.h (numstr_of): Likewise.
* util.cc (cbl_field_t::report_invalid_initial_value): Likewise.

13 days agoc: rewrite implementation of `arg spec' attribute
Martin Uecker [Sun, 27 Jul 2025 15:58:14 +0000 (17:58 +0200)] 
c: rewrite implementation of `arg spec' attribute

Rewrite the implementation of the `arg spec' attribute to pass the the
original type of an array parameter instead of passing a string description
and a list of bounds.  The string and list are then created
from this type during the integration of the information of `arg spec'
into the access attribute because it still needed later for various
warnings.  This change makes the implementation simpler and more robust
as the declarator is not processed and information that is already encoded
in the type is not duplicated.  A similar change to the access attribute
could then completely remove the string processing.  With this change, the
original type is now available and can be used for other warnings or for
_Countof.  The new implementation tries to be faithful to the original,
but this is not entirely true as it fixes a bug in the old implementation.

gcc/c-family/ChangeLog:
* c-attribs.cc (handle_argspec_attribute): Update.
(build_arg_spec): New function.
(build_attr_access_from_parms): Rewrite `arg spec' handling.

gcc/c/ChangeLog:
* c-decl.cc (get_parm_array_spec): Remove.
(push_parm_decl): Do not add `arg spec` attribute.
(build_arg_spec_attribute): New function.
(grokdeklarator): Add `arg spec` attribute.

gcc/testsuite/ChangeLog:
* gcc.dg/Warray-parameter-11.c: Change Warray-parameter to
-Wvla-parameter as these are VLAs.
* gcc.dg/Warray-parameter.c: Remove xfail.

13 days agoDaily bump.
GCC Administrator [Sat, 2 Aug 2025 00:20:17 +0000 (00:20 +0000)] 
Daily bump.

13 days agoi386: Fix incorrect attributes-error.c test
Artemiy Granat [Fri, 1 Aug 2025 13:19:18 +0000 (16:19 +0300)] 
i386: Fix incorrect attributes-error.c test

gcc/testsuite/ChangeLog:

* gcc.target/i386/attributes-error.c: Change incorrect
sseregparm,fastcall combination to cdecl,fastcall.

13 days agocobol: Minor changes to quiet cppcheck warnings. [PR119324]
Robert Dubner [Fri, 1 Aug 2025 14:37:38 +0000 (10:37 -0400)] 
cobol: Minor changes to quiet cppcheck warnings.  [PR119324]

gcc/cobol/ChangeLog:

PR cobol/119324
* cbldiag.h (location_dump): Inline suppression of knownConditionTrueFalse.
* genapi.cc (parser_statement_begin): Combine two if() statements.
* genutil.cc (get_binary_value): File-level suppression of duplicateBreak.
* symbols.cc (symbol_elem_cmp): File-level suppression of duplicateBreak.

13 days agoPR modula2/121354: ICE when attempting to fold HIGH from an unbounded array in a...
Gaius Mulley [Fri, 1 Aug 2025 14:16:37 +0000 (15:16 +0100)] 
PR modula2/121354: ICE when attempting to fold HIGH from an unbounded array in a nested procedure

The bug fix re-implements gcc/m2/gm2-compiler/M2GenGCC.mod:FoldHigh
to ignore any attempt to constant fold HIGH if it has an unbounded
array operand.

gcc/m2/ChangeLog:

PR modula2/121354
* gm2-compiler/M2GenGCC.mod (FoldHigh): Rewrite.
(IsUnboundedArray): New procedure function.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 weeks agofortran: Fix closing brace in comment
Mikael Morin [Tue, 15 Jul 2025 11:33:34 +0000 (13:33 +0200)] 
fortran: Fix closing brace in comment

In a comment, fix the closing brace of the tree layout definition of the
openmp allocate clause.  It was confusing vim's matching brace support.

gcc/fortran/ChangeLog:

* trans-decl.cc (gfc_trans_deferred_vars): Fix closing brace in
a comment.

2 weeks agoProperly record SLP node when costing a vectorized store
Richard Biener [Fri, 1 Aug 2025 11:27:00 +0000 (13:27 +0200)] 
Properly record SLP node when costing a vectorized store

Even when we emit scalar stores we should pass down the SLP node.

PR tree-optimization/121350
* tree-vect-stmts.cc (vectorizable_store): Pass down SLP
node when costing scalar stores in vect_body.

2 weeks agoAvoid representing SLP mask by scalar op
Richard Biener [Fri, 1 Aug 2025 11:06:51 +0000 (13:06 +0200)] 
Avoid representing SLP mask by scalar op

The following removes the scalar mask output from vect_check_scalar_mask
and deals with the fallout, eliminating uses of it.  That's mostly
replacing checks on 'mask' by checks on 'mask_node' but also realizing
PR121349 and fixing that up a bit in check_load_store_for_partial_vectors.

PR tree-optimization/121349
* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Get full SLP mask, reduce to uniform scalar_mask for further
processing if possible.
(vect_check_scalar_mask): Remove scalar mask output, remove
code conditional on slp_mask.
(vectorizable_call): Adjust.
(check_scan_store): Get and check SLP mask.
(vectorizable_store): Eliminate scalar mask variable.
(vectorizable_load): Likewise.

2 weeks agodoc: mdocml.bsd.lv is now mandoc.bsd.lv
Gerald Pfeifer [Fri, 1 Aug 2025 11:15:57 +0000 (13:15 +0200)] 
doc: mdocml.bsd.lv is now mandoc.bsd.lv

On the way switch from http to https.

gcc:
* doc/install.texi (Prerequisites): mdocml.bsd.lv is now
mandoc.bsd.lv.

2 weeks agoMerge get_group_load_store_type into get_load_store_type
Richard Biener [Fri, 1 Aug 2025 09:02:43 +0000 (11:02 +0200)] 
Merge get_group_load_store_type into get_load_store_type

The following merges back get_group_load_store_type into
get_load_store_type, it gets easier to follow that way.  I've
removed the unused ncopies parameter as well.

* tree-vect-stmts.cc (get_group_load_store_type): Remove,
inline into ...
(get_load_store_type): ... this.  Remove ncopies parameter.
(vectorizable_load): Adjust.
(vectorizable_store): Likewise.

2 weeks agoSome TLC to vectorizable_store
Richard Biener [Fri, 1 Aug 2025 08:45:24 +0000 (10:45 +0200)] 
Some TLC to vectorizable_store

The following removes redundant checks and scalar operand uses.

* tree-vect-stmts.cc (get_group_load_store_type): Remove
checks performed at SLP build time.
(vect_check_store_rhs): Remove scalar RHS output.
(vectorizable_store): Remove uses of scalar RHS.

2 weeks agoAdd VMAT_UNINITIALIZED
Richard Biener [Fri, 1 Aug 2025 07:47:20 +0000 (09:47 +0200)] 
Add VMAT_UNINITIALIZED

We're using VMAT_INVARIANT as default, but we should simply have
an uninitialized state.

* tree-vectorizer.h (VMAT_UNINITIALIZED): New
vect_memory_access_type.
* tree-vect-slp.cc (_slp_tree::_slp_tree): Use it.

2 weeks agotree-optimization/121338 - UBSAN error in adjust_setup_cost
Richard Biener [Fri, 1 Aug 2025 06:55:11 +0000 (08:55 +0200)] 
tree-optimization/121338 - UBSAN error in adjust_setup_cost

The following avoids possibly overflowing adds for rounding.  We
know cost is bound, so it's enough to do this simple test.

PR tree-optimization/121338
* tree-ssa-loop-ivopts.cc (avg_loop_niter): Return an
unsigned.
(adjust_setup_cost): When niters is so large the division
result is one or zero avoid it.
(create_new_ivs): Adjust.

2 weeks agoPut SLP_TREE_SIMD_CLONE_INFO into type specifc data
Richard Biener [Wed, 30 Jul 2025 09:46:17 +0000 (11:46 +0200)] 
Put SLP_TREE_SIMD_CLONE_INFO into type specifc data

The following adds vect_simd_clone_data as a container for vect
type specific data for vectorizable_simd_clone_call and moves
SLP_TREE_SIMD_CLONE_INFO there.

* tree-vectorizer.h (vect_simd_clone_data): New.
(_slp_tree::simd_clone_info): Remove.
(SLP_TREE_SIMD_CLONE_INFO): Likewise.
* tree-vect-slp.cc (_slp_tree::_slp_tree): Adjust.
(_slp_tree::~_slp_tree): Likewise.
* tree-vect-stmts.cc (vectorizable_simd_clone_call): Use
tyupe specific data to store SLP_TREE_SIMD_CLONE_INFO.

2 weeks agoUse a class hierarchy for vect specific data
Richard Biener [Wed, 30 Jul 2025 09:19:03 +0000 (11:19 +0200)] 
Use a class hierarchy for vect specific data

The following turns the union into a class hierarchy.  One completed
SLP_TREE_TYPE could move into the base class.

* tree-vect-slp.cc (_slp_tree::_slp_tree): Adjust.
(_slp_tree::~_slp_tree): Likewise.
* tree-vectorizer.h (vect_data): New base class.
(_slp_tree::u): Remove.
(_slp_tree::data): Add pointer to vect_data.
(_slp_tree::get_data): New helper template.

2 weeks agobswap: Fix up ubsan detected UB in find_bswap_or_nop [PR121322]
Jakub Jelinek [Fri, 1 Aug 2025 06:41:54 +0000 (08:41 +0200)] 
bswap: Fix up ubsan detected UB in find_bswap_or_nop [PR121322]

The following testcase results in compiler UB as detected by ubsan.
find_bswap_or_nop first checks is_bswap_or_nop_p and if that fails
on the tmp_n value, tries some rotation of that if possible.
The discovery what rotate count to use ignores zero bytes from
the least significant end (those mean zero bytes and so can be masked
away) and on the first non-zero non-0xff byte (0xff means don't know),
1-8 means some particular byte of the original computes count (the rotation
count) from that byte + the byte index.
Now, on the following testcase we have tmp_n 0x403020105060700, i.e.
the least significant byte is zero, then the msb from the original value,
byte below it, another one below it, then the low 32 bits of the original
value.  So, we stop at count 7 with i 1, it wraps around and we get count
0.
Then we invoke UB on
          tmp_n = tmp_n >> count | tmp_n << (range - count);
because count is 0 and range is 64.
Now, of course I could fix it up by doing tmp_n << ((range - count) % range)
or something similar, but that is just wasted compile time, if count is 0,
we already know that is_bswap_or_nop_p failed on that tmp_n value and
so it will fail again if the value is the same.  So I think better
just return NULL (i.e. punt).

2025-08-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/121322
* gimple-ssa-store-merging.cc (find_bswap_or_nop): Return NULL if
count is 0.

* gcc.dg/pr121322.c: New test.

2 weeks agoMAINTAINERS: Update my e-mail address.
Luis Machado [Fri, 1 Aug 2025 05:56:17 +0000 (06:56 +0100)] 
MAINTAINERS: Update my e-mail address.

ChangeLog/
* MAINTAINERS: Update my e-mail address.

2 weeks agoc++/modules: Warn for optimize attributes instead of ICEing [PR108080]
Nathaniel Shead [Tue, 29 Jul 2025 11:46:59 +0000 (21:46 +1000)] 
c++/modules: Warn for optimize attributes instead of ICEing [PR108080]

This PR is the most frequently reported modules bug for 15, as the ICE
message does not indicate the issue at all and reducing to find the
underlying cause can be tricky.

I have a WIP patch to fix this issue by just reconstructing these nodes
on stream-in from any attributes applied to the functions, but since at
this stage it may still take a while to be ready, it seems useful to me
to at least make the error here more friendly and guide users to what
they could do to work around this issue.

In fact, as noted on the PR, a lot of the time it should be harmless to
just ignore the optimize etc. attribute and continue translation, at the
user's own risk; this patch as such turns the ICE into a warning with no
option to silence.

PR c++/108080

gcc/cp/ChangeLog:

* module.cc (trees_out::core_vals): Warn when streaming
target/optimize node; adjust comments.
(trees_in::core_vals): Don't stream a target/optimize node.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr108080.H: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2 weeks agoc++/modules: Merge PARM_DECL properties from function definitions [PR121238]
Nathaniel Shead [Wed, 30 Jul 2025 22:56:09 +0000 (08:56 +1000)] 
c++/modules: Merge PARM_DECL properties from function definitions [PR121238]

When we merge a function definition, if there already exists a forward
declaration in the importing TU we use the PARM_DECLs belonging to that
decl.  This usually works fine, except as noted in the linked PR there
are some flags (such as TREE_ADDRESSABLE) that only get set on a
PARM_DECL once a definition is provided.

This patch fixes the wrong-code issues by propagating any properties on
PARM_DECLs I could find that may affect codegen.

PR c++/121238

gcc/cp/ChangeLog:

* module.cc (trees_in::fn_parms_fini): Merge properties for
definitions.

gcc/testsuite/ChangeLog:

* g++.dg/modules/merge-19.h: New test.
* g++.dg/modules/merge-19_a.H: New test.
* g++.dg/modules/merge-19_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2 weeks agoDaily bump.
GCC Administrator [Fri, 1 Aug 2025 00:20:20 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agoPR modula2/121314: quotes appearing in concatenated error strings
Gaius Mulley [Thu, 31 Jul 2025 22:28:53 +0000 (23:28 +0100)] 
PR modula2/121314: quotes appearing in concatenated error strings

This patch fixes the addition of strings so that no extraneous quotes
appear in the result string.  The fix is made to the bootstrap tool mc
and it has been rebuilt.

gcc/m2/ChangeLog:

PR modula2/121314
* mc-boot/GFormatStrings.cc (PerformFormatString): Rebuilt.
* mc-boot/GM2EXCEPTION.cc (M2EXCEPTION_M2Exception): Rebuilt.
* mc-boot/GSFIO.cc (SFIO_GetFileName): Rebuilt.
* mc-boot/GSFIO.h (SFIO_GetFileName): Rebuilt.
* mc-boot/Gdecl.cc: Rebuilt.
* mc-boot/GmcFileName.h: Rebuilt.
* mc/decl.mod (getStringChar): New procedure function.
(getStringContents): Call getStringChar.
(addQuotes): New procedure function.
(foldBinary): Call addQuotes to add delimiting quotes
to the new string.

gcc/testsuite/ChangeLog:

PR modula2/121314
* gm2/errors/fail/badindrtype.mod: New test.
* gm2/errors/fail/badindrtype2.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 weeks agofortran: Evaluate class function bounds in the scalarizer [PR121342]
Mikael Morin [Wed, 30 Jul 2025 09:02:27 +0000 (11:02 +0200)] 
fortran: Evaluate class function bounds in the scalarizer [PR121342]

There is code in gfc_conv_procedure_call that, for polymorphic
functions, initializes the scalarization array descriptor
information and forcedfully sets loop bounds.  This code is changing
the decisions made by the scalarizer behind his back, and the test shows
an example where the consequences are (badly) visible.  In the test, for
one of the actual arguments to an elemental subroutine, an offset to the
loop variable is missing to access the array, as it was the one
originally chosen to set the loop bounds from.

This could theoretically be fixed by just clearing the array of choice
for the loop bounds.  This change takes instead the harder path of
adding the missing information to the scalarizer's knowledge so that its
decision doesn't need to be forced to something else after the fact.
The array descriptor information initialisation for polymorphic
functions is moved to gfc_add_loop_ss_code (after the function call
generation), and the loop bounds initialization to a new function called
after that.

As the array chosen to set the loop bounds from is no longer forced
to be the polymorphic function result, we have to let the scalarizer set
a delta for polymorphic function results.  For regular non-polymorphic
function result arrays, they are zero-based and the temporary creation
makes the loop zero-based as well, so we can continue to skip the delta
calculation.

In the cases where a temporary is created to store the result of the
array function, the creation of the temporary shifts the loop bounds
to be zero-based.  As there was no delta for polymorphic result arrays,
the function result descriptor offset was set to zero in that case for
a zero-based array reference to be correct.  Now that the scalarizer
sets a delta, those forced offset updates have to go because they can
make the descriptor invalid and cause erroneous array references.

PR fortran/121342

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_subref_array_arg): Remove offset
update.
(gfc_conv_procedure_call): For polymorphic functions, move the
scalarizer descriptor information...
* trans-array.cc (gfc_add_loop_ss_code): ... here, and evaluate
the bounds to fresh variables.
(get_class_info_from_ss): Remove offset update.
(gfc_conv_ss_startstride): Don't set a zero value for function
result upper bounds.
(late_set_loop_bounds): New.
(gfc_conv_loop_setup): If the bounds of a function result have
been set, and no other array provided loop bounds for a
dimension, use the function result bounds as loop bounds for
that dimension.
(gfc_set_delta): Don't skip delta setting for polymorphic
function results.

gcc/testsuite/ChangeLog:

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

2 weeks agoAVR: avr.opt.urls: Add -mfuse-move2
Georg-Johann Lay [Thu, 31 Jul 2025 19:10:10 +0000 (21:10 +0200)] 
AVR: avr.opt.urls: Add -mfuse-move2

PR rtl-optimization 121340
gcc/
* config/avr/avr.opt.urls (-mfuse-move2): Add url.

2 weeks agoAVR: Set .type of jump table label.
Georg-Johann Lay [Thu, 31 Jul 2025 16:31:33 +0000 (18:31 +0200)] 
AVR: Set .type of jump table label.

gcc/
* config/avr/avr.cc (avr_output_addr_vec) <labl>: Asm out its .type.

2 weeks agoAVR: rtl-optimization/121340 - New mini-pass to undo superfluous moves from insn...
Georg-Johann Lay [Wed, 30 Jul 2025 10:34:56 +0000 (12:34 +0200)] 
AVR: rtl-optimization/121340 - New mini-pass to undo superfluous moves from insn combine.

Insn combine may come up with superfluous reg-reg moves, where the combine
people say that these are no problem since reg-alloc is supposed to optimize
them.  The issue is that the lower-subreg pass sitting between combine and
reg-alloc may split such moves, coming up with a zoo of subregs which are
only handled poorly by the register allocator.

This patch adds a new avr mini-pass that handles such cases.

As an example, take

int f_ffssi (long x)
{
    return __builtin_ffsl (x);
}

where the two functions have the same interface, i.e. there are no extra
moves required for the argument or for the return value. However,

$ avr-gcc -S -Os -dp -mno-fuse-move ...

f_ffssi:
mov r20,r22  ;  29 [c=4 l=1]  movqi_insn/0
mov r21,r23  ;  30 [c=4 l=1]  movqi_insn/0
mov r22,r24  ;  31 [c=4 l=1]  movqi_insn/0
mov r23,r25  ;  32 [c=4 l=1]  movqi_insn/0
mov r25,r23  ;  33 [c=4 l=4]  *movsi/0
mov r24,r22
mov r23,r21
mov r22,r20
rcall __ffssi2  ;  34 [c=16 l=1]  *ffssihi2.libgcc
ret  ;  37 [c=0 l=1]  return

where all the moves add up to a no-op.  The -mno-fuse-move option
stops any attempts by the avr backend to clean up that mess.

PR rtl-optimization/121340
gcc/
* config/avr/avr.opt (-mfuse-move2): New option.
* config/avr/avr-passes.def (avr_pass_2moves): Insert after combine.
* config/avr/avr-passes.cc (make_avr_pass_2moves): New function.
(pass_data avr_pass_data_2moves): New static variable.
(avr_pass_2moves): New rtl_opt_pass.
* config/avr/avr-protos.h (make_avr_pass_2moves): New proto.
* common/config/avr/avr-common.cc
(default_options avr_option_optimization_table) <-mfuse-move2>:
Set for -O1 and higher.
* doc/invoke.texi (AVR Options) <-mfuse-move2>: Document.

2 weeks agoc++: constexpr, array, private ctor [PR120800]
Jason Merrill [Thu, 31 Jul 2025 18:23:10 +0000 (14:23 -0400)] 
c++: constexpr, array, private ctor [PR120800]

Here cxx_eval_vec_init_1 wants to recreate the default constructor call that
we previously built and threw away in build_vec_init_elt, but we aren't in
the same access context at this point.  Since we already checked access,
let's just suppress access control here.

Redoing overload resolution at constant evaluation time is sketchy, but
should usually be fine for a default/copy constructor.

PR c++/120800

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_vec_init_1): Suppress access control.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-array30.C: New test.

2 weeks agoRevert "Ada: Add System.C_Time and GNAT.C_Time units to libgnat"
Eric Botcazou [Thu, 31 Jul 2025 15:47:07 +0000 (17:47 +0200)] 
Revert "Ada: Add System.C_Time and GNAT.C_Time units to libgnat"

This reverts commit 41974d6ed349507ca1532629851b7b5d74f44abc.

2 weeks agoAda: Fix miscompilation of GNAT tools with -march=znver3
Eric Botcazou [Thu, 31 Jul 2025 15:38:50 +0000 (17:38 +0200)] 
Ada: Fix miscompilation of GNAT tools with -march=znver3

The throw and catch sides of the Ada exception machinery disagree about
the BIGGEST_ALIGNMENT setting.

gcc/ada/
PR ada/120440
* gcc-interface/Makefile.in (GNATLINK_OBJS): Add s-excmac.o.
(GNATMAKE_OBJS): Likewise.

2 weeks agoAda: Add System.C_Time and GNAT.C_Time units to libgnat
Nicolas Boulenguez [Fri, 25 Jul 2025 13:02:06 +0000 (15:02 +0200)] 
Ada: Add System.C_Time and GNAT.C_Time units to libgnat

The first unit provides the time_t, timeval and timespec types corresponding
to the C types defined by the OS, as well as various conversion functions.

The second unit is a mere renaming of the first under the GNAT hierarchy.

This removes C time types and conversions under System, and from bodies and
private parts under GNAT, while keeping visible types and conversions under
GNAT as Obsolescent.

[changelog]
PR ada/114065
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-c_time$(objext) and
s-c_time$(objext).
(Aarch64/Android): Do not use s-osinte__android.adb.
(SPARC/Solaris): Do not use s-osprim__solaris.adb.
(x86/Solaris): Likewise.
(LynxOS178): Do not use s-parame__posix2008.ads.
(RTEMS): Likewise.
(x32/Linux): Likewise, as well as s-linux__x32.ads.  Replace
s-osprim__x32.adb with s-osprim__posix.adb.
(LIBGNAT_OBJS): Remove cal.o.
* cal.c: Delete.
* doc/gnat_rm/the_gnat_library.rst (GNAT.C_Time): New entry.
(GNAT.Calendar): Do not mention the obsolete conversion functions.
* impunit.adb (Non_Imp_File_Names_95): Add g-c_time.
* libgnarl/a-exetim__posix.adb: Add with clause for System.C_Time
(Clock): Use type and functions from System.C_Time.
* libgnarl/s-linux.ads: Remove with clause for System.Parameters.
Remove declarations of C time types.
* libgnarl/s-linux__alpha.ads: Likewise.
* libgnarl/s-linux__android-aarch64.ads: Likewise.
* libgnarl/s-linux__android-arm.ads: Likewise.
* libgnarl/s-linux__hppa.ads: Likewise.
* libgnarl/s-linux__loongarch.ads: Likewise.
* libgnarl/s-linux__mips.ads: Likewise.
* libgnarl/s-linux__riscv.ads: Likewise.
* libgnarl/s-linux__sparc.ads: Likewise.
* libgnarl/s-osinte__aix.ads: Likewise.
* libgnarl/s-osinte__android.ads: Likewise.
* libgnarl/s-osinte__cheribsd.ads: Likewise.
* libgnarl/s-osinte__darwin.ads: Likewise.
* libgnarl/s-osinte__dragonfly.ads: Likewise.
* libgnarl/s-osinte__freebsd.ads: Likewise.
* libgnarl/s-osinte__gnu.ads: Likewise.
* libgnarl/s-osinte__hpux.ads: Likewise.
* libgnarl/s-osinte__kfreebsd-gnu.ads: Likewise.
* libgnarl/s-osinte__linux.ads: Likewise.
* libgnarl/s-osinte__lynxos178e.ads: Likewise.
* libgnarl/s-osinte__qnx.ads: Likewise.
* libgnarl/s-osinte__rtems.ads: Likewise.
* libgnarl/s-osinte__solaris.ads: Likewise.
* libgnarl/s-osinte__vxworks.ads: Likewise.
* libgnarl/s-qnx.ads: Likewise.
* libgnarl/s-linux__x32.ads: Delete.
* libgnarl/s-osinte__darwin.adb (To_Duration): Remove.
(To_Timespec): Likewise.
* libgnarl/s-osinte__aix.adb: Likewise.
* libgnarl/s-osinte__dragonfly.adb: Likewise.
* libgnarl/s-osinte__freebsd.adb: Likewise.
* libgnarl/s-osinte__gnu.adb: Likewise.
* libgnarl/s-osinte__lynxos178.adb: Likewise.
* libgnarl/s-osinte__posix.adb: Likewise.
* libgnarl/s-osinte__qnx.adb: Likewise.
* libgnarl/s-osinte__rtems.adb: Likewise.
* libgnarl/s-osinte__solaris.adb: Likewise.
* libgnarl/s-osinte__vxworks.adb: Likewise.
* libgnarl/s-osinte__x32.adb: Likewise.
* libgnarl/s-taprop__solaris.adb: Add with clause for System.C_Time.
(Monotonic_Clock): Use type and functions from System.C_Time.
(RT_Resolution): Likewise.
(Timed_Sleep): Likewise.
(Timed_Delay): Likewise.
* libgnarl/s-taprop__vxworks.adb: Likewise.
* libgnarl/s-tpopmo.adb: Likewise.
* libgnarl/s-osinte__android.adb: Delete.
* libgnat/g-c_time.ads: New file.
* libgnat/g-calend.adb: Delegate to System.C_Time.
* libgnat/g-calend.ads: Likewise.
* libgnat/g-socket.adb: Likewise.
* libgnat/g-socthi.adb: Likewise.
* libgnat/g-socthi__vxworks.adb: Likewise.
* libgnat/g-sothco.ads: Likewise.
* libgnat/g-spogwa.adb: Likewise.
* libgnat/s-c_time.adb: New file.
* libgnat/s-c_time.ads: Likewise.
* libgnat/s-optide.adb: Import nanosleep here.
* libgnat/s-os_lib.ads (time_t): Remove.
(To_Ada): Adjust.
(To_C): Likewise.
* libgnat/s-os_lib.adb: Likewise.
* libgnat/s-osprim__darwin.adb: Delegate to System.C_Time.
* libgnat/s-osprim__posix.adb: Likewise.
* libgnat/s-osprim__posix2008.adb: Likewise.
* libgnat/s-osprim__rtems.adb: Likewise.
* libgnat/s-osprim__unix.adb: Likewise.
* libgnat/s-osprim__solaris.adb: Delete.
* libgnat/s-osprim__x32.adb: Likewise.
* libgnat/s-parame.ads (time_t_bits): Remove.
* libgnat/s-parame__hpux.ads: Likewise.
* libgnat/s-parame__vxworks.ads: Likewise.
* libgnat/s-parame__posix2008.ads: Delete.
* s-oscons-tmplt.c (SIZEOF_tv_nsec): New constant.

2 weeks agoc++: consteval blocks
Marek Polacek [Mon, 14 Jul 2025 21:24:18 +0000 (17:24 -0400)] 
c++: consteval blocks

This patch implements consteval blocks, as specified by P2996.
They aren't very useful without define_aggregate, but having
a reviewed implementation on trunk would be great.

consteval {} can be anywhere where a member-declaration or
block-declaration can be.  The expression corresponding to it is:

  [] -> void static consteval compound-statement ()

and it must be a constant expression.

I've used cp_parser_lambda_expression to take care of most of the
parsing.  Since a consteval block can find itself in a template, we
need a vehicle to carry the block for instantiation.  Rather than
inventing a new tree, I'm using STATIC_ASSERT.

A consteval block can't return a value but that is checked by virtue
of the lambda having a void return type.

PR c++/120775

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_outermost_constant_expr): Use
extract_call_expr.
* cp-tree.h (CONSTEVAL_BLOCK_P, LAMBDA_EXPR_CONSTEVAL_BLOCK_P): Define.
(finish_static_assert): Adjust declaration.
(current_nonlambda_function): Likewise.
* lambda.cc (current_nonlambda_function): New parameter.  Only keep
iterating if the function represents a consteval block.
* parser.cc (cp_parser_lambda_expression): New parameter for
consteval blocks.  Use it.  Set LAMBDA_EXPR_CONSTEVAL_BLOCK_P.
(cp_parser_lambda_declarator_opt): Likewise.
(build_empty_string): New.
(cp_parser_next_tokens_are_consteval_block_p): New.
(cp_parser_consteval_block): New.
(cp_parser_block_declaration): Handle consteval blocks.
(cp_parser_static_assert): Use build_empty_string.
(cp_parser_member_declaration): Handle consteval blocks.
* pt.cc (tsubst_stmt): Adjust a call to finish_static_assert.
* semantics.cc (finish_fname): Warn for consteval blocks.
(finish_static_assert): New parameter for consteval blocks.  Set
CONSTEVAL_BLOCK_P.  Evaluate consteval blocks specially.

gcc/testsuite/ChangeLog:

* g++.dg/cpp26/consteval-block1.C: New test.
* g++.dg/cpp26/consteval-block2.C: New test.
* g++.dg/cpp26/consteval-block3.C: New test.
* g++.dg/cpp26/consteval-block4.C: New test.
* g++.dg/cpp26/consteval-block5.C: New test.
* g++.dg/cpp26/consteval-block6.C: New test.
* g++.dg/cpp26/consteval-block7.C: New test.
* g++.dg/cpp26/consteval-block8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoRISC-V: Add testcases for signed avg ceil vx combine
Pan Li [Wed, 30 Jul 2025 06:21:02 +0000 (14:21 +0800)] 
RISC-V: Add testcases for signed avg ceil vx combine

The unsigned avg ceil share the vaaddx.vx for the vx combine,
so add the test case to make sure it works well as expected.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i16.c: Add asm check
for signed avg ceil.
* 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-4-i16.c: Ditto.
* 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-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.
* 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-2-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vaadd-run-2-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vaadd-run-2-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vaadd-run-2-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agovect: Don't set bogus bounds on epilogues [PR120805]
Tamar Christina [Thu, 31 Jul 2025 14:29:30 +0000 (15:29 +0100)] 
vect: Don't set bogus bounds on epilogues [PR120805]

The testcases in the PR are failing due to the code trying to set a vector range
on an epilogue.

However on epilogues the range doesn't make sense.  In particular we are setting
ranged to help niters analysis. But the epilogue doesn't iterate.

Secondly the bounds variable hasn't been adjusted to vector iterations:

In the epilogue this is calculated as

  <bb 13> [local count: 81467476]:
  # i_127 = PHI <tmp.7_131(10), 0(5)>
  # _132 = PHI <_133(10), 0(5)>
  _181 = (unsigned int) n_41(D);
  bnd.31_180 = _181 - _132;

where

  _133 = niters_vector_mult_vf.6_130;

but _132 is a phi node, and if coming from the vector loop skip edge
_181 will be <1, VF>.

But this is a range VRP or Ranger can easily report due to the guard on the
skip_vector loop.

Previously, non-const VF would skip this code entirely due to the .is_constant()
check.

Non-partial vector loop would also skip it because the bounds would fold to a
constant. so it doesn't enter the !gimple_value check.

When support for partial vector ranges was added, this accidentally enabled
ranges on partial vector epilogues.

This patch now makes it explicit that ranges shouldn't be set for epilogues, as
they don't seem to be useful anyway.

gcc/ChangeLog:

PR tree-optimization/120805
* tree-vect-loop-manip.cc (vect_gen_vector_loop_niters): Skip setting
bounds on epilogues.

2 weeks agolibgcc: Update FMV features to latest ACLE spec 2024Q4
Wilco Dijkstra [Tue, 25 Mar 2025 15:51:42 +0000 (15:51 +0000)] 
libgcc: Update FMV features to latest ACLE spec 2024Q4

Update FMV features to latest ACLE spec of 2024Q4 - several features have been
removed or merged.  Add FMV support for CSSC and MOPS.  Preserve the ordering
in enum CPUFeatures.

gcc:
* common/config/aarch64/cpuinfo.h: Remove unused features, add FEAT_CSSC
and FEAT_MOPS.
* config/aarch64/aarch64-option-extensions.def: Remove FMV support
for RPRES, use PULL rather than AES, add FMV support for CSSC and MOPS.

libgcc:
* config/aarch64/cpuinfo.c (__init_cpu_features_constructor):
Remove unused features, add support for CSSC and MOPS.

2 weeks agolibgcc: Cleanup HWCAP defines in cpuinfo.c
Wilco Dijkstra [Mon, 28 Apr 2025 16:20:15 +0000 (16:20 +0000)] 
libgcc: Cleanup HWCAP defines in cpuinfo.c

Cleanup HWCAP defines - rather than including hwcap.h and then repeating it
using ifndef, just define the HWCAPs we need exactly as in hwcap.h.

libgcc:
* config/aarch64/cpuinfo.c: Cleanup HWCAP defines.

2 weeks agoAArch64: Use correct cost for shifted halfword load/stores
Wilco Dijkstra [Thu, 26 Jun 2025 15:41:06 +0000 (15:41 +0000)] 
AArch64: Use correct cost for shifted halfword load/stores

Since all Armv9 cores support shifted LDRH/STRH, use the correct cost of zero
for these.

gcc:
* config/aarch64/tuning_models/generic_armv9_a.h
(generic_armv9_a_addrcost_table): Use zero cost for himode.

2 weeks agoFixup wrong change to get_group_load_store_type
Richard Biener [Thu, 31 Jul 2025 12:56:27 +0000 (14:56 +0200)] 
Fixup wrong change to get_group_load_store_type

The following fixes up the r16-2593-g6ac78317aa6adf change which
made us match up a scalar with a vector type.  Oops.

Noticed when removing the gather/scatter pattern that creates the
IFNs early.

* tree-vect-stmts.cc (get_group_load_store_type): Properly
compare the scalar type of the gather/scatter offset to
the offset vector component type.

2 weeks agozlib: refresh version in configure
Sam James [Thu, 31 Jul 2025 13:57:15 +0000 (14:57 +0100)] 
zlib: refresh version in configure

zlib/ChangeLog:

* configure: Regenerate.
* configure.ac: Set version to 1.3.1.

2 weeks agoExtend gimple_fold_inplace API
Richard Biener [Thu, 20 Feb 2025 10:45:06 +0000 (11:45 +0100)] 
Extend gimple_fold_inplace API

The following allows to specify the valueization hook to be used.

* gimple-fold.h (fold_stmt_inplace): Add valueization hook
argument, defaulted to no_follow_ssa_edges.
* gimple-fold.cc (fold_stmt_inplace): Adjust.

2 weeks agozlib: update ChangeLog
Sam James [Thu, 31 Jul 2025 13:28:14 +0000 (14:28 +0100)] 
zlib: update ChangeLog

zlib/ChangeLog:
PR other/105404
* Import zlib-1.3.1

2 weeks agozlib: import zlib-1.3.1
Sam James [Fri, 22 Nov 2024 19:30:47 +0000 (19:30 +0000)] 
zlib: import zlib-1.3.1

This is vanilla zlib-1.3.1 imported over the existing zlib/ dir with:
* README adjusted to add the GCC note at the top;
* GCC's ChangeLog merged with the upstream one, as before;
* Deleted upstream Makefile as has been done before (we use an autoconf-
  generated one)

2 weeks agocobol: Eliminate various errors. [PR120244]
Robert Dubner [Wed, 30 Jul 2025 13:54:13 +0000 (09:54 -0400)] 
cobol: Eliminate various errors.  [PR120244]

The following coding errors were located by running extended tests
through valgrind.  These changes repair the errors.

gcc/cobol/ChangeLog:

PR cobol/120244
* genapi.cc (get_level_88_domain): Increase array size for final byte.
(psa_FldLiteralA): Use correct length in build_string_literal call.
* scan.l: Use a loop instead of std:transform to avoid EOF overrun.
* scan_ante.h (binary_integer_usage): Use a variable-length buffer.

2 weeks agoi386: Fix typo in diagnostic about simultaneous regparm and thiscall use
Artemiy Granat [Thu, 24 Jul 2025 15:38:27 +0000 (18:38 +0300)] 
i386: Fix typo in diagnostic about simultaneous regparm and thiscall use

gcc/ChangeLog:

* config/i386/i386-options.cc (ix86_handle_cconv_attribute):
Fix typo.

2 weeks agoi386: Fix incorrect handling of simultaneous regparm and thiscall use
Artemiy Granat [Thu, 24 Jul 2025 15:38:26 +0000 (18:38 +0300)] 
i386: Fix incorrect handling of simultaneous regparm and thiscall use

gcc/ChangeLog:

* config/i386/i386-options.cc (ix86_handle_cconv_attribute):
Handle simultaneous use of regparm and thiscall attributes in
case when regparm is set before thiscall.

gcc/testsuite/ChangeLog:

* gcc.target/i386/attributes-error.c: Add more attributes
combinations.

2 weeks agoi386: Fix incorrect comment about stdcall and fastcall compatibility
Artemiy Granat [Thu, 24 Jul 2025 15:38:25 +0000 (18:38 +0300)] 
i386: Fix incorrect comment about stdcall and fastcall compatibility

gcc/ChangeLog:

* config/i386/i386-options.cc (ix86_handle_cconv_attribute):
Fix comments which state that combination of stdcall and fastcall
attributes is valid but redundant.

2 weeks agoi386: Ignore regparm attribute and warn for it in 64-bit mode
Artemiy Granat [Tue, 29 Jul 2025 14:20:46 +0000 (17:20 +0300)] 
i386: Ignore regparm attribute and warn for it in 64-bit mode

The regparm attribute does not affect code generation on x86-64 target.
Despite this, regparm was accepted silently, unlike other calling
convention attributes handled in the ix86_handle_cconv_attribute
function.

Due to lack of diagnostics, Linux kernel attempted to specify regparm(0)
on vmread_error_trampoline declaration, which is supposed to be invoked
with all arguments on stack:
https://lore.kernel.org/all/20220928232015.745948-1-seanjc@google.com/

To produce a warning for regparm in 64-bit mode, simply move the block
that produces diagnostics above the block that handles the regparm
attribute.

gcc/ChangeLog:

* config/i386/i386-options.cc (ix86_handle_cconv_attribute):
Move 64-bit mode check before regparm handling.

gcc/testsuite/ChangeLog:

* g++.dg/abi/regparm1.C: Require ia32 target.
* gcc.target/i386/20020224-1.c: Likewise.
* gcc.target/i386/pr103785.c: Use regparm attribute only if
not in 64-bit mode.
* gcc.target/i386/pr36533.c: Likewise.
* gcc.target/i386/pr59099.c: Likewise.
* gcc.target/i386/sibcall-8.c: Likewise.
* gcc.target/i386/sw-1.c: Likewise.
* gcc.target/i386/pr15184-2.c: Fix invalid comment.
* gcc.target/i386/attributes-ignore.c: New test.