[Ada] Fix access to predicated parent in Itype

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Getter function Predicated_Parent expects to be called on subtypes only, which was not enforced always, possibly leading to assertion failures on compiler built with assertions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Build_Predicate_Functions): Access

[Ada] More precise analysis of function renamings in GNATprove

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
When a function renaming has a contract, it is important for GNATprove that it is not treated as a simple wrapper, otherwise the link between the renamed function and its renaming is lost for proof. Instead, it should be treated as an expression function. There is no impact on compilation. Tested

[Ada] Removal of technical debt

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
This is an iterative patch as part of a greater project to reduce the amount of technical debt present in the frontend of the compiler. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ali.adb, ali.ads (Scan_ALI): Remove use of deprecated parameter Ignore_ED, and all

[Ada] Fix infinite loop in compilation of illegal code

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
When rewriting a derived type declaration into a subtype declaration, the aspect specifications were shared in a way that made the aspect point to a node outside of the tree as parent node. This could lead to an infinite loop on illegal code using a non-static value for attribute Object_Size of the

[Ada] Add Package_Body helper routine to be used in GNATprove

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
We already had Subprogram_[Body|Spec|Specification] family of routines; now we also have a symmetrical Package_[Body|Spec|Specification] family. The added Package_Body routine is essentially moved from GNATprove, but for simplicity it doesn't support package body entities. Tested on x86_64-pc-lin

[Ada] VxWorks inconsistent use of return type (BOOL)

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Type BOOL is made a new int to be consistent with the typedef used in the C header files. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-vxwext.ads (BOOL): New int type. (Interrupt_Context): Change return type to BOOL. * libgnarl/s-vxwext__kernel.

[Ada] Add adequate guard before calling First_Rep_Item

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
New contracts on Ada.Strings.Bounded revealed an unprotected call to First_Rep_Item on a possibly empty node. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Build_Predicate_Functions): Add guard.diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb --- a/gc

