]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
7 weeks agoada: Update bug-box texts
Tonu Naks [Thu, 30 May 2024 09:22:18 +0000 (09:22 +0000)] 
ada: Update bug-box texts

gcc/ada/ChangeLog:

* comperr.adb: update support instructions
* switch.adb: update support instructions

7 weeks agoada: Fix reference to RM clause in comment
Ronan Desplanques [Thu, 10 Apr 2025 15:08:34 +0000 (17:08 +0200)] 
ada: Fix reference to RM clause in comment

The implicit declarations for labels are defined in 5.1 (12), not
5.1 (3).

gcc/ada/ChangeLog:

* sinfo.ads: Fix RM reference.

7 weeks agoada: Reuse local constant when handling External_Initialization
Piotr Trojanek [Thu, 10 Apr 2025 08:13:35 +0000 (10:13 +0200)] 
ada: Reuse local constant when handling External_Initialization

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* sem_ch3.adb (Apply_External_Initialization): Reuse local constant.

7 weeks agoada: Fix documentation of Generalized Finalization extension
Eric Botcazou [Sat, 5 Apr 2025 14:21:45 +0000 (16:21 +0200)] 
ada: Fix documentation of Generalized Finalization extension

The current documentation does not reflect the implementation present in
the compiler and contains various other inaccuracies.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst
(Generalized Finalization): Document the actual implementation.
(No_Raise): Move to separate section.
* gnat_rm.texi: Regenerate.

7 weeks agoada: Apply tweak for machine-code-based coverage
Ronan Desplanques [Mon, 7 Apr 2025 08:19:24 +0000 (10:19 +0200)] 
ada: Apply tweak for machine-code-based coverage

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Scan_Raw_Real): Apply tweak.

7 weeks agoada: Fix support e-mail addresses
Tonu Naks [Fri, 4 Apr 2025 14:38:35 +0000 (14:38 +0000)] 
ada: Fix support e-mail addresses

gcc/ada/ChangeLog:

* comperr.adb: replace report@ with support@
* gnatcmd.adb: replace report@ with support@

7 weeks agoada: Fix wrong visibility over discriminants
Ronan Desplanques [Fri, 4 Apr 2025 08:31:27 +0000 (10:31 +0200)] 
ada: Fix wrong visibility over discriminants

This patch fixes an issue where the compiler was incorrectly allowing
references to discriminants of the ancestor type in private type
extensions.

gcc/ada/ChangeLog:

* sem_ch3.adb (Build_Derived_Private_Type): Fix test.
(Build_Derived_Record_Type): Adjust error recovery paths.

7 weeks agoada: Assorted minor cleanups and tweaks
Eric Botcazou [Fri, 4 Apr 2025 18:17:28 +0000 (20:17 +0200)] 
ada: Assorted minor cleanups and tweaks

There should be no functional changes.

gcc/ada/ChangeLog:

* einfo.ads (Has_Homonym): Fix inaccuracy in description.
* sem_ch8.ads (Find_Direct_Name): Remove obsolete description.
* sem_ch12.adb (Analyze_Associations): Rename I_Node parameter
into N and adjust description.
(Analyze_Subprogram_Instantiation): Add missing description.
(Contains_Instance_Of): Fix description.
(Associations): Rename Generic_Actual_Rec into Actual_Rec and
Gen_Assocs_Rec into Match_Rec.
(Analyze_One_Association): Rename I_Node parameter into N.
(Check_Fixed_Point_Warning): Rename Gen_Assocs parameter into
Match.
(Body of Associations): Minor cleanups and tweaks.
(Analyze_Associations): Rename I_Node parameter into N and
adjust implementation.
(Analyze_One_Association): Likewise.
(Analyze_Package_Instantiation): Remove obsolete code and clean up.
(Check_Fixed_Point_Warning): Rename Gen_Assocs parameter into
Match and adjust implementation.
(Freeze_Package_Instance): Simplify condition.
(Get_Unit_Instantiation_Node): Add support for instantiations of
subprograms and stop the loop properly in case of errors.
* sem_util.ads (Add_Global_Declaration): Rename N parameter into
Decl and fix description.
* sem_util.adb (Add_Global_Declaration): Rename N parameter into
Decl and adjust implementation.

7 weeks agoada: Add Ada RM clause reference in comment
Ronan Desplanques [Wed, 2 Apr 2025 15:30:43 +0000 (17:30 +0200)] 
ada: Add Ada RM clause reference in comment

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Scan_Raw_Real): Add RM reference.

7 weeks agoada: Remove subexpression that's always False
Ronan Desplanques [Thu, 3 Apr 2025 12:22:24 +0000 (14:22 +0200)] 
ada: Remove subexpression that's always False

Also improve a few comments in the enclosing subprogram body.

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Scan_Raw_Real): Remove subexpression. Improve
surrounding comments.

7 weeks agoada: VAST: Check basic tree properties
Bob Duff [Tue, 1 Apr 2025 23:03:31 +0000 (19:03 -0400)] 
ada: VAST: Check basic tree properties

Check that the tree is really a tree, that parent pointers
make sense, that every node has been analyzed, and so on.
Most of these checks are disabled, because they fail in
many cases, including the compiler and run-time library.

Improve the debugging support in VAST. Walk subtrees "by hand",
rather than calling Atree.Traverse routines, because that
makes debugging printouts more convenient, and because we
want to keep a node stack for checking parents.

gcc/ada/ChangeLog:

* vast.adb: Check basic tree properties.
* atree.adb (Traverse_Field): Minor.
* treepr.adb (Destroy): Minor comment.

7 weeks agoada: Fix rounding test with odd bases
Eric Botcazou [Wed, 2 Apr 2025 11:13:33 +0000 (13:13 +0200)] 
ada: Fix rounding test with odd bases

The test as currently written is incorrect for odd bases.

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Round_Extra): Use multiplicative test.

7 weeks agoada: Remove obsolete test
Ronan Desplanques [Mon, 31 Mar 2025 13:17:26 +0000 (15:17 +0200)] 
ada: Remove obsolete test

A previous change cleaned up the Ekind field of record component
entities. That made a particular test obsolete, so this patch removes
that test.

gcc/ada/ChangeLog:

* einfo-utils.adb (Set_Convention): Remove obsolete test.

7 weeks agoada: Set Ekinds of discriminants earlier
Ronan Desplanques [Wed, 2 Apr 2025 09:48:06 +0000 (11:48 +0200)] 
ada: Set Ekinds of discriminants earlier

Some error processing paths in Enter_Name are adjusted so that error
messages are not affected.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Discriminants): Set Ekind earlier.
* sem_util.adb (Enter_Name): Adjust error processing.

7 weeks agoada: Fix various issues in System.Value_F.Integer_To_Fixed function
Eric Botcazou [Wed, 2 Apr 2025 08:02:18 +0000 (10:02 +0200)] 
ada: Fix various issues in System.Value_F.Integer_To_Fixed function

The first issue is that the function would wrongly raise Constraint_Error
on the edge case where Val = 2**(Int'Size - 1) and Minus is not set.

The second issue is that some runtimes are compiled with -gnatp and would
fail to raise Constraint_Error when the sum of the terms overflows an Int.

The third issue is that the function takes a long time to deal with huge
negative exponents.

gcc/ada/ChangeLog:

* libgnat/s-valuef.adb (Integer_To_Fixed): Enable overflow checks.
Deal specifically with Val = 2**(Int'Size - 1) if Minus is not set.
Exit the loop when V saturates to 0 in the case of (huge) negative
exponents.

7 weeks agoada: Tweak special handling of synchronized type scopes
Ronan Desplanques [Wed, 2 Apr 2025 08:48:57 +0000 (10:48 +0200)] 
ada: Tweak special handling of synchronized type scopes

Exp_Util.Insert_Actions handles scopes of synchronized types specially,
but the condition it tested before this patch was not quite correct in
some cases, for example during some expansion operations made under
Expand_N_Task_Type_Declaration. This patch refines the test.

gcc/ada/ChangeLog:

* exp_util.adb (Insert_Actions): Refine test.

7 weeks agoada: Small tweak to latest change
Eric Botcazou [Mon, 31 Mar 2025 22:24:12 +0000 (00:24 +0200)] 
ada: Small tweak to latest change

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler
switches) <-O>: Fix long line.
* gnat_ugn.texi: Regenerate.

7 weeks agoada: Implement -gnatRh switch to display holes in record layout
Eric Botcazou [Mon, 31 Mar 2025 19:29:27 +0000 (21:29 +0200)] 
ada: Implement -gnatRh switch to display holes in record layout

This implements the new (sub)switch -gnatRh to display holes in the layout
of record types, which are mostly present to fulfill alignment requirements.

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst (List of
all switches): Add -gnatRh subswitch.
(Debugging Control): Document -gnatRh subswitch.
* opt.ads (List_Representation_Info_Holes): New boolean variable.
* repinfo.adb: Add with clause for GNAT.Heap_Sort_G.
(List_Common_Type_Info): Relax assertion.
(List_Object_Info): Replace assertion with additional test.
(List_Record_Layout): If -gnatRh is specified, make sure that the
components are ordered by increasing offsets.  Output a comment
line giving the number of unused bits if there is a hole between
consecutive components.  Streamline the control flow of the loop.
(List_Record_Info): Use the original record type giving the layout
of components, if any, to display the layout of the record.
* switch-c.adb (Scan_Front_End_Switches) <-gnatR>: Add support for
-gnatRh subswitch.
* usage.adb (Usage): Document -gnatRh subswitch.
* gnat_ugn.texi: Regenerate.

7 weeks agoada: Adjust alignment calculation for secondary stack
Johannes Kliemann [Tue, 25 Mar 2025 15:20:41 +0000 (15:20 +0000)] 
ada: Adjust alignment calculation for secondary stack

The secondary stack allocator needs to take alignment constraints into
account when doing allocations. In the full runtime the secondary stack
is allocated in chunks on the heap and can grow dynamically. As it does
not grow contiguously the "top" of the stack depends on the size of
the allocation. Therefore the alignment of the stack top is not known at
allocation time and the padding needed for a particular alignment needs
to be calculated conservatively to ensure the allocation fits the
requested size after the base address has been aligned.
On more restricted platforms the secondary stack is a contiguous block
of statically allocated memory. Here the conservative mechanism is not
required since the allocations base address is known and the required
padding can be calculated right away. The conservative approach also
sometimes causes an allocation to be slightly larger than it needs to
be. This can be a problem on platforms with limited RAM availability. To
avoid this problem modify the calculation of the required padding on these
platforms to always exactly fit the required size.

gcc/ada/ChangeLog:

* libgnat/s-secsta.adb (SS_Allocate): Add comment about
conservative alignment padding calculation.
* libgnat/s-secsta__cheri.adb (SS_Allocate): Add comment about
conservative alignment padding calculation.

7 weeks agoada: Rewrite boolean expression
Ronan Desplanques [Mon, 31 Mar 2025 11:44:53 +0000 (13:44 +0200)] 
ada: Rewrite boolean expression

This patch rewrites a boolean expression to make it easier to understand
in its context. It also tweaks the surrounding comments.

gcc/ada/ChangeLog:

* sem_warn.adb (Check_References): Rewrite expression

7 weeks agoada: Remove uses of E_Void
Ronan Desplanques [Fri, 28 Mar 2025 10:22:22 +0000 (11:22 +0100)] 
ada: Remove uses of E_Void

This patch removes various calls on entities that have their entity
kinds set to E_Void, by giving those entities their proper kinds earlier.
This is to prepare for potential new future invariant checks on entities.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Index, Make_Index, Array_Type_Declaration,
Analyze_Number_Declaration): Remove uses of E_Void.

