[Ada] Add support for Unreferenced aspect on formal parameters

2020-10-20 Thread Pierre-Marie de Rodat
This is useful in particular to be able to mark a formal parameter of an expression function as unreferenced: function F (Param : Integer with Unreferenced) return Integer is (1); We also add the infrastructure to support other aspects on formal parameters in the future. Put this feature unde

[Ada] Refine type for type constraining routines

2020-10-20 Thread Pierre-Marie de Rodat
Parameters of Constrain_Decimal, Constrain_Enumeration, etc. routines are type entities, which is now reflected in the parameter type. Cleanup only; behavior is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Constrain_Decimal, Constrain_Enumeration,

[Ada] Simplify the VxWorks implementation of __gnat_environ

2020-10-21 Thread Pierre-Marie de Rodat
The VxWorks kernel implementation of __gnat_environ was more convoluted than it needed to be and had an unneeded dependency on ppGlobalEnviron, a symbol which Wind River has removed in newer versions of VxWorks. This patch simplifies the implementation and uses a common implementation for both VxWo

[Ada] Raise Capacity_Error on formal vector insertion

2020-10-21 Thread Pierre-Marie de Rodat
Capacity_Error should be raised on insertion inside a formal vector when the capacity is exceeded. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cofove.adb (Copy): Add explanation in case of Capacity_Error. (Insert_Space): Raise Capacity_Error if

[Ada] Improve precision of Ada.Directories.Modification_Time

2020-10-21 Thread Pierre-Marie de Rodat
The modification file time precision now defined by OS. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.c (__gnat_file_time): New routine. (__gnat_copy_attribs): Copy timestamps in nanoseconds. * libgnat/a-direct.adb (C_Modification_Time): Bind to

[Ada] Disable warnings on entities when building finalizers

2020-10-21 Thread Pierre-Marie de Rodat
GNAT emits references to GNAT-generated entities when generating finalizers. These references are protected by a counter. GCC is unable to detect that the counter protects these references and emits warnings when -Wmaybe-uninitialized is used. This is a problem because users can't do anything to p

[Ada] Make minimum accessibility level a constant object

2020-10-21 Thread Pierre-Marie de Rodat
Minimum accessibility level was stored in a variable which was never modified. It seems cleaner to store it in a constant, which hopefully allows better optimization (e.g. when tracking know object the value of a variable is killed on a subprogram called). No impact on compiler behaviour, expect p

[Ada] Use VxWorks 7 APIs for accessing environment variables in kernel mode

2020-10-21 Thread Pierre-Marie de Rodat
VxWorks 7 provides newer APIs for kernel mode for accessing environment variables that lead to smaller and more efficient code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * env.c (__gnat_setenv): call setenv for VxWorks 7 kernel mode. (__gnat_environ): envGet take

[Ada] Fix bogus error for bit-packed array with volatile component

2020-10-21 Thread Pierre-Marie de Rodat
This fixes a bogus error recently introduced in the compiler for a bit-packed array component in a record type with Volatile_Components aspect on the array definition. The array type should not be deemed requiring strict alignment, although it is a by-reference type. Tested on x86_64-pc-linux-gnu

[Ada] Incorrect associations for extra accessibility parameters

2020-10-21 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby extra accessibility level actuals did not get expanded properly in calls - leading to mislabed parameter associations. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_Call_Helper): Modify calls to

[Ada] Remove -mthreads from Linker_Options pragma for x86-lynx178e

2020-10-21 Thread Pierre-Marie de Rodat
The -mthreads flag is no longer needed. It was deprecated in 2.2.4 and in 2.2.5 causes the linker to reference a non-existent directory. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-osinte__lynxos178e.ads: Remove -mthreads switch.diff --git a/gcc/ada/libgnarl/

[Ada] Fix crash with iterated_component_association and -gnatc

2020-10-21 Thread Pierre-Marie de Rodat
When expansion was disabled, e.g. in GNATprove mode or when switch -gnatc was used, analysis of the iterated_component_association's expression was crashing when the expression included a function call. The problem was that a copy of the expression was created with empty parent. Then an access-be

