[Ada] Spurious link error with child unit and different Assertion modes.

2021-09-20 Thread Pierre-Marie de Rodat
This patch fixes a spurious link error on a compilation that involves a child unit that must be compiled with assertions enabled, and a parent that is compiled without. The error occurs when the parent includes instantiations that involve constructs such as predicates or pre/ postconditions, and ob

[Ada] Fix condition in op interpretation resolution

2021-09-20 Thread Pierre-Marie de Rodat
A previous patch fixed crashes on comparisons of string literals with access to strings by making sure that resolution of operations was only performed when operand types are actually compatible. However, the check was incomplete. Indeed, using only Has_Compatible_Type does not cover the case wher

[Ada] Fix repeated generation of dispatch tables in CodePeer mode

2021-09-20 Thread Pierre-Marie de Rodat
Routine Make_DT that generates dispatch tables for tagged types might be called twice: when the tagged type is frozen (if it requires freezing) and once the enclosing package is fully analyzed. The Has_Dispatch_Table flag on a type prevents dispatch tables being generated twice. However, this flag

[Ada] SPARK proof of the Ada.Strings.Fixed library

2021-09-20 Thread Pierre-Marie de Rodat
Introduced pragmas to prove with SPARK the behaviours of most of the functions and procedures from Ada.Strings.Fixed. Procedure Move and all procedures that rely on it (Insert, Delete, Overwrite, Replace_Slice) have incomplete contracts and can have runtime errors. Function Count is given without a

[Ada] Adjust latest change for ELF platforms

2021-09-20 Thread Pierre-Marie de Rodat
Shared libraries effectively have a "static" load address of zero in ELF. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-objrea.adb (Get_Load_Address): Return 0 for ELF.diff --git a/gcc/ada/libgnat/s-objrea.adb b/gcc/ada/libgnat/s-objrea.adb --- a/gcc/ada/libgnat/

[Ada] Add support for PE-COFF PIE to System.Dwarf_Line

2021-09-20 Thread Pierre-Marie de Rodat
This makes it possible for System.Dwarf_Line to handle Position-Independent Executables on Windows systems by translating the run-time addresses it is provided with into addresses in the executable. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.c (__gnat_get_executa

[Ada] Cleanups related to building of dispatch tables

2021-09-20 Thread Pierre-Marie de Rodat
Code cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb (Expand_N_Package_Declaration): Fix wording in comment. * exp_disp.adb (Mark_DT): Remove unnecessary initialization of I_Depth.diff --git a/gcc/ada

[Ada] Use OS_Time for interface to TZ functions.

2021-09-20 Thread Pierre-Marie de Rodat
A recent regression caused by the parameterization of time_t was due to the unusual declaration used for time_t in the interface to TZ functions in sysdep.c. The root cause was the Long_Integer size of 32 bits used on x86_64-windows. The incident was temporarily fixed by reverting the declaration t

[Ada] Accept volatile expressions as non-scalar actual parameters

2021-09-20 Thread Pierre-Marie de Rodat
This change removes an old, incomplete and duplicated code that implemented the very first wording of a SPARK RM rule related to volatile expressions acting as actual parameters. Current the rule says: "[a name denoting] an effectively volatile object for reading [can be] an actual parameter in a

[Ada] Accept volatile properties on constant objects

2021-09-20 Thread Pierre-Marie de Rodat
Aspects Volatile and its related properties, i.e. Async_Readers, Async_Writers, Effective_Reads, Effective_Writes and No_Caching, are now allowed on stand-alone constant objects in SPARK. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * contracts.adb (Add_Contract_Item): Acce

[Ada] Clean up Uint fields, remove unused routines

2021-09-20 Thread Pierre-Marie de Rodat
Remove unused routines. Remove 2-parameter versions of Init_Alignment and friends. Replace calls with direct calls to Set_Alignment and friends. These routines aren't really doing anything worth an extra abstraction. Change remaining Init_ routines to Reinit_, because these are not usually bein

[Ada] Remove redundant checks for non-empty list of aspects

2021-09-20 Thread Pierre-Marie de Rodat
Cleanup related to inlining-for-proof and detection of overlaying actual parameters in GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Has_Excluded_Declaration): Remove redundant guard; the guarded code will call First

[Ada] Fix shadowing in conditions for inlining