[Ada] Contracts written for the Ada.Strings.Bounded library

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Written SPARK contracts describing the behaviours of all functions of the Ada.Strings.Bounded library. All contracts are replicated in Ada.Strings.Superbounded, the package that provides the explicit implementation of bounded strings. The contracts (with the exception of Trim, which uses search fun

[Ada] More flexibility in preprocessor

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
When using -gnatd.M (or in codepeer mode), we want to be more flexible in the preprocessor syntax, to accomodate better legacy toolchains. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * prep.adb (Preprocess): Allow for more flexibility when Relaxed_RM_Semantics is s

[Ada] VxWorks inconsistent use of return type (STATUS)

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Type STATUS is made a new int with constants OK and ERROR declared. In code where ERROR clashes with an already defined integer value, the clashing variable is renamed to IERR. In other clashes where STATUS is a variable that variable is renamed. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Update status of some attributes

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
These attributes are no longer GNAT specific. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * snames.ads-tmpl: Update status of some attributes.diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl --- a/gcc/ada/snames.ads-tmpl +++ b/gcc/ada/snames.ads-tmpl @@ -963,

[Ada] Clarify parts of Ada.Strings.Unbounded in SPARK or not

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Except for the Free procedure which should not be called in SPARK code (as it could be called on pointers to the stack), the rest of the public API of Ada.Strings.Unbounded is valid in SPARK. Mark the private part not in SPARK as it uses controlled types. Tested on x86_64-pc-linux-gnu, committed o

[Ada] Fix conformance errors and erroneous code

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes many cases where a formal parameter is declared as Node_Id on the spec, and Entity_Id on the body (and similar), which is illegal according to the conformance rules. It also removes some erroneous pragmas Suppress, and initializes the uninitialized variables that were being read.

[Ada] Spurious error on deferred constant with predicate

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Do not insert a predicate check after a deferred constant declaration, as the constant is not elaborated at this point, but only at the point of its completion. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Do not insert a

[Ada] Reuse routines for detecting attributes Old and Result

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to handling of attribute 'Old in Contract_Cases; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_Op_Eq): Reuse Is_Attribute_Result. * exp_prag.adb (Expand_Attributes): Reuse Is_Attribute_Old.diff --g

[Ada] Simplify contract of Ada.Strings.Fixed.Trim for proof

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Use of two nested existential quantications makes proof brittle. Use instead explicit values for the bounds given by Index_Non_Blank, like done in Ada.Strings.Bounded. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strfix.ads (Trim): Simplify contracts. *

[Ada] Remove global parameter in Global contracts of Ada.Strings.Bounded

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
The predefined Ada.Strings.Bounded unit has been annotated SPARK contracts that reference a local constant: generic Max : Positive; package Generic_Bounded_Length Max_Length : constant Positive := Max; function XXX return YYY with Global => Max_Length; ... When this

[Ada] Update "Implementation Defined Characteristics" documentation.

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
Ada RM M.2 gives a list of implementation-defined characteristics, each of which is required to be documented. This requirement is addressed in the "Implementation Defined Characteristics" section of the GNAT RM. This section needs to be updated to reflect changes to the Ada RM M.2 over the last fe

[Ada] Minimize parts of Ada.Strings.Fixed marked SPARK_Mode => Off

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
Replace use of SPARK_Mode Off on callers of procedure Move by stronger preconditions, as mandated by Ada RM A.4.3, so that calls to the corresponding functions inside the procedure bodies are provably correct. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strfix.

[Ada] Remove Initializes contracts from Ada.Strings.Bounded

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
SPARK rules regarding constants with variable inputs and generic actual parameters are currently not flexible enough to allow an explicit Initializes contract on Ada.Strings.Bounded.Generic_Bounded_Length. This patch removes the explicit contract, so that GNATprove generates an implicit one with o

[Ada] Cleanup and efficiency improvements

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
This patch implements some efficiency improvements related to field getters and setters, and implements some cleanups that make the efficiency improvements easier. Instead of just storing the Offset with each node, we store a node header, which contains the Offset plus a small number of slots. Fie

[Ada] If unnesting and relocating subprogram call, make new Parameter_Associations

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
When unnesting, we may add static links to the actual parameters. This will cause duplication if a the Parameter_Associations list is shared, so ensure that we make a new one in this situation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * atree.adb (Relocate_Node): If rel

[Ada] Follow-on efficiency improvements

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
This patch improves compiler efficiency by placing the Homonym attribute at offset zero. Homonym is a heavily used field. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen.adb: Set the number of concrete nodes that have the Homonym field to a higher number t

[Ada] Tune detection of internally generated positional aggregates

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
In Resolve_Array_Aggregate we typically compute and set Aggregate_Bounds based on the aggregate itself. We only need to keep the already computed bounds for aggregates that have been optimized into positional ones. However, we kept the already computed bounds for other aggregates too. In particula

[Ada] Ada2022: implementation of AI12-0212 : iterator specs in array aggregates

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
This patch implements the two-pass algorithm described in RM 4.3.3 (20.2/5), for the construction of an array aggregate all of whose component associations are iterated component associations with iterator specifications. Each iterator specification is executed twice: once to compute the number of

[Ada] Adjust documentation of gnatsymbolize

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
This documents the new --load option and makes a few minor tweaks. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/gnat_utility_programs.rst (gnatsymbolize): Document new --load option and -g1 as minimal compilation requirement.diff --git a/gcc/a

[Ada] Wrappers of access-to-subprograms with pre/post conditions

2021-09-23 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes decoration of wrappers of access to subprograms with pre/post conditions (that is, wrappers internally built by the compiler to support AI12-0220). This patch also adds assertions, fixes node decorations, and avoids cascade errors. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Switch to SR0660

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
Change to 64bit time to avoid Unix Epochalypse. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-parame__vxworks.ads (time_t_bits): Change to Long_Long_Integer'Size.diff --git a/gcc/ada/libgnat/s-parame__vxworks.ads b/gcc/ada/libgnat/s-parame__vxworks.ads --

[Ada] Fix CodePeer warnings

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
This commit fixes warnings emitted by the CodePeer static analyzer. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Iterated_Component_Association): Initialize Id_Typ to Any_Type by default.diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.ad

