[Ada] Fix lemma in generic unit System.Arith_Double

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
This system unit is instanciated with values of Single_Size either 32 or 64 currently. A lemma was only valid for value of 32, which became visible when proving the instance with value of 64. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb (Lemma_Word_Co

[Ada] Remove Compiler_Unit[_Warning] pragmas

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Updated base requirement on GNAT version and the fact that stage1 of the bootstrap now uses the base compiler's libgnat allows for more Ada features in the runtime and makes these pragma obsolete. Added comments in files that are still built during stage1 and that need to be modified with care now

[Ada] Rename parameter-dependent constants in generic unit

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Constant names of Big2xx32, Big2xx63 and Big2xx64 were misleading, as SIngle_Size and Double_Size need not be 32 and 64. Replace by names that don't refer to an explicit size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb: Apply replacement. patch.dif

[Ada] Deconstruct dead wrappers added for external axiomatization

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Support for external axiomatization in GNATprove has been deconstructed few years ago, so the related frontend code can be deconstructed too. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch12.ads (Build_Function_Wrapper, Build_Operator_Wrapper): Remove unrefer

[Ada] Renamed_Entity should return Entity_Id

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
This patch is minor cleanup. The Renamed_Entity and Alias synthesized attributes are of type Entity_Id. No change in behavior. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo-utils.ads, einfo-utils.adb (Renamed_Entity Alias): Change Node_Id to Entity_Id.diff -

[Ada] Fix sharing of formal parameters between wrapper spec and body

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
When creating wrappers for dispatching functions with controlling results, we first created the wrapper spec. Then we created a shallow copy of its specification for the wrapper body using New_Copy_Tree. However, formal parameters in spec and body must have distinct entities and New_Copy_Tree does

[Ada] Remove redundant code related to instances with formal subprograms

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to expansion of dispatching wrappers for GNATprove, which just like instantiation involves copying of a specification from an existing subprogram. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch12.adb (Instantiate_Formal_Subprogram): Remove redundant

[Ada] Proof of runtime units for integer exponentiation (checks off)

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
This proves the generic unit System.Exponn instanciated for Integer, Long_Long_Integer and Long_Long_Long_Integer. In order to be able to add a suitable contract to the generic function, it is changed into a generic package which contains the function. Instantiations are adapted. GNATprove is call

[Ada] Simplify making of null procedure wrappers

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Yet another cleanup related to expansion of dispatching primitives for GNATprove. To keep this change semantically neutral, one parameter is added to the Copy_Subprogram_Spec utility routine. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Make_Null_Procedure_Sp

[Ada] Prevent Get_Current_Value_Condition from returning the same node

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Get_Current_Value_Condition should never return Val = Var, because that could cause infinite recursion in Known_Null. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.ads (Get_Current_Value_Condition): Belt: Add a postcondition that Val /= Var. * sem_

[Ada] Introduce expression functions for contract of Scan_Exponent

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Introduce expression functions to make the contract of Scan_Exponent more readable. They can be reused in the contracts of scan functions for scalar types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valuti.ads (Starts_As_Exponent_Format_Ghost): Ghost f

[Ada] Remove unnecessary check for missing parameter specifications

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
List iteration with First/Present/Next is safe even for No_List. This safety is intentional and we rely on it in many places. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_disp.adb (Gen_Parameters_Profile): Remove redundant guard

[Ada] Proof of runtime units for integer exponentiation (checks on)

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
This proves the generic unit System.Expont instantiated for Integer, Long_Long_Integer and Long_Long_Long_Integer. The proof is similar to the one done for the same units with checks off. In this case too, the generic function is changed into a generic package. GNATprove is called with switch --le

[Ada] Simplify handling of user-defined numeric literals

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (String_From_Numeric_Literal): Simplify using membership tests and ranges; fix whitespace.diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb --- a/gcc/ada/sem_ut

[Ada] Add contracts for the proof of System.Arith_128

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Similar to the contracts added for the 32bits and 64bits versions, add corresponding contracts for the 128bits version. Proof is currently too difficult for this instance of generic System.Arith_Double, as even with a huge prover timeout of 15 minutes, 2 checks remain unproved. Tested on x86_64-pc

[Ada] Fix condition to build subtype for discriminated types

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
We should build subtype for discriminated types in several situations where we know a priori that we never need to allocate the max possible size. To factorize these conditions between `Analyze_Component_Declaration` and `Analyze_Object_Declaration`, the function `Should_Build_Subtypes` is introdu

[Ada] Fix layout of parameters in calls to Predef_Spec_Or_Body

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to expansion of dispatching routines for GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Make_Eq_Body, Make_Neq_Body, Make_Predefined_Primitive_Eq_Spec, Make_Predefined_Primitive_Specs): Fix whitespace.diff --git a