[Ada] Use helper function in Freeze_Subprogram_Body

2020-10-21 Thread Pierre-Marie de Rodat
This replaces the manual retrieval of the freeze node for the enclosing body of the generic with a mere call to Package_Freeze_Node. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch12.adb (Freeze_Subprogram_Body): Call Package_Freeze_Nod

[Ada] Wrong detection of potentially blocking call in protected object

2020-10-21 Thread Pierre-Marie de Rodat
When a protected subprogram invokes a function that returns a limited type, and the sources are compiled with pragma Detect_ Blocking, the code generated by the compiler erroneously invokes the runtime service Activate_Tasks, call which is detected by the runtime as a potentially blocking call (as

[Ada] Fix crash on illegal OTHERS in iterated_component_association

2020-10-21 Thread Pierre-Marie de Rodat
A code for detecting illegal OTHERS clause is handles both component_association and iterated_component_association, whose choice list must be accessed with Choices and Discrete_Choices, respectively. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Arra

[Ada] Implement missing function result finalization.

2020-10-21 Thread Pierre-Marie de Rodat
In the case where a function call a) has a non-limited result type that requires finalization; and b) the callee has an out-mode (or in-out-mode) formal parameter; and c) the corresponding actual parameter's subtype is subject to an enabled predicate , fix a compiler bug that could cause

[Ada] Use index parameter for iterated_component_association

2020-10-21 Thread Pierre-Marie de Rodat
Processing of index parameters in iterated_component_association was different within array aggregates (where we created a synonym identifier) and array delta aggregates (where we used the existing defining identifier). Apparently, we can use the existing defining identifiers in both cases. This

[Ada] Compiler crash on prefixed call to controlled function with invariant check

2020-10-21 Thread Pierre-Marie de Rodat
When post call actions are created for a call to a function with a result of a controlled type, such as for performing an invariant check on a parameter with mode out or in out, the compiler can violate an assertion (or crash with a Storage_Error) due to not recognizing the expanded call as a funct

[Ada] Work around missing Long_Long_Long_Size entry in .atp file

2020-10-21 Thread Pierre-Marie de Rodat
This prevents the compiler from giving an error message when the new Long_Long_Long_Size entry is missing in a target configuration file. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * set_targ.adb (DTN): Fix oversight. (Read_Target_Dependent_Values): Do not error o

[Ada] Codepeer remarks take into account

2020-10-21 Thread Pierre-Marie de Rodat
This patch adds pragma Assert to help CodePeer static analysis and pragma Annotate to ignore Intentional or False_Positive warning. Furthermore, some minor changes were added to take into account CodePeer finding. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-car

[Ada] Fix problematic placement of freeze node after instantiation

2020-10-21 Thread Pierre-Marie de Rodat
This prevents Freeze_Subprogram_Body from moving the freeze node of a package body outside of its scope when it contains the instantiation of a generic subprogram and the parent of the package body happens to be in the same declarative part as the freeze node of the scope of the generic subprogram.

[Ada] Fix analysis of iterated component expression with null range

2020-10-21 Thread Pierre-Marie de Rodat
When checking legality of the iterated_component_association's expression the index parameter must be in scope, even its range is null. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Gen_Loop): Analyze copy of the expression in the scope of the implici

[Ada] Fix target configuration file used for CodePeer/SPARK for new ints

2020-10-21 Thread Pierre-Marie de Rodat
The new 128-bits integer support requires adapting the special target configuration file used for CodePeer and SPARK analysis. One change was missing in Width_From_Size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ada_get_targ.adb (Width_From_Size): Add case for 128 bits

[Ada] Fix bootstrap with old GCC

2020-10-21 Thread Pierre-Marie de Rodat
Some gcc versions (4 or less) support the __builtin_*_overflow routines while corresponding g++ compilers do not. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.c (__gnat_file_time): Use regular arithmetic instead of __builtin_*_overflow routines if GCC versi

[Ada] Add No_Implicit_Task_Allocations and No_Implicit_PO_Allocations to Jorvik