[Ada] No ABE check needed for an expression function call.

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
If -gnatE is specified, then in some cases a call to a subprogram includes a check that the body of the subprogram has been elaborated. No such check is needed in the case of an expression function that is not a completion; the function has no prior declaration. However, in some cases the compiler

[Ada] Improve error message for .ali file version mismatch

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
When the binder detects a mismatch between the versions of two .ali files, include the version information in the resulting message. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * bcheck.adb (Check_Versions): In the case of an ali file version mismatch, if distinct

[Ada] Spurious range checks on aggregate with non-static bounds

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
Refine predicate Must_Slide to ensure that no spurious range checks are generated when context subtype and aggregate subtype are non-static. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Must_Slide): If the aggregate only contains an others_clause no

[Ada] Support gmem.out longer than 2G on 32 bit platforms

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
C stream fopen function opens file for size no more than 2G by default on 32 bit platforms. Use fopen and other stream functions from System.CRTL to overcome this limit. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/memtrack.adb (Putc): New routine wrapped around f

[Ada] Info. gathering in preparation for more efficiency improvements

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
Information gathering in preparation for more efficiency improvements. We gather statistics from the running compiler, and we also have gen_il generate information in the form of comments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * atree.adb: Gather and print statistics

[Ada] Fix bug in inherited user-defined-literal aspects for tagged types

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
In some cases, an integer literal of a tagged type whose Integer_Literal aspect is inherited from an ancestor type was not handled correctly by the compiler. In particular, Ada RM 13.1(15.5) was not correctly implemented, resulting in the incorrect rejection of legal uses of integer literals with (

[Ada] Improve error message for .ali file version mismatch

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
When the binder detects a mismatch between the versions of two .ali files, include the version information in the resulting message. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * bcheck.adb (Check_Versions): Add support for the case where the .ali file contains bot

[Ada] Fix deleting CodePeer files for non-ordinary units

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
A routine for deleting SCIL files generated by previous CodePeer runs didn't expect compilation units that are subprogram renamings, generic renamings and generic subprogram declarations. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * comperr.adb (Delete_SCIL_Files): Handle

[Ada] Implementation of AI12-0212: iterator specs in array aggregates (II)

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds a guard to the code generated in the second pass of the two-pass expansion for array aggregates described in AI12-0212. The guard is needed to prevent a spurious constraint error when incrementing the index used for aggregate insertion, before exiting the loop. Tested on x86_64-pc

[Ada] Ada2022: AI12-0195 overriding class-wide pre/postconditions

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
New implementation of class-wide pre/postconditions that relies on helpers to move the corresponding runtime checks to the caller side. This implementation also adds indirect call wrappers and dispatch table wrappers that facilitate combining class-wide conditions with access-to-subprogram types wi

[Ada] Assert_Failure on derived type with inherited Default_Initial_Condition

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
A type derived from a private type that specifies Default_Initial_Condition can lead to an assertion failure when the compiler builds the body of the derived type's DIC procedure. Some code inherited from type invariants doesn't apply in the DIC case, and performed an incorrect assertion testing fo

[Ada] Crash on renaming within declare expression

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue in the compiler whereby a renaming within a declare expression may result in a crash in some systems. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_dbug.adb (Debug_Renaming_Declaration): Add check for Entity present for Ren to preve

[Ada] Add more node unions

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
Also fix [se]info.h output to include both declarations and definitions of the functions for unions so that unions can refer to other unions without being order-dependent. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen-gen_nodes.adb (N_Alternative, N_Is_Case_Choi

[Ada] Stub CUDA_Device aspect

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
The CUDA_Device aspect allows specifying an entity as being device (GPU)-only. This commit implements the basic machinery to detect the aspect/pragma, but does not implement any functionality (a warning is issued instead). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * aspe

[Ada] Spurious warning about hiding in generic instantiation

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
Warnings about declarations being hidden can be issued in some cases when compiling a generic instantiation, but such warnings aren't correct (hiding can be flagged in a generic, but shouldn't be in an instance). The warning is now suppressed within instances. Tested on x86_64-pc-linux-gnu, commit

[Ada] Add new debug switch -gnatd.8

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
It will be used to tame the inlining of expression functions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * debug.adb (d.8): Document usage. * fe.h (Debug_Flag_Dot_8): Declare.diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb --- a/gcc/ada/debug.adb +++ b/gcc/ada/

[Ada] Add missing guard before call to Interface_Present_In_Ancestor

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
Calling the function on an unspecified type may trigger the failure of the precondition of the Interfaces accessor. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_type.adb (Specific_Type): Check that the type is tagged before calling Interface_Present_In_Ancesto

[Ada] Crash on improper use of GNAT attribute Type_Key

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes a crash on a case statement whose expression is an attribute reference Type_Key, which yields a String. The attribute reference may have been fully analyzed, and the resolution against Any_Discrete fails to detect the error. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/a

[Ada] Document rounding mode assumed for dynamic floating-point computations

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
It is only documented for static computations currently. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementation_defined_characteristics.rst: Document the rounding mode assumed for dynamic computations as per 3.5.7(16). * gnat_rm.texi: Rege

[Ada] More work on efficiency improvements

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
Gather more statistics, and make some minor efficiency improvements. Adjust the heuristic for the order in which we choose field offsets. This reduces the maximum size of a node from 10 slots to 9 slots, and makes the compiler a little bit faster. Add more special cases for fields whose offsets s

[Ada] Improved checking for invalid index values when accessing array elements

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
Ensure that the consequences of indexing into an array with the value of an uninitialized variable are consistent with Ada RM 13.9.1(11) by generating additional validity checks in some array indexing cases. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.ads: Define

[Ada] Empty CUDA_Global procedures when compiling for host

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
This commit makes GNAT empty CUDA_Global procedures when compiling for the host. This is required because CUDA_Global procedures could be referencing entities that only exist on the GPU, which would result in errors from the linker at link time. We empty the procedures rather than completely delet

[Ada] Subprogram_Variant in ignored ghost code

2021-09-30 Thread Pierre-Marie de Rodat via Gcc-patches
If a Subprogram_Variant aspect is given in ghost code, and the assertion policy is set to Ghost => Ignore, and the -gnata switch is used, the compiler gives spurious error messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_Call_Helper): Do not call