[Ada] Remove extra space in parameter associations

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Whitespace cleanup related to cleanup of creating copies of subprogram specifications, which was needed for expanding dispatching wrappers for GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Two_Pass_Aggregate_Expansion): Fix whitespace. * li

[Ada] Align arrows in parameter associations

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Whitespace cleanup; wrong layout found with grep. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_Op_Ne): Fix whitespace. * sem_dim.adb (Expand_Put_Call_With_Symbol): Likewise. (Reduce): Likewise.diff --git a/gcc/ada/exp_ch4.adb b/gcc/ad

[Ada] Remove explicit "in" in internal parameter association

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to expansion of dispatching routines for GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Build_Array_VS_Func): Remove explicit "IN" in spec of the generated array validation function; it was redundant, just like i

[Ada] Remove extra whitespace in declarations and parameters lists

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Remove extra whitespace spotted while doing other cleanups related to expansion of dispatching routines for GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_Dcheck_Function): Remove extra whitespace. * libgnarl/s-taskin.adb (Initialize_AT

[Ada] Remove obsolete s-sopco* and s-strops units

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
These units are not required anymore as oldest compiler version allowed for bootstrap does not need them. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-sopco3.ads, libgnat/s-sopco3.adb: Remove. * libgnat/s-sopco4.ads, libgnat/s-sopco4.adb: Remove.

[Ada] Compiler crash with -gnatR2 and with of child

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes a bug where if a parent library package contains a with clause that mentions a child of that same parent package, then gnat can crash if the parent package is compiled with the -gnatR2 switch. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * repinfo.adb (List

[Ada] Simplify calls to Name_Find with known string parameter

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnatls.adb (Gnatls): Use Name_Find function. * targparm.adb (Get_Target_Parameters): Likewise.diff --git a/gcc/ada/gnatls.adb b/gcc/ada/gnatls.adb --- a/gcc/ada/gnatls.adb +++ b/gc

[Ada] Use Add_Char_To_Name_Buffer for 1-character strings

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Adding a single character to name buffer should be (marginally) more efficient with Add_Char_To_Name_Buffer and not Add_Str_To_Name_Buffer. Even if not more efficient, it should be still more readable. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_dbug.adb, sem_dim.adb

[Ada] Expand controlling functions wrappers in GNATprove mode

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Enable expansion of wrappers for dispatching functions with controlling results in GNATprove mode. Without those wrappers the AST for calls to dispatching functions on parent and child objects is exactly the same and the GNATprove backend can't determine what function is actually called. Tested on

[Ada] Expand controlling function wrapper into expression function

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
GNATprove prefers various internally generated functions to be expression functions, because then it will use the expression itself as an implicit postcondition. The same applies to wrappers for dispatching functions with controlling results. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/

[Ada] Simplify detection of alphabetic characters with membership test

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup originating from enabling expansion of dispatching wrappers for GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Adjust_External_Name_Case): Use membership test.diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb

[Ada] Improve support for casing on types with controlled parts

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
INOX allows casing on composite values. In some cases of bindings for subcomponents, the compiler introduced copying which led to compiler failures associated with finalizing those copies. In such cases a bound object now provides a constant view of the appropriate subcomponent of the selector obje

[Ada] Proof of runtime units for binary modular exponentiation

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
This proves the generic unit System.Exponu instantiated for Unsigned, Long_Long_Unsigned and Long_Long_Long_Unsigned. The proof is simpler than the one for signed integers, as there are no possible overflows here. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-exp

[Ada] Proof of runtime unit for non-binary modular exponentiation

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
This proof combines the difficulties of proving signed exponentiation, as we need to compare the result to the mathematical one using big integers, with pervasive use of modulo operation. This requires lemmas which should later be isolated in a shared library, for possible reuse in other runtime un

[Ada] Simplify GNAT AST printing with simple GNAT hash table

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
For pretty-printing of GNAT AST we had a custom hash table which stored visited nodes. Now this custom hash table is replaced with an instance of GNAT.Dynamic_Tables.Dynamic_Hash_Tables. Expansion and compression factors for this table are the same as for all other instances of Dynamic_Hash_Tables

[Ada] Simplify repeated calls in printing of GNAT AST

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * treepr.adb (Visit_Node): Simplify repeated call to Next_Entity.diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb --- a/gcc/ada/treepr.adb +++ b/gcc/ada/treepr.adb @@ -2305,8 +23

[Ada] Crash in class-wide pre/postconditions

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler may crash processing a class-wide pre/postcondition that has dispatching calls using the Object.Operation notation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * contracts.adb (Restore_Original_Selected_Component): New subprogram that traverses a prean

[Ada] Justify false positive message from CodePeer analysis of GNAT

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Analysis of loop variant is known to lead to false alarms with CodePeer. Add pragma Annotate in such a case which can be justified. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-exponu.adb (Exponu): Add annotation.diff --git a/gcc/ada/libgnat/s-exponu.adb b/gcc/a

[Ada] Removal of technical debt

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
This patch removes various technical debt in the form of "???" comments throughout the GNAT sources. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Add comments regarding special handling of components which depend on

[Ada] Suppress spurious CodePeer check on generic actual subprogram

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Procedure Destroy is intentionally doing nothing and needs an IN OUT parameter, because to match the profile of a generic formal subprogram. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * treepr.adb (Destroy): Prevent spurious check from CodePeer.diff --git a/gcc/ada/treepr

[Ada] Rename Any_Access into Universal_Access

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
The front-end defines an Any_Access entity which is only used as the type of the literal null. Now, since AI95-0230, the RM 4.2(8/2) clause reads: "An integer literal is of type universal_integer. A real literal is of type universal_real. The literal null is of type universal_access." and e.g. Fin

[Ada] Remove duplicates of empty strings

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
In package Stringt we already have a Null_String_Id, which represents a null string with length zero. There is no need to duplicate it in other packages. Cleanup originating from enabling expansion of dispatching wrappers for GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, comm

[Ada] New restriction No_Tagged_Type_Registration

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
This patch implements the No_Tagged_Type_Registration restriction, analogous to No_Exception_Registration, but for tagged types. Fix several violations of the RTE_Available protocol, as documented in rtsfind.ads: -- If we call this and it returns True, we should generate a reference to --

[Ada] Spurious error when using current instance of type

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes an issue in the compiler whereby it fails to recognize the presence of a current instance of an incomplete type when the instance is used within a default expression for a record component. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_A

[Ada] Avoid building malformed component constraints

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Given a discriminated type T1 with discriminant D1 having a component C1 of another discriminated type T2 with discriminant D2 and a propagated discriminant constraint (that is, "C1 : T2 (D2 => D1);" and, for example, a parameter of type T1, the compiler will sometimes build an anonymous subtype to

[Ada] Avoid building malformed component constraints

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
The previous fix introduced a not-yet-understood regression in compiling CodePeer. For now, we attempt a quick workaround for the problem. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Build_Discriminant_Reference): In the unexpected case where we pre

[Ada] Fix spurious error on instantiation with Text_IO name

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
This gets rid of a spurious error given by the compiler on the instantiation of a generic package, when the instance happens to be an homonym of one of the subpackages of Text_IO (Fixed_IO, Float_IO, etc) and when it is placed in a context where Text_IO itself is also visible. Tested on x86_64-pc-

[Ada] Fix style in calls to Compile_Time_Constraint_Error

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to handling of -gnatwE (warnings-as-errors) in instances of generic units. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Null_Exclusion_Static_Checks, Selected_Range_Checks): Fix style.diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb

