[Ada] Fix expansion of attribute Loop_Entry wrt value propagation

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
When expanding attribute Loop_Entry we create constant object declarations and put them just before the loop. The current values of variables at the point of Loop_Entry attribute must not be used when analysing the initialization expressions of these constants, because they might be different from

[Ada] Fix fallout of change in equality for untagged record types

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
The problem is that the resolution of expanded names implicitly assumes that the visible and private homonyms in a given scope are segregated on the homonym chain, and this was no longer the case for equality operators in the specific case at stake. Tested on x86_64-pc-linux-gnu, committed on trun

[Ada] Enable current value propagation within pragma expressions

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes an odd incomplete optimization within pragma expressions. For example, in this code: X := True; pragma Assert (X = True); pragma Assert (X); the first assertion was eliminated by the frontend (regardless of the optimization switches), while the second assertion was only

[Ada] Check token to be "access", reject it if not

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
The parser skips the token without verifying it is indeed "access". So any token is accepted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch3.adb (P_Access_Type_Definition): Outputs an error if token is not "access".diff --git a/gcc/ada/par-ch3.adb b/gcc/ada

[Ada] Fix documentation of using attribute Loop_Entry in pragmas

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
Attribute Loop_Entry was initially only allowed to appear in pragmas Loop_Variant and Loop_Invariant. Then it was also allowed to appear in pragmas Assert, Assert_And_Cut and Assume, but this change was not reflected in the GNAT RM. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Implement calls to abstract subprograms in class-wide pre/post-conditions

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
In some special cases involving class-wide pre/post conditions, Ada allows a non-dispatching call to an abstract function (which is usually illegal). Fix a bug in the implementation of Ada's rules about the run-time behavior of such a call. Thanks to Javier Miranda for producing this patch. Teste

[Ada] Use Actions field of freeze nodes for subprograms

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
This has a couple of advantages: 1) the actions are analyzed with checks disabled and 2) they are considered elaboration code by Sem_Elab. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch13.adb (Expand_N_Freeze_Entity): Delete freeze nodes for subprograms only

[Ada] Crash freezing declaration that will raise constraint error

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
When the compiler is built with assertions enabled and processes the following declarations: type Vector_Boolean_Array is array (1 .. 10) of Boolean; O2 : constant Vector_Boolean_Array := [for J in 2 => True]; The expression is rewritten by the frontend with an N_Raise_CE node, which leads

[Ada] Remove superfluous call to Original_Node

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
The function Same_Object starts by taking the Original_Node of its arguments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb (Analyze_Assignment): Remove superfluous call to Original_Node.diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb --- a/gcc/a

[Ada] Streamline implementation of Has_Compatible_Representation

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
The predicate is only concerned with the internal representation of types and this representation is shared by the subtypes of a given type, so the implementation can directly look into the (implementation) base types. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/

[Ada] Deal with derived record types in Has_Compatible_Representation

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
More precisely, untagged record types, as tagged record types are already handled by the predicate. If the derived type has not been given its own representation clause, then the representations are the same. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Has