7 weeks agoada: Document supported GCC optimization switches
Eric Botcazou [Fri, 28 Mar 2025 17:51:23 +0000 (18:51 +0100)] 
ada: Document supported GCC optimization switches

In particular the most recently added ones, namely -Og and -Oz.  But -Ofast
is not documented because it disregards strict compliance with standards.

gcc/ada/ChangeLog:

* usage.adb (Usage): Justify the documentation of common switches
like that of other switches.  Rework that of the -O switch.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler
switches) <-O>: Rework and document 'z' and 'g' operands.
* doc/gnat_ugn/gnat_and_program_execution.rst (Optimization Levels):
Rework and document -Oz and -Og switches.
* gnat_ugn.texi: Regenerate.

7 weeks agoada: Remove creation of some unused itypes
Ronan Desplanques [Fri, 28 Mar 2025 11:37:50 +0000 (12:37 +0100)] 
ada: Remove creation of some unused itypes

Before this patch, Constrain_Index always started by creating an itype
but then sometimes not using it for anything. This patch makes it so an
itype is only created when needed.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Index): Avoid unused itypes.

7 weeks agoada: Factorize return statement
Ronan Desplanques [Fri, 28 Mar 2025 11:58:36 +0000 (12:58 +0100)] 
ada: Factorize return statement

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Index): Factorize return statement.

7 weeks agoada: Remove duplicate setter call
Ronan Desplanques [Thu, 27 Mar 2025 13:46:00 +0000 (14:46 +0100)] 
ada: Remove duplicate setter call

gcc/ada/ChangeLog:

* sem_ch3.adb (Build_Derived_Numeric_Type): Remove duplicate call.

7 weeks agoFix test case for PR117811 which failed for int < 32 bit.
Georg-Johann Lay [Thu, 12 Jun 2025 08:07:37 +0000 (10:07 +0200)] 
Fix test case for PR117811 which failed for int < 32 bit.

PR middle-end/117811
PR testsuite/52641
gcc/testsuite/
* gcc.dg/torture/pr117811.c: Fix for int < 32 bit.

7 weeks agoRefactor record_function_versions.
Alfie Richards [Thu, 27 Mar 2025 14:12:06 +0000 (14:12 +0000)] 
Refactor record_function_versions.

Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.

Additionally, change the insertion point to always maintain priority ordering
of the versions.

This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.

gcc/ChangeLog:

* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc (aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc (ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.

gcc/cp/ChangeLog:

* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.

7 weeks agoUpdate is_function_default_version to work with target_version.
Alfie Richards [Fri, 31 Jan 2025 10:47:14 +0000 (10:47 +0000)] 
Update is_function_default_version to work with target_version.

Notably this respects target_version semantics where an unannotated
function can be the default version.

gcc/ChangeLog:

* attribs.cc (is_function_default_version): Add target_version logic.

7 weeks agoi386: Set SRF, GRR, CWF, GNR, DMR, ARL and PTL issue rate
Hu, Lin1 [Wed, 14 May 2025 03:36:26 +0000 (11:36 +0800)] 
i386: Set SRF, GRR, CWF, GNR, DMR, ARL and PTL issue rate

Hi,

This patch aims to set SRF issue rate to 4, GNR issue rate to 6. According to
tests about spec2017, the patch has little effect on performance.

For GRR, CWF, DMR, ARL and PTL, the patch set their issue rate to 6. Waiting for
more information to update.

Bootstrapped and regtested on x86_64-linux-pc-gnu, OK for trunk.

BRs,
Lin

gcc/ChangeLog:

* config/i386/x86-tune-sched.cc (ix86_issue_rate): Set 4 for SRF,
6 for GRR, GNR, CWF, DMR, ARL, PTL.

7 weeks agoc, c++: Save 8 bytes of memory in lang_type for non-ObjC*
Jakub Jelinek [Thu, 12 Jun 2025 06:33:38 +0000 (08:33 +0200)] 
c, c++: Save 8 bytes of memory in lang_type for non-ObjC*

For C++26 P2786R13 I'm afraid I'll need 4-6 new flags on class types
in struct lang_type (1 bit for trivially_relocatable_if_eligible,
1 for replaceable_if_eligible, 1 for not_trivially_relocatable and
1 for not_replaceable and perhaps 2 bits whether the last 2 have been
computed already) and there are just 2 bits left.

The following patch is an attempt to save 8 bytes of memory
in those structures when not compiling ObjC or ObjC++ (I think those
are used fairly rarely and the patch keeps the sizes unmodified for
those 2).  The old allocations were 32 bytes for C and 120 bytes
for C++.  The patch moves the objc_info member last in the C++ case
(it was already last in the C case), arranges for GC to skip it
for C and C++ but walk for ObjC and ObjC++ and allocates or
copies over just offsetof bytes instead of sizeof.

2025-06-12  Jakub Jelinek  <jakub@redhat.com>

gcc/c/
* c-lang.h (union lang_type::maybe_objc_info): New type.
(struct lang_type): Use union maybe_objc_info info member
instead of tree objc_info.
* c-decl.cc (finish_struct): Allocate struct lang_type using
ggc_internal_cleared_alloc instead of ggc_cleared_alloc,
and use sizeof (struct lang_type) for ObjC and otherwise
offsetof (struct lang_type, info) as size.
(finish_enum): Likewise.
gcc/cp/
* cp-tree.h (union lang_type::maybe_objc_info): New type.
(struct lang_type): Use union maybe_objc_info info member
instead of tree objc_info.
* lex.cc (copy_lang_type): Use sizeof (struct lang_type)
just for ObjC++ and otherwise offsetof (struct lang_type, info).
(maybe_add_lang_type_raw): Likewise.
(cxx_make_type): Formatting fix.
gcc/objc/
* objc-act.h (TYPE_OBJC_INFO): Define to info.objc_info
instead of objc_info.
gcc/objcp/
* objcp-decl.h (TYPE_OBJC_INFO): Define to info.objc_info
instead of objc_info.

7 weeks agofortran: add intrinsic doc for trig functions with half revolutions
Yuao Ma [Wed, 11 Jun 2025 15:33:35 +0000 (23:33 +0800)] 
fortran: add intrinsic doc for trig functions with half revolutions

This patch is a follow-up to commit r16-938-ge8fdd55ec90749. In this patch, we
add intrinsic documentation for the newly added trig functions with half
revolutions. We also reorder the documentation for `atand` to place it in
correct alphabetical order.

PR fortran/113152

gcc/fortran/ChangeLog:

* intrinsic.texi: Document new half-revolution trigonometric
functions. Reorder doc for atand.

Signed-off-by: Yuao Ma <c8ef@outlook.com>
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
7 weeks agoc/c++: Handle '#pragma GCC target optimize' early [PR48026]
Gwenole Beauchesne [Mon, 2 Jun 2025 21:44:55 +0000 (14:44 -0700)] 
c/c++: Handle '#pragma GCC target optimize' early [PR48026]

Handle '#pragma GCC optimize' earlier as the __OPTIMIZE__ macro may need
to be defined as well for certain usages. Add additional tests for the
'#pragma GCC target' case with auto-vectorization enabled and multiple
combinations of namespaces and/or class member functions.

This is similar to what was done for `#pramga GCC target` in r14-4967-g8697d3a1dcf327,
to fix the similar issue there.

Add more complete tests for PR c++/41201 after git commit r14-4967-g8697d3a1dcf327.

PR c++/41201
PR c++/48026
gcc/c-family/ChangeLog:

* c-pragma.cc (init_pragma): Use c_register_pragma_with_early_handler
instead of c_register_pragma for `#pragma GCC optimize`.

gcc/testsuite/ChangeLog:

* c-c++-common/pragma-optimize-1.c: New test.
* g++.target/i386/vect-pragma-target-1.C: New test.
* g++.target/i386/vect-pragma-target-2.C: New test.
* gcc.target/i386/vect-pragma-target-1.c: New test.
* gcc.target/i386/vect-pragma-target-2.c: New test.

Signed-off-by: Gwenole Beauchesne <gb.devel@gmail.com>
Co-authored-by: Andrew Pinski <quic_apinski@quicinc.com>
7 weeks agolibstdc++: Add _GLIBCXX_USE_BUILTIN_TRAIT to Doxygen config
Jonathan Wakely [Thu, 29 May 2025 12:49:04 +0000 (13:49 +0100)] 
libstdc++: Add _GLIBCXX_USE_BUILTIN_TRAIT to Doxygen config

This ensures that Doxygen sees the simpler definitions of type traits,
which are implemented using the built-ins.

Also add _GLIBCXX_HAVE_ICONV (which is less important) and fix some
typos for _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE and
_GLIBCXX_END_INLINE_ABI_NAMESPACE.

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (PREDEFINED): Remove -D prefixes from
some macros. Define _GLIBCXX_USE_BUILTIN_TRAIT and
_GLIBCXX_HAVE_ICONV macros.

7 weeks agolibstdc++: Remove redundant parentheses in preprocessor condition
Jonathan Wakely [Wed, 11 Jun 2025 12:29:30 +0000 (13:29 +0100)] 
libstdc++: Remove redundant parentheses in preprocessor condition

Also indent the group controlled by the condition.

libstdc++-v3/ChangeLog:

* libsupc++/exception: Remove redundant parentheses and adjust
whitespace.

7 weeks agolibstdc++: Fix mismatched @cond and @endcond in <type_traits>
Jonathan Wakely [Wed, 11 Jun 2025 12:21:24 +0000 (13:21 +0100)] 
libstdc++: Fix mismatched @cond and @endcond in <type_traits>

I messed up the Doxygen conditionals in r16-1077-gb32bf304793047.

libstdc++-v3/ChangeLog:

* include/std/type_traits: Restore @cond and @endcond balance.

7 weeks agoc: remaining fix for the composite type inconsistency [PR120510]
Martin Uecker [Mon, 9 Jun 2025 16:48:43 +0000 (18:48 +0200)] 
c: remaining fix for the composite type inconsistency [PR120510]

There is an old GNU extension which allows overriding the
promoted old-style arguments when there is an earlier prototype
An example (from a test added for PR16666) is the following.

float dremf (float, float);

float
dremf (x, y)
     float x, y;
{
  return x + y;
}

The types of the two declarations are not compatible, because
the arguments are not self-promoting.  Add a special case
to function_types_compatible_p that can be toggled via a flag
for comptypes_internal and add a helper function to be able to
add the checking assertions to composite_type.

PR c/120510

gcc/c/ChangeLog:
* c-typeck.cc (composite_type_internal): Activate checking
assertions for all types and also inputs.
(comptypes_for_composite_check): New helper function.
(function_types_compatible_p): Add exception.

gcc/testsuite/ChangeLog:
* gcc.dg/old-style-prom-4.c: New test.

7 weeks agocobol: Eliminate unguarded clock_gettime dependencies. [PR119975]
Robert Dubner [Wed, 11 Jun 2025 19:49:41 +0000 (15:49 -0400)] 
cobol: Eliminate unguarded clock_gettime dependencies. [PR119975]

These changes are help make it possible to compile on MacOS.  In
addition to guarding clock_settime() calls, it removes the use
of structures and constants needed for clock_settime().

libgcobol/ChangeLog:

PR cobol/119975
* intrinsic.cc (__gg__current_date): Eliminate CLOCK_REALTIME.
(__gg__seconds_past_midnight): Likewise.
(__gg__formatted_current_date): Likewise.
(__gg__random): Likewise.
(__gg__random_next): Likewise.
* libgcobol.cc: include <sys/time.h>.
(__gg__abort): Eliminate CLOCK_REALTIME.
(cobol_time): Likewise.
(get_time_nanoseconds): Rename.
(get_time_nanoseconds_local): Comment; Eliminate CLOCK_REALTIME.
(__gg__clock_gettime): Likewise.
(__gg__get_date_hhmmssff): Likewise.
* libgcobol.h (__gg__clock_gettime): Eliminate clockid_t from declaration.

7 weeks agolibstdc++: Test for precision and floting point durations.
Tomasz Kamiński [Wed, 11 Jun 2025 13:56:25 +0000 (15:56 +0200)] 
libstdc++: Test for precision and floting point durations.

libstdc++-v3/ChangeLog:

* testsuite/std/time/format/empty_spec.cc: New tests.
* testsuite/std/time/format/precision.cc: New test.

7 weeks agodiagnostics: add selftests for html_token_printer [PR116792]
David Malcolm [Wed, 11 Jun 2025 18:21:41 +0000 (14:21 -0400)] 
diagnostics: add selftests for html_token_printer [PR116792]

No functional change intended.

gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc: Include "selftest-xml.h".
(html_builder::make_element_for_diagnostic): Move...
(class html_token_printer): ...from local to the function
to the global namespace.
(struct selftest::token_printer_test): New.
(selftest::test_token_printer): New.
(selftest::test_simple_log): Simplify using ASSERT_XML_PRINT_EQ.
(selftest::test_metadata): Likewise.
(selftest::diagnostic_format_html_cc_tests): Run the new test.
* selftest-xml.h: New file.
* xml.cc: Include "selftest-xml.h".
(selftest::assert_xml_print_eq): New.
(selftest::test_no_dtd): Simplify using ASSERT_XML_PRINT_EQ.
(selftest::test_printer): Likewise.
(selftest::test_attribute_ordering): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
7 weeks agoRISC-V: Prevent speculative vsetvl insn scheduling
Edwin Lu [Tue, 10 Jun 2025 20:26:42 +0000 (13:26 -0700)] 
RISC-V: Prevent speculative vsetvl insn scheduling

The instruction scheduler appears to be speculatively hoisting vsetvl
insns outside of their basic block without checking for data
dependencies. This resulted in a situation where the following occurs

        vsetvli a5,a1,e32,m1,tu,ma
        vle32.v v2,0(a0)
        sub     a1,a1,a5 <-- a1 potentially set to 0
        sh2add  a0,a5,a0
        vfmacc.vv       v1,v2,v2
        vsetvli a5,a1,e32,m1,tu,ma <-- incompatible vinfo. update vl to 0
        beq     a1,zero,.L12 <-- check if avl is 0

This patch would essentially delay the vsetvl update to after the branch
to prevent unnecessarily updating the vinfo at the end of a basic block.

PR/117974

gcc/ChangeLog:

* config/riscv/riscv.cc (struct riscv_tune_param): Add tune
param.
(riscv_sched_can_speculate_insn): Implement.
(TARGET_SCHED_CAN_SPECULATE_INSN): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/pr117974.c: New test.

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
7 weeks agoi386: Fix signed integer overflow in ix86_expand_int_movcc [PR120604]
Uros Bizjak [Wed, 11 Jun 2025 12:12:33 +0000 (14:12 +0200)] 
i386: Fix signed integer overflow in ix86_expand_int_movcc [PR120604]

Patch for PR120553 enabled full 64-bit DImode immediates in
ix86_expand_int_movcc.  However, the function calculates the difference
between two immediate arguments using signed 64-bit HOST_WIDE_INT
subtractions that can cause signed integer overflow.

Avoid the overflow by casting operands of subtractions to
(unsigned HOST_WIDE_INT).

PR target/120604

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_expand_int_movcc): Cast operands of
signed 64-bit HOST_WIDE_INT subtractions to (unsigned HOST_WIDE_INT).

7 weeks agolibfortran: Simplify Makefile logic
Francois-Xavier Coudert [Tue, 10 Jun 2025 10:37:02 +0000 (12:37 +0200)] 
libfortran: Simplify Makefile logic

Simplify the structure of the Makefile, because now we don't need so
many different variables. Also, list the m4 directory entirely in
EXTRA_DIST instead of individual files, to reduce information
duplication.

I also introduce some level of checking the regenerate.sh script.
It should catch cases where the list of generated files gets out
of sync between Makefile.am and regenerate.sh

2025-06-10  François-Xavier Coudert  <fxcoudert@gcc.gnu.org>

libgfortran/ChangeLog:

PR libfortran/116400
* Makefile.am: Simplify logic.
* Makefile.in: Regenerate.
* regenerate.sh: Add some checks.

7 weeks agoRISC-V: Add patterns for vector-scalar negate-(multiply-add/sub) [PR119100]
Paul-Antoine Arras [Wed, 4 Jun 2025 12:51:17 +0000 (14:51 +0200)] 
RISC-V: Add patterns for vector-scalar negate-(multiply-add/sub) [PR119100]

This pattern enables the combine pass (or late-combine, depending on the case)
to merge a vec_duplicate into a (possibly negated) minus-mult RTL instruction.

Before this patch, we have two instructions, e.g.:
  vfmv.v.f        v6,fa0
  vfnmadd.vv      v2,v6,v4

After, we get only one:
  vfnmadd.vf      v2,fa0,v4

This also fixes a sign mistake in the handling of vfmsub.

PR target/119100

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*<optab>_vf_<mode>): Only handle vfmadd
and vfmsub.
(*vfnmsub_<mode>): New pattern.
(*vfnmadd_<mode>): New pattern.
* config/riscv/riscv.cc (get_vector_binary_rtx_cost): Add cost model for
NEG and VEC_DUPLICATE.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f16.c: Add vfnmadd and
vfnmsub.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f64.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f16.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f64.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f16.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f64.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f16.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f64.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop.h: Add support for neg
variants. Fix sign for sub.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_data.h: Add data for neg
variants. Fix data for sub.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_run.h: Rename x to f.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f16.c: Add neg
argument.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f64.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f16.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f64.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfnmadd-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfnmadd-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfnmadd-run-1-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfnmsub-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfnmsub-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfnmsub-run-1-f64.c: New test.

7 weeks agoc: clean up some functions in c-typeck.cc
Martin Uecker [Mon, 9 Jun 2025 09:30:04 +0000 (11:30 +0200)] 
c: clean up some functions in c-typeck.cc

This removes two unnecessary variables and replaces 1/0 with
true/false for two functions with boolean return type.

gcc/c/ChangeLog:
* c-typeck.cc (function_types_compatible_p): Remove unused
variables and return true/false instead of 1/0.
(type_lists_compatible_p): Return false instead of 0.

7 weeks agoc: fix ICE for invalid code in generic selection [PR120303]
Martin Uecker [Wed, 4 Jun 2025 18:07:11 +0000 (20:07 +0200)] 
c: fix ICE for invalid code in generic selection [PR120303]

Fix an error recovery ICE that occurs when a typename
can not be parsed correctly in the controlling expression
of a generic selection.

PR c/120303

gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Handle error
condition.

gcc/testsuite/ChangeLog:
* gcc.dg/pr120303.c: New test.

7 weeks agolibstdc++: Replace some uses of std::__addressof with std::addressof
Jonathan Wakely [Thu, 22 May 2025 13:49:25 +0000 (14:49 +0100)] 
libstdc++: Replace some uses of std::__addressof with std::addressof

Since r16-154-gc91eb5a5c13f14 std::addressof is no less efficient than
std::__addressof, so change some uses of the latter to the former.  We
can't change them all, because some uses need to compile as C++98 which
only has std::__addressof.

Similarly, since r16-848-gb2aeeb2803f97b std::is_constant_evaluated is
no less efficient than std::__is_constant_evaluated.

libstdc++-v3/ChangeLog:

* include/bits/stl_construct.h: Replace std::__addressof with
std::addressof in code that doesn't need to compile as C++98.
Replace std::__is_constant_evaluated with
std::is_constant_evaluated in code that doesn't need to compile
as C++17 or earlier.
* include/bits/stl_uninitialized.h: Likewise for __addressof.

7 weeks agolibstdc++: Remove unused 'test' variables in test cases
Jonathan Wakely [Tue, 10 Jun 2025 08:34:50 +0000 (09:34 +0100)] 
libstdc++: Remove unused 'test' variables in test cases

