[Ada] Add expected and actual size to "bit number out of range" error message

2020-07-08 Thread Pierre-Marie de Rodat
This commit lets users know what the expected and actual size are when conflicting representation clauses are present. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Analyze_Record_Representation_Clause, Check_Record_Representation_Clause): Add expecte

[Ada] Fix incorrect placement of freeze node with predicate

2020-07-08 Thread Pierre-Marie de Rodat
This prevents the freezing mechanism from putting a node inside the subprogram body generated for a predicate function, which can for example happen for a function referenced in the predicate. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (In_Expanded_Body): Ret

[Ada] Ada_2020 AI12-0250 : Implement Iterator filters.

2020-07-08 Thread Pierre-Marie de Rodat
Iterator filters can appear in loop parameter specifications and in iterator specifications, and determine which elements of some domain of iteration are to be used in a loop, aggregate ,or quantified expression. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par.adb (P_Ite

[Ada] Static expression function problems with -gnatc and -gnatd.F (SPARK mode)

2020-07-08 Thread Pierre-Marie de Rodat
The implementation of static expression functions exhibited various problems when compiling with the switches -gnatd.F (SPARK mode) or -gnatc. Use of those switches could lead to errors on legal calls to static expression functions (such as the calls being flagged as not static), plus the compiler

[Ada] Accept aspect Relaxed_Initialization on generic subprograms

2020-07-08 Thread Pierre-Marie de Rodat
Aspect Relaxed_Initialization has been prototyped for ordinary subprograms and then SPARK RM 6.10 allowed it for generic subprograms as well. This is mostly straightforward to implement, except when 'Result appears in the aspect expression for a generic function. When instantiated in a wrapper pac

[Ada] Update entities on class-wide condition function creation

2020-07-08 Thread Pierre-Marie de Rodat
Problem: Expression functions that have class-wide pre/post conditions which call functions that are themselves expression functions refer to entities from a specification that isn't theirs. Solution: When creating the class-wide clone of the function that has the class-wide condition, update its

[Ada] Analyze aspects once generic subprograms are recognized

2020-07-08 Thread Pierre-Marie de Rodat
When analysing aspect Yield we were adding a minimum decoration to the annotated entity by setting its kind to E_Function/E_Procedure. This kind was then correctly reset to E_Generic_Function/E_Generic_Procedure after all aspects has been analysed. It seems cleaner to set this kind once and correc

[Ada] Add comment on implementation choice for byte-packed array types

2020-07-08 Thread Pierre-Marie de Rodat
This documents the implementation choice made for byte-packed array types, where we let the code generator deal with them if the type is composite and use the manipulation routines of the front-end if the type is discrete. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * free

[Ada] Clean up in Interfaces.C.Extensions

2020-07-08 Thread Pierre-Marie de Rodat
Now that Interfaces.C also defined long_long and unsigned_long_long, make definitions in Interfaces.C.Extensions subtypes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/i-cexten.ads (long_long, unsigned_long_long): Now subtypes of Interfaces.C types.

[Ada] Fix internal error on string type comparision with predicate

2020-07-08 Thread Pierre-Marie de Rodat
This freezing issue shows that Freeze_Expression does not fully control the placement of freeze nodes produced by an expression coming from the Actions list of various constructs, here an N_And_Then node, because it does not check whether the entity being frozen, for example a type, is really decla

[Ada] Fix warnings in C runtime files on Windows

2020-07-08 Thread Pierre-Marie de Rodat
They are mostly warnings on unused parameters, useless variables, casts between integer and pointers of different size, or missing or incorrect prototypes. There is also an improper checking of a return value. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.h (__gnat

[Ada] Disable warning about unsafe use of __builtin_frame_address

2020-07-08 Thread Pierre-Marie de Rodat
This disables the warning that is given by the C compiler when it is compiling the generic implementation of the backtrace facility used on some platforms. This happens when a positive frame level is requested, which can be problematic in the general case. But this implementation is known to work

[Ada] Do not apply constraint checks on allocator with No_Initialization

2020-07-08 Thread Pierre-Marie de Rodat
For an allocator in the subtype mark case, the constraints of the subtype must be checked against the designated subtype, except in the case where the No_Initialization flag is set on the allocator node. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_A

[Ada] Fix C miss parentheses warning on Windows

2020-07-08 Thread Pierre-Marie de Rodat
The C compiler switch -Wparentheses causes the warning suggest parentheses around '&&' within '||'. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * socket.c [_WIN32] (__gnat_minus_500ms): Parentheses around && operations. Remove notes about TN in comment.diff --git

[Ada] Fix crash on quantified expression in expression function (2)

2020-07-10 Thread Pierre-Marie de Rodat
This just replaces Find_Aspect with Find_Value_Of_Aspect, which seems to be the preferred idiom to retrieve the value of an aspect. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Expr_Types): Replace call to Find_Aspect with call to Find_Value_Of_

[Ada] Fix crash on quantified expression in expression function

2020-07-10 Thread Pierre-Marie de Rodat
The problem is that the compiler freezes the iterator type associated with a given type in the body of an expression function that contains a quantified expression for this type and happens to be the completion of a previous declaration. The reason is that Freeze_Expr_Types does not see that the

[Ada] Make System.Generic_Bignums more flexible

2020-07-10 Thread Pierre-Marie de Rodat
Reorganize the code and add new generic parameters so that this unit can be reused in more contexts and in particular provide support for bounded large integers without needing any dynamic memory allocation nor secondary stack. Move the implementation of To_String to System.Generic_Bignums to allo

[Ada] Add global contracts to Ada.Numerics.Big_Numbers libraries

2020-07-10 Thread Pierre-Marie de Rodat
This patch adds global contracts to functions from Ada.Numerics.Big_Numbers.Big_Integers and Ada.Numerics.Big_Numbers.Big_Reals. This removes the warnings returned when using these functions in SPARK. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-nbnbin.ads, libg

[Ada] Spurious error in generic dispatching constructor call

2020-07-10 Thread Pierre-Marie de Rodat
Given two interface types Ifc0 and Ifc1 where Ifc1 is a descendant of Ifc0, the frontend reports a spurious error handling a call to a Generic_Dispatching_Constructor instance that occurs as the operand of a qualified expression initializing an allocator where Ifc1'Class is the subtype_mark of the

[Ada] Part of implementation of AI12-0212: container aggregates

2020-07-10 Thread Pierre-Marie de Rodat
This is ongoing work for the implementation of Ada 2020 generalized aggregates for containers. The patch includes the infrastructure to support the new aspect and related subprograms, and implements the functionality of positional aggregates for set-like containers. Still to come: a) resolution a