2020-10-22 Thread Pierre-Marie de Rodat
Jorvik was meant to include the restrictions No_Implicit_Task_Allocations and No_Implicit_Protected_Object_Allocations but they accidentally got overlooked during the standardisation of the GNAT_Extended_Ravenscar profile. These restrictions are important as they allow us to statically determine th

[Ada] Fix error message for import aspect

2020-10-22 Thread Pierre-Marie de Rodat
Confusing error messages are emitted about arguments when erroneously using the import/convention aspect. This is caused by GNAT turning aspects into pragmas and then emitting error messages about pragmas. This is fixed by checking if the pragma comes from an aspect specification and emitting a di

[Ada] Reduce scope of local variables for detecting extra WITH clauses

2020-10-22 Thread Pierre-Marie de Rodat
Reduce visibility of variables in procedure Check_Unused_Withs by moving them to a nested procedure Check_One_Unit. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_warn.adb (Check_Unused_Withs): Move local variables from to

[Ada] Fix bogus error on conversion from Float to 128-bit unsigned

2020-10-22 Thread Pierre-Marie de Rodat
The compiler confuses itself because it generates a range check in Float whose upper bound is 2 ** 128, but this number is larger than the largest number representable in Float so it triggers an error when converted to Float as part of the check. The fix is to saturate the upper bound of the check

[Ada] Ada_2020: ongoing work for aggregates for bounded containers

2020-10-22 Thread Pierre-Marie de Rodat
This patch completes the handling of predefined bounded containers, including indexed containers with iterated_component_associations. The size of the constructed object is taken from the size of the aggregate if it can be determined statically, and otherwise uses the default value for the given p

[Ada] Fix transformation of Suppress aspect into pragma

2020-10-22 Thread Pierre-Marie de Rodat
Using the Suppress aspect results in a crash. This is caused by the incorrect transformation of the Suppress aspect into its pragma equivalent: the entity and check name were inverted. We use this change as an excuse to turn Make_Aitem_Pragma into a function that returns a new value instead of cha

[Ada] Fix oversight in Eval_Attribute for Bit_Position

2020-10-22 Thread Pierre-Marie de Rodat
The code would correctly distinguish the entity from the selected component case but not use the result of the analysis in the latter case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Eval_Attribute): Fix oversight for Bit_Position.diff --git a/gcc/ada/sem_

[Ada] Refactor appending to possibly empty lists

2020-10-22 Thread Pierre-Marie de Rodat
Reuse Append_New_To when expanding pragmas and appending code to possibly empty lists of statements. This is equivalent to checking it the list exists, allocating a new list if necessary, and appending to it. Code cleanup only related to implementation of aspect Subprogram_Variant, which is simila

[Ada] AI12-0307: uniform resolution rules for aggregates

2020-10-22 Thread Pierre-Marie de Rodat
The resolution rules for container aggregates can lead to ambiguities when homonym subprograms have a formal of a composite type, and the actual in a call is an aggregate. This patch adds an indication that this aggregate should be qualified to remove the ambiguity. Tested on x86_64-pc-linux-gnu,

[Ada] Implement AI12-0030: Stream attribute availability

2020-10-22 Thread Pierre-Marie de Rodat
An attempt to reference a streaming attribute of a type that has no corresponding attribute definition is typically rejected at compile time. For example, if a task type T lacks a user-defined Read attribute, then a reference to T'Read is illegal. However, obscure ways to bypass these legality rul

[Ada] Get rid of useless if-then-else in Exp_Fixd.Fpt_Value

2020-10-22 Thread Pierre-Marie de Rodat
The two arms of the conditional construct have been the same for 25 years. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_fixd.adb (Fpt_Value): Fold if-then-else with identical arms.diff --git a/gcc/ada/exp_fixd.adb b/gcc/ada/exp_fixd.adb --- a/gcc/ada/exp_fixd.adb +++

[Ada] Fix parser not detecting casing issues in keywords

2020-10-22 Thread Pierre-Marie de Rodat
Casing issues are not detected when using `-gnaty` if the keyword does not start with a capital letter. This is fixed by checking if any letter in the keywoard is uppercase. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * scng.adb (Scan): Check if any letter of the token is

[Ada] Adjust documentation for Has_Constrained_Partial_View flag

