[Ada] Error when closing c_stream

2020-10-23 Thread Pierre-Marie de Rodat
When using .C_Streams.Open with a null Name, the File will be incorrectly set as a temporary file, causing a wrong attempt to delete it when closing it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-fileio.adb (Open): Fix setting of Tempfile.diff --git a/gcc/

[Ada] Missing detection of unused with_clause

2020-10-23 Thread Pierre-Marie de Rodat
In some cases involving a package spec using object.method notation in e.g. subprogram aspects, an old change in Complete_Object_Operation would disable the proper detection of an unused "with" clause. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Complete_Obj

[Ada] Decorate iterated_component_association in SPARK expansion

2020-10-23 Thread Pierre-Marie de Rodat
When compiling iterated_component_association, the analysis, resolution and range checking is done when expanding aggregate into assignments. This is now mirrored in the custom expansion for GNATprove, so that the backend sees a fully decorated (but unexpanded) AST. Tested on x86_64-pc-linux-gnu,

[Ada] Do not use Long_Long_Long_Integer'Image with pragma Discard_Names

2020-10-23 Thread Pierre-Marie de Rodat
When the Image attribute is applied to an enumeration type subject to pragma Discard_Names, the underlying numeric value is printed instead of the string of the literal and this is done by invoking the Image routine of Long_Long_Long_Integer, which is overkill in the context. Tested on x86_64-pc-l

[Ada] Ignore container types for aggregates if not in Ada_2020

2020-10-23 Thread Pierre-Marie de Rodat
To prevent ambiguities in the use of predefined containers in legacy code, the resolution of aggregates must ignore the presence of the Aggregate aspect when the compilation version is earlier than Ada_2020. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resol

[Ada] Fix logic in C_Select under mingw

2020-10-23 Thread Pierre-Marie de Rodat
GNAT started generated a new legitimate warning on g-socthi__mingw.adb: g-socthi.adb:395:19: warning: condition is always True After further investigation, it appears that Original_WFS was unconditionally dereferencing Writefds without first checking against null. Tested on x86_64-pc-linux-gnu, c

[Ada] Sockets.Poll implementation

2020-10-23 Thread Pierre-Marie de Rodat
Implement wait on set of sockets to become ready to perform I/O operations. Current implementation of the similar functionality with type Selector_Type and Check_Selector routine in GNAT.Sockets package is limited by 1024 sockets. New implementation limited only by process limit on number of open

[Ada] Further Ada 2020 work on accessibility checking

2020-10-23 Thread Pierre-Marie de Rodat
This patch implements AI12-0035, AI12-0335, AI12-0345, AI12-0372, and partially Ada2012-A235 and fixes many holes in accessibility checking. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Apply_Accessibility_Check): Skip checks against the extra accessib

[Ada] Clean up in writing of ALI files

2020-10-23 Thread Pierre-Marie de Rodat
We had code that was trying to read an existing ALI files to extract information in -gnatc mode, mainly for ASIS use. Remove this code which is no longer needed and might even cause hard to understand effects. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-writ.ads, lib

[Ada] Reject illegal syntax in pragma Contract_Cases

2020-10-23 Thread Pierre-Marie de Rodat
In pragma Contract_Cases argument only "CASE_GUARD => CONSEQUENCE" clauses are allowed. Once we know that the pragma argument is an N_Aggregate, we checked if it has component associations; now we also check that it has no expressions. Same for the argument of the Subprogram_Variant contract, whos

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

2020-10-23 Thread Pierre-Marie de Rodat
This removes the now obsolete legality rules specified by AI12-0128 and replaces them with the new legality rules specified by AI12-0363 pertaining to nonatomic subcomponents of full access types and objects. This also introduces the new aspect Full_Access_Only in Ada 2020 mode and revamps the imp

[Ada] Remove Digits_From_Size and Width_From_Size