[Ada] Fix internal error on if-expression in call returning tagged type

2020-07-10 Thread Pierre-Marie de Rodat
This removes the left-overs of an expansion done in Expand_Call_Helper in order to pass the correct accessibility level to the callee when the actual is an if-expression of an access type. The expansion uses a dummy temporary to analyze the outermost Expression_With_Actions it makes and removes it

[Ada] Cleanup excessive conditions in Check_Completion

2020-07-10 Thread Pierre-Marie de Rodat
In routine Check_Completion once the entity kind is determined, it is enough to look if the required completion is provided. However, those two tests were combined, so we were processing the entity several times, which was inelegant and inefficient. Tested on x86_64-pc-linux-gnu, committed on trun

[Ada] Small cleanup throughout Exp_Ch4

2020-07-10 Thread Pierre-Marie de Rodat
This replaces calls to Esize or RM_Size for standard integer types with their value, uses Standard_Long_Long_Unsigned directly in one case and Standard_Long_Long_Integer in another case, and changes the recently added Narrow_Large_Operation to use Uint instead of Nat for sizes. No functional chang

[Ada] Use small limit for aggregates inside subprograms

2020-07-10 Thread Pierre-Marie de Rodat
We want to favor large static aggregate at library level, but within subprograms, we want to favor loops instead when relevant. As part of this work we uncovered a missing freeze on allocator subtype marks showing up with this change, as well as the need to generate predicate checks within init pr

[Ada] Fix detection of volatile properties in SPARK