[Ada] Initialize Compiler_State to avoid Constraint_Error

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
When building gnat1 with `-gnatVa` as we do locally, rules like: `gcc -c -gnatyM79 ` will throw a constraint error as `lib.compiler_state` is initialized by par.adb, ie after scanning. Therefore any error_msg thrown during scanning will perform this uninitialized read (which raises a Constraint_Err

[Ada] Typo fix in finalization comment

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
Add missing 's' and reformat the comment block. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb: Fix typo.diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -157,14 +157,14 @@ package body Exp_Ch7 is

[Ada] Don't create calls to Abort_Undefer when not Abort_Allowed

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
Prevent creation of references to Abort_Undefer when aborts aren't allowed. Another solution could have been an early return at Expand_N_Asynchronous_Select's beginning, but this would break backends that currently expect trees that do not contain any N_Asynchronous_Selects in their AST (e.g. CodeP

[Ada] Allow 'Reduce with -gnat2022

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
After a period of experimentation, allow 'Reduce in Ada 2022 mode. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Analyze_Attribute [Attribute_Reduce]): Allow 'Reduce for Ada 2022 and above. * sem_attr.ads (Attribute_Impl_Def): 'Reduce is no lo

[Ada] Take full view of private type

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
This allows to resolve the following: type Rec (<>) is private; type Arr (<>) is private; private type Arr is array (Positive range <>) of Natural; type Rec (L : Natural) is record F1 : Integer; F2 : Arr (1 .. L); end record; Tested on x86_64-pc-

[Ada] Fix bogus visibility error with partially parameterized formal package

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
The problem comes from the special instantiation (abbreviated instantiation in GNAT parlance) done to check conformance between a formal package and its corresponding actual in a generic instantiation: the compiler instantiates the formal package, in the context of the generic instantiation, so tha

[Ada] Generic binary search implementation

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
Allows binary search in sorted anonymous array (or array-like container). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-binsea.ads, libgnat/g-binsea.adb (GNAT.Binary_Search): New package. * Makefile.rtl (GNATRTL_NONTASKING_OBJS): New item in list.

[Ada] Output.w always writes to stderr

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
There are several debugging procedures called Output.w, and some output-redirection features. This patch modifies Output.w so their output is not redirected; it always goes to standard error. Otherwise, debugging output can get mixed in with some "real" output (perhaps to a file), which causes conf

[Ada] Requires_Cleanup_Actions and N_Protected_Body

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
This patch disallows N_Protected_Body from being passed to Requires_Cleanup_Actions. Protected bodies never need cleanup, and are never passed to Requires_Cleanup_Actions, which is a good thing, because it would blow up on Handled_Statement_Sequence, which doesn't exist for N_Protected_Body. Teste

[Ada] Fix small glitch in Expand_N_Full_Type_Declaration

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
The original node is not guaranteed to also be an N_Full_Type_Declaration, so the code needs to look into the node itself. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Expand_N_Full_Type_Declaration): Look into N.diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp

[Ada] Fix Forced sign flag in formatted string

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
Fix the Forced sign flag that is incorrectly ignored for scientific notation and shortest representation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-forstr.adb (Is_Number): Add scientific notation and shortest representation.diff --git a/gcc/ada/libgna

[Ada] Fix insertion of declaration inside quantified expression

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
When the evaluation of the subtype_indication for the iterator_specification of a quantified_expression leads to the insertion of a type declaration, this should be done with Insert_Action instead of Insert_Before. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb

[Ada] GNAT.Binary_Search is not internal

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
Put package GNAT.Binary_Search to predefined units list. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * impunit.adb: Add "g-binsea" to Non_Imp_File_Names_95 list.diff --git a/gcc/ada/impunit.adb b/gcc/ada/impunit.adb --- a/gcc/ada/impunit.adb +++ b/gcc/ada/impunit.adb @@ -2

[Ada] Cleanups related to front-end SJLJ

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
This patch cleans up some code that is left over from the front-end SJLJ exception handling mechanism, which has been removed. This is in preparation for fixing a finalization-related bug. Most importantly: The documentation is changed: a Handled_Sequence_Of_Statements node CAN contain bo

[Ada] Provide allocation subtype for allocators of a Designated_Storage_Model type

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
When an allocator is for an access type that has a Designated_Storage_Model aspect, and the designated type is an unconstrained record type with discriminants, and the subtype associated with the allocator is constrained, a dereference of the new access value can be passed to the designated type's

[Ada] Allow inlining for proof inside generics

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
For local subprograms without contracts inside generics, allow their inlining for proof in GNATprove mode. This requires forbidding the inlining of subprograms which contain references to object renamings, which would be replaced in the SPARK expansion and violate assumptions of the inlining code.

[Ada] Enhance the warning on C enum with size clause for size /= 32

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
Improve the warning message and silence warning when size > 32, this is likely intentional and does not warrant a warning. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Enumeration_Type): Fix comment, enhance message and silence warning for size