2021-09-20 Thread Pierre-Marie de Rodat
Cleanup related to inlining-for-proof and detection of overlaying actual parameters in GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Has_Excluded_Declaration): Rename and reduce scope of a local variable.diff --git a/

[Ada] Present and No functions for type Uint

2021-09-20 Thread Pierre-Marie de Rodat
Declare Present and No functions for type Uint, analogous to other types such as Node_Id, and use them as appropriate. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * uintp.ads, uintp.adb (Present, No): New functions for comparing with No_Uint. * checks.adb,

[Ada] Remove "with GNAT.OS_Lib;" from libgnat/a-stbufi.ads

2021-09-21 Thread Pierre-Marie de Rodat
...and replace with System.OS_Lib, because we don't want things under Ada to depend on GNAT. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-stbufi.ads, libgnat/a-stbufi.adb: Change all occurrences of GNAT.OS_Lib to System.OS_Lib.diff --git a/gcc/ada/libgna

[Ada] Refine patch for spurious link error involving discriminated types

2021-09-21 Thread Pierre-Marie de Rodat
This patch handles properly the case of a Component_Definition appearing in a Component_Declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Process_Discriminant_Expressions): If the constraint is for a Component_Definition that appears in a

[Ada] Exception raised on empty file in GNATprove mode

2021-09-21 Thread Pierre-Marie de Rodat
Adapt computation of indexes in buffer for outputting error messages to avoid an index out-of-bound exception on an empty file in GNATprove mode. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Get_Line_End): Do not allow the result to go past the end of

[Ada] Update comment for Error_Msg_Internal

2021-09-21 Thread Pierre-Marie de Rodat
When Error_Msg_Internal parameters Sptr and Optr were renamed to Span and Opan, its comment has not been updated. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Error_Msg_Internal): Fix references to Sptr and Optr in comment; fix grammar of "low-level" w

[Ada] Refactor sort procedures of doubly linked list containers

2021-09-21 Thread Pierre-Marie de Rodat
In earlier work, a performance problem was addressed by rewriting Ada.Containers.Doubly_Linked_Lists.Generic_Sorting in a-cdlili.adb. It turned out that the very-slow-in-some-cases Sort algorithm formerly used there was duplicated in 4 other units: the Bounded, Formal, Indefinite, and Restricted v

[Ada] Enforce legality rule for Predicate_Failure aspect specifications

2021-09-21 Thread Pierre-Marie de Rodat
If a Predicate_Failure aspect is specified for a type or subtype, Ada requires that either the Static_Predicate aspect or the Dynamic_Predicate aspect must also be specified for that same type or subtype. [The GNAT-defined Predicate aspect can also be used to meet this requirement.] The point is th

[Ada] Clean up uses of Esize and RM_Size

2021-09-21 Thread Pierre-Marie de Rodat
This patch updates calls to Esize and RM_Size so they will work with the new representation of "unknown" (i.e. "not yet set"). The old representation is "Uint_0". The new one will be "initial zero bits". The new representation is not yet installed; we are still using Uint_0. A future change wil

[Ada] Interface behaves differently from abstract tagged null

2021-09-21 Thread Pierre-Marie de Rodat
When the result expression of a simple-return-statement is a type conversion, and the tag of the expression differs from the tag of the specific nonlimited return type, the frontend silently skips ensuring that the tag of the returned object is that of the result type. Tested on x86_64-pc-linux-gn

[Ada] Presence of abstract operator function causes resolution problems

2021-09-21 Thread Pierre-Marie de Rodat
The declaration of an abstract function with an operator designator can result in removing a nonhomographic user-defined operator as a possible interpretation in an overloaded expression, leading to an error about mismatched types. The condition for marking an interpretation as being a predefined

[Ada] Fix ignored dynamic predicates specified through "predicate" aspect