[Ada] Build activation chain for BIP only when needed

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
In some cases, BIP references tasking while it is not needed. Check if this is needed before adding this reference. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_Actuals): Add a condition to check for the possibility of task.diff --git a/gcc/ad

[Ada] Guard against illegal items in Global but not Depends

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
An illegal item appearing in the Global contract but missing from the Depends contract was crashing the compiler. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Check_Usage): Guard against calling Usage_Error with illegal Item_Id. The intention to do t

[Ada] Fix support for prefixed call with incomplete type declarations

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
GNAT crashes when using -gnatX on code with an incomplete type declaration, due to a missing initialization of the list meant to store primitive operations. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Analyze_Incomplete_Type_Decl): Add the missing

[Ada] Fix detection of array aggregates with single others associations

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Detection of array aggregates of the form "(others => ...)" needs to be adapted to iterated_component_association, which was added by Ada 2022. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Apply_Constraint_Check): Guard against calling Choices when the

[Ada] Complete support for prefixed call on subtypes/derived types

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Definition of subtypes and derived types needs to possibly initialize the list meant to store primitive operations when -gnatX is used. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Analyze_Subtype_Declaration, Derived_Type_Declaration): Initialize lis

[Ada] Add missing regular expression syntax error check

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
The procedure System.Regexp.Compile.Check_Well_Formed_Pattern is intended to verify the syntactic correctness of a regular expression pattern. It was failing to detect the (incorrect) case of a pattern that ends in a "|". Subsequent code depends on the pattern being correct, so failing to detect t