2020-07-10 Thread Pierre-Marie de Rodat
Now that volatile properties can be set on types, objects other than variable may have fine-grain volatile properties inherited through their type. This is now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Has_Enabled_Property): Add handling of

[Ada] Reuse SPARK expansion of attribute Update for delta_aggregate

2020-07-10 Thread Pierre-Marie de Rodat
For GNATprove we have a special expansion of attribute Update. It is now refactored it into a dedicated routine and reused for delta_aggregate. For attribute Update the behaviour is as it was; for delta_aggregate we now decorate the AST with range checks flags that were previously missing. Tested

[Ada] Fix failing assertions related to volatile objects

2020-07-10 Thread Pierre-Marie de Rodat
Comments for routines No_Caching_Enabled and Is_Effectively_Volatile, which are both related to volatile objects, were not enforced with assertions. As a result, we had failing assertions much deeper in the call tree, far from where the problems occur. This patch adds both the missing assertions an

[Ada] Revert too late setting of Ekind on discriminants

2020-07-10 Thread Pierre-Marie de Rodat
A recent patch enforced an existing comment in Is_Effectively_Volatile with an assertion. To satisfy this assertion, it also set the Ekind on discriminants earlier. However, a subtle prevention of cascaded errors in routine Enter_Name relies on the Ekind of discriminants being set late. This patch

[Ada] Fix expansion of 'Update with multiple choices in GNATprove

2020-07-10 Thread Pierre-Marie de Rodat
GNAT expands attribute Update applied to a record component into a sequence of assignments to a temporary object and applies range checks when analysing those assignment. GNATprove keeps such an aggregate unexpanded, so it misses range checks, especially when several components of a different type

[Ada] Further improve the expansion of array aggregates

2020-07-10 Thread Pierre-Marie de Rodat
First, this change extends the memset optimization to the case of array aggregates nested in other aggregates, when the outer aggregates are expanded component-wise; second, it prevents the compiler from duplicating allocators and other nonstatic constructs present in an Others choice of array aggr

[Ada] Fix detection of actual parameters for procedure calls

2020-07-10 Thread Pierre-Marie de Rodat
Routine Is_Actual_Parameter, which deals with cross-references and pragma Unreferenced, for a procedure call like this: P (A); was wrongly returning True for both the identifiers P and A above, on the grounds that both have N_Procedure_Call_Statement as their parent. Now it only returns True f

[Ada] Remove references to non-existing E_Protected_Object

2020-07-10 Thread Pierre-Marie de Rodat
Nowhere in the code we call set Ekind to E_Protected_Object, so all the code that tests this is necessarily dead. This patch removes references to E_Protected_Object. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads (E_Protected_Object): Enumeration literal removed.

[Ada] Add warning for overlays changing scalar storage order

2020-07-10 Thread Pierre-Marie de Rodat
This makes the compiler issue an unconditional warning for an overlay that changes the scalar storage order, i.e. for an address clause when the overlaid and the underlying objects are of array or record types that have opposite scalar storage order. The reason is that the code generator does not

[Ada] Ada2020: AI12-0368 Declare expressions can be static

2020-07-10 Thread Pierre-Marie de Rodat
This patch implements AI12-0368, which allows declare expressions to be static. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Expression_With_Actions): Check the rules of AI12-0368, and mark the declare expression as static or known at

[Ada] Revert mistaken negation related to references to labels

2020-07-10 Thread Pierre-Marie de Rodat
Commit titled "Update handling of assigned value/unreferenced warnings" added a comment "... *unless* this is an actual parameter" and at the same time removed a "not" operator from the corresponding condition. This is now reverted to match both the previous code and the current comment. Tested on

[Ada] Spurious error on parameterless acccess_to_subprogram

2020-07-10 Thread Pierre-Marie de Rodat
Compiler rejects an indirect call through an Access_To_Subprogram value that denotes a parameterless subprogram, when the corresponding access type has a pre- or postcondition. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_Access_Subprogram_Wrapper_Body)

[Ada] Preserve casing of output files

2020-07-10 Thread Pierre-Marie de Rodat
Windows is case insensitive but also case preserving, so we don't want to generate a file in lower case if the input file wasn't. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * osint-c.adb (Set_File_Name): Preserve casing of file. * osint.adb (File_Names_Equal): New