[Ada] CUDA: remove code performing kernel registration

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
A previous commit implemented a new kernel registration scheme, using the binder to generate registration code rather than inserting registration code in packages. Now that this new approach has had time to be thoroughly tested, it is time to remove the old approach. Tested on x86_64-pc-linux-gnu

[Ada] Restore defensive guard in checks for volatile actuals

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
When flagging names of volatile objects occurring in actual parameters it is safer to guard against identifiers without entity. This is redundant (because earlier in the resolution of actual parameters we already guard against actuals with Any_Type), but perhaps such identifiers will become allowed

[Ada] Subprogram renaming fails to hide homograph

2022-05-17 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler failed to detect an error where the first prefix of an expanded name given as the renamed subprogram in a subprogram renaming declaration denotes a unit with the same name as the name given for the subprogram renaming. Such a unit must be hidden by the renaming itself. An error check i

[Ada] New port arm-qnx

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
The QNX system specs for ARM and AARCH64 are identical. It makes more sense to have it named for the base architecture. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl: Rename system-qnx-aarch64.ads to system-qnx-arm.ads. (AARCH64 QNX section): M

[Ada] Small performance tweak in recent change

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
This avoids a useless walk of the prefix chain in instances. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Analyze_Subprogram_Renaming): Move final test on In_Instance to outer condition.diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb --- a/gcc/

[Ada] Ada.Numerics.Aux.*: Mention more Intrinsic and less C Math Library

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Since we import the elemental math functions as intrinsics, it's not accurate to state we're drawing them in from the C math library. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-nagefl.ads: Replace mentions of C/unix math library with intrinsics.

[Ada] Fix incorrect freezing with generic child unit

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
The Analyze_Associations.Check_Generic_Parent function was using an incorrect node as the instanciation node for the actual, possibly leading to incorrect freeze node being created (and later crashing in gigi). Using Get_Unit_Instantiation_Node fixes the issue. Tested on x86_64-pc-linux-gnu, commi

[Ada] Freezing too strict in instances

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Should_Freeze_Type is relaxed to only take the relevant case into account (entities denoted by generic actual parameters as per 13.14(5/3), as well as profile of any subprograms named as per 13.14(10.2/4)), instead of being overly conservative wrt instances and as a result, wrongly rejecting some l

[Ada] Fast implementation of floating-point mathematical functions

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
This adds a package renaming unit to the GNAT hierarchy so as to expose the underlying implementation of floating-point mathematical functions, thus also making it possible to use their vector implementation, if any. The change also contains a small improvement to the Hide_Public_Entities mechanis

[Ada] Prevent overflow in computation of aggregate size

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
When computing size of a static aggregate to decide if it should be transformed into assignments and loops we could have an overflow check. This is mostly harmless, because colossal aggregates will likely crash the application anyway, no matter how we transform them. This was not detected because

[Ada] Overriding error on type derived from discriminated untagged private type

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
When a derived type DT has an untagged private parent type PT with a discriminant, where the full type of PT is tagged, and DT inherits a function F with an anonymous access result that designates the type, the compiler wrongly reports an error saying that DT must be declared abstract or F overridd

[Ada] Fix internal error on subprogram instantiation

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler builds renamings for actuals of formal objects for debugging purposes in this case, but it must not generate them for temporaries. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_dbug.ads (Build_Subprogram_Instance_Renamings): Fix typo. * exp_dbug.ad

[Ada] Rework optimization skipping pragma check in object declaration

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
When an object declaration is initialized with a type conversion: Var : Typ := Typ (Value); we skip the check for Typ's predicate as it is already checked during the type conversion. This is not correct when Var's subtype and the target subtype of the conversion do not statically match: Var :

[Ada] Spurious error on freezing of tagged types in SPARK

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
SPARK RM 7.7(8) mandates that the freezing point of a tagged type must occur within the so-called early call region of all its primitives. This check may lead to spurious errors due to generated constructs being considered in the search for the start of the early call region. Tested on x86_64-pc-l