2020-10-27 Thread Pierre-Marie de Rodat
The Digits_From_Size and Width_From_Size functions of Get_Targ, as well as the *_Width and *_Digits constants of Ttypes, have been unused for a while in the compiler. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ada_get_targ.adb (Digits_From_Size): Delete. (Width_

[Ada] Warnings on g-spogwa.adb

2020-10-27 Thread Pierre-Marie de Rodat
This unit added recently generate legitimate warnings which were not caught because this file had not been added to Makefile.rtl. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-spogwa object. * libgnat/g-spogwa.adb: Fix

[Ada] Multidimensional arrays with Iterated_Component_Associations

2020-10-27 Thread Pierre-Marie de Rodat
This patch allows the compiler to handle array aggregates with more than two dimensions, when the aggregate includes nested Iterated_Component_Associations for sub-aggregates. These constructs are expanded into a loop that contains a copy of the expression. Previously their semantic analysis was do

[Ada] New flag Transform_Function_Array

2020-10-27 Thread Pierre-Marie de Rodat
This new flag is introduced to enable the transformation of function returning constrained arrays into a procedure separately from Modify_Tree_For_C for easier reuse. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb, freeze.adb, gnat1drv.adb, opt.ads, sem_ch6.adb

[Ada] Fix GNATprove support for iterated_component_associations

2020-10-27 Thread Pierre-Marie de Rodat
GNAT only partially analyzes iterated_component_associations within array aggregates, as they are fully analyzed when expanded into loops. GNATprove must therefore analyze iterated_component_associations as part of its custom expansion. This only worked for one-dimensional array aggregates; now it

Re: [PATCH] Ada: hashed container Cursor type predefined equality non-conformance

2021-04-09 Thread Pierre-Marie de Rodat
on the list. Thank you again for your contribution. -- Pierre-Marie de Rodat

[Ada] Add more initialization of Stored_Constraint

2021-06-15 Thread Pierre-Marie de Rodat
There several more missing cases of needing to reinitialize Stored_Contraint when changing Etype from an incomplete type to a modular or array type (where the field is Original_Array_Type). Also, include the node number in the -gnatd_v output. Tested on x86_64-pc-linux-gnu, committed on trunk gcc

[Ada] Avoid inappropriate error messages regarding aggregates and variant parts

2021-06-15 Thread Pierre-Marie de Rodat
An aggregate of a type that has a variant part has to satisfy certain rules about the discriminant value governing that variant part. If these rules are violated, then the front end typically emits a message associated with the discriminant value. However, this is not useful in the case where the d

[Ada] Rename Ada 202* to Ada 2022

2021-06-15 Thread Pierre-Marie de Rodat
The next Ada standard will finally be Ada 2022, so update references to Ada 2020 and 202X accordingly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads, errout.adb, errout.ads, exp_aggr.adb, exp_ch5.adb, exp_ch6.adb, exp_ch8.adb, exp_ch9.adb, exp_imgv.adb,

[Ada] Robust switching from incomplete to access types

2021-06-15 Thread Pierre-Marie de Rodat
When processing an access type declaration that completes an incomplete type, we now cleanly switch to a proper access type before setting the designated type. This simplifies the previous ad-hoc machinery for error recovery, which actually didn't work when the completion as an access type referenc

[Ada] Fix bug in subtype of private type with invariants

2021-06-15 Thread Pierre-Marie de Rodat
This patch fixes a bug in which the compiler could crash if there is a subtype of a private type, and the full type has invariants. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Propagate_Invariant_Attributes): Call Set_Has_Own_Invariants on the base

[Ada] Variable-sized node types: improve error messages

2021-06-15 Thread Pierre-Marie de Rodat
Give a better error message when we run out of fields. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen.adb (To_Bit_Offset): Use 'Base to avoid overflow in computations in Last_Bit when Offset = 'Last. (Choose_Offset): Give a better error message wh

[Ada] Fix bug in if_expressions introduced by var-size nodes changes

2021-06-15 Thread Pierre-Marie de Rodat
The old compiler (pre-var-size nodes) had code in Set_Then_Actions to set the parent of the Then_Actions to point to the If_Expression, even though this field is not syntactic. This was missing from the new version. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen

[Ada] Add support for folding more and/or expressions

2021-06-15 Thread Pierre-Marie de Rodat
In particular we now recognize expressions of the form xxx and False xxx or True when xxx has no side effect. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.adb (Eval_Logical_Op, Test_Expression_Is_Foldable): Add support for folding more "and"/"or" ex

[Ada] Remove redundant guard from Find_Overlaid_Entity