[Ada] Refactor repeated implicit conversion from Char_Code to Uint

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
When resolving a string literal we examine each character against low and high bounds of the expected type. We stored each character as an Int and implicitly converted it to Uint twice: for "<" and ">" operators. Now we store convert it to Uint explicitly and only once. Cleanup related to handling

[Ada] Simplify type conversions in source pointer arithmetic

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup; semantics is unaffacted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_String_Literal): Simplify pointer arithmetic.diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -117

[Ada] Fix style in comments about warning messages

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to handling of messages for compile-time known constraint errors. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Error_Msg_Internal): Reorder words. * erroutc.ads (Is_Warning_Msg): Add closing paren. * sem_util.adb (Compile_Time_C

[Ada] Remove unreferenced Warn_On_Instance

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to handling of -gnatwE (warnings-as-errors) in instances of generic units. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * err_vars.ads (Warn_On_Instance): Remove; it was a relic from the previous handling of warning in instances that was removed

[Ada] Fix regression in freezing code for instantiations

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
When going to the outer level for the placement of a freeze node in the case where the current package has no body, the previous change would overlook instantiations whose body has not materialized yet. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch12.adb (Insert_Fre

[Ada] Remove unnecessary guards for non-empty lists

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
All node lists can be safely iterated with First/Present/Next. There is no need for explicit guard against empty lists. Code cleanup. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Remove_Warning_Messages): Remove unnecessary guard. * exp_util.adb (Kill_

[Ada] Move messages on division by zero to the right operand

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
All compile-time messages about division by zero are now located at the right operand. Previously some of them were located at the division operator, which was inconsistent. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.adb (Eval_Arithmetic_Op): Add Loc parameter

[Ada] Remove a locally handled exception

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to handling of warnings-as-errors. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_Concatenate): There is no reason for using declaring, raising and catching an exception; a simple return state

[Ada] Simplify traversal for removing warnings from dead code

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to handling of warnings-as-errors. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Remove_Warning_Messages): Use traversal procedure instead of traversal function, since we discard status of each step anywa

