[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

[Ada] Document the introduction of the Object_Size attribute in Ada 2020

2019-12-17 Thread Pierre-Marie de Rodat
This adds references to Ada 2020 in the section documenting the two size attributes used by GNAT, namely Object_Size and Value_Size, as well as in the head comment of Subtypes_Statically_Match. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-18 Eric Botcazou gcc/ada/ * einf

[Ada] Fix three-letter typos like "sss" in comments and docs

2019-12-17 Thread Pierre-Marie de Rodat
Fix three-letter typos like "alllowed" or "corrresponding". They can be detected with this command: $ grep "[[:alpha:]]\([[:lower:]]\+\)\1\1" ... but need to be manually filtered for things like "ieee", "dd-mm-" or hexadecimal literals. Tested on x86_64-pc-linux-gnu, committed on trunk 20

[Ada] Missing accessibility check on access discriminants

2019-12-17 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby compile-time checks on return aggregates with anonymous access discriminants were not performed when multiple of such discriminants were present, the aggregate was within an extended return statement, or the aggregate was within a qualified expression. Tested on x

[Ada] Fix overriding subprogram being incorrectly seen as returning

2021-07-05 Thread Pierre-Marie de Rodat
Before this commit, GNAT failed to notice that subprograms overriding non-returning subprograms could be renamings of non-returning subprograms and thus wrongfully emitted an error. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Check_Abstract_Overriding): Chec

[Ada] Do not catch 'N rem -1' in CodePeer_Mode

2021-07-05 Thread Pierre-Marie de Rodat
The special case used for catching the 'rem -1' operation is not useful to CodePeer, and in fact may be detrimental to its precision. Remove it in CodePeer_Mode. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_Op_Rem): Remove special case for rem -1

[Ada] Refactoring related to Returns_By_Ref

2021-07-05 Thread Pierre-Marie de Rodat
Split out the computation of Returns_By_Ref, to make subsequent changes easier. General cleanups. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads, sem_util.adb (Compute_Returns_By_Ref): New procedure to compute Returns_By_Ref, to avoid some code

[Ada] Print JSON continuation messages as separate messages

2021-07-05 Thread Pierre-Marie de Rodat
Printing continuation messages as a single JSON message was an error as consumers of the JSON output can take advantage of different locations of the continuation message. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Output_JSON_Message): Recursively call

[Ada] Fix crash when printing error message

2021-07-05 Thread Pierre-Marie de Rodat
Missing Chars on N were causing a crash - the solution is to set the Sloc from N and to use F_type's chars. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Profile): Use N's Sloc, F_type's chars.diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb --- a/gc

[Ada] Spurious error in instantiation with aggregate and private ancestor

2021-07-05 Thread Pierre-Marie de Rodat
Compiler rejects an instantiation but accepts the corresponding generic unit, when it includes a declaration for a private type whose full view is a record type with a controlled component, and the full view of an object of the type is given by an aggregate with default-initialized components. Tes

[Ada] Cleanup checking for compatible alignment

2021-07-05 Thread Pierre-Marie de Rodat
Code cleanup only related to handling of Address clauses in GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Has_Compatible_Alignment_Internal): Fix indentation of ELSIF comments; remove explicit calls to UI_To

[Ada] Turn GNAT_Annotate into its own pragma

2021-07-05 Thread Pierre-Marie de Rodat
GNAT_Annotate being an alias of Annotate rather than its own pragma results in issues for tools that rely on snames to get a list of available pragmas. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * aspects.ads: Add GNAT_Annotate aspect. * gnat1drv.adb (Adjust_Globa

[Ada] Move overriding rename error message from declaration to use

2021-07-05 Thread Pierre-Marie de Rodat
Posting the error message on the declaration of the renamed subprogram is more confusing than posting the message on the name of the renamed subprogram in the renaming. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Check_Abstract_Overriding): Post error messag

[Ada] Adapt SPARK checking after change in rules regarding heap modeling

2021-07-05 Thread Pierre-Marie de Rodat
Rules in SPARK RM section 3.10 regarding modeling of heap through dynamic (de)allocation has changed. As a result, the dependency contract of Ada.Unchecked_Deallocation can be added directly in the sources, and placement of allocators is not checked in the frontend anymore. Tested on x86_64-pc-lin

[Ada] Fix comment about the debug flag for strict alignment