These variables could be used by custom definitions of the VERIFY macro
prior to GCC 7.1 but serve no purpose now. They can be removed, along
with the documentation with the historical note.

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Remove note about unused 'test'
variables for old definition of VERIFY.
* doc/html/manual/test.html: Regenerate.
* testsuite/experimental/net/buffer/arithmetic.cc: Remove unused
variable.
* testsuite/experimental/net/buffer/const.cc: Likewise.
* testsuite/experimental/net/buffer/mutable.cc: Likewise.
* testsuite/experimental/net/buffer/size.cc: Likewise.
* testsuite/experimental/net/timer/waitable/cons.cc: Likewise.
* testsuite/experimental/net/timer/waitable/dest.cc: Likewise.
* testsuite/experimental/net/timer/waitable/ops.cc: Likewise.
* testsuite/ext/special_functions/airy_ai/check_value.cc:
Likewise.
* testsuite/ext/special_functions/airy_bi/check_value.cc:
Likewise.
* testsuite/ext/special_functions/conf_hyperg/check_value.cc:
Likewise.
* testsuite/ext/special_functions/hyperg/check_value.cc:
Likewise.
* testsuite/special_functions/01_assoc_laguerre/check_value.cc:
Likewise.
* testsuite/special_functions/02_assoc_legendre/check_value.cc:
Likewise.
* testsuite/special_functions/02_assoc_legendre/pr86655.cc:
Likewise.
* testsuite/special_functions/03_beta/check_value.cc: Likewise.
* testsuite/special_functions/04_comp_ellint_1/check_value.cc:
Likewise.
* testsuite/special_functions/05_comp_ellint_2/check_value.cc:
Likewise.
* testsuite/special_functions/06_comp_ellint_3/check_value.cc:
Likewise.
* testsuite/special_functions/07_cyl_bessel_i/check_value.cc:
Likewise.
* testsuite/special_functions/08_cyl_bessel_j/check_value.cc:
Likewise.
* testsuite/special_functions/09_cyl_bessel_k/check_value.cc:
Likewise.
* testsuite/special_functions/10_cyl_neumann/check_value.cc:
Likewise.
* testsuite/special_functions/11_ellint_1/check_value.cc:
Likewise.
* testsuite/special_functions/12_ellint_2/check_value.cc:
Likewise.
* testsuite/special_functions/13_ellint_3/check_value.cc:
Likewise.
* testsuite/special_functions/14_expint/check_value.cc:
Likewise.
* testsuite/special_functions/15_hermite/check_value.cc:
Likewise.
* testsuite/special_functions/16_laguerre/check_value.cc:
Likewise.
* testsuite/special_functions/17_legendre/check_value.cc:
Likewise.
* testsuite/special_functions/18_riemann_zeta/check_value.cc:
Likewise.
* testsuite/special_functions/19_sph_bessel/check_value.cc:
Likewise.
* testsuite/special_functions/20_sph_legendre/check_value.cc:
Likewise.
* testsuite/special_functions/20_sph_legendre/pr86655.cc:
Likewise.
* testsuite/special_functions/21_sph_neumann/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/01_assoc_laguerre/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/02_assoc_legendre/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/02_assoc_legendre/pr86655.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/03_beta/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/04_comp_ellint_1/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/05_comp_ellint_2/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/06_comp_ellint_3/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/07_conf_hyperg/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/08_cyl_bessel_i/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/10_cyl_bessel_k/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/12_ellint_1/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/13_ellint_2/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/14_ellint_3/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/15_expint/check_value_neg.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/16_hermite/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/17_hyperg/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/18_laguerre/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/19_legendre/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/20_riemann_zeta/check_value_neg.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/21_sph_bessel/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/22_sph_legendre/check_value.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/22_sph_legendre/pr86655.cc:
Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/23_sph_neumann/check_value.cc:
Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Fix whitespace before comments in <sstream>
Jonathan Wakely [Tue, 10 Jun 2025 10:31:14 +0000 (11:31 +0100)] 
libstdc++: Fix whitespace before comments in <sstream>

libstdc++-v3/ChangeLog:

* include/std/sstream: Adjust whitespace.

7 weeks agolibstdc++: Improve diagnostics for ill-formed std::_Destroy and std::_Destroy_n ...
Jonathan Wakely [Wed, 21 May 2025 22:48:34 +0000 (23:48 +0100)] 
libstdc++: Improve diagnostics for ill-formed std::_Destroy and std::_Destroy_n [PR120390]

By using std::is_trivially_destructible instead of the old
__has_trivial_destructor built-in we no longer need the static_assert to
deal with types with deleted destructors. All non-destructible types,
including those with deleted destructors, will now give user-friendly
diagnostics that clearly explain the problem.

Also combine the _Destroy_aux and _Destroy_n_aux class templates used
for C++98 into one, so that we perform fewer expensive class template
instantiations.

libstdc++-v3/ChangeLog:

PR libstdc++/120390
* include/bits/stl_construct.h (_Destroy_aux::__destroy_n): New
static member function.
(_Destroy_aux<true>::__destroy_n): Likewise.
(_Destroy_n_aux): Remove.
(_Destroy(ForwardIterator, ForwardIterator)): Remove
static_assert. Use is_trivially_destructible instead of
__has_trivial_destructor.
(_Destroy_n): Likewise. Use _Destroy_aux::__destroy_n instead of
_Destroy_n_aux::__destroy_n.
* testsuite/20_util/specialized_algorithms/memory_management_tools/destroy_neg.cc:
Adjust dg-error strings. Move destroy_n tests to ...
* testsuite/20_util/specialized_algorithms/memory_management_tools/destroy_n_neg.cc:
New test.
* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
Adjust dg-error strings.
* testsuite/23_containers/vector/cons/destructible_neg.cc:
Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Fix new <sstream> tests for COW std::string ABI
Jonathan Wakely [Tue, 10 Jun 2025 09:52:13 +0000 (10:52 +0100)] 
libstdc++: Fix new <sstream> tests for COW std::string ABI

The std::basic_stringbuf::get_allocator() member is only available for
the SSO std::string ABI.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_istringstream/cons/char/string_view.cc:
Only check get_allocator() for new string ABI.
* testsuite/27_io/basic_ostringstream/cons/char/string_view.cc:
Likewise.
* testsuite/27_io/basic_stringbuf/cons/char/string_view.cc:
Likewise.
* testsuite/27_io/basic_stringstream/cons/char/string_view.cc:
Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agotestsuite: Add -mpopcnt and -mabm variants of PR90693 tests
Jakub Jelinek [Wed, 11 Jun 2025 05:16:06 +0000 (07:16 +0200)] 
testsuite: Add -mpopcnt and -mabm variants of PR90693 tests

My r16-1398 patch broke bootstrap on aarch64-linux and powerpc64le-linux
at least.  Fixed with r16-1408.
The following patch just adds testcases with which the bug can be reproduced
also on x86_64-linux where it hasn't been caught by the testsuite (while
there are 2 tests with it, both where compiled with -mno-abm -mno-popcnt
and so didn't trigger the right path).  This patch just includes those
tests in 4 further ones, two with -mpopcnt and two with -mabm flags.

2025-06-11  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/90693
* gcc.target/i386/pr90693-3.c: New test.
* gcc.target/i386/pr90693-4.c: New test.
* gcc.target/i386/pr90693-5.c: New test.
* gcc.target/i386/pr90693-6.c: New test.

7 weeks agoranger: Handle the theoretical case of GIMPLE_COND with one succ edge during expansio...
Jakub Jelinek [Wed, 11 Jun 2025 05:03:04 +0000 (07:03 +0200)] 
ranger: Handle the theoretical case of GIMPLE_COND with one succ edge during expansion [PR120434]

On Tue, Jun 10, 2025 at 10:51:25AM -0400, Andrew MacLeod wrote:
> Edge range should be fine, and really that assert doesnt really need to be
> there.
>
> Where the issue could arise is in gimple-range-fold.cc in
> fold_using_range::range_of_range_op()  where we see something like:
>
>          else if (is_a<gcond *> (s) && gimple_bb (s))
>             {
>               basic_block bb = gimple_bb (s);
>               edge e0 = EDGE_SUCC (bb, 0);
>               edge e1 = EDGE_SUCC (bb, 1);
>
>               if (!single_pred_p (e0->dest))
>                 e0 = NULL;
>               if (!single_pred_p (e1->dest))
>                 e1 = NULL;
>               src.register_outgoing_edges (as_a<gcond *> (s),
>                                            as_a <irange> (r), e0, e1);
>
> Althogh, now that I look at it, it doesn't need much adjustment, just the
> expectation that there are 2 edges.  I suppose EDGE_SUCC (bb, 1) cpould
> potentially trap if there is only one edge.   we'd just have to guard it and
> alloow for that case

This patch implements that.

2025-06-11  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120434
* gimple-range-fold.cc: Include rtl.h.
(fold_using_range::range_of_range_op): Handle bb ending with
GIMPLE_COND during RTL expansion where there is only one succ
edge instead of two.

7 weeks agointernal-fn: Fix up .POPCOUNT expansion
Jakub Jelinek [Wed, 11 Jun 2025 05:00:27 +0000 (07:00 +0200)] 
internal-fn: Fix up .POPCOUNT expansion

Apparently my ranger during expansion patch broke bootstrap on
aarch64-linux, while building libsupc++, there is endless recursion
on __builtin_popcountl (x) == 1 expansion.
The hack to temporarily replace SSA_NAME_VAR of the lhs which replaced
the earlier hack to temporarily change the gimple_call_lhs relies on
the lhs being expanded with EXPAND_WRITE when expanding that ifn call.
Unfortunately, in two spots I was using expand_normal (lhs) instead
of expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE) which was used
everywhere else in internal-fn.cc.  This happened to work fine in the
past, but doesn't anymore.  git blame shows it was my patch using
these incorrect calls.

2025-06-11  Jakub Jelinek  <jakub@redhat.com>

* internal-fn.cc (expand_POPCOUNT): Use
expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE) instead of
expand_normal (lhs).

7 weeks agoDaily bump.
GCC Administrator [Wed, 11 Jun 2025 00:19:51 +0000 (00:19 +0000)] 
Daily bump.

7 weeks agodiagnostics: make experimental-html sink prettier [PR116792]
David Malcolm [Wed, 11 Jun 2025 00:06:38 +0000 (20:06 -0400)] 
diagnostics: make experimental-html sink prettier [PR116792]

This patch to the "experimental-html" diagnostic sink:
* adds use of the PatternFly 3 CSS library (via an optional link
  in the generated html to a copy in a CDN)
* uses PatternFly's "alert" pattern to show severities for diagnostics,
  properly nesting "note" diagnostics for diagnostic groups.
  Example:
    before: https://dmalcolm.fedorapeople.org/gcc/2025-06-10/before/diagnostic-ranges.c.html
     after: https://dmalcolm.fedorapeople.org/gcc/2025-06-10/after/diagnostic-ranges.c.html

* adds initial support for logical locations and physical locations
* adds initial support for multi-level nested diagnostics such as those
  for C++ concepts diagnostics.  Ideally this would show a clickable
  disclosure widget to expand/collapse a level, but for now it uses
  nested <ul> elements with <li> for the child diagnostics.
  Example:
    before: https://dmalcolm.fedorapeople.org/gcc/2025-06-10/before/nested-diagnostics-1.C.html
     after: https://dmalcolm.fedorapeople.org/gcc/2025-06-10/after/nested-diagnostics-1.C.html

gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc: Include "diagnostic-path.h" and
"diagnostic-client-data-hooks.h".
(html_builder::m_logical_loc_mgr): New field.
(html_builder::m_cur_nesting_levels): New field.
(html_builder::m_last_logical_location): New field.
(html_builder::m_last_location): New field.
(html_builder::m_last_expanded_location): New field.
(HTML_STYLE): Add "white-space: pre;" to .source and .annotation.
Add "gcc-quoted-text" CSS class.
(html_builder::html_builder): Initialize the new fields.  If CSS
is enabled, add CDN links to PatternFly 3 stylesheets.
(html_builder::add_stylesheet): New.
(html_builder::on_report_diagnostic): Add "alert" param to
make_element_for_diagnostic, setting it by default, but unsetting
it for nested diagnostics below the top level.  Use
add_at_nesting_level for nested diagnostics.
(add_nesting_level_attr): New.
(html_builder::add_at_nesting_level): New.
(get_pf_class_for_alert_div): New.
(get_pf_class_for_alert_icon): New.
(get_label_for_logical_location_kind): New.
(add_labelled_value): New.
(html_builder::make_element_for_diagnostic): Add leading comment.
Add "alert" param.  Drop class="gcc-diagnostic" from <div> tag,
instead adding the class for a PatternFly 3 alert if "alert" is
true, and adding a <span> with an alert icon, both according to
the diagnostic severity.  Add a severity prefix to the message for
alerts.  Add any metadata/option text as suffixes to the message.
Show any logical location.  Show any physical location.  Don't
show the locus if the last location is unchanged within the
diagnostic_group.  Wrap any execution path element in a
<div id="execution-path"> and add a label to it.  Wrap any
generated patch in a <div id="suggested-fix"> and add a label
to it.
(selftest::test_simple_log): Update expected HTML.

gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/html-output/missing-semicolon.py: Update for changes
to diagnostic elements.
* gcc.dg/format/diagnostic-ranges-html.py: Likewise.
* gcc.dg/plugin/diagnostic-test-metadata-html.py: Likewise.  Drop
out-of-date comment.
* gcc.dg/plugin/diagnostic-test-paths-2.py: Likewise.
* gcc.dg/plugin/diagnostic-test-paths-4.py: Likewise.  Drop
out-of-date comment.
* gcc.dg/plugin/diagnostic-test-show-locus.py: Likewise.
* lib/htmltest.py (get_diag_by_index): Update to use search by id.
(get_message_within_diag): Update to use search by class.

libcpp/ChangeLog:
PR other/116792
* include/line-map.h (typedef expanded_location): Convert to...
(struct expanded_location): ...this.
(operator==): New decl, for expanded_location.
(operator!=): Likewise.
* line-map.cc (operator==): New decl, for expanded_location.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
7 weeks agodiagnostics: xml: add add_text_from_pp
David Malcolm [Wed, 11 Jun 2025 00:06:38 +0000 (20:06 -0400)] 
diagnostics: xml: add add_text_from_pp

Various places use
  xp.add_text (pp_formatted_text (&pp))
Add a helper function for this.
No functional change intended.

gcc/ChangeLog:
* diagnostic-path-output.cc: Use xml::printer::add_text_from_pp.
* diagnostic-show-locus.cc: Likewise.
* xml-printer.h (xml::printer::add_text_from_pp): New decl.
* xml.cc (xml::node_with_children::add_text_from_pp): New.
(xml::printer::add_text_from_pp): New.
* xml.h (xml::node_with_children::add_text_from_pp): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
7 weeks agodiagnostics: fix tag nesting issues in experimental-html sink [PR120610]
David Malcolm [Wed, 11 Jun 2025 00:06:37 +0000 (20:06 -0400)] 
diagnostics: fix tag nesting issues in experimental-html sink [PR120610]

I've been seeing issues in the experimental-html sink where the nesting
of tags goes wrong.

The two issues I've seen are:
* the pp_token_list from the diagnostic message that reaches the
  html_token_printer doesn't always have matching pairs of begin/end
  tokens (PR other/120610)
* a bug in diagnostic-show-locus where there was a stray xp.pop_tag,
  in print_trailing_fixits.

This patch:
* changes the xml::printer::pop_tag API so that it now takes the
  expected name of the element being popped (rather than expressing this
  in comments), and that, by default, the xml::printer asserts that this
  matches.
* gives the html_token_printer its own xml::printer instance to restrict
  the affected area of the DOM tree; this xml::printer doesn't enforce
  nesting (PR other/120610)
* adds RAII sentinel classes that automatically check for pushes/pops
  being balanced within a scope, using them in various places
* fixes the bug in print_trailing_fixits for html output

gcc/ChangeLog:
PR other/120610
* diagnostic-format-html.cc (html_builder::html_builder): Update
for new param of xml::printer::pop_tag.
(html_path_label_writer::end_label): Likewise.
(html_builder::make_element_for_diagnostic::html_token_printer):
Give the instance its own xml::printer.  Update for new param of
xml::printer::pop_tag.
(html_builder::make_element_for_diagnostic): Give the instance its
own xml::printer.
(html_builder::make_metadata_element): Update for new param of
xml::printer::pop_tag.
(html_builder::flush_to_file): Likewise.
* diagnostic-path-output.cc (begin_html_stack_frame): Likewise.
(begin_html_stack_frame): Likewise.
(end_html_stack_frame): Likewise.
(print_path_summary_as_html): Likewise.
* diagnostic-show-locus.cc
(struct to_text::auto_check_tag_nesting): New.
(struct to_html:: auto_check_tag_nesting): New.
(to_text::pop_html_tag): Change param to const char *.
(to_html::pop_html_tag): Likewise; rename param to
"expected_name".
(default_diagnostic_start_span_fn<to_html>): Update for new param
of xml::printer::pop_tag.
(layout_printer<to_html>::end_label): Likewise.
(layout_printer<Sink>::print_trailing_fixits): Add RAII sentinel
to check tag nesting for the HTML case.  Delete stray popping
of "td" in the presence of fix-it hints.
(layout_printer<Sink>::print_line): Add RAII sentinel
to check tag nesting for the HTML case.
(diagnostic_source_print_policy::print_as_html): Likewise.
(layout_printer<Sink>::print): Likewise.
* xml-printer.h (xml::printer::printer): Add optional
"check_popped_tags" param.
(xml::printer::pop_tag): Add "expected_name" param.
(xml::printer::get_num_open_tags): New accessor.
(xml::printer::dump): New decl.
(xml::printer::m_check_popped_tags): New field.
(class xml::auto_check_tag_nesting): New.
(class xml::auto_print_element): Update for new param of pop_tag.
* xml.cc: Move pragma pop so that the pragma also covers
xml::printer's member functions, "dump" in particular.
(xml::printer::printer): Add param "check_popped_tags".
(xml::printer::pop_tag): Add param "expected_name" and use it to assert
that the popped tag is as expected.  Assert that we have a tag to
pop.
(xml::printer::dump): New.
(selftest::test_printer): Update for new param of pop_tag.
(selftest::test_attribute_ordering): Likewise.

gcc/testsuite/ChangeLog:
PR other/120610
* gcc.dg/format/diagnostic-ranges-html.py: Remove out-of-date
comment.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
7 weeks agogimple-ssa-warn-access: add missing auto_diagnostic_group
David Malcolm [Wed, 11 Jun 2025 00:06:37 +0000 (20:06 -0400)] 
gimple-ssa-warn-access: add missing auto_diagnostic_group

Spotted whilst implementing nesting support in the
experimental-html diagnostic sink.

gcc/ChangeLog:
* gimple-ssa-warn-access.cc
(pass_waccess::maybe_check_dealloc_call): Add missing
auto_diagnostic_group to nest the "returned from %qD"
note within the warning.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
7 weeks agoRISC-V: testsuite: fix an obvious build error
Vineet Gupta [Tue, 20 May 2025 21:15:53 +0000 (14:15 -0700)] 
RISC-V: testsuite: fix an obvious build error

For a non-multilib build, I see following errors.

| FAIL: gcc.target/riscv/rvv/vtype-call-clobbered.c (test for excess errors)
| Excess errors:
| TC-INSTxyz/sysroot/usr/include/gnu/stubs.h:14:11: fatal error: gnu/stubs-lp64.h: No such file or directory compilation terminated.

The test selects non default ABI lp64 (vs. lp64d) for no real reason.
Fix that.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vtype-call-clobbered.c: Fix -mabi.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
7 weeks agoMore API for IPA profile manipulation
Jan Hubicka [Tue, 10 Jun 2025 19:32:40 +0000 (21:32 +0200)] 
More API for IPA profile manipulation

This patch attempts to make IPA profile manipulation easier.  It introduces

 node->scale_profile_to (count)
    which can be used to scale profile to a given IPA count.
    If IPA count is zero, then local profile is preserved and proper variant
    of global0 count is used.

 node->make_profile_local
    this can be used to drop IPA profile but keep local profile

 node->make_profile_global0
    this can be used to make IPA profile 0 but keep local
    profile.

Most of this can be accomplished by existing apply_scale.  I.e.
 - node->scale_profile_to (count)
     corresponds to
    node->apply_scale (count, node->count),
 - node->make_profile_local
     corresponds to
   node->apply_scale (node->count.guessed_local (), node->count)

I think new API is more clean about what intention is and less error prone.
Also it handles some side cases when entry block of profile happens to be 0,
but body is non-zero (by profile inconsistencies).  In this case the scaling
API did kind of random things.

I noticed three bugs in ipa-cp (two already in released GCCs while one mine
introduced by last patch):

@@ -4528,7 +4528,7 @@ lenient_count_portion_handling (profile_count remainder, cgraph_node *orig_node)
   if (remainder.ipa_p () && !remainder.ipa ().nonzero_p ()
       && orig_node->count.ipa_p () && orig_node->count.ipa ().nonzero_p ()
       && opt_for_fn (orig_node->decl, flag_profile_partial_training))
-    remainder = remainder.guessed_local ();
+    remainder = orig_node->count.guessed_local ();

The code was intended to drop IPA profile to local when remainder is 0.
In this case orig_node->count is some non-zero count but all of control flow
was redirected to a clone which means that remainer is 0 (adjusted).
Doing

     remainder = remainder.guessed_local ();

will turn it into 0 (guessed_local) and the scalling will then multiply
all counts by 0 and turn them tinto guessed local.
We want to keep original count but reduce the quality. i.e.

     remainder = orig_node->count.guessed_local ();

Second problem is:
       /* TODO: Profile has alreay gone astray, keep what we have but lower it
   to global0 category.  */
       remainder = orig_node->count.global0 ();
global0 means that converting to ipa count will be precise 0. Since we lost track
it should be adjusted 0 :)

Finally in:
  new_sum = orig_node_count.combine_with_ipa_count (new_sum);
  orig_node->count = remainder;

  new_node->apply_scale (new_sum, new_node->count);

   if (!orig_edges_processed)
    orig_node->apply_scale (remainder, orig_node->count);
    orig_node->scale_profile_to (remainder);

orig_node->count is first set to remainder and then scalling is done
(which in turn does nothing).