[Ada] Proof of System.Generic_Array_Operations at silver level

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Proof of the generic unit to array operations (vector/matrix), only at silver level, for runtime errors that come from the generic part of the unit. This does not prove e.g. absence of overflows in an instantiation related to arithmetic operations passed as formal generic subprogram parameters. Ju

[Ada] Remove unnecessary declare block

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to handling of warnings-as-errors. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Adjust_Name_Case): Remove unnecessary declare block.diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb --- a/gcc/ada/errout.

[Ada] Warn on subtype declaration of null range

2022-01-06 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds a warning on a subtype declaration with a compile-time-known range constraint that is a null range. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Range): Warn on null range, unless we are inside a generic unit or an instance the

[Ada] Small cleanup of osint-m.adb

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
We remove the "pragma Elaborate_All (Osint)", because it is no longer needed. That allows us to remove the "with Osint" (i.e. with of our own parent). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * osint-m.adb: Remove with_clause and pragma.diff --git a/gcc/ada/osint-m.adb

[Ada] Warn on import of parent package

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
There is no need to say "with P;" in package P.Q. This patch adds a warning for that case. We also remove with clauses in our own code that trigger the warning. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch10.adb (Check_Redundant_Withs): Add a warning if a

[Ada] Add an option to Get_Fullest_View to not recurse

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
This option is used by GNAT LLVM. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads, sem_util.adb (Get_Fullest_View): Add option to not recurse and return the next-most-fullest view.diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb --- a/gcc/ada/sem