2021-06-15 Thread Pierre-Marie de Rodat
The comment for Find_Overlaid_Entity which says "node N should be an address representation clause" is now enforced with an assertion. A defensive code is removed from the body; the defensive code at the callers of this routine is enough to prevent crashes. Code cleanup related to improved handlin

[Ada] Remove const qualifier on a couple of pointed-to types

2021-06-15 Thread Pierre-Marie de Rodat
gnat_argv is defined as pointer to const memory in argv.c but declared and accessed as pointer to mutable memory in rtinit.c, which breaks the One Definition Rule in C++. Its initialization is also non-standard. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * argv.c: Add in

[Ada] Add Interface_Name field to E_Loop_Parameter

2021-06-15 Thread Pierre-Marie de Rodat
...for uniformity of referencing code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen-gen_entities.adb (E_Loop_Parameter): Add Interface_Name field.diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb --- a/gcc/ada/gen_il

[Ada] Disable certain checks in predefined units

2021-06-15 Thread Pierre-Marie de Rodat
This patch fixes a failure of ACATS test cxaib08, which was getting errors in instances of Bounded_Hashed_Maps about nonpreelaborable constructs. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_cat.adb (Check_Non_Static_Default_Expr): Allow nonstatic expression i

[Ada] Allow Known_Static_Component_Size (etc) on private types

2021-06-15 Thread Pierre-Marie de Rodat
Use Implementation_Base_Type instead of Base_Type in certain synthesized attributes so they work on private types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo-utils.adb (Known_Component_Size, Known_Static_Component_Size, Unknown_Component_Size): Use

[Ada] Fix typos in comment about expansion of attribute Image

2021-06-15 Thread Pierre-Marie de Rodat
Minor fix in comment; behaviour is unaffected. Spotted while examining the expansion of attribute Image in GNAT so it can be better supported in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_imgv.adb (Expand_User_Defined_Enumeration_Image): Fix typos

[Ada] Error when passing subprogram'Access to null-defaulted formal subprogram

2021-06-15 Thread Pierre-Marie de Rodat
The compiler issues an error on passing 'Access of a subprogram declared within a generic unit body to an anonymous access-to-subprogram formal of a formal subprogram of the generic that has an "is null" default, when the generic is instantiated and the actual for that formal subprogram is defaulte

[Ada] AI12-0138: Iterators and other nonoverridable aspects

2021-06-15 Thread Pierre-Marie de Rodat
This Ada202X AI, as well as AI12-0396 and AI12-0423, clarifies the notion of nonoverridable aspects, as well as the rules for confirming inheritance of such aspects. This patch refines the check for confirming specifications to allow, e.g. renamed discriminants to carry an Implicit_Dereference aspe

[Ada] Fix detection of access-to-variable types

2021-06-15 Thread Pierre-Marie de Rodat
Routine Is_Access_Variable, which relied on the Ekind of the type, wrongly returned True for subtypes of an access-to-subprogram type. It is more reliable to also use Directly_Designated_Type. This only affects SPARK legality checks for Global and Depends contracts; compilation is not affected, be

[Ada] Incorrect Reinit_Field_To_Zero calls for concurrent entities

2021-06-15 Thread Pierre-Marie de Rodat
This patch fixes some calls to Reinit_Field_To_Zero that were called for too many or too few Ekinds. In particular, SPARK_Aux_Pragma_Inherited does not exist in concurrent subtypes, causing crashes in Atree when the pragmas at the start of the file are removed. Tested on x86_64-pc-linux-gnu, commi

[Ada] Enable removal of side-effects in component declarations

2021-06-15 Thread Pierre-Marie de Rodat
Side-effects in component declarations are prohibited in SPARK (both in the constraints of component type definitions and in the default expressions), but GNAT requires them to be removed when processing records with per-object constraints. This patch allows removal of side-effects in component de

[Ada] No_Task_Parts aspect

2021-06-15 Thread Pierre-Marie de Rodat
The patch implements the No_Task_Parts aspect, which says that a type and extensions of it cannot contain tasks. In addition, we optimize away tasking-related code for T'Class when T has No_Task_Parts. This is mostly just an efficiency improvement, but it fixes a bug in one obscure case: The expan

