[Ada] Another case where freezing incorrectly suppresses checks

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Avoid improperly suppressing checks for the wrapper subprogram that is built when a null type extension inherits (and does not override) a function with a controlling result. This is a follow-up to other changes already made on this ticket. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ad

[Ada] Note that hardening features are experimental

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Some features haven't got customer feedback or made upstream yet. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/security_hardening_features.rst: Note that hardening features are experimental. * gnat_rm.texi: Regenerate.diff --git a/gcc/ada/doc/g

[Ada] Get rid of secondary stack for controlled components of limited types

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
The initial work didn't change anything for limited types because they use a specific return mechanism for functions called build-in-place where there is no anonymous return object, so the secondary stack was used only for the sake of consistency with the nonlimited case. This change aligns the li

[Ada] Propagate null-exclusion to anonymous access types

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
When analyzing an array or record type declaration whose component has a constrained access type, e.g.: type Buffer_Acc is not null access all String; type Buffer_Rec is record Data : Buffer_Acc (1 .. 10); end record; type Buffer_Arr is array (Boolean) of Buffer_Acc (1 .. 10);

[Ada] Fix bad interaction between Inline_Always and -gnateV + -gnata

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
The combination of pragma/aspect Inline_Always and -gnateV -gnata runs afoul of the handling of inlining across units by gigi, which does not inline a subprogram that calls nested subprograms if these subprograms are not themselves inlined. This condition does not apply to internally generated sub

[Ada] Enable using absolute paths in -fdiagnostics-format=json output

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This commit makes GNAT use absolute paths in -fdiagnostics-format=json's output when -gnatef is present on the command line. This makes life easier for tools that ingest GNAT's output. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_

[Ada] arm-qnx-7.1: unwind goes wrong after regs restore

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Bump the pc +3 total for Thumb mode, the same calculation that as is done for arm-linux. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * init.c (__gnat_adjust_context_for_raise) [QNX][__thumb2__]: Bump the pc an extra byte.diff --git a/gcc/ada/init.c b/gcc/ada/init.c

[Ada] Fix predicate check on object declaration

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
When subtype predicate checks are added for object declarations, it could lead to a compiler crash or to an incorrect check. When the subtype for the object being declared is built later by Analyze_Object_Declaration, the predicate check can't be applied on the object instead of a copy as the call

[Ada] Bug fix in "=" function of formal doubly linked list

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Correction of a typo regarding indexes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfdlli.adb ("="): Make the function properly loop over the right list.diff --git a/gcc/ada/libgnat/a-cfdlli.adb b/gcc/ada/libgnat/a-cfdlli.adb --- a/gcc/ada/libgnat/a-cf

[Ada] Do not freeze subprogram body without spec too early

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This fixes a small oddity whereby a subprogram body declared without a spec would be frozen before its entity is fully processed as an overloaded name. Now the latter step computes useful information, for example whether the body is a (late) primitive of a tagged type, which can be required during

[Ada] Fix classification of Subprogram_Variant as assertion pragma

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This pragma was wrongly not recognized as an assertion pragma. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.ads (Assertion_Expression_Pragmas): Fix value for pragma Subprogram_Variant.diff --git a/gcc/ada/sem_prag.ads b/gcc/ada/sem_prag.ads --

[Ada] Rename Returns_On_Secondary_Stack into Needs_Secondary_Stack

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
The Returns_On_Secondary_Stack predicate is a misnomer because it must be invoked on a type and types do not return; as a matter of fact, the other Returns_XXX predicates apply to functions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Caller_Known_Size): Inv

[Ada] Fix missing space in error message

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
On illegal code like: type T is new Positive in range 1..5; the compiler was emitting message: error: extra "in"ignored ^^ which lacked a space character. A tiny diagnostic improvement; spotted while mistakenly typing an illegal test. Tested on x86_64-pc-linux-gnu, comm

[Ada] Combine system.ads files - arm and aarch64 qnx

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-qnx-arm.ads (Memory_Size): Compute based on Word_Size.diff --git a/gcc/ada/