[Ada] treepr: Print value of static expression

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
When printing a node, if it happens to be an integer-like expression whose value is known, print that value. This makes debugging a little easier. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * treepr.adb (Print_Node_Ref): Print the value if available.diff --git a/gcc/ada/t

[Ada] Use non-internal representation for access subprograms if UC to Address

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
If we have an Unchecked_Conversion between an access to subprogram and System.Address, we want to try to use a thin subprogram pointer. Try to do this automatically as much as possible and add one to the RTS. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-spipat.a

[Ada] treepr: print value only for discrete types

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Follow-on to previous change "Print value of static expression". Print only if the type is discrete. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * treepr.adb (Print_Node_Ref): Change "not Is_Array_Type" to "Is_Discrete_Type".diff --git a/gcc/ada/treepr.adb b/gcc/ad

[Ada] Check scalar range in arrays constructed by concatenation

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
When concatenating scalars, we should check their range as in the following example: type uint8 is range 0 .. 255; type Array_Type is array (Positive range <>) of uint8; Array_1 : Array_Type := 42 & 256; This commit leads to emitting: - a warning if a constraint error is expected but

[Ada] Remove unnecessary guards for appending non-empty lists

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Calls to Append_List and Append_List_To applied with empty lists do nothing, so there is no need to explicitly guard against such calls. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_Init_Procedure): Remove unnecessary guard. * exp_disp.adb (Make

[Ada] Remove unnecessary guard for inserting non-empty list

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Calls to Insert_List_After and Insert_List_Before applied to empty lists do nothing, so there is no need to explicitly guard against such calls. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Expand_N_Object_Declaration):

[Ada] Consistent suppression for warnings inside null loops

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Warnings for nodes inside null loops were suppressed if posted with Error_Msg_NLE and emitted if posted with other error-reporting routines. This was inconsistent and error-prone. Part of removing quotes around exception names in messages, because messages without quotes will be now emitted by Err

[Ada] Fix inconsistent quoting in messages about compile-time errors

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
In some messages of the form "XXX_Error will be raised at run time" the XXX_Error was enclosed in quotes, in other it was not. Now all messages of this form are emitted without quotes. Note: in messages emitted from routine Possible_Local_Raise we still quote names of exceptions, but there indeed

[Ada] Fix comment about subprogram unnesting and unconstrained arrays

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
The original code for subprogram unnesting used 'Access for unconstrained arrays. This was recently changed to 'Unchecked_Access for GNAT-to-LLVM, but a reference to 'Access still appears in the comment. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_unst.adb (Unnest_Su

[Ada] Update -gnatwr doc for import of parent package

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
This construct is now flagged with -gnatwr. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Update -gnatwr documentation. * gnat_ugn.texi: Regenerate.diff --git a/gcc/ada/doc/gnat_ugn/building_executabl

[Ada] Remove explicit expansion of block with general case statement

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
When a general case statements is rewritten into a block, it is enough to call Analyze on this block node, because analysis of non-expressions automatically triggers expansion. Cleanup originating from investigating many variants of routines for (pre)analysis and resolution. Tested on x86_64-pc-l

[Ada] Fix exit status of GNAT.Expect.Close call on running process

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Fix exit status processing logic in __gnat_waitpid. Fix GNAT.Expect.Interrupt on Windows. It was terminating the calling process. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * expect.c (__gnat_waitpid): Use macros WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WI

[Ada] Remove extra space before THEN keywords

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Style cleanup; semantics is unaffected. Offending occurrences found with: $ grep "[A-Za-z0-9\)]+ +then$" -C 3 and reviewed manually, because some of them were due to explicit layout. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch5.adb, exp_disp.adb, exp_util.ad