[Ada] Avoid unhelpful dead code warnings

2021-06-15 Thread Pierre-Marie de Rodat
We have an existing mechanism for suppressing dead code warning messages in the case of an if-statement within an instance of a generic where the value of the condition is known statically. Generalize this approach to also handle case statements. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Use runtime from base compiler during stage1

2021-06-15 Thread Pierre-Marie de Rodat
When performing a bootstrap with Ada, we are currently using the runtime files from the repository during stage1, causing some subtle inconsistencies during stage1 of the bootstrap, sometimes hard to workaround. This change now uses the runtime from the base compiler during stage1 only. We still re

[Ada] Small cleanup in System.Exceptions

2021-06-16 Thread Pierre-Marie de Rodat
This removes obsolete stuff. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-except.ads (ZCX_By_Default): Delete. (Require_Body): Likewise. * libgnat/s-except.adb: Replace body with pragma No_Body.diff --git a/gcc/ada/libgnat/s-except.adb b/gcc/ada/

[Ada] Reorder code for validity checks of unchecked conversions

2021-06-16 Thread Pierre-Marie de Rodat
The placement of check for types of an unchecked conversion being generic was done in the middle of switching from their original to underlying views, which was inconsistent and made the surrounding comments confusing. Code cleanup in preparation for a follow-up improvement; behaviour is unaffecte

[Ada] Raise expressions and unconstrained components

2021-06-16 Thread Pierre-Marie de Rodat
During the implementation of AI12-0172, we incorrectly allowed illegal cases of unconstrained components. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Analyze_Component_Declaration): Do not special case raise expressions. gcc/testsuite/ * gn

[Ada] Small cleanup in C header files

2021-06-16 Thread Pierre-Marie de Rodat
This removes obsolete stuff. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * initialize.c: Do not include vxWorks.h and fcntl.h from here. (__gnat_initialize) [__MINGW32__]: Remove #ifdef and attribute (__gnat_initialize) [init_float]: Delete. (__gnat

[Ada] Use more straightforward implementation for Current_Entity_In_Scope

2021-06-16 Thread Pierre-Marie de Rodat
This new version is both more straightforward to understand and to map to the generated code at high optimization. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Current_Entity_In_Scope): Reimplement.diff --git a/gcc/ada/sem_util.adb b/

[Ada] Fix missing array bounds checking

2021-06-16 Thread Pierre-Marie de Rodat
For an assignment statement of the form "A.B(C).D := ...", in a loop, the index check on C can be missing. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ghost.adb: Add another special case where full analysis is needed. This bug is due to quirks in the way

[Ada] ACATS 4.1R-c611a04: Class-wide preconditions in dispatching calls

2021-06-16 Thread Pierre-Marie de Rodat
Completing previous patch since it introduced a regression on ACATS c611a03 under certified runtime. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_disp.adb (Build_Class_Wide_Check): Ensure that evaluation of actuals is side effects free (since the check duplica

[Ada] Do not perform useless work in Check_No_Parts_Violations

2021-06-16 Thread Pierre-Marie de Rodat
There is no need to walk the hierarchy rooted at a type that does not come from source only to drop the result on the floor. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Check_No_Parts_Violations): Return earlier if the type is

[Ada] Make Incomplete_Or_Partial_View independent of the context

2021-06-16 Thread Pierre-Marie de Rodat
The value returned by Incomplete_Or_Partial_View depends on the current scope, which is unexpected at best. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Incomplete_Or_Partial_View): Retrieve the scope of the parameter and use it to find its incomplet

[Ada] Non-static Interrupt_Priority allowed with restriction Static_Priorities

2021-06-16 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby a non-static expression is allowed as an argument to aspect Interrupt_Priority despite restriction Static_Priorities being in effect. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Make_Aitem_Pragma): Check for

[Ada] Fix ALI source location for dominance markers