This is bug I introduced in last path which should have removed
orig_node->count = remainder.  As a result now counts of cgraph edges are not
adjusted correctly.  I am sorry for that.

gcc/ChangeLog:

* cgraph.cc (cgraph_node::make_profile_local): New member function.
(cgraph_node::make_profile_global0): New member function.
(cgraph_node::apply_scale): Do not call adjust_for_ipa_scalling.
(cgraph_node::scale_profile_to): New member function.
* cgraph.h (cgraph_node::make_profile_local,
cgraph_node::make_profile_global0, cgraph_node::scale_profile_to):
Declare.
* ipa-cp.cc (lenient_count_portion_handling): Fix logic dropping count
to local.
(update_counts_for_self_gen_clones): Use scale_profile_to.
(update_profiling_info): Use make_profile_local, make_profile_global0
and scale_profile_to.
(update_specialized_profile): Likewise.
* ipa-inline-transform.cc (clone_inlined_nodes): Call
adjust_for_ipa_scalling.

7 weeks agoexpand: Use less costly from sign and zero extensions for values where value range...
Jakub Jelinek [Tue, 10 Jun 2025 18:06:14 +0000 (20:06 +0200)] 
expand: Use less costly from sign and zero extensions for values where value range says they don't have MSB set [PR120434]