[Ada] Simplify traversal in hooking of transient scopes

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Subprogram calls can be detected with just Traverse_Func, we don't need a separate global variable or a Traverse_Proc (which is a wrapper for Traverse_Func with a yet another variable). Cleanup related to handling of transient scopes in various routines for (pre)analysis and resolution. Semantics

[Ada] Remove repeated routines for printing AST in Mixed_Case

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * osint.adb (To_Lower): Clarify that only To_Lower function causes bootstrap issues; fix style. * treepr.adb (Print_Str_Mixed_Case): Reuse existing case conversion ro

[Ada] Fix a couple of issues with pragma Inspection_Point

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
The first issue is that the pragma may require the address of the objects subject to it to have their address taken, like Asm_Input and Asm_Output, so these objects need to be specifically marked. The second issue is that the detection of unfrozen objects was not robust enough and would miss objec

[Ada] Fix __gnat_kill on Windows

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Terminate process only on terminating signals. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.c (__gnat_kill): Terminate process only in case of SIGKILL, SIGINT, SIGBREAK, SIGTERM, SIGABRT. Do not call OpenProcess if not going to terminate process.di

[Ada] Spurious error caused by order of interfaces in full view

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
The frontend reports a spurious error when the order of interfaces differ between the full view and the partial view of a private type defined in a generic unit. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Reorder_Interfaces): When the conflicting in

[Ada] Cleanup and modification of unreferenced warnings

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
This patch modifies the behavior of pragma Unreferenced to be consistent in its behavior, by counting all variables specified as "Out" actual parameters as being referenced instead of only the first "Out" parameter. Additionally, much related duplicated has been removed. Tested on x86_64-pc-linux-

[Ada] More default initialization for multi-dim array aggregates

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Expansion of multi-dimensional array aggregates with boxes (e.g. "(others => (others => <>))" only applied default initialization to components of a scalar type with Default_Value aspect and of an access type (which are initialized by default to null). Now default initialization is applied to comp

[Ada] Crash in class-wide pre/postconditions

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler may crash processing a class-wide pre/postcondition that has dispatching calls using the Object.Operation notation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * atree.ads (Traverse_Func_With_Parent): New generic subprogram. (Traverse_Proc_With_Parent)

[Ada] Fix style in expansion of multi-dimensional array aggregates

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code): Fix inconsistent style in comments and code.diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_a

[Ada] Fix layout of pragma Inline in generated AST unit

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
Make the generated nmake.ads unit look more like it was written with GNAT style rules in mind; semantics is unaffected. Cleanup related to fix of default initialization in multi-dimensional arrays, which used to explicitly call the Nmake.Make_Null routine. Tested on x86_64-pc-linux-gnu, committed

[Ada] Fix uses of pragma Unreferenced in MinGW runtime unit

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
GNAT now emits more warnings about pragma Unreferenced. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-taprop__mingw.adb (Timed_Sleep): Remove "pragma Unreferenced" for Result. (Timed_Delay): Likewise.diff --git a/gcc/ada/libgnarl/s-taprop__mingw.

[Ada] Fix the check of the 'Old prefix

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
The check did miss the part of Ada 2022 RM 6.1.1 (27/5) that the use of an entity declared within the postcondition expression is allowed if it's declared within the prefix itself. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Check_Reference): Fix condition.

[Ada] Read directory in Ada.Directories.Start_Search rather than Get_Next_Entry

2022-01-07 Thread Pierre-Marie de Rodat via Gcc-patches
The Ada.Directories directory search function is changed so the contents of the directory is now read in Start_Search instead of in Get_Next_Entry. Start_Search now stores the result of the directory search in the search object, with Get_Next_Entry returning results from the search object. This di

[Ada] Task arrays trigger spurious unreferenced warnings

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes an issue in the compiler whereby objects of task arrays would trigger spurious unreferenced warnings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_warn.adb (Check_References): Handle arrays of tasks similar to task objects.diff --git a/gcc/ada