[Ada] Combine system.ads file - vxworks7 kernel constants.

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-aarch64.ads (Word_Size): Compute based on Standard'Word_Size. (Mem

[Ada] Allow confirming volatile properties on No_Caching variables

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Volatile variables marked with the No_Caching aspect can now have confirming aspects for other volatile properties, with a value of False. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * contracts.adb (Check_Type_Or_Object_External_Properties): Check the validity of

[Ada] Add contracts to Interfaces.C.Strings

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds Global contracts and preconditions to subprograms of Interfaces.C.Strings. Effects on allocated memory are modelled through an abstract state, C_Memory. The preconditions protect against Dereference_Error, but not Storage_Error (which is not handled by SPARK). This patch also disabl

[Ada] Add contracts to System.Address_To_Access_Conversions

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds SPARK annotations to subprograms from System.Address_To_Access_Conversions. To_Pointer is considered to have no global items, if the returned value has no aliases. To_Address is forbidden in SPARK because addresses are not handled. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Fix iteration on formal vectors

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
We need to use Extended_Index for the Position parameter of the Element function in formal vectors so it is compatible with other primitives of the Iterable aspect. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfinve.ads (Element): Change the type of the

[Ada] Gnatbind crash during checksum calculation

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby gnatbind may crash during calculation of file checksums in certain corner cases due to uninitialized lookup tables. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnatbind.adb (Gnatbind): Add initialize call for Uintp

[Ada] Combine system.ads file - vxworks7 rtp constants

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-aarch64-rtp-smp.ads (Word_Size): Compute based on Standard'Word_Si

[Ada] Combine system.ads files - arm and aarch64 linux

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-linux-arm.ads (Memory_Size): Compute based on Word_Size.diff --git a/gcc/ad

[Ada] Propagate Has_Inherit{able,ed}_Invariants to base types

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
The two flags apply to base types only like Has_Own_Invariants. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Propagate_DIC_Attributes): Add ??? comment. (Propagate_Invariant_Attributes): Likewise. Propagate the Has_Inheritable_Invariants and

[Ada] Complete contracts of Interfaces.C.Strings subprograms

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds preconditions to Update procedures, to protect from Update_Error propagations. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/i-cstrin.ads (Update): Add precondition.diff --git a/gcc/ada/libgnat/i-cstrin.ads b/gcc/ada/libgnat/i-cstrin.ads --- a/gcc/a

[Ada] Issue errors on wrong context for ghost entities

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
References to ghost entities should only occur in ghost context. This was not checked systematically on all references. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch2.adb (Analyze_Identifier): Add checking for ghost context. * sem_ch5.adb (Analyze_I

[Ada] Fix preconditions of Interfaces.C.Strings

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Preconditions of Update procedures were always true when Offset was 0. The changes enable to protect from Update_Error when Offset is 0. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/i-cstrin.ads (Update): Update precondition.diff --git a/gcc/ada/libgnat/i-cstrin.a

[Ada] Fix detection of deferred constants for freezing error

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Testing Is_Frozen is not robust enough, so instead test that the full view has been seen and that the Has_Completion flag is set on it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Check_Expression_Function.Find_Constant): Make test for deferred consta

[Ada] Update documentation of GNAT.Dynamic_Tables

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Document that dynamic tables are defined aliased for backward compatibility. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-dyntab.ads (Table_Type): Update documentation.diff --git a/gcc/ada/libgnat/g-dyntab.ads b/gcc/ada/libgnat/g-dyntab.ads --- a/gcc/ada/libgnat

[Ada] vx7r2-arm/aarch64 - Support Atomic Primitives True

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This feature is an architecture feature, not an OS feature, so enable on vx7r2 for arm and aarch64 to coincide with what is done on similarly capable targets. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-arm.ads (Support_Atomic_Primitives):

[Ada] Build static dispatch tables always at the end of declarative part

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
The static dispatch tables of library-level tagged types are either built on the first object declaration or at the end of the declarative part of the package spec or body. There is no real need for the former case, and the tables are not built for other constructs that freeze (tagged) types. Ther