On top of the just posted patch, the following patch attempts to
use value range to see if MSB is known to be false and for scalar integral
extension in that case tries to expand both sign and zero extension and
chooses based on RTX costs the cheaper one (if the costs are the same
uses what it used before, TYPE_UNSIGNED (TREE_TYPE (treeop0)) based.

The patch regresses the gcc.target/i386/pr78103-3.c test, will post
a separate patch for that momentarily (with the intent that if all 3
patches are approved, I'll commit the PR78103 related one before this one).

2025-06-10  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120434
* expr.cc (expand_expr_real_2) <CASE_CONVERT>: If get_range_pos_neg
at -O2 for scalar integer extension suggests the most significant
bit of op0 is not set, try both unsigned and signed conversion and
choose the cheaper one.  If both are the same cost, choose one
based on TYPE_UNSIGNED (TREE_TYPE (treeop0)).

* gcc.target/i386/pr120434-2.c: New test.

7 weeks agoi386: Handle ZERO_EXTEND like SIGN_EXTEND in bsr patterns [PR120434]
Jakub Jelinek [Tue, 10 Jun 2025 18:07:06 +0000 (20:07 +0200)] 
i386: Handle ZERO_EXTEND like SIGN_EXTEND in bsr patterns [PR120434]

The just posted second PR120434 patch causes
+FAIL: gcc.target/i386/pr78103-3.c scan-assembler \\\\m(leaq|addq|incq)\\\\M
+FAIL: gcc.target/i386/pr78103-3.c scan-assembler-not \\\\mmovl\\\\M+
+FAIL: gcc.target/i386/pr78103-3.c scan-assembler-not \\\\msubq\\\\M
+FAIL: gcc.target/i386/pr78103-3.c scan-assembler-not \\\\mxor[lq]\\\\M
While the patch generally improves code generation by often using
ZERO_EXTEND instead of SIGN_EXTEND, where the former is often for free
on x86_64 while the latter requires an extra instruction or larger
instruction than one with just zero extend, the PR78103 combine patterns
and splitters were written only with SIGN_EXTEND in mind.  As CLZ is UB
on 0 and otherwise returns just [0,63] and is xored with 63, ZERO_EXTEND
does the same thing there as SIGN_EXTEND.

2025-06-10  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120434
* config/i386/i386.md (*bsr_rex64_2): Rename to ...
(*bsr_rex64<u>_2): ... this.  Use any_extend instead of sign_extend.
(*bsr_2): Rename to ...
(*bsr<u>_2): ... this.  Use any_extend instead of sign_extend.
(bsr splitters after those): Use any_extend instead of sign_extend.

7 weeks agoexpand, ranger: Use ranger during expansion [PR120434]
Jakub Jelinek [Tue, 10 Jun 2025 18:04:52 +0000 (20:04 +0200)] 
expand, ranger: Use ranger during expansion [PR120434]

As the following testcase shows, during expansion we use value range info
in lots of places, but sadly currently use only the global ranges.
It is mostly through get_range_pos_neg function, which uses
get_global_range_query ()->range_of_expr (arg1, arg2)
but other spots use it directly.

On the testcase at the end of the patch, in foo we don't know range of x,
so emit the at least on x86_64 less efficient signed division in that case.
In bar, the default def SSA_NAME has global range and we try to expand
the division both as signed and unsigned because the range proves they will
have the same result and choose the cheaper one.
And finally in baz, we have VARYING in global range, but can do better if
we ask for range at the statement we're expanding.

The main problem of using the ranger during expansion is that things are in
flux, the already expanded basic blocks switch their IL from gimple to RTL
(bb->flags & BB_RTL) and the gimple stmts are gone, PHI nodes even earlier,
etc.

The patch attempts to make the ranger usable by keeping (bb->flags & BB_RTL)
== 0 on basic blocks for longer, in particular until the last
expand_gimple_basic_block call for the function.  Instead of changing the
IL right away, it uses a vector indexed by bb->index to hold the
future BB_HEAD/BB_END.  I had to do a few changes on the ranger side and
maybe testing in the wild will show a few extra cases, but I think those
are tolerable and can be guarded with currently_expanding_to_rtl so that
we don't punt on consistency checks on normal GIMPLE.
In particular, even with the patch there will still be some BB_RTL
bbs in the IL, e.g. the initial block after ENTRY, ENTRY and EXIT blocks
and from time to time others as well, but those should never contain
anything intreresting from the ranger POV.  And switch expansion can drop
the default edge if it is __builtin_unreachable.

Also, had to change the internal call TER expansion, the current way
of temporarily changing gimple_call_lhs ICEd badly in the ranger, so I'm
instead temporarily changing SSA_NAME_VAR of the SSA_NAME.

2025-06-10  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120434
* cfgrtl.h (update_bb_for_insn_chain): Declare.
* cfgrtl.cc (update_bb_for_insn_chain): No longer static.
* cfgexpand.h (expand_remove_edge): Declare.
* cfgexpand.cc: Include "gimple-range.h".
(head_end_for_bb): New variable.
(label_rtx_for_bb): Drop ATTRIBUTE_UNUSED from bb argument.
Use head_end_for_bb if possible for non-BB_RTL bbs.
(expand_remove_edge): New function.
(maybe_cleanup_end_of_block): Use it instead of remove_edge.
(expand_gimple_cond): Don't clear EDGE_TRUE_VALUE and
EDGE_FALSE_VALUE just yet.  Use head_end_for_bb elts instead
of BB_END and update_bb_for_insn_chain instead of update_bb_for_insn.
(expand_gimple_tailcall): Use expand_remove_edge instead of
remove_edge.  Use head_end_for_bb elts instead of BB_END and
update_bb_for_insn_chain instead of update_bb_for_insn.
(expand_gimple_basic_block): Don't change bb to BB_RTL here, instead
use head_end_for_bb elts instead of BB_HEAD and BB_END.  Use
update_bb_for_insn_chain instead of update_bb_for_insn.
(pass_expand::execute): Enable ranger before expand_gimple_basic_block
calls and create head_end_for_bb vector.  Disable ranger after
those calls, turn still non-BB_RTL blocks into BB_RTL and set their
BB_HEAD and BB_END from head_end_for_bb elts, and clear EDGE_TRUE_VALUE
and EDGE_FALSE_VALUE flags on edges.  Release head_end_for_bb
vector.
* tree-outof-ssa.cc (expand_phi_nodes): Don't clear phi nodes here.
* tree.h (get_range_pos_neg): Add gimple * argument defaulted to NULL.
* tree.cc (get_range_pos_neg): Add stmt argument.  Use
get_range_query (cfun) instead of get_global_range_query () and pass
stmt as third argument to range_of_expr.
* expr.cc (expand_expr_divmod): Pass currently_expanding_gimple_stmt
to get_range_pos_neg.
(expand_expr_real_1) <case SSA_NAME>: Change internal fn handling
to avoid temporarily overwriting gimple_call_lhs of ifn, instead
temporarily overwrite SSA_NAME_VAR of its lhs.
(maybe_optimize_pow2p_mod_cmp): Pass currently_expanding_gimple_stmt
to get_range_pos_neg.
(maybe_optimize_mod_cmp): Likewise.
* internal-fn.cc (get_min_precision): Likewise.  Use
get_range_query (cfun) instead of get_global_range_query () and pass
currently_expanding_gimple_stmt as third argument to range_of_expr.
Pass g to get_range_pos_neg.
(expand_addsub_overflow): Pass currently_expanding_gimple_stmt
to get_range_pos_neg.
(expand_mul_overflow): Likewise.
(expand_arith_overflow): Pass stmt to get_range_pos_neg.
* gimple-range-edge.cc: Include rtl.h.
(gimple_outgoing_range_stmt_p): Return NULL for BB_RTL bbs.
(gimple_outgoing_range::calc_switch_range): If default_edge is NULL,
assert currently_expanding_to_rtl and return before trying to
set range on that edge.
* builtins.cc (expand_builtin_strnlen): Use get_range_query (cfun)
instead of get_global_range_query () and pass
currently_expanding_gimple_stmt as third argument to range_of_expr.
(determine_block_size): Likewise.
* gimple-range.cc (gimple_ranger::range_on_exit): Set s to NULL
instead of last_nondebug_stmt for BB_RTL bbs.
* stmt.cc: Include cfgexpand.h.
(expand_case): Use expand_remove_edge instead of remove_edge.

* gcc.target/i386/pr120434-1.c: New test.

7 weeks agoCheck if constant is a member before returning it.
Andrew MacLeod [Tue, 10 Jun 2025 16:11:18 +0000 (12:11 -0400)] 
Check if constant is a member before returning it.

set_range_from_bitmask checks the new bitmask, and if it is a constant,
simply returns the constant.  It never checks if that constant is
actually within the range.  If it is not, the result should be UNDEFINED.

* value-range.cc (irange::set_range_from_bitmask): When the bitmask
result is a singleton, check if it is contained in the range.

7 weeks agocobol: Variety of small changes in answer to cppcheck diagnostics.
James K. Lowden [Tue, 10 Jun 2025 14:34:28 +0000 (10:34 -0400)] 
cobol: Variety of small changes in answer to cppcheck diagnostics.

Remove non-ASCII input and blank lines from gcobol.1. Restrict
cobol.clean target to compiler object files.

gcc/cobol/ChangeLog:

* Make-lang.in: cobol.clean does not remove libgcobol files.
* cdf.y: Suppress 1 cppcheck false positive.
* cdfval.h (scanner_parsing):  Partial via cppcheck for PR119324.
* gcobol.1: Fix groff errors.
* gcobolspec.cc (append_arg): Const parameter.
* parse_ante.h (intrinsic_call_2): Avoid NULL dereference.

7 weeks agolibstdc++: Make __max_size_type and __max_diff_type structural
Patrick Palka [Tue, 10 Jun 2025 14:15:25 +0000 (10:15 -0400)] 
libstdc++: Make __max_size_type and __max_diff_type structural

This patch makes these integer-class types structural types by
public-izing their data members so that they could be used as NTTP
types.  I don't think this is required by the standard, but it seems
like a useful extension.

libstdc++-v3/ChangeLog:

* include/bits/max_size_type.h (__max_size_type::_M_val): Make
public instead of private.
(__max_size_type::_M_msb): Likewise.
(__max_diff_type::_M_rep): Likewise.
* testsuite/std/ranges/iota/max_size_type.cc: Verify
__max_diff_type and __max_size_type are structural.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
7 weeks agolibstdc++: Implement LWG3528 make_from_tuple can perform (the equivalent of) a C...
Yihan Wang [Mon, 9 Jun 2025 10:07:51 +0000 (11:07 +0100)] 
libstdc++: Implement LWG3528 make_from_tuple can perform (the equivalent of) a C-style cast

Implement LWG3528 to make std::make_from_tuple SFINAE friendly.

libstdc++-v3/ChangeLog:

* include/std/tuple (__can_make_from_tuple): New variable
template.
(__make_from_tuple_impl): Add static_assert.
(make_from_tuple): Constrain using __can_make_from_tuple.
* testsuite/20_util/tuple/dr3528.cc: New test.

Signed-off-by: Yihan Wang <yronglin777@gmail.com>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agogcn: Add experimental MI300 (gfx942) support
Tobias Burnus [Tue, 10 Jun 2025 13:12:47 +0000 (15:12 +0200)] 
gcn: Add experimental MI300 (gfx942) support

As gfx942 and gfx950 belong to gfx9-4-generic, the latter two are also added.
Note that there are no specific optimizations for MI300, yet.

For none of the mentioned devices, any multilib is build by default; use
'--with-multilib-list=' when configuring GCC to build them alongside.
gfx942 was added in LLVM (and its mc assembler, used by GCC) in version 18,
generic support in LLVM 19 and gfx950 in LLVM 20.

gcc/ChangeLog:

* config/gcn/gcn-devices.def: Add gfx942, gfx950 and gfx9-4-generic.
* config/gcn/gcn-opts.h (TARGET_CDNA3, TARGET_CDNA3_PLUS,
TARGET_GLC_NAME, TARGET_TARGET_SC_CACHE): Define.
(TARGET_ARCHITECTED_FLAT_SCRATCH): Use also for CDNA3.
* config/gcn/gcn.h (gcn_isa): Add ISA_CDNA3 to the enum.
* config/gcn/gcn.cc (print_operand): Update 'g' to use
TARGET_GLC_NAME; add 'G' to print TARGET_GLC_NAME unconditionally.
* config/gcn/gcn-valu.md (scatter, gather): Use TARGET_GLC_NAME.
* config/gcn/gcn.md: Use %G<num> instead of glc; use 'buffer_inv sc1'
for TARGET_TARGET_SC_CACHE.
* doc/invoke.texi (march): Add gfx942, gfx950 and gfx9-4-generic.
* doc/install.texi (amdgcn*-*-*): Add gfx942, gfx950 and gfx9-4-generic.
* config/gcn/gcn-tables.opt: Regenerate.

libgomp/ChangeLog:

* testsuite/libgomp.c/declare-variant-4.h (gfx942): New variant function.
* testsuite/libgomp.c/declare-variant-4-gfx942.c: New test.

7 weeks ago[RISC-V] Fix ICE due to splitter emitting constant loads directly
Jeff Law [Tue, 10 Jun 2025 12:38:52 +0000 (06:38 -0600)] 
[RISC-V] Fix ICE due to splitter emitting constant loads directly

This is a fix for a bug found internally in Ventana using the cf3 testsuite.

cf3 looks to be dead as a project and likely subsumed by modern fuzzers.  In
fact internally we tripped another issue with cf3 that had already been
reported by Edwin with the fuzzer he runs.

Anyway, the splitter in question blindly emits the 2nd adjusted constant into a
register, that's not valid if the constant requires any kind of synthesis --
and it well could since we're mostly focused on the first constant turning into
something that can be loaded via LUI without increasing the cost of the second
constant.

Instead of using the split RTL template, this just emits the code we want
directly, using riscv_move_insn to synthesize the constant into the provided
temporary register.

Tested in my system.  Waiting on upstream CI's verdict before moving forward.

gcc/
* config/riscv/riscv.md (lui-constraint<X:mode>and_to_or): Do not use
the RTL template for split code.  Emit it directly taking care to avoid
emitting a constant load that needed synthesis.  Fix formatting.

gcc/testsuite/
* gcc.target/riscv/ventana-16122.c: New test.

7 weeks agolibfortran: Add script to regenerate source files
Francois-Xavier Coudert [Mon, 9 Jun 2025 15:19:04 +0000 (17:19 +0200)] 
libfortran: Add script to regenerate source files

Move the regeneration of libgfortran source files from the Makefile
to a standalone script. We were previously highjacking the
maintainer mode of autoconf/automake in a way that was not adequate,
leading to various issues. Bring our behavior in line with other
GCC libraries.

2025-06-09  François-Xavier Coudert  <fxcoudert@gcc.gnu.org>

libgfortran/ChangeLog:

PR libfortran/116400
* Makefile.am: Remove source file regeneration rules.
* Makefile.in: Regenerate.
* regenerate.sh: New file.

7 weeks agoada: Generic formal objects have no entry components
Piotr Trojanek [Tue, 25 Mar 2025 15:15:39 +0000 (16:15 +0100)] 
ada: Generic formal objects have no entry components

AST field Entry_Component doesn't make sense for generic formal objects and was
never used there. Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* gen_il-gen-gen_entities.adb (Formal_Object_Kind): Remove
Entry_Component field.

7 weeks agoada: Remove redundant guard against attribute with no expressions
Piotr Trojanek [Wed, 26 Mar 2025 17:42:10 +0000 (18:42 +0100)] 
ada: Remove redundant guard against attribute with no expressions

We intentionally allow First to work on No_List, so there is no need to guard
against a No_List. Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* sem_attr.adb (Resolve_Attribute): Remove redundant guard.

7 weeks agoada: Minor comment tweak
Eric Botcazou [Thu, 27 Mar 2025 21:56:59 +0000 (22:56 +0100)] 
ada: Minor comment tweak

This replaces a couple of occurrences of "function" by "subprogram".

gcc/ada/ChangeLog:

* inline.adb (Analyze_Inlined_Bodies): Minor comment tweak.

7 weeks agoada: Small cleanup in instantiation of generic bodies
Eric Botcazou [Thu, 27 Mar 2025 12:27:46 +0000 (13:27 +0100)] 
ada: Small cleanup in instantiation of generic bodies

This removes the code dealing with generic main units from the body of the
instantiation routine, namely Instantiate_Bodies, and replaces it by tests
done earlier in the processing.

The test added to Need_Subprogram_Instance_Body is already present in the
twin predicate Needs_Body_Instantiated.

gcc/ada/ChangeLog:

* inline.adb (Instantiate_Body): Do not call Add_Scope_To_Clean if
the main unit is generic.
(Instantiate_Bodies): Do not deal with generic main units here.
* sem_ch12.adb (Need_Subprogram_Instance_Body): Return false if the
main unit is generic.

7 weeks agoada: Do not install the support files of 128-bit types on 32-bit targets
Eric Botcazou [Thu, 27 Mar 2025 15:16:46 +0000 (16:16 +0100)] 
ada: Do not install the support files of 128-bit types on 32-bit targets

The files are not compiled into libgnat.a but are nevertheless installed
in the adainclude directory, which is unwanted.

gcc/ada/ChangeLog:

* Makefile.rtl (ADA_EXCLUDE_SRCS): Add the 128-bit support files.

7 weeks agoada: Factorize some duplicate code
Ronan Desplanques [Thu, 27 Mar 2025 11:13:20 +0000 (12:13 +0100)] 
ada: Factorize some duplicate code

Process_Subtype can be passed either a subtype indication or a subtype
mark. Before this patch, it branched directly depending on the kind of
the argument, but there actually was processing common to the two
branches like resolving the subtype mark. This patch factorizes this
common processing out of the if statement.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Subtype): Factorize code.

7 weeks agoada: VAST found bug: Itypes with Parent
Bob Duff [Thu, 27 Mar 2025 10:14:33 +0000 (06:14 -0400)] 
ada: VAST found bug: Itypes with Parent

Fix the comment about Itypes, so the Parent field is no longer required.

Change VAST to no longer require it. Remove Check_Itype_Parents
from Check_Enum; it can no longer fail, so there's no point in
making it switchable.

gcc/ada/ChangeLog:

* einfo.ads (Associated_Node_For_Itype): Document that
Parent field may be empty.
* vast.adb:  Allow empty Parent in Itypes.

7 weeks agoada: Error on subtype with static predicate used in case_expression
Gary Dismukes [Sat, 22 Mar 2025 00:01:52 +0000 (00:01 +0000)] 
ada: Error on subtype with static predicate used in case_expression

The compiler improperly flags an error on the use of a subtype with a
static predicate as a choice in a case expression alternative, complaining
that the subtype has a nonstatic predicate. The fix for this is to add
a test for the subtype not having a static predicate.

gcc/ada/ChangeLog:

* einfo.ads: Revise comment about Dynamic_Predicate flag to make it
more accurate.
* sem_case.adb (Check_Choices): Test "not Has_Static_Predicate_Aspect"
as additional guard for error about use of subtype with nonstatic
predicate as a case choice. Improve related error message.

7 weeks agoada: Special case for inconsistent pointer in Scan_Raw_Unsigned
Tonu Naks [Tue, 25 Mar 2025 09:49:25 +0000 (09:49 +0000)] 
ada: Special case for inconsistent pointer in Scan_Raw_Unsigned

gcc/ada/ChangeLog:

* libgnat/s-valueu.adb: add explict raise
* libgnat/s-valueu.ads: update annotation

7 weeks agoada: Move Check_Discriminant_Conformance to Sem_Ch3
Ronan Desplanques [Tue, 25 Mar 2025 11:50:40 +0000 (12:50 +0100)] 
ada: Move Check_Discriminant_Conformance to Sem_Ch3

Check_Discriminant_Conformance is really only about concepts defined in
chapter 3 of the Ada reference manual, so it fits better in Sem_Ch3 than
in Sem_Ch6.

gcc/ada/ChangeLog:

* sem_ch6.adb, sem_ch6.ads (Check_Discriminant_Conformance): Move to …
* sem_ch3.adb (Check_Discriminant_Conformance): … here.

7 weeks agoada: Fix fallout of latest change
Eric Botcazou [Tue, 25 Mar 2025 23:37:22 +0000 (00:37 +0100)] 
ada: Fix fallout of latest change

Freeze_Static_Object needs to deal with the objects that have been created
by Insert_Conditional_Object_Declaration.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Static_Object): Do not issue any error message
for compiler-generated entities.