2021-09-21 Thread Pierre-Marie de Rodat
Before this patch, GNAT would ignore dynamic predicates specified through the "predicate" pragma when attempting to evaluate expressions. This would result in incorrect behavior in cases like the following: subtype SS is String (1 .. 4) with Predicate => SS (2) = 'e'; pragma Assert ("" i

[Ada] rtems: add 128bit support for aarch64

2021-09-21 Thread Pierre-Marie de Rodat
Add 128BITS integer support for aarch64-rtems6. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (aarch64-rtems*): Add GNATRTL_128BIT_PAIRS to the LIBGNAT_TARGET_PAIRS list and also GNATRTL_128BIT_OBJS to the EXTRA_GNATRTL_NONTASKING_OBJS list.dif

[Ada] exp_pakd.adb: work around spurious Codepeer warnings

2021-09-21 Thread Pierre-Marie de Rodat
Codepeer erroneously emits a warning for this if expression. Replacing it with a statement is enough to make the problem disappear. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_pakd.adb (Expand_Packed_Not): Replace expression with statement.diff --git a/gcc/ad

[Ada] Follow-up tweaks to System.Dwarf_Line

2021-09-21 Thread Pierre-Marie de Rodat
This fixes a couple of thinkos in the previous change. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-dwalin.adb (Skip_Form): Fix cases of DW_FORM_addrx and DW_FORM_implicit_const. Replace Constraint_Error with Dwarf_Error.diff --git a/gcc/ada/lib

[Ada] Small optimization to DWARF 5 mode in System.Dwarf_Line

2021-09-21 Thread Pierre-Marie de Rodat
There is no need to fetch every string from the .debug_line_str section. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-dwalin.adb (To_File_Name): Fetch only the last string from the .debug_line_str section. (Symbolic_Address.Set_Result): Likewise.

[Ada] Add assertions to Uintp

2021-09-21 Thread Pierre-Marie de Rodat
Add appropriate assertions to the operations in Uintp. Most operations disallow No_Uint. Division disallows Uint_0 on the right, and so on. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * uintp.ads, uintp.adb: Add assertions. (Ubool, Opt_Ubool): New "boolean" subtyp

[Ada] Remove if_expression

2021-09-21 Thread Pierre-Marie de Rodat
Replace an if_expression with an if_statement, because codepeer is tripping over the if_expression. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.adb (Fold_Shift): Replace an if_expression with an if_statement.diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/se

[Ada] Add assertions to Uintp (UI_Is_In_Int_Range)

2021-09-21 Thread Pierre-Marie de Rodat
This completes the previous change that added assertions to Uintp. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * uintp.ads, uintp.adb (UI_Is_In_Int_Range): Change the type of the formal parameter to Valid_Uint. Remove code that preserved the previous behavi

[Ada] Cleanup old VxWorks in Makefile.rtl

2021-09-21 Thread Pierre-Marie de Rodat
The sections titled "PowerPC and e500v2 VxWorks 653" and "VxWorksae / VxWorks 653 for x86 (vxsim)" in Makefile.rtl are removed since they are no longer used. Also remove the relevant packages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl: Remove unused VxWork

[Ada] Crash on build of Initialization procedure for derived container

2021-09-21 Thread Pierre-Marie de Rodat
This patch fixes a compiler abort on the construction of the initialization procedure for a private type completed by a derived container type whose element type is another container with controlled components with trivial initializations, Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada

[Ada] Set related expression for external DISCR symbols in Build_Temporary

2021-09-21 Thread Pierre-Marie de Rodat
This is required for CodePeer to use a better name for a variable, or a constant created by GNAT. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Build_Temporary): In case of an external DISCR symbol, set the related expression for CodePeer so that a mo

[Ada] Fix regression in ACATS bdd2006 and bdd2007

2021-09-21 Thread Pierre-Marie de Rodat
This fix is not strictly necessary to pass these ACATS tests, but this improves the error message, and avoids updating expected outputs. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Stream_Size): Print message about allowed stream sizes even if other

[Ada] bindgen: support additional features on targets suppressing the standard lib

2021-09-21 Thread Pierre-Marie de Rodat
For targets that suppress the standard library, the binder can now set the default stack size and enable stack checking when GCC stack limit are used. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * bindgen.adb (Gen_Adainit): For targets that suppress the standard li

[Ada] Add "optional" node subtypes that allow Empty

2021-09-21 Thread Pierre-Marie de Rodat
This patch adds new Opt_... subtypes to Sinfo.Nodes and Einfo.Entities. The predicates say "Opt_N_Declaration = Empty" rather than "No (Opt_N_Declaration)" because No is not visible. It can't be made visible with "with Atree;", because that would introduce cycles. It could be made visible by moving

[Ada] SCOs: generate 'P' decisions for [Type_]Invariant pragmas

2021-09-21 Thread Pierre-Marie de Rodat
Those pragmas should be dealt with in the same way as their equivalent aspects. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par_sco.adb (Traverse_One): Add support for pragma Invariant / Type_Invariant.diff --git a/gcc/ada/par_sco.adb b/gcc/ada/par_sco.adb --- a/