[Ada] Potentially unevaluated nested expressions

2020-07-10 Thread Pierre-Marie de Rodat
This patch fixes the general problem in the detection of potentially unevaluated nested expressions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Immediate_Context_Implies_Is_Potentially_Unevaluated): New subprogram. (Is_Potentially_U

[Ada] Ongoing work for unnamed and named container aggregates

2020-07-15 Thread Pierre-Marie de Rodat
This implements additional functionality for the Ada 202x container aggregates, in particular the use of iterated_component_association in both Unnamed (positional) and Named (keyed) aggregates for types for which the Aspect Aggregate is defined. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Cleanup condition for an effectively volatile array type

2020-07-15 Thread Pierre-Marie de Rodat
When we detect effectively volatile array type we only need to examine the type of array component if the array itself has no Has_Volatile_Components property. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Atomic_Components): Simplify with Ekind_In. (

[Ada] Use Sloc of delay statement in timed entry call

2020-07-15 Thread Pierre-Marie de Rodat
This changes the Sloc used to expand a timed entry call from that of the Select to that of the Delay statement for coverage purposes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch9.adb (Expand_N_Timed_Entry_Call): Use the Sloc of the delay statement in the e

[Ada] Do not generate extra copies inside initialization procedures

2020-07-15 Thread Pierre-Marie de Rodat
The RM C.6(19) clause says that atomic or volatile objects of types that are not by reference must be passed by copy in a call if the type of the formal is not atomic or volatile respectively. But this requirement does not apply to initialization procedures, which are generated by the compiler, an

[Ada] Fix oversight in Delayed_Aspect_Present predicate

2020-07-15 Thread Pierre-Marie de Rodat
The predicate returns true only if an aspect requiring delaying like Alignment or Address is the first aspect in the list. The change also contains a small consistency fix for Freeze_Object_Declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Delayed_As

[Ada] Extend static functions

2020-07-15 Thread Pierre-Marie de Rodat
This patch extends static functions and allow them on Intrinsic imported subprograms in addition to expression functions, under -gnatX. We also implement compile time evaluation of Shift_Left/Right operators as a first set of useful static-compatible intrinsics. Tested on x86_64-pc-linux-gnu, com

[Ada] Assert failure with -gnatwr

2020-07-15 Thread Pierre-Marie de Rodat
In a case of a complex precondition expression with quantifiers, we can get a crash in Resolve_Type_Conversion when trying to emit a -gnatwr warning. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Type_Conversion): Protect against null entity.

[Ada] ACATS 4.1P [BDB4001] - 13.11.4(22-23/3) not enforced

2020-07-15 Thread Pierre-Marie de Rodat
This ACATS test shows GNAT was not enforcing legality rules related to subpools. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Freeze_Type): Remove warning in expander, replaced by a corresponding error in sem_ch13.adb. Replace RTE_Available by

[Ada] Small addition and tweaks in documentation on freezing

2020-07-15 Thread Pierre-Marie de Rodat
Apart from the usual editorial tweaks, this documents the discrepancy between the aspect and the non-aspect cases for alignment settings in object declarations. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads (Delayed Freezing and Elaboration): Minor tweaks.

[Ada] Spurious accessibility error on allocator

2020-07-15 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby an allocator for a limited type may cause spurious accessibility errors due to a miscalculation of access levels on interally generated temporaries. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Make_Build_In_P

[Ada] Fix slices and qualified expressions being effectively volatile

2020-07-15 Thread Pierre-Marie de Rodat
Detecting effectively volatile objects in restricted contexts happens in two routines: Is_Effectively_Volatile_Object and Is_OK_Volatile_Context. Their handling of type conversions and slices were different; also none of them has been dealing with qualified expressions, which has been just added to

[Ada] Fix for possibly null ranges in 'Update and delta_aggregate

2020-07-15 Thread Pierre-Marie de Rodat
In expression like "(Arr with delta Low .. High => New_Component_Value)" bounds Low .. High might denote a null range. In this case both Low and High can be any values from the base type of the array's index type; they don't need to belong to the array's index type itself. This patch removes unnec