[Ada] Tune comment about expansion of array equality

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to expansion of dispatching equality for GNATprove. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Arr_Attr): Refine type of the parameter from Int to Pos; refine name of the parameter from Num to Dim; fix

[Ada] Errors on globals in expressions of predicate aspects in generic bodies

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
When a predicate aspect is given on a declaration inside of a generic body and the expression of the aspect references entities declared outside of the generic, errors about those entities not being defined can be issued in instantiations of the generic. This happens because the expression of the P

[Ada] Document the SuSE kernel bug

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
We found a SuSE kernel bug that affects 32-bit debugging on 64-bit machines. We agreed to document the problem in gnat_ugn. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/platform_specific_information.rst: Document the SuSE kernel bug. * gnat_u

[Ada] Reference in Unbounded_String is almost never null

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
The underlying reference in Unbounded_String is almost never null, so recently it was changed to a non-excluding type (to avoid runtime checks that are almost never needed). The low-level routines that modify that reference had to be adapted, but only the Deallocate routine was adapted. This patch

[Ada] Simplify expansion of array equality

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to expansion of dispatching equality for GNATprove. Semantics is unaffected Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Test_Empty_Arrays): Simplify with Evolve_Or_Else; remove unnecessary call to Relocate_Node. (Test_Lengths_

[Ada] Return a valid value when handling Constraint_Error

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
We hit the Constraint_Error because Start_Column is outside bounds. So it should not be returned because that will again raise a Constraint_Error. Instead return its type'Last which is then properly handled. Also reformat the Blanks_Loop to be a simple loop. It seems, the nested if's were writte

[Ada] Simplify building of entity occurrences

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to expansion of predefined equality for GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * tbuild.adb (New_Occurrence_Of): Simplify by reusing Make_Identifier.diff --git a/gcc/ada/tbuild.adb b/gcc/ada/tbuild.adb -

[Ada] Refine type in expansion of array equality

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to expansion of predefined equality for GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Handle_One_Dimension): Parameter N must be always positive, because it is translated into expression of 'Firs

[Ada] Cleanup building of renamed equality

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to expansion of predefined equality for GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch8.adb (Build_Body_For_Renaming): Remove unnecessary calls to Sloc; set Handled_Statement_Sequence when building s

[Ada] Cleanup copying of parameter lists

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to expansion of predefined equality for GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Copy_Parameter_List): Refactor to remove repeated calls to First_Formal.diff --git a/gcc/ada/sem_util.adb b/gcc/a

[Ada] Accessibility fix

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
This commit fixes an issue where when creating initialization procedures, GNAT would generate failing accessibility checks because it would use the scope depth of the parameter of the initialization procedure instead of using the scope depth passed as parameter. Tested on x86_64-pc-linux-gnu, comm

[Ada] Use atomics in runtime on ARM and Aarch64 VxWorks

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
For ARM and Aarch64 architectures we use runtime units that rely on atomic builtins instructions on all OSes except VxWorks (e.g. QNX, Linux, FreeBSD). This looks like an oversight, because the builtins depend on the architecture, not on the OS. Part of improving efficiency of the Ada.Strings.Unbo

[Ada] Initialize Current_Source_Unit

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Preprocessing may call Error_Msg though Current_Source_Unit is not initialized. When gnat1 is compiled with gnatVa, this leads to a Constraint_Error. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sinput.ads: Initialize Current_Source_Unit to No_Unit.diff --git a/gcc/ada/si

[Ada] Improve integration of strub with type systems

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
This patch brings various improvements to the integration of strub modes into the Ada type system. Strub modes for subprograms are promoted to subprogram types when applied to access-to-subprogram objects and types, and promoted from subprograms to access types' designated types. Matching strub m

[Ada] Crash on expansion of tagged membership test

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue in the compiler whereby the expansion of a tagged membership test when one of the types involved is a protected type can cause a crash a compile-time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Tagged_Membership): Use correspond