[Ada] Spurious dynamic accessibility check on allocator

2021-09-21 Thread Pierre-Marie de Rodat
This patch corrects an issue in the compiler whereby an anonymous access class-wide type allocator with default initialization has spuriously generated dynamic accessibility checks associated with the construct - leading to spurious runtime accessibility failures. Additionally, this patch corrects

[Ada] Rename "optional" node subtypes that allow Empty

2021-09-21 Thread Pierre-Marie de Rodat
This patch renames the new Opt_... subtypes in Sinfo.Nodes and Einfo.Entities to end with the suffix "_Id" for homogeneity with other subtypes of Node_Id and Entity_Id. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen.adb (Put_Opt_Subtype): Add suffix.diff --git a/

[Ada] Add some comments in init.c about the lynx178 signal handler

2021-09-21 Thread Pierre-Marie de Rodat
__gnat_error_handler for LynxOS in init.c only accepts a "sig" argument. Add some comments to explain why, and how to fix it with a change to a kernel build parameter. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * init.c (__gnat_error_handler) [LynxOS]: Add a comment about

[Ada] Improve end of command line arguments detection

2019-12-12 Thread Pierre-Marie de Rodat
Add routine Get_Argument with End_Of_Arguments Boolean out parameter into GNAT.Command_Line API to distinguish between the empty argument and the end of arguments. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-12 Dmitriy Anisimkov gcc/ada/ * libgnat/g-comlin.ads (Get_Argu

[Ada] Mark Ada subprograms and variables referenced from gigi

2019-12-12 Thread Pierre-Marie de Rodat
In addition to the C bindings automatically generated during the build process (einfo.h, sinfo.h, snames.h), gigi also makes use of a manually maintained C interface to the front-end (atree.h, elists.h, fe.h, namet.h, nlists.h, repinfo.h, scos.h, stringt.h, types.h, uintp.h, urealp.h). This change

[Ada] Crash on use of Loop_Entry, Result, and Old as actuals

2019-12-12 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby the compiler crashes generating accessibility checks for the attribute references 'Loop_Entry, 'Old, and 'Result when they are used as actuals. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-12 Justin Squirek gcc/ada/ * exp_ch6.adb (Expand

[Ada] Constraint is ignored on constrained access record component

2019-12-12 Thread Pierre-Marie de Rodat
This patch fixes an omission in the generation of constraint checks, when assigning to a record component whose type is a constrained access to a discriminated record. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-12 Ed Schonberg gcc/ada/ * sem_ch3.adb (Constrain_Access):

[Ada] Implement AI12-0036 (a new legality check for instantiations)

2019-12-12 Thread Pierre-Marie de Rodat
AI12-0036 is a binding interpretation which adds the following legality rule: The actual type for a formal derived type shall be tagged if and only if the formal derived type is a private extension. Implement this new compile-time check. The check is implemented without checking the value o

[Ada] Improved handling of circular compilation dependencies

2019-12-12 Thread Pierre-Marie de Rodat
In the case described on this ticket, a predefined unit (the body of Ada.Finalization) is recompiled with a configuration pragma in effect (an Interrupt_State pragma) which has has the effect of introducing a circular compilation dependency. Previously this resulted in an internal error. With this

[Ada] Broken privacy on Controlled type extensions

2019-12-12 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby the compiler incorrectly resolves non-visible controlled primitives such as the case where predefined controlled operations get called on a type extension whose parent is a private extension completed with a controlled extension. Tested on x86_64-pc-linux-gnu, com

[Ada] Use correct subtype for call to Last in formal vectors

2019-12-12 Thread Pierre-Marie de Rodat
Correct the subtype used for a call to Last in Find_Index so that it no longer crashes on empty vectors with checks enabled. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-12 Claire Dross gcc/ada/ * libgnat/a-cofove.adb, libgnat/a-cfinve.adb (Find_Index): Use Exten

[Ada] Tighten up semantic checking for protected subprogram declarations

2019-12-12 Thread Pierre-Marie de Rodat
The B940010 ACATS test includes some legality violations that GNAT was failing to reject (at compile time). With this change these violations are detected and appropriate error messages are produced. Most of the required error messages that are not generated initially are because splitting is requ

[Ada] Missing error on incorrect use of Result attribute

2019-12-12 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby the compiler failed to issue an error on the use of the attribute Result when the prefix is a non-subprogram. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-12 Justin Squirek gcc/ada/ * sem_attr.adb (Analyze_Attribute): Add error message f

[Ada] Crash on Descriptor_Size attribute

2019-12-12 Thread Pierre-Marie de Rodat
This patch fixes the following bug: If the Descriptor_Size attribute is used in the private part of a generic package, then the compiler crashes when compiling an instance of that generic. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-12 Bob Duff gcc/ada/ * sem_attr.adb (

[Ada] Compiler crash on prefix call in generic body

2019-12-12 Thread Pierre-Marie de Rodat
This patch fixes the following bug: If prefix notation is used to call a subprogram, and the call is within a generic package body that is within a package body P, and the called subprogram is not declared in the spec of P, the compiler crashes when compiling an instance of the generic package. Te

[Ada] Fix repeated words and typos in doc and comments

2019-12-12 Thread Pierre-Marie de Rodat
Found with 'grep " \([[:alpha:]]\+\) \1[[:space:]]" *.ad?', just like in 2015; fixed manually with refilling comments where possible. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-12 Piotr Trojanek gcc/ada/ * libgnat/g-altive.ads: Fix typo in comment. * bindo-grap

[Ada] Fix related to handling up-level references in protected entries

2019-12-12 Thread Pierre-Marie de Rodat
This change fixes a regression that occurred on a Ravenscar test, where gigi blew up because an itype inside the block created for a protected entry procedure had its scope set incorrectly (designating the enclosing package) so appeared to gigi not to be declared within the procedure. The scope of

[Ada] Missing length check on private type with unknown discriminants

2019-12-12 Thread Pierre-Marie de Rodat
Compiler fails to emit a length check on the right-hand side of an assignment when the type involved is a private type with unknown discriminants whose full view is an unconstrained array type. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-12 Ed Schonberg gcc/ada/ * exp_c

[Ada] Fix wrong value of 'Size for slices of bit-packed arrays (2)

2019-12-12 Thread Pierre-Marie de Rodat
This completes the previous fix, which is not sufficient when the Size attribute is applied to a formal object of mode In Out and the generic is instantiated on a slice of a bit-packed array whose size is not a multiple of the storage unit. The hurdle here is that introducing a temporary may chang

[Ada] Fix Global contract for the predefined Yield procedure

2019-12-12 Thread Pierre-Marie de Rodat
In GNATprove flow analysis is not aware of implicitly evaluated routines, e.g. subtype predicates and user-defined equality for record types. Therefore SPARK 2014 mandates both routines to not reference any globals. Likewise, we don't want them to have any effects related to tasking, i.e. we don

[Ada] Handling up-level references in protected entries and freeze nodes

2019-12-12 Thread Pierre-Marie de Rodat
For GNAT-LLVM, up-level references within the procedure created for a protected entry were not being handled right inside the block created to hold the declarations and statements of the entry. Calls to procedures declared within the block that make up-level references (such as to the init proc for

[Ada] Spurious error on overriding controlled primitive

2019-12-13 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby the compiler generates spurious ineffective overriding subprogram errors on instantiations of generic child packages where such packages contain overriding controlled primitives for types extended from parent packages which are, in turn, private controlled completi

[Ada] Implement AI12-0101

2019-12-13 Thread Pierre-Marie de Rodat
This AI simply relaxes a legality rule, legalizing a construct that was previously illegal. In particular, it deletes the second sentence of 4.5.2(9.8) In addition, if the untagged record type has a nonlimited partial view, then the declaration shall occur in the visible part of the encl

[Ada] Missing accessibility checks on conditionals

2019-12-13 Thread Pierre-Marie de Rodat
This is an incremental patch which fixes a compiler error whereby accessbility checks on if and case expressions used to set access discriminants within allocators were not performed. It also corrects an issue where dynamic accessibility levels are not passed correctly when a conditional expression

[Ada] Up-level addressing problems with private tasks and selective accept procs

2019-12-13 Thread Pierre-Marie de Rodat
When a task type has a partial view, the procedure created for a selective accept statement within the task was not being passed an activation record actual (despite having such a formal), and also certain variables addressed up-level were not being stored within the activation record. This was be

[Ada] Clear confusion about subcomponents of atomic object

2019-12-13 Thread Pierre-Marie de Rodat
The Ada RM explicitly says in the C.6 sub-chapter that, contrary to what happens for the Volatile aspect, the Atomic aspect doesn't automatically propagate down to subcomponents of atomic objects. That is not what is implemented in the compiler, in particular in the Is_Atomic_Object predicate of S

[Ada] Rtsfind: minor comment fixes

2019-12-13 Thread Pierre-Marie de Rodat
The comment was way too repetitive. The term "second level child" sounds like it means "grandchild", but that's not what was meant. This comment was written in 1994: ...This is part of a temporary implementation of delays; --eventually, packages implementing delays will

[Ada] Fix support for > 24 hours image in Ada.Calendar.Formatting

2019-12-13 Thread Pierre-Marie de Rodat
The Ada.Calendar.Formatting.Image function is supposed to support at least durations up to (excluding) 100 hours. Fixes the implementation so that it does and clarify in the spec the behavior when the duration exceeds 100 hours (raise Time_Error). Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Pragma Linker_Section in subprogram instantiations in CCG

2019-12-13 Thread Pierre-Marie de Rodat
Propagate attribute Linker_Section_Pragma to the ultimate aliased entity to facilitate processing it in instantantiations of generic subprograms in the C backend. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-13 Javier Miranda gcc/ada/ * sem_prag.adb (Analyze_Pragma): Pro

[Ada] Suppress Base_Address call on init of activation record components

2019-12-13 Thread Pierre-Marie de Rodat
In the special case of an Address attribute that is used to initialize a component of an activation record object (for handling unnesting in back ends that don't support nested subprograms directly, such as LLVM), we don't want the attribute to be passed to the Base_Address function (that performs

[Ada] Adding support for unsupported type conversion in CCG

2019-12-13 Thread Pierre-Marie de Rodat
Generate an extra temporary for the unchecked conversion of a function call returning a composite type, and for the unchecked conversion to a composite type of a function call returning a discrete type (since the C backend does not support such cases). Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Prevent inlining inside condition of while loop in GNATprove

2019-12-13 Thread Pierre-Marie de Rodat
The special inlining performed in GNATprove should not allow inlining inside the condition of while loops, as this creates complex actions inside the condition itself, which are not handled by GNATprove. Other loops are not impacted, as the bounds are only computed once, which allows to move the a

[Ada] Better error message for aliased formal and atomic actual

2019-12-13 Thread Pierre-Marie de Rodat
The C.6 (12/3) clause makes it illegal to pass an atomic actual parameter in a call corresponding to an aliased formal with a nonatomic type. This illegal case had been accepted up recently and started only to be rejected as a by-product of the implementation of the C.6 (19) clause, but the error

[Ada] Detect illegal implicit type conversions

2019-12-13 Thread Pierre-Marie de Rodat
When testing whether the target of a type conversion is a general access type, the test should not be E_Kind (Target_Type) = E_General_Access_Type but rather E_Kind (Base_Type (Target_Type)) = E_General_Access_Type Fix this bug in two places. As a consequence of these bugs, some of the le

[Ada] Deallocation of controlled type implementing interface types

2019-12-13 Thread Pierre-Marie de Rodat
The code generated by the compiler to deallocate a controlled type that has variable size components and implements interface types computes a wrong address (and crashes at runtime). Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-13 Javier Miranda gcc/ada/ * exp_disp.ads (

[Ada] Avoid spurious mismatch error of assertion policy in generics

2019-12-13 Thread Pierre-Marie de Rodat
Because of the way generics are analyzed, it is possible that an assertion pragma is transformed into a Check pragma by the time ghost code inside the assertion is checked for a possible mismatch of assertion policy. In that case, the original pragma that led to the Check pragma should be retrieved

[Ada] Avoid spurious errors on Global/Depends in instantiations

2019-12-13 Thread Pierre-Marie de Rodat
The (Refined_)Global/Depends contracts in SPARK are analyzed by GNAT for possible violations of legality rules. Some of these rules have to do with visibility of refinement at the point where the contract is specified. These rules should not be checked inside generic instantiations, as the visibili

[Ada] Implement AI12-0109 (prohibit some "early" derivations)

2019-12-13 Thread Pierre-Marie de Rodat
If a by-reference untagged type has primitive subprograms, then the representations of that type and any type derived from it need to match. This is because passing in a reference to a "change of representation" copy doesn't work for a by-reference type. AI12-0109 is a binding interpretation that

[Ada] Validate_Access_Subprogram_Instance: check if not null types match

2019-12-16 Thread Pierre-Marie de Rodat
The Ada RM states that "For a formal access-to-subprogram subtype, the designated profiles of the formal and the actual shall be subtype conformant." (section 12.5.4). This requires checking if both types can or can't be null. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-16 Ghjuvan

[Ada] Implement RM C.6(19) clause entirely in the front-end

2019-12-16 Thread Pierre-Marie de Rodat
This merges the implementation of the C.6(19) clause present for In Out and Out parameters in the front-end (without warning) with that present in gigi (with a warning), and puts the result in the front-end with a warning. This means that the compiler will now warn in all cases. Tested on x86_64-

[Ada] Suppress unused warnings in the presence of errors

2019-12-16 Thread Pierre-Marie de Rodat
The compiler no longer warns about unused use clauses, unused declarations, and the like, if errors were already detected. This is an improvement, because the errors can hide the relevant uses, and thus cause things to look "unused" when they are not. Tested on x86_64-pc-linux-gnu, committed on tr

[Ada] Do not issue restriction violations on ignored ghost code

2019-12-16 Thread Pierre-Marie de Rodat
Ignored ghost code should only be semantically analyzed, but as it is not contributing to any executable code, no restriction violation should result from analyzing such code. Add protections to that effect in the analysis of subprogram calls. Tested on x86_64-pc-linux-gnu, committed on trunk 201

[Ada] Bad warning: Size in Compile_Time_Error in nested instance

2019-12-16 Thread Pierre-Marie de Rodat
This patch fixes a bug in which if a Size attribute occurs in a pragma Compile_Time_Error, and the pragma occurs in a generic unit that is instantiated in another generic unit, and that other generic unit is instantiated, then the compiler does not know the value of Size at compile time. It issues

[Ada] AI12-0208 Support for Ada.Numerics.Big_Numbers.Big_Integers and Big_Reals

2019-12-16 Thread Pierre-Marie de Rodat
This change implements Ada 2020 AI12-0208 which adds support for infinite precision integers and rationals via new packages in the Ada.Numerics.Big_Numbers hierarchy. A default implementation using System.Generic_Bignum (made generic out of the existing System.Bignum) is enabled everywhere, and an

[Ada] Implement new legality rules introduced in C.6(13) by AI12-0128

2019-12-16 Thread Pierre-Marie de Rodat
This implements the new 4 legality rules added to C.6(13) by AI12-0128 and pertaining to nonatomic subcomponents of atomic types and objects. This also implements the counterpart of the last 2 rules for the GNAT specific aspect/pragma Volatile_Full_Access (they were only partially implemented befo

[Ada] Small consistency fix for Volatile_Full_Access objects

2019-12-16 Thread Pierre-Marie de Rodat
This fixes a small oversight in the part of the Is_Atomic_Or_VFA_Object predicate which detects the Volatile_Full_Access aspect/pragma. This aspect/pragma can also be put on individual components in record types and, more generally, components of arrays or records whose type is subject to the aspe

[Ada] Syntax error on improperly indented imported subprogram

2019-12-16 Thread Pierre-Marie de Rodat
This patch fixes an incorrect syntax error. In particular, in an example like the following: procedure Main is procedure Imported with Import; begin null; end; where there is a subprogram declaration with an Import aspect specification, and the declaration is indented the s

[Ada] AI12-0234/321 atomic operations

2019-12-16 Thread Pierre-Marie de Rodat
This patch adds support for Ada 202x new packages adding support for atomic operations (Exchange, Test and Set, Fetch Add/Sub). Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-16 Arnaud Charlet gcc/ada/ * libgnat/s-aotase.adb, libgnat/s-aotase.ads, libgnat/s-atoope.

[Ada] AI12-0001: Independence and Representation clauses for atomic objects

2019-12-16 Thread Pierre-Marie de Rodat
This implements the aforementioned AI in all versions of the language since it is classified as a Binding Interpretation. The main visible effects are to turn errors given for the Pack aspect/pragma into mere warnings and to give new errors for representation clauses that do not abide by the align

[Ada] Better error message for "is null" subunit

2019-12-16 Thread Pierre-Marie de Rodat
The syntax rules do not allow a null procedure as a subunit, and the compiler was correctly rejecting that. This patch improves the error message. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-16 Bob Duff gcc/ada/ * sem_ch10.adb (Analyze_Subunit): Give an error if the sub

[Ada] Export the Ada version through the C interface

2019-12-16 Thread Pierre-Marie de Rodat
This just exports the version of the language internally used in the front-end of the compiler through the C interface. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-16 Eric Botcazou gcc/ada/ * fe.h (Ada_Version_Type): New typedef. (Ada_Version): Declare.

[Ada] Fully propagate representation aspects through renaming

2019-12-16 Thread Pierre-Marie de Rodat
This makes sure that the 4 representation aspects defined (or not) in C.6 and supported by GNAT, that is to say Atomic, Independent, Volatile and Volatile_Full_Access, are fully propagated through renaming declarations. This also overhauls the implementation of the 4 associated predicates Is_[Aspe

[Ada] Remove new strict-alignment check added by AI12-0001

2019-12-16 Thread Pierre-Marie de Rodat
This removes the check on aliased components recently added to the Check_Strict_Alignment procedure as part of the implementation of AI12-0001 because it causes a build failure for Florist on 32-bit platforms and might also affect other legacy codebases. Tested on x86_64-pc-linux-gnu, committed on

[Ada] Expand renamings of subcomponents of an atomic or VFA object

2019-12-16 Thread Pierre-Marie de Rodat
This change makes sure that the front-end expands the renamings of subcomponents of atomic or Volatile_Full_Access objects, i.e. the references in the renamed object are elaborated and the result is substituted for the renaming in the expanded code. This means that code generators implementing ren

[Ada] Fix couple of oversights in the implementation of AI12-0128

2019-12-16 Thread Pierre-Marie de Rodat
This fixes a couple of oversights in the implementation of the new legality rules added to the C.6(13) clause by AI12-0128: 1. the new code does not properly deal with an Atomic_Components aspect/pragma put directly on an array object declaration, 2. the new Is_Subcomponent_Of_Atomic_Obj

[Ada] Do not set a bogus Esize on subtype built for Component_Size clause

2019-12-16 Thread Pierre-Marie de Rodat
This fixes a small glitch in the handling of Component_Size clauses: when the component type is a biased integer type, the compiler builds a subtype with the size prescribed by the clause, but sets it both as the Esize and the RM_Size of this subtype. Now this size might not be a multiple of the s

[Ada] Reserving switch d_K for known problem isssues detection

2019-12-17 Thread Pierre-Marie de Rodat
This patch documents that switch -gnatd_K is reserved to enable machinery that detects known problem issues of previous releases. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-18 Javier Miranda gcc/ada/ * debug.adb: Document -gnatd_K as a reserved switch for the d

[Ada] Bad "already use-visible" warning re: use in private part

2019-12-17 Thread Pierre-Marie de Rodat
This patch fixes a bug in which if a parent package has a use clause in its private part, and a child of that parent has a use clause for the same thing in its context clause, the compiler incorrectly warns that the one in the child is redundant. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Do not propagate Object_Size onto Size for composite types

2019-12-17 Thread Pierre-Marie de Rodat
This gets rid of an old bypass used in the compiler, which would copy the value set in an Object_Size clause for record types onto Size. This means that a confirming Object_Size clause can prevent packing, which is counter-intuitive given that Object_Size is not supposed to pertain to packing at a

[Ada] Wrong error on hidden must-override primitive

2019-12-17 Thread Pierre-Marie de Rodat
The compiler gave a wrong error about "must override" in the following case. A private type is completed with a derived type that inherits a must-override function. Outside that package, a type extension of the private type is declared. The function on that type extension is not visible, and is n

[Ada] AI12-0282: shared variable control aspects on formal types

2019-12-17 Thread Pierre-Marie de Rodat
Ada202X allows some aspects related to shared variable control to appear on formal type declarations. These aspects represent new enforceable parts of the contract between generic units and instantiations. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-18 Ed Schonberg gcc/ada/

[Ada] Missing accessibility actuals on calls to interface conversion functions

2019-12-17 Thread Pierre-Marie de Rodat
In certain cases of conversions to interface types, the compiler generates a special function to handle the conversion. In cases where such a function has an extra accessibility-level formal and the target type of the conversion has a designated type that comes from a limited view (via limited_with

<    1   2   3   4   5   6   7   8   9   10   >