2021-06-16 Thread Pierre-Marie de Rodat
As First_Sloc is used to compute source location for entry guards, it must be also used to compute the dominance marker source location in this particular case (when a statement is dominated by an entry guard). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par_sco.adb (Set

[Ada] Spurious accessibility error on "for of" loop parameter

2021-06-16 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby taking 'Access of a "for of" loop parameter caused spurious compile-time accessibility errors. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Accessibility_Level): Take into account renamings of loop pa

[Ada] Mixing of positional and named entries allowed in enum rep

2021-06-16 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby the mixing of positional and named entries in an enumeration representation clause was erroneously allowed instead of rejected - as per RM rules. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Analyze_Enumerati

[Ada] Remove unused initialization with New_List

2021-06-16 Thread Pierre-Marie de Rodat
Code cleanup; behaviour is unaffected. The extra initialization most likely come from a initial version of the patch, before the limit of parameters to a subsequent call to New_List was discovered. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_Slice_Assi

[Ada] Adapt Is_Actual_Parameter to also work for entry parameters

2021-06-16 Thread Pierre-Marie de Rodat
Routine Is_Actual_Parameter now also detects entry parameters; this change is harmless for GNAT and allows this routine to be reused in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads (Is_Actual_Parameter): Update comment. * sem_util.adb (Is_A

[Ada] Wrong reference to System.Tasking in expanded code

2021-06-16 Thread Pierre-Marie de Rodat
The expanded code should never reference entities in the tasking runtime (libgnarl) except when expanding tasking constructs directly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * rtsfind.ads, libgnarl/s-taskin.ads, exp_ch3.adb, exp_ch4.adb, exp_ch6.adb, exp_ch9.a

[Ada] Implementation of AI12-0152: legality rules for Raise_Expression

2021-06-16 Thread Pierre-Marie de Rodat
This patch implements the legality rules specified in RM 11.3 (2) for the placement of Raise_Expressions. In Ada2020 aspect specifications can appear in several new declarative contexts, and the keyword "with" can be part of a Raise_Expression or the start of a list of aspect specifications. To pr

[Ada] Fix aliasing check for actual parameters passed by reference

2021-06-16 Thread Pierre-Marie de Rodat
The aliasing check applies when some of the formals has their passing mechanism unspecified; RM 6.2 (12/3). Previously it only applied when the first formal had its passing mechanism unspecified and the second had its passing mechanism either unspecified or by-reference. Tested on x86_64-pc-linux-

[Ada] Include info about containers in GNAT RM Implementation Advice section

2021-06-16 Thread Pierre-Marie de Rodat
For each instance of implementation advice given in the Ada RM, the Implementation Advice section of the GNAT RM documents whether the advice is followed (see Ada RM M.3(1)). Such documention was missing for the implementation advice regarding Ada.Containers and its child units. Rectify this omissi

[Ada] Do not generate an Itype_Reference node for slices in GNATprove mode

2021-06-16 Thread Pierre-Marie de Rodat
As part of the work on changing side-effects removal in SPARK, a special case was introduced to generate an Itype_Reference for Itypes in slices. This was based on a misunderstanding of existing checks for bounds when analyzing slices. These Itype_Reference are actually not needed to get the corres

[Ada] Fix floating-point exponentiation with Integer'First exponent

2021-06-16 Thread Pierre-Marie de Rodat
It works neither at compile time nor at run time because of the classical issue that -Integer'First is not a valid Integer value. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * urealp.adb (Scale): Change first paramter to Uint and adjust. (Equivalent_Decimal_Exponen

[Ada] Fix detection of volatile expressions in restricted contexts

2021-06-16 Thread Pierre-Marie de Rodat
Detection of volatile expressions, i.e. references to volatile objects and allocators, is done in two steps: first when analysing entity names and allocators themselves (except when they occur within actual parameters of subprogram calls) and then after the subprogram call has been resolved (so tha

[Ada] Fix Is_Volatile_Function for functions declared in protected bodies

2021-06-16 Thread Pierre-Marie de Rodat
Function declared immediately within a protected body is a not a protected function; the exact definition is RM 9.5.1(1): "A protected subprogram is a subprogram declared immediately within a protected definition." Consequently, functions declared immediately within a protected body are not volati

[Ada] Ignore volatile restrictions in preanalysis

2021-06-16 Thread Pierre-Marie de Rodat
When detecting references to volatile objects in expressions of the expression functions we couldn't determine the enclosing function. This was because we examined a copy of the expression made for preanalysis and this copy is not properly decorated. Consequently, we wrongly rejected valid referenc

[Ada] Reject allocators in contexts restricted by SPARK

2021-06-17 Thread Pierre-Marie de Rodat
References to allocators, just like references to volatile objects, are now rejected in all context restricted by SPARK, both within actual parameters and outside of them. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Analyze_Allocator): Reject allocators in

[Ada] AI12-0411 Add "bool" to Interfaces.C

2021-06-17 Thread Pierre-Marie de Rodat
This AI got updated to remove some detected incompatibilities and Interfaces.C.bool is now named Interfaces.C.C_bool. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/i-c.ads, libgnat/i-cexten.ads, libgnat/i-cexten__128.ads: bool renamed C_bool.diff --git a/gc

[Ada] Apply aliasing checks only to names and not to objects as actuals

2021-06-17 Thread Pierre-Marie de Rodat
Run-time checks generated by the compiler with -gnateA switch are only relevant for actuals that name existing objects. They are irrelevant for other (anonymous) objects, because an object that acts as actual for one parameter cannot be referenced as the actual for another parameter. Consequently,

[Ada] Display Entity in debugging printouts

2021-06-17 Thread Pierre-Marie de Rodat
This patch fixes a bug in which procedures in Treepr such as pp would fail to display the Entity or Associated_Node fields. This was because of the shenanigans played with the Entity_Or_Associated_Node field (see Sinfo.Utils). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ *

[Ada] Do not systematically suppress checks on atree.adb

2021-06-17 Thread Pierre-Marie de Rodat
This does not make a significant enough performance difference. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * atree.adb: Do not suppress checks.diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb --- a/gcc/ada/atree.adb +++ b/gcc/ada/atree.adb @@ -27,12 +27,11 @@ -- file

[Ada] Look at Others_Discrete_Choices for N_Others_Choice

2021-06-17 Thread Pierre-Marie de Rodat
When seeing if we have any static predicates in an "others" choice for a case statement, look at and possibly update choices Others_Discrete_Choices. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Expand_Static_Predicates_In_Choices): Handle Others_Dis

[Ada] Provide new function Uintp.UI_To_Unsigned_64

2021-06-17 Thread Pierre-Marie de Rodat
The function UI_To_Int is sometimes not sufficient, so provide this new function which can be useful to some GNAT back-ends. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * uintp.ads, uintp.adb (UI_To_Unsigned_64): New.diff --git a/gcc/ada/uintp.adb b/gcc/ada/uintp.adb --- a

[Ada] Fix varsize node name conflict

2021-06-17 Thread Pierre-Marie de Rodat
The enumeration literals in type Node_Field were overloading the getter functions, which causes gdb to be confused. Same for Entity_Field. This patch prefixes all the enumeration literals with "F_", to disambiguate. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-ge

[Ada] Use source casing in messages for aliasing checks

2021-06-17 Thread Pierre-Marie de Rodat
When compiling code with -gnateA -gnateE switches, i.e. with aliasing checks and extra information in exception messages, the runtime error includes names the overlapping formal parameters. Those parameters are now printed exactly as they appear in the source code, not in casing that has been deter

[Ada] Clarify error for unsupported ELIMINATED overflow mode

2021-06-17 Thread Pierre-Marie de Rodat
The ELIMINATED overflow checking mode, enabled either by a pragma or a command line switch, requires Long_Long_Integer'Size to 64 (because of the assumptions in the System.Bignums library). GNAT emitted a cryptic error when this requirement was not satisfied, e.g. when using a target configuration

[Ada] Removal of technical debt

2021-06-17 Thread Pierre-Marie de Rodat
This is an iterative patch as part of a greater project to reduce the amount of technical debt present in the frontend of the compiler. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Check_Missing_Others): Add comment. (Build_Initialization_Call): Remov