[Ada] Fix problematic underflow for Float_Type'Value

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
We need a couple of guards for boundary conditions in the support code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-dourea.adb ("/"): Add guard for zero and infinite divisor. * libgnat/s-valuer.adb (Scan_Raw_Real): Add guard for very large

[Ada] Secondary stack and a-tags

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
The simple use of Ada.Tags triggers a dependency on the secondary stack mechanism, which is unwanted on small embedded targets. To avoid this dependency, we special case a-tags.ali in ALI.Scan_ALI to not set Sec_Stack_Used. If some other code calls one of the functions returning a string, this code

[Ada] Fix the parsing for delta aggregate

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
In Ada 2022, delta aggregate must use parentheses not square brackets except array delta aggregates. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen-gen_nodes.adb (Gen_IL.Gen.Gen_Nodes): Add Is_Homogeneous_Aggregate field for N_Delta_Aggregate nodes.

[Ada] Errors missed on ACATS test B650007

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
This ACATS test shows that we need to call Is_Immutably_Limited_Type in Analyze_Function_Return and also that we have a latent bug in Is_Immutably_Limited_Type which shouldn't look through private types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aux.adb (Is_Immutab

[Ada] Fix proof of runtime units

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Update to latest version of Why3 caused some proof regressions. Fix the proof by changing ghost code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-imagei.adb (Set_Digits): Add assertion. * libgnat/s-imgboo.adb (Image_Boolean): Add assertions. * l

[Ada] Crash building VSS with compiler built with assertions

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
When a tagged type T has aspect String_Literal, a derived type defines a null extension T2, and the context to resolve the use of an object of type T2 where the string literal is applicable is a class-wide type the frontend crashes trying to evaluate if the object is a null extension. This problem

[Ada] Use specific predicate before manipulating BIP_Alloc_Form

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
For the sake of consistency with other similar manipulations. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb (Build_BIP_Cleanup_Stmts): Use Needs_BIP_Alloc_Form.diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch

[Ada] Fix Ada-QNX task priority conversion

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
The conversion between OS and Ada priorties should be done in the wider Interfaces.C.int type rather than Any_Priority otherwise Constraint_Error will be raised when coverting Any_Priority'Last to int. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-osinte__qnx.ad

[Ada] Improve error messages for occurrence of GNAT extensions without -gnatX

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
The error message issued for use of GNAT extension features without specifying -gnatX (or pragma Extensions_Allowed) was confusing in the presence of a pragma specifying a language version (such as "pragma Ada_2022;"), because the pragma supersedes the switch. The message is improved by testing fo

[Ada] Fix DWARF parsing for 32-bit targets on 64-bit hosts

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Currently, a 64-bit gnatsymbolize fails to output line numbers and accurate symbol names when run on 32-bit executables (and vice-versa). This is because a couple of spots in System.Dwarf_Lines expect the Address_Size found in the DWARF data to match the host Address'Size. This patch corrects that

[Ada] arm-qnx-7.1: undefined reference to fma* symbols

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Configure the arm-qnx runtime packages to avoid generating these symbols. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (arm-qnx): Use default (non-fma) target pair.diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl --- a/gcc/ada/Makefile.rtl +++ b/gcc/a

[Ada] Fix proof of runtime unit s-valeu

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Update to provers caused some proof regressions. Fix the proof by changing ghost code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertions.diff --git a/gcc/ada/libgnat/s-valueu.adb b/gcc/ada/libgnat/s-valueu.adb --- a/gcc

[Ada] Disable Vet calls when container checks are disabled

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Calls to various Vet functions are used throughout the containers packages to check internal consistency. This patch improves efficiency by disabling these calls when Container_Checks are suppressed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-crbtgo.ads, libgn

[Ada] qnx-7.1: warning in sigtramp-qnx.c __gnat_sigtramp

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Fix compilation warning. The code was using a cast to struct sigcontext *, which doesn't exist. It worked by accident. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sigtramp-qnx.c: Change struct sigcontext * to mcontext_t *.diff --git a/gcc/ada/sigtramp-qnx.c b/gcc/ada/sig