[Ada] Mark standard containers as not in SPARK

2020-07-15 Thread Pierre-Marie de Rodat
Use aspect SPARK_Mode with value Off in the spec and body of standard containers, bounded and unbounded versions, so that it is clearer that they cannot be used in SPARK code. Formal containers should be used instead. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a

[Ada] Missing error on operator call

2020-07-15 Thread Pierre-Marie de Rodat
In some cases where a procedure call is expected but a function is provided such as "Interfaces.C."=" (x, y);" GNAT would not generate any error message. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Procedure_Call): Detect use of operators in

[Ada] Fix logic in Allocate_Any_Controlled

2020-07-15 Thread Pierre-Marie de Rodat
If an exception is raised early in Allocate_Any_Controlled, no lock is taken yet and Unlock is called on a lock which isn't taken. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-stposu.adb (Allocate_Any_Controlled): Fix logic in lock/unlock.diff --git a/gc

[Ada] Do not generate elaboration code for alignment aspect

2020-07-15 Thread Pierre-Marie de Rodat
This prevents the compiler from generating elaboration code for a record declared with an initial value and an alignment aspect. The expression of an alignment aspect must be static so, in practice, there is no need to defer the elaboration of the object just because of it. Tested on x86_64-pc-li

[Ada] Cleanup code related to object overlays

2020-07-15 Thread Pierre-Marie de Rodat
Cleanup frontend code before routine Find_Overlaid_Entity will be reused in GNATprove backend. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Find_Overlaid_Entity): Fix style in comment. (Note_Possible_Modification): Simplify repeated calls to Ekind.di

[Ada] Target name is an object reference

2020-07-15 Thread Pierre-Marie de Rodat
Target name (i.e. "@"), which was introduced to Ada 202X in AI12-0125, denotes a constant object (RM 3.3(21.2/5)), even though target_name itself is not an object (RM 3.3(2)). This patch allows @ to be appear as a prefix for Address attribute (which requires an object). Also, it enables constructs

[Ada] Spurious error on Predicate_Failure aspect

2020-07-15 Thread Pierre-Marie de Rodat
GNAT would in some cases not resolve a Predicate_Failure aspect properly and generate spurious errors of the form: cannot find unique type for raise expression Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Add proper

[Ada] Ongoing work for AI12-0212: container aggregates

2020-07-15 Thread Pierre-Marie de Rodat
This patch modifies the parser to recognize iterated_element_associations, which may include a key_exprewsion to be used in a named aggregate such as a map. The new syntactic node N_Iterated_Element_Association is recognized throughout the compiler. The patch also extends the analysis and expansion

[Ada] Guard against access to wrong fields in Is_Renaming

2020-07-15 Thread Pierre-Marie de Rodat
Renamed_Entity is only valid for a few entities, using it on any entity passed to Is_Renaming can result in crashes. Fixing this requires making sure that Is_Renaming only uses Renamed_Entity on entities where this is allowed and uses Is_Renaming_Of_Object everywhere else. Tested on x86_64-pc-lin

[Ada] Cleanup in Convert_To_Positional after previous work

