[Ada] Implement expansion of CUDA_Execute pragma

2020-10-16 Thread Pierre-Marie de Rodat
This commit implements expansion of the CUDA_Execute pragma. CUDA_Execute must result in multiple calls to the runtime API: calls to the hidden functions CUDA.Push_Call_Configuration and CUDA.Pop_Call_Configuration but also to CUDA.Launch_Kernel. Calling these functions requires putting arguments o

[Ada] AI12-0170: Abstract subprogram calls in class-wide precond exprs

2020-10-19 Thread Pierre-Marie de Rodat
As specified in AI12-0170, calls to abstract subprograms within pre- and postcondition expressions of an abstract subprogram of type T are allowed in some cases, and references to a formal parameter of the controlling type are reinterpreted as though they had a (notional) nonabstract type NT that i

[Ada] Crash in expression function defined in protected object

2020-10-19 Thread Pierre-Marie de Rodat
The frontend crashes processing an expression function defined in the body of protected type that depends on discriminants. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Find_Direct_Name): Do not trust in the decoration of the Entity attribute in const

[Ada] Refine type of a local variable

2020-10-19 Thread Pierre-Marie de Rodat
Formal parameters, while iterated with First_Formal/Next_Formal, are entities and not just nodes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Is_Direct_Deep_Call): Refine type from Node_Id to Entity_Id.diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_c

[Ada] Clarify current design of Errout wrt global variable usage

2020-10-19 Thread Pierre-Marie de Rodat
Current design of Errout mandates that the global variables defining its input state for issuing messages is restored when needed by multiple successive calls. This is surprising, and deserves proper documenting. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.ads: Ad

[Ada] Clarify protection offered by preconditions on Ada.Text_IO units

2020-10-19 Thread Pierre-Marie de Rodat
These preconditions are used in particular for analysis by SPARK tools. It is thus important that they precisely convey which errors they allow detecting, in callers of Ada.Text_IO. Here, Layout_Error cannot be detected in a number of cases. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/a

[Ada] Remove useless initialization and refine type of a local variable

2020-10-19 Thread Pierre-Marie de Rodat
A local variable Param_Count is only accessed after being initialized to 1 and then is only incremented, so it only takes positive values. There is no complex control flow involved, so code checkers like CodePeer should have no trouble with the new code. Semantics is unaffected. Tested on x86_64-

[Ada] Private type unexpectedly visible

2020-10-19 Thread Pierre-Marie de Rodat
The frontend erroneously allows referencing a subtype declaration of a private type defined in the private part of a package. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch7.adb (Uninstall_Declarations): Uninstall the declaration of a subtype declaration defi

[Ada] Clean up support of square brackets

2020-10-19 Thread Pierre-Marie de Rodat
We cannot support at the same time [] aggregate notation and the [""] wide character notation, and there's no agreement yet on the proper syntax for [] aggregates, so resolve this temporarily by supporting only [] as an aggregate under -gnatX and only the wide chars legacy notation otherwise.

[Ada] Implement initialization of CUDA runtime

2020-10-19 Thread Pierre-Marie de Rodat
Executing CUDA kernels requires registering the kernel with the CUDA runtime beforehand. This is achieved by keeping track of procedures marked with CUDA_Global when analyzing packages and then registering each of the procedures with a fat binary created by the CUDA toolchain. Tested on x86_64-pc-

[Ada] No range check on fixed point to integer conversion

2020-10-19 Thread Pierre-Marie de Rodat
In some cases, range checks are missing when converting fixed point values to integer. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Apply_Type_Conversion_Checks): Minor code clean up. * exp_ch4.adb (Discrete_Range_Check): Optimize range checks.

[Ada] Compiler abort on in_out function parameter with type invariant

2020-10-19 Thread Pierre-Marie de Rodat
Compiler crashes on a function call when function profile includes an in_out parameter, the parameter type has an inherited type invariant, and the actual is a view conversion to an ancestor type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Add_View_Conversi

[Ada] Do not replace bounds for packed arrays that depend on discriminants

2020-10-19 Thread Pierre-Marie de Rodat
When generating constraint checks for types whose size depend on a discriminant, the frontend would generate a reference to the discriminant. This would result in a crash as the backend actually needs a reference to the object itself. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Reject use of Relaxed_Initialization on scalar/access param or result

2020-10-19 Thread Pierre-Marie de Rodat
The rules for Relaxed_Initialization have been tightened in SPARK RM, to reject meaningless uses. This is implemented here. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): Fix bug where a call to Error_Msg_N leads

[Ada] Remove excessive guards in building predicate functions

2020-10-19 Thread Pierre-Marie de Rodat
When calling routine Add_Call, which extends the type predicate function with a call to its ancestor's type predicate function, we checked that the ancestor type is present twice: in the Add_Call itself and at its only call site. Also, when the ancestor type has a predicate function, this routine

[Ada] Use alternate stack for signal handling on PowerPC/Linux

2020-10-19 Thread Pierre-Marie de Rodat
This is necessary because the stack checking method has been changed on this platform and now requires an alternate stack to propagate the stack overflow exception. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (PowerPC/Linux): Use s-taspri__posix.ads instead

