[Ada] Don't correct socket timeout on Windows Server 2019

2020-06-12 Thread Pierre-Marie de Rodat
Windows Server 2019 do not need 500ms socket timeout correction. The problem is that Windows API recommended function IsWindowsVersionOrGreater is not comparing the build part which is only difference between Windows 2016 and 2019 servers. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06

[Ada] Fix handling of subprograms declared in a protected body

2020-06-12 Thread Pierre-Marie de Rodat
Such subprograms are not protected and have convention Intrinsic to ensure that their 'Access isn't taken as per RM 6.3.1(10/2). Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Arnaud Charlet gcc/ada/ * exp_ch6.adb (Expand_N_Subprogram_Declaration): Do nothing for

[Ada] Fix anonymous-to-named access type implicit conversion legality checking

2020-06-12 Thread Pierre-Marie de Rodat
There are some cases where an explicit type conversion from an anonymous access type to a named access type is legal but an implicit conversion is not. Ada RM 8.6 requires that for such an implicit conversion (but not for an explicit conversion), the operand of the conversion "shall denote a view w

[Ada] Alphabetic ordering for name and pragmas

2020-06-12 Thread Pierre-Marie de Rodat
Identifiers in the snames template file are ordered either logically or alphabetically, but the Test_Case identifier was clearly out-of-order. Likewise for pragmas. Cleanup before adding a new aspect; semantics in unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Piotr Tro

[Ada] Fix handling of Ada 83 OUT parameter rule