2021-07-05 Thread Pierre-Marie de Rodat
The "strict alignment" compilation mode is controlled by -gnatd.a, as described in Adjust_Global_Switches. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ttypes.ads (Target_Strict_Alignment): Fix comment.diff --git a/gcc/ada/ttypes.ads b/gcc/ada/ttypes.ads --- a/gcc/ada/tty

[Ada] The Unix Epochalyse of 2038 - OS_Time

2021-07-05 Thread Pierre-Marie de Rodat
OS_Time is use mainly in the interface to the "C" part of the GNAT RTL. Change it to a 64-bit signed type on all targets. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.h (OS_Time): typedef as long long. * osint.adb (Underlying_OS_Time): Declare as 64-bit sig

[Ada] The Unix Epochalypse of 2038 - Use OS_Time

2021-07-05 Thread Pierre-Marie de Rodat
__gnat_set_file_time_name is called from Ada with OS_Time, but the C function argument is time_t. This is a violation of the interface rule that calls to the C parts use OS_Time. It currently works by accident. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.h (__gn

[Ada] Temporarily disable Ada 2022 Image and Put_Image support for tagged types

2021-07-05 Thread Pierre-Marie de Rodat
Revert to having support for Ada 2022's Image and Put_Image attributes of tagged types conditional on the -gnatd_z switch (as opposed to being enabled unconditionally). This is a temporary change, so the comments in debug.adb about the -gnatd_z switch have not been restored. Tested on x86_64-pc-li

[Ada] Fix missing minus sign in literal translation

2021-07-05 Thread Pierre-Marie de Rodat
When translating literals to big reals, the compiler would forget about the minus sign and turn a negative number into a positive one. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve): Insert minus sign if needed.diff --git a/gcc/ada/sem_res.adb b/gcc/ad

[Ada] The Unix Epochalyse of 2038 - OS_Time comparison

2021-07-05 Thread Pierre-Marie de Rodat
The comment in the public section of the spec says the comparison ops are intrinsic, but that doesn't match the private part implementation and comment. Fix this. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-os_lib.ads: Import OS_Time comparison ops as i

[Ada] The Unix Epochalypse of 2038 (Warn about time_t in the compiler)

2021-07-05 Thread Pierre-Marie de Rodat
Add some comments to warn about the use of time_t in the host based tools since it's not practical to remove the declaration itself. Rename some formal parameters in internal subprograms to reflect the fact that OS_Time is the preferred interface type. Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Fix excessive check for alignment of overlaying objects

2021-07-05 Thread Pierre-Marie de Rodat
When generating alignment checks for Address representation clauses we optimized them away for clauses like: for X'Address use Arr (1)'Address; for X'Address use Rec.C'Address; but not: for X'Address use Obj'Address; even though the alignment of Obj is known. Tested on x86_64-pc-linux-gn

[Ada] Fix missing error messages when returning limited type

2021-07-05 Thread Pierre-Marie de Rodat
Check_Limited_Return originally used Comes_From_Source (N) in order to decide whether N was a return statement created from an extended return statement or not. This was a problem because the return statement from expression functions also have their Comes_From_Source flag set to false. The soluti

[Ada] Fix some "current instance" bugs

2021-07-05 Thread Pierre-Marie de Rodat
This started out as an Ada2022 ticket, but work on Ada 2022 constructs uncovered bugs that could affect pre-Ada2022 code. Fix those bugs. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): When building the assignme

[Ada] Adapt SPARK RM rule on non-effectively volatile abstract state

2021-07-05 Thread Pierre-Marie de Rodat
SPARK RM 7.1.3(8) has been updated to reflect the fact that abstract states which do have Async_Writers or Effective_Reads cannot have as constituents objects which are effectively volatile for reading, hence need not require that a function reading such an abstract state be marked as a volatile fu

[Ada] Reject overlays in Global/Depends/Initializes contracts

2021-07-05 Thread Pierre-Marie de Rodat
Object overlays, i.e. objects with an Address clause that specify the address of an overlaid object, are no longer allowed to appear in SPARK data and dependency flow contracts. Also, they do not contribute to the package state and so don't need to appear in Refined_State contracts. Tested on x86_

[Ada] Simplify and reuse Is_Concurrent_Interface

2021-07-05 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Stream_Operation_OK): Reuse Is_Concurrent_Interface. * sem_ch3.adb (Analyze_Interface_Declaration, Build_Derived_Record_Type): Likewise. * sem_

[Ada] Clean up Get_Index_Bounds