[Ada] Fix proof of runtime unit s-imageu

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Update to provers caused some proof regressions. Fix the proof by adding an assertion. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-imageu.adb (Set_Image_Unsigned): Change assertion.diff --git a/gcc/ada/libgnat/s-imageu.adb b/gcc/ada/libgnat/s-imageu.adb --- a/

[Ada] Adapt proof of double arithmetic runtime unit

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
After changes in Why3 and generation of VCs, ghost code needs to be adapted for proofs to remain automatic. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb (Big3): Change return type. (Lemma_Mult_Non_Negative, Lemma_Mult_Non_Positive): Reorder

[Ada] arm-qnx-7.1: stack-checking and sigtramp implementation

2022-05-18 Thread Pierre-Marie de Rodat via Gcc-patches
Rewrite and base on VxWorks RTP implementation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sigtramp-arm-qnx.c: Rewrite.diff --git a/gcc/ada/sigtramp-arm-qnx.c b/gcc/ada/sigtramp-arm-qnx.c --- a/gcc/ada/sigtramp-arm-qnx.c +++ b/gcc/ada/sigtramp-arm-qnx.c @@ -6,7 +6,7 @@

[Ada] Remove dead code for scope entity having E_Subprogram_Body kind

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
In GNAT AST the Scope field always points to the semantic scope (e.g. subprogram) and never to syntactic scope (e.g. subprogram body). Cleanup related to handling of circular access-to-record types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat

[Ada] Small housekeeping work

2022-05-19 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/trans.cc (Subprogram_Body_to_gnu): Rename a couple of local variables and use Is_Generic_Subprogram predicate. (process_decls): Likewise.diff --git a/gcc/ada/gcc-interface/tr

[Ada] Small housekeeping work continued

2022-05-19 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/trans.cc: Fix formatting issues in comments. (Subprogram_Body_to_gnu): Tidy up. (Exception_Handler_to_gnu_gcc): Rename into... (Exception_Handler_to_gnu): ...this.

[Ada] Get rid of secondary stack for controlled components

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
This eliminates the use of the secondary stack to return composite types with controlled components from functions, by exposing the return slot of these functions through the support interface of memory pools, much like for the secondary stack itself. This is piggybacked on the support of a specif

[Ada] Casing style on record components

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes a bug where the -gnatyr switch fails to detect incorrect casing of record components. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * style.adb (Check_Identifier): Deal with the case where a record component definition has been transformed; we want t

[Ada] Further adapt proof of double arithmetic runtime unit

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
After changes in Why3 and generation of VCs, ghost code needs to be adapted for proofs to remain automatic. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb (Lemma_Abs_Range, Lemma_Double_Shift_Left, Lemma_Shift_Left): New lemmas. (Double_

[Ada] Support Ada 2022 null array aggregates

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
Add support for Ada 2022's "[]" null array aggregates (thanks to Ed Schonberg for producing most of this patch). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * erroutc.ads: Fix a single-character typo in a comment. * exp_aggr.adb: Fix a single-character typo in a co

[Ada] Improve optimization of "=" on bit-packed arrays

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes a performance regression, introduced by a previous bug fix. That fix had the unintended side effect of removing the optimization in cases where the two operands are of two different compiler-generated modular types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Fix proof of runtime unit a-strfix and a-strsup

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
Update to provers caused some proof regressions. Fix the proof by adding an assertion. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strfix.adb: Add assertions. * libgnat/a-strsup.adb: Idem.diff --git a/gcc/ada/libgnat/a-strfix.adb b/gcc/ada/libgnat/a-st

[Ada] Cleanup expansion of protected entry families

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
Expansion of entry families contained a condition that was always true. Cleanup related to detection of uninitialized scalar objects (which uncovered that expansion of entry families creates a slightly illegal AST with Elsif_Parts being an empty list). Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Fix invalid expanded code for entry families

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
Expansion of entry families created a slightly illegal AST with Elsif_Parts being an empty list. Cleanup uncovered by the work on detection of uninitialized scalars. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch9.adb (Build_Find_Body_Index): Remove empty Elsif_Parts

[Ada] Avoid copy operation for returns involving function calls

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
The underlying issue is that the front-end does not create transient scopes for return statements, so objects copied for these statements can never be finalized properly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_Call_Helper): Adjust comment.

