[gcc r15-3099] Remove unnecessary view_convert obsoleted by [PR86468].
https://gcc.gnu.org/g:0636de8c5202d8fe58af42afdf24dd93d1a90abd commit r15-3099-g0636de8c5202d8fe58af42afdf24dd93d1a90abd Author: Andre Vehreschild Date: Wed Aug 21 11:22:57 2024 +0200 Remove unnecessary view_convert obsoleted by [PR86468]. This patch removes an unnecessary view_convert in trans_associate to prevent hard to find runtime errors in the future. The view_convert was erroneously introduced not understanding why ranks of the arrays to assign are different. The ranks are fixed by PR86468 now and the view_convert is obsolete. gcc/fortran/ChangeLog: PR fortran/86468 * trans-stmt.cc (trans_associate_var): Remove superfluous view_convert. Diff: --- gcc/fortran/trans-stmt.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index 023b1739b858..d92ca6477e4e 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -2031,9 +2031,7 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block) gfc_class_data_get (GFC_DECL_SAVED_DESCRIPTOR (tmp))); } else - gfc_add_modify (&se.pre, sym->backend_decl, - build1 (VIEW_CONVERT_EXPR, - TREE_TYPE (sym->backend_decl), se.expr)); + gfc_add_modify (&se.pre, sym->backend_decl, se.expr); if (unlimited) {
[gcc r15-3100] doc: Specifically link to GPL v3.0 for GM2
https://gcc.gnu.org/g:afa90807f68650c0596f8a3f00c1d47d79bed2f4 commit r15-3100-gafa90807f68650c0596f8a3f00c1d47d79bed2f4 Author: Gerald Pfeifer Date: Wed Aug 21 00:50:01 2024 +0200 doc: Specifically link to GPL v3.0 for GM2 The generic GPL link redirects to GPL v3.0 right now, but may redirect to a different version at one point. Specifically link to the version we are using gcc: * doc/gm2.texi (License): Specifically link to GPL v3.0 Diff: --- gcc/doc/gm2.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi index 1db07c91cf2c..a035011aa00a 100644 --- a/gcc/doc/gm2.texi +++ b/gcc/doc/gm2.texi @@ -3027,7 +3027,7 @@ These exist and can be found on the frontends web page on the @section License of GNU Modula-2 GNU Modula-2 is free software, the compiler is held under the GPL v3 -@uref{http://www.gnu.org/licenses/gpl.txt}, +@uref{http://www.gnu.org/licenses/gpl-3.0.txt}, its libraries (pim, iso and Logitech compatible) are under the GPL v3 with the GCC run time library exception clause.
[gcc r15-3101] fortran: Minor fix to -ffrontend-optimize description
https://gcc.gnu.org/g:a071fcda136d00f8321d0adc773007f4f45020ea commit r15-3101-ga071fcda136d00f8321d0adc773007f4f45020ea Author: Gerald Pfeifer Date: Fri Aug 23 10:02:15 2024 +0200 fortran: Minor fix to -ffrontend-optimize description gcc/fortran: * invoke.texi (Code Gen Options): Add a missing word. Diff: --- gcc/fortran/invoke.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 6bc42afe2c4f..8b3f81188483 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -2117,7 +2117,7 @@ if @option{-ffrontend-optimize} is in effect. @cindex Front-end optimization @item -ffrontend-optimize This option performs front-end optimization, based on manipulating -parts the Fortran parse tree. Enabled by default by any @option{-O} option +parts of the Fortran parse tree. Enabled by default by any @option{-O} option except @option{-O0} and @option{-Og}. Optimizations enabled by this option include: @itemize @bullet
[gcc r15-3102] ada: First controlling parameter aspect
https://gcc.gnu.org/g:8a41af72e060b150df3ce8a77120705155cb698e commit r15-3102-g8a41af72e060b150df3ce8a77120705155cb698e Author: Javier Miranda Date: Fri Jul 26 12:53:23 2024 + ada: First controlling parameter aspect This patch adds support for a new GNAT aspect/pragma that modifies the semantics of dispatching primitives. When a tagged type has this aspect/pragma, only subprograms that have the first parameter of this type will be considered dispatching primitives; this new pragma/aspect is inherited by all descendant types. gcc/ada/ * aspects.ads (Aspect_First_Controlling_Parameter): New aspect. Defined as implementation defined aspect that has a static boolean value and it is converted to pragma when the value is True. * einfo.ads (Has_First_Controlling_Parameter): New attribute. * exp_ch9.adb (Build_Corresponding_Record): Propagate the aspect to the corresponding record type. (Expand_N_Protected_Type_Declaration): Analyze the inherited aspect to add the pragma. (Expand_N_Task_Type_Declaration): ditto. * freeze.adb (Warn_If_Implicitly_Inherited_Aspects): New subprogram. (Has_First_Ctrl_Param_Aspect): New subprogram. (Freeze_Record_Type): Call Warn_If_Implicitly_Inherited_Aspects. (Freeze_Subprogram): Check illegal subprograms of tagged types and interface types that have this new aspect. * gen_il-fields.ads (Has_First_Controlling_Parameter): New entity field. * gen_il-gen-gen_entities.adb (Has_First_Controlling_Parameter): The new field is a semantic flag. * gen_il-internals.adb (Image): Add Has_First_Controlling_Parameter. * par-prag.adb (Prag): No action for Pragma_First_Controlling_Parameter since processing is handled entirely in Sem_Prag. * sem_ch12.adb (Validate_Private_Type_Instance): When the generic formal has this new aspect, check that the actual type also has this aspect. * sem_ch13.adb (Analyze_One_Aspect): Check that the aspect is applied to a tagged type or a concurrent type. * sem_ch3.adb (Analyze_Full_Type_Declaration): Derived tagged types inherit this new aspect, and also from their implemented interface types. (Process_Full_View): Propagate the aspect to the full view. * sem_ch6.adb (Is_A_Primitive): New subprogram; used to factor code and also clarify detection of primitives. * sem_ch9.adb (Check_Interfaces): Propagate this new aspect to the type implementing interface types. * sem_disp.adb (Check_Controlling_Formals): Handle tagged type that has the aspect and has subprograms overriding primitives of tagged types that lack this aspect. (Check_Dispatching_Operation): Warn on dispatching primitives disallowed by this new aspect. (Has_Predefined_Dispatching_Operation_Name): New subprogram. (Find_Dispatching_Type): Handle dispatching functions of tagged types that have the new aspect. (Find_Primitive_Covering_Interface): For primitives of tagged types that have the aspect and override a primitive of a parent type that does not have the aspect, we must temporarily unset attribute First_Controlling_ Parameter to properly check conformance. * sem_prag.ads (Aspect_Specifying_Pragma): Add new pragma. * sem_prag.adb (Pragma_First_Controlling_Parameter): Handle new pragma. * snames.ads-tmpl (Name_First_Controlling_Parameter): New name. * warnsw.ads (Warn_On_Non_Dispatching_Primitives): New warning. * warnsw.adb (Warn_On_Non_Dispatching_Primitives): New warning; not set by default when GNAT_Mode warnings are enabled, nor when all warnings are enabled (-gnatwa). Diff: --- gcc/ada/aspects.ads | 5 + gcc/ada/einfo.ads | 9 ++ gcc/ada/exp_ch9.adb | 73 ++ gcc/ada/freeze.adb | 279 gcc/ada/gen_il-fields.ads | 1 + gcc/ada/gen_il-gen-gen_entities.adb | 3 + gcc/ada/gen_il-internals.adb| 2 + gcc/ada/par-prag.adb| 1 + gcc/ada/sem_ch12.adb| 12 ++ gcc/ada/sem_ch13.adb| 52 +++ gcc/ada/sem_ch3.adb | 48 +++ gcc/ada/sem_ch6.adb | 83 +-- gcc/ada/sem_ch9.adb | 8 ++ gcc/ada/sem_disp.adb| 207 -- gcc/ada/sem_prag.adb| 86 +++ gcc/ada/sem_prag.ads
[gcc r15-3103] ada: Error missing when 'access is applied to an interface type object
https://gcc.gnu.org/g:aa95cd98575bd25e211d4ef0a025844575e752b4 commit r15-3103-gaa95cd98575bd25e211d4ef0a025844575e752b4 Author: Javier Miranda Date: Mon Aug 5 15:56:33 2024 + ada: Error missing when 'access is applied to an interface type object The compiler does not report an error when 'access is applied to a non-aliased class-wide interface type object. gcc/ada/ * exp_util.ads (Is_Expanded_Class_Wide_Interface_Object_Decl): New subprogram. * exp_util.adb (Is_Expanded_Class_Wide_Interface_Object_Decl): ditto. * sem_util.adb (Is_Aliased_View): Handle expanded class-wide type object declaration. * checks.adb (Is_Aliased_Unconstrained_Component): Protect the frontend against calling Is_Aliased_View with Empty. Found working on this issue. Diff: --- gcc/ada/checks.adb | 2 +- gcc/ada/exp_util.adb | 15 +++ gcc/ada/exp_util.ads | 5 + gcc/ada/sem_util.adb | 4 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 38fe687bc7aa..77043ca07c21 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -1549,7 +1549,7 @@ package body Checks is then if (Etype (N) = Typ or else (Do_Access and then Designated_Type (Typ) = S_Typ)) - and then not Is_Aliased_View (Lhs) + and then (No (Lhs) or else not Is_Aliased_View (Lhs)) then return; end if; diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index ef8c91dfe949..392bf3a511e6 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -8574,6 +8574,21 @@ package body Exp_Util is and then Is_Formal (Entity (N))); end Is_Conversion_Or_Reference_To_Formal; + -- + -- Is_Expanded_Class_Wide_Interface_Object_Decl -- + -- + + function Is_Expanded_Class_Wide_Interface_Object_Decl + (N : Node_Id) return Boolean is + begin + return not Comes_From_Source (N) +and then Nkind (Original_Node (N)) = N_Object_Declaration +and then Nkind (N) = N_Object_Renaming_Declaration +and then Is_Class_Wide_Type (Etype (Defining_Identifier (N))) +and then Is_Interface (Etype (Defining_Identifier (N))) +and then Nkind (Name (N)) = N_Explicit_Dereference; + end Is_Expanded_Class_Wide_Interface_Object_Decl; + -- -- Is_Finalizable_Transient -- -- diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 14d9e345b537..279feb2e6fe0 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -773,6 +773,11 @@ package Exp_Util is -- Return True if N is a type conversion, or a dereference thereof, or a -- reference to a formal parameter. + function Is_Expanded_Class_Wide_Interface_Object_Decl + (N : Node_Id) return Boolean; + -- Determine if N is the expanded code for a class-wide interface type + -- object declaration. + function Is_Finalizable_Transient (Decl : Node_Id; N: Node_Id) return Boolean; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 3f956098c6d8..ab7fcf8dfd11 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -15223,6 +15223,10 @@ package body Sem_Util is then return Is_Aliased_View (Expression (Obj)); + elsif Is_Expanded_Class_Wide_Interface_Object_Decl (Parent (Obj)) then + return Is_Aliased + (Defining_Identifier (Original_Node (Parent (Obj; + -- The dereference of an access-to-object value denotes an aliased view, -- but this routine uses the rules of the language so we need to exclude -- rewritten constructs that introduce artificial dereferences.
[gcc r15-3104] ada: First controlling parameter aspect
https://gcc.gnu.org/g:4522f1f6e31a606d1c9784eb5790b51e5e194bc7 commit r15-3104-g4522f1f6e31a606d1c9784eb5790b51e5e194bc7 Author: Javier Miranda Date: Mon Aug 5 20:03:01 2024 + ada: First controlling parameter aspect gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Temporarily remove reporting an error when the new aspect is set to True and the extensions are not enabled. Diff: --- gcc/ada/sem_ch13.adb | 3 --- 1 file changed, 3 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index f4ff3a282734..3487931bf4d7 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -4524,9 +4524,6 @@ package body Sem_Ch13 is if (No (Expr) or else Entity (Expr) = Standard_True) and then not Core_Extensions_Allowed then - Error_Msg_GNAT_Extension - ("'First_'Controlling_'Parameter", Sloc (Aspect), - Is_Core_Extension => True); goto Continue; end if;
[gcc r15-3105] ada: Fix validity checks for named parameter associations
https://gcc.gnu.org/g:8719b1843bc0f24a79433c8685d09cf822af0db7 commit r15-3105-g8719b1843bc0f24a79433c8685d09cf822af0db7 Author: Piotr Trojanek Date: Tue Jul 30 12:30:08 2024 +0200 ada: Fix validity checks for named parameter associations When iterating over actual and formal parameters, we should use First_Actual/Next_Actual and not simply First/Next, because the order of actual parameters might be different than the order of formal parameters obtained with First_Formal/Next_Formal. This patch fixes a glitch in validity checks for actual parameters and applies the same fix to other misuses of First/Next as well. gcc/ada/ * checks.adb (Ensure_Valid): Use First_Actual/Next_Actual. * exp_ch6.adb (Is_Direct_Deep_Call): Likewise. * exp_util.adb (Type_Of_Formal): Likewise. * sem_util.adb (Is_Container_Element): Likewise; cleanup membership test by using a subtype. Diff: --- gcc/ada/checks.adb | 4 ++-- gcc/ada/exp_ch6.adb | 4 ++-- gcc/ada/exp_util.adb | 4 ++-- gcc/ada/sem_util.adb | 10 -- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 77043ca07c21..343f027608b5 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -6840,7 +6840,7 @@ package body Checks is -- OUT parameter for which we are the argument. F := First_Formal (E); - A := First (L); + A := First_Actual (P); while Present (F) loop if A = N and then (Ekind (F) = E_Out_Parameter @@ -6850,7 +6850,7 @@ package body Checks is end if; Next_Formal (F); -Next (A); +Next_Actual (A); end loop; end if; end if; diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 24b754731d22..420d5f44a69e 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -3879,7 +3879,7 @@ package body Exp_Ch6 is Formal : Entity_Id; begin - Actual := First (Parameter_Associations (Call_Node)); + Actual := First_Actual (Call_Node); Formal := First_Formal (Subp); while Present (Actual) and then Present (Formal) @@ -3891,7 +3891,7 @@ package body Exp_Ch6 is return True; end if; - Next (Actual); + Next_Actual (Actual); Next_Formal (Formal); end loop; end; diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 392bf3a511e6..756638c52c24 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -13070,14 +13070,14 @@ package body Exp_Util is begin -- Examine the list of actual and formal parameters in parallel - A := First (Parameter_Associations (Call)); + A := First_Actual (Call); F := First_Formal (Entity (Name (Call))); while Present (A) and then Present (F) loop if A = Actual then return Etype (F); end if; -Next (A); +Next_Actual (A); Next_Formal (F); end loop; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ab7fcf8dfd11..688d9232b443 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -15918,10 +15918,8 @@ package body Sem_Util is elsif Nkind (Parent (Par)) = N_Object_Renaming_Declaration then return False; - elsif Nkind (Parent (Par)) in - N_Function_Call| - N_Procedure_Call_Statement | - N_Entry_Call_Statement + elsif Nkind (Parent (Par)) in N_Entry_Call_Statement + | N_Subprogram_Call then -- Check that the element is not part of an actual for an -- in-out parameter. @@ -15932,14 +15930,14 @@ package body Sem_Util is begin F := First_Formal (Entity (Name (Parent (Par; - A := First (Parameter_Associations (Parent (Par))); + A := First_Actual (Parent (Par)); while Present (F) loop if A = Par and then Ekind (F) /= E_In_Parameter then return False; end if; Next_Formal (F); -Next (A); +Next_Actual (A); end loop; end;
[gcc r15-3106] ada: Simplify validity checks for scalar parameters
https://gcc.gnu.org/g:f67d108dbcd499cd6db6cb59484c400301e4ebd9 commit r15-3106-gf67d108dbcd499cd6db6cb59484c400301e4ebd9 Author: Piotr Trojanek Date: Tue Jul 30 12:52:14 2024 +0200 ada: Simplify validity checks for scalar parameters Replace low-level iteration over formal and actual parameters with a call to high-level Find_Actual routine. Code cleanup; behavior is unaffected. gcc/ada/ * checks.adb (Ensure_Valid): Use Find_Actual. Diff: --- gcc/ada/checks.adb | 58 -- 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 343f027608b5..d13e7bb3269c 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -6799,60 +6799,18 @@ package body Checks is if Is_Scalar_Type (Typ) then declare - P : Node_Id; - N : Node_Id; - E : Entity_Id; - F : Entity_Id; - A : Node_Id; - L : List_Id; + Formal : Entity_Id; + Call : Node_Id; begin - -- Find actual argument (which may be a parameter association) - -- and the parent of the actual argument (the call statement) + Find_Actual (Expr, Formal, Call); - N := Expr; - P := Parent (Expr); - - if Nkind (P) = N_Parameter_Association then - N := P; - P := Parent (N); - end if; - - -- If this is an indirect or dispatching call, get signature - -- from the subprogram type. - - if Nkind (P) in N_Entry_Call_Statement - | N_Function_Call - | N_Procedure_Call_Statement + if Present (Formal) + and then + (Ekind (Formal) = E_Out_Parameter + or else Mechanism (Formal) = By_Reference) then - E := Get_Called_Entity (P); - L := Parameter_Associations (P); - - -- Only need to worry if there are indeed actuals, and if - -- this could be a subprogram call, otherwise we cannot get - -- a match (either we are not an argument, or the mode of - -- the formal is not OUT). This test also filters out the - -- generic case. - - if Is_Non_Empty_List (L) and then Is_Subprogram (E) then - - -- This is the loop through parameters, looking for an - -- OUT parameter for which we are the argument. - - F := First_Formal (E); - A := First_Actual (P); - while Present (F) loop -if A = N - and then (Ekind (F) = E_Out_Parameter - or else Mechanism (F) = By_Reference) -then - return; -end if; - -Next_Formal (F); -Next_Actual (A); - end loop; - end if; + return; end if; end; end if;
[gcc r15-3107] ada: Cleanup validity of boolean operators
https://gcc.gnu.org/g:ff356c0ab4cf514eaffc847df3c8717a5ee705d6 commit r15-3107-gff356c0ab4cf514eaffc847df3c8717a5ee705d6 Author: Piotr Trojanek Date: Tue Jul 30 16:17:29 2024 +0200 ada: Cleanup validity of boolean operators Move detection of always valid expressions from routine Ensure_Valid (which inserts validity checks) to Expr_Known_Valid (which decides their validity). In particular, this patch removes duplicated detection of boolean operators, which were recognized in both these routines. Code cleanup; behavior is unaffected. gcc/ada/ * checks.adb (Ensure_Valid): Remove detection of boolean and short-circuit operators. (Expr_Known_Valid): Detect short-circuit operators; detection of boolean operators was already done in this routine. Diff: --- gcc/ada/checks.adb | 16 +++- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index d13e7bb3269c..3650c070b7a0 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -6816,17 +6816,6 @@ package body Checks is end if; end if; - -- If this is a boolean expression, only its elementary operands need - -- checking: if they are valid, a boolean or short-circuit operation - -- with them will be valid as well. - - if Base_Type (Typ) = Standard_Boolean -and then - (Nkind (Expr) in N_Op or else Nkind (Expr) in N_Short_Circuit) - then - return; - end if; - -- If we fall through, a validity check is required Insert_Valid_Check (Expr, Related_Id, Is_Low_Bound, Is_High_Bound); @@ -6947,9 +6936,10 @@ package body Checks is return True; -- The result of a membership test is always valid, since it is true or - -- false, there are no other possibilities. + -- false, there are no other possibilities; same for short-circuit + -- operators. - elsif Nkind (Expr) in N_Membership_Test then + elsif Nkind (Expr) in N_Membership_Test | N_Short_Circuit then return True; -- For all other cases, we do not know the expression is valid
[gcc r15-3108] ada: Fix style in lines starting with assignment operator
https://gcc.gnu.org/g:0020cae9fba4409c4c776129c3c45c27b79edf62 commit r15-3108-g0020cae9fba4409c4c776129c3c45c27b79edf62 Author: Piotr Trojanek Date: Tue Jul 30 13:59:28 2024 +0200 ada: Fix style in lines starting with assignment operator Style cleanup; semantics is unaffected. Offending occurrences found with grep "^ *:=" and fixed manually. gcc/ada/ * checks.ads, cstand.adb, exp_aggr.adb, exp_ch4.adb, exp_ch5.adb, exp_dbug.adb, exp_util.adb, gnatlink.adb, lib-util.adb, libgnat/a-except.adb, libgnat/a-exexpr.adb, libgnat/a-ngcoar.adb, libgnat/s-rannum.adb, libgnat/s-trasym__dwarf.adb, osint.adb, rtsfind.adb, sem_case.adb, sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_ch6.adb, sem_eval.adb, sem_prag.adb, sem_util.adb: Fix style. Diff: --- gcc/ada/checks.ads | 4 +-- gcc/ada/cstand.adb | 4 +-- gcc/ada/exp_aggr.adb| 14 gcc/ada/exp_ch4.adb | 16 - gcc/ada/exp_ch5.adb | 10 +++--- gcc/ada/exp_dbug.adb| 4 +-- gcc/ada/exp_util.adb| 28 +++ gcc/ada/gnatlink.adb| 6 ++-- gcc/ada/lib-util.adb| 3 +- gcc/ada/libgnat/a-except.adb| 4 +-- gcc/ada/libgnat/a-exexpr.adb| 4 +-- gcc/ada/libgnat/a-ngcoar.adb| 4 +-- gcc/ada/libgnat/s-rannum.adb| 14 gcc/ada/libgnat/s-trasym__dwarf.adb | 16 - gcc/ada/osint.adb | 8 ++--- gcc/ada/rtsfind.adb | 4 +-- gcc/ada/sem_case.adb| 16 - gcc/ada/sem_ch12.adb| 18 +- gcc/ada/sem_ch13.adb| 12 +++ gcc/ada/sem_ch3.adb | 8 ++--- gcc/ada/sem_ch6.adb | 4 +-- gcc/ada/sem_eval.adb| 10 +++--- gcc/ada/sem_prag.adb| 20 +-- gcc/ada/sem_util.adb| 68 ++--- 24 files changed, 151 insertions(+), 148 deletions(-) diff --git a/gcc/ada/checks.ads b/gcc/ada/checks.ads index 322629a3c1f9..83d3fdb8329d 100644 --- a/gcc/ada/checks.ads +++ b/gcc/ada/checks.ads @@ -49,8 +49,8 @@ package Checks is record Elements : Bit_Vector (1 .. Dimensions); end record; - Empty_Dimension_Set : constant Dimension_Set - := (Dimensions => 0, Elements => (others => <>)); + Empty_Dimension_Set : constant Dimension_Set := + (Dimensions => 0, Elements => (others => <>)); procedure Initialize; -- Called for each new main source program, to initialize internal diff --git a/gcc/ada/cstand.adb b/gcc/ada/cstand.adb index 6b45d2521639..d2e4a6b0c827 100644 --- a/gcc/ada/cstand.adb +++ b/gcc/ada/cstand.adb @@ -1334,8 +1334,8 @@ package body CStand is -- used internally. They are unsigned types with the same length as -- the correspondingly named signed integer types. - Standard_Short_Short_Unsigned -:= New_Standard_Entity ("short_short_unsigned"); + Standard_Short_Short_Unsigned := +New_Standard_Entity ("short_short_unsigned"); Build_Unsigned_Integer_Type (Standard_Short_Short_Unsigned, Standard_Short_Short_Integer_Size); diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index aa6079d82b58..83b88e7cf734 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -7126,9 +7126,9 @@ package body Exp_Aggr is -- Determine whether this is an indexed aggregate (see RM 4.3.5(25/5)) - Is_Indexed_Aggregate -:= Sem_Aggr.Is_Indexed_Aggregate - (N, Add_Unnamed_Subp, New_Indexed_Subp); + Is_Indexed_Aggregate := +Sem_Aggr.Is_Indexed_Aggregate + (N, Add_Unnamed_Subp, New_Indexed_Subp); -- The constructor for bounded containers is a function with -- a parameter that sets the size of the container. If the @@ -7140,8 +7140,8 @@ package body Exp_Aggr is declare Count_Type : Entity_Id := Standard_Natural; Default: Node_Id := Empty; - Empty_First_Formal : constant Entity_Id -:= First_Formal (Entity (Empty_Subp)); + Empty_First_Formal : constant Entity_Id := + First_Formal (Entity (Empty_Subp)); Param_List : List_Id; begin @@ -7636,8 +7636,8 @@ package body Exp_Aggr is declare -- recursively get name for prefix - LHS_Prefix : constant Node_Id -:= Make_Delta_Choice_LHS (Prefix (Choice), Deep_Choice); + LHS_Prefix : constant Node_Id := +Make_Delta_Choice_LHS (Prefix (Choice), Deep_Choice); begin if Nkind (Choice) = N_Indexed_Component then return Make_Indexed_Component (Sloc (Choice), diff --git
[gcc r15-3109] ada: First controlling parameter aspect
https://gcc.gnu.org/g:92a9b5527b21b7af83cea8553d9b3224f29a commit r15-3109-g92a9b5527b21b7af83cea8553d9b3224f29a Author: Javier Miranda Date: Tue Aug 6 17:07:09 2024 + ada: First controlling parameter aspect gcc/ada/ * sem_ch6.adb (Check_Private_Overriding): Improve code detecting error on private function with controlling result. Fixes the regression of ACATS bde0003. Diff: --- gcc/ada/sem_ch6.adb | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 008c3a7ba139..461bdfcbe4b0 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -11535,8 +11535,16 @@ package body Sem_Ch6 is -- operation. That's illegal in the tagged case -- (but not if the private type is untagged). +-- Do not report this error when the tagged type has +-- the First_Controlling_Parameter aspect, unless the +-- function has a controlling result (which is only +-- possible if the function overrides an inherited +-- primitive). + if T = Base_Type (Etype (S)) - and then Has_Controlling_Result (S) + and then +(not Has_First_Controlling_Parameter_Aspect (T) + or else Has_Controlling_Result (S)) then Error_Msg_N ("private function with controlling result must" @@ -11550,7 +11558,9 @@ package body Sem_Ch6 is elsif Ekind (Etype (S)) = E_Anonymous_Access_Type and then T = Base_Type (Designated_Type (Etype (S))) - and then Has_Controlling_Result (S) + and then +(not Has_First_Controlling_Parameter_Aspect (T) + or else Has_Controlling_Result (S)) and then Ada_Version >= Ada_2012 then Error_Msg_N
[gcc r15-3110] ada: Emit a warning on inheritly limited types
https://gcc.gnu.org/g:dce0d46490cc3f929a5636902f47e2410719e33c commit r15-3110-gdce0d46490cc3f929a5636902f47e2410719e33c Author: Viljar Indus Date: Thu Aug 1 15:59:00 2024 +0300 ada: Emit a warning on inheritly limited types Record types that do not have a limited keyword but have a member with a limited type are also considered to be limited types. This can be confusing to understand for newer Ada users. It is better to emit a warning in this scenario and suggest that the type should be marked with a limited keyword. This diagnostic will be acticated when the -gnatw_l switch is used. gcc/ada/ * sem_ch3.adb: Add method Check_Inherited_Limted_Record for emitting the warning for an inherited limited type. * warnsw.adb: Add processing for the -gnatw_l switch that triggeres the inheritly limited type warning. * warnsw.ads: same as above. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add entry for -gnatw_l switch. * gnat_ugn.texi: Regenerate. Diff: --- .../building_executable_programs_with_gnat.rst | 17 +++ gcc/ada/gnat_ugn.texi | 27 - gcc/ada/sem_ch3.adb| 34 ++ gcc/ada/warnsw.adb | 3 +- gcc/ada/warnsw.ads | 7 + 5 files changed, 86 insertions(+), 2 deletions(-) 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 ce3ed0cc65a0..07ca2ea22c35 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 @@ -3430,6 +3430,23 @@ of the pragma in the :title:`GNAT_Reference_manual`). This switch suppresses listing of inherited aspects. +.. index:: -gnatw_l (gcc) + +:switch:`-gnatw_l` + *Activate warnings on inheritely limited types.* + + This switch causes the compiler trigger warnings on record types that do not + have a limited keyword but contain a component that is a limited type. + + +.. index:: -gnatw_L (gcc) + +:switch:`-gnatw_L` + *Suppress warnings on inheritely limited types.* + + This switch suppresses warnings on inheritely limited types. + + .. index:: -gnatwm (gcc) :switch:`-gnatwm` diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 0e3ee935552d..dcde9ea705bb 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -19,7 +19,7 @@ @copying @quotation -GNAT User's Guide for Native Platforms , Jul 29, 2024 +GNAT User's Guide for Native Platforms , Aug 19, 2024 AdaCore @@ -11671,6 +11671,31 @@ Pre’Class, and Post’Class aspects. Also list inherited subtype predicates. This switch suppresses listing of inherited aspects. @end table +@geindex -gnatw_l (gcc) + + +@table @asis + +@item @code{-gnatw_l} + +`Activate warnings on inheritely limited types.' + +This switch causes the compiler trigger warnings on record types that do not +have a limited keyword but contain a component that is a limited type. +@end table + +@geindex -gnatw_L (gcc) + + +@table @asis + +@item @code{-gnatw_L} + +`Suppress warnings on inheritely limited types.' + +This switch suppresses warnings on inheritely limited types. +@end table + @geindex -gnatwm (gcc) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 3b44f0a51001..4dac4eec1089 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -741,6 +741,11 @@ package body Sem_Ch3 is -- Check that an entity in a list of progenitors is an interface, -- emit error otherwise. + procedure Warn_On_Inherently_Limited_Type (E : Entity_Id); + -- Emit a warning if a record type that does not have a limited keyword in + -- its definition has any components that are limited (which implicitly + -- make the type limited). + --- -- Access_Definition -- --- @@ -22924,6 +22929,8 @@ package body Sem_Ch3 is Derive_Progenitor_Subprograms (T, T); end if; + Warn_On_Inherently_Limited_Type (T); + Check_Function_Writable_Actuals (N); end Record_Type_Declaration; @@ -23396,4 +23403,31 @@ package body Sem_Ch3 is Set_Is_Constrained (T); end Signed_Integer_Type_Declaration; + - + -- Warn_On_Inherently_Limited_Type -- + - + + procedure Warn_On_Inherently_Limited_Type (E : Entity_Id) is + C : Entity_Id; + begin + if Warnsw.Warn_On_Inherently_Limited_Type +and then not Is_Limited_Record (E) + then + C := First_Component (Base_Type (E)); + while Present (C) loop +if Is_Inherently_Limited_Type (Etype (C)) then + Error_Msg_Node_2 := E; + Error_Ms
[gcc r15-3111] ada: Update libraries with the limited flag
https://gcc.gnu.org/g:40903c7decc4632ce54617ea9d68ead3b126a52e commit r15-3111-g40903c7decc4632ce54617ea9d68ead3b126a52e Author: Viljar Indus Date: Fri Aug 2 09:09:10 2024 +0300 ada: Update libraries with the limited flag Records without a limited keyword now emit a warning if they contain a member that has an inherently limited type. gcc/ada/ * libgnat/a-coinho__shared.ads: add limited keyword. * libgnat/g-awk.adb: add limited keyword. * libgnat/g-comlin.ads: add limited keyword. * libgnat/s-excmac__arm.ads: add limited keyword. * libgnat/s-excmac__gcc.ads: add limited keyword. * libgnat/s-soflin.ads: add limited keyword. Diff: --- gcc/ada/libgnat/a-coinho__shared.ads | 2 +- gcc/ada/libgnat/g-awk.adb| 2 +- gcc/ada/libgnat/g-comlin.ads | 4 ++-- gcc/ada/libgnat/s-excmac__arm.ads| 2 +- gcc/ada/libgnat/s-excmac__gcc.ads| 2 +- gcc/ada/libgnat/s-soflin.ads | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/ada/libgnat/a-coinho__shared.ads b/gcc/ada/libgnat/a-coinho__shared.ads index ddab1fd7d93c..57abd1bafe3d 100644 --- a/gcc/ada/libgnat/a-coinho__shared.ads +++ b/gcc/ada/libgnat/a-coinho__shared.ads @@ -109,7 +109,7 @@ private type Holder_Access is access all Holder; - type Shared_Holder is record + type Shared_Holder is limited record Counter : System.Atomic_Counters.Atomic_Counter; Element : Element_Access; end record; diff --git a/gcc/ada/libgnat/g-awk.adb b/gcc/ada/libgnat/g-awk.adb index 62856d9204a8..c9284944dd55 100644 --- a/gcc/ada/libgnat/g-awk.adb +++ b/gcc/ada/libgnat/g-awk.adb @@ -261,7 +261,7 @@ package body GNAT.AWK is -- Session Data -- -- - type Session_Data is record + type Session_Data is limited record Current_File : Text_IO.File_Type; Current_Line : Unbounded_String; Separators : Split.Mode_Access; diff --git a/gcc/ada/libgnat/g-comlin.ads b/gcc/ada/libgnat/g-comlin.ads index c20cd5eb31ae..2a131e5d78cf 100644 --- a/gcc/ada/libgnat/g-comlin.ads +++ b/gcc/ada/libgnat/g-comlin.ads @@ -1045,7 +1045,7 @@ private type Depth is range 1 .. Max_Depth; - type Level is record + type Level is limited record Name_Last : Natural := 0; Dir : GNAT.Directory_Operations.Dir_Type; end record; @@ -1087,7 +1087,7 @@ private -- separators in the pattern. end record; - type Opt_Parser_Data (Arg_Count : Natural) is record + type Opt_Parser_Data (Arg_Count : Natural) is limited record Arguments : GNAT.OS_Lib.Argument_List_Access; -- null if reading from the command line diff --git a/gcc/ada/libgnat/s-excmac__arm.ads b/gcc/ada/libgnat/s-excmac__arm.ads index 23d02f85ff90..463191d6b426 100644 --- a/gcc/ada/libgnat/s-excmac__arm.ads +++ b/gcc/ada/libgnat/s-excmac__arm.ads @@ -154,7 +154,7 @@ package System.Exceptions.Machine is -- A GNAT exception object to be dealt with by the personality routine -- called by the GCC unwinding runtime. - type GNAT_GCC_Exception is record + type GNAT_GCC_Exception is limited record Header : Unwind_Control_Block; -- ABI Exception header first diff --git a/gcc/ada/libgnat/s-excmac__gcc.ads b/gcc/ada/libgnat/s-excmac__gcc.ads index 24899055506c..6cbc92654ec8 100644 --- a/gcc/ada/libgnat/s-excmac__gcc.ads +++ b/gcc/ada/libgnat/s-excmac__gcc.ads @@ -142,7 +142,7 @@ package System.Exceptions.Machine is -- A GNAT exception object to be dealt with by the personality routine -- called by the GCC unwinding runtime. - type GNAT_GCC_Exception is record + type GNAT_GCC_Exception is limited record Header : Unwind_Exception; -- ABI Exception header first diff --git a/gcc/ada/libgnat/s-soflin.ads b/gcc/ada/libgnat/s-soflin.ads index c2d947535d9a..61025e5961dc 100644 --- a/gcc/ada/libgnat/s-soflin.ads +++ b/gcc/ada/libgnat/s-soflin.ads @@ -339,7 +339,7 @@ package System.Soft_Links is -- specific data. This type is used to store the necessary data into the -- Task_Control_Block or into a global variable in the non tasking case. - type TSD is record + type TSD is limited record Pri_Stack_Info : aliased Stack_Checking.Stack_Info; -- Information on stack (Base/Limit/Size) used by System.Stack_Checking. -- If this TSD does not belong to the environment task, the Size field
[gcc r15-3112] ada: Eliminated-mode overflow check not eliminated
https://gcc.gnu.org/g:24c5396f8cd6e93010612f09fb77845559e30692 commit r15-3112-g24c5396f8cd6e93010612f09fb77845559e30692 Author: Steve Baird Date: Mon Aug 5 15:15:22 2024 -0700 ada: Eliminated-mode overflow check not eliminated If the Overflow_Mode in effect is Eliminated, then evaluating an arithmetic op such as addition or subtraction should not fail an overflow check. Fix a bug which resulted in such an overflow check failure. gcc/ada/ * checks.adb (Is_Signed_Integer_Arithmetic_Op): Return True in the case of relational operator whose operands are of a signed integer type. Diff: --- gcc/ada/checks.adb | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 3650c070b7a0..83879a519f7d 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -330,10 +330,11 @@ package body Checks is function Is_Signed_Integer_Arithmetic_Op (N : Node_Id) return Boolean; -- Returns True if node N is for an arithmetic operation with signed - -- integer operands. This includes unary and binary operators, and also - -- if and case expression nodes where the dependent expressions are of - -- a signed integer type. These are the kinds of nodes for which special - -- handling applies in MINIMIZED or ELIMINATED overflow checking mode. + -- integer operands. This includes unary and binary operators (including + -- comparison operators), and also if and case expression nodes which + -- yield a value of a signed integer type. + -- These are the kinds of nodes for which special handling applies in + -- MINIMIZED or ELIMINATED overflow checking mode. function Range_Or_Validity_Checks_Suppressed (Expr : Node_Id) return Boolean; @@ -8337,6 +8338,9 @@ package body Checks is => return Is_Signed_Integer_Type (Etype (N)); + when N_Op_Compare => +return Is_Signed_Integer_Type (Etype (Left_Opnd (N))); + when N_Case_Expression | N_If_Expression =>
[gcc r15-3113] ada: Implicit_Dereference aspect specification for subtype incorrectly accepted
https://gcc.gnu.org/g:7dd9c7d1293ad16708748f617e10263e4ee88a39 commit r15-3113-g7dd9c7d1293ad16708748f617e10263e4ee88a39 Author: Steve Baird Date: Tue Aug 6 14:44:54 2024 -0700 ada: Implicit_Dereference aspect specification for subtype incorrectly accepted Implicit_Dereference is a type-specific aspect and therefore cannot be legally specified as part of a subtype declaration. gcc/ada/ * sem_ch13.adb (Analyze_Aspect_Implicit_Dereference): Generate error if an aspect specification specifies the Implicit_Dereference aspect of a non-first subtype. Diff: --- gcc/ada/sem_ch13.adb | 5 + 1 file changed, 5 insertions(+) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 0546aa37de78..a55ba3c7bd9a 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1982,6 +1982,11 @@ package body Sem_Ch13 is Error_Msg_N ("aspect must apply to a type with discriminants", Expr); + elsif not Is_First_Subtype (E) then + Error_Msg_N +("aspect not specifiable in a subtype declaration", + Aspect); + elsif not Is_Entity_Name (Expr) then Error_Msg_N ("aspect must name a discriminant of current type", Expr);
[gcc r15-3114] ada: Crash on string interpolation with custom string types
https://gcc.gnu.org/g:a7ff045c4492738b62b486d81ae4618990b73539 commit r15-3114-ga7ff045c4492738b62b486d81ae4618990b73539 Author: Javier Miranda Date: Wed Aug 7 17:41:42 2024 + ada: Crash on string interpolation with custom string types The compiler crashes when processing an object declaration of a custom string type initialized with an interpolated string. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference: [Put_Image]): Add support for custom string types. * exp_ch2.adb (Expand_N_Interpolated_String_Literal): Add a type conversion to the result object declaration of custom string types. * exp_put_image.adb (Build_String_Put_Image_Call): Handle custom string types. Diff: --- gcc/ada/exp_attr.adb | 28 +++- gcc/ada/exp_ch2.adb | 14 ++ gcc/ada/exp_put_image.adb | 36 +++- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 6475308f71b9..84c7a4bbdeeb 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -6006,6 +6006,7 @@ package body Exp_Attr is when Attribute_Put_Image => Put_Image : declare use Exp_Put_Image; U_Type : constant Entity_Id := Underlying_Type (Entity (Pref)); + C_Type : Entity_Id; Pname : Entity_Id; Decl : Node_Id; @@ -6031,6 +6032,21 @@ package body Exp_Attr is end if; if No (Pname) then +if Is_String_Type (U_Type) then + declare + R : constant Entity_Id := Root_Type (U_Type); + + begin + if Is_Private_Type (R) then + C_Type := Component_Type (Full_View (R)); + else + C_Type := Component_Type (R); + end if; + + C_Type := Root_Type (Underlying_Type (C_Type)); + end; +end if; + -- If Put_Image is disabled, call the "unknown" version if not Put_Image_Enabled (U_Type) then @@ -6046,7 +6062,17 @@ package body Exp_Attr is Analyze (N); return; -elsif Is_Standard_String_Type (U_Type) then +-- String type objects, including custom string types, and +-- excluding C arrays. + +elsif Is_String_Type (U_Type) + and then C_Type in Standard_Character + | Standard_Wide_Character + | Standard_Wide_Wide_Character + and then (not RTU_Loaded (Interfaces_C) + or else Enclosing_Lib_Unit_Entity (U_Type) +/= RTU_Entity (Interfaces_C)) +then Rewrite (N, Build_String_Put_Image_Call (N)); Analyze (N); return; diff --git a/gcc/ada/exp_ch2.adb b/gcc/ada/exp_ch2.adb index 958f4299b73a..99a169475250 100644 --- a/gcc/ada/exp_ch2.adb +++ b/gcc/ada/exp_ch2.adb @@ -768,6 +768,7 @@ package body Exp_Ch2 is New_Occurrence_Of (Sink_Entity, Loc; Actions : constant List_Id := New_List; + U_Type : constant Entity_Id := Underlying_Type (Etype (N)); Elem_Typ : Entity_Id; Str_Elem : Node_Id; @@ -810,6 +811,19 @@ package body Exp_Ch2 is Next (Str_Elem); end loop; + -- Add a type conversion to the result object declaration of custom + -- string types. + + if not Is_Standard_String_Type (U_Type) + and then (not RTU_Loaded (Interfaces_C) + or else Enclosing_Lib_Unit_Entity (U_Type) + /= RTU_Entity (Interfaces_C)) + then +Set_Expression (Result_Decl, + Convert_To (Etype (N), +Relocate_Node (Expression (Result_Decl; + end if; + Append_To (Actions, Result_Decl); return Make_Expression_With_Actions (Loc, diff --git a/gcc/ada/exp_put_image.adb b/gcc/ada/exp_put_image.adb index 217c38a30e75..190ac99b5653 100644 --- a/gcc/ada/exp_put_image.adb +++ b/gcc/ada/exp_put_image.adb @@ -417,14 +417,48 @@ package body Exp_Put_Image is Lib_RE : RE_Id; use Stand; begin + pragma Assert (Is_String_Type (U_Type)); + pragma Assert (not RTU_Loaded (Interfaces_C) +or else Enclosing_Lib_Unit_Entity (U_Type) + /= RTU_Entity (Interfaces_C)); + if R = Standard_String then Lib_RE := RE_Put_Image_String; elsif R = Standard_Wide_String then Lib_RE := RE_Put_Image_Wide_String; elsif R = Standard_Wide_Wide_String then Lib_RE := RE_Put_Image_Wide_Wide_String; + else - raise Program_Error; + -- Handle custom s
[gcc r15-3115] ada: Fix incorrect tracebacks on Windows
https://gcc.gnu.org/g:509cc70fbbba911722a428f3a8bb01edbb90a7eb commit r15-3115-g509cc70fbbba911722a428f3a8bb01edbb90a7eb Author: Sebastian Poeplau Date: Wed Aug 7 11:21:25 2024 +0200 ada: Fix incorrect tracebacks on Windows PECOFF symbols don't have a size attached to them. The symbol size that System.Object_Reader.Read_Symbol guesses to make up for the lack of information can be wrong when the symbol table doesn't match the algorithm's expectations; in particular that's the case when function symbols aren't sorted by address. To avoid incorrect tracebacks caused by wrong symbol size guesses, don't use the symbol size for PECOFF files when producing a traceback and instead pick the symbol with the highest address lower than the target address. gcc/ada/ * libgnat/s-dwalin.adb (Symbolic_Address): Ignore symbol size in address-to-symbol translation for PECOFF files. Diff: --- gcc/ada/libgnat/s-dwalin.adb | 26 +- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/ada/libgnat/s-dwalin.adb b/gcc/ada/libgnat/s-dwalin.adb index 46a7d61e78db..028a55d1f20b 100644 --- a/gcc/ada/libgnat/s-dwalin.adb +++ b/gcc/ada/libgnat/s-dwalin.adb @@ -1753,6 +1753,7 @@ package body System.Dwarf_Lines is Success : Boolean; Done : Boolean; S: Object_Symbol; + Closest_S: Object_Symbol := Null_Symbol; begin -- Initialize result @@ -1801,7 +1802,22 @@ package body System.Dwarf_Lines is else S := First_Symbol (C.Obj.all); while S /= Null_Symbol loop -if Spans (S, Addr_Int) then +if Format (C.Obj.all) = PECOFF + or else Format (C.Obj.all) = PECOFF_PLUS +then + -- Don't use the size of symbols from PECOFF files; it's + -- just a guess and can be unreliable. Instead, iterate + -- over the entire symbol table and use the symbol with the + -- highest address lower than Addr_Int. + + if Closest_S = Null_Symbol + or else (Closest_S.Value < S.Value + and then S.Value <= Addr_Int) + then + Closest_S := S; + end if; + +elsif Spans (S, Addr_Int) then Subprg_Name := Object_Reader.Name (C.Obj.all, S); exit; end if; @@ -1809,6 +1825,14 @@ package body System.Dwarf_Lines is S := Next_Symbol (C.Obj.all, S); end loop; + if (Format (C.Obj.all) = PECOFF + or else Format (C.Obj.all) = PECOFF_PLUS) + and then Closest_S /= Null_Symbol + then +S := Closest_S; -- for consistency with non-PECOFF +Subprg_Name := Object_Reader.Name (C.Obj.all, S); + end if; + -- Search address in aranges table Aranges_Lookup (C, Addr, Info_Offset, Success);
[gcc r15-3116] ada: String interpolation: report error without Extensions allowed
https://gcc.gnu.org/g:87bdd17829e93bf98d8984d6a16ed25081af6c0d commit r15-3116-g87bdd17829e93bf98d8984d6a16ed25081af6c0d Author: Javier Miranda Date: Sun Aug 11 11:11:29 2024 + ada: String interpolation: report error without Extensions allowed The compiler does not report the correct error in occurrences of interpolated strings, when the sources are compiled without language extensions allowed. gcc/ada/ * scng.adb (Scan): Call Error_Msg_GNAT_Extension() to report an error, when the sources are compiled without Core_Extensions_ Allowed, and the scanner detects the beginning of an interpolated string. Diff: --- gcc/ada/scng.adb | 36 +++- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb index 08ce2ab5ad1c..658970fbab2d 100644 --- a/gcc/ada/scng.adb +++ b/gcc/ada/scng.adb @@ -2135,14 +2135,19 @@ package body Scng is -- Lower case letters when 'a' .. 'z' => -if Core_Extensions_Allowed - and then Source (Scan_Ptr) = 'f' +if Source (Scan_Ptr) = 'f' and then Source (Scan_Ptr + 1) = '"' then - Scan_Ptr := Scan_Ptr + 1; - Accumulate_Checksum (Source (Scan_Ptr)); - Token := Tok_Left_Interpolated_String; - return; + if Core_Extensions_Allowed then + Scan_Ptr := Scan_Ptr + 1; + Accumulate_Checksum (Source (Scan_Ptr)); + Token := Tok_Left_Interpolated_String; + return; + else + Error_Msg_GNAT_Extension +("interpolated string", Scan_Ptr, + Is_Core_Extension => True); + end if; end if; Name_Len := 1; @@ -2155,15 +2160,20 @@ package body Scng is -- Upper case letters when 'A' .. 'Z' => -if Core_Extensions_Allowed - and then Source (Scan_Ptr) = 'F' +if Source (Scan_Ptr) = 'F' and then Source (Scan_Ptr + 1) = '"' then - Error_Msg_S - ("delimiter of interpolated string must be in lowercase"); - Scan_Ptr := Scan_Ptr + 1; - Token := Tok_Left_Interpolated_String; - return; + if Core_Extensions_Allowed then + Error_Msg_S +("delimiter of interpolated string must be in lowercase"); + Scan_Ptr := Scan_Ptr + 1; + Token := Tok_Left_Interpolated_String; + return; + else + Error_Msg_GNAT_Extension +("interpolated string", Scan_Ptr, + Is_Core_Extension => True); + end if; end if; Token_Contains_Uppercase := True;
[gcc r15-3117] ada: Fix crash on aliased variable with packed array type and -g switch
https://gcc.gnu.org/g:19c22fbea31ae421d5b09a9d0b4f91438310ac45 commit r15-3117-g19c22fbea31ae421d5b09a9d0b4f91438310ac45 Author: Eric Botcazou Date: Mon Aug 5 13:06:17 2024 +0200 ada: Fix crash on aliased variable with packed array type and -g switch This comes from a loophole in gnat_get_array_descr_info for record types containing a template, which represent an aliased array, when this array type is bit-packed and implemented as a modular integer. gcc/ada/ * gcc-interface/misc.cc (gnat_get_array_descr_info): Test the BIT_PACKED_ARRAY_TYPE_P flag only once on the final debug type. In the case of records containing a template, replay the entire processing for the array type contained therein. Diff: --- gcc/ada/gcc-interface/misc.cc | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc index f77629ce70bf..13cb39e91cbe 100644 --- a/gcc/ada/gcc-interface/misc.cc +++ b/gcc/ada/gcc-interface/misc.cc @@ -784,7 +784,7 @@ gnat_get_array_descr_info (const_tree const_type, { tree type = const_cast (const_type); tree first_dimen, dimen; - bool is_bit_packed_array, is_array; + bool is_array; int i; /* Temporaries created in the first pass and used in the second one for thin @@ -797,12 +797,7 @@ gnat_get_array_descr_info (const_tree const_type, /* If we have an implementation type for a packed array, get the original array type. */ if (TYPE_IMPL_PACKED_ARRAY_P (type) && TYPE_ORIGINAL_PACKED_ARRAY (type)) -{ - is_bit_packed_array = BIT_PACKED_ARRAY_TYPE_P (type); - type = TYPE_ORIGINAL_PACKED_ARRAY (type); -} - else -is_bit_packed_array = false; +type = TYPE_ORIGINAL_PACKED_ARRAY (type); /* First pass: gather all information about this array except everything related to dimensions. */ @@ -833,6 +828,14 @@ gnat_get_array_descr_info (const_tree const_type, tree array_field = DECL_CHAIN (bounds_field); tree array_type = TREE_TYPE (array_field); + /* Replay the entire processing for array types. */ + if (TYPE_CAN_HAVE_DEBUG_TYPE_P (array_type) + && TYPE_DEBUG_TYPE (array_type)) +array_type = TYPE_DEBUG_TYPE (array_type); + if (TYPE_IMPL_PACKED_ARRAY_P (array_type) + && TYPE_ORIGINAL_PACKED_ARRAY (array_type)) +array_type = TYPE_ORIGINAL_PACKED_ARRAY (array_type); + /* Shift back the address to get the address of the template. */ tree shift_amount = fold_build1 (NEGATE_EXPR, sizetype, byte_position (array_field)); @@ -859,9 +862,7 @@ gnat_get_array_descr_info (const_tree const_type, /* If this array has fortran convention, it's arranged in column-major order, so our view here has reversed dimensions. */ const bool convention_fortran_p = TYPE_CONVENTION_FORTRAN_P (first_dimen); - - if (BIT_PACKED_ARRAY_TYPE_P (first_dimen)) -is_bit_packed_array = true; + const bool is_bit_packed_array = BIT_PACKED_ARRAY_TYPE_P (first_dimen); /* ??? For row major ordering, we probably want to emit nothing and instead specify it as the default in Dw_TAG_compile_unit. */
[gcc r15-3118] Fix test failure on powerpc targets
https://gcc.gnu.org/g:a8ae8f9c2ed055b9e4408209f1c724493c5a3e3c commit r15-3118-ga8ae8f9c2ed055b9e4408209f1c724493c5a3e3c Author: Bernd Edlinger Date: Fri Aug 23 06:22:55 2024 +0200 Fix test failure on powerpc targets Apparently due to slightly different optimization levels not always both subroutines have multiple subranges, but having at least one such, and no lexical blocks is sufficient to prove that the fix worked. Q.E.D. So reduce the test expectations to only at least one inlined subroutine with multiple subranges. gcc/testsuite/ChangeLog: PR other/116462 * gcc.dg/debug/dwarf2/inline7.c: Reduce test expectations. Diff: --- gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c index 48d457216b10..083df5b586cd 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c @@ -1,9 +1,9 @@ -/* Verify that both inline instances have a DW_AT_ranges but - no extra DW_TAG_lexical_block. */ +/* Verify that at least one of both inline instances have + a DW_AT_ranges but no extra DW_TAG_lexical_block. */ /* { dg-options "-O -gdwarf -dA" } */ /* { dg-do compile } */ /* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_inlined_subroutine" 2 } } */ -/* { dg-final { scan-assembler-times " DW_AT_ranges" 2 } } */ +/* { dg-final { scan-assembler " DW_AT_ranges" } } */ /* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_lexical_block" 0 } } */ static int foo (int i)
[gcc r15-3119] RISC-V: Expand vec abs without masking.
https://gcc.gnu.org/g:c22d57cdc52d990eb7d353fa82c67882bc824d40 commit r15-3119-gc22d57cdc52d990eb7d353fa82c67882bc824d40 Author: Robin Dapp Date: Fri Aug 9 15:05:39 2024 +0200 RISC-V: Expand vec abs without masking. Standard abs synthesis during expand is max (a, -a). This expansion has the advantage of avoiding masking and is thus potentially faster than the a < 0 ? -a : a synthesis. gcc/ChangeLog: * config/riscv/autovec.md (abs2): Expand via max (a, -a). gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/abs-rv32gcv.c: Adjust test expectation. * gcc.target/riscv/rvv/autovec/unop/abs-rv64gcv.c: Ditto. * gcc.target/riscv/rvv/autovec/vls/abs-2.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-1.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-2.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-3.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-4.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-5.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-6.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-7.c: Ditto. * gcc.target/riscv/rvv/autovec/cond/cond_unary-8.c: Ditto. Diff: --- gcc/config/riscv/autovec.md| 26 +++--- .../riscv/rvv/autovec/cond/cond_unary-1.c | 6 +++-- .../riscv/rvv/autovec/cond/cond_unary-2.c | 6 +++-- .../riscv/rvv/autovec/cond/cond_unary-3.c | 6 +++-- .../riscv/rvv/autovec/cond/cond_unary-4.c | 6 +++-- .../riscv/rvv/autovec/cond/cond_unary-5.c | 6 +++-- .../riscv/rvv/autovec/cond/cond_unary-6.c | 6 +++-- .../riscv/rvv/autovec/cond/cond_unary-7.c | 6 +++-- .../riscv/rvv/autovec/cond/cond_unary-8.c | 6 +++-- .../riscv/rvv/autovec/unop/abs-rv32gcv.c | 6 ++--- .../riscv/rvv/autovec/unop/abs-rv64gcv.c | 6 ++--- .../gcc.target/riscv/rvv/autovec/vls/abs-2.c | 2 +- 12 files changed, 47 insertions(+), 41 deletions(-) diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index decfe2bf8cc8..4decaedbd826 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -1073,29 +1073,19 @@ [(set_attr "type" "vialu")]) ;; --- -;; - [INT] ABS expansion to vmslt and vneg. +;; - [INT] ABS expansion to vneg and vmax. ;; --- -(define_insn_and_split "abs2" +(define_expand "abs2" [(set (match_operand:V_VLSI 0 "register_operand") - (abs:V_VLSI - (match_operand:V_VLSI 1 "register_operand")))] - "TARGET_VECTOR && can_create_pseudo_p ()" - "#" - "&& 1" - [(const_int 0)] +(smax:V_VLSI + (match_dup 0) + (neg:V_VLSI + (match_operand:V_VLSI 1 "register_operand"] + "TARGET_VECTOR" { - rtx zero = gen_const_vec_duplicate (mode, GEN_INT (0)); - machine_mode mask_mode = riscv_vector::get_mask_mode (mode); - rtx mask = gen_reg_rtx (mask_mode); - riscv_vector::expand_vec_cmp (mask, LT, operands[1], zero); - - rtx ops[] = {operands[0], mask, operands[1], operands[1]}; - riscv_vector::emit_vlmax_insn (code_for_pred (NEG, mode), - riscv_vector::UNARY_OP_TAMU, ops); DONE; -} -[(set_attr "type" "vector")]) +}) ;; --- ;; [FP] Unary operations diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_unary-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_unary-1.c index 2233c6eeecb9..4866b221ca4a 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_unary-1.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_unary-1.c @@ -36,8 +36,10 @@ TEST_ALL (DEF_LOOP) -/* NOTE: int abs operator is converted to vmslt + vneg.v */ -/* { dg-final { scan-assembler-times {\tvneg\.v\tv[0-9]+,v[0-9]+,v0\.t} 8 } } */ +/* NOTE: int abs operator is converted to vneg.v + vmax.vv */ +/* { dg-final { scan-assembler-times {\tvneg\.v\tv[0-9]+,v[0-9]+} 8 } } */ +/* { dg-final { scan-assembler-times {\tvmax\.vv\tv[0-9]+,v[0-9]+,v[0-9]+} 4 } } */ +/* { dg-final { scan-assembler-times {\tvneg\.v\tv[0-9]+,v[0-9]+,v0\.t} 4 } } */ /* { dg-final { scan-assembler-times {\tvnot\.v\tv[0-9]+,v[0-9]+,v0\.t} 4 } } */ /* { dg-final { scan-assembler-times {\tvfabs\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */ /* { dg-final { scan-assembler-times {\tvfneg\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_unary-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_unary-2.c index 4886bff67d86..651df9f86461 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_unary-2.c +++ b/gcc/testsu
[gcc r15-3120] optabs-query: Use opt_machine_mode for smallest_int_mode_for_size [PR115495].
https://gcc.gnu.org/g:96fe95bac67c7303dc811c04f5e99cc959a7182a commit r15-3120-g96fe95bac67c7303dc811c04f5e99cc959a7182a Author: Robin Dapp Date: Tue Aug 20 14:02:09 2024 +0200 optabs-query: Use opt_machine_mode for smallest_int_mode_for_size [PR115495]. In get_best_extraction_insn we use smallest_int_mode_for_size with struct_bits as size argument. PR115495 has struct_bits = 256 and we don't have a mode for that. This patch makes smallest_mode_for_size and smallest_int_mode_for_size return opt modes so we can just skip over the loop when there is no mode. PR middle-end/115495 gcc/ChangeLog: * cfgexpand.cc (expand_debug_expr): Require mode. * combine.cc (make_extraction): Ditto. * config/aarch64/aarch64.cc (aarch64_expand_cpymem): Ditto. (aarch64_expand_setmem): Ditto. * config/arc/arc.cc (arc_expand_cpymem): Ditto. * config/arm/arm.cc (arm_expand_divmod_libfunc): Ditto. * config/i386/i386.cc (ix86_get_mask_mode): Ditto. * config/rs6000/predicates.md: Ditto. * config/rs6000/rs6000.cc (vspltis_constant): Ditto. * config/s390/s390.cc (s390_expand_insv): Ditto. * config/sparc/sparc.cc (assign_int_registers): Ditto. * coverage.cc (get_gcov_type): Ditto. (get_gcov_unsigned_t): Ditto. * dse.cc (find_shift_sequence): Ditto. * expmed.cc (store_integral_bit_field): Ditto. * expr.cc (convert_mode_scalar): Ditto. (op_by_pieces_d::smallest_fixed_size_mode_for_size): Ditto. (emit_block_move_via_oriented_loop): Ditto. (copy_blkmode_to_reg): Ditto. (store_field): Ditto. * internal-fn.cc (expand_arith_overflow): Ditto. * machmode.h (HAVE_MACHINE_MODES): Ditto. (smallest_mode_for_size): Use opt_machine_mode. (smallest_int_mode_for_size): Use opt_scalar_int_mode. * optabs-query.cc (get_best_extraction_insn): Require mode. * optabs.cc (expand_twoval_binop_libfunc): Ditto. * stor-layout.cc (smallest_mode_for_size): Return opt_machine_mode. (layout_type): Require mode. (initialize_sizetypes): Ditto. * tree-ssa-loop-manip.cc (canonicalize_loop_ivs): Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr115495.c: New test. gcc/ada/ChangeLog: * gcc-interface/utils2.cc (fast_modulo_reduction): Require mode. (nonbinary_modular_operation): Ditto. Diff: --- gcc/ada/gcc-interface/utils2.cc | 5 +++-- gcc/cfgexpand.cc | 2 +- gcc/combine.cc| 2 +- gcc/config/aarch64/aarch64.cc | 6 -- gcc/config/arc/arc.cc | 2 +- gcc/config/arm/arm.cc | 2 +- gcc/config/i386/i386.cc | 4 ++-- gcc/config/rs6000/predicates.md | 2 +- gcc/config/rs6000/rs6000.cc | 2 +- gcc/config/s390/s390.cc | 2 +- gcc/config/sparc/sparc.cc | 2 +- gcc/coverage.cc | 5 +++-- gcc/dse.cc| 3 ++- gcc/expmed.cc | 3 ++- gcc/expr.cc | 17 + gcc/internal-fn.cc| 4 ++-- gcc/machmode.h| 10 +- gcc/optabs-query.cc | 1 + gcc/optabs.cc | 3 ++- gcc/stor-layout.cc| 16 +--- gcc/testsuite/gcc.target/riscv/rvv/autovec/pr115495.c | 9 + gcc/tree-ssa-loop-manip.cc| 2 +- 22 files changed, 62 insertions(+), 42 deletions(-) diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index 0d7e03ec6b07..8eebf5935960 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -661,7 +661,7 @@ fast_modulo_reduction (tree op, tree modulus, unsigned int precision) if (type_precision < BITS_PER_WORD) { const scalar_int_mode m - = smallest_int_mode_for_size (type_precision + 1); + = smallest_int_mode_for_size (type_precision + 1).require (); tree new_type = gnat_type_for_mode (m, 1); op = fold_convert (new_type, op); modulus = fold_convert (new_type, modulus); @@ -721,7 +721,8 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, for its mode since ope
[gcc r15-3121] libcpp: bump padding size in _cpp_convert_input [PR116458]
https://gcc.gnu.org/g:b2c1d7c4573d3b938f44b3bda202adeb292b1cbc commit r15-3121-gb2c1d7c4573d3b938f44b3bda202adeb292b1cbc Author: Alexander Monakov Date: Thu Aug 22 21:09:47 2024 +0300 libcpp: bump padding size in _cpp_convert_input [PR116458] The recently introduced search_line_fast_ssse3 raised padding requirement from 16 to 64, which was adjusted in read_file_guts, but the corresponding ' + 16' in _cpp_convert_input was overlooked. libcpp/ChangeLog: PR preprocessor/116458 * charset.cc (_cpp_convert_input): Bump padding to 64 if HAVE_SSSE3. Diff: --- libcpp/charset.cc | 21 - 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libcpp/charset.cc b/libcpp/charset.cc index d58319a500a1..79072877cbf7 100644 --- a/libcpp/charset.cc +++ b/libcpp/charset.cc @@ -3093,6 +3093,7 @@ _cpp_convert_input (cpp_reader *pfile, const char *input_charset, struct cset_converter input_cset; struct _cpp_strbuf to; unsigned char *buffer; + size_t pad; input_cset = init_iconv_desc (pfile, SOURCE_CHARSET, input_charset); if (input_cset.func == convert_no_conversion) @@ -3129,16 +3130,18 @@ _cpp_convert_input (cpp_reader *pfile, const char *input_charset, } } +#ifdef HAVE_SSSE3 + pad = 64; +#else + pad = 16; +#endif /* Resize buffer if we allocated substantially too much, or if we - haven't enough space for the \n-terminator or following - 15 bytes of padding (used to quiet warnings from valgrind or - Address Sanitizer, when the optimized lexer accesses aligned - 16-byte memory chunks, including the bytes after the malloced, - area, and stops lexing on '\n'). */ - if (to.len + 4096 < to.asize || to.len + 16 > to.asize) -to.text = XRESIZEVEC (uchar, to.text, to.len + 16); - - memset (to.text + to.len, '\0', 16); + don't have enough space for the following padding, which allows + search_line_fast to use (possibly misaligned) vector loads. */ + if (to.len + 4096 < to.asize || to.len + pad > to.asize) +to.text = XRESIZEVEC (uchar, to.text, to.len + pad); + + memset (to.text + to.len, '\0', pad); /* If the file is using old-school Mac line endings (\r only), terminate with another \r, not an \n, so that we do not mistake
[gcc r15-3122] Match: Support form 4 for unsigned integer .SAT_TRUNC
https://gcc.gnu.org/g:07988874c340e575521473b01dc98c8a1b2886b5 commit r15-3122-g07988874c340e575521473b01dc98c8a1b2886b5 Author: Pan Li Date: Tue Aug 20 15:44:38 2024 +0800 Match: Support form 4 for unsigned integer .SAT_TRUNC This patch would like to support the form 4 of the unsigned integer .SAT_TRUNC. Aka below example: Form 4: #define DEF_SAT_U_TRUC_FMT_4(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_4 (WT x) \ { \ bool not_overflow = x <= (WT)(NT)(-1); \ return ((NT)x) | (NT)((NT)not_overflow - 1); \ } DEF_SAT_U_TRUC_FMT_4(uint32_t, uint64_t) Before this patch: 4 │ __attribute__((noinline)) 5 │ uint8_t sat_u_truc_uint32_t_to_uint8_t_fmt_4 (uint32_t x) 6 │ { 7 │ _Bool not_overflow; 8 │ unsigned char _1; 9 │ unsigned char _2; 10 │ unsigned char _3; 11 │ uint8_t _6; 12 │ 13 │ ;; basic block 2, loop depth 0 14 │ ;;pred: ENTRY 15 │ not_overflow_5 = x_4(D) <= 255; 16 │ _1 = (unsigned char) x_4(D); 17 │ _2 = (unsigned char) not_overflow_5; 18 │ _3 = _2 + 255; 19 │ _6 = _1 | _3; 20 │ return _6; 21 │ ;;succ: EXIT 22 │ 23 │ } After this patch: 4 │ __attribute__((noinline)) 5 │ uint8_t sat_u_truc_uint32_t_to_uint8_t_fmt_4 (uint32_t x) 6 │ { 7 │ uint8_t _6; 8 │ 9 │ ;; basic block 2, loop depth 0 10 │ ;;pred: ENTRY 11 │ _6 = .SAT_TRUNC (x_4(D)); [tail call] 12 │ return _6; 13 │ ;;succ: EXIT 14 │ 15 │ } The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. gcc/ChangeLog: * match.pd: Add form 4 for unsigned .SAT_TRUNC matching. Signed-off-by: Pan Li Diff: --- gcc/match.pd | 18 ++ 1 file changed, 18 insertions(+) diff --git a/gcc/match.pd b/gcc/match.pd index 65a3aae22430..78f1957e8c78 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3325,6 +3325,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) } (if (otype_precision < itype_precision && wi::eq_p (trunc_max, int_cst)) +/* Unsigned saturation truncate, case 3, sizeof (WT) > sizeof (NT). + SAT_U_TRUNC = (NT)X | ((NT)(X <= (WT)-1) + (NT)-1). */ +(match (unsigned_integer_sat_trunc @0) + (bit_ior:c (plus:c (convert (le @0 INTEGER_CST@1)) INTEGER_CST@2) + (convert @0)) + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && TYPE_UNSIGNED (TREE_TYPE (@0))) + (with + { + unsigned itype_precision = TYPE_PRECISION (TREE_TYPE (@0)); + unsigned otype_precision = TYPE_PRECISION (type); + wide_int trunc_max = wi::mask (otype_precision, false, itype_precision); + wide_int max = wi::mask (otype_precision, false, otype_precision); + wide_int int_cst_1 = wi::to_wide (@1); + wide_int int_cst_2 = wi::to_wide (@2); + } + (if (wi::eq_p (trunc_max, int_cst_1) && wi::eq_p (max, int_cst_2)) + /* x > y && x != XXX_MIN --> x > y x > y && x == XXX_MIN --> false . */ (for eqne (eq ne)
[gcc r15-3123] Revert "Fortran: Fix class transformational intrinsic calls [PR102689]"
https://gcc.gnu.org/g:f9f599a44e3156a5f5679adc048ec6ff2f44cc0e commit r15-3123-gf9f599a44e3156a5f5679adc048ec6ff2f44cc0e Author: Paul Thomas Date: Fri Aug 23 13:16:53 2024 +0100 Revert "Fortran: Fix class transformational intrinsic calls [PR102689]" This reverts commit 4cb07a38233aadb4b389a6e5236c95f52241b6e0. Diff: --- gcc/fortran/trans-array.cc | 146 +++ gcc/fortran/trans-expr.cc | 57 +- .../gfortran.dg/class_transformational_1.f90 | 204 - .../gfortran.dg/class_transformational_2.f90 | 103 --- 4 files changed, 35 insertions(+), 475 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index ea5fff2e0c29..8c35926436d7 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -1301,28 +1301,23 @@ get_array_ref_dim_for_loop_dim (gfc_ss *ss, int loop_dim) is a class expression. */ static tree -get_class_info_from_ss (stmtblock_t * pre, gfc_ss *ss, tree *eltype, - gfc_ss **fcnss) +get_class_info_from_ss (stmtblock_t * pre, gfc_ss *ss, tree *eltype) { - gfc_ss *loop_ss = ss->loop->ss; gfc_ss *lhs_ss; gfc_ss *rhs_ss; - gfc_ss *fcn_ss = NULL; tree tmp; tree tmp2; tree vptr; - tree class_expr = NULL_TREE; + tree rhs_class_expr = NULL_TREE; tree lhs_class_expr = NULL_TREE; bool unlimited_rhs = false; bool unlimited_lhs = false; bool rhs_function = false; - bool unlimited_arg1 = false; gfc_symbol *vtab; - tree cntnr = NULL_TREE; /* The second element in the loop chain contains the source for the - class temporary created in gfc_trans_create_temp_array. */ - rhs_ss = loop_ss->loop_chain; + temporary; ie. the rhs of the assignment. */ + rhs_ss = ss->loop->ss->loop_chain; if (rhs_ss != gfc_ss_terminator && rhs_ss->info @@ -1331,58 +1326,28 @@ get_class_info_from_ss (stmtblock_t * pre, gfc_ss *ss, tree *eltype, && rhs_ss->info->data.array.descriptor) { if (rhs_ss->info->expr->expr_type != EXPR_VARIABLE) - class_expr + rhs_class_expr = gfc_get_class_from_expr (rhs_ss->info->data.array.descriptor); else - class_expr = gfc_get_class_from_gfc_expr (rhs_ss->info->expr); + rhs_class_expr = gfc_get_class_from_gfc_expr (rhs_ss->info->expr); unlimited_rhs = UNLIMITED_POLY (rhs_ss->info->expr); if (rhs_ss->info->expr->expr_type == EXPR_FUNCTION) rhs_function = true; } - /* Usually, ss points to the function. When the function call is an actual - argument, it is instead rhs_ss because the ss chain is shifted by one. */ - *fcnss = fcn_ss = rhs_function ? rhs_ss : ss; - - /* If this is a transformational function with a class result, the info - class_container field points to the class container of arg1. */ - if (class_expr != NULL_TREE - && fcn_ss->info && fcn_ss->info->expr - && fcn_ss->info->expr->expr_type == EXPR_FUNCTION - && fcn_ss->info->expr->value.function.isym - && fcn_ss->info->expr->value.function.isym->transformational) -{ - cntnr = ss->info->class_container; - unlimited_arg1 - = UNLIMITED_POLY (fcn_ss->info->expr->value.function.actual->expr); -} - /* For an assignment the lhs is the next element in the loop chain. If we have a class rhs, this had better be a class variable - expression! Otherwise, the class container from arg1 can be used - to set the vptr and len fields of the result class container. */ + expression! */ lhs_ss = rhs_ss->loop_chain; - if (lhs_ss && lhs_ss != gfc_ss_terminator - && lhs_ss->info && lhs_ss->info->expr + if (lhs_ss != gfc_ss_terminator + && lhs_ss->info + && lhs_ss->info->expr && lhs_ss->info->expr->expr_type ==EXPR_VARIABLE && lhs_ss->info->expr->ts.type == BT_CLASS) { tmp = lhs_ss->info->data.array.descriptor; unlimited_lhs = UNLIMITED_POLY (rhs_ss->info->expr); } - else if (cntnr != NULL_TREE) -{ - tmp = gfc_class_vptr_get (class_expr); - gfc_add_modify (pre, tmp, fold_convert (TREE_TYPE (tmp), - gfc_class_vptr_get (cntnr))); - if (unlimited_rhs) - { - tmp = gfc_class_len_get (class_expr); - if (unlimited_arg1) - gfc_add_modify (pre, tmp, gfc_class_len_get (cntnr)); - } - tmp = NULL_TREE; -} else tmp = NULL_TREE; @@ -1390,33 +1355,35 @@ get_class_info_from_ss (stmtblock_t * pre, gfc_ss *ss, tree *eltype, if (tmp != NULL_TREE && lhs_ss->loop_chain == gfc_ss_terminator) lhs_class_expr = gfc_get_class_from_expr (tmp); else -return class_expr; +return rhs_class_expr; gcc_assert (GFC_CLASS_TYPE_P (TREE_TYPE (lhs_class_expr))); /* Set the lhs vptr and, if necessary, the _len field. */ - if (class_expr) + if (rhs_class_expr) { /*
[gcc r15-3124] libstdc++: Make std::vector::reference constructor private [PR115098]
https://gcc.gnu.org/g:b25b101bc380004b82e25d2b1ef306856c75d864 commit r15-3124-gb25b101bc380004b82e25d2b1ef306856c75d864 Author: Jonathan Wakely Date: Wed Aug 21 21:19:46 2024 +0100 libstdc++: Make std::vector::reference constructor private [PR115098] The standard says this constructor should be private. LWG 4141 proposes to remove it entirely. We still need it, but it doesn't need to be public. For std::bitset the default constructor is already private (and never even defined) but there's a non-standard constructor that's public, but doesn't need to be. libstdc++-v3/ChangeLog: PR libstdc++/115098 * include/bits/stl_bvector.h (_Bit_reference): Make default constructor private. Declare vector and bit iterators as friends. * include/std/bitset (bitset::reference): Make constructor and data members private. * testsuite/20_util/bitset/115098.cc: New test. * testsuite/23_containers/vector/bool/115098.cc: New test. Diff: --- libstdc++-v3/include/bits/stl_bvector.h| 12 +--- libstdc++-v3/include/std/bitset| 5 + libstdc++-v3/testsuite/20_util/bitset/115098.cc| 11 +++ libstdc++-v3/testsuite/23_containers/vector/bool/115098.cc | 8 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index c45b7ff3320d..42261ac5915f 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -81,6 +81,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER struct _Bit_reference { + private: +template friend class vector; +friend struct _Bit_iterator; +friend struct _Bit_const_iterator; + +_GLIBCXX20_CONSTEXPR +_Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { } + _Bit_type * _M_p; _Bit_type _M_mask; @@ -88,9 +96,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _Bit_reference(_Bit_type * __x, _Bit_type __y) : _M_p(__x), _M_mask(__y) { } -_GLIBCXX20_CONSTEXPR -_Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { } - + public: #if __cplusplus >= 201103L _Bit_reference(const _Bit_reference&) = default; #endif diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset index e5d677ff059c..2e82a0e289d5 100644 --- a/libstdc++-v3/include/std/bitset +++ b/libstdc++-v3/include/std/bitset @@ -870,10 +870,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _WordT* _M_wp; size_t _M_bpos; - // left undefined - reference(); - - public: _GLIBCXX23_CONSTEXPR reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT { @@ -881,6 +877,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_bpos = _Base::_S_whichbit(__pos); } + public: #if __cplusplus >= 201103L reference(const reference&) = default; #endif diff --git a/libstdc++-v3/testsuite/20_util/bitset/115098.cc b/libstdc++-v3/testsuite/20_util/bitset/115098.cc new file mode 100644 index ..52d6a0ec3781 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/115098.cc @@ -0,0 +1,11 @@ +// { dg-do compile { target c++11 } } + +#include + +using namespace std; + +static_assert( ! is_default_constructible::reference>::value, +"std::bitset::reference is not default constructible"); + +static_assert( ! is_constructible::reference, bitset<10>&, size_t>::value, +"std::bitset::reference is not default constructible"); diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/115098.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/115098.cc new file mode 100644 index ..3df8b8017950 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/115098.cc @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } + +#include + +static_assert( +!std::is_default_constructible::reference>::value, +"std::vector::reference is not default constructible" +);
[gcc r15-3125] libstdc++: Simplify C++20 implementation of std::variant
https://gcc.gnu.org/g:0bb26524ae43ffe6a1e54941f467f59931f921b3 commit r15-3125-g0bb26524ae43ffe6a1e54941f467f59931f921b3 Author: Jonathan Wakely Date: Tue Aug 20 18:07:32 2024 +0100 libstdc++: Simplify C++20 implementation of std::variant For C++20 the __detail::__variant::_Uninitialized primary template can be used for all types, because _Variant_union can have a non-trivially destructible union member in C++20, and the constrained user-provided destructor will ensure we don't destroy inactive objects. Since we always use the primary template for C++20, we don't need the _Uninitialized::_M_get accessors to abstract the difference between the primary template and the partial specialization. That allows us to simplify __get_n for C++20 too. Also improve the comments that explain the uses of _Uninitialized and when/why _Variant_union needs a user-provided destructor. libstdc++-v3/ChangeLog: * include/std/variant [C++20] (_Uninitialized): Always use the primary template. [C++20] (__get_n): Access the _M_storage member directly. Diff: --- libstdc++-v3/include/std/variant | 83 ++-- 1 file changed, 37 insertions(+), 46 deletions(-) diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 5fb7770d8891..08c5395b54d9 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -54,10 +54,9 @@ // C++ < 20 || __cpp_concepts < 202002L || __cpp_constexpr < 201811L #if __cpp_lib_variant < 202106L -# include // Use __aligned_membuf instead of union. +# include // Use __aligned_membuf for storage. #endif - namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -209,17 +208,18 @@ namespace __variant __as(const std::variant<_Types...>&& __v) noexcept { return std::move(__v); } - // For C++17: - // _Uninitialized is guaranteed to be a trivially destructible type, - // even if T is not. - // For C++20: - // _Uninitialized is trivially destructible iff T is, so _Variant_union - // needs a constrained non-trivial destructor. +#if __cpp_lib_variant < 202106L template> struct _Uninitialized; +#else + template +struct _Uninitialized; +#endif - template -struct _Uninitialized<_Type, true> + // The primary template is used for trivially destructible types in C++17, + // and for all types in C++20. + template +struct _Uninitialized { template constexpr @@ -227,6 +227,7 @@ namespace __variant : _M_storage(std::forward<_Args>(__args)...) { } +#if __cpp_lib_variant < 202106L constexpr const _Type& _M_get() const & noexcept { return _M_storage; } @@ -238,46 +239,18 @@ namespace __variant constexpr _Type&& _M_get() && noexcept { return std::move(_M_storage); } +#endif _Type _M_storage; }; +#if __cpp_lib_variant < 202106L + // This partial specialization is used for non-trivially destructible types + // in C++17, so that _Uninitialized is trivially destructible and can be + // used as a union member in _Variadic_union. template struct _Uninitialized<_Type, false> { -#if __cpp_lib_variant >= 202106L - template - constexpr - _Uninitialized(in_place_index_t<0>, _Args&&... __args) - : _M_storage(std::forward<_Args>(__args)...) - { } - - constexpr ~_Uninitialized() { } - - _Uninitialized(const _Uninitialized&) = default; - _Uninitialized(_Uninitialized&&) = default; - _Uninitialized& operator=(const _Uninitialized&) = default; - _Uninitialized& operator=(_Uninitialized&&) = default; - - constexpr const _Type& _M_get() const & noexcept - { return _M_storage; } - - constexpr _Type& _M_get() & noexcept - { return _M_storage; } - - constexpr const _Type&& _M_get() const && noexcept - { return std::move(_M_storage); } - - constexpr _Type&& _M_get() && noexcept - { return std::move(_M_storage); } - - struct _Empty_byte { }; - - union { - _Empty_byte _M_empty; - _Type _M_storage; - }; -#else template constexpr _Uninitialized(in_place_index_t<0>, _Args&&... __args) @@ -299,7 +272,6 @@ namespace __variant { return std::move(*_M_storage._M_ptr()); } __gnu_cxx::__aligned_membuf<_Type> _M_storage; -#endif }; template @@ -316,6 +288,22 @@ namespace __variant return __variant::__get_n<_Np - 3>( std::forward<_Union>(__u)._M_rest._M_rest._M_rest); } +#else + template +constexpr auto&& +__get_n(_Union&& __u) noexcept +{ + if constexpr (_Np == 0) + return std::forward<_Union>(__u)._M_first._M_storage; + else if constexpr (_Np == 1) + return std::forward<_Union>(__u)._M_rest._M_first._M_storage; + else if constexpr (_Np == 2) + retur
[gcc r15-3126] libstdc++: Use noexcept insted of throw() in src/c++11/debug.cc
https://gcc.gnu.org/g:9115593d8517d210ffe7da2c8ec786342381e471 commit r15-3126-g9115593d8517d210ffe7da2c8ec786342381e471 Author: Jonathan Wakely Date: Wed Aug 21 12:22:58 2024 +0100 libstdc++: Use noexcept insted of throw() in src/c++11/debug.cc libstdc++-v3/ChangeLog: * src/c++11/debug.cc: Replace throw() with noexcept. Diff: --- libstdc++-v3/src/c++11/debug.cc | 32 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc index 5d6bb5b7547a..e3880318e5c3 100644 --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -380,7 +380,7 @@ namespace __gnu_debug __gnu_cxx::__mutex& _Safe_sequence_base:: - _M_get_mutex() throw () + _M_get_mutex() noexcept { return get_safe_base_mutex(this); } void @@ -393,7 +393,7 @@ namespace __gnu_debug void _Safe_sequence_base:: - _M_attach_single(_Safe_iterator_base* __it, bool __constant) throw () + _M_attach_single(_Safe_iterator_base* __it, bool __constant) noexcept { _Safe_iterator_base*& __its = __constant ? _M_const_iterators : _M_iterators; @@ -414,7 +414,7 @@ namespace __gnu_debug void _Safe_sequence_base:: - _M_detach_single(_Safe_iterator_base* __it) throw () + _M_detach_single(_Safe_iterator_base* __it) noexcept { // Remove __it from this sequence's list __it->_M_unlink(); @@ -443,7 +443,7 @@ namespace __gnu_debug void _Safe_iterator_base:: - _M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw () + _M_attach_single(_Safe_sequence_base* __seq, bool __constant) noexcept { _M_detach_single(); @@ -478,7 +478,7 @@ namespace __gnu_debug void _Safe_iterator_base:: - _M_detach_single() throw () + _M_detach_single() noexcept { if (_M_sequence) { @@ -489,7 +489,7 @@ namespace __gnu_debug void _Safe_iterator_base:: - _M_reset() throw () + _M_reset() noexcept { reset_sequence_ptr(_M_sequence); // Do not reset version, so that a detached iterator does not look like a @@ -501,17 +501,17 @@ namespace __gnu_debug bool _Safe_iterator_base:: - _M_singular() const throw () + _M_singular() const noexcept { return !_M_sequence || _M_version != _M_sequence->_M_version; } bool _Safe_iterator_base:: - _M_can_compare(const _Safe_iterator_base& __x) const throw () + _M_can_compare(const _Safe_iterator_base& __x) const noexcept { return _M_sequence == __x._M_sequence; } __gnu_cxx::__mutex& _Safe_iterator_base:: - _M_get_mutex() throw () + _M_get_mutex() noexcept { return _M_sequence->_M_get_mutex(); } _Safe_unordered_container_base* @@ -538,7 +538,7 @@ namespace __gnu_debug void _Safe_local_iterator_base:: - _M_attach_single(_Safe_sequence_base* __cont, bool __constant) throw () + _M_attach_single(_Safe_sequence_base* __cont, bool __constant) noexcept { _M_detach_single(); @@ -566,7 +566,7 @@ namespace __gnu_debug void _Safe_local_iterator_base:: - _M_detach_single() throw () + _M_detach_single() noexcept { if (_M_sequence) { @@ -608,7 +608,7 @@ namespace __gnu_debug void _Safe_unordered_container_base:: - _M_attach_local_single(_Safe_iterator_base* __it, bool __constant) throw () + _M_attach_local_single(_Safe_iterator_base* __it, bool __constant) noexcept { _Safe_iterator_base*& __its = __constant ? _M_const_local_iterators : _M_local_iterators; @@ -629,7 +629,7 @@ namespace __gnu_debug void _Safe_unordered_container_base:: - _M_detach_local_single(_Safe_iterator_base* __it) throw () + _M_detach_local_single(_Safe_iterator_base* __it) noexcept { // Remove __it from this container's list __it->_M_unlink(); @@ -1233,7 +1233,7 @@ namespace namespace __gnu_debug { _Error_formatter& - _Error_formatter::_M_message(_Debug_msg_id __id) const throw () + _Error_formatter::_M_message(_Debug_msg_id __id) const noexcept { return const_cast<_Error_formatter*>(this) ->_M_message(_S_debug_messages[__id]); @@ -1334,7 +1334,7 @@ namespace __gnu_debug template void _Error_formatter::_M_format_word(char*, int, const char*, _Tp) -const throw () +const noexcept { } void @@ -1346,7 +1346,7 @@ namespace __gnu_debug { } void - _Error_formatter::_M_get_max_length() const throw () + _Error_formatter::_M_get_max_length() const noexcept { } // Instantiations.
[gcc r15-3127] libstdc++: Make debug sequence members mutable [PR116369]
https://gcc.gnu.org/g:a35dd276cbf6236e08bcf6e56e62c2be41cf6e3c commit r15-3127-ga35dd276cbf6236e08bcf6e56e62c2be41cf6e3c Author: Jonathan Wakely Date: Wed Aug 21 12:29:32 2024 +0100 libstdc++: Make debug sequence members mutable [PR116369] We need to be able to attach debug mode iterators to const containers, so the safe iterator constructor uses const_cast to get a modifiable pointer to the container. If the container was defined as const, that const_cast to access its members results in undefined behaviour. PR 116369 shows a case where it results in a segfault because the container is in a rodata section (which shouldn't have happened, but the undefined behaviour in the library still exists in any case). This makes the _M_iterators and _M_const_iterators data members mutable, so that it's safe to modify them even if the declared type of the container is a const type. Ideally we would not need the const_cast at all. Instead, the _M_attach member (and everything it calls) should be const-qualified. That would work fine now, because the members that it ends up modifying are mutable. Making that change would require a number of new exports from the shared library, and would require retaining the old non-const member functions (maybe as symbol aliases) for backwards compatibility. That might be worth changing at some point, but isn't done here. libstdc++-v3/ChangeLog: PR c++/116369 * include/debug/safe_base.h (_Safe_sequence_base::_M_iterators): Add mutable specifier. (_Safe_sequence_base::_M_const_iterators): Likewise. Diff: --- libstdc++-v3/include/debug/safe_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/debug/safe_base.h b/libstdc++-v3/include/debug/safe_base.h index d5fbe4b1320b..88d7f0b05c8b 100644 --- a/libstdc++-v3/include/debug/safe_base.h +++ b/libstdc++-v3/include/debug/safe_base.h @@ -205,10 +205,10 @@ namespace __gnu_debug public: /// The list of mutable iterators that reference this container -_Safe_iterator_base* _M_iterators; +mutable _Safe_iterator_base* _M_iterators; /// The list of constant iterators that reference this container -_Safe_iterator_base* _M_const_iterators; +mutable _Safe_iterator_base* _M_const_iterators; /// The container version number. This number may never be 0. mutable unsigned int _M_version;
[gcc r15-3128] tree-optimization/116463 - complex lowering leaves around dead stmts
https://gcc.gnu.org/g:de1923f9f4d5344694c22ca883aeb15caf635734 commit r15-3128-gde1923f9f4d5344694c22ca883aeb15caf635734 Author: Richard Biener Date: Fri Aug 23 13:44:29 2024 +0200 tree-optimization/116463 - complex lowering leaves around dead stmts Complex lowering generally replaces existing complex defs with COMPLEX_EXPRs but those might be dead when it can always refer to components from the lattice. This in turn can pessimize followup transforms like forwprop and reassoc, the following makes sure to get rid of dead COMPLEX_EXPRs generated by using simple_dce_from_worklist. PR tree-optimization/116463 * tree-complex.cc: Include tree-ssa-dce.h. (dce_worklist): New global. (update_complex_assignment): Add SSA def to the DCE worklist. (tree_lower_complex): Perform DCE. Diff: --- gcc/tree-complex.cc | 9 + 1 file changed, 9 insertions(+) diff --git a/gcc/tree-complex.cc b/gcc/tree-complex.cc index dfb45b9d91cf..7480c07640e1 100644 --- a/gcc/tree-complex.cc +++ b/gcc/tree-complex.cc @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "case-cfn-macros.h" #include "builtins.h" #include "optabs-tree.h" +#include "tree-ssa-dce.h" /* For each complex ssa name, a lattice value. We're interested in finding out whether a complex number is degenerate in some way, having only real @@ -88,6 +89,9 @@ static vec phis_to_revisit; /* BBs that need EH cleanup. */ static bitmap need_eh_cleanup; +/* SSA defs we should try to DCE. */ +static bitmap dce_worklist; + /* Lookup UID in the complex_variable_components hashtable and return the associated tree. */ static tree @@ -731,6 +735,7 @@ update_complex_assignment (gimple_stmt_iterator *gsi, tree r, tree i) update_stmt (stmt); if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt)) bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index); + bitmap_set_bit (dce_worklist, SSA_NAME_VERSION (gimple_assign_lhs (stmt))); update_complex_components (gsi, gsi_stmt (*gsi), r, i); } @@ -1962,6 +1967,7 @@ tree_lower_complex (void) complex_propagate.ssa_propagate (); need_eh_cleanup = BITMAP_ALLOC (NULL); + dce_worklist = BITMAP_ALLOC (NULL); complex_variable_components = new int_tree_htab_type (10); @@ -2008,6 +2014,9 @@ tree_lower_complex (void) gsi_commit_edge_inserts (); + simple_dce_from_worklist (dce_worklist, need_eh_cleanup); + BITMAP_FREE (dce_worklist); + unsigned todo = gimple_purge_all_dead_eh_edges (need_eh_cleanup) ? TODO_cleanup_cfg : 0; BITMAP_FREE (need_eh_cleanup);
[gcc r15-3129] libstdc++: Fix std::random_shuffle for low RAND_MAX [PR88935]
https://gcc.gnu.org/g:125bab23ad75449333983c9389898c5b92b3aa0d commit r15-3129-g125bab23ad75449333983c9389898c5b92b3aa0d Author: Giovanni Bajo Date: Wed Jul 31 20:03:40 2024 +0100 libstdc++: Fix std::random_shuffle for low RAND_MAX [PR88935] When RAND_MAX is small and the number of elements being shuffled is close to it, we get very uneven distributions in std::random_shuffle. This uses a simple xorshift generator seeded by std::rand if we can't rely on std::rand itself. libstdc++-v3/ChangeLog: PR libstdc++/88935 * include/bits/stl_algo.h (random_shuffle) [RAND_MAX < INT_MAX]: Use xorshift instead of rand(). * testsuite/25_algorithms/random_shuffle/88935.cc: New test. Co-authored-by: Jonathan Wakely Signed-off-by: Giovanni Bajo Diff: --- libstdc++-v3/include/bits/stl_algo.h | 42 +- .../25_algorithms/random_shuffle/88935.cc | 24 + 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 541f53b2..778a37ac46f4 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -4521,15 +4521,39 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO _RandomAccessIterator>) __glibcxx_requires_valid_range(__first, __last); - if (__first != __last) - for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) - { - // XXX rand() % N is not uniformly distributed - _RandomAccessIterator __j = __first - + std::rand() % ((__i - __first) + 1); - if (__i != __j) - std::iter_swap(__i, __j); - } + if (__first == __last) + return; + +#if RAND_MAX < __INT_MAX__ + if (__builtin_expect((__last - __first) >= RAND_MAX / 4, 0)) + { + // Use a xorshift implementation seeded by two calls to rand() + // instead of using rand() for all the random numbers needed. + unsigned __xss + = (unsigned)std::rand() ^ ((unsigned)std::rand() << 15); + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + { + __xss += !__xss; + __xss ^= __xss << 13; + __xss ^= __xss >> 17; + __xss ^= __xss << 5; + _RandomAccessIterator __j = __first + + (__xss % ((__i - __first) + 1)); + if (__i != __j) + std::iter_swap(__i, __j); + } + return; + } +#endif + + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + { + // XXX rand() % N is not uniformly distributed + _RandomAccessIterator __j = __first + + (std::rand() % ((__i - __first) + 1)); + if (__i != __j) + std::iter_swap(__i, __j); + } } /** diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/88935.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/88935.cc new file mode 100644 index ..30dca2a897a3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/88935.cc @@ -0,0 +1,24 @@ +// { dg-do run } +// { dg-options "-Wno-deprecated-declarations" } + +// Bug 88935 std::random_shuffle does not work if the sequence +// is longer than RAND_MAX elements + +#include +#include +#include + +int main() +{ + const std::size_t N = 3; + std::vector v(N, (unsigned char)0); + std::fill(v.begin() + (N / 5 * 4), v.end(), (unsigned char)1); + std::random_shuffle(v.begin(), v.end()); + double sum = 0; + for (std::size_t i = 0; i < v.size(); ++i) + { +sum += v[i]; +if (i > 0 && i % (N / 100) == 0) + VERIFY( (sum / i) < 0.3 ); + } +}
[gcc r15-3130] libstdc++: Define operator== for hash table iterators [PR115939]
https://gcc.gnu.org/g:591b71993f15ed95eb38f3314f3d9ac159b9d051 commit r15-3130-g591b71993f15ed95eb38f3314f3d9ac159b9d051 Author: Jonathan Wakely Date: Tue Jul 16 09:43:06 2024 +0100 libstdc++: Define operator== for hash table iterators [PR115939] Currently iterators for unordered containers do not directly define operator== and operator!= overloads. Instead they rely on the base class defining them, which is done so that iterator and const_iterator comparisons work using the same overloads. However this means a derived-to-base conversion is needed to call those operators, and PR libstdc++/115939 shows that this can be ambiguous (for -pedantic) when another overloaded operator could be used after an implicit conversion. This change defines operator== and operator!= directly for _Node_iterator and _Node_const_iterator so that no derived-to-base conversions are needed. The new overloads just forward to the base class ones, so the implementation is still shared and doesn't need to be duplicated. libstdc++-v3/ChangeLog: PR libstdc++/115939 * include/bits/hashtable_policy.h (_Node_iterator): Add operator== and operator!=. (_Node_const_iterator): Likewise. * testsuite/23_containers/unordered_map/115939.cc: New test. Diff: --- libstdc++-v3/include/bits/hashtable_policy.h | 80 +- .../23_containers/unordered_map/115939.cc | 29 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 26def24f24e6..1b9d9aae1a71 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -464,6 +464,23 @@ namespace __detail this->_M_incr(); return __tmp; } + +#if __cpp_impl_three_way_comparison >= 201907L + friend bool + operator==(const _Node_iterator&, const _Node_iterator&) = default; +#else + friend bool + operator==(const _Node_iterator& __x, const _Node_iterator& __y) noexcept + { + const __base_type& __bx = __x; + const __base_type& __by = __y; + return __bx == __by; + } + + friend bool + operator!=(const _Node_iterator& __x, const _Node_iterator& __y) noexcept + { return !(__x == __y); } +#endif }; /// Node const_iterators, used to iterate through all the hashtable. @@ -475,6 +492,10 @@ namespace __detail using __base_type = _Node_iterator_base<_Value, __cache>; using __node_type = typename __base_type::__node_type; + // The corresponding non-const iterator. + using __iterator + = _Node_iterator<_Value, __constant_iterators, __cache>; + public: typedef _Value value_type; typedef std::ptrdiff_t difference_type; @@ -489,8 +510,7 @@ namespace __detail _Node_const_iterator(__node_type* __p) noexcept : __base_type(__p) { } - _Node_const_iterator(const _Node_iterator<_Value, __constant_iterators, - __cache>& __x) noexcept + _Node_const_iterator(const __iterator& __x) noexcept : __base_type(__x._M_cur) { } reference @@ -515,6 +535,62 @@ namespace __detail this->_M_incr(); return __tmp; } + +#if __cpp_impl_three_way_comparison >= 201907L + friend bool + operator==(const _Node_const_iterator&, +const _Node_const_iterator&) = default; + + friend bool + operator==(const _Node_const_iterator& __x, const __iterator& __y) + { + const __base_type& __bx = __x; + const __base_type& __by = __y; + return __bx == __by; + } +#else + friend bool + operator==(const _Node_const_iterator& __x, +const _Node_const_iterator& __y) noexcept + { + const __base_type& __bx = __x; + const __base_type& __by = __y; + return __bx == __by; + } + + friend bool + operator!=(const _Node_const_iterator& __x, +const _Node_const_iterator& __y) noexcept + { return !(__x == __y); } + + friend bool + operator==(const _Node_const_iterator& __x, +const __iterator& __y) noexcept + { + const __base_type& __bx = __x; + const __base_type& __by = __y; + return __bx == __by; + } + + friend bool + operator!=(const _Node_const_iterator& __x, +const __iterator& __y) noexcept + { return !(__x == __y); } + + friend bool + operator==(const __iterator& __x, +const _Node_const_iterator& __y) noexcept + { + const __base_type& __bx = __x; + const __base_type& __by = __y; + return __bx == __by; + } + + friend bool + operator!=(const __iterator& __x, +
[gcc r15-3133] libstdc++: Optimize __try_use_facet for const types
https://gcc.gnu.org/g:952e67c0d131300f263d729a0fe07bc3655dad27 commit r15-3133-g952e67c0d131300f263d729a0fe07bc3655dad27 Author: Jonathan Wakely Date: Wed May 22 16:49:31 2024 +0100 libstdc++: Optimize __try_use_facet for const types LWG 436 confirmed that const-qualified types are valid arguments for Facet template parameters (but volatile-qualified types are not). Use the fast path in std::use_facet and std::has_facet for const T as well as T. libstdc++-v3/ChangeLog: * include/bits/locale_classes.tcc (__try_use_facet): Also avoid dynamic_cast for const-qualified facet types. Diff: --- libstdc++-v3/include/bits/locale_classes.tcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/locale_classes.tcc b/libstdc++-v3/include/bits/locale_classes.tcc index c79574e58de8..d5ef1911057b 100644 --- a/libstdc++-v3/include/bits/locale_classes.tcc +++ b/libstdc++-v3/include/bits/locale_classes.tcc @@ -110,7 +110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // We know these standard facets are always installed in every locale // so dynamic_cast always succeeds, just use static_cast instead. #define _GLIBCXX_STD_FACET(...) \ - if _GLIBCXX_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \ + if _GLIBCXX_CONSTEXPR (__is_same(const _Facet, const __VA_ARGS__)) \ return static_cast(__facets[__i]) _GLIBCXX_STD_FACET(ctype);
[gcc r15-3132] libstdc++: Fix std::allocator_traits::construct constraints [PR108619]
https://gcc.gnu.org/g:8cf51d7516b92b352c358c14ab4e456ae53c3371 commit r15-3132-g8cf51d7516b92b352c358c14ab4e456ae53c3371 Author: Jonathan Wakely Date: Wed Jul 10 23:14:19 2024 +0100 libstdc++: Fix std::allocator_traits::construct constraints [PR108619] Using std::is_constructible in the constraints introduces a spurious dependency on the type being destructible, which should not be required for constructing with an allocator. The test case shows a case where the type has a private destructor, which can be destroyed by the allocator, but std::is_destructible and std::is_constructible are false. Similarly, using is_nothrow_constructible in the noexcept-specifiers for the construct members of allocator_traits and std::allocator, __gnu_cxx::__new_allocator, and __gnu_cxx::__malloc_allocator gives the wrong answer if the type isn't destructible. We need a new type trait to define those correctly, so that we only check if the placement new-expression is nothrow after using is_constructible to check that it would be well-formed. Instead of just fixing the overly restrictive constraint to check for placement new, rewrite allocator_traits in terms of 'if constexpr' using variable templates and the detection idiom. Although we can use 'if constexpr' and variable templates in C++11 with appropriate uses of diagnostic pragmas, we can't have constexpr functions with multiple return statements. This means that in C++11 mode the _S_nothrow_construct and _S_nothrow_destroy helpers used for noexcept-specifiers still need to be overlaods using enable_if. Nearly everything else can be simplified to reduce overload resolution and enable_if checks. libstdc++-v3/ChangeLog: PR libstdc++/108619 * include/bits/alloc_traits.h (__allocator_traits_base): Add variable templates for detecting which allocator operations are supported. (allocator_traits): Use 'if constexpr' instead of dispatching to overloads constrained with enable_if. (allocator_traits>::construct): Use Construct if construct_at is not supported. Use __is_nothrow_new_constructible for noexcept-specifier. (allocator_traits>::construct): Use __is_nothrow_new_constructible for noexcept-specifier. * include/bits/new_allocator.h (construct): Likewise. * include/ext/malloc_allocator.h (construct): Likewise. * include/std/type_traits (__is_nothrow_new_constructible): New variable template. * testsuite/20_util/allocator/89510.cc: Adjust expected results. * testsuite/ext/malloc_allocator/89510.cc: Likewise. * testsuite/ext/new_allocator/89510.cc: Likewise. * testsuite/20_util/allocator_traits/members/108619.cc: New test. Diff: --- libstdc++-v3/include/bits/alloc_traits.h | 351 ++--- libstdc++-v3/include/bits/new_allocator.h | 2 +- libstdc++-v3/include/ext/malloc_allocator.h| 2 +- libstdc++-v3/include/std/type_traits | 15 + libstdc++-v3/testsuite/20_util/allocator/89510.cc | 14 +- .../20_util/allocator_traits/members/108619.cc | 35 ++ .../testsuite/ext/malloc_allocator/89510.cc| 14 +- libstdc++-v3/testsuite/ext/new_allocator/89510.cc | 14 +- 8 files changed, 314 insertions(+), 133 deletions(-) diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index 82fc79c7b9f9..c2acc2ab2070 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -48,10 +48,19 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++14-extensions" // for variable templates +#pragma GCC diagnostic ignored "-Wc++17-extensions" // for if-constexpr + /// @cond undocumented struct __allocator_traits_base { +#if __cpp_concepts +template +#else template +#endif struct __rebind : __replace_first_arg<_Tp, _Up> { static_assert(is_same< @@ -61,8 +70,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template +#if __cpp_concepts + requires requires { typename _Tp::template rebind<_Up>::other; } + struct __rebind<_Tp, _Up> +#else struct __rebind<_Tp, _Up, __void_t::other>> +#endif { using type = typename _Tp::template rebind<_Up>::other; @@ -89,6 +103,135 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __pocs = typename _Tp::propagate_on_container_swap; template using __equal = __type_identity; + +// __has_allocate_hint is true if a.allocate(n, hint) is well-formed. +#if __cpp_concepts +template + static constexpr bool __has_allocate_hint +
[gcc r15-3131] libstdc++: Only use std::time_put in std::format for non-C locales
https://gcc.gnu.org/g:43b8153c26655a7a00f1584fcb4f511dc5e45fab commit r15-3131-g43b8153c26655a7a00f1584fcb4f511dc5e45fab Author: Jonathan Wakely Date: Wed Jul 31 16:32:44 2024 +0100 libstdc++: Only use std::time_put in std::format for non-C locales When testing on Solaris I noticed that std/time/year/io.cc was FAILing because the year 1642 was being formatted as "+(" by %Ey. This turns out to be because we defer to std::time_put for modified conversion specs, and std::time_put uses std::strftime, and that's undefined for years before 1970. In particular, years before 1900 mean that the tm_year field is negative, which then causes incorrect results from strftime on at least Solaris and AIX. I've raised the general problem with LWG, but we can fix the FAILing test case (and probably improve performance slightly) by ignoring the E and O modifiers when the formatting locale is the "C" locale. The modifiers have no effect for the C locale, so we can just treat %Ey as %y and format it directly. This doesn't fix anything when the formatting locale isn't the C locale, but that case is not adequately tested, so doesn't cause any FAIL right now! The naïve fix would be simply: if (__mod) if (auto __loc = _M_locale(__ctx); __loc != locale::classic()) // ... However when the format string doesn't use the 'L' option, _M_locale always returns locale::classic(). In that case, we make a copy of the classic locale (which calls the non-inline copy constructor in the library), then make another copy of the classic locale, then compare the two. We can avoid all that by checking for the 'L' option first, instead of letting _M_locale do that: if (__mod && _M_spec._M_localized) if (auto __loc = __ctx.locale(); __loc != locale::classic()) // ... We could optimize this further if we had a __is_classic(__loc) function that would do the __loc == locale::classic() check without making any copies or non-inline calls. That would require examining the locale's _M_impl member, and probably require checking its name, because the locale::_S_classic singleton is not exported from the library. For _M_S the change is slightly different from the other functions, because if we skip using std::time_put for %OS then we fall through to the code that potentially prints fractional seconds, but the %OS format only prints whole seconds. So we need to format whole seconds directly when not using std::time_put, instead of falling through to the code below. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (__formatter_chrono::_M_C_y_Y): Ignore modifiers unless the formatting locale is not the C locale. (__formatter_chrono::_M_d_e): Likewise. (__formatter_chrono::_M_H_I): Likewise. (__formatter_chrono::_M_m): Likewise. (__formatter_chrono::_M_M): Likewise. (__formatter_chrono::_M_S): Likewise. (__formatter_chrono::_M_u_w): Likewise. (__formatter_chrono::_M_U_V_W): Likewise. Diff: --- libstdc++-v3/include/bits/chrono_io.h | 133 +++--- 1 file changed, 74 insertions(+), 59 deletions(-) diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h index a449ffdc5583..38a0b002c81c 100644 --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -917,13 +917,14 @@ namespace __format chrono::year __y = _S_year(__t); - if (__mod) [[unlikely]] - { - struct tm __tm{}; - __tm.tm_year = (int)__y - 1900; - return _M_locale_fmt(std::move(__out), _M_locale(__ctx), __tm, - __conv, __mod); - } + if (__mod && _M_spec._M_localized) [[unlikely]] + if (auto __loc = __ctx.locale(); __loc != locale::classic()) + { + struct tm __tm{}; + __tm.tm_year = (int)__y - 1900; + return _M_locale_fmt(std::move(__out), __loc, __tm, +__conv, __mod); + } basic_string<_CharT> __s; int __yi = (int)__y; @@ -985,13 +986,14 @@ namespace __format chrono::day __d = _S_day(__t); unsigned __i = (unsigned)__d; - if (__mod) [[unlikely]] - { - struct tm __tm{}; - __tm.tm_mday = __i; - return _M_locale_fmt(std::move(__out), _M_locale(__ctx), __tm, - (char)__conv, 'O'); - } + if (__mod && _M_spec._M_localized) [[unlikely]] + if (auto __loc = __ctx.locale(); __loc != locale::classic()) + { + struct tm __tm{}; + __tm.tm_mday = __i; +
[gcc r15-3134] libstdc++: Implement LWG 3746 for std::optional
https://gcc.gnu.org/g:c429d509a86d61b21298b787948e24a9c97084e3 commit r15-3134-gc429d509a86d61b21298b787948e24a9c97084e3 Author: Jonathan Wakely Date: Tue Jun 25 21:58:34 2024 +0100 libstdc++: Implement LWG 3746 for std::optional This avoids constraint recursion in operator<=> for std::optional. The resolution was approved in Kona 2022. libstdc++-v3/ChangeLog: * include/std/optional (__is_derived_from_optional): New concept. (operator<=>): Use __is_derived_from_optional. * testsuite/20_util/optional/relops/lwg3746.cc: New test. Diff: --- libstdc++-v3/include/std/optional| 12 ++-- .../testsuite/20_util/optional/relops/lwg3746.cc | 20 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 6651686cd1d0..933a5b15e569 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -1581,9 +1581,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !__rhs; } #endif // three-way-comparison +#if __cpp_lib_concepts // _GLIBCXX_RESOLVE_LIB_DEFECTS // 4072. std::optional comparisons: constrain harder -#if __cpp_lib_concepts # define _REQUIRES_NOT_OPTIONAL(T) requires (!__is_optional_v) #else # define _REQUIRES_NOT_OPTIONAL(T) @@ -1675,8 +1675,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !__rhs || __lhs >= *__rhs; } #ifdef __cpp_lib_three_way_comparison + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3746. optional's spaceship with U with a type derived from optional + // causes infinite constraint meta-recursion + template +concept __is_derived_from_optional = requires (const _Tp& __t) { + [](const optional<_Up>&){ }(__t); +}; + template -requires (!__is_optional_v<_Up>) +requires (!__is_derived_from_optional<_Up>) && three_way_comparable_with<_Up, _Tp> constexpr compare_three_way_result_t<_Tp, _Up> operator<=> [[nodiscard]] (const optional<_Tp>& __x, const _Up& __v) diff --git a/libstdc++-v3/testsuite/20_util/optional/relops/lwg3746.cc b/libstdc++-v3/testsuite/20_util/optional/relops/lwg3746.cc new file mode 100644 index ..46065f8e901d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/optional/relops/lwg3746.cc @@ -0,0 +1,20 @@ +// { dg-do compile { target c++20 } } + +// LWG 3746. optional's spaceship with U with a type derived from optional +// causes infinite constraint meta-recursion + +#include + +struct S : std::optional +{ +bool operator==(const S&) const; +bool operator<(const S&) const; +bool operator>(const S&) const; +bool operator<=(const S&) const; +bool operator>=(const S&) const; +}; + +auto cmp(const S& s, const std::optional& o) +{ + return s <=> o; +}
[gcc r15-3135] lto: Don't check obj.found for offload section
https://gcc.gnu.org/g:cb51e0b236c7d492af2033582230e78d8b55290f commit r15-3135-gcb51e0b236c7d492af2033582230e78d8b55290f Author: H.J. Lu Date: Fri Aug 23 05:36:45 2024 -0700 lto: Don't check obj.found for offload section obj.found is the number of LTO symbols. We should include the offload section when it is used by linker even if there are no LTO symbols. PR lto/116361 * lto-plugin.c (claim_file_handler_v2): Don't check obj.found for the offload section. Signed-off-by: H.J. Lu Diff: --- lto-plugin/lto-plugin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index 61b0de62f524..c564b36eb92a 100644 --- a/lto-plugin/lto-plugin.c +++ b/lto-plugin/lto-plugin.c @@ -1320,7 +1320,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file, if (*can_be_claimed && !obj.offload && offload_files_last_lto == NULL) offload_files_last_lto = offload_files_last; - if (obj.offload && known_used && obj.found > 0) + if (obj.offload && known_used) { /* Add file to the list. The order must be exactly the same as the final order after recompilation and linking, otherwise host and target tables
[gcc r15-3136] rs6000: Fix PTImode handling in power8 swap optimization pass [PR116415]
https://gcc.gnu.org/g:6e68c3df1540c5bafbb47343698bf4e270333fdb commit r15-3136-g6e68c3df1540c5bafbb47343698bf4e270333fdb Author: Peter Bergner Date: Fri Aug 23 11:45:40 2024 -0500 rs6000: Fix PTImode handling in power8 swap optimization pass [PR116415] Our power8 swap optimization pass has some special handling for optimizing swaps of TImode variables. The test case reported in bugzilla uses a call to __atomic_compare_exchange, which introduces a variable of PTImode and that does not get the same treatment as TImode leading to wrong code generation. The simple fix is to treat PTImode identically to TImode. 2024-08-23 Peter Bergner gcc/ PR target/116415 * config/rs6000/rs6000.h (TI_OR_PTI_MODE): New define. * config/rs6000/rs6000-p8swap.cc (rs6000_analyze_swaps): Use it to handle PTImode identically to TImode. gcc/testsuite/ PR target/116415 * gcc.target/powerpc/pr116415.c: New test. Diff: --- gcc/config/rs6000/rs6000-p8swap.cc | 8 +++--- gcc/config/rs6000/rs6000.h | 2 ++ gcc/testsuite/gcc.target/powerpc/pr116415.c | 42 + 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/gcc/config/rs6000/rs6000-p8swap.cc b/gcc/config/rs6000/rs6000-p8swap.cc index 639f477d7822..05fb76057f93 100644 --- a/gcc/config/rs6000/rs6000-p8swap.cc +++ b/gcc/config/rs6000/rs6000-p8swap.cc @@ -2469,10 +2469,10 @@ rs6000_analyze_swaps (function *fun) mode = V4SImode; } - if (ALTIVEC_OR_VSX_VECTOR_MODE (mode) || mode == TImode) + if (ALTIVEC_OR_VSX_VECTOR_MODE (mode) || TI_OR_PTI_MODE (mode)) { insn_entry[uid].is_relevant = 1; - if (mode == TImode || mode == V1TImode + if (TI_OR_PTI_MODE (mode) || mode == V1TImode || FLOAT128_VECTOR_P (mode)) insn_entry[uid].is_128_int = 1; if (DF_REF_INSN_INFO (mention)) @@ -2497,10 +2497,10 @@ rs6000_analyze_swaps (function *fun) && ALTIVEC_OR_VSX_VECTOR_MODE (GET_MODE (SET_DEST (insn mode = GET_MODE (SET_DEST (insn)); - if (ALTIVEC_OR_VSX_VECTOR_MODE (mode) || mode == TImode) + if (ALTIVEC_OR_VSX_VECTOR_MODE (mode) || TI_OR_PTI_MODE (mode)) { insn_entry[uid].is_relevant = 1; - if (mode == TImode || mode == V1TImode + if (TI_OR_PTI_MODE (mode) || mode == V1TImode || FLOAT128_VECTOR_P (mode)) insn_entry[uid].is_128_int = 1; if (DF_REF_INSN_INFO (mention)) diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 703be908d944..d460eb065448 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -986,6 +986,8 @@ enum data_align { align_abi, align_opt, align_both }; (ALTIVEC_VECTOR_MODE (MODE) || VSX_VECTOR_MODE (MODE) \ || (MODE) == V2DImode || (MODE) == V1TImode) +#define TI_OR_PTI_MODE(mode) ((mode) == TImode || (mode) == PTImode) + /* Post-reload, we can't use any new AltiVec registers, as we already emitted the vrsave mask. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr116415.c b/gcc/testsuite/gcc.target/powerpc/pr116415.c new file mode 100644 index ..08cc282e2c27 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr116415.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ +/* { dg-require-effective-target p8vector_hw } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-O2 -mdejagnu-cpu=power8" } */ + +/* PR 116415: Verify our Power8 swap optimization pass doesn't incorrectly swap + PTImode values. They should be handled identically to TImode values. */ + +#include +#include +#include + +typedef union { + struct { +uint64_t a; +uint64_t b; + } t; + __uint128_t data; +} Value; +Value value, next; + +void +bug (Value *val, Value *nxt) +{ + for (;;) { +nxt->t.a = val->t.a + 1; +nxt->t.b = val->t.b + 2; +if (__atomic_compare_exchange (&val->data, &val->data, &nxt->data, + 0, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE)) + break; + } +} + +int +main (void) +{ + bug (&value, &next); + printf ("%lu %lu\n", value.t.a, value.t.b); + if (value.t.a != 1 || value.t.b != 2) +abort (); + return 0; +}
[gcc r15-3137] ifcvt: disallow call instructions in noce_convert_multiple_sets [PR116358]
https://gcc.gnu.org/g:c9e2d0ec6eabc2a6b8c00984b2b2bc48565bb99b commit r15-3137-gc9e2d0ec6eabc2a6b8c00984b2b2bc48565bb99b Author: Manolis Tsamis Date: Thu Aug 22 02:59:11 2024 -0700 ifcvt: disallow call instructions in noce_convert_multiple_sets [PR116358] Similar to not allowing jump instructions in the generated code, we also shouldn't allow call instructions in noce_convert_multiple_sets. In the case of PR116358 a libcall was generated from force_operand. PR middle-end/116358 gcc/ChangeLog: * ifcvt.cc (noce_convert_multiple_sets): Disallow call insns. gcc/testsuite/ChangeLog: * gcc.target/aarch64/pr116358.c: New test. Diff: --- gcc/ifcvt.cc| 2 +- gcc/testsuite/gcc.target/aarch64/pr116358.c | 15 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index da59c9078919..b136d7dbbba3 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -3550,7 +3550,7 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) return false; for (insn = seq; insn; insn = NEXT_INSN (insn)) -if (JUMP_P (insn) +if (JUMP_P (insn) || CALL_P (insn) || recog_memoized (insn) == -1) return false; diff --git a/gcc/testsuite/gcc.target/aarch64/pr116358.c b/gcc/testsuite/gcc.target/aarch64/pr116358.c new file mode 100644 index ..0a5fd9e02b92 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr116358.c @@ -0,0 +1,15 @@ +/* PR middle-end/116358 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +long long f(int b, int c, long long d) +{ + if (c) { +long long bb = b; +long long t2 = (bb < 16 ? bb : 16); +d = t2 - 16; + } + return d; +} + +/* { dg-final { scan-assembler-not "bl" } } */
[gcc r15-3138] ifcvt: Do not overwrite results in noce_convert_multiple_sets [PR116372, PR116405]
https://gcc.gnu.org/g:a9f5e23aba1a6f4ec32f1147b340a8145d827da9 commit r15-3138-ga9f5e23aba1a6f4ec32f1147b340a8145d827da9 Author: Manolis Tsamis Date: Tue Aug 20 09:16:29 2024 +0200 ifcvt: Do not overwrite results in noce_convert_multiple_sets [PR116372, PR116405] Now that more operations are allowed for noce_convert_multiple_sets, it is possible that the same register appears multiple times as target in a basic block. After noce_convert_multiple_sets_1 is called we potentially also emit register moves from temporaries back to the original targets. In some cases where the target registers overlap with the block's condition, these register moves may overwrite intermediate variables because they're emitted after the if-converted code. To address this issue we now iterate backwards and keep track of seen registers when emitting these final register moves. PR rtl-optimization/116372 PR rtl-optimization/116405 gcc/ChangeLog: * ifcvt.cc (noce_convert_multiple_sets): Iterate backwards and track target registers. gcc/testsuite/ChangeLog: * gcc.dg/pr116372.c: New test. * gcc.dg/pr116405.c: New test. Diff: --- gcc/ifcvt.cc| 22 ++ gcc/testsuite/gcc.dg/pr116372.c | 13 + gcc/testsuite/gcc.dg/pr116405.c | 17 + 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index b136d7dbbba3..6487574c5149 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -3515,10 +3515,24 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) given an empty BB to convert, and we can't handle that. */ gcc_assert (!insn_info.is_empty ()); - /* Now fixup the assignments. */ - for (unsigned i = 0; i < insn_info.length (); i++) -if (insn_info[i]->target != insn_info[i]->temporary) - noce_emit_move_insn (insn_info[i]->target, insn_info[i]->temporary); + /* Now fixup the assignments. + PR116405: Iterate in reverse order and keep track of the targets so that + a move does not overwrite a subsequent value when multiple instructions + have the same target. */ + unsigned i; + noce_multiple_sets_info *info; + bitmap set_targets = BITMAP_ALLOC (®_obstack); + FOR_EACH_VEC_ELT_REVERSE (insn_info, i, info) +{ + gcc_checking_assert (REG_P (info->target)); + + if (info->target != info->temporary + && !bitmap_bit_p (set_targets, REGNO (info->target))) + noce_emit_move_insn (info->target, info->temporary); + + bitmap_set_bit (set_targets, REGNO (info->target)); +} + BITMAP_FREE (set_targets); /* Actually emit the sequence if it isn't too expensive. */ rtx_insn *seq = get_insns (); diff --git a/gcc/testsuite/gcc.dg/pr116372.c b/gcc/testsuite/gcc.dg/pr116372.c new file mode 100644 index ..e9878ac5042b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr116372.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/116372 */ +/* { dg-do run } */ +/* { dg-options "-O1" } */ +/* { dg-additional-options "-march=z13" { target s390x-*-* } } */ + +long x = -0x7fff - 1; +int main (void) +{ + long y = x % (-0xf - 1); + if (-0x7fff - 1 + y == x == 0) +__builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr116405.c b/gcc/testsuite/gcc.dg/pr116405.c new file mode 100644 index ..9223f15a2987 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr116405.c @@ -0,0 +1,17 @@ +/* PR rtl-optimization/116405 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-ssa-phiopt -fno-tree-dce" } */ + +int printf(const char *, ...); +int a, b = 2, c = 1; +unsigned d, e; +int main() { + L: + a = -1 / c; + d = ~(b && (c && ~e) & b); + printf("0\n"); + c = 0; + if (d != -1) +goto L; + return 0; +}
[gcc r15-3139] RISC-V: Use encoded nelts when calling repeating_sequence_p
https://gcc.gnu.org/g:5dce17e17469161f413e1a5b723dca0e94be3fb6 commit r15-3139-g5dce17e17469161f413e1a5b723dca0e94be3fb6 Author: Patrick O'Neill Date: Mon Aug 19 12:19:33 2024 -0700 RISC-V: Use encoded nelts when calling repeating_sequence_p repeating_sequence_p operates directly on the encoded pattern and does not derive elements using the .elt() accessor. Passing in the length of the unencoded vector can cause an out-of-bounds read of the encoded pattern. gcc/ChangeLog: * config/riscv/riscv-v.cc (rvv_builder::can_duplicate_repeating_sequence_p): Use encoded_nelts when calling repeating_sequence_p. (rvv_builder::is_repeating_sequence): Ditto. (rvv_builder::repeating_sequence_use_merge_profitable_p): Ditto. Signed-off-by: Patrick O'Neill Diff: --- gcc/config/riscv/riscv-v.cc | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index 0db5c7591eff..c89603669e3a 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -502,9 +502,7 @@ rvv_builder::can_duplicate_repeating_sequence_p () || GET_MODE_SIZE (m_new_inner_mode) > UNITS_PER_WORD || !get_vector_mode (m_new_inner_mode, new_size).exists (&m_new_mode)) return false; - if (full_nelts ().is_constant ()) -return repeating_sequence_p (0, full_nelts ().to_constant (), npatterns ()); - return nelts_per_pattern () == 1; + return repeating_sequence_p (0, encoded_nelts (), npatterns ()); } /* Return true if the vector is a simple sequence with one pattern and all @@ -514,9 +512,7 @@ rvv_builder::is_repeating_sequence () { if (npatterns () > 1) return false; - if (full_nelts ().is_constant ()) -return repeating_sequence_p (0, full_nelts ().to_constant (), 1); - return nelts_per_pattern () == 1; + return repeating_sequence_p (0, encoded_nelts (), 1); } /* Return true if it is a repeating sequence that using @@ -564,7 +560,7 @@ rvv_builder::repeating_sequence_use_merge_profitable_p () unsigned int nelts = full_nelts ().to_constant (); - if (!repeating_sequence_p (0, nelts, npatterns ())) + if (!repeating_sequence_p (0, encoded_nelts (), npatterns ())) return false; unsigned int merge_cost = 1;
[gcc r15-3140] libstdc++: Improve Doxygen docs for std::allocator_traits specializations
https://gcc.gnu.org/g:cd8e0ea7273425931a0843f4355ad61e177e1bf2 commit r15-3140-gcd8e0ea7273425931a0843f4355ad61e177e1bf2 Author: Jonathan Wakely Date: Fri Aug 23 21:54:21 2024 +0100 libstdc++: Improve Doxygen docs for std::allocator_traits specializations The main fix here is to use @header so that the docs show the correct header file instead of an internal header like alloc_traits.h. libstdc++-v3/ChangeLog: * include/bits/alloc_traits.h: Improve doxygen docs for allocator_traits specializations. * include/bits/memory_resource.h: Likewise. Diff: --- libstdc++-v3/include/bits/alloc_traits.h| 16 ++-- libstdc++-v3/include/bits/memory_resource.h | 9 +++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index c2acc2ab2070..c64f4757d5da 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -549,7 +549,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #pragma GCC diagnostic pop #if _GLIBCXX_HOSTED - /// Partial specialization for std::allocator. + /** + * @brief Partial specialization for `std::allocator` + * @headerfile memory + * @ingroup allocators + * @since C++11 + * @see std::allocator_traits + */ template struct allocator_traits> { @@ -720,7 +726,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __rhs; } }; - /// Explicit specialization for std::allocator. + /** + * @brief Explicit specialization for `std::allocator` + * @headerfile memory + * @ingroup allocators + * @since C++11 + * @see std::allocator_traits + */ template<> struct allocator_traits> { diff --git a/libstdc++-v3/include/bits/memory_resource.h b/libstdc++-v3/include/bits/memory_resource.h index 5f50b296df7b..db515fb30ef9 100644 --- a/libstdc++-v3/include/bits/memory_resource.h +++ b/libstdc++-v3/include/bits/memory_resource.h @@ -52,7 +52,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace pmr { - /// Class memory_resource + /// Class `memory_resource` /** * @ingroup pmr * @headerfile memory_resource @@ -385,7 +385,12 @@ namespace pmr template struct allocator_traits; - /// Partial specialization for std::pmr::polymorphic_allocator + /// Partial specialization for `std::pmr::polymorphic_allocator` + /** + * @ingroup pmr + * @headerfile memory_resource + * @since C++17 + */ template struct allocator_traits> {
[gcc r15-3141] libstdc++: Hide std::tuple internals from Doxygen docs
https://gcc.gnu.org/g:5cfee9360c90da8171e9f6bb71568bdc4c296e6e commit r15-3141-g5cfee9360c90da8171e9f6bb71568bdc4c296e6e Author: Jonathan Wakely Date: Fri Aug 23 22:06:43 2024 +0100 libstdc++: Hide std::tuple internals from Doxygen docs libstdc++-v3/ChangeLog: * include/std/tuple: Do not include implementation details in Doxygen documentation. Diff: --- libstdc++-v3/include/std/tuple | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 93b649e7d211..70cf4dba7b93 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -66,6 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template class tuple; + /// @cond undocumented template struct __is_empty_non_tuple : is_empty<_Tp> { }; @@ -823,6 +824,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr bool __is_explicitly_constructible() { return false; } }; + /// @endcond /// Primary class template, tuple template
[gcc r15-3142] libstdc++: Update and clarify Doxygen version requirements in manual
https://gcc.gnu.org/g:a523d1b46beb75150094dafd82cb065bd7cec463 commit r15-3142-ga523d1b46beb75150094dafd82cb065bd7cec463 Author: Jonathan Wakely Date: Fri Aug 23 21:32:14 2024 +0100 libstdc++: Update and clarify Doxygen version requirements in manual There are lots of bugs that affect libstdc++ output from Doxygen, so using 1.9.6 or later is recommended. Give a lower minimum, because some distros still use 1.9.1 and that will work, albeit suboptimally. libstdc++-v3/ChangeLog: * doc/xml/manual/documentation_hacking.xml: Update minimum Doxygen version. * doc/html/*: Regenerate. Diff: --- libstdc++-v3/doc/html/manual/debug.html | 2 +- libstdc++-v3/doc/html/manual/documentation_hacking.html | 5 +++-- libstdc++-v3/doc/html/manual/setup.html | 3 +-- libstdc++-v3/doc/html/manual/using_exceptions.html | 4 ++-- libstdc++-v3/doc/html/manual/using_headers.html | 2 +- libstdc++-v3/doc/xml/manual/documentation_hacking.xml | 5 +++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/doc/html/manual/debug.html b/libstdc++-v3/doc/html/manual/debug.html index a5f51569e008..1623cd304867 100644 --- a/libstdc++-v3/doc/html/manual/debug.html +++ b/libstdc++-v3/doc/html/manual/debug.html @@ -250,4 +250,4 @@ with C++11 and later standards. They might be removed at a future date. Prev Up NextExceptions Home Part II. Standard Contents - + \ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/documentation_hacking.html b/libstdc++-v3/doc/html/manual/documentation_hacking.html index 047a62e0831e..6b462b44acf4 100644 --- a/libstdc++-v3/doc/html/manual/documentation_hacking.html +++ b/libstdc++-v3/doc/html/manual/documentation_hacking.html @@ -112,9 +112,10 @@ supported, and are always aliased to dummy rules. These unsupported formats are: info, ps, and dvi. -DoxygenPrerequisitesTable B.1. Doxygen PrerequisitesToolVersionRequired Bycoreutils8.5allbash4.1alldoxygen1.7.6.1allgraphviz2.26graphical hierarchiespdflatex2007-59pdf output +DoxygenPrerequisitesTable B.1. Doxygen PrerequisitesToolVersionRequired Bycoreutils8.5allbash4.1alldoxygen1.9.1allgraphviz2.26graphical hierarchiespdflatex2007-59pdf output Prerequisite tools are Bash 2.0 or later, - https://www.doxygen.nl"; target="_top">Doxygen, and + https://www.doxygen.nl"; target="_top">Doxygen + 1.9.1 or later (for best results use at least 1.9.6), and the http://www.gnu.org/software/coreutils/"; target="_top">GNU coreutils. (GNU versions of find, xargs, and possibly sed and grep are used, just because the GNU versions make diff --git a/libstdc++-v3/doc/html/manual/setup.html b/libstdc++-v3/doc/html/manual/setup.html index d8c5ff65cffe..67bb6c108a1b 100644 --- a/libstdc++-v3/doc/html/manual/setup.html +++ b/libstdc++-v3/doc/html/manual/setup.html @@ -22,8 +22,7 @@ Because libstdc++ is part of GCC, the primary source for installation instructions is https://gcc.gnu.org/install/"; target="_top">the GCC install page. - In particular, the list of prerequisite software needed to build - the library + In particular, list of prerequisite software needed to build the library https://gcc.gnu.org/install/prerequisites.html"; target="_top"> starts with those requirements. The same pages also list the tools you will need if you wish to modify the source. diff --git a/libstdc++-v3/doc/html/manual/using_exceptions.html b/libstdc++-v3/doc/html/manual/using_exceptions.html index f3556ef9d755..706b27e14793 100644 --- a/libstdc++-v3/doc/html/manual/using_exceptions.html +++ b/libstdc++-v3/doc/html/manual/using_exceptions.html @@ -166,8 +166,8 @@ exception neutrality and exception safety. implicitly generated magic necessary to support try and catch blocks and thrown objects. (Language support -for -fno-exceptions is documented in the GNU -GCC https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options"; target="_top">manual.) +for -fno-exceptions is documented in the GCC +https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options"; target="_top">manual.) Before detailing the library support for -fno-exceptions, first a passing note on the things lost when this flag is used: it will break exceptions diff --git a/libstdc++-v3/doc/html/manual/using_headers.html b/libstdc++-v3/doc/html/manual/using_headers.html index 5f6698626541..49a826143441 100644 --- a/libstdc++-v3/doc/html/manual/using_headers.html +++ b/libstdc++-v3/doc/html/manual/using_headers.html @@ -186,5 +186,5 @@ g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe ! ./stdc++.h.gch . /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0/iostream . /mnt/share/bld/H-x86-gcc.20071201include/c++/4.3.0/string -The exclamation point to the left of
[gcc/aoliva/heads/testme] (223 commits) Optimize initialization of small padded objects
The branch 'aoliva/heads/testme' was updated to point to: ce140008fff6... Optimize initialization of small padded objects It previously pointed to: d2b89c77861c... Dump aliases in -fcallgraph-info Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- d2b89c7... Dump aliases in -fcallgraph-info 7b50738... Optimize initialization of small padded objects Summary of changes (added commits): --- ce14000... Optimize initialization of small padded objects 3ff1b91... Daily bump. (*) a523d1b... libstdc++: Update and clarify Doxygen version requirements (*) 5cfee93... libstdc++: Hide std::tuple internals from Doxygen docs (*) cd8e0ea... libstdc++: Improve Doxygen docs for std::allocator_traits s (*) 5dce17e... RISC-V: Use encoded nelts when calling repeating_sequence_p (*) a9f5e23... ifcvt: Do not overwrite results in noce_convert_multiple_se (*) c9e2d0e... ifcvt: disallow call instructions in noce_convert_multiple_ (*) 6e68c3d... rs6000: Fix PTImode handling in power8 swap optimization pa (*) cb51e0b... lto: Don't check obj.found for offload section (*) c429d50... libstdc++: Implement LWG 3746 for std::optional (*) 952e67c... libstdc++: Optimize __try_use_facet for const types (*) 8cf51d7... libstdc++: Fix std::allocator_traits::construct constraints (*) 43b8153... libstdc++: Only use std::time_put in std::format for non-C (*) 591b719... libstdc++: Define operator== for hash table iterators [PR11 (*) 125bab2... libstdc++: Fix std::random_shuffle for low RAND_MAX [PR8893 (*) de1923f... tree-optimization/116463 - complex lowering leaves around d (*) a35dd27... libstdc++: Make debug sequence members mutable [PR116369] (*) 9115593... libstdc++: Use noexcept insted of throw() in src/c++11/debu (*) 0bb2652... libstdc++: Simplify C++20 implementation of std::variant (*) b25b101... libstdc++: Make std::vector::reference constructor pr (*) f9f599a... Revert "Fortran: Fix class transformational intrinsic calls (*) 0798887... Match: Support form 4 for unsigned integer .SAT_TRUNC (*) b2c1d7c... libcpp: bump padding size in _cpp_convert_input [PR116458] (*) 96fe95b... optabs-query: Use opt_machine_mode for smallest_int_mode_fo (*) c22d57c... RISC-V: Expand vec abs without masking. (*) a8ae8f9... Fix test failure on powerpc targets (*) 19c22fb... ada: Fix crash on aliased variable with packed array type a (*) 87bdd17... ada: String interpolation: report error without Extensions (*) 509cc70... ada: Fix incorrect tracebacks on Windows (*) a7ff045... ada: Crash on string interpolation with custom string types (*) 7dd9c7d... ada: Implicit_Dereference aspect specification for subtype (*) 24c5396... ada: Eliminated-mode overflow check not eliminated (*) 40903c7... ada: Update libraries with the limited flag (*) dce0d46... ada: Emit a warning on inheritly limited types (*) 92a9b55... ada: First controlling parameter aspect (*) 0020cae... ada: Fix style in lines starting with assignment operator (*) ff356c0... ada: Cleanup validity of boolean operators (*) f67d108... ada: Simplify validity checks for scalar parameters (*) 8719b18... ada: Fix validity checks for named parameter associations (*) 4522f1f... ada: First controlling parameter aspect (*) aa95cd9... ada: Error missing when 'access is applied to an interface (*) 8a41af7... ada: First controlling parameter aspect (*) a071fcd... fortran: Minor fix to -ffrontend-optimize description (*) afa9080... doc: Specifically link to GPL v3.0 for GM2 (*) 0636de8... Remove unnecessary view_convert obsoleted by [PR86468]. (*) f6b10fe... testsuite: Fix vect-mod-var.c for division by 0 [PR116461] (*) 2cd783b... Daily bump. (*) da043f9... testsuite: Fix gcc.dg/torture/pr116420.c for targets defaul (*) c937773... [PR rtl-optimization/116420] Fix interesting block bitmap D (*) 8e0da56... libstdc++: Add some missing ranges feature-test macro tests (*) 792adb8... Recompute TYPE_MODE and DECL_MODE for aggregate type for ac (*) a025081... RISC-V: Fix vector cfi notes for stack-clash protection (*) 51761c5... libstdc++: Optimize std::projected (*) 6202324... libstdc++: Implement P2997R1 changes to the indirect invoca (*) b552730... libstdc++: Implement P2609R3 changes to the indirect invoca (*) a98dd53... Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook (*) b07f8a3... fold: Fix `a * 1j` if a has side effects [PR116454] (*) 4e905bd... fix single argument static_assert (*) 313aa73... PR target/116365: Add user-friendly arguments to --param aa (*) 76c2954... RISC-V: Enable -gvariable-location-views by default (*) bcb33b1... Do not emit a redundant DW_TAG_lexical_block for inlined su (*) 9bbad36... PR tree-optimization/101390: Vectorize modulo operator (*) 2349609... Dump aliases in -fcallgraph-info (*) c1aba5e... Makefile.tpl: fix w
[gcc/aoliva/heads/testbase] (222 commits) Daily bump.
The branch 'aoliva/heads/testbase' was updated to point to: 3ff1b91e7729... Daily bump. It previously pointed to: 4d2e8fcdaf32... Daily bump. Diff: Summary of changes (added commits): --- 3ff1b91... Daily bump. (*) a523d1b... libstdc++: Update and clarify Doxygen version requirements (*) 5cfee93... libstdc++: Hide std::tuple internals from Doxygen docs (*) cd8e0ea... libstdc++: Improve Doxygen docs for std::allocator_traits s (*) 5dce17e... RISC-V: Use encoded nelts when calling repeating_sequence_p (*) a9f5e23... ifcvt: Do not overwrite results in noce_convert_multiple_se (*) c9e2d0e... ifcvt: disallow call instructions in noce_convert_multiple_ (*) 6e68c3d... rs6000: Fix PTImode handling in power8 swap optimization pa (*) cb51e0b... lto: Don't check obj.found for offload section (*) c429d50... libstdc++: Implement LWG 3746 for std::optional (*) 952e67c... libstdc++: Optimize __try_use_facet for const types (*) 8cf51d7... libstdc++: Fix std::allocator_traits::construct constraints (*) 43b8153... libstdc++: Only use std::time_put in std::format for non-C (*) 591b719... libstdc++: Define operator== for hash table iterators [PR11 (*) 125bab2... libstdc++: Fix std::random_shuffle for low RAND_MAX [PR8893 (*) de1923f... tree-optimization/116463 - complex lowering leaves around d (*) a35dd27... libstdc++: Make debug sequence members mutable [PR116369] (*) 9115593... libstdc++: Use noexcept insted of throw() in src/c++11/debu (*) 0bb2652... libstdc++: Simplify C++20 implementation of std::variant (*) b25b101... libstdc++: Make std::vector::reference constructor pr (*) f9f599a... Revert "Fortran: Fix class transformational intrinsic calls (*) 0798887... Match: Support form 4 for unsigned integer .SAT_TRUNC (*) b2c1d7c... libcpp: bump padding size in _cpp_convert_input [PR116458] (*) 96fe95b... optabs-query: Use opt_machine_mode for smallest_int_mode_fo (*) c22d57c... RISC-V: Expand vec abs without masking. (*) a8ae8f9... Fix test failure on powerpc targets (*) 19c22fb... ada: Fix crash on aliased variable with packed array type a (*) 87bdd17... ada: String interpolation: report error without Extensions (*) 509cc70... ada: Fix incorrect tracebacks on Windows (*) a7ff045... ada: Crash on string interpolation with custom string types (*) 7dd9c7d... ada: Implicit_Dereference aspect specification for subtype (*) 24c5396... ada: Eliminated-mode overflow check not eliminated (*) 40903c7... ada: Update libraries with the limited flag (*) dce0d46... ada: Emit a warning on inheritly limited types (*) 92a9b55... ada: First controlling parameter aspect (*) 0020cae... ada: Fix style in lines starting with assignment operator (*) ff356c0... ada: Cleanup validity of boolean operators (*) f67d108... ada: Simplify validity checks for scalar parameters (*) 8719b18... ada: Fix validity checks for named parameter associations (*) 4522f1f... ada: First controlling parameter aspect (*) aa95cd9... ada: Error missing when 'access is applied to an interface (*) 8a41af7... ada: First controlling parameter aspect (*) a071fcd... fortran: Minor fix to -ffrontend-optimize description (*) afa9080... doc: Specifically link to GPL v3.0 for GM2 (*) 0636de8... Remove unnecessary view_convert obsoleted by [PR86468]. (*) f6b10fe... testsuite: Fix vect-mod-var.c for division by 0 [PR116461] (*) 2cd783b... Daily bump. (*) da043f9... testsuite: Fix gcc.dg/torture/pr116420.c for targets defaul (*) c937773... [PR rtl-optimization/116420] Fix interesting block bitmap D (*) 8e0da56... libstdc++: Add some missing ranges feature-test macro tests (*) 792adb8... Recompute TYPE_MODE and DECL_MODE for aggregate type for ac (*) a025081... RISC-V: Fix vector cfi notes for stack-clash protection (*) 51761c5... libstdc++: Optimize std::projected (*) 6202324... libstdc++: Implement P2997R1 changes to the indirect invoca (*) b552730... libstdc++: Implement P2609R3 changes to the indirect invoca (*) a98dd53... Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook (*) b07f8a3... fold: Fix `a * 1j` if a has side effects [PR116454] (*) 4e905bd... fix single argument static_assert (*) 313aa73... PR target/116365: Add user-friendly arguments to --param aa (*) 76c2954... RISC-V: Enable -gvariable-location-views by default (*) bcb33b1... Do not emit a redundant DW_TAG_lexical_block for inlined su (*) 9bbad36... PR tree-optimization/101390: Vectorize modulo operator (*) 2349609... Dump aliases in -fcallgraph-info (*) c1aba5e... Makefile.tpl: fix whitespace in licence header (*) d6a112a... Makefile.tpl: drop leftover intermodule cruft (*) 6ea25c0... Align ix86_{move_max,store_max} with vectorizer. (*) f155534... Daily bump. (*) 91f2139... RISC-V: Add testcases for unsigned vector .SAT_TRUNC form 3 (*) 1e99e1b... RISC-V: Add testcases for unsigned vector .SAT_TRUNC form 2 (*) cdc9cd4... [PR r
[gcc(refs/users/aoliva/heads/testme)] Optimize initialization of small padded objects
https://gcc.gnu.org/g:ce140008fff6b1e62674be932e3e908232337192 commit ce140008fff6b1e62674be932e3e908232337192 Author: Alexandre Oliva Date: Sat Aug 24 01:52:09 2024 -0300 Optimize initialization of small padded objects When small objects containing padding bits (or bytes) are fully initialized, we will often store them in registers, and setting bitfields and other small fields will attempt to preserve the uninitialized padding bits, which tends to be expensive. Zero-initializing registers, OTOH, tends to be cheap. So, if we're optimizing, zero-initialize such small padded objects even if that's not needed for correctness. We can't zero-initialize all such padding objects, though: if there's no padding whatsoever, and all fields are initialized with nonzero, the zero initialization would be flagged as dead. That's why we introduce machinery to detect whether objects have padding bits. I considered distinguishing between bitfields, units and larger padding elements, but I didn't pursue that distinction. Since the object's zero-initialization subsumes fields' zero-initialization, the empty string test in builtin-snprintf-6.c's test_assign_aggregate would regress without the addition of native_encode_constructor. for gcc/ChangeLog * expr.cc (categorize_ctor_elements_1): Change p_complete to int, to distinguish complete initialization in presence or absence of uninitialized padding bits. (categorize_ctor_elements): Likewise. Adjust all callers... * expr.h (categorize_ctor_elements): ... and declaration. (type_has_padding_at_level_p): New. * gimple-fold.cc (type_has_padding_at_level_p): New. * fold-const.cc (native_encode_constructor): New. (native_encode_expr): Call it. * gimplify.cc (gimplify_init_constructor): Clear small non-addressable non-volatile objects with padding or other uninitialized fields as an optimization. for gcc/testsuite/ChangeLog * gcc.dg/init-pad-1.c: New. Diff: --- gcc/expr.cc | 20 ++-- gcc/expr.h| 3 ++- gcc/fold-const.cc | 36 gcc/gimple-fold.cc| 50 +++ gcc/gimplify.cc | 14 ++- gcc/testsuite/gcc.dg/init-pad-1.c | 18 ++ 6 files changed, 132 insertions(+), 9 deletions(-) diff --git a/gcc/expr.cc b/gcc/expr.cc index 8d17a5a39b4b..320be8b17a13 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -7096,7 +7096,7 @@ count_type_elements (const_tree type, bool for_ctor_p) static bool categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts, HOST_WIDE_INT *p_unique_nz_elts, - HOST_WIDE_INT *p_init_elts, bool *p_complete) + HOST_WIDE_INT *p_init_elts, int *p_complete) { unsigned HOST_WIDE_INT idx; HOST_WIDE_INT nz_elts, unique_nz_elts, init_elts, num_fields; @@ -7218,7 +7218,10 @@ categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts, if (*p_complete && !complete_ctor_at_level_p (TREE_TYPE (ctor), num_fields, elt_type)) -*p_complete = false; +*p_complete = 0; + else if (*p_complete > 0 + && type_has_padding_at_level_p (TREE_TYPE (ctor))) +*p_complete = -1; *p_nz_elts += nz_elts; *p_unique_nz_elts += unique_nz_elts; @@ -7239,7 +7242,10 @@ categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts, and place it in *P_ELT_COUNT. * whether the constructor is complete -- in the sense that every meaningful byte is explicitly given a value -- - and place it in *P_COMPLETE. + and place it in *P_COMPLETE: + - 0 if any field is missing + - 1 if all fields are initialized, and there's no padding + - -1 if all fields are initialized, but there's padding Return whether or not CTOR is a valid static constant initializer, the same as "initializer_constant_valid_p (CTOR, TREE_TYPE (CTOR)) != 0". */ @@ -7247,12 +7253,12 @@ categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts, bool categorize_ctor_elements (const_tree ctor, HOST_WIDE_INT *p_nz_elts, HOST_WIDE_INT *p_unique_nz_elts, - HOST_WIDE_INT *p_init_elts, bool *p_complete) + HOST_WIDE_INT *p_init_elts, int *p_complete) { *p_nz_elts = 0; *p_unique_nz_elts = 0; *p_init_elts = 0; - *p_complete = true; + *p_complete = 1; return categorize_ctor_elements_1 (ctor, p_nz_elts, p_unique_nz_elts, p_init_elts, p_complete); @@ -7313,7 +7319,7 @@ mostly_zeros_p (const_tree exp) if (TREE_CODE (e