7 weeks agoada: VAST: treewalker improvements
Bob Duff [Tue, 25 Mar 2025 19:42:08 +0000 (15:42 -0400)] 
ada: VAST: treewalker improvements

Implement two basic checks: Check that N_Error nodes cannot appear in the
tree (because VAST is not called when the source is illegal).
Check that every node has a parent, except for certain nodes where
we check the opposite. (We do not yet check that the parent pointers
actually point to the right node.)

Minor improvements. Flags for controlling debugging outputs and the like.

Capability to enable/disable individual checks. The intent is to
implement that only when needed -- i.e. when VAST finds a bug, and we
have not yet fixed the bug.

gcc/ada/ChangeLog:

* vast.adb: Implement two checks. Improve debugging
outputs.

7 weeks agoada: Fix wrong initialization of library-level object by conditional expression
Eric Botcazou [Tue, 25 Mar 2025 17:23:50 +0000 (18:23 +0100)] 
ada: Fix wrong initialization of library-level object by conditional expression

The previous fix was not robust enough in the presence of transient scopes.

gcc/ada/ChangeLog:

* exp_ch4.adb (Insert_Conditional_Object_Declaration): Deal with a
transient scope being created around the declaration.
* freeze.adb (Freeze_Entity): Do not call Freeze_Static_Object for
a renaming declaration.

7 weeks agoada: Fix inconsistent comment for fixed-point Value attribute implementation
Eric Botcazou [Tue, 25 Mar 2025 17:35:10 +0000 (18:35 +0100)] 
ada: Fix inconsistent comment for fixed-point Value attribute implementation

The comment incorrectly mentions decimal fixed point.

gcc/ada/ChangeLog:

* libgnat/s-vafi32.ads: Fix head description.
* libgnat/s-vafi64.ads: Likewise.
* libgnat/s-vafi128.ads: Likewise.

7 weeks agoada: VAST: create treewalker
Bob Duff [Mon, 24 Mar 2025 20:21:53 +0000 (16:21 -0400)] 
ada: VAST: create treewalker

Walks all trees (not just the main unit), deals with switches and
flags. Doesn't check much of anything yet (asserts that "unused" nodes
are not present).

Move decisions (what tree(s) to check, what switches enable checking)
from the caller to the body of VAST.

gcc/ada/ChangeLog:

* vast.adb: Initial implementation.
* vast.ads: Rename procedure. Remove parameter; body should decide
what to do.
* lib.ads (ipu): Minor: Rewrite comment for brevity, and because
of an inconvenient misspelling.
(Num_Units): Not used; remove.
(Remove_Unit): Minor: Remove "Currently" (which was current a decade
ago from) comment.
* lib.adb (Num_Units): Not used; remove.
* debug_a.adb (Debug_A_Entry): Fix bug: Use Write_Name_For_Debug,
so this won't crash on the Error node.
* debug.adb: Document -gnatd_V and -gnatd_W compiler switches.
* exp_ch6.adb (Validate_Subprogram_Calls): Remove redundant check for
Serious_Errors_Detected. (We turn off code gen when errors are
detected.)
* frontend.adb: Move decisions into VAST body.
* namet.ads (Present): Remove unnecessary overriding; these are
inherited by the derived types.
* namet.adb (Present): Likewise.

7 weeks agoada: Storage_Error on Ordered_Maps container aggregate with enumeration Key_Type
Gary Dismukes [Fri, 21 Mar 2025 22:03:46 +0000 (22:03 +0000)] 
ada: Storage_Error on Ordered_Maps container aggregate with enumeration Key_Type

The compiler fails with a Storage_Error when compiling a container aggregate
for a Map type coming from an instantiation of Ada.Containers.Ordered_Maps
that specifies an enumeration type for the Key_Type formal.

gcc/ada/ChangeLog:

* exp_aggr.adb (Build_Container_Aggr_Code.To_Int): Apply Enumeration_Pos
to Entity (Expr) rather than Expr.

7 weeks agoada: Fix omission in comment
Ronan Desplanques [Mon, 24 Mar 2025 11:39:29 +0000 (12:39 +0100)] 
ada: Fix omission in comment

gcc/ada/ChangeLog:

* sem_ch3.adb (Find_Type_Of_Object): Fix comment.

7 weeks agoada: Rename constant in Analyze_Component_Declaration
Ronan Desplanques [Mon, 24 Mar 2025 11:19:07 +0000 (12:19 +0100)] 
ada: Rename constant in Analyze_Component_Declaration

"Typ" is typically used to name constants that are entity IDs for types.
Before this patch, a constant local to Analyze_Component_Declaration
designating a syntactic subtype indication had that name. This patch
renames it to "Ind".

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* sem_ch3.adb (Analyze_Component_Declaration): Rename constant.

7 weeks agoada: Simplify Constrain_Array
Ronan Desplanques [Fri, 21 Mar 2025 15:49:20 +0000 (16:49 +0100)] 
ada: Simplify Constrain_Array

Before this patch, Constrain_Array had a feature where it could be
passed Empty for the first actual and would then create an Itype itself.
There was only one use of this feature and it was unnecessary, so this
patch removes it.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Array): Simplify.
(Process_Subtype): Adjust.

7 weeks agoada: Fix infinite loop with aggregate in generic unit
Eric Botcazou [Thu, 20 Mar 2025 22:29:33 +0000 (23:29 +0100)] 
ada: Fix infinite loop with aggregate in generic unit

Root_Type does not return the same type for the private and the full view of
a derived private tagged type when both derive from an interface type.

gcc/ada/ChangeLog:

* sem_ch12.adb (Copy_Generic_Node): Do not call Root_Type to find
the root type of an aggregate of a derived tagged type.

7 weeks agoada: Fix use-after-free in Compute_All_Tasks
Ronan Desplanques [Tue, 18 Mar 2025 12:56:58 +0000 (13:56 +0100)] 
ada: Fix use-after-free in Compute_All_Tasks

This patch fixes a bug in System.Stack_Usage.Tasking.Compute_All_Tasks
where it would attempt to read the stack of threads that had already
completed.

gcc/ada/ChangeLog:

* libgnarl/s-stusta.adb (Compute_All_Tasks): Skip terminated tasks.

7 weeks agoada: Fix the detection of configuration pragmas
Viljar Indus [Wed, 19 Mar 2025 09:28:13 +0000 (11:28 +0200)] 
ada: Fix the detection of configuration pragmas

Some pragma nodes like the ones for Assertion_Policy are
replaced by a Null_Statement. This is not taken into account
when analyzing if the pragma is a configuration pragma.

gcc/ada/ChangeLog:

* sem_prag.adb (Is_Configuration_Pragma): Check that nodes
preceding the pragma are pragma nodes or originally were
pragma nodes.

7 weeks agoada: Fix Value_Decimal to raise Constraint_Error on boundary values
Eric Botcazou [Tue, 18 Mar 2025 21:44:15 +0000 (22:44 +0100)] 
ada: Fix Value_Decimal to raise Constraint_Error on boundary values

Even though the issue is not user-visible, it's a (minor) departure from the
specification of the procedure.

gcc/ada/ChangeLog:

* libgnat/s-valued.adb (Integer_to_Decimal): Add Extra parameter and
use its value to call Bad_Value on boundary values.
(Scan_Decimal): Adjust call to Integer_to_Decimal.
(Value_Decimal): Likewise.

7 weeks agoada: Add Incomplete_Type_OK formal to Process_Subtype
Ronan Desplanques [Tue, 18 Mar 2025 17:02:29 +0000 (18:02 +0100)] 
ada: Add Incomplete_Type_OK formal to Process_Subtype

Before this patch, Process_Subtype looked at the parent of its argument
to determine whether it was called in a context where it was OK for the
subtype mark to refer to the incomplete view of a type. This patch adds
a new formal so that it becomes the responsibility of the caller in
order to make the code simpler overall.

The only change in the behavior of the compiler is that the messages
emitted in some error situations with the -gnatf switch are slightly
different.

gcc/ada/ChangeLog:

* sem_ch3.ads (Process_Subtype): New formal.
* sem_ch3.adb (Process_Subtype): Likewise.
(Analyze_Subtype_Declaration, Access_Type_Declaration): Use new
formal.

7 weeks agoada: Fix recursive call in Process_Subtype
Ronan Desplanques [Tue, 18 Mar 2025 07:53:35 +0000 (08:53 +0100)] 
ada: Fix recursive call in Process_Subtype

Process_Subtype calls itself in some error situations. This recursive
call was not updated together with the recent addition of the
Excludes_Null formal. This does not matter in practice because there can
never be both a null exclusion and another constraint at the same time,
but this patch updates the call anyway to make the situation clearer.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Subtype): Fix recursive call.

7 weeks agoada: Rename a couple of local variables
Eric Botcazou [Tue, 18 Mar 2025 10:36:35 +0000 (11:36 +0100)] 
ada: Rename a couple of local variables

Block_Node is the name of an entity field, so the change renames local
variables with this name for the sake of clarity.

gcc/ada/ChangeLog:

* par-ch5.adb (P_Declare_Statement): Rename local variable.
(P_Begin_Statement): Likewise.

7 weeks agoada: Remove outdated comment about reused entity fields
Piotr Trojanek [Tue, 18 Mar 2025 09:41:43 +0000 (10:41 +0100)] 
ada: Remove outdated comment about reused entity fields

With the current representation of GNAT AST the entity fields are not reused.

gcc/ada/ChangeLog:

* einfo.ads (Overridden_Operation, Static_Initialization): Remove
comments about a reused entity field.

7 weeks agoada: Tweak formatting in Process_Subtype
Ronan Desplanques [Mon, 17 Mar 2025 16:21:45 +0000 (17:21 +0100)] 
ada: Tweak formatting in Process_Subtype

This patch removes parentheses and vertical alignment that misleadingly
suggested the presence of function calls where there weren't any.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Subtype): Tweak formatting.

7 weeks agoada: Add assertion on expanded code in particular case
Ronan Desplanques [Mon, 17 Mar 2025 16:18:26 +0000 (17:18 +0100)] 
ada: Add assertion on expanded code in particular case

This patch adds an assertion that checks that expanded code does not
contain erroneous access subtype definitions.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Subtype): Add assertion.

7 weeks agoada: Factorize initialization of local variable
Ronan Desplanques [Mon, 17 Mar 2025 16:15:29 +0000 (17:15 +0100)] 
ada: Factorize initialization of local variable

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Subtype): Factorize initialization of variable.