2020-10-22 Thread Pierre-Marie de Rodat
This documents that the Has_Constrained_Partial_View flag now explicitly applies to the base type only. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads (Has_Constrained_Partial_View): Add "base type" marker.diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads --- a/g

[Ada] Implement AI12-0280's interactions with container aggregates

2020-10-22 Thread Pierre-Marie de Rodat
AI12-0280 has already been mostly implemented, but some interactions with container aggregates were not initially implemented. In particular, RM 6.1.1's mention of "the expression of a container_element_association" in the definition of the term "repeatedly evaluated" needs to be reflected in the

[Ada] AI12-0095 Formal types and Constrained Partial Views

2020-10-22 Thread Pierre-Marie de Rodat
AI12-0095 is a binding interpretation that revises the RM to have a general rule about how generic formal discriminated types are considered to have a constrained partial view within generic bodies, rather than just have this rule appear in the sections of the RM on Access attributes and type conve

[Ada] Ada_2020 AI12-0250: Iterator filters in Iterated_Element_Assocations

2020-10-22 Thread Pierre-Marie de Rodat
Iterator filters can appear in loop parameter specifications and in iterator specifications, and thus in Iterated_Element_Awsociations in container aggregates. This patch extend the parsing and expansion of Iterated associations, to better distinguish the Ada_2020 construct from the Ada_2012 Iterat

[Ada] CUDA: discover runtime types instead of hard-coding

2020-10-22 Thread Pierre-Marie de Rodat
The CUDA bindings change very frequently, sometimes changing the underlying representation of types. In order to reduce the amount of work needed in the compiler on each CUDA update, we make GNAT infer the types it needs instead of hard-coding them. Tested on x86_64-pc-linux-gnu, committed on trun

[Ada] Reimplementation of accessibility checking

2020-10-22 Thread Pierre-Marie de Rodat
This patch removes much of the logic relating to static and dynamic accessibility level checks and replaces it with a simplified and centralized implementation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Apply_Accessibility_Check): Modify condition to

[Ada] Update the head comment of Check_Compile_Time_Size

2020-10-22 Thread Pierre-Marie de Rodat
In order to reflect that the size limit is System_Max_Integer_Size now. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.ads (Check_Compile_Time_Size): Adjust size limit.diff --git a/gcc/ada/freeze.ads b/gcc/ada/freeze.ads --- a/gcc/ada/freeze.ads +++ b/gcc/ada/freeze.

[Ada] Build support units for 128-bit integer types on 64-bit platforms

2020-10-22 Thread Pierre-Marie de Rodat
This enables the build of the support units for 128-bit integer types in the full runtime of 64-bit platforms. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (64-bit platforms): Add GNATRTL_128BIT_PAIRS to the LIBGNAT_TARGET_PAIRS list and also GNATRTL_

[Ada] Wrong accessibility for conversion to named access

2020-10-22 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby the accessibility level for explicit type conversions from an anonymous access object to a named access type led to spurious runtime accessibility errors. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Accessib

[Ada] AI12-0211: Consistency of inherited nonoverridable aspects

2020-10-22 Thread Pierre-Marie de Rodat
AI12-0211 introduces two new legality rules. The first says that if a nonoverridable aspect is explicitly specified for a type which also inherits that aspect from another type (an ancestor or a progenitor), then the explicit aspect specification shall be confirming. The second says that if a type

[Ada] Enable the support of 128-bit integer types by default

2020-10-22 Thread Pierre-Marie de Rodat
This enables the support of 128-bit integer types by default on 64-bit platforms (except for BB ports): the -gnate128 switch is removed and the debug switch -gnatd.H can now be used to disable again the support. Technically speaking, apart from the obvious effect on integer types, this will bump t

[Ada] Update header of front-end files

2020-10-23 Thread Pierre-Marie de Rodat
Some Ada front-end files had a runtime license exception header, which is not needed since these files are pure compiler (tool) files, and not runtime files. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * alloc.ads, aspects.adb, aspects.ads, atree.adb, atree.ads, ca

[Ada] Sync code for external properties with SPARK RM