[Ada] Hang on compilation of unit with type extension in body

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue in the compiler whereby the expansion of a type extension declared in the body of a package with an overriding primitive causes an infinite loop during compilation when the type being extended is both declared in the package spec and has a function and a procedure primi

[Ada] Do not indicate a pending abort if the task is already aborting

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Check_Abort_Status would return the equivalent of True while a task was in the process of aborting causing another Abort exception to be raised and not to terminate cleanly. This only affects targets that use stack check emulation, which is currently limited to RTEMS. Tested on x86_64-pc-linux-gnu

[Ada] Print Storage_Pool and Procedure_To_Call fields

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
This makes Sprint output the Storage_Pool and Procedure_To_Call fields of the nodes for which they are defined (allocator, free and returns). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sprint.adb (Sprint_Node_Actual) : Also print the Procedure_To_Call field if i

[Ada] Invalid GPR_PROJECT_PATH_FILE confuses gnatls

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue within gnatls whereby having an invalid GPR_PROJECT_PATH_FILE causes an early abort when initializing the default project path, leading to GPR_PROJECT_PATH being ignored. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnatls.adb (Initialize_Defa

[Ada] Tidy up implementation of Has_Compatible_Type

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Has_Compatible_Type is essentially a wrapper around Covers in Sem_Type that handles overloading and a few other details, i.e. calling: Has_Compatible_Type (N, Typ) is morally equivalent to calling: Covers (Typ, Etype (N)) or Covers (Typ, Interp (N)) Except that the implementation also perfo

[Ada] Fix Codepeer warning

2021-11-09 Thread Pierre-Marie de Rodat via Gcc-patches
Codepeer was emitting a warning about Ifaces_List not being initialized. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Check_Inherited_Conditions): Initialize Ifaces_List.diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb --- a/gcc/ada/freeze.adb +++

[Ada] Better error message on missing parentheses

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
Adapt the test to issue a different error message when it is likely that an if-expression is suspected, but parentheses are missing. This makes the test more in line with its comment. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch4.adb (P_Primary): Adapt test for get

[Ada] Create explicit ghost mirror unit for big integers

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
So far, only one light runtime units was using the standard unit for big integers. A special ghost mirror had been created for the reduced runtimes. In order to use more liberally big integers for proof of the runtime, rename this ghost mirror into Big_Integers_Ghost at the same level in the hierar

[Ada] Warn when interfaces swapped between full and partial view

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
The following package declaration is legal but the declaration of D leads to performing a tree transformation. Defining D as `type D is new B and A with null record` would be consistent with the partial view and thus does not require any transformation. This is helpful in the case of generic pack

[Ada] Extend optimized equality of 2-element arrays

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
Array equality is typically expanded into a loop, but for small arrays such loops are inefficient (and the code generator might fail to turn them into linear code, especially when the array contains records). We optimize equality of 2-element arrays into an AND THEN expression, but only for array

[Ada] Fix Constraint error on rexgexp close bracket find algorithm

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
In pattern syntax checking, make a procedure out of the algorithm to find the close bracket matching an open bracket. Fix cases where the close bracket is missing in the special cases '-' and '\', e.g.: - "[a-b" - "[\b" - "[\]" misses either a backslash or a close bracket These three cases would

[Ada] Fix oversight in latest change to Has_Compatible_Type

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
Adding manual calls to Covers in the callers overlooks the overloaded case, so this follow-up change adds back the reversed calls to Has_Compatible_Type but guard them with a boolean flag set to true for comparison operators. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * s

[Ada] Use predefined equality for arrays inside records

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
The equality of arrays inside records always applies the predefined equality, just like for elementary types. In Expand_Composite_Equality we had some dedicated code for arrays inside records which was failing to duplicate a similar code in Expand_N_Op_Eq, e.g. it was failing to apply validity chec