2020-07-15 Thread Pierre-Marie de Rodat
This adjusts the description of Flatten, removes an obsolete comment and uses Compile_Time_Known_Value as now done in Is_Static_Element. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Flatten): Adjust description. (Convert_To_Po

[Ada] AI12-0373 Additional check on Integer_Literal function

2020-07-16 Thread Pierre-Marie de Rodat
Part (1) clarifies that we anticipated in Statically_Names_Object, update comment accordingly. Part 4 (4) clarifies: 4.2.1(3/5) says that the only parameter of a user-defined Integer_Literal function is of type String. But it doesn't specify a mode. Since the parameter is passed a string literal,

[Ada] Incorrect static accessibility error in return aggregate

2020-07-16 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby a local object of a named access type used as an actual for an anonymous access discriminant within a return aggregate would lead to an incorrect accessibility level calculation and thus an incorrect compile-time accessibility error on such an object.

[Ada] Do not perform null exclusion static checks on generated entities

2020-07-16 Thread Pierre-Marie de Rodat
Performing null exclusion checks on generated entities can result in bogus error messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Add Comes_From_Source call.diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb ---

[Ada] Simplify detection of others choice with just one value

2020-07-16 Thread Pierre-Marie de Rodat
Trivial cleanup with equality between universal integers, which should be much faster than subtraction. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_case.adb (Build_Choice): Simplify.diff --git a/gcc/ada/sem_case.adb b/gcc/ada/sem_case.adb ---

[Ada] Ada2020: AI12-0289 Implicitly null excluding anon access

2020-07-16 Thread Pierre-Marie de Rodat
This patch implements AI12-0289. In particular, if an untagged type T is completed with a tagged full type, and a parameter whose type is "access T", where T denotes the partial view in the subprogram spec, an explicit "not null" is required. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/

[Ada] Add centralized capacity check in Generic_Bignums

2020-07-16 Thread Pierre-Marie de Rodat
This replaces the special case done in "**" so far. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-genbig.adb ("**"): Remove capacity limit check. Improve code by using an extended return. (Normalize): Perform capacity limit check here instead whic

[Ada] Spurious accessibility error on allocator in generic instance

2020-07-16 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby an allocator for a limited type may cause spurious accessibility errors due to a miscalculation of access levels on internally generated temporaries within the instance. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4

[Ada] Spurious redundant use clause warning

2020-07-16 Thread Pierre-Marie de Rodat
The recent change in Exp_Ch3.Freeze_Type exposes a latent issue in Sem_Ch8.Note_Redundant_Use when Load_RTU triggers at the wrong time, causing spurious redundant use clause warnings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Note_Redundant_Use): Add missi

[Ada] Handle N_Others_Choice case in range-building function

2020-07-16 Thread Pierre-Marie de Rodat
GNAT crashes when building static predicate functions out of a case expression that contain an "others" clause. This is because it attempts to call Is_OK_Static_Expression() on the N_Others_Choice of the case expression when trying to figure out whether the case is exhaustive or not. Fixing requir

[Ada] Disable Initialize_Scalars on runtime files

2020-07-16 Thread Pierre-Marie de Rodat
To avoid creating circular dependencies between runtime units and to allow compiling e.g. GNAT with Initialize_Scalars. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * frontend.adb: Disable Initialize_Scalars on runtime files.diff --git a/gcc/ada/frontend.adb b/gcc/ada/front

[Ada] Ada2020: AI12-0107 convention of By_Protected_Procedure

2020-07-16 Thread Pierre-Marie de Rodat
A prefixed view of a subprogram with aspect Synchronization being By_Protected_Procedure has convention protected. This new feature is documented in AI12-0107. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Has_By_Protected_Procedure_Prefixed_View): New

[Ada] AI12-0042: Type invariant checking rules

2020-07-16 Thread Pierre-Marie de Rodat
AI12-0042 specifies a couple of new rules for type invariants. The first is that when a type extension inherits a nonabstract subprogram that is a private operation of an ancestor type that has a class-wide invariant and the parent subprogram is visible at that point, the subprogram must be overrid

[Ada] Overflow in string streaming

2020-07-16 Thread Pierre-Marie de Rodat
The routine to output strings in an optimized manner has an overflow error in case of very large strings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-ststop.ads: Fix typo. * libgnat/s-ststop.adb (Read, Write): Fix block number computation to avo

[Ada] gnatbind: Fix No_Entry_Calls_In_Elaboration_Code message

2020-07-16 Thread Pierre-Marie de Rodat
This patch fixes a bug where gnatbind would suggest adding the No_Entry_Calls_In_Elaboration_Code restriction, when that restriction is already present. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * bindo-diagnostics.adb (Output_Invocation_Related_Suggestions): Use

[Ada] Implicit dereferencing in container indexing

2020-07-16 Thread Pierre-Marie de Rodat
The compiler was disallowing an access to a container to be used as the prefix of an indexing of the container, but implicit dereferencing is allowed in such a context (basically because a prefix can be an implicit_dereference, by RM 4.1(4); a Ramification note was added in RM 4.1.6(11.a/5), to cla

[Ada] Misplace of internal master renaming declaration

2020-07-16 Thread Pierre-Marie de Rodat
This patch fixes a regression introduced by the recent work done for tagged type constructors with task components. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Expand_N_Full_Type_Declaration): Ensure a _master declaration on limited types that might