2020-10-23 Thread Pierre-Marie de Rodat
Originally the allowed combinations of external properties (i.e. Async_Readers, Async_Writers, Effective_Writes and Effective_Reads) were described in the SPARK RM as a sequence of conditions. Then they have been rewritten as a table and now the correspondence between description in the SPARK RM an

[Ada] Fix default value for re-analysis of external property pragmas

2020-10-23 Thread Pierre-Marie de Rodat
Routine Analyze_External_Property_In_Decl_Part, which deals with pragmas Async_Readers, Async_Writers, Effective_Reads, Effective_Writes, returned early when the pragma has been already analyzed. When this happened, its output parameter Expr_Val was set to False no matter what the pragma argument w

[Ada] Always enable the support for 128-bit integer types on 64-bit platforms

2020-10-23 Thread Pierre-Marie de Rodat
This lifts the condition of the presence of s-arit128.ads in order to enable the support for 128-bit integer types on 64-bit platforms, the rationale being that this mirrors the support for 64-bit integer types on 32-bit platforms, which is always enabled. Tested on x86_64-pc-linux-gnu, committed

[Ada] Prevent copying uninitialized array with address clause

2020-10-23 Thread Pierre-Marie de Rodat
An object of a nominal unconstrained array type may be given a subtype by initialization with an aggregate with specified bounds and box initialization. The freezing of the object copies the aggregate into the object, which propagates uninitialized values if the component type has no default specif

[Ada] Iterative patch for accessibility cleanup

2020-10-23 Thread Pierre-Marie de Rodat
This patch fixes a "comes from source" calculation needed for determining the innermost master scope depth. Also, this patch fixes issues calculating accessibility for function calls which initialize objects in their entirety. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ *

[Ada] Spurious errors on tagged types with renamed subprograms

2020-10-23 Thread Pierre-Marie de Rodat
When a tagged type erroneusly defines primitives by means of renaming subprograms that require overriding, the compiler properly reports the error; however, it also reports bogus errors indicating that the renaming declaration must be overridden. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Crash on expression function and access type

2020-10-23 Thread Pierre-Marie de Rodat
This patch fixes a compiler abort on an expression function that is a completion, when the expression includes function calls and dereferences and the result is an access type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Type_Refs): Add guard on freezi

[Ada] CUDA: fix CUDA_Execute not working with aggregates

2020-10-23 Thread Pierre-Marie de Rodat
When expanding pragma CUDA_Execute, the compiler declares temporary variables to capture the value of the pragma's arguments. These declarations's type is inferred from the pragma's arguments type, because said arguments could be integers of CUDA.Vector_Types.Dim3s. Inferring the type of these dec

[Ada] CUDA: Use internal types instead of public ones

2020-10-23 Thread Pierre-Marie de Rodat
The previous version of the CUDA bindings had a C_Pass_By_Copy convention on its definition of the Dim3 type. The new version doesn't. This change causes ABI issues in generated binaries. In order to avoid needing changes in the compiler every time the public bindings are updated, a new Dim3 type

[Ada] Better error for illegal call to abstract operation in instantiations

2020-10-23 Thread Pierre-Marie de Rodat
In cases involving instantiations and formal packages, a call to an abstract nondispatching subprogram within an instantiation, where the operation comes in via the actual for a formal package, was not being flagged with an informative message on the instantiation. (A program could potentially comp

[Ada] Fix scope of index parameter inside a delta aggregate

2020-10-23 Thread Pierre-Marie de Rodat
When resolving iterated_component_association that occurs within delta_aggregate, we create an implicit loop which should act as a scope for the index parameter entity. However, the name of this entity was entered before pushing the scope of the implicit loop, so the index parameter was visible out

[Ada] Fix crash in SPARK on array delta_aggregate with subtype_indication

2020-10-23 Thread Pierre-Marie de Rodat
Expansion of array delta_aggregate in GNATprove mode needs handled ranges and expressions (including type identifiers), but not subtype_indications (e.g. "A with delta Integer range 1 .. 10 => 0"). Also, call Apply_Scalar_Range_Check didn't seem necessary for ranges and likewise it makes no differ

[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/

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