[Ada] Ignore Predicate_Failure in GNATprove mode

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
In GNATprove mode we are don't want predicate failure to pollute the predicate expression extracted from the predicate function. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Build_Predicate_Function): Ignore predicate failure in GNATprove mode.diff -

[Ada] Fix bug in handling of Predicate_Failure aspect

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
The run-time behavior of the Ada 2022 Predicate_Failure aspect was incorrectly implemented. This could cause incorrect exception messages at execution time in the case of a predicate check failure, as demonstrated by ACATS test C324006. In addition, a new attribute (Predicate_Expression) is defined

[Ada] Wrong interface dynamic dispatch via access parameter

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
When the prefix of an Access attribute is an explicit dereference of an access parameter (or a renaming of such a dereference, or a subcomponent of such a dereference), the context is a general access type to a class-wide interface type, and an accessibility check must be generated, the frontend si

[Ada] Preserve and reuse original type in Narrow_Large_Operation

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
Instead of using that of Original_Node (N) after rewriting, which does not work if N had previously been rewritten. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Narrow_Large_Operation): Preserve and reuse Etype.diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_c

[Ada] Fix compilation of raise-gcc.c with -DSTANDALONE under windows

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
This is needed in particular by GNAT LLVM builds. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * raise-gcc.c: Fix compilation with -DSTANDALONE under windows.diff --git a/gcc/ada/raise-gcc.c b/gcc/ada/raise-gcc.c --- a/gcc/ada/raise-gcc.c +++ b/gcc/ada/raise-gcc.c @@ -78,7

[Ada] Fix spurious violations of No_Secondary_Stack restriction

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
Now that finalization and return on the secondary stack are decoupled, the transient scopes created because of the former need not necessarily manage the secondary stack and trigger a violation of the associated restriction. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ex

[Ada] Mark Requires_Transient_Scope as Inline

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
The predicate is now a simple disjunction of two other predicates. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads (Requires_Transient_Scope): Add pragma Inline.diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem

[Ada] Fix continuation message without a prior error

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
When resolution of an expanded name fails, we call routine Error_Missing_With_Of_Known_Unit which emits an error continuation message (i.e. an error string starting with \\). However, for error continuations to work properly there must be some prior error, because continuation itself doesn't set fl

[Ada] Remove redundant marking of illegal pragma with error posted

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
We flag illegal pragma Elaborate with a call to Error_Msg on the pragma argument, which in turn calls Set_Error_Posted on the enclosing statement, i.e. on the pragma itself. The explicit call to Set_Error_Posted on the pragma itself was redundant. Cleanup related to handling of illegal code when d

[Ada] Preserve unchecked conversion of string constant

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
This makes it possible to pass the result to a C function directly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils.cc (unchecked_convert): Do not fold a string constant if the target type is pointer to character.diff --git a/gcc/ada/gcc-interface

[Ada] Fix for internal error on semi-circular record aggregate

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
This creates a couple of record subtypes pointing to each other through access subtypes, and we break the circularity at the latter subtypes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : If it is a special subtype desig

[Ada] Fix internal error on semi-circular record types

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
The front-end properly computes a linear elaboration order for them, but there was a loophole in the handling of the delayed case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : And skip the elaboration of the designated

[Ada] Do not set Current_Error_Node to a node without location

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
The message "No source file position information available" is displayed in the bugbox when Current_Error_Node has no location, which is useless. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu): Do not set Current_Error_Node to a

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

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
The issue arises when the unchecked union contains both a fixed part and 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 consistently. Tested on x86_6

[Ada] Small housekeeping work in gnat_gimplify_expr

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
This alphabetizes the large switch statement, removes a useless nested switch statement, an artificial fall through and adds a default return. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.cc (gnat_gimplify_expr): Tidy up.diff --