2021-07-05 Thread Pierre-Marie de Rodat
Replace some calls to procedure Get_Index_Bounds with calls to the function with the same name. Not all calls are replaced (some seem clearer as procedure calls). Change names to be more consistent with the RM. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb, exp

[Ada] Add Ada 2022 Image and Put_Image support for tagged types

2021-07-05 Thread Pierre-Marie de Rodat
GNAT's initial implementation of Ada 2022's Image and Put_Image attributes did not include full support for tagged types. Improve that level of support. This support is still disabled by default and is enabled via the -gnatd_z switch because it generates additional dispatching routines even for Ada

[Ada] INOX: prototype alternative accessibility model

2021-07-05 Thread Pierre-Marie de Rodat
This patch implements an experimental restriction No_Dynamic_Accessibility_Checks which presents the two alternative accessibility models. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Accessibility_Checks_Suppressed): Add check against restriction No_D

[Ada] Remove Ada.Strings.Text_Output and child units

2021-07-05 Thread Pierre-Marie de Rodat
The GNAT-defined package Ada.Strings.Text_Output has been replaced by the Ada-defined package Ada.Strings.Text_Buffers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-stobbu.adb, libgnat/a-stobbu.ads, libgnat/a-stobfi.adb, libgnat/a-stobfi.ads, lib

[Ada] Add Reference and Constant_Reference functions to formal containers

2021-07-05 Thread Pierre-Marie de Rodat
Reference and Constant_Reference functions are added to all formal containers types, returning an access to an element in the container. This takes avantage of pointer support in SPARK. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfdlli.ads, libgnat/a-cfdlli.ad

[Ada] Spurious conformance error on expression function

2021-07-06 Thread Pierre-Marie de Rodat
Compiler rejects an expression function whose signature includes an access parameter with a null_exclusion indicator. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not perform conformance check when the subprogram bo

[Ada] Add GNAT RM text regarding Ada 2022 default Put_Image implementation

2021-07-06 Thread Pierre-Marie de Rodat
Add GNAT RM text indicating that users should not rely on the details of the text generated by the default implementation of T'Put_Image for any nonscalar type T. The compiler is free to change the details of such text, subject to the general guidance on this topic given in the Ada RM. Tested on x

[Ada] Support for Object.Op subprogram-call notation for untagged types

2021-07-06 Thread Pierre-Marie de Rodat
This is a prototype implementation of a language extension that allows calls to primitives of untagged types to be written using prefixed notation. That is, the first actual parameter of the call is given as a prefix using selected_component syntax, and the selector is a primitive operation of the

[Ada] Add Void_Or_Type_Kind and Exception_Or_Object_Kind

2021-07-06 Thread Pierre-Marie de Rodat
To be used in GNAT LLVM as declarations for parameters and variables. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-types.ads (Void_Or_Type_Kind, Exception_Or_Object_Kind): Declare. * gen_il-gen-gen_entities.adb: Likewise.diff --git a/gcc/ada/gen_il-

[Ada] Unix Epochalypse (s-osprim.adb)

2021-07-06 Thread Pierre-Marie de Rodat
System.OS_Primitives in libgnat for VxWorks imports Ssystem.OS_Interface in libgnarl, creating a dependency on libgnarl by libgnat. This works as long as the functions being referenced in OS_Primitives were pragma imported functions from the kernel, but this is no longer the case with a selectable

[Ada] Improper predicate check on view conversion

2021-07-06 Thread Pierre-Marie de Rodat
This patch removes an incorrect predicate check applied to a view conversion of a tagged object. Such a view conversion is an object and can appear as the target of an assignment statement, in which case no predicate check applies to the now-dead value. Tested on x86_64-pc-linux-gnu, committed on

[Ada] Make parent of N_Exception_Declaration be N_Declaration

2021-07-06 Thread Pierre-Marie de Rodat
The parent was Node_Kind before. This is a minor cleanup, and has no effect on the operation of the compiler. However, if we start declaring more objects of the various predicated subtypes, such as N_Declaration_Id, it would be good to get them right. Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Return when not working for procedures

2021-07-06 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby the experimental "return when" feature was not supported in procedures. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch6.adb (Get_Return_Kind): Properly handle the case of a "return when" statement in the procedur

[Ada] Tbuild cleanup

2021-07-06 Thread Pierre-Marie de Rodat
This patch removes some unnecessary unchecked conversions from the generated code. This makes the .dg output more readable in some cases, especially those involving finalization. Also misc cleanups. This patch does not change calls to Make_Unchecked_Type_Conversion to Unchecked_Convert_To, but we

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