[Ada] Move runtime units for Put_Image attribute to libgnarl

2021-06-17 Thread Pierre-Marie de Rodat
The initial implementation wrongly put s-putaim.ads, s-putaim.adb in libgnat instead of libgnarl. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-putaim.ads, libgnat/s-putaim.adb: Move... * libgnarl/s-putaim.ads, libgnarl/s-putaim.adb: ... here.diff --git /

[Ada] Cleanup redundant conditions in checks for overlapping actuals

2021-06-17 Thread Pierre-Marie de Rodat
Detection of overlapping actuals based on the mode and type of the formal parameters (i.e. IN/OUT/IN-OUT and elementary/composite) involved repeated conditions both in the outer loop (i.e. conditions applied to first formal) and in the inner loop (i.e. conditions applied to both formals). Those re

[Ada] Fix handling of generic types in check for overlapping actuals

2021-06-17 Thread Pierre-Marie de Rodat
In detection of overlapping actuals we were giving up on the first formal parameter of a generic type, which caused errors to depend on the order of parameters. Now we examine all parameters and simply ignore generic ones. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_

[Ada] Remove dead code for overlapping actuals and prefix notation

2021-06-17 Thread Pierre-Marie de Rodat
In detection of overlapping actuals we first call Refer_Same_Object to filter function calls that act as actual parameters. There is no need to later special-case any function calls, e.g. in the prefix notation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_warn.adb (W

[Ada] Check all pairs of actuals for overlapping

2021-06-17 Thread Pierre-Marie de Rodat
When detecting overlapping actuals GNAT was giving up on the first pair of parameters that refer to the same object (even when there was no overlapping because both parameters had mode IN). Now we examine all pairs. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_warn.ad

[Ada] Fix detection of slices that denote the same object

2021-06-17 Thread Pierre-Marie de Rodat
To detect overlapping slices acting as actual parameters we rely on the Get_Index_Bounds routine. We were calling it with a type entity, while its description says that it parameter "must be a range, subtype indication, or the name of a scalar subtype." Tested on x86_64-pc-linux-gnu, committed on

[Ada] Fix detection of valid renamings for overlapping checks

2021-06-17 Thread Pierre-Marie de Rodat
Checks for overlapping actuals only apply to "valid renamings", i.e. renamings whose renamed object_name contains no references to non-static expressions; RM 6.4.1 (6.11/3). Such references can appear both in indexed components and slices. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada

[Ada] Error in instance on incomplete actual passed to formal incomplete type

2021-06-17 Thread Pierre-Marie de Rodat
The compiler wrongly issues an error on a generic instantiation when an incomplete view of a type that is completed before the instantiation is given as an actual for a formal incomplete type. We now check whether the full view of the actual incomplete type is present at that point, and associate t

[Ada] Don't check No_Wide_Characters restriction for illegal types

2021-06-17 Thread Pierre-Marie de Rodat
On illegal declarations of illegal types, e.g.: type X; type X is new X; the No_Wide_Characters restriction was checked using an incomplete entity of type X, which caused a crash. Now restriction No_Wide_Characters in derived types is checked after the legality of the parent type has been

[Ada] Remove dubious wrapper of a recursive function

2021-06-17 Thread Pierre-Marie de Rodat
Routine Is_Valid_Renaming was a wrapper subprogram that simply called its nested function. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Is_Valid_Renaming): Body moved from its nested routine.diff --git a/gcc/ada