[Ada] Fix error on too large size clause for bit-packed array

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler should give again a warning instead of an error, which comes from an improper Esize set on the bit-packed array type by Layout_Type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_pakd.adb (Install_PAT): Do not reset the alignment here. * layout.adb

[Ada] Switch from __sync to __atomic builtins for atomic counters

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
Unit System.Atomic_Counters was using deprecated __sync GCC builtins. Now it uses __atomic builtins, which are recommended for new code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-atocou__builtin.adb (Decrement, Increment): Switch from __sync to __atom

[Ada] Adjust the alignment to the size for bit-packed arrays

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
This fixes a fallout of the latest change, which removed a problematic line resetting the alignment of the PAT type. It turns out that the alignment must now be adjusted for modular PAT types, as done in other contexts, to be consistent with the size. Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Disable expansion of pragma Loop_Variant in CodePeer mode

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
Pragma Loop_Variant is expanded into code which is too complicated for CodePeer to handle and results in messages with internal names. Disable expansion. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_prag.adb (Expand_Pragma_Loop_Variant): Disable expansion in C

[Ada] Remove CodePeer annotations for pragma Loop_Variant

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
Pragma Loop_Variant is now expanded into a null statement in CodePeer mode. Remove annotations related to false positives in runtime units. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-exponn.adb, libgnat/s-expont.adb, libgnat/s-exponu.adb, libgnat/s-wid

[Ada] Switch from __sync to __atomic builtins for Lock_Free_Try_Write

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
Routine Lock_Free_Try_Write was using deprecated __sync GCC builtins. Now it uses __atomic builtins, which are recommended for new code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-atopri.ads (Atomic_Compare_Exchange): Replaces deprecated Sync_Compare_A

[Ada] Make pragma Inspection_Point work for constants

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
This entails marking the pragma as requiring an lvalue and explicitly going to the corresponding variable of the constants, which is always built since the front-end marks the constants as having their address taken. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interf

[Ada] Fix internal error on unchecked union with component clauses

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
The issue arises when the unchecked union contains nested variants, i.e. variants containing themselves a variant part, and is subject to a full representation clause covering all the components in all the variants, when the component clauses do not align the variant boundaries with byte boundaries

[Ada] Fix bogus error on call to subprogram with incomplete profile

2022-01-10 Thread Pierre-Marie de Rodat via Gcc-patches
This fixes a bad interaction between the machinery used to build subprogram types referencing incomplete types and the Copy-In/Copy-Out mechanism used to implement In/Out and Out parameters of elementary types in subprograms. The latter mechanism cannot be finalized until after incomplete types ar

[Ada] Use atomic builtins for atomic counters on x86 (32bit)

2022-01-11 Thread Pierre-Marie de Rodat via Gcc-patches
Remove the x86-specific (32bit) variant of System.Atomic_Counters, because the __atomic builtins work fine on all x86 CPUs except for i386, where they can be provided by libatomic (when compiling with -march=i386). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl

[Ada] Document LLVM-specific flags

2022-01-11 Thread Pierre-Marie de Rodat via Gcc-patches
Add documentation for new -gnatd_u and old -gnatd_R flags used for GNAT LLVM and its CCG. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * debug.adb: Add documentation for new -gnatd_u and old -gnatd_R flags used for GNAT LLVM and its CCG.diff --git a/gcc/ada/debug.ad

[Ada] Escalate pre-continuation messages from warnings to errors

2022-01-11 Thread Pierre-Marie de Rodat via Gcc-patches
When a compile-time constraint error is inserted into the AST, we emit a main message (e.g. "value not in range of ...") and its continuation (e.g. "Constraint_Error will be raised at run time"). When the main message is emitted as a warning and the continuation is escalated into an error, the main

[Ada] Code cleanups

2022-01-11 Thread Pierre-Marie de Rodat via Gcc-patches
Use membership tests when possible Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch9.adb, gen_il-types.ads, make.adb, par-ch12.adb, sem_ch13.adb: Use membership tests.diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada

<    29   30   31   32   33   34   35   >