[Ada] AI12-0004 Normalization and allowed characters

2020-07-16 Thread Pierre-Marie de Rodat
This Ada AI clarifies that Ada identifiers that contain characters that are not allowed in Normalization Form KC are illegal. It also introduces a new function Is_NFKC. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * scng.adb (Scan): Detect wide characters not in NFKC.

[Ada] Ongoing work for AI12-0212 : container aggregates

2020-07-16 Thread Pierre-Marie de Rodat
This patch adds support for indexed aggregates with both positional components and component associations that include multiple choices and range specifications. For indexed aggregates the expansion uses a separate pass, as suggested in AI12-0212, to compute the size of the resulting object and pre

[Ada] Spurious error in instance nested in formal package

2020-07-16 Thread Pierre-Marie de Rodat
This patch removes a spurious error in a compilation of a generic body GB that includes a formal package whose source GF includes a nested generic package NGF, and GB includes instances of NGF and of further generic units declared within NGF. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/

[Ada] AI12-0132 Freezing of renames_as_body

2020-07-16 Thread Pierre-Marie de Rodat
This AI clarifies that a renames-as-body freezes the expression of any expression function that it renames. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Analyze_Subprogram_Renaming): A renames-as-body freezes the expression of any expression function

[Ada] Set missing Parent field of block entity

2020-07-16 Thread Pierre-Marie de Rodat
This sets the Parent field of the block entity created in the case of a statement sequence by Expand_N_Accept_Statement to the newly created block statment, as done for example in Add_Block_Identifier. This is needed in peculiar cases where the block contains instantiations of packages with generi

[Ada] Ada2020: AI12-0117 Restriction No_Tasks_Unassigned_To_CPU

2020-07-16 Thread Pierre-Marie de Rodat
Implement the No_Tasks_Unassigned_To_CPU restriction. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnatbind.adb (Gnatbind): For No_Tasks_Unassigned_To_CPU, check that CPU has been set on the main subprogram. (Restriction_Could_Be_Set): Don't print

[Ada] Adjust heuristics about size of static aggregates

2020-07-16 Thread Pierre-Marie de Rodat
This patch adjusts the heuristics about the size of static aggregates, which determine whether an aggregate should be statically allocated. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Max_Aggregate_Size): Use the small size of 64 when copying is nee

[Ada] Wrong execution of Tan on large argument

2020-07-16 Thread Pierre-Marie de Rodat
The custom implementation of Tan in a-numaux__x86.adb has some holes for large values and will e.g. produce the wrong result on Tan (16367173.0 * 2.0**72). This is fixed by replacing the use of a-numaux__x86 by a-numaux__libc-x86.ads. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] x86-lynx178elf: use a-numaux.ads instead of a-numaux__libc-x86.ads

2020-07-27 Thread Pierre-Marie de Rodat
a-numaux__libc-x86.ads wraps around long double trig functions that Lynx178 does not have, so use the default a-numaux.ads instead to match what is offered on Lynx178. This is done by removing X86_TARGET_PAIRS from the x86-lynx178elf configuration as it is now redundant: the default a-numaux pacak

[Ada] AI12-0382: Loosen type-invariant overriding requirement of AI12-0042

2020-07-27 Thread Pierre-Marie de Rodat
The requirement for overriding an inherited visible private operation when extending from an ancestor that specifies Type_Invariant'Class as specified in RM 7.3.2(6.1/4) (AI12-0042) was unintentionally overrestrictive. The rule is loosened by AI12-0382 so that it only applies to type extensions th

[Ada] Warnings on overloays involving generic In_Parameters

2020-07-27 Thread Pierre-Marie de Rodat
Warnings aare emitted when a declaration for a constant C has an address aspect or an address_specification clause of the form O'Address, where O is a previously declared entity that is not a constant, The warning must br supppressed if O is a generic formal In_Parameter, which is a constant within