[Ada] Ada2020: matching parentheses and brackets

2020-10-19 Thread Pierre-Marie de Rodat
This patch fixes a bug where the compiler allowed mismatched brackets and parentheses in aggregates in -gnatX mode, as in (...] and [...). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch4.adb (P_Aggregate_Or_Paren_Expr): Require matching parens or brackets.

[Ada] Ada2020: AI12-0304 Put_Image attrs of lang-def types

2020-10-19 Thread Pierre-Marie de Rodat
This patch implements AI12-0304. In particular, Put_Image (and therefore 'Image) is provided for the containers and for unbounded strings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_put_image.adb (Build_Elementary_Put_Image_Call): Use the base type to recogn

[Ada] AI12-0352: Early derivation and equality of untagged types

2020-10-19 Thread Pierre-Marie de Rodat
This AI clarifies that declaring a user-defined primitive equality operation for a record type T is illegal if it occurs after a type has been derived from T. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Check_Untagged_Equality): Check for AI12-0352.diff --gi

[Ada] ACATS 4.1R - Exception missed

2020-10-19 Thread Pierre-Marie de Rodat
This new ACATS test shows that we are not taking the subtype constraint into account when a Default_Value (via a box notation) is used in an aggregate, e.g: B_Rec : Bad_Rec := (Cnt => <>); Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Record_Aggregate

[Ada] Ada2020: AI12-0304 Put_Image attrs of lang-def types

2020-10-19 Thread Pierre-Marie de Rodat
More work on this AI. Replace the Put_Image procedures in Ada.Containers.Indefinite_Vectors and Indefinite_Doubly_Linked_Lists with versions that call procedure Iterate, rather than using a "for ... of" loop, because the "for ... of" loop causes regressions. Tested on x86_64-pc-linux-gnu, committe

[Ada] Expanded names in ghost assignments

2020-10-19 Thread Pierre-Marie de Rodat
If the left-hand side of an assignment statement denotes a ghost entity, then the assignment statement is a ghost assignment. This patch fixes a bug in which ghost assignments were not recognized in some cases. In particular, for an assignment of the form "P.R.C := ...;", where P is a nonghost pack

[Ada] Missing check on array concatenation

2020-10-19 Thread Pierre-Marie de Rodat
The expansion of array concatenation disables checks too much, so reenable checks that are needed on the relevant internal subtype declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_Concatenate): Enable needed range checks.diff --git a/gcc/ada/e

[Ada] Alternative display of multi-line messages for GNATprove

2020-10-19 Thread Pierre-Marie de Rodat
GNATprove now supports better display of multi-line messages on the command-line, where additional information for a given check is issued on separate lines that are clearly associated to the main message, both by prefixing such lines with space characters, and by separating a block of lines corres

[Ada] Ada_2020: Implement Key_Expression for named container aggregates

2020-10-19 Thread Pierre-Marie de Rodat
This patch implements the Key_Expression mechanism for container aggregates. A Key_Expression specifies a mapping between the loop variable in an iterated element association, and the value of the key to be used for insertion of successive components into the container being populated. The parser c

[Ada] Display source code pointing at locations in messages for GNATprove

2020-10-20 Thread Pierre-Marie de Rodat
In GNATprove, output of messages is adapted (under debug switch -gnatdF) so that both for the location of messages, and extra locations appearing as line insertion in continuation messages, the corresponding line of source code is displayed. For example: incr.adb:3:11: medium: overflow check might

[Ada] Ada_2020: Further code cleanup for container aggregates

2020-10-20 Thread Pierre-Marie de Rodat
This patch corrects a potential use of an uninitialized variable uncovered by CodePeer in Expand_Iterated_Component, and removes some code duplication. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Expand_Iterated_Component): Reorganize code to ensure

[Ada] Support for new aspect Subprogram_Variant on recursive subprograms

2020-10-20 Thread Pierre-Marie de Rodat
This patch introduces a new aspect "Subprogram_Variant" with expressions that are meant to increase/decrease with each recursive call of the annotated subprogram. It is inspired by the existing pragma Loop_Variant, whose expressions are meant to increase/decrease with each iteration of the loop. Bo

[Ada] Crash on precondition, discriminant and protected objects

2020-10-20 Thread Pierre-Marie de Rodat
This combination led to a hole in function Is_Prologue_Renaming, causing the generation of precondition checks too early. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * contracts.adb (Is_Prologue_Renaming): This function was missing support for E_Constant which can

[Ada] Flexible AST node structure

2020-10-20 Thread Pierre-Marie de Rodat
This patch is preliminary work in preparation for changing the node structure so that nodes and entities can be of different sizes depending on the Node_Kind or Entity_Kind. This is cleanup/simplification combined with efficiency improvements. We rearrange the subranges of the various union types

[Ada] Propagate predicate function to a full view of a private subtype