[Ada] Move registering code for predefined primitives to Exp_Disp

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This avoids making Expand_Interface_Thunk visible from the outside. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Freeze_Subprogram.Register_Predefined_DT_Entry): Move procedure to... * exp_disp.ads (Expand_Interface_Thu

[Ada] Fix spurious errors on ghost code in generics

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
After the recent fix for detecting illegal use of ghost entities in code, spurious errors could be raised on generic code with ghost, due to wrong setting of the ghost flags on copied entities from the generic to the instantiation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Refine previous changes on making symbols public/private

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Inline_Always procedures should be kept public for proper inter unit inlining. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch7.adb (Set_Referencer_Of_Non_Subprograms): New local procedure, used for code refactoring. Also take into account Inline_Alway

[Ada] Add precise subprogram identification to -fdiagnostics-format=json

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This commit adds information allowing identification of the subprogram surrounding the message emitted by gnat when using -gnatdJ along with -fdiagnostics-format=json. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Write_JSON_Span): Add subprogram name to emitte

[Ada] Fix spurious use of trampolines with interface types

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Function pointers must always be built with '[Unrestricted_]Access. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Init_Secondary_Tags.Initialize_Tag): Initialize the Offset_Func component by means of 'Unrestricted_Access.diff --git a/gcc/ada/exp_ch3.ad

[Ada] Rename GNATprove annotate pragma for termination to Always_Return

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
GNATprove changed the name of the pragma Annotate used to verify that a subprogram always returns normally. It is now called Always_Return instead of Terminating. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb: Use Always_Return instead of Terminating

[Ada] Make the functional Maps and Sets unbounded

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Before this patch, the Functional Sets ans Maps were bounded both from the user and the implementation points of view. To make them closer to mathematical Sets ans Maps, this patch removes the bounds from the contracts. Note that, in practice, they are still bounded by Count_Type'Last, even if the

[Ada] Fix references to old variables that have been refactored

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Local_Entity_Suppress and Global_Entity_Suppress variables referencing tables were refactored to Local_Suppress_Stack_Top and Global_Suppress_Stack_Top stacks back in 2007. Fix remaining references to these variables. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ad

[Ada] Remove redundant checks for missing lists

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
When iterating over list elements with First/Next there is no need to check if the list is present, because First intentionally returns Empty if list is not present and the condition of subsequent loop will not be satisfied. Code cleanup; semantics is unaffected. Occurrences of the redundant patt

[Ada] Get rid of secondary stack for most calls returning tagged types

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This eliminates the use of the secondary stack to return specific tagged types from functions in calls that are not dispatching on result, which comprises returning controlled types, by introducing thunks whose only purpose is to move the result from the primary to the secondary stack for primitive

[Ada] Never make symbols for thunks public

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Thunks are only referenced locally by dispatch tables and never inlined. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Clear the Is_Public flag on thunks.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/

[Ada] Restore full generation of static dispatch tables with -gnatzr

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
The -gnatzr switch triggers the creation of distribution stubs for use by the implementation of PolyORB. Now these stubs declare tagged types and are generated at the very end of the analysis of compilation units, after the static dispatch tables have been built, so these tables are missing for th

[Ada] Couple of small preparatory adjustments

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Do not check the scope of anonymous access Itypes. * gcc-interface/trans.cc (Identifier_to_gnu): Do not translate the return type of a s

[Ada] Disable -flto when building the shared libgnat

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This setting isn't useful in this context. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/Makefile.in (gnatlib-shared-default): Add -fno-lto.diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in --- a/gcc/ada/gcc-interface/

[Ada] Fix record layout warnings not being tagged

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This allows tools ingesting GNAT's output to properly classify these messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (warn_on_field_placement): Add insertion character '.q' to warning string.diff --git a/gcc/ada/gcc-interface/decl.cc b

[Ada] Reduce runtime dependencies on stage1

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
To simplify the bootstrap constraints, duplicate a few definitions in order to remove dependencies on a recent version of System.Case_Util, System.Crtl, System.OS_Lib. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * osint.adb (File_Names_Equal): Declare To_Lower locally.

[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

<    3   4   5   6   7   8   9   >