[Ada] Crash on a nested aggregate containing controlled objects

2021-06-17 Thread Pierre-Marie de Rodat
Exp_Util.Find_Hook_Context wasn't prepared to handle this case properly and we ended up inserting a statement in the middle of an aggregate, causing chaos. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Find_Hook_Context): Do not stop on an aggregate n

[Ada] Missing finalization on nested expression with action

2021-06-17 Thread Pierre-Marie de Rodat
Finalization may be missed when at least two if or case expressions are nested together and a controlled object is created after the nested expression. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_Expression_With_Actions.Process_Action): Do n

[Ada] Casing on composite values

2021-06-17 Thread Pierre-Marie de Rodat
Initial support for casing on composite values if extensions are allowed (e.g., if -gnatX is specified). The implementation is far from complete. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch5.adb (Expand_N_Case_Statement.Expand_General_Case_Statement): New

[Ada] Implementation of Inox feature of fixed lower bounds on array types/subtypes

2021-06-17 Thread Pierre-Marie de Rodat
This is a prototype implementation of the feature for defining array types and subtypes with fixed lower bounds for index ranges as proposed as part of the "Inox" language design effort. This feature is currently supported under control of the -gnatX (language extensions) switch, and allows unconst

[Ada] Warn on 'in out' param containing access in predefined private type