2020-10-20 Thread Pierre-Marie de Rodat
When the ancestor in subtype declaration is a private type, routine Analyze_Subtype_Declaration creates private and full view, but only the private view had Predicate_Function inherited from the ancestor. Now also the full view has Predicate_Function inherited. This doesn't appear to affect compil

[Ada] Remove extra validity check in case statement

2020-10-20 Thread Pierre-Marie de Rodat
Recognize code of the form: if X'Valid then case X is [...] and suppress the redundant validity check on X done as part of the case statement. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch5.adb (Expand_N_Case_Statement): Do not generate validity c

[Ada] Fix internal error on bit-aligned component of function call

2020-10-20 Thread Pierre-Marie de Rodat
This fixes an internal error in the code generator triggered by a reference generated by the front-end to a bit-aligned component of the result of a function call. Such a reference cannot be handled by the code generator because the object is not aligned on a byte boundary, so it is replaced by a

[Ada] Spurious discriminant check on "for of" loop

2020-10-20 Thread Pierre-Marie de Rodat
When using a "for ... of" loop with an element of a record type with defaulted discriminants, a spurious disciminant check is emitted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Check_Constrained_Object): Suppress discriminant checks when the type h

[Ada] Inlining nonstatic calls to static expression functions

2020-10-20 Thread Pierre-Marie de Rodat
Static expression functions were already effectively inlined in the case of calls to them with static arguments, but calls with nonstatic arguments were not generally being inlined, but now they are, as a result of setting the Has_Pragma_Inline and Is_Inlined flags on such functions. It appears tha

[Ada] New warning on not fully initialized box aggregate

2020-10-20 Thread Pierre-Marie de Rodat
This new warning detect cases of aggregates of the form (others => <>) where the type doesn't have full default values for all its components. Refine handling of -gnatwv by not warning when an object of a type with partial initialization is declared (and used): this generates a better ratio of use

[Ada] Fixes for pretty command-line GNATprove output with -gnatdF

2020-10-20 Thread Pierre-Marie de Rodat
Various fixes are applied to the recent pretty output mode for GNATprove, activated under debug switch -gnatdF: - do not separate info messages from previous ones - do not display souce code line for info messages - display source code lines closer to the format adopted in GCC - do not set the exit

[Ada] Crash on cond expression as actual for anonymous access formal

2020-10-20 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby a conditional expression used as an actual for an anonymous access formal when the condition is known at compile time triggers a crash during compilation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_Branc

[Ada] Make attribute Update an obsolescent feature

2020-10-20 Thread Pierre-Marie de Rodat
In the new version of Ada, GNAT specific 'Update atttribute is replaced by delta aggregates. Add a warning on occurrences of 'Update. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Analyze_Attribute): Emit a warning on 'Update when Warn_On_Obsolescent_

[Ada] gnatpp: Fix documentation of threshold switches

2020-10-20 Thread Pierre-Marie de Rodat
The gnatpp switches --call-threshold and --par-threshold were documented with "_" instead of "-" (as in "--par_threshold"). It does accept that form, but for consistency, the documentation is changed to "-". Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/gnat_

[Ada] Issue with gnatbind -V switch and Ada 2012

2020-10-20 Thread Pierre-Marie de Rodat
When compiling the binder generated file in Ada 2012 mode and using the gnatbind -V switch, invalid characters are flagged. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * bindgen.adb (Gen_Bind_Env_String): Generate Ada 2012 compatible strings. Code cleanup.diff --gi

[Ada] Refine result type of Get_Accessibility

2020-10-20 Thread Pierre-Marie de Rodat
Routine Get_Accessibility returns either the result of Minimum_Accessibility or Extra_Accessibility functions, both of which return Entity_Id, so Get_Accessibility should return Entity_Id as well, not just Node_Id. Cleanup only; behavior is not affected. Tested on x86_64-pc-linux-gnu, committed o

[Ada] Hang on cond expression as actual for anonymous access formal

2020-10-20 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby a conditional expression used as an actual for an anonymous access formal when the condition is known at compile time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_Call_Helper): Properly handle the case

[Ada] Implement AI12-0280 Making 'Old more flexible

2020-10-20 Thread Pierre-Marie de Rodat
AI12-0280 relaxes the "potentially unevaluated" restrictions on the use of the Old attribute in postconditions. A complex attribute prefix is allowed in cases that were previously forbidden if the conditions governing whether the attribute value will be needed during evaluation of the postcondition

[Ada] Prevent crashes when pretty-printing freeze nodes from gdb

2020-10-20 Thread Pierre-Marie de Rodat
With recently enabled data validity checking in development builds routine "ps", when called from gdb to examine the AST, might crash on invalid data. This is because its Sprint_Node_Actual callee reads Dump_Freeze_Null global variable when processing nodes of N_Freeze_Entity and this global varia

[Ada] AI12-0339: Empty function for Aggregate aspect of Ada containers

2020-10-20 Thread Pierre-Marie de Rodat
The specification of the aspect Aggregate includes a primitive operation Empty that returns the initial value to be used when building an aggregate for the corresponding composite type. For bounded containers, the function Empty includes an explicit parameter that corresponds to the discriminant of

[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

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