[Ada] Don't carry action bodies for expansion of array equality

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
Expansion of array equality creates a function, which needs to be inserted into the AST. The insertion point was carried from Expand_N_Op_Eq to Expand_Record_Equality and Expand_Array_Equality, which were mutually recursive (via Expand_Composite_Equality). Now these routines are no longer recursive

[Ada] Prove double precision integer arithmetic unit

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
This unit is used to implement the rutime support for fixed-point operations (conversions, multiplication, division and I/O). Its correctness is proved with GNATprove. Proof is performed with GNATprove options --level=4 --prover=all Proof requires use of the special Big_Integers_Ghost unit for s

[Ada] Do not assume a priority value of zero is a valid priority

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
While a priority value of zero is typically valid on most systems, there are some targets where zero may be reserved for OS purposes (for example: RTEMS where zero is reserved for use by the idle thread and should not be used by applications). This patch removes one occurrence in GNARL where a Prio

[Ada] ACATS BDC1002 shall not error on arbitrary aspect

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
When giving an arbitrary pragma Restrictions (No_Specification_of_Aspect => Future_Aspect); Future_Aspect shall not be rejected. Nevertheless a warning shall be emitted. In case the unknown aspect might be a misspelling, a hint should be emitted accordingly. To ease this spell-checking, Aspe

[Ada] Avoid warnings regarding rep clauses in generics

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
Representation-related node fields are not set for types in generic units, so we should not warn based on the values of such fields. Also avoid printing the values of such fields for -gnatR. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * repinfo.adb (List_Common_Type_Info,

[Ada] Fix comments about expansion of array equality

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
Expansion of array equality involves two index variables. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_Array_Equality): Fix inconsistent casing in comment about the template for expansion of array equality; now we use lower case for tru

[Ada] Avoid warnings regarding rep clauses in generics -- follow-on

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
Codepeer is complaining about uninitialized variables. This fixes it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * repinfo.adb (List_Component_Layout): Initialize Sbit.diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.

[Ada] Warn for bidirectional characters

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
Bidirectional characters can cause security vulnerabilities, as explained in the paper mentioned in a comment in this patch. Therefore, we warn if such characters appear in string_literals, character_literals, or comments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * scng

[Ada] Minor cleanup in translation of calls to subprograms

2021-11-10 Thread Pierre-Marie de Rodat via Gcc-patches
This gets rid of the DECL_STUBBED_P macro and adjusts Call_to_gnu. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/ada-tree.h (DECL_STUBBED_P): Delete. * gcc-interface/decl.c (gnat_to_gnu_entity): Do not set it. * gcc-interface/trans.c (Call_to_

[Ada] Improve checking for invalid index values when accessing array elements

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Two improvements to the previous change on this topic: 1) Add a guard to prevent a call to Number_Of_Dimensions that would pass in a non-array type. This is needed in error cases (see ACATS test B95094C). 2) Do not generate the new validity checks in the case where the index type in ques

[Ada] Fix compiler internal error

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
In some cases with -gnat2022 enabled, an enabled postcondition containing a quantified expression containing an Old attribute reference could result in an internal error during compilation. Fix this. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Is_Repeatedly

[Ada] Emit debugging information for TSD object

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This makes the compiler emit debugging information for the Type-Specific Data object generated for tagged types, so as to make sure that debugging information is emitted for its type in ell circumstances. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_disp.adb (Make_DT)

[Ada] VxWorks inconsistent use of return type Fixup

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Fix STATUS and int return types for Vxworks6 in legacy. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-osinte__vxworks.ads (tlsKeyCreate): Return int. * libgnarl/s-tpopsp__vxworks-rtp.adb (ERROR): Declare from System.VxWorks.Ext.ERROR. (In

[Ada] Spurious accessibility error on renamed expression

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue in the compiler whereby a renaming of a subprogram (as opposed to an object) may cause accessibility levels to be incorrectly calculated on such renamings -- leading to spurious accessibility errors at run time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ad

<    26   27   28   29   30   31   32   33   34   35   >