2020-06-12 Thread Pierre-Marie de Rodat
The current code was climbing the tree manually assuming that an array attribute (e.g. 'First) would appear immediately, which isn't the case for e.g. a selected component expression. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Arnaud Charlet gcc/ada/ * sem_res.adb (

[Ada] AI12-0074 View conversions and out parameters passed by copy

2020-06-12 Thread Pierre-Marie de Rodat
This Ada 202x AI makes illegal some cases of out parameters whose type has a Default_Value aspect. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Arnaud Charlet gcc/ada/ * sem_res.adb (Resolve_Actuals): Check for AI12-0074.--- gcc/ada/sem_res.adb +++ gcc/ada/sem_res.adb

[Ada] Improve code generated for assignment of dynamic record aggregates

2020-06-12 Thread Pierre-Marie de Rodat
This mainly improves the code generated for the assignment of dynamic record aggregates, which was always going through a temporary if the target of the assignment was not a simple identifier (this is not the case for dynamic array aggregates). This also extends a little the set of acceptable comp

[Ada] Implement AI12-0369

2020-06-12 Thread Pierre-Marie de Rodat
AI12-0369 relaxes the rules for the Static_Barriers and Pure_Barriers restrictions so that subcomponents of a protected object can be named (subject to some restrictions) in a barrier expression. Note that one effect of this is to undo a change that was made recently for AI12-0290. Tested on x86_6

[Ada] Update 'Loop_Entry checking to match changes in 'Old rules.

2020-06-15 Thread Pierre-Marie de Rodat
AI12-0217 made changes in the rules for 'Old; make analogous changes for 'Loop_Entry. In particular, where the rules used to require that the attribute prefix must "statically denote" an object in some cases, those rules have been relaxed to say that the prefix must "statically name" an object inst

[Ada] Bad access checks on if/case expression as actual

2020-06-15 Thread Pierre-Marie de Rodat
This patch corrects an issue in the compiler whereby conditional expressions used directly as actuals for anonymous access types caused the callee to fail to generate relevant accessibility checks. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Justin Squirek gcc/ada/ *

[Ada] Put_Image: Implement for private types with full real type

2020-06-15 Thread Pierre-Marie de Rodat
Implement Put_Image for private types whose full type is a fixed or floating point type. Also implement 'Image for private types in general. This affects integers and enumeration types. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Bob Duff gcc/ada/ * exp_imgv.adb (Exp

[Ada] Do not expect task discriminants in Global and Depends contracts

2020-06-15 Thread Pierre-Marie de Rodat
When the support for Global and Depends (and their Refined variants) contracts was implemented, it wrongly allowed discriminants to appear in these contracts. This was later fixed, but we still had task discriminants installed when resolving the contract items. Tested on x86_64-pc-linux-gnu, commi

[Ada] Put_Image: Enable for access-to-subprogram types

2020-06-15 Thread Pierre-Marie de Rodat
Implement Put_Image for access-to-subprogram, including access-to-protected-subprogram, and enable. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Bob Duff gcc/ada/ * libgnat/s-putima.ads, libgnat/s-putima.adb (Put_Image_Access_Subp, Put_Image_Access_Prot): New

[Ada] Implement AI12-0077 Has_Same_Storage on objects of size zero

2020-06-15 Thread Pierre-Marie de Rodat
This implements the AI in all versions of the language, since it is a binding interpretation. The point is to make 'Has_Same_Storage return false for objects of size zero, as 'Overlaps_Storage already does. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Eric Botcazou gcc/ada/

[Ada] Use uniform type resolution for membership tests

2020-06-15 Thread Pierre-Marie de Rodat
This fixes an annoying discrepancy in the resolution of the type of the elements of the choice list in a membership test. Consider: Msg : String; if Msg not in "" | "bypass" then ... end if; if not (Msg in "" or else Msg in "bypass") then ... end if; function Func return St

[Ada] Remove unreferenced and dubious Is_Renaming_Declaration

2020-06-15 Thread Pierre-Marie de Rodat
Routine Is_Renaming_Declaration was added to support the Ghost aspect in SPARK, but later its only callee has been removed when handling of this aspect was fixed; now it is unreferenced. Also, it is dubious whether we ever needed this routine (and whether we needed to explicitly list renaming node

[Ada] Link failure with call to expression function in precondition

2020-06-15 Thread Pierre-Marie de Rodat
A call to an exprewion function generated for a precondition that applies to a null procedure leaves the freeze node for the expression function in the wrong context. As a result the body of the function is not properly compiled and the corresponding symbol is markea as undefined, leading to a subs

[Ada] Do not expect Global or Depends on single protected objects

2020-06-15 Thread Pierre-Marie de Rodat
The Global and Depends contracts can only be attached to single task objects, not to single protected objects. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Piotr Trojanek gcc/ada/ * contracts.adb (Analyze_Object_Contract): Do not expect Global/Depends on singl

[Ada] Do expect task discriminants in Global and Depends contracts

2020-06-15 Thread Pierre-Marie de Rodat
This reverts a previous commit and reinstalls task discriminants for the analysis of Global/Depends contracts (and their refined variants). Task discriminants are rejected in those contracts, but need to be installed for the analysis, as otherwise we get difficult to understand error messages. Tes

[Ada] Fix analysis of Relaxed_Initialization for bodies-as-specs

2020-06-15 Thread Pierre-Marie de Rodat
Analysis of Relaxed_Initialization is heavily inspired by the existing code for Global/Depends contract. There was one difference in dealing with scope tables; it turns out that this difference was a mistake. Now fixed. Also, fix a mistake in querying the aspect property for subprogram parameter,

[Ada] Missing errors on aspect checking

2020-06-15 Thread Pierre-Marie de Rodat
Some aspects with no corresponding pragmas (Default_Value and Default_Component_Value) did not have proper checking for rules in RM 13.1(9) and RM 13.1(10)), this is now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Arnaud Charlet gcc/ada/ * sem_attr.adb (Eval_A

[Ada] Implement AI12-0343 Return Statement Checks

2020-06-15 Thread Pierre-Marie de Rodat
This implements the AI in all versions of the languages, since it is a binding interpretation. The goal of the AI is to clarify where three checks prescribed by the 6.5 clause are done in the case of an extended return statement (immediately after the return object is created or immediately before

[Ada] Allow uninitialized values on Big_Positive/Natural

2020-06-15 Thread Pierre-Marie de Rodat
The current Dynamic_Predicate prevents declaring a variable without also initializing it at the same time. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Arnaud Charlet gcc/ada/ * libgnat/a-nbnbin.ads (Big_Positive, Big_Natural): Fix predicate.--- gcc/ada/libgna

[Ada] Put_Image improvements for strings

2020-06-15 Thread Pierre-Marie de Rodat
Use string literal syntax for private types whose full type is string, as was already done for visible string types. Double the double-quote characters in the literal. Disable Put_Image for unchecked unions, so they'll just print the type name. Tested on x86_64-pc-linux-gnu, committed on trunk 2

[Ada] Rewrite Sem_Eval.Predicates_Match predicate

2020-06-15 Thread Pierre-Marie de Rodat
This reimplements the predicate more efficiently and more strictly. It is used to implement the part of the 4.9.1 (2/3) subclause that pertains to predicates: "A subtype statically matches another subtype of the same type if they have statically matching constraints, all predicate specifications t

[Ada] Clean up error handling of 'Image

2020-06-15 Thread Pierre-Marie de Rodat
...in preparation for enabling 'Image for all types in Ada 2020, and having it call 'Put_Image for nonscalar types, and for types with user-defined 'Put_Image. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Bob Duff gcc/ada/ * sem_attr.adb (Check_Image_Type): New proced

[Ada] Crash in tagged type constructor with task components

2020-06-15 Thread Pierre-Marie de Rodat
The compiler blows up processing a constructor function that returns a limited private tagged type that implements an interface type whose full view has a task type component. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Javier Miranda gcc/ada/ * restrict.ads (Set_Glo

[Ada] Passing actual parameter values to out formals when Default_Value is set

2020-06-15 Thread Pierre-Marie de Rodat
When the type of a scalar formal parameter of mode out has the Default_Value aspect, the actual type is also required to have that aspect (required now by AI12-0074, RM 6.4.1(5.3/4)), and the value of the actual must be passed on calls (since the actual is guaranteed to be initialized and deinitial

[Ada] AI12-0260 Functions Is_Basic and To_Basic in Wide_Characters.Handling

2020-06-15 Thread Pierre-Marie de Rodat
This Ada 202x AI introduces new functions Is_Basic and To_Basic in Ada.Wide_Characters.Handling. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Arnaud Charlet gcc/ada/ * libgnat/a-wichha.ads, libgnat/a-wichha.adb, libgnat/a-wichun.ads, libgnat/a-wichun.adb (Is_B

[Ada] T'Image calls T'Put_Image

2020-06-15 Thread Pierre-Marie de Rodat
In Ada 2020, T'Image calls T'Put_Image if there is an explicit aspect_specification for Put_Image, or if U_Type'Image is illegal in pre-2020 versions of Ada. Scalar types continue to use the old 'Image, even in Ada 2020. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-15 Bob Duff gc

[Ada] Fix small fallout of freezing change for expression functions

2020-06-16 Thread Pierre-Marie de Rodat
The previous change implemented the rule in Freeze_Expression that expression functions that are not completions are not freeze points. However, for code generation purposes, the artificial entities that are created during the expansion of the expressions must still be frozen inside the body create

[Ada] Fix spurious error on implicit dereference for private type

2020-06-16 Thread Pierre-Marie de Rodat
This is a fallout of the earlier work on the handling of Ada 95 implicit dereferences. The dereferences are now made explicit only at the final stage of type resolution and this slightly changes the way they are analyzed during semantic analysis. In particular, in the case of an implicit derefere

[Ada] Spurious undefined symbol with nested call to expression function

2020-06-16 Thread Pierre-Marie de Rodat
The compiler creates a link failure involving an expression function that is not a completion when the expression of the expression function includes a call to a function F declared in on outer scope of the same package declaration, becausw the compiler places the freeze node for F in the generated

[Ada] Check if attribute Passed_By_Reference is called on incomplete types

2020-06-16 Thread Pierre-Marie de Rodat
Problem: When Passed_By_Reference is used on an incomplete type (e.g. `type T; B : Boolean := T'Passed_By_Reference;`) GNAT crashes in Gigi because it doesn't know the size of T. Solution: Reject programs that use Passed_By_Reference on incomplete types, just like what is currently done for the Al

[Ada] Implement AI12-0351 Matching for actuals for formal derived types

2020-06-16 Thread Pierre-Marie de Rodat
This implements the AI in all versions of the language, since it is a binding interpretation. The AI extends the 12.5.1(8) subclause: "For a generic formal derived type with no discriminant_part, the actual subtype shall be statically compatible with the ancestor subtype" from constained types to

[Ada] Accept renamings of folded string aggregates

2020-06-16 Thread Pierre-Marie de Rodat
Routine Is_Object_Reference, which implements Ada RM 3.3(2) that says "All of the following are objects: ..." was slightly diverging from the exact wording of that rule and from the exact wording of AI05-0003, which allows qualified expressions to be used as objects (provided that their expression

[Ada] Force evaluation of qualified aggregates

2020-06-16 Thread Pierre-Marie de Rodat
This patch fixes regressions in GNATprove, after a previous patch changed routine Is_Object_Reference to literally implement the Ada RM and recognize aggregates as objects. Now routine Evaluate_Name also literally implements the Ada RM rules about name evaluation; in particular, it restores forced

[Ada] ACATS 4.1K - B452001 - No errors detected

2020-06-16 Thread Pierre-Marie de Rodat
This is a test against RM 4.5.2(4.1/4), the rule that ensures that equality is visible for a membership involving objects. GNAT wasn't handling this case properly because during the rewrite of membership tests, the legality rules were bypassed as the rewrite was no longer treated as if it came from

[Ada] ACATS 4.1P - C432003 - Errors missed on extension aggregates

2020-06-16 Thread Pierre-Marie de Rodat
This ACATS test show that GNAT was not implementing AI05-0115 properly, now fixed by checking the relevant parent type. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Arnaud Charlet gcc/ada/ * sem_aggr.adb (Resolve_Extension_Aggregate): Fix implementation of AI0

[Ada] Force evaluation of operator calls in renamings

2020-06-16 Thread Pierre-Marie de Rodat
When renaming a qualified expression with an operator, e.g.: Y : Boolean renames Boolean'(not X); routine Evaluate_Name should handle operators just like it handles function calls. This doesn't appear to matter for GNAT (where this routine is called in very few cases, as described in the comme

[Ada] Fix assertion failure on qualified type names in predicates

2020-06-16 Thread Pierre-Marie de Rodat
An assertion is code for static membership tests was failing on this code: subtype A is Integer with predicate => A > 0; subtype B is Integer with predicate => B in P.A; where a qualified type name "P.A" appears in the predicate of type B. The fix is trivial and the problem didn'

[Ada] ACATS 4.1P - BC55001 - Error missed

2020-06-16 Thread Pierre-Marie de Rodat
This ACATS test shows that we are not checking legality of functions returning interfaces that need to be abstract. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Arnaud Charlet gcc/ada/ * sem_ch6.adb (Analyze_Subprogram_Specification): Generate error message fo

[Ada] ACATS C452005/C452006 memberships use wrong equality operation

2020-06-16 Thread Pierre-Marie de Rodat
ACATS tests C452005 and C452006 show that GNAT is using the wrong equality operation for non record/non limited types as defined in RM 4.5.2 (28.1/4). This is actually a follow up/complement of the previous change for ACATS B452001 against RM 4.5.2(4.1/4). Tested on x86_64-pc-linux-gnu, committed

[Ada] Fix premature freezing of artificial array subtype

2020-06-16 Thread Pierre-Marie de Rodat
This prevents the compiler from placing the freeze node of an array subtype, generated for the expression of an if-expression whose type is an array type declared with a predicate, ahead of this expression and, in particular, before its declaration. Tested on x86_64-pc-linux-gnu, committed on trun

[Ada] Enable literal aspect specifications in Big_Numbers specs

2020-06-16 Thread Pierre-Marie de Rodat
Specify the Integer_Literal aspect for the type Ada.Numerics.Big_Numbers.Big_Integers.Big_Integer. Specify the Real_Literal aspect for the type Ada.Numerics.Big_Numbers.Big_Reals.Big_Real. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Steve Baird gcc/ada/ * libgnat/a-

[Ada] Implement AI12-0216 on restricting overlap errors in calls

2020-06-16 Thread Pierre-Marie de Rodat
This patch implements A12-0216, which clarifies RM 6.4.1 (6.16-17/3) concerning illegal overlappings between actuals in a call. The previous illegality rule applied to a call in which two writable actuals, one of them having an elementary type, are known to overlap. The new rule states that illegal

[Ada] Crash in tagged type constructor with task components

2020-06-16 Thread Pierre-Marie de Rodat
This patch fixes the regressions introduced in CodePeer (caused by missing support for thunks) and enforces checks on BIP formals in the frontend to avoid mismatch when their values are passed as actuals of BIP calls. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Javier Miranda

[Ada] Crash in tagged type constructor with task components

2020-06-16 Thread Pierre-Marie de Rodat
This patch removes part of the patch added to process the run-time package system.ads; it is not needed because we now rely on Targparm.Restrictions_On_Target. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Javier Miranda gcc/ada/ * sem_prag.adb (Process_Restrictions_Or

[Ada] Implement AI12-0249, AI12-0295 (user-defined numeric & string literals)

2020-06-16 Thread Pierre-Marie de Rodat
Implement Ada 202x's Integer_Literal, Real_Literal, and String_Literal aspects. This is just a preliminary implementation; interactions with controlled types, build-in-place functions, abstract types, interface types, aspects specifying an operator (e.g, "+"), mandatory aspect overriding, and many

[Ada] Minor casing of " The " after a comma in docs and comments

2020-06-16 Thread Pierre-Marie de Rodat
Fix wrong casing in phrases like "something, The"; also, fix other small typos in comments. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Piotr Trojanek gcc/ada/ * checks.adb, doc/gnat_ugn/the_gnat_compilation_model.rst, einfo.ads, exp_ch5.adb, exp_ch7.adb, lib

[Ada] Expand 'Pos and 'Val for enumeration types with standard representation

2020-06-16 Thread Pierre-Marie de Rodat
This changes the front-end to expand the 'Pos and 'Val attributes for enumeration types with standard representation. It turns out that this was the only remaining case where it does not expand them, as it does so for enumeration types with non-standard representation as well as for integer types.

[Ada] Fix spurious error on derived private type with predicate

2020-06-16 Thread Pierre-Marie de Rodat
As explained in the head comment of Compatible_Types_In_Predicate, anomalies involving private and full views can occur when a call to a predicate or invariant function is generated by the compiler. The function uses the child function Common_Type to reconcile the various views of a private type,

[Ada] Declare expressions

2020-06-16 Thread Pierre-Marie de Rodat
This patch implements AI12-0236-1, declare expressions. They are implemented in terms of N_Expression_With_Actions, which has the same semantics. A superset of the semantics, actually. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Bob Duff gcc/ada/ * par-ch4.adb (P_Cas

[Ada] Improve bug box customer language

2020-06-16 Thread Pierre-Marie de Rodat
The language used in the bugbox for a customer to report an error message is missing an upper-case for the start of a sentence and also could be worded a bit clearer. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Richard Kenner gcc/ada/ * comperr.adb (Compiler_Abort):

[Ada] Reuse Is_Object where possible

2020-06-16 Thread Pierre-Marie de Rodat
Reuse a high-level Is_Object, which is meant to be more readable than a low-level membership test with Ekind. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Piotr Trojanek gcc/ada/ * einfo.adb, exp_spark.adb, exp_util.adb, sem_eval.adb: Replace

[Ada] Change how we detect internal protected subprograms

2020-06-16 Thread Pierre-Marie de Rodat
We don't always have Convention_Protected, so test for presence of Protected_Body_Subprogram. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-16 Richard Kenner gcc/ada/ * exp_unst.adb (Subp_Index): Change way we detect internal protected subprograms.--- gcc/ada/exp_

[Ada] Fix small fallout of change for 'Pos and 'Val attributes

2020-06-17 Thread Pierre-Marie de Rodat
The function Build_Conversion in Exp_Fixd does a bit of folding but fails to preserve the Conversion_OK flag in doing so, unlike other flags. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Eric Botcazou gcc/ada/ * exp_fixd.adb (Build_Conversion): Also preserve the

[Ada] Optimize length checks generated for slice assignments

2020-06-17 Thread Pierre-Marie de Rodat
The purpose of this change is to enhance Optimize_Length_Comparison so that it optimizes the two length computations generated for the length check required for an assignment of array slices. It also ensures that the computations generated as part of the optimization are done without overflow chec

[Ada] Work around problematic interaction with public symbol generation

2020-06-17 Thread Pierre-Marie de Rodat
The previous change made to fold 'First and 'Last for constrained array types can go awry in the presence of layers of package instantiations because the referenced entities need to have a stable name if they are public and providing such a guarantee is not trivial in some cases. Therefore this ch

[Ada] Implement static expression functions for Ada 202x (AI12-0075)

2020-06-17 Thread Pierre-Marie de Rodat
AI12-0075 adds a new aspect Static that can be applied to expression functions to specify that the functions are static. When a static expression function is called with actual parameters that are static expressions, the function call is itself treated as a static expression and can be used in cont

[Ada] Fix comment of Get_Iterable_Type_Primitive

2020-06-17 Thread Pierre-Marie de Rodat
The comment for Get_Iterable_Type_Primitive didn't mention that it can be used for primitives Last and Previous. This happens when this routine is called from Build_Formal_Container_Iteration when analyzing a reverse iteration. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Piotr T

[Ada] Remove unnecessary special-casing of GNATprove expansion

2020-06-17 Thread Pierre-Marie de Rodat
In GNATprove mode expansion is disabled; in terms of code, we have an invariant that GNATprove_Mode implies Expander_Active to be False. This renders conditions like "GNATprove_Mode or not Expander_Active" redundant, as they are equivalent to just "not Expander_Active". This patch removes this red

[Ada] Fix casing from GNATProve to GNATprove

2020-06-17 Thread Pierre-Marie de Rodat
The preferred casing is "GNATprove", i.e. "GNAT" in upper-case and "prove" in lower-case. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Piotr Trojanek gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst, lib-writ.ads, par-prag.adb, sem_ch12.adb, sem_ch8.a

[Ada] Fix small oversight in change to Optimize_Length_Comparison

2020-06-17 Thread Pierre-Marie de Rodat
The previous change has introduced a type consistency issue when the length comparison boils down to a comparison of the upper bounds. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Eric Botcazou gcc/ada/ * exp_ch4.adb (Optimize_Length_Comparison): Make sure the base

[Ada] Deal with second specific superflat case in Optimize_Length_Comparison

2020-06-17 Thread Pierre-Marie de Rodat
In the general case, the procedure Optimize_Length_Comparison goes to great lengths to make sure that it does not deal with superflat arrays because, in this case, the canonical formula of the length is not valid. The only such case that it accepts is a comparison against literal zero. This change

[Ada] Fix expansion of "for X of Y loop" in GNATprove

2020-06-17 Thread Pierre-Marie de Rodat
Expansion of "for X of Y loop" where Y is an array was differed in GNAT (where it was correct) and GNATprove (where it was wrong). Typically expansion is controlled by the Expander_Active variable. In GNATprove mode this variable is always False, so we need to explicitly enable expansion where req

[Ada] Ada2020: AI12-0110 Tampering checks are performed first

2020-06-17 Thread Pierre-Marie de Rodat
This patch implements AI12-0110-1, which requires tampering checks in the containers library to be performed first, before any other checks. In some cases, this patch causes cases where a check for no-op happens to be moved later, after checks. This is correcting bugs (the checks should happen eve

[Ada] Add assertions to Preserve_Comes_From_Source and reuse it

2020-06-17 Thread Pierre-Marie de Rodat
Routine Preserve_Comes_From_Source directly manipulated node tables without checking whether their arguments are valid and whether the node table is locked. Now it applies those checks. Also, this routine is now reused where possible. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committ

[Ada] Couple of small tweaks related to integer conversions

2020-06-17 Thread Pierre-Marie de Rodat
The first tweak is to change Get_Integer_Type, which is the routine used by Expand_N_Attribute_Reference to pick a small integer type for various attributes applied on enumeration types, to use the "standard" standard integer types instead of the standard integer types with a specific size. That's

[Ada] Support aspect Relaxed_Initialization on private types and constants

2020-06-17 Thread Pierre-Marie de Rodat
Aspect Relaxed_Initialization can now be attached to private types and deferred constants, but only to their private views. This is similar to the spirit of SPARK RM 6.9(9) for ghost aspect, which says: "[This rule is to ensure that the ghostliness of a visible entity can be determined without

[Ada] Ada_2020 AI12-0220 Pre/Postconditions on Access_To_Subprogram types

2020-06-17 Thread Pierre-Marie de Rodat
This patch completes the implementation of AI12-0220, which adds contracts to Access_To_Subprogram types. Attributes 'Old and 'Result are properly supported, and the needed subprogram wrapper is built before the contract aspects on the access type are analyzed, to simplify semantic checks. Tested

[Ada] Remove new problematic condition for LLVM

2020-06-17 Thread Pierre-Marie de Rodat
The new condition added for scalar types in the previous change for the sake of consistency with array types is apparently problematic for LLVM so this change removes it. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Eric Botcazou gcc/ada/ * exp_attr.adb (Expand_N_Attr

[Ada] ACATS 4.1H - BA12018 - Missed errors for private with

2020-06-17 Thread Pierre-Marie de Rodat
GNAT was ignoring the 'private' keyword for parent packages implicitly withed from a subprogram unit, via a child unit. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Arnaud Charlet gcc/ada/ * sem_ch10.adb (Expand_With_Clause): Add missing handling of N_Generic_

[Ada] Add early return to Apply_Universal_Integer_Attribute_Checks

2020-06-17 Thread Pierre-Marie de Rodat
The procedure Apply_Universal_Integer_Attribute_Checks is called from the expander when an attribute nominally returning Universal_Integer is seen so that, if resolution has determined another type for the result, then Universal_Integer is nevertheless forced on the attribute and a conversion is ad

[Ada] Small cleanup throughout CStand body

2020-06-17 Thread Pierre-Marie de Rodat
This mainly fixes a couple of inconsistencies in the way entities of the Standard package are built: first, some of them are built with a bare call to New_Standard_Entity and the name is only set afterwards, whereas others are built with a call to New_Standard_Entity with the name passed as argumen

[Ada] Do not give "bad indentation" error inside a declare_expression

2020-06-17 Thread Pierre-Marie de Rodat
In -gnatg mode, gnat complains "bad indentation" if a statement or declaration does not start in a column divisible by 3. This patch fixes a bug in which it complained similarly about a declare_expression, which is not a statement or declaration. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Do not generate useless length check for array initialization

2020-06-17 Thread Pierre-Marie de Rodat
This prevents the compiler from generating a length check that can never fail for the initialization of an array whose nominal subtype is unconstrained and which is subject to an address clause. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Eric Botcazou gcc/ada/ * che

[Ada] Additional legality rule for indexing operation for derived type

2020-06-17 Thread Pierre-Marie de Rodat
AI12-0160 clarifies the rules for nonoverridable aspects for indexing: when a derived type inherits a single indexing aspect (constant or variable) from a parent type, it cannot specify the other (non-inherited) indexing aspect. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Ed Sch

[Ada] Nested subprograms in protected subprograms improperly handled in GNAT-LLVM

2020-06-17 Thread Pierre-Marie de Rodat
For GNAT-LLVM, subprograms nested within protected subprograms become part of the new unprotected body created by Build_Unprotected_Subprogram_Body, but the entity of the unprotected subprogram was not getting marked as Has_Nested_Subprogram, and the declarations now nested within the new body didn

[Ada] Ada2020: AI12-0279 more dispatching points with aspect Yield

2020-06-17 Thread Pierre-Marie de Rodat
This patch implements AI12-0279-1, which adds a Yield aspect applicable to a noninstance subprogram (including a generic formal subprogram), a generic subprogram, or an entry, to ensure that the associated subprogram encounters at least one task dispatching point during each invocation. Tested on

[Ada] Fix incorrect operand sharing after expansion

2020-06-17 Thread Pierre-Marie de Rodat
The Expand_N_Op_Expon procedure of the expander starts by relocating its operands, but later reuses the original right operand in the code generated in the modular case and, in particular, passes it to Duplicate_Subexpr, which is fooled into thinking that operands are not syntactical and thus does

[Ada] Crash in tagged type constructor with task components

2020-06-17 Thread Pierre-Marie de Rodat
This patch fixes regressions introduced in CodePeer on dispatching calls, fixes a latent problem in the decoration of the Extra_Formals attribute, and enforces checks on extra formals. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-17 Javier Miranda gcc/ada/ * exp_ch6.adb

[Ada] Small improvement to Optimize_Length_Comparison

2020-06-18 Thread Pierre-Marie de Rodat
This just changes Optimize_Length_Comparison to accept 32-bit values in the full unsigned range, so that the length of all arrays with a 32-bit or smaller index can be optimized. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Eric Botcazou gcc/ada/ * exp_ch4.adb (Optimi

[Ada] Small adjustment to Get_Integer_Type function

2020-06-18 Thread Pierre-Marie de Rodat
The Get_Integer_Type function is used by the expander when generating code for the Enum_Rep and Pos attributes applied to an enumeration type. The expansion generates a direct conversion from the enumeration type to the result type, which is nominally Universal_Integer; therefore, in order to prese

[Ada] Fix failed assertion on a slice indexed by a subtype_indication

2020-06-18 Thread Pierre-Marie de Rodat
An assignment with a slice indexed by a subtype_indication, e.g.: Y : T := X (Positive range Low .. High); is expanded into: [subtype S is Positive range Low .. High;] Y : S := X (Positive range Low .. High); The bounds of the target subtype S were queried with Scalar_Range, which migh

[Ada] The definition of constants in declare expressions is an interfering context

2020-06-18 Thread Pierre-Marie de Rodat
The definition of constants can be nested inside declare expressions in which case they cannot be considered as valid contexts for calls to volatile functions and access to volatile variable. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Claire Dross gcc/ada/ * sem_uti

[Ada] AI12-0293-1 Implement storage streams

2020-06-18 Thread Pierre-Marie de Rodat
This patch implements storage streams, as specified by three Ada Issues: AI12-0293-1, AI12-0329-1, and AI12-0361-1. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Bob Duff gcc/ada/ * libgnat/a-strsto.ads, libgnat/a-ststbo.adb, libgnat/a-ststbo.ads, libgnat/a-sts

[Ada] List aspect Relaxed_Initialization in GNAT RM

2020-06-18 Thread Pierre-Marie de Rodat
Aspect Relaxed_Initialization and attribute Initialized are now listed as implementation-defined with a reference to the SPARK RM, where their full description will appear shortly. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Piotr Trojanek gcc/ada/ * doc/gnat_rm/impl

[Ada] Do not treat pragma Compile_Time_Warning as error even with -gnatwe

2020-06-18 Thread Pierre-Marie de Rodat
Not treating 'pragma Compile_Time_Warning' warnings as errors even with the -gnatwe switch makes sense because if users desire errors, they can use the Compile_Time_Error pragma. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Ghjuvan Lacambre gcc/ada/ * erroutc.ads: Dec

[Ada] Missing error on aspects Input and Output

2020-06-18 Thread Pierre-Marie de Rodat
The frontend does not report an error on the illegal use of a non class-wide subprogram with class-wide aspects Input and Output; similarly it also skips reporting the error when a class-wide subprogram is used with the non class-wide aspects. As a consequence of not reporting these errors at comp

[Ada] Add second warning for convention C_Variadic_n

2020-06-18 Thread Pierre-Marie de Rodat
This adds a second warning related to the new C_Variadic_n convention, for the cases where the aspect/pragma is applied to a subprogram with exactly n parameters since, in this case, the aspect/pragma is useless. The warning is given as such: btest.ads:16:05: warning: subprogram should have at le

[Ada] Improve compile-time evaluation of value ranges

2020-06-18 Thread Pierre-Marie de Rodat
The main goal of this change is to improve the evaluation at compile time of the ranges of values that an expression can have at run time and to apply it in as many cases as possible during the compilation. It turns out that the front-end contains two separate engines that can evaluate value range

[Ada] ACATS 4.1L - B452002 - Wrong universal access "=" rules

2020-06-18 Thread Pierre-Marie de Rodat
This ACATS test shows that: - GNAT does not allow a named access type in the universal access "=" operator. - GNAT does not enforce the static matching requirement for designated elementary and array types. - GNAT does not allow designated types where one covers the other. - GNAT does not enfo

[Ada] Fix host/target confusion for attribute To_Address

2020-06-18 Thread Pierre-Marie de Rodat
The check applied to the expression of the To_Address attribute in the case where it is static is done with the address size of the host instead of the target, resulting in missing error messages. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Eric Botcazou gcc/ada/ * s

[Ada] Minor cleanup in Expand_Call_Helper

2020-06-18 Thread Pierre-Marie de Rodat
This makes a couple of changes in the code dealing with a call to a derived subprogram: first, it removes useless calls to Relocate_Node before calls to OK_Convert_To and Unchecked_Convert_To (these functions already call Relocate_Node on their second operand) and merge calls to Analyze and Resolve

[Ada] Update output of verbose error summary

2020-06-18 Thread Pierre-Marie de Rodat
GNAT does not count warnings originating from a Compile_Time_Warning pragma as an error anymore, even if the -gnatwe flag is provided. This requires updating the output of its error summary. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Ghjuvan Lacambre gcc/ada/ * erro

[Ada] Add support for XDR streaming in the default runtime

2020-06-18 Thread Pierre-Marie de Rodat
Currently we provide a separate implementation of Stream_Attributes via s-stratt__xdr.adb which needs to be recompiled manually. This change introduces instead a new binder switch to choose at bind time which stream implementation to use and replaces s-stratt__xdr.adb by a new unit System.Stream_A

[Ada] Narrow large arithmetic and comparison operations

2020-06-18 Thread Pierre-Marie de Rodat
The goal of this enhancement is to make it possible for the expander to rewrite both arithmetic and comparison operations that have been resolved to a large type, namely Universal_Integer, into equivalent operations in a smaller type, namely Integer (or Long_Long_Integer). In certain contexts invo

[Ada] No Default_Initial_Condition check when declaring an imported object

2020-06-18 Thread Pierre-Marie de Rodat
Default initialization is not performed when an imported object is declared, so there should also be no Default_Initial_Condition check generated for such an object declaration. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Steve Baird gcc/ada/ * exp_ch3.adb (Expand_N_

[Ada] Small cleanup in constraint checking code for allocators

2020-06-18 Thread Pierre-Marie de Rodat
This consolidates the constraint checking code for allocators in only two places, Expand_Allocator_Expression for the qualified expression case and Expand_N_Allocator for the subtype indication case, getting rid of some duplication and plugging some loopholes in the process. Tested on x86_64-pc-li

<    6   7   8   9   10   11   12   13   14   15   >