[Ada] Do not give warnings for compiler-generated entities by default

2022-05-19 Thread Pierre-Marie de Rodat via Gcc-patches
The rationale is that these entities are almost always the result of expansion activities in the front-end, over which the user has very limited control. These warnings can be restored by means of -gnatD. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils.c

[Ada] Mark gnatfind and gnatxref obsolete

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Before removing them completely. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnatfind.adb, gnatxref.adb: Mark these tools as obsolete before removing them completely.diff --git a/gcc/ada/gnatfind.adb b/gcc/ada/gnatfind.adb --- a/gcc/ada/gnatfind.adb +++ b/gcc/ada

[Ada] Change message format on missing return

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
To make it compatible with -gnatwE so that this warning is easier to spot when needed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Check_Returns): Change message on missing return.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/ada/sem_ch6.a

[Ada] Make Ada.Task_Initialization compatible with No_Elaboration_Code_All

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
So that this unit can be used and called even before elaboration has started, to ensure very early registration via e.g. C code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/a-tasini.ads, libgnarl/a-tasini.adb: Make compatible with No_Elaboration_Code_All

[Ada] Fix imprecise wording for error on scalar storage order

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
The current error message does not distinguish the component clause case from the packed case, which can be confusing in the latter case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Check_Component_Storage_Order): Give a specific error message for non

[Ada] Add -gnatX support for casing on array values

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Improve existing support for the Ada extension feature of casing on composite values to handle casing on array values; in particular, casing on an array value whose subtype is unconstrained (or dynamically constrained) so that choices in the case statement may have differing lengths. This commit do

[Ada] Generate temporary for if-expression with -fpreserve-control-flow

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
When an if-expression is a condition in an outer decision, the compiler may entirely encode the interplay between the two decisions, i.e. the if-expression and the outer one, in the control-flow graph, effectively creating branches that are shared between the two decisions. This makes it very hard

[Ada] Replace use of 'Image with use of Error_Msg_Uint

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
'Image is too recent for bootstraping and shouldn't be used when emitting error messages in any case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_case.adb (Composite_Case_Ops): Replace 'Image with Error_Msg_Uint.diff --git a/gcc/ada/sem_case.adb b/gcc/ada/sem

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

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Several inconsistencies were found. They will be submitted as separate proposed fixes. The approach is to make them "types" rather than "subtypes" in order to catch inconsistencies in their usage, and to declare them in a central package. System.VxWorks.Ext was chosen, the only difficulty with this

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

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Int_Unlock/intUnlock is incorrectly declared as a function. In the VxWorks headers intUnlock is type void. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-osinte__vxworks.ads: Make procedure vice function. * libgnarl/s-vxwext.ads: Likewise. * libgn

[Ada] Fix obsolete comments/name referring to girder discriminants

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
This name was changed in 2002 to stored discriminants, but some comments and variable names were not converted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads: Fix comments. * exp_aggr.adb: Fix variable name. * exp_util.adb: Fix comments. *

[Ada] Remove System.Img_Enum_New unit

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
It was still needed only because of bootstrap path considerations that are obsolete after the recent overhaul of the bootstrap process. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-imenne.ads, libgnat/s-imenne.adb: Delete. * gcc-interface/Make-lang.in (G

[Ada] Improve performance for case-insensitive regular expressions

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
An existing optimization substantially improves performance in the case of checking for pattern matches where all possible matches are known to start with the same character. Generalize this optimization to also apply in the case of a case-insensitive comparison (so that there are two possible init

[Ada] Allow more cases of import with Relaxed_RM_Semantics

2021-09-22 Thread Pierre-Marie de Rodat via Gcc-patches
Such as importing a package as was accepted by JGNAT, for use in analyzers such as SPARK or CodePeer. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Process_Import_Or_Interface): Relax error when Relaxed_RM_Semantics.diff --git a/gcc/ada/sem_prag.adb b

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