diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2025-06-17 11:44:30 +0200 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2025-06-17 11:44:30 +0200 |
commit | 2ed152968611a87c80a510ac7ceb24ab53ccc4be (patch) | |
tree | 00c47257dd568cb2ddcbcd26d0c32042dbdf6047 | |
parent | a6a5a2674c5c7f2ae64277c7f79a3b8c20a87fc6 (diff) | |
parent | 9803e23a212962217dc3b076435da4dc4839fe2d (diff) | |
download | gcc-2ed152968611a87c80a510ac7ceb24ab53ccc4be.zip gcc-2ed152968611a87c80a510ac7ceb24ab53ccc4be.tar.gz gcc-2ed152968611a87c80a510ac7ceb24ab53ccc4be.tar.bz2 |
Merge branch 'releases/gcc-15' into devel/omp/gcc-15
Merge up to r15-9840-g9803e23a212962 (June 17, 2025)
32 files changed, 974 insertions, 470 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e4f3f94..99eef0d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,65 @@ +2025-06-14 Georg-Johann Lay <avr@gjlay.de> + + PR rtl-optimization/120423 + PR rtl-optimization/116389 + * config/avr/avr.md [-mno-lra]: Add pre-reload split to transform + (left shift of) a paradoxical subreg to a (left shift of) zero-extend. + +2025-06-13 Jakub Jelinek <jakub@redhat.com> + + Backported from master: + 2025-06-12 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/120638 + * tree-ssa-math-opts.cc (pass_cse_reciprocals::execute): Call + reset_flow_sensitive_info on arg1. + +2025-06-13 Jakub Jelinek <jakub@redhat.com> + + Backported from master: + 2025-06-05 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/120547 + * real.cc (real_from_integer): Remove maxbitlen variable, use + len instead of that. When shifting right, or in 1 if any of the + shifted away bits are non-zero. Formatting fix. + +2025-06-13 Jakub Jelinek <jakub@redhat.com> + + Backported from master: + 2025-05-20 Jakub Jelinek <jakub@redhat.com> + + * tree-chrec.cc (convert_affine_scev): Use signed_type_for instead of + build_nonstandard_integer_type. + +2025-06-12 Martin Jambor <mjambor@suse.cz> + + Backported from master: + 2025-05-29 Martin Jambor <mjambor@suse.cz> + + PR ipa/120295 + * ipa-prop.cc (update_jump_functions_after_inlining): Do not + combine pass-through jump functions with type-casts changing + signedness. + +2025-06-10 Andrew Pinski <quic_apinski@quicinc.com> + + Backported from master: + 2025-04-30 Andrew Pinski <quic_apinski@quicinc.com> + + PR target/120042 + * tree-vectorizer.h: Include dominance.h. + +2025-06-10 Xi Ruoyao <xry111@xry111.site> + + Backported from master: + 2025-06-04 Xi Ruoyao <xry111@xry111.site> + + PR rtl-optimization/120050 + * ext-dce.cc (ext_dce_process_uses): Break early if a SUBREG in + rhs is promoted and the truncation from the inner mode to the + outer mode is not a noop when handling SETs. + 2025-06-06 Tobias Burnus <tburnus@baylibre.com> Backported from master: diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 52988ae..aaa22e3 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20250610 +20250617 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index b275a5c..aee2253 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,69 @@ +2025-06-12 Eric Botcazou <ebotcazou@adacore.com> + + * doc/gnat_rm/gnat_language_extensions.rst + (Generalized Finalization): Document the actual implementation. + (No_Raise): Move to separate section. + * gnat_rm.texi: Regenerate. + +2025-06-12 Ronan Desplanques <desplanques@adacore.com> + + * sem_ch3.adb (Build_Derived_Private_Type): Fix test. + (Build_Derived_Record_Type): Adjust error recovery paths. + +2025-06-12 Ronan Desplanques <desplanques@adacore.com> + + * exp_util.adb (Insert_Actions): Refine test. + +2025-06-12 Eric Botcazou <ebotcazou@adacore.com> + + * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler + switches) <-O>: Fix long line. + * gnat_ugn.texi: Regenerate. + +2025-06-12 Eric Botcazou <ebotcazou@adacore.com> + + * 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. + +2025-06-10 Gary Dismukes <dismukes@adacore.com> + + * 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. + +2025-06-10 Eric Botcazou <ebotcazou@adacore.com> + + * freeze.adb (Freeze_Static_Object): Do not issue any error message + for compiler-generated entities. + +2025-06-10 Eric Botcazou <ebotcazou@adacore.com> + + * 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. + +2025-06-10 Gary Dismukes <dismukes@adacore.com> + + * exp_aggr.adb (Build_Container_Aggr_Code.To_Int): Apply Enumeration_Pos + to Entity (Expr) rather than Expr. + +2025-06-10 Eric Botcazou <ebotcazou@adacore.com> + + * sem_ch12.adb (Copy_Generic_Node): Do not call Root_Type to find + the root type of an aggregate of a derived tagged type. + +2025-06-10 Ronan Desplanques <desplanques@adacore.com> + + * libgnarl/s-stusta.adb (Compute_All_Tasks): Skip terminated tasks. + 2025-06-09 Gary Dismukes <dismukes@adacore.com> * sem_ch3.adb (Constrain_Index): In the case of a fixed-lower-bound index, diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst index ee2df66..45d7a66 100644 --- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst +++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst @@ -1453,97 +1453,60 @@ that the record type must be a root type, in other words not a derived type. The aspect additionally makes it possible to specify relaxed semantics for the finalization operations by means of the ``Relaxed_Finalization`` setting. - -Example: +Here is the archetypal example: .. code-block:: ada - type Ctrl is record - Id : Natural := 0; + type T is record + ... end record with Finalizable => (Initialize => Initialize, Adjust => Adjust, Finalize => Finalize, Relaxed_Finalization => True); - procedure Adjust (Obj : in out Ctrl); - procedure Finalize (Obj : in out Ctrl); - procedure Initialize (Obj : in out Ctrl); - -The three procedures have the same profile, taking a single ``in out T`` -parameter. + procedure Adjust (Obj : in out T); + procedure Finalize (Obj : in out T); + procedure Initialize (Obj : in out T); -We follow the same dynamic semantics as controlled objects: +The three procedures have the same profile, with a single ``in out`` parameter, +and also have the same dynamic semantics as for controlled types: - ``Initialize`` is called when an object of type ``T`` is declared without - default expression. + initialization expression. - ``Adjust`` is called after an object of type ``T`` is assigned a new value. - ``Finalize`` is called when an object of type ``T`` goes out of scope (for - stack-allocated objects) or is explicitly deallocated (for heap-allocated - objects). It is also called when on the value being replaced in an - assignment. - -However the following differences are enforced by default when compared to the -current Ada controlled-objects finalization model: - -* No automatic finalization of heap allocated objects: ``Finalize`` is only - called when an object is implicitly deallocated. As a consequence, no-runtime - support is needed for the implicit case, and no header will be maintained for - this in heap-allocated controlled objects. - - Heap-allocated objects allocated through a nested access type definition will - hence **not** be deallocated either. The result is simply that memory will be - leaked in those cases. - -* The ``Finalize`` procedure should have have the :ref:`No_Raise_Aspect` specified. - If that's not the case, a compilation error will be raised. - -Additionally, two other configuration aspects are added, -``Legacy_Heap_Finalization`` and ``Exceptions_In_Finalize``: - -* ``Legacy_Heap_Finalization``: Uses the legacy automatic finalization of - heap-allocated objects - -* ``Exceptions_In_Finalize``: Allow users to have a finalizer that raises exceptions - **NB!** note that using this aspect introduces execution time penalities. - -.. _No_Raise_Aspect: - -No_Raise aspect ----------------- + stack-allocated objects) or is deallocated (for heap-allocated objects). + It is also called when the value is replaced by an assignment. -The ``No_Raise`` aspect can be applied to a subprogram to declare that this subprogram is not -expected to raise any exceptions. Should an exception still occur during the execution of -this subprogram, ``Program_Error`` is raised. +However, when ``Relaxed_Finalization`` is either ``True`` or not explicitly +specified, the following differences are implemented relative to the semantics +of controlled types: -New specification for ``Ada.Finalization.Controlled`` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +* The compiler has permission to perform no automatic finalization of + heap-allocated objects: ``Finalize`` is only called when such an object + is explicitly deallocated, or when the designated object is assigned a new + value. As a consequence, no runtime support is needed for performing + implicit deallocation. In particular, no per-object header data is needed + for heap-allocated objects. -``Ada.Finalization.Controlled`` is now specified as: - -.. code-block:: ada - - type Controlled is abstract tagged null record - with Initialize => Initialize, - Adjust => Adjust, - Finalize => Finalize, - Legacy_Heap_Finalization, Exceptions_In_Finalize; - - procedure Initialize (Self : in out Controlled) is abstract; - procedure Adjust (Self : in out Controlled) is abstract; - procedure Finalize (Self : in out Controlled) is abstract; + Heap-allocated objects allocated through a nested access type will therefore + **not** be deallocated either. The result is simply that memory will be leaked + in this case. +* The ``Adjust`` and ``Finalize`` procedures are automatically considered as + having the :ref:`No_Raise_Aspect` specified for them. In particular, the + compiler has permission to enforce none of the guarantees specified by the + RM 7.6.1 (14/1) and subsequent subclauses. -### Examples - -A simple example of a ref-counted type: +Simple example of ref-counted type: .. code-block:: ada type T is record - Value : Integer; + Value : Integer; Ref_Count : Natural := 0; end record; @@ -1555,8 +1518,8 @@ A simple example of a ref-counted type: type T_Ref is record Value : T_Access; end record - with Adjust => Adjust, - Finalize => Finalize; + with Finalizable => (Adjust => Adjust, + Finalize => Finalize); procedure Adjust (Ref : in out T_Ref) is begin @@ -1568,8 +1531,7 @@ A simple example of a ref-counted type: Def_Ref (Ref.Value); end Finalize; - -A simple file handle that ensures resources are properly released: +Simple file handle that ensures resources are properly released: .. code-block:: ada @@ -1579,51 +1541,47 @@ A simple file handle that ensures resources are properly released: function Open (Path : String) return File; procedure Close (F : in out File); + private type File is limited record Handle : ...; end record - with Finalize => Close; - - -Finalized tagged types -^^^^^^^^^^^^^^^^^^^^^^^ + with Finalizable (Finalize => Close); + end P; -Aspects are inherited by derived types and optionally overriden by those. The -compiler-generated calls to the user-defined operations are then -dispatching whenever it makes sense, i.e. the object in question is of -class-wide type and the class includes at least one finalized tagged type. +Finalizable tagged types +^^^^^^^^^^^^^^^^^^^^^^^^ -However note that for simplicity, it is forbidden to change the value of any of -those new aspects in derived types. +The aspect is inherited by derived types and the primitives may be overridden +by the derivation. The compiler-generated calls to these operations are then +dispatching whenever it makes sense, i.e. when the object in question is of a +class-wide type and the class includes at least one finalizable tagged type. Composite types ^^^^^^^^^^^^^^^ -When a finalized type is used as a component of a composite type, the latter -becomes finalized as well. The three primitives are derived automatically -in order to call the primitives of their components. - -If that composite type was already user-finalized, then the compiler -calls the primitives of the components so as to stay consistent with today's -controlled types's behavior. - -So, ``Initialize`` and ``Adjust`` are called on components before they -are called on the composite object, but ``Finalize`` is called on the composite -object first. +When a finalizable type is used as a component of a composite type, the latter +becomes finalizable as well. The three primitives are derived automatically +in order to call the primitives of their components. The dynamic semantics is +the same as for controlled components of composite types. Interoperability with controlled types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -As a consequence of the redefinition of the ``Controlled`` type as a base type -with the new aspects defined, interoperability with controlled type naturally -follows the definition of the above rules. In particular: +Finalizable types are fully interoperable with controlled types, in particular +it is possible for a finalizable type to have a controlled component and vice +versa, but the stricter dynamic semantics, in other words that of controlled +types, is applied in this case. -* It is possible to have a new finalized type have a controlled type - component -* It is possible to have a controlled type have a finalized type - component +.. _No_Raise_Aspect: + +No_Raise aspect +---------------- +The ``No_Raise`` aspect can be applied to a subprogram to declare that this +subprogram is not expected to raise an exception. Should an exception still +be raised during the execution of the subprogram, it is caught at the end of +this execution and ``Program_Error`` is propagated to the caller. Inference of Dependent Types in Generic Instantiations ------------------------------------------------------ diff --git a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst index 4f46fba..4bdd213 100644 --- a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst +++ b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst @@ -2259,15 +2259,16 @@ Alphabetical List of All Switches ======= ================================================================== *n* Effect ------- ------------------------------------------------------------------ - *0* No optimization, the default setting if no :switch:`-O` appears - *1* Normal optimization, the default if you specify :switch:`-O` without an - operand. A good compromise between code quality and compilation - time. - *2* Extensive optimization, may improve execution time, possibly at + *0* No optimization, the default setting if no :switch:`-O` appears. + *1* Moderate optimization, same as :switch:`-O` without an operand. + A good compromise between code quality and compilation time. + *2* Extensive optimization, should improve execution time, possibly at the cost of substantially increased compilation time. - *3* Same as :switch:`-O2`, and also includes inline expansion for small - subprograms in the same unit. - *s* Optimize space usage + *3* Full optimization, may further improve execution time, possibly at + the cost of substantially larger generated code. + *s* Optimize for size (code and data) rather than speed. + *z* Optimize aggressively for size (code and data) rather than speed. + *g* Optimize for debugging experience rather than speed. ======= ================================================================== See also :ref:`Optimization_Levels`. diff --git a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst index 756bc74..4ecb3cf 100644 --- a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst +++ b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst @@ -1584,18 +1584,16 @@ Turning on optimization makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly the ability to debug the program. -If you use multiple :switch:`-O` switches, with or without level -numbers, the last such switch is the one that's used. - -You can use the -:switch:`-O` switch (the permitted forms are :switch:`-O0`, :switch:`-O1` -:switch:`-O2`, :switch:`-O3`, and :switch:`-Os`) -to ``gcc`` to control the optimization level: +You can pass the :switch:`-O` switch, with or without an operand +(the permitted forms with an operand are :switch:`-O0`, :switch:`-O1`, +:switch:`-O2`, :switch:`-O3`, :switch:`-Os`, :switch:`-Oz`, and +:switch:`-Og`) to ``gcc`` to control the optimization level. If you +pass multiple :switch:`-O` switches, with or without an operand, +the last such switch is the one that's used: * :switch:`-O0` - No optimization (the default); - generates unoptimized code but has + No optimization (the default); generates unoptimized code but has the fastest compilation time. Debugging is easiest with this switch. Note that many other compilers do substantial optimization even if @@ -1606,32 +1604,45 @@ to ``gcc`` to control the optimization level: mind when doing performance comparisons. * :switch:`-O1` - Moderate optimization; optimizes reasonably well but does not - degrade compilation time significantly. You may not be able to see - some variables in the debugger and changing the value of some - variables in the debugger may not have the effect you desire. + Moderate optimization (same as :switch:`-O` without an operand); + optimizes reasonably well but does not degrade compilation time + significantly. You may not be able to see some variables in the + debugger, and changing the value of some variables in the debugger + may not have the effect you desire. * :switch:`-O2` - Full optimization; - generates highly optimized code and has - the slowest compilation time. You may see significant impacts on + Extensive optimization; generates highly optimized code but has + an increased compilation time. You may see significant impacts on your ability to display and modify variables in the debugger. * :switch:`-O3` - Full optimization as in :switch:`-O2`; - also uses more aggressive automatic inlining of subprograms within a unit - (:ref:`Inlining_of_Subprograms`) and attempts to vectorize loops. - + Full optimization; attempts more sophisticated transformations, in + particular on loops, possibly at the cost of larger generated code. + You may be hardly able to use the debugger at this optimization level. * :switch:`-Os` - Optimize space usage (code and data) of resulting program. + Optimize for size (code and data) of resulting binary rather than + speed; based on the :switch:`-O2` optimization level, but disables + some of its transformations that often increase code size, as well + as performs further optimizations designed to reduce code size. + +* :switch:`-Oz` + Optimize aggressively for size (code and data) of resulting binary + rather than speed; may increase the number of instructions executed + if these instructions require fewer bytes to be encoded. + +* :switch:`-Og` + Optimize for debugging experience rather than speed; based on the + :switch:`-O1` optimization level, but attempts to eliminate all the + negative effects of optimization on debugging. + Higher optimization levels perform more global transformations on the program and apply more expensive analysis algorithms in order to generate faster and more compact code. The price in compilation time, and the -resulting improvement in execution time, -both depend on the particular application and the hardware environment. -You should experiment to find the best level for your application. +resulting improvement in execution time, both depend on the particular +application and the hardware environment. You should experiment to find +the best level for your application. Since the precise set of optimizations done at each level will vary from release to release (and sometime from target to target), it is best to think diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 44e26d1..5fc4ed8 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -8223,19 +8223,31 @@ package body Exp_Util is return; end if; - -- the expansion of Task and protected type declarations can + -- The expansion of task and protected type declarations can -- create declarations for temporaries which, like other actions - -- are inserted and analyzed before the current declaraation. - -- However, the current scope is the synchronized type, and - -- for unnesting it is critical that the proper scope for these - -- generated entities be the enclosing one. + -- are inserted and analyzed before the current declaration. + -- However, in some cases, the current scope is the synchronized + -- type, and for unnesting it is critical that the proper scope + -- for these generated entities be the enclosing one. when N_Task_Type_Declaration | N_Protected_Type_Declaration => - Push_Scope (Scope (Current_Scope)); - Insert_List_Before_And_Analyze (P, Ins_Actions); - Pop_Scope; + declare + Skip_Scope : constant Boolean := + Ekind (Current_Scope) in Concurrent_Kind; + begin + if Skip_Scope then + Push_Scope (Scope (Current_Scope)); + end if; + + Insert_List_Before_And_Analyze (P, Ins_Actions); + + if Skip_Scope then + Pop_Scope; + end if; + end; + return; -- A special case, N_Raise_xxx_Error can act either as a statement diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 54830b8..e38e3d6 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -939,10 +939,9 @@ Simpler Accessibility Model * Subprogram parameters:: * Function results:: -No_Raise aspect +Generalized Finalization -* New specification for Ada.Finalization.Controlled: New specification for Ada Finalization Controlled. -* Finalized tagged types:: +* Finalizable tagged types:: * Composite types:: * Interoperability with controlled types:: @@ -30867,27 +30866,24 @@ that the record type must be a root type, in other words not a derived type. The aspect additionally makes it possible to specify relaxed semantics for the finalization operations by means of the @code{Relaxed_Finalization} setting. - -Example: +Here is the archetypal example: @example -type Ctrl is record - Id : Natural := 0; +type T is record + ... end record with Finalizable => (Initialize => Initialize, Adjust => Adjust, Finalize => Finalize, Relaxed_Finalization => True); -procedure Adjust (Obj : in out Ctrl); -procedure Finalize (Obj : in out Ctrl); -procedure Initialize (Obj : in out Ctrl); +procedure Adjust (Obj : in out T); +procedure Finalize (Obj : in out T); +procedure Initialize (Obj : in out T); @end example -The three procedures have the same profile, taking a single @code{in out T} -parameter. - -We follow the same dynamic semantics as controlled objects: +The three procedures have the same profile, with a single @code{in out} parameter, +and also have the same dynamic semantics as for controlled types: @quotation @@ -30896,98 +30892,49 @@ We follow the same dynamic semantics as controlled objects: @item @code{Initialize} is called when an object of type @code{T} is declared without -default expression. +initialization expression. @item @code{Adjust} is called after an object of type @code{T} is assigned a new value. @item @code{Finalize} is called when an object of type @code{T} goes out of scope (for -stack-allocated objects) or is explicitly deallocated (for heap-allocated -objects). It is also called when on the value being replaced in an -assignment. +stack-allocated objects) or is deallocated (for heap-allocated objects). +It is also called when the value is replaced by an assignment. @end itemize @end quotation -However the following differences are enforced by default when compared to the -current Ada controlled-objects finalization model: +However, when @code{Relaxed_Finalization} is either @code{True} or not explicitly +specified, the following differences are implemented relative to the semantics +of controlled types: @itemize * @item -No automatic finalization of heap allocated objects: @code{Finalize} is only -called when an object is implicitly deallocated. As a consequence, no-runtime -support is needed for the implicit case, and no header will be maintained for -this in heap-allocated controlled objects. +The compiler has permission to perform no automatic finalization of +heap-allocated objects: @code{Finalize} is only called when such an object +is explicitly deallocated, or when the designated object is assigned a new +value. As a consequence, no runtime support is needed for performing +implicit deallocation. In particular, no per-object header data is needed +for heap-allocated objects. -Heap-allocated objects allocated through a nested access type definition will -hence `not' be deallocated either. The result is simply that memory will be -leaked in those cases. +Heap-allocated objects allocated through a nested access type will therefore +`not' be deallocated either. The result is simply that memory will be leaked +in this case. @item -The @code{Finalize} procedure should have have the @ref{462,,No_Raise aspect} specified. -If that’s not the case, a compilation error will be raised. +The @code{Adjust} and @code{Finalize} procedures are automatically considered as +having the @ref{466,,No_Raise aspect} specified for them. In particular, the +compiler has permission to enforce none of the guarantees specified by the +RM 7.6.1 (14/1) and subsequent subclauses. @end itemize -Additionally, two other configuration aspects are added, -@code{Legacy_Heap_Finalization} and @code{Exceptions_In_Finalize}: - - -@itemize * - -@item -@code{Legacy_Heap_Finalization}: Uses the legacy automatic finalization of -heap-allocated objects - -@item -@code{Exceptions_In_Finalize}: Allow users to have a finalizer that raises exceptions -`NB!' note that using this aspect introduces execution time penalities. -@end itemize - -@node No_Raise aspect,Inference of Dependent Types in Generic Instantiations,Generalized Finalization,Experimental Language Extensions -@anchor{gnat_rm/gnat_language_extensions id3}@anchor{463}@anchor{gnat_rm/gnat_language_extensions no-raise-aspect}@anchor{462} -@subsection No_Raise aspect - - -The @code{No_Raise} aspect can be applied to a subprogram to declare that this subprogram is not -expected to raise any exceptions. Should an exception still occur during the execution of -this subprogram, @code{Program_Error} is raised. - -@menu -* New specification for Ada.Finalization.Controlled: New specification for Ada Finalization Controlled. -* Finalized tagged types:: -* Composite types:: -* Interoperability with controlled types:: - -@end menu - -@node New specification for Ada Finalization Controlled,Finalized tagged types,,No_Raise aspect -@anchor{gnat_rm/gnat_language_extensions new-specification-for-ada-finalization-controlled}@anchor{464} -@subsubsection New specification for @code{Ada.Finalization.Controlled} - - -@code{Ada.Finalization.Controlled} is now specified as: - -@example -type Controlled is abstract tagged null record - with Initialize => Initialize, - Adjust => Adjust, - Finalize => Finalize, - Legacy_Heap_Finalization, Exceptions_In_Finalize; - - procedure Initialize (Self : in out Controlled) is abstract; - procedure Adjust (Self : in out Controlled) is abstract; - procedure Finalize (Self : in out Controlled) is abstract; -@end example - -### Examples - -A simple example of a ref-counted type: +Simple example of ref-counted type: @example type T is record - Value : Integer; + Value : Integer; Ref_Count : Natural := 0; end record; @@ -30999,8 +30946,8 @@ type T_Access is access all T; type T_Ref is record Value : T_Access; end record - with Adjust => Adjust, - Finalize => Finalize; + with Finalizable => (Adjust => Adjust, + Finalize => Finalize); procedure Adjust (Ref : in out T_Ref) is begin @@ -31013,7 +30960,7 @@ begin end Finalize; @end example -A simple file handle that ensures resources are properly released: +Simple file handle that ensures resources are properly released: @example package P is @@ -31022,66 +30969,64 @@ package P is function Open (Path : String) return File; procedure Close (F : in out File); + private type File is limited record Handle : ...; end record - with Finalize => Close; + with Finalizable (Finalize => Close); +end P; @end example -@node Finalized tagged types,Composite types,New specification for Ada Finalization Controlled,No_Raise aspect -@anchor{gnat_rm/gnat_language_extensions finalized-tagged-types}@anchor{465} -@subsubsection Finalized tagged types - +@menu +* Finalizable tagged types:: +* Composite types:: +* Interoperability with controlled types:: -Aspects are inherited by derived types and optionally overriden by those. The -compiler-generated calls to the user-defined operations are then -dispatching whenever it makes sense, i.e. the object in question is of -class-wide type and the class includes at least one finalized tagged type. +@end menu -However note that for simplicity, it is forbidden to change the value of any of -those new aspects in derived types. +@node Finalizable tagged types,Composite types,,Generalized Finalization +@anchor{gnat_rm/gnat_language_extensions finalizable-tagged-types}@anchor{463} +@subsubsection Finalizable tagged types -@node Composite types,Interoperability with controlled types,Finalized tagged types,No_Raise aspect -@anchor{gnat_rm/gnat_language_extensions composite-types}@anchor{466} -@subsubsection Composite types +The aspect is inherited by derived types and the primitives may be overridden +by the derivation. The compiler-generated calls to these operations are then +dispatching whenever it makes sense, i.e. when the object in question is of a +class-wide type and the class includes at least one finalizable tagged type. -When a finalized type is used as a component of a composite type, the latter -becomes finalized as well. The three primitives are derived automatically -in order to call the primitives of their components. +@node Composite types,Interoperability with controlled types,Finalizable tagged types,Generalized Finalization +@anchor{gnat_rm/gnat_language_extensions composite-types}@anchor{464} +@subsubsection Composite types -If that composite type was already user-finalized, then the compiler -calls the primitives of the components so as to stay consistent with today’s -controlled types’s behavior. -So, @code{Initialize} and @code{Adjust} are called on components before they -are called on the composite object, but @code{Finalize} is called on the composite -object first. +When a finalizable type is used as a component of a composite type, the latter +becomes finalizable as well. The three primitives are derived automatically +in order to call the primitives of their components. The dynamic semantics is +the same as for controlled components of composite types. -@node Interoperability with controlled types,,Composite types,No_Raise aspect -@anchor{gnat_rm/gnat_language_extensions interoperability-with-controlled-types}@anchor{467} +@node Interoperability with controlled types,,Composite types,Generalized Finalization +@anchor{gnat_rm/gnat_language_extensions interoperability-with-controlled-types}@anchor{465} @subsubsection Interoperability with controlled types -As a consequence of the redefinition of the @code{Controlled} type as a base type -with the new aspects defined, interoperability with controlled type naturally -follows the definition of the above rules. In particular: - +Finalizable types are fully interoperable with controlled types, in particular +it is possible for a finalizable type to have a controlled component and vice +versa, but the stricter dynamic semantics, in other words that of controlled +types, is applied in this case. -@itemize * +@node No_Raise aspect,Inference of Dependent Types in Generic Instantiations,Generalized Finalization,Experimental Language Extensions +@anchor{gnat_rm/gnat_language_extensions no-raise-aspect}@anchor{466} +@subsection No_Raise aspect -@item -It is possible to have a new finalized type have a controlled type -component -@item -It is possible to have a controlled type have a finalized type -component -@end itemize +The @code{No_Raise} aspect can be applied to a subprogram to declare that this +subprogram is not expected to raise an exception. Should an exception still +be raised during the execution of the subprogram, it is caught at the end of +this execution and @code{Program_Error} is propagated to the caller. @node Inference of Dependent Types in Generic Instantiations,External_Initialization Aspect,No_Raise aspect,Experimental Language Extensions -@anchor{gnat_rm/gnat_language_extensions inference-of-dependent-types-in-generic-instantiations}@anchor{468} +@anchor{gnat_rm/gnat_language_extensions inference-of-dependent-types-in-generic-instantiations}@anchor{467} @subsection Inference of Dependent Types in Generic Instantiations @@ -31158,7 +31103,7 @@ package Int_Array_Operations is new Array_Operations @end example @node External_Initialization Aspect,Finally construct,Inference of Dependent Types in Generic Instantiations,Experimental Language Extensions -@anchor{gnat_rm/gnat_language_extensions external-initialization-aspect}@anchor{469} +@anchor{gnat_rm/gnat_language_extensions external-initialization-aspect}@anchor{468} @subsection External_Initialization Aspect @@ -31199,7 +31144,7 @@ The maximum size of loaded files is limited to 2@w{^31} bytes. @end cartouche @node Finally construct,,External_Initialization Aspect,Experimental Language Extensions -@anchor{gnat_rm/gnat_language_extensions finally-construct}@anchor{46a} +@anchor{gnat_rm/gnat_language_extensions finally-construct} @subsection Finally construct @@ -31216,7 +31161,7 @@ This feature is similar to the one with the same name in other languages such as @end menu @node Syntax<2>,Legality Rules<2>,,Finally construct -@anchor{gnat_rm/gnat_language_extensions id4}@anchor{46b} +@anchor{gnat_rm/gnat_language_extensions id4}@anchor{46a} @subsubsection Syntax @@ -31231,7 +31176,7 @@ handled_sequence_of_statements ::= @end example @node Legality Rules<2>,Dynamic Semantics<2>,Syntax<2>,Finally construct -@anchor{gnat_rm/gnat_language_extensions id5}@anchor{46c} +@anchor{gnat_rm/gnat_language_extensions id5}@anchor{46b} @subsubsection Legality Rules @@ -31241,7 +31186,7 @@ to be transferred outside the finally part are forbidden. Goto & exit where the target is outside of the finally’s @code{sequence_of_statements} are forbidden @node Dynamic Semantics<2>,,Legality Rules<2>,Finally construct -@anchor{gnat_rm/gnat_language_extensions id6}@anchor{46d} +@anchor{gnat_rm/gnat_language_extensions id6}@anchor{46c} @subsubsection Dynamic Semantics @@ -31256,7 +31201,7 @@ execution, that is the finally block must be executed in full even if the contai aborted, or if the control is transferred out of the block. @node Security Hardening Features,Obsolescent Features,GNAT language extensions,Top -@anchor{gnat_rm/security_hardening_features doc}@anchor{46e}@anchor{gnat_rm/security_hardening_features id1}@anchor{46f}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15} +@anchor{gnat_rm/security_hardening_features doc}@anchor{46d}@anchor{gnat_rm/security_hardening_features id1}@anchor{46e}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15} @chapter Security Hardening Features @@ -31278,7 +31223,7 @@ change. @end menu @node Register Scrubbing,Stack Scrubbing,,Security Hardening Features -@anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{470} +@anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{469} @section Register Scrubbing @@ -31314,7 +31259,7 @@ programming languages, see @cite{Using the GNU Compiler Collection (GCC)}. @c Stack Scrubbing: @node Stack Scrubbing,Hardened Conditionals,Register Scrubbing,Security Hardening Features -@anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{471} +@anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{470} @section Stack Scrubbing @@ -31458,7 +31403,7 @@ Bar_Callable_Ptr. @c Hardened Conditionals: @node Hardened Conditionals,Hardened Booleans,Stack Scrubbing,Security Hardening Features -@anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{472} +@anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{471} @section Hardened Conditionals @@ -31548,7 +31493,7 @@ be used with other programming languages supported by GCC. @c Hardened Booleans: @node Hardened Booleans,Control Flow Redundancy,Hardened Conditionals,Security Hardening Features -@anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{473} +@anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{472} @section Hardened Booleans @@ -31609,7 +31554,7 @@ and more details on that attribute, see @cite{Using the GNU Compiler Collection @c Control Flow Redundancy: @node Control Flow Redundancy,,Hardened Booleans,Security Hardening Features -@anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{474} +@anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{473} @section Control Flow Redundancy @@ -31777,7 +31722,7 @@ see @cite{Using the GNU Compiler Collection (GCC)}. These options can be used with other programming languages supported by GCC. @node Obsolescent Features,Compatibility and Porting Guide,Security Hardening Features,Top -@anchor{gnat_rm/obsolescent_features doc}@anchor{475}@anchor{gnat_rm/obsolescent_features id1}@anchor{476}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16} +@anchor{gnat_rm/obsolescent_features doc}@anchor{474}@anchor{gnat_rm/obsolescent_features id1}@anchor{475}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16} @chapter Obsolescent Features @@ -31796,7 +31741,7 @@ compatibility purposes. @end menu @node pragma No_Run_Time,pragma Ravenscar,,Obsolescent Features -@anchor{gnat_rm/obsolescent_features id2}@anchor{477}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{478} +@anchor{gnat_rm/obsolescent_features id2}@anchor{476}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{477} @section pragma No_Run_Time @@ -31809,7 +31754,7 @@ preferred usage is to use an appropriately configured run-time that includes just those features that are to be made accessible. @node pragma Ravenscar,pragma Restricted_Run_Time,pragma No_Run_Time,Obsolescent Features -@anchor{gnat_rm/obsolescent_features id3}@anchor{479}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{47a} +@anchor{gnat_rm/obsolescent_features id3}@anchor{478}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{479} @section pragma Ravenscar @@ -31818,7 +31763,7 @@ The pragma @code{Ravenscar} has exactly the same effect as pragma is part of the new Ada 2005 standard. @node pragma Restricted_Run_Time,pragma Task_Info,pragma Ravenscar,Obsolescent Features -@anchor{gnat_rm/obsolescent_features id4}@anchor{47b}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{47c} +@anchor{gnat_rm/obsolescent_features id4}@anchor{47a}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{47b} @section pragma Restricted_Run_Time @@ -31828,7 +31773,7 @@ preferred since the Ada 2005 pragma @code{Profile} is intended for this kind of implementation dependent addition. @node pragma Task_Info,package System Task_Info s-tasinf ads,pragma Restricted_Run_Time,Obsolescent Features -@anchor{gnat_rm/obsolescent_features id5}@anchor{47d}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{47e} +@anchor{gnat_rm/obsolescent_features id5}@anchor{47c}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{47d} @section pragma Task_Info @@ -31854,7 +31799,7 @@ in the spec of package System.Task_Info in the runtime library. @node package System Task_Info s-tasinf ads,,pragma Task_Info,Obsolescent Features -@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{47f}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{480} +@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{47e}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{47f} @section package System.Task_Info (@code{s-tasinf.ads}) @@ -31864,7 +31809,7 @@ to support the @code{Task_Info} pragma. The predefined Ada package standard replacement for GNAT’s @code{Task_Info} functionality. @node Compatibility and Porting Guide,GNU Free Documentation License,Obsolescent Features,Top -@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{481}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{482} +@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{480}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{481} @chapter Compatibility and Porting Guide @@ -31886,7 +31831,7 @@ applications developed in other Ada environments. @end menu @node Writing Portable Fixed-Point Declarations,Compatibility with Ada 83,,Compatibility and Porting Guide -@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{483}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{484} +@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{482}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{483} @section Writing Portable Fixed-Point Declarations @@ -32008,7 +31953,7 @@ If you follow this scheme you will be guaranteed that your fixed-point types will be portable. @node Compatibility with Ada 83,Compatibility between Ada 95 and Ada 2005,Writing Portable Fixed-Point Declarations,Compatibility and Porting Guide -@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{485}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{486} +@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{484}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{485} @section Compatibility with Ada 83 @@ -32036,7 +31981,7 @@ following subsections treat the most likely issues to be encountered. @end menu @node Legal Ada 83 programs that are illegal in Ada 95,More deterministic semantics,,Compatibility with Ada 83 -@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{487}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{488} +@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{486}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{487} @subsection Legal Ada 83 programs that are illegal in Ada 95 @@ -32136,7 +32081,7 @@ the fix is usually simply to add the @code{(<>)} to the generic declaration. @end itemize @node More deterministic semantics,Changed semantics,Legal Ada 83 programs that are illegal in Ada 95,Compatibility with Ada 83 -@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{489}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{48a} +@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{488}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{489} @subsection More deterministic semantics @@ -32164,7 +32109,7 @@ which open select branches are executed. @end itemize @node Changed semantics,Other language compatibility issues,More deterministic semantics,Compatibility with Ada 83 -@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{48b}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{48c} +@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{48a}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{48b} @subsection Changed semantics @@ -32239,7 +32184,7 @@ include @code{pragma Interface} and the floating point type attributes @end itemize @node Compatibility between Ada 95 and Ada 2005,Implementation-dependent characteristics,Compatibility with Ada 83,Compatibility and Porting Guide -@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{48f}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{490} +@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{48f} @section Compatibility between Ada 95 and Ada 2005 @@ -32311,7 +32256,7 @@ can declare a function returning a value from an anonymous access type. @end itemize @node Implementation-dependent characteristics,Compatibility with Other Ada Systems,Compatibility between Ada 95 and Ada 2005,Compatibility and Porting Guide -@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{491}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{492} +@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{490}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{491} @section Implementation-dependent characteristics @@ -32334,7 +32279,7 @@ transition from certain Ada 83 compilers. @end menu @node Implementation-defined pragmas,Implementation-defined attributes,,Implementation-dependent characteristics -@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{493}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{494} +@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{492}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{493} @subsection Implementation-defined pragmas @@ -32356,7 +32301,7 @@ avoiding compiler rejection of units that contain such pragmas; they are not relevant in a GNAT context and hence are not otherwise implemented. @node Implementation-defined attributes,Libraries,Implementation-defined pragmas,Implementation-dependent characteristics -@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{495}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{496} +@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{494}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{495} @subsection Implementation-defined attributes @@ -32370,7 +32315,7 @@ Ada 83, GNAT supplies the attributes @code{Bit}, @code{Machine_Size} and @code{Type_Class}. @node Libraries,Elaboration order,Implementation-defined attributes,Implementation-dependent characteristics -@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{497}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{498} +@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{496}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{497} @subsection Libraries @@ -32399,7 +32344,7 @@ be preferable to retrofit the application using modular types. @end itemize @node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics -@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{499}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{49a} +@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{498}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{499} @subsection Elaboration order @@ -32435,7 +32380,7 @@ pragmas either globally (as an effect of the `-gnatE' switch) or locally @end itemize @node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics -@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{49b}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{49c} +@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{49a}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{49b} @subsection Target-specific aspects @@ -32448,10 +32393,10 @@ on the robustness of the original design. Moreover, Ada 95 (and thus Ada 2005 and Ada 2012) are sometimes incompatible with typical Ada 83 compiler practices regarding implicit packing, the meaning of the Size attribute, and the size of access values. -GNAT’s approach to these issues is described in @ref{49d,,Representation Clauses}. +GNAT’s approach to these issues is described in @ref{49c,,Representation Clauses}. @node Compatibility with Other Ada Systems,Representation Clauses,Implementation-dependent characteristics,Compatibility and Porting Guide -@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{49e}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{49f} +@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{49d}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{49e} @section Compatibility with Other Ada Systems @@ -32494,7 +32439,7 @@ far beyond this minimal set, as described in the next section. @end itemize @node Representation Clauses,Compatibility with HP Ada 83,Compatibility with Other Ada Systems,Compatibility and Porting Guide -@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{4a0}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{49d} +@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{49f}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{49c} @section Representation Clauses @@ -32587,7 +32532,7 @@ with thin pointers. @end itemize @node Compatibility with HP Ada 83,,Representation Clauses,Compatibility and Porting Guide -@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{4a1}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{4a2} +@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{4a0}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{4a1} @section Compatibility with HP Ada 83 @@ -32617,7 +32562,7 @@ extension of package System. @end itemize @node GNU Free Documentation License,Index,Compatibility and Porting Guide,Top -@anchor{share/gnu_free_documentation_license doc}@anchor{4a3}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{4a4} +@anchor{share/gnu_free_documentation_license doc}@anchor{4a2}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{4a3} @chapter GNU Free Documentation License diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 2579b31..114a891 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -10072,7 +10072,7 @@ Library (RTL) ALI files. @code{n} controls the optimization level: -@multitable {xxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} +@multitable {xxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} @item `n' @@ -10087,7 +10087,7 @@ Effect @tab -No optimization, the default setting if no @code{-O} appears +No optimization, the default setting if no @code{-O} appears. @item @@ -10095,9 +10095,8 @@ No optimization, the default setting if no @code{-O} appears @tab -Normal optimization, the default if you specify @code{-O} without an -operand. A good compromise between code quality and compilation -time. +Moderate optimization, same as @code{-O} without an operand. +A good compromise between code quality and compilation time. @item @@ -10105,7 +10104,7 @@ time. @tab -Extensive optimization, may improve execution time, possibly at +Extensive optimization, should improve execution time, possibly at the cost of substantially increased compilation time. @item @@ -10114,8 +10113,8 @@ the cost of substantially increased compilation time. @tab -Same as @code{-O2}, and also includes inline expansion for small -subprograms in the same unit. +Full optimization, may further improve execution time, possibly at +the cost of substantially larger generated code. @item @@ -10123,7 +10122,23 @@ subprograms in the same unit. @tab -Optimize space usage +Optimize for size (code and data) rather than speed. + +@item + +`z' + +@tab + +Optimize aggressively for size (code and data) rather than speed. + +@item + +`g' + +@tab + +Optimize for debugging experience rather than speed. @end multitable @@ -20277,13 +20292,12 @@ Turning on optimization makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly the ability to debug the program. -If you use multiple @code{-O} switches, with or without level -numbers, the last such switch is the one that’s used. - -You can use the -@code{-O} switch (the permitted forms are @code{-O0}, @code{-O1} -@code{-O2}, @code{-O3}, and @code{-Os}) -to @code{gcc} to control the optimization level: +You can pass the @code{-O} switch, with or without an operand +(the permitted forms with an operand are @code{-O0}, @code{-O1}, +@code{-O2}, @code{-O3}, @code{-Os}, @code{-Oz}, and +@code{-Og}) to @code{gcc} to control the optimization level. If you +pass multiple @code{-O} switches, with or without an operand, +the last such switch is the one that’s used: @itemize * @@ -20294,8 +20308,7 @@ to @code{gcc} to control the optimization level: @item @code{-O0} -No optimization (the default); -generates unoptimized code but has +No optimization (the default); generates unoptimized code but has the fastest compilation time. Debugging is easiest with this switch. Note that many other compilers do substantial optimization even if @@ -20312,10 +20325,11 @@ mind when doing performance comparisons. @item @code{-O1} -Moderate optimization; optimizes reasonably well but does not -degrade compilation time significantly. You may not be able to see -some variables in the debugger and changing the value of some -variables in the debugger may not have the effect you desire. +Moderate optimization (same as @code{-O} without an operand); +optimizes reasonably well but does not degrade compilation time +significantly. You may not be able to see some variables in the +debugger, and changing the value of some variables in the debugger +may not have the effect you desire. @end table @item @@ -20324,9 +20338,8 @@ variables in the debugger may not have the effect you desire. @item @code{-O2} -Full optimization; -generates highly optimized code and has -the slowest compilation time. You may see significant impacts on +Extensive optimization; generates highly optimized code but has +an increased compilation time. You may see significant impacts on your ability to display and modify variables in the debugger. @end table @@ -20336,9 +20349,9 @@ your ability to display and modify variables in the debugger. @item @code{-O3} -Full optimization as in @code{-O2}; -also uses more aggressive automatic inlining of subprograms within a unit -(@ref{104,,Inlining of Subprograms}) and attempts to vectorize loops. +Full optimization; attempts more sophisticated transformations, in +particular on loops, possibly at the cost of larger generated code. +You may be hardly able to use the debugger at this optimization level. @end table @item @@ -20347,16 +20360,41 @@ also uses more aggressive automatic inlining of subprograms within a unit @item @code{-Os} -Optimize space usage (code and data) of resulting program. +Optimize for size (code and data) of resulting binary rather than +speed; based on the @code{-O2} optimization level, but disables +some of its transformations that often increase code size, as well +as performs further optimizations designed to reduce code size. +@end table + +@item + +@table @asis + +@item @code{-Oz} + +Optimize aggressively for size (code and data) of resulting binary +rather than speed; may increase the number of instructions executed +if these instructions require fewer bytes to be encoded. +@end table + +@item + +@table @asis + +@item @code{-Og} + +Optimize for debugging experience rather than speed; based on the +@code{-O1} optimization level, but attempts to eliminate all the +negative effects of optimization on debugging. @end table @end itemize Higher optimization levels perform more global transformations on the program and apply more expensive analysis algorithms in order to generate faster and more compact code. The price in compilation time, and the -resulting improvement in execution time, -both depend on the particular application and the hardware environment. -You should experiment to find the best level for your application. +resulting improvement in execution time, both depend on the particular +application and the hardware environment. You should experiment to find +the best level for your application. Since the precise set of optimizations done at each level will vary from release to release (and sometime from target to target), it is best to think diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 9a25ff7..e94b043 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -8488,11 +8488,19 @@ package body Sem_Ch3 is Analyze (Decl); - pragma Assert (Has_Discriminants (Full_Der) - and then not Has_Unknown_Discriminants (Full_Der)); + pragma + Assert + ((Has_Discriminants (Full_Der) + and then not Has_Unknown_Discriminants (Full_Der)) + or else Serious_Errors_Detected > 0); Uninstall_Declarations (Par_Scope); + if Etype (Full_Der) = Any_Type then + pragma Assert (Serious_Errors_Detected > 0); + return; + end if; + -- Freeze the underlying record view, to prevent generation of -- useless dispatching information, which is simply shared with -- the real derived type. @@ -9457,8 +9465,8 @@ package body Sem_Ch3 is if Constraint_Present then if not Has_Discriminants (Parent_Base) or else - (Has_Unknown_Discriminants (Parent_Base) - and then Is_Private_Type (Parent_Base)) + (Has_Unknown_Discriminants (Parent_Type) + and then Is_Private_Type (Parent_Type)) then Error_Msg_N ("invalid constraint: type has no discriminant", diff --git a/gcc/ada/usage.adb b/gcc/ada/usage.adb index efa38b5..3f6cd69 100644 --- a/gcc/ada/usage.adb +++ b/gcc/ada/usage.adb @@ -92,17 +92,17 @@ begin -- Common switches available everywhere - Write_Switch_Char ("g ", ""); + Write_Switch_Char ("g ", ""); Write_Line ("Generate debugging information"); - Write_Switch_Char ("Idir ", ""); + Write_Switch_Char ("Idir ", ""); Write_Line ("Specify source files search path"); - Write_Switch_Char ("I- ", ""); + Write_Switch_Char ("I- ", ""); Write_Line ("Do not look for sources in current directory"); - Write_Switch_Char ("O[0123] ", ""); - Write_Line ("Control the optimization level"); + Write_Switch_Char ("O[?] ", ""); + Write_Line ("Control the optimization level (?=0/1/2/3/s/z/g)"); Write_Eol; diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index 01b8e4b..f8bbdc7 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -5273,6 +5273,41 @@ ;;<< << << << << << << << << << << << << << << << << << << << << << << << << << ;; arithmetic shift left +;; Work around PR120423: Transform left shift of a paradoxical subreg +;; into left shift of the zero-extended entity. +(define_split ; PR120423 + [(set (match_operand:HISI 0 "register_operand") + (ashift:HISI (subreg:HISI (match_operand:QIPSI 1 "nonimmediate_operand") + 0) + (match_operand:QI 2 "const_int_operand")))] + "!reload_completed + && !avropt_lra_p + && <HISI:SIZE> > <QIPSI:SIZE>" + [(set (match_dup 4) + (zero_extend:HISI (match_dup 5))) + (set (match_dup 0) + (ashift:HISI (match_dup 4) + (match_dup 2)))] + { + operands[4] = gen_reg_rtx (<HISI:MODE>mode); + operands[5] = force_reg (<QIPSI:MODE>mode, operands[1]); + }) + +;; Similar happens for PR116389. +(define_split ; PR116389 + [(set (match_operand:HISI 0 "register_operand") + (subreg:HISI (match_operand:QIPSI 1 "nonimmediate_operand") + 0))] + "!reload_completed + && !avropt_lra_p + && <HISI:SIZE> > <QIPSI:SIZE>" + [(set (match_dup 0) + (zero_extend:HISI (match_dup 2)))] + { + operands[2] = force_reg (<QIPSI:MODE>mode, operands[1]); + }) + + ;; "ashlqi3" ;; "ashlqq3" "ashluqq3" (define_expand "ashl<mode>3" diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c470df3..9ee7251 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2025-06-13 Andre Vehreschild <vehre@gcc.gnu.org> + + Backported from master: + 2025-06-13 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/120483 + * trans-expr.cc (gfc_conv_substring): Use pointer arithmetic on + static allocatable char arrays. + 2025-06-04 Harald Anlauf <anlauf@gmx.de> Backported from master: diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index d72545e..a3f6de2 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -2784,9 +2784,11 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind, start.expr = gfc_evaluate_now (start.expr, &se->pre); /* Change the start of the string. */ - if ((TREE_CODE (TREE_TYPE (se->expr)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (se->expr)) == INTEGER_TYPE) - && TYPE_STRING_FLAG (TREE_TYPE (se->expr))) + if (((TREE_CODE (TREE_TYPE (se->expr)) == ARRAY_TYPE + || TREE_CODE (TREE_TYPE (se->expr)) == INTEGER_TYPE) + && TYPE_STRING_FLAG (TREE_TYPE (se->expr))) + || (POINTER_TYPE_P (TREE_TYPE (se->expr)) + && TREE_CODE (TREE_TYPE (TREE_TYPE (se->expr))) != ARRAY_TYPE)) tmp = se->expr; else tmp = build_fold_indirect_ref_loc (input_location, @@ -2797,6 +2799,14 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind, tmp = gfc_build_array_ref (tmp, start.expr, NULL_TREE, true); se->expr = gfc_build_addr_expr (type, tmp); } + else if (POINTER_TYPE_P (TREE_TYPE (tmp))) + { + tree diff; + diff = fold_build2 (MINUS_EXPR, size_type_node, start.expr, + build_one_cst (size_type_node)); + se->expr + = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (tmp), tmp, diff); + } } /* Length = end + 1 - start. */ diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 0398d69..5f6f93c 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -3329,6 +3329,10 @@ update_jump_functions_after_inlining (struct cgraph_edge *cs, ipa_edge_args *args = ipa_edge_args_sum->get (e); if (!args) return; + ipa_node_params *old_inline_root_info = ipa_node_params_sum->get (cs->callee); + ipa_node_params *new_inline_root_info + = ipa_node_params_sum->get (cs->caller->inlined_to + ? cs->caller->inlined_to : cs->caller); int count = ipa_get_cs_argument_count (args); int i; @@ -3540,6 +3544,30 @@ update_jump_functions_after_inlining (struct cgraph_edge *cs, enum tree_code operation; operation = ipa_get_jf_pass_through_operation (src); + tree old_ir_ptype = ipa_get_type (old_inline_root_info, + dst_fid); + tree new_ir_ptype = ipa_get_type (new_inline_root_info, + formal_id); + if (!useless_type_conversion_p (old_ir_ptype, new_ir_ptype)) + { + /* Jump-function construction now permits type-casts + from an integer to another if the latter can hold + all values or has at least the same precision. + However, as we're combining multiple pass-through + functions together, we are losing information about + signedness and thus if conversions should sign or + zero extend. Therefore we must prevent combining + such jump-function if signednesses do not match. */ + if (!INTEGRAL_TYPE_P (old_ir_ptype) + || !INTEGRAL_TYPE_P (new_ir_ptype) + || (TYPE_UNSIGNED (new_ir_ptype) + != TYPE_UNSIGNED (old_ir_ptype))) + { + ipa_set_jf_unknown (dst); + continue; + } + } + if (operation == NOP_EXPR) { bool agg_p; diff --git a/gcc/po/ChangeLog b/gcc/po/ChangeLog index 1db7cd5..3bfcf33 100644 --- a/gcc/po/ChangeLog +++ b/gcc/po/ChangeLog @@ -1,3 +1,7 @@ +2025-06-12 Joseph Myers <josmyers@redhat.com> + + * es.po: Update. + 2025-05-15 Joseph Myers <josmyers@redhat.com> * zh_CN.po: Update. diff --git a/gcc/po/es.po b/gcc/po/es.po index 6033f331..2959212 100644 --- a/gcc/po/es.po +++ b/gcc/po/es.po @@ -2,7 +2,7 @@ # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2016, 2017, 2018, 2019, 2020 Free Software Foundation, Inc. # This file is distributed under the same license as the gcc package. # Cristian Othón Martínez Vera <cfuga@cfuga.mx>, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -# Antonio Ceballos Roa <aceballos@gmail.com>, 2016, 2017, 2018, 2019, 2020 +# Antonio Ceballos Roa <aceballos@gmail.com>, 2016, 2017, 2018, 2019, 2020, 2025 # # Agradezco a Juan Cuquejo Mira por sus comentarios sobre esta traducción # @@ -40,10 +40,10 @@ # msgid "" msgstr "" -"Project-Id-Version: gcc 10.1-b20200209\n" +"Project-Id-Version: gcc 15.1.0\n" "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n" "POT-Creation-Date: 2025-04-23 19:27+0000\n" -"PO-Revision-Date: 2020-03-22 16:48+0100\n" +"PO-Revision-Date: 2025-06-12 23:08+0200\n" "Last-Translator: Antonio Ceballos Roa <aceballos@gmail.com>\n" "Language-Team: Spanish <es@tp.org.es>\n" "Language: es\n" @@ -15533,12 +15533,12 @@ msgstr "Activa las opciones comunes para generar información de análisis de pe #: common.opt:2648 #, no-c-format msgid "Register the profile information in the .gcov_info section instead of using a constructor/destructor." -msgstr "" +msgstr "Registra la información de análisis de perfil en la sección .gcov_info en lugar de utilizar un constructor/destructor." #: common.opt:2652 #, no-c-format msgid "Register the profile information in the specified section instead of using a constructor/destructor." -msgstr "" +msgstr "Registra la información de análisis de perfil en la sección especificada en lugar de utilizar un constructor/destructor." #: common.opt:2656 #, no-c-format @@ -18902,7 +18902,7 @@ msgstr "" #: gcov-tool.cc:157 gcov-tool.cc:300 #, c-format msgid "no profile files were merged\n" -msgstr "" +msgstr "no se han mezclado ficheros de perfil\n" #: gcov-tool.cc:169 #, c-format @@ -18925,26 +18925,22 @@ msgid " -w, --weight <w1,w2> Set weights (float point values)\ msgstr " -w, --weight <p1,p2> Establece los pesos (valores de coma flotante)\n" #: gcov-tool.cc:188 -#, fuzzy, c-format -#| msgid "Merge subcomand usage:" +#, c-format msgid "Merge subcommand usage:" msgstr "Modo de empleo de la suborden de mezcla:" #: gcov-tool.cc:240 -#, fuzzy, c-format -#| msgid "" -#| " -l, --long-file-names Use long output file names for included\n" -#| " source files\n" +#, c-format msgid "" " merge-stream [options] [<file>] Merge coverage stream file (or stdin)\n" " and coverage file contents\n" msgstr "" -" -l, --long-file-names Usa nombres largos de ficheros para los\n" -" ficheros fuentes incluidos\n" +" merge-stream [options] [<fich>] Mezcla el fichero de flujo de cobertura\n" +" (o stdin) y el contenido del fichero de\n" +" cobertura\n" #: gcov-tool.cc:258 -#, fuzzy, c-format -#| msgid "Merge subcomand usage:" +#, c-format msgid "Merge-stream subcommand usage:" msgstr "Modo de empleo de la suborden de mezcla:" @@ -19014,8 +19010,7 @@ msgid " -t <float>, --hot_threshold <float> Set the threshold for hotness\n" msgstr " -t <float>, --hot_threshold <float> Establece el umbral de calentura\n" #: gcov-tool.cc:510 -#, fuzzy, c-format -#| msgid "Overlap subcomand usage:" +#, c-format msgid "Overlap subcommand usage:" msgstr "Modo de empleo de la suborden de solapamiento:" @@ -19059,10 +19054,9 @@ msgstr "" "%s.\n" #: gcov-tool.cc:595 -#, fuzzy, c-format -#| msgid "Copyright %s 2019 Free Software Foundation, Inc.\n" +#, c-format msgid "Copyright %s 2025 Free Software Foundation, Inc.\n" -msgstr "Copyright %s 2019 Free Software Foundation, Inc.\n" +msgstr "Copyright %s 2025 Free Software Foundation, Inc.\n" #: gcov.cc:1096 #, c-format @@ -19102,22 +19096,21 @@ msgstr "" " en lugar de los porcentajes\n" #: gcov.cc:1102 -#, fuzzy, c-format -#| msgid "" -#| " -c, --branch-counts Output counts of branches taken\n" -#| " rather than percentages\n" +#, c-format msgid "" " -g, --conditions Include modified condition/decision\n" " coverage (masking MC/DC) in output\n" msgstr "" -" -c, --branch-counts Se muestra el número de ramificaciones\n" -" en lugar de los porcentajes\n" +" -g, --conditions Incluye la cobertura de condición/decisión\n" +" modificada (enmascarando MC/DC) en la\n" +" salida\n" #: gcov.cc:1104 -#, fuzzy, c-format -#| msgid " -p, --preserve-paths Preserve all pathname components\n" +#, c-format msgid " -e, --prime-paths Show prime path coverage summary\n" -msgstr " -p, --preserve-paths Preserva todos los nombres de ruta de los componentes\n" +msgstr "" +" -e, --prime-paths Muestra el resumen de la cobertura de camino\n" +" primario\n" #: gcov.cc:1105 #, c-format @@ -19127,6 +19120,10 @@ msgid "" " TYPE is 'covered', 'uncovered', or 'both'\n" " and defaults to 'uncovered'\n" msgstr "" +" --prime-paths-lines[=TIPO] Incluye los caminos en la salida\n" +" modo de traza de línea - no afecta a json\n" +" TIPO es 'covered', 'uncovered' o 'both'\n" +" y el predefinido es 'uncovered'\n" #: gcov.cc:1109 #, c-format @@ -19136,6 +19133,10 @@ msgid "" " TYPE is 'covered', 'uncovered', or 'both'\n" " and defaults to 'uncovered'\n" msgstr "" +" --prime-paths-source[=TIPO] Incluye los caminos en la salida\n" +" modo de traza de fuente - no afecta a json\n" +" TIPO es 'covered', 'uncovered' o 'both'\n" +" y el predefinido es 'uncovered'\n" #: gcov.cc:1113 #, c-format @@ -19145,7 +19146,7 @@ msgstr " -d, --display-progress Muestra información de progreso\n" #: gcov.cc:1114 #, c-format msgid " -D, --debug\t\t\t Display debugging dumps\n" -msgstr "" +msgstr " -D, --debug\t\t\t Muestra volcados de depuración\n" #: gcov.cc:1115 #, c-format @@ -19153,16 +19154,14 @@ msgid " -f, --function-summaries Output summaries for each function\n" msgstr " -f, --function-summaries Muestra sumarios para cada función\n" #: gcov.cc:1116 -#, fuzzy, c-format -#| msgid " -f, --function Print function level info\n" +#, c-format msgid " --include Include functions matching this regex\n" -msgstr " -f, --function Imprime información sobre el nivel de funciones\n" +msgstr " --include Incluye funciones coincidentes con esta regex\n" #: gcov.cc:1117 -#, fuzzy, c-format -#| msgid " -h, --help Print this help, then exit\n" +#, c-format msgid " --exclude Exclude functions matching this regex\n" -msgstr " -h, --help Muestra esta información, y finaliza\n" +msgstr " --exclude Excluye funciones coincidentes con esta regex\n" #: gcov.cc:1118 #, c-format @@ -19170,18 +19169,18 @@ msgid " -h, --help Print this help, then exit\n" msgstr " -h, --help Muestra esta información, y finaliza\n" #: gcov.cc:1119 -#, fuzzy, c-format -#| msgid " -i, --json-format Output JSON intermediate format into .gcov.json.gz file\n" +#, c-format msgid "" " -j, --json-format Output JSON intermediate format\n" " into .gcov.json.gz file\n" -msgstr " -i, --json-format Salida con formato JSON intermedia en el fichero .gcov.json.gz\n" +msgstr "" +" -j, --json-format Envía el formato intermedio JSON\n" +" al fichero .gcov.json.gz\n" #: gcov.cc:1121 -#, fuzzy, c-format -#| msgid " -j, --human-readable Output human readable numbers\n" +#, c-format msgid " -H, --human-readable Output human readable numbers\n" -msgstr " -j, --human-readable Salida con números legibles para humanos\n" +msgstr " -H, --human-readable Salida con números legibles para humanos\n" #: gcov.cc:1122 #, c-format @@ -19200,19 +19199,16 @@ msgstr "" #: gcov.cc:1125 #, c-format msgid " -m, --demangled-names Output demangled function names\n" -msgstr " -m, --demangled-names Nombres de función mutilados de salida\n" +msgstr " -m, --demangled-names Saca nombres de función desofuscados\n" #: gcov.cc:1126 -#, fuzzy, c-format -#| msgid "" -#| " -l, --long-file-names Use long output file names for included\n" -#| " source files\n" +#, c-format msgid "" " -M, --filter-on-demangled Make --include/--exclude match on demangled\n" " names. This does not imply -m\n" msgstr "" -" -l, --long-file-names Usa nombres largos de ficheros para los\n" -" ficheros fuentes incluidos\n" +" -M, --filter-on-demangled Aplica --include/--exclude a los nombres\n" +" desofuscados. No implica -m\n" #: gcov.cc:1128 #, c-format @@ -19270,24 +19266,23 @@ msgid " -x, --hash-filenames Hash long pathnames\n" msgstr " -x, --hash-filenames Nombres de ruta largos de Hash\n" #: gcov.cc:1139 -#, fuzzy, c-format -#| msgid "Options:\n" +#, c-format msgid "" "\n" "Obsolete options:\n" -msgstr "Opciones:\n" +msgstr "" +"\n" +"Opciones obsoletas:\n" #: gcov.cc:1140 -#, fuzzy, c-format -#| msgid " -i, --json-format Output JSON intermediate format into .gcov.json.gz file\n" +#, c-format msgid " -i, --json-format Replaced with -j, --json-format\n" -msgstr " -i, --json-format Salida con formato JSON intermedia en el fichero .gcov.json.gz\n" +msgstr " -i, --json-format Reemplazado por -j, --json-format\n" #: gcov.cc:1141 -#, fuzzy, c-format -#| msgid " -j, --human-readable Output human readable numbers\n" +#, c-format msgid " -j, --human-readable Replaced with -H, --human-readable\n" -msgstr " -j, --human-readable Salida con números legibles para humanos\n" +msgstr " -j, --human-readable Reemplazado por -H, --human-readable\n" #: gcov.cc:1152 #, c-format @@ -19295,20 +19290,19 @@ msgid "gcov %s%s\n" msgstr "gcov %s%s\n" #: gcov.cc:1153 -#, fuzzy, c-format -#| msgid "collect2 version %s\n" +#, c-format msgid "JSON format version: %s\n" -msgstr "collect2 versión %s\n" +msgstr "versión del formato JSON: %s\n" #: gcov.cc:1237 #, c-format msgid "invalid argument '%s' for '--prime-paths-lines'. Valid arguments are: 'covered', 'uncovered', 'both'\n" -msgstr "" +msgstr "argumento no válido '%s' para --prime-paths-lines'. Argumentos válidos: 'covered', 'uncovered', 'both'\n" #: gcov.cc:1258 #, c-format msgid "invalid argument '%s' for '--prime-paths-source'. Valid arguments are: 'covered', 'uncovered', 'both'\n" -msgstr "" +msgstr "argumento no válido '%s' para --prime-paths-source'. Argumentos válidos: 'covered', 'uncovered', 'both'\n" #: gcov.cc:1726 #, c-format @@ -19376,10 +19370,9 @@ msgid "%s:already seen blocks for '%s'\n" msgstr "%s:ya se vieron bloques para '%s'\n" #: gcov.cc:2391 -#, fuzzy, c-format -#| msgid "%s:already seen blocks for '%s'\n" +#, c-format msgid "%s:already seen conditions for '%s'\n" -msgstr "%s:ya se vieron bloques para '%s'\n" +msgstr "%s:condiciones ya vistas para '%s'\n" #: gcov.cc:2449 gcov.cc:2589 #, c-format @@ -19482,28 +19475,24 @@ msgid "No calls\n" msgstr "No hay llamadas\n" #: gcov.cc:3090 gcov.cc:3144 -#, fuzzy, c-format -#| msgid "Lines executed:%s of %d\n" +#, c-format msgid "Condition outcomes covered:%s of %d\n" -msgstr "Líneas ejecutadas:%s de %d\n" +msgstr "Salidas de condiciones cubiertas:%s de %d\n" #: gcov.cc:3095 gcov.cc:3149 -#, fuzzy, c-format -#| msgid "bad condition code" +#, c-format msgid "No conditions\n" -msgstr "código de condición erróneo" +msgstr "No hay condiciones\n" #: gcov.cc:3101 gcov.cc:3155 -#, fuzzy, c-format -#| msgid "Branches executed:%s of %d\n" +#, c-format msgid "Prime paths covered:%s of %d\n" -msgstr "Ramificaciones ejecutadas:%s de %d\n" +msgstr "Caminos primarios cubiertos:%s de %d\n" #: gcov.cc:3105 gcov.cc:3159 -#, fuzzy, c-format -#| msgid "Display this information." +#, c-format msgid "No path information\n" -msgstr "Muestra esta información." +msgstr "No hay información de caminos\n" #: gcov.cc:3379 #, c-format @@ -19513,13 +19502,12 @@ msgstr "%s:no hay líneas para '%s'\n" #: gcov.cc:3515 #, c-format msgid "condition outcomes covered %d/%d\n" -msgstr "" +msgstr "salidas de condiciones cubiertas %d/%d\n" #: gcov.cc:3528 -#, fuzzy, c-format -#| msgid "unconditional %2d taken %s\n" +#, c-format msgid "condition %2u not covered (%s%s)\n" -msgstr "el incondicional %2d tomado %s\n" +msgstr "condición %2u no cubierta (%s%s)\n" #: gcov.cc:3542 #, c-format @@ -19537,10 +19525,9 @@ msgid "branch %2d taken %s%s" msgstr "ramificación %2d tomada %s%s" #: gcov.cc:3557 -#, fuzzy, c-format -#| msgid "branch %2d never executed" +#, c-format msgid "branch %2d never executed%s" -msgstr "la ramificacion %2d nunca se ejecuta" +msgstr "la ramificacion %2d nunca se ejecuta%s" #: gcov.cc:3562 #, c-format @@ -19558,15 +19545,14 @@ msgid "unconditional %2d never executed\n" msgstr "el incondicional %2d nunca se ejecuta\n" #: gcov.cc:3729 -#, fuzzy, c-format -#| msgid "parameter name omitted" +#, c-format msgid "path coverage omitted\n" -msgstr "se omitió el nombre del parámetro" +msgstr "cobertura de caminos omitida\n" #: gcov.cc:3731 #, c-format msgid "paths covered %u of %zu\n" -msgstr "" +msgstr "caminos cubiertos %u de %zu\n" #: gcov.cc:3806 #, c-format @@ -19612,16 +19598,14 @@ msgid "End of search list.\n" msgstr "Fin de la lista de búsqueda.\n" #: incpath.cc:408 -#, fuzzy, c-format -#| msgid "#include <...> search starts here:\n" +#, c-format msgid "#embed <...> search starts here:\n" -msgstr "la búsqueda de #include <...> inicia aquí:\n" +msgstr "la búsqueda de #embed <...> comienza aquí:\n" #: incpath.cc:411 -#, fuzzy, c-format -#| msgid "End of search list.\n" +#, c-format msgid "End of #embed search list.\n" -msgstr "Fin de la lista de búsqueda.\n" +msgstr "Fin de la lista de búsqueda de #embed.\n" #: input.cc:35 msgid "<built-in>" @@ -27144,10 +27128,9 @@ msgid "wrong number of arguments to %%:dwarf-version-gt" msgstr "número erróneo de argumentos para %%:debug-level-gt" #: gcov-tool.cc:75 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "error in removing %s\n" +#, gcc-internal-format, gfc-internal-format msgid "error in removing %s" -msgstr "error al quitar %s\n" +msgstr "error al quitar %s" #: gcov-tool.cc:106 #, gcc-internal-format, gfc-internal-format @@ -27167,19 +27150,17 @@ msgstr "No se puede cambiar al directorio %s" #: gcov-tool.cc:125 #, gcc-internal-format, gfc-internal-format msgid "output file %s already exists in folder %s" -msgstr "" +msgstr "el fichero de salida %s ya existe en la carpeta %s" #: gcov-tool.cc:217 gcov-tool.cc:285 -#, fuzzy, gcc-internal-format -#| msgid "weights need to be non-negative\n" +#, gcc-internal-format msgid "weights need to be non-negative" -msgstr "los pesos tienen que ser no negativos\n" +msgstr "los pesos han de ser no negativos" #: gcov-tool.cc:424 -#, fuzzy, gcc-internal-format -#| msgid "scale needs to be non-negative\n" +#, gcc-internal-format msgid "scale needs to be non-negative" -msgstr "la escala tiene que ser no negativa\n" +msgstr "la escala ha de ser no negativa" #: gcse.cc:4194 #, gcc-internal-format, gfc-internal-format diff --git a/gcc/real.cc b/gcc/real.cc index b64bad0..95a9332 100644 --- a/gcc/real.cc +++ b/gcc/real.cc @@ -2230,7 +2230,6 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt, { unsigned int len = val_in.get_precision (); int i, j, e = 0; - int maxbitlen = MAX_BITSIZE_MODE_ANY_INT + HOST_BITS_PER_WIDE_INT; const unsigned int realmax = (SIGNIFICAND_BITS / HOST_BITS_PER_WIDE_INT * HOST_BITS_PER_WIDE_INT); @@ -2238,12 +2237,6 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt, r->cl = rvc_normal; r->sign = wi::neg_p (val_in, sgn); - /* We have to ensure we can negate the largest negative number. */ - wide_int val = wide_int::from (val_in, maxbitlen, sgn); - - if (r->sign) - val = -val; - /* Ensure a multiple of HOST_BITS_PER_WIDE_INT, ceiling, as elt won't work with precisions that are not a multiple of HOST_BITS_PER_WIDE_INT. */ @@ -2252,7 +2245,13 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt, /* Ensure we can represent the largest negative number. */ len += 1; - len = len/HOST_BITS_PER_WIDE_INT * HOST_BITS_PER_WIDE_INT; + len = len / HOST_BITS_PER_WIDE_INT * HOST_BITS_PER_WIDE_INT; + + /* We have to ensure we can negate the largest negative number. */ + wide_int val = wide_int::from (val_in, len, sgn); + + if (r->sign) + val = -val; /* Cap the size to the size allowed by real.h. */ if (len > realmax) @@ -2260,14 +2259,18 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt, HOST_WIDE_INT cnt_l_z; cnt_l_z = wi::clz (val); - if (maxbitlen - cnt_l_z > realmax) + if (len - cnt_l_z > realmax) { - e = maxbitlen - cnt_l_z - realmax; + e = len - cnt_l_z - realmax; /* This value is too large, we must shift it right to preserve all the bits we can, and then bump the - exponent up by that amount. */ - val = wi::lrshift (val, e); + exponent up by that amount, but or in 1 if any of + the shifted out bits are non-zero. */ + if (wide_int::from (val, e, UNSIGNED) != 0) + val = wi::set_bit (wi::lrshift (val, e), 0); + else + val = wi::lrshift (val, e); } len = realmax; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4008287..d25e135 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,52 @@ +2025-06-14 Georg-Johann Lay <avr@gjlay.de> + + PR rtl-optimization/120423 + PR rtl-optimization/116389 + * gcc.target/avr/torture/pr120423-1.c: New test. + * gcc.target/avr/torture/pr120423-2.c: New test. + * gcc.target/avr/torture/pr120423-116389.c: New test. + +2025-06-13 Georg-Johann Lay <avr@gjlay.de> + + Backported from master: + 2025-06-12 Georg-Johann Lay <avr@gjlay.de> + + PR middle-end/117811 + PR testsuite/52641 + * gcc.dg/torture/pr117811.c: Fix for int < 32 bit. + +2025-06-13 Jakub Jelinek <jakub@redhat.com> + + Backported from master: + 2025-06-12 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/120638 + * gcc.dg/pr120638.c: New test. + +2025-06-13 Jakub Jelinek <jakub@redhat.com> + + Backported from master: + 2025-06-05 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/120547 + * gcc.dg/bitint-123.c: New test. + +2025-06-13 Andre Vehreschild <vehre@gcc.gnu.org> + + Backported from master: + 2025-06-13 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/120483 + * gfortran.dg/save_8.f90: New test. + +2025-06-12 Martin Jambor <mjambor@suse.cz> + + Backported from master: + 2025-05-29 Martin Jambor <mjambor@suse.cz> + + PR ipa/120295 + * gcc.dg/ipa/pr120295.c: New test. + 2025-06-09 Jason Merrill <jason@redhat.com> Backported from master: diff --git a/gcc/testsuite/gcc.dg/bitint-123.c b/gcc/testsuite/gcc.dg/bitint-123.c new file mode 100644 index 0000000..4d019a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitint-123.c @@ -0,0 +1,26 @@ +/* PR middle-end/120547 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-O2" } */ +/* { dg-add-options float64 } */ +/* { dg-require-effective-target float64 } */ + +#define CHECK(x, y) \ + if ((_Float64) x != (_Float64) y \ + || (_Float64) (x + 1) != (_Float64) (y + 1)) \ + __builtin_abort () + +int +main () +{ + unsigned long long a = 0x20000000000001ULL << 7; + volatile unsigned long long b = a; + CHECK (a, b); +#if __BITINT_MAXWIDTH__ >= 4096 + unsigned _BitInt(4096) c = ((unsigned _BitInt(4096)) 0x20000000000001ULL) << 253; + volatile unsigned _BitInt(4096) d = c; + CHECK (c, d); + unsigned _BitInt(4096) e = ((unsigned _BitInt(4096)) 0x20000000000001ULL) << 931; + volatile unsigned _BitInt(4096) f = e; + CHECK (e, f); +#endif +} diff --git a/gcc/testsuite/gcc.dg/ipa/pr120295.c b/gcc/testsuite/gcc.dg/ipa/pr120295.c new file mode 100644 index 0000000..2033ee9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr120295.c @@ -0,0 +1,66 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +struct { + signed a; +} b; +int a, f, j, l; +char c, k, g, e; +short d[2] = {0}; +int *i = &j; + +volatile int glob; +void __attribute__((noipa)) sth (const char *, int a) +{ + glob = a; + return; +} + +void marker_37() { + a++; + sth ("%d\n", a); +} +unsigned long long m(unsigned, char, unsigned, short); +int n(int, unsigned char, long long); +int o(long long, unsigned, unsigned); +unsigned short p(void) { + int *r = &l; + *r |= ({ + long long y = (m(c, c, 0, c), b.a); + y; + }); + return 0; +} +unsigned long long m(unsigned q, char v, unsigned s, short u) { + unsigned short ab = 5; + if (n(q, ab, d[1])) + for (; g; g++) + ; + return c; +} +int n(int af, unsigned char e, long long ae) { + unsigned ag = 4; + int *ah = &f; + *ah = ({ short ad = o(af, f, ag); ad<0 || ad> e; }); + return *i; +} +int o(long long aj, unsigned ai, unsigned ak) { + for (; e; e--) { + int *al = &f; + for (; k; k++) + *al = 0; + } + if (18446744073709551606UL != (unsigned long long) aj) + ; + else + marker_37(); + return ak; +} +int f123() { + c = 0xf6; + p(); + return 0; +} +int main() { + return f123(); +} diff --git a/gcc/testsuite/gcc.dg/pr120638.c b/gcc/testsuite/gcc.dg/pr120638.c new file mode 100644 index 0000000..4a057a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr120638.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/120638 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern float sqrtf (float x); + +__attribute__((noipa)) float +foo (unsigned int s) +{ + return 0.5f / sqrtf (1.f + s); +} + +__attribute__((noipa)) float +bar (float s) +{ + if (s < 0.0 || s > 65535.0f) + __builtin_unreachable (); + return 0.5f / sqrtf (1.f + s); +} + +int +main () +{ + if (__builtin_fabsf (foo (3) - 0.25f) > 0.00390625f + || __builtin_fabsf (foo (15) - 0.125f) > 0.00390625f + || __builtin_fabsf (foo (63) - 0.0625f) > 0.00390625f + || __builtin_fabsf (bar (3.0f) - 0.25f) > 0.00390625f + || __builtin_fabsf (bar (15.0f) - 0.125f) > 0.00390625f + || __builtin_fabsf (bar (63.0f) - 0.0625f) > 0.00390625f) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/torture/pr117811.c b/gcc/testsuite/gcc.dg/torture/pr117811.c index 13d7e13..05e8622 100644 --- a/gcc/testsuite/gcc.dg/torture/pr117811.c +++ b/gcc/testsuite/gcc.dg/torture/pr117811.c @@ -18,8 +18,13 @@ void __attribute__((noclone,noinline)) do_shift (v4 *vec, int shift) int main () { +#if __SIZEOF_INT__ >= 4 v4 vec = {0x1000000, 0x2000, 0x300, 0x40}; v4 vec2 = {0x100000, 0x200, 0x30, 0x4}; +#else + v4 vec = {0x4000, 0x2000, 0x300, 0x40}; + v4 vec2 = {0x400, 0x200, 0x30, 0x4}; +#endif do_shift (&vec, 4); if (memcmp (&vec, &vec2, sizeof (v4)) != 0) __builtin_abort (); diff --git a/gcc/testsuite/gcc.target/avr/torture/pr120423-1.c b/gcc/testsuite/gcc.target/avr/torture/pr120423-1.c new file mode 100644 index 0000000..91b4bbc --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/pr120423-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ + +struct data +{ + int a; + int b; + long c; +}; + +unsigned char val; +unsigned val2; + +void func1 (struct data *d) +{ + d->a = 0; + d->b = 0x100 * val - 1; +} + +void func2 (struct data *d) +{ + d->a = 0; + d->c = 0x10000 * val2 - 1; +} + +void func3 (struct data *d) +{ + d->a = 0; + d->c = 0x1000000 * val - 1; +} diff --git a/gcc/testsuite/gcc.target/avr/torture/pr120423-116389.c b/gcc/testsuite/gcc.target/avr/torture/pr120423-116389.c new file mode 100644 index 0000000..928c135 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/pr120423-116389.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +struct T { int val; }; + +void f_int (int); +char* get_pos (void); +struct T* get_pT (void); + +void func (char i) +{ + struct T t = * get_pT (); + unsigned diff = get_pos () - &i; + + if (diff) + { + long val32 = t.val; + if (get_pos ()) + val32 = diff; + if (get_pos ()) + f_int (2 * val32); + } +} diff --git a/gcc/testsuite/gcc.target/avr/torture/pr120423-2.c b/gcc/testsuite/gcc.target/avr/torture/pr120423-2.c new file mode 100644 index 0000000..56e6141 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/pr120423-2.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ffixed-18 -ffixed-20 -ffixed-22" } */ + +struct data +{ + int a; + int b; + long c; +}; + +unsigned char val; +unsigned val2; + +void func1 (struct data *d) +{ + d->a = 0; + d->b = 0x100 * val - 1; +} + +void func2 (struct data *d) +{ + d->a = 0; + d->c = 0x10000 * val2 - 1; +} + +void func3 (struct data *d) +{ + d->a = 0; + d->c = 0x1000000 * val - 1; +} diff --git a/gcc/testsuite/gfortran.dg/save_8.f90 b/gcc/testsuite/gfortran.dg/save_8.f90 new file mode 100644 index 0000000..8e9198c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/save_8.f90 @@ -0,0 +1,13 @@ +!{ dg-do run } + +! Check PR120483 is fixed. +! Contributed by Thomas Koenig <tkoenig@gcc.gnu.org> +! and Peter Güntert <peter@guentert.com> + +program save_8 + implicit none + character(len=:), allocatable, save :: s1 + s1 = 'ABC' + if (s1(3:3) /= 'C') stop 1 +end program save_8 + diff --git a/gcc/tree-chrec.cc b/gcc/tree-chrec.cc index 38eb329..a7c2f8d 100644 --- a/gcc/tree-chrec.cc +++ b/gcc/tree-chrec.cc @@ -1490,7 +1490,7 @@ convert_affine_scev (class loop *loop, tree type, new_step = *step; if (TYPE_PRECISION (step_type) > TYPE_PRECISION (ct) && TYPE_UNSIGNED (ct)) { - tree signed_ct = build_nonstandard_integer_type (TYPE_PRECISION (ct), 0); + tree signed_ct = signed_type_for (ct); new_step = chrec_convert (signed_ct, new_step, at_stmt, use_overflow_semantics); } diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index eb03ebe..1954c28 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -1053,6 +1053,7 @@ pass_cse_reciprocals::execute (function *fun) continue; gimple_replace_ssa_lhs (call, arg1); + reset_flow_sensitive_info (arg1); if (gimple_call_internal_p (call) != (ifn != IFN_LAST)) { auto_vec<tree, 4> args; diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 838f13d..0742cdb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,41 @@ +2025-06-12 Jonathan Wakely <jwakely@redhat.com> + + Backported from master: + 2025-06-12 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/120625 + * include/std/format (__format::__disabled): Remove. + (__formatter_disabled): New type. + (formatter<char*, wchar_t>, formatter<const char*, wchar_t>) + (formatter<char[N], wchar_t>, formatter<string, wchar_t>) + (formatter<string_view, wchar_t>): Use __formatter_disabled as + base class instead of formatter<__disabled, wchar_t>. + * testsuite/std/format/formatter/120625.cc: New test. + +2025-06-10 Jonathan Wakely <jwakely@redhat.com> + + Backported from master: + 2025-06-04 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/99832 + * include/bits/chrono.h (system_clock::to_time_t): Add + always_inline attribute to be agnostic to the underlying type of + time_t. + (system_clock::from_time_t): Add always_inline for consistency + with to_time_t. + * testsuite/20_util/system_clock/99832.cc: New test. + +2025-06-10 Jonathan Wakely <jwakely@redhat.com> + + Backported from master: + 2025-06-05 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/120548 + * include/std/format (__formatter_fp::_M_localize): Do not + include a leading sign character in the string to be grouped. + * testsuite/std/format/functions/format.cc: Check grouping when + sign is present in the output. + 2025-06-06 Patrick Palka <ppalka@redhat.com> Backported from master: diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index d25df12..7d6b752 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -3017,24 +3017,28 @@ namespace __format // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3944. Formatters converting sequences of char to sequences of wchar_t - namespace __format { struct __disabled; } + struct __formatter_disabled + { + __formatter_disabled() = delete; // Cannot format char sequence to wchar_t + __formatter_disabled(const __formatter_disabled&) = delete; + __formatter_disabled& operator=(const __formatter_disabled&) = delete; + }; - // std::formatter<__disabled, C> uses the primary template, which is disabled. template<> struct formatter<char*, wchar_t> - : private formatter<__format::__disabled, wchar_t> { }; + : private __formatter_disabled { }; template<> struct formatter<const char*, wchar_t> - : private formatter<__format::__disabled, wchar_t> { }; + : private __formatter_disabled { }; template<size_t _Nm> struct formatter<char[_Nm], wchar_t> - : private formatter<__format::__disabled, wchar_t> { }; + : private __formatter_disabled { }; template<class _Traits, class _Allocator> struct formatter<basic_string<char, _Traits, _Allocator>, wchar_t> - : private formatter<__format::__disabled, wchar_t> { }; + : private __formatter_disabled { }; template<class _Traits> struct formatter<basic_string_view<char, _Traits>, wchar_t> - : private formatter<__format::__disabled, wchar_t> { }; + : private __formatter_disabled { }; #endif /// An iterator after the last character written, and the number of diff --git a/libstdc++-v3/testsuite/std/format/formatter/120625.cc b/libstdc++-v3/testsuite/std/format/formatter/120625.cc new file mode 100644 index 0000000..6b03af9 --- /dev/null +++ b/libstdc++-v3/testsuite/std/format/formatter/120625.cc @@ -0,0 +1,19 @@ +// { dg-do compile { target c++20 } } + +// Bug libstdc++/120625 +// std::formatter<__disabled> specializations cause errors in user code + +#include <format> + +enum X { }; + +// A concept that cannot be used with incomplete types: +template<typename T> +concept is_X = !std::is_empty_v<T> && std::is_same_v<X, T>; + +// A valid program-defined specialization: +template<typename T, typename C> requires is_X<T> +struct std::formatter<T, C> : std::formatter<int, C> { }; + +// Instantiate the program-defined formatter specialization: +auto s = sizeof(std::formatter<X, char>); |