2021-06-17 Thread Pierre-Marie de Rodat
Normally the warnings: warning: formal parameter "..." is not modified warning: mode could be "in" instead of "in out" are disabled if the type contains components of an access type. This patch enables such warnings if the only such components are in internal private types. Tested on x8

[Ada] Fix operations on Unbounded_String...

2021-06-17 Thread Pierre-Marie de Rodat
... when its length is close to Natural'Last. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strunb__shared.ads (Allocate): Additional parameter to provide additional amount of space to be allocated. * libgnat/a-strunb__shared.adb (Aligned_Max_Leng

[Ada] Crash on overriding of an abstract primitive on an incomplete type

2021-06-17 Thread Pierre-Marie de Rodat
This combination breaks an assumption in Sem_Ch3.Check_Ops_From_Incomplete_Type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Check_Ops_From_Incomplete_Type): Protect against no Primitive_Operations.diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.a

[Ada] GNAT.Compiler_Version and LTO

2021-06-18 Thread Pierre-Marie de Rodat
When mixing GNAT.Compiler_Version and LTO, a warning about a type mismatch between the import and export of __gnat_version is generated. Fixed by introducing a level of indirection. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * bindgen.adb (Gen_Output_File_Ada): Generate

[Ada] Update comments related to TBD

2021-06-18 Thread Pierre-Marie de Rodat
We use ??? when relevant, not TBD in GNAT comments Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb, exp_dist.adb, exp_unst.adb, sa_messages.ads, sem_ch13.adb, sem_ch3.adb, sem_ch5.adb, sem_eval.adb, sem_util.adb, sem_util.ads, sinfo.ads: Update c

[Ada] Replace Opt.Extensions_Allowed by Ada_Version

2021-06-18 Thread Pierre-Marie de Rodat
Code cleanup: add a new value in Ada_Version_Type to represent the latest version of Ada with GNAT extensions instead of using a separate flag. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * fe.h, opt.adb, opt.ads, par-prag.adb, sem_prag.adb, switch-c.adb (Extension

[Ada] Implement basic support for -fdiagnostics-format=json

2021-06-18 Thread Pierre-Marie de Rodat
This commit implements basic support for the -fdiagnostics-format=json option that GCC has. When GNAT finds this argument in the command line, error messages such as: tmp.adb:4:12: "My_Var" is undefined Will be printed as: [ { "kind": "error", "locations": [ { "caret": {

[Ada] Do not clear Is_True_Constant flag on imported constants

2021-06-18 Thread Pierre-Marie de Rodat
The flag is first set on them as for any other constants but then cleared when the import pragma is processed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Process_Import_Or_Interface): Do not artificially record a possible modification for a constan

[Ada] Relax null exclusion mismatch check in Relaxed_RM_Semantics mode

2021-06-18 Thread Pierre-Marie de Rodat
This is useful for e.g. CodePeer usage. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Null_Exclusions_Match): Relax null exclusion mismatch check when Relaxed_RM_Semantics is set.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/ada/sem_

[Ada] Remove dead code for overlapping actuals in prefix notation

2021-06-18 Thread Pierre-Marie de Rodat
Detection of overlapping actuals doesn't need to be special-cased for prefix notation, because it is done after prefixed calls have been rewritten into ordinary calls, both in normal compilation and semantic checking mode (with switch -gnatc). Behaviour is unaffected; the removed code was dead. T

[Ada] New debug switch to disable large static aggregates

2021-06-18 Thread Pierre-Marie de Rodat
This patch adds the -gnatd_g switch, which lowers the threshold for computing static aggregates at compile time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * debug.adb: Document switch. * exp_aggr.adb: If -gnatd_g was given, then do not bump the limit to 5

[Ada] Warn on 'in out' param containing access in private type

2021-06-18 Thread Pierre-Marie de Rodat
Normally the warnings: warning: formal parameter "..." is not modified warning: mode could be "in" instead of "in out" are disabled if the type contains components of an access type. A previous patch enabled such warnings if the only such components are in internal private types. This pa

<    10   11   12   13   14   15   16   17   18   19   >