[Ada] Add range check for GNATprove on 'Pos to Long_Integer conversion

2020-07-27 Thread Pierre-Marie de Rodat
In GNAT mode attribute Pos is typically expanded into either a type conversion (unless applied to enumeration types with custom representation values) and analysis of this type conversion adds check flags as required. In GNATprove mode we expand the attribute with Apply_Universal_Integer_Attribute

[Ada] AI12-0194: Language-defined aspects and entry bodies

2020-07-27 Thread Pierre-Marie de Rodat
AI12-0194 specifies that language-defined aspects aren't permitted on entry bodies, which is already effectively enforced by GNAT, however the error message given when Max_Entry_Queue_Length is applied to an entry body is potentially confusing, because it says that the aspect "must apply to a prote

[Ada] Unbounded string overriding control

2020-07-27 Thread Pierre-Marie de Rodat
Unbounded string operation has to raise Constraint_Error if resulting string going to be over Integer'Last length. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strunb.adb (Sum, Mul, Saturated_Sum, Saturated_Mul): New routines. Use them when resulting st

[Ada] Ada2020: wording of 'Image messages

2020-07-27 Thread Pierre-Marie de Rodat
Change the wording of error messages about 'Image to indicate that newer versions of the language allow more cases. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.ads, errout.adb (Error_Msg_Ada_2020_Feature): New procedure analogous to Error_Msg_Ada_2012_Feat

[Ada] Remove disabled code

2020-07-27 Thread Pierre-Marie de Rodat
This old code is likely made obsolete by recent changes related to the handling of the universal access "=" operator. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Resolve_Attribute): Remove dead code.diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb -

[Ada] Remove obsolete special case in Switch_View

2020-07-27 Thread Pierre-Marie de Rodat
This removes obsolete code that would prevent a subtype dependent on a private type from having its views switched when those of the private type are switched by Switch_View. Not switching the views in this case is problematic because this is not in keeping with what the mechanism based on Install

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

2020-07-27 Thread Pierre-Marie de Rodat
Implement Put_Image for the random number packages and for Ada.Containers.Vectors. More to come. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-rannum.ads, libgnat/s-rannum.adb: Add Put_Image. This will be inherited by the language-defined packages

[Ada] Bug in Enum_Subtype'Image in Ada 2020 mode

2020-07-27 Thread Pierre-Marie de Rodat
This patch fixes a bug in which Enum_Subtype'Image, where Enum_Subtype is a non-first subtype of an enumeration type, would return the image of the 'Pos -- that is, an integer instead of the text of the enumeration literal. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp

[Ada] AI12-0383 Renaming values

2020-07-27 Thread Pierre-Marie de Rodat
This AI allows names that denote values rather than objects to nevertheless be renamed using an object renaming. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Analyze_Object_Renaming): Allow values in Ada 2020 mode.diff --git a/gcc/ada/sem_ch8.adb b/gc

[Ada] AI12-0377 View conversions and out parameters revisited

2020-07-27 Thread Pierre-Marie de Rodat
This AI refines AI12-0074 to disallow cases of potential de-initializing of out parameters. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Actuals): Refine 6.4.1 rules as per AI12-0377.diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb --- a

[Ada] Wrong accessibility on 'Access of formal in call

2020-07-27 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby taking 'Access on a component of an anonymous access formal parameter and using such an expression as an actual in a call where the corresponding formal is also an anonymous access type will cause dynamic accessibility checks within the callee function

[Ada] Revert "Revamp dump and aux output names"

2020-07-27 Thread Pierre-Marie de Rodat
This reverts commit 593627b4562814d2206e53e9ad6ce2e85295aa58. That commit was installed in GCC by mistake, bringing it in sync with an earlier, internal transitory state that had just been resolved in a separate patch. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * switch.

[Ada] Switch Ada_Version_Runtime to Ada 2020

2020-07-27 Thread Pierre-Marie de Rodat
Now that we're adding more and more Ada 2020 specific aspects in runtime units, this is the convenient thing to do. Note that this doesn't impact the Ada version used by user code. Also fix a latent bug in sem_ch3 along the way, showing up when System.Atomic_Primitives generic children are compile

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