[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

[Ada] Small cleanup in the attribute code of the expander

2020-06-18 Thread Pierre-Marie de Rodat
This fixes a few minor glitches in the part of the expander dealing with attributes: missing check for Component_Size, alphabetization issues and wrong classification of few other attributes. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Eric Botcazou gc

[Ada] Implement AI12-0032 fixes for 'Old attribute accessibility

2020-06-18 Thread Pierre-Marie de Rodat
AI12-0032 modifies/clarifies many of the rules pertaining to uses of the Old attribute. Most of these 7 changes were already implemented by GNAT but a couple having to do with accessibility were not. Implement those unimplemented rules. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18

[Ada] Fix invalid expression sharing in Expand_Array_Equality

2020-06-18 Thread Pierre-Marie de Rodat
The procedure Expand_Array_Equality has an optimization whereby the equality operation for an array of 2 elements is expanded into a simple conjunction of two component comparisons instead of into the generic loop. But this special circuitry reuses the same expression list for the indexed componen

[Ada] ACATS 4.1J - B854003 - Subtype conformance check missed

2020-06-18 Thread Pierre-Marie de Rodat
This test shows that GNAT was missing formal subprogram conformance checking in some cases, now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-18 Arnaud Charlet gcc/ada/ * sem_ch6.ads, sem_ch6.adb (Check_Formal_Conformance): New subprogram. (Check_Co

[Ada] Fix small inefficiency in previous change to expander

2020-06-18 Thread Pierre-Marie de Rodat
The procedure Get_Size_For_Range does not need to return the smallest size for a signed integer type covering the range, the important thing is instead to return a size lower than that of the original type; this saves a bunch of lookups in the power-of-two table of the Uint unit. The change also b

[Ada] Fix validity checks on attribute 'Old prefix

2020-06-19 Thread Pierre-Marie de Rodat
Validity checks for 'Old prefixes (enabled by the -gnatVo switch) are now executed when the 'Old prefix is evaluated, i.e. at the very beginning of a subprogram and not when evaluating the postcondition. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Piotr Trojanek gcc/ada/

[Ada] Remove repeated testing of Check_Validity_Of_Parameters

2020-06-19 Thread Pierre-Marie de Rodat
Routine Apply_Parameter_Validity_Checks is only called when flag Check_Validity_Of_Parameters is true, so repeated testing of this flag within that routine itself was unnecessary. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Piotr Trojanek gcc/ada/ * checks.adb (Apply

[Ada] Simplify processing of 'Valid_Scalars on array types

2020-06-19 Thread Pierre-Marie de Rodat
When calling routine Build_Array_VS_Func that expands attribute Valid_Scalars on array objects we tested Scalar_Part_Present on the array's component type. This was unnecessary, because Build_Array_VS_Func is only called after checking Scalar_Part_Present on the array's type, which internally Scala

[Ada] Add comments about attribute 'Valid_Scalars on private tagged types

2020-06-19 Thread Pierre-Marie de Rodat
Attribute 'Valid_Scalars on private tagged types doesn't work as it should on private tagged types. Fix most likely needs to modify three routines. This patch document the problem with a ??? comment. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Piotr Trojanek gcc/ada/

[Ada] Remove second warning for convention C_Variadic_n

2020-06-19 Thread Pierre-Marie de Rodat
It turns out that there are legitimate cases now flagged by the warning. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Eric Botcazou gcc/ada/ * sem_prag.adb (Process_Convention): Revert previous change.--- gcc/ada/sem_prag.adb +++ gcc/ada/sem_prag.adb @@ -8304,7 +8304,

[Ada] universal_access equality and 'Access attributes

2020-06-19 Thread Pierre-Marie de Rodat
For any object Foo, Foo'Access can never be passed as a parameter of a call to the equality op for Universal_Access, so add this check and do some code cleanup on recent changes at the same time. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Arnaud Charlet gcc/ada/ * s

[Ada] Fix validity checking for class-wide objects

2020-06-19 Thread Pierre-Marie de Rodat
When applying 'Valid_Scalars attribute to a class-wide object (either explicitly or as a result of a command line switch like -gnateV), we must strip away type privacy. Note: this is just a minimal fix to avoid a crash. Attribute 'Valid_Scalars is not really working as expected on tagged types, es

[Ada] Decorate record delta aggregate for GNATprove

2020-06-19 Thread Pierre-Marie de Rodat
For a record delta aggregate like "(X with delta C => 1)" the component choice identifier "C" had empty Entity and Etype fields. For GNAT this was fine, because it expands delta aggregates into assignments using component names alone; for GNATprove this was troublesome, because it keeps delta aggr

[Ada] Style checks on invalid UTF character cause crash

2020-06-19 Thread Pierre-Marie de Rodat
This patch fixes the compiler whereby style checks for extranious whitespace (under the flag -gnatyb) may crash the compiler when a manually specified UTF character is present directly before such an extranious whitespace. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Justin Squir

[Ada] AI12-0366 Changes to Big_Integer and Big_Real

2020-06-19 Thread Pierre-Marie de Rodat
This AI changes the API to move the validity checks to a subtype Valid_Big_Integer/Real with a dynamic predicate. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Arnaud Charlet gcc/ada/ * libgnat/a-nbnbin.adb, libgnat/a-nbnbin.ads, libgnat/a-nbnbin__gmp.adb, libg

[Ada] Fix small fallout of previous change for Analyze_Selected_Component

2020-06-19 Thread Pierre-Marie de Rodat
The removal of the obsolete code path originally implemented for ASIS has exposed a latent issue for components of discriminated tagged types in instance bodies: Is_Visible_Component can wrongly return false for them even though the ancestor type is perfectly visible in the instance. No functional

[Ada] Spurious condition warning on type conversion in return

2020-06-19 Thread Pierre-Marie de Rodat
This patch fixes the compiler whereby a conversion to Interfaces.C.Bool within a return statement may cause a spurious "condition always X" warning. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Justin Squirek gcc/ada/ * sem_warn.adb (Warn_On_Known_Condition): Add gene

[Ada] Small cleanup in Apply_Range_Check implementation

2020-06-19 Thread Pierre-Marie de Rodat
The procedure Apply_Range_Check is the only caller of the procedure Apply_Selected_Range_Checks and always passes Do_Static as False, which means that the True path is unreachable in the latter, so this change merges the latter in the former. Moveover, it adds a new parameter Insert_Node to Apply_

[Ada] Reject junk expressions in attribute Update

2020-06-19 Thread Pierre-Marie de Rodat
Attribute Update only makes sense with named component associations. The positional component associations were silently ignored by both analysis, resolution and expansion; now they are rejected as illegal. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Piotr Trojanek gcc/ada/

[Ada] Fix check for bounds in aggregate expansion of allocator

2020-06-19 Thread Pierre-Marie de Rodat
The predicate function In_Place_Assign_OK is responsible for finding out whether the in-place assignment of an aggregate is possible; for array aggregates, it checks among other things whether sliding will occur during the assignment. But, in an allocator context, it does so by comparing the bound

[Ada] Deal with enumeration types with very large size

2020-06-19 Thread Pierre-Marie de Rodat
It is permitted to put very large size clauses on enumeration types so we need to deal with them in Get_Integer_Type. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Eric Botcazou gcc/ada/ * exp_attr.adb (Get_Integer_Type): Return the largest supported unsigned i

[Ada] Plug small loophole in implementation of AI12-0100

2020-06-19 Thread Pierre-Marie de Rodat
The qualified expressions present in allocators use a specific circuitry during type resolution and, therefore, escape the new static predicate check required by AI12-0100 and present in Resolve_Qualified_Expression. This removes the specific circuitry, as well as makes small adjustments to Resolv

[Ada] Fix small fallout of previous change for allocator

2020-06-19 Thread Pierre-Marie de Rodat
Resolve_Qualified_Expression propagates the type of the operand into the node itself if the original type of the node is unconstrained, but this is not needed for an allocator and might be problematic, e.g. for the CCG compiler which expects unconstrained array types. No functional changes. Teste

[Ada] Fix internal error on component of class-wide parameter in instance body

2020-06-19 Thread Pierre-Marie de Rodat
This fixes a Program_Error raised by Analyze_Selected_Component because it didn't manage to find the proper selector for a selected component applied to a parameter of class-wide type in an instance body. The problem is that the tagged type is derived in the private part of the generic spec from a

[Ada] Attempt to hide public entities in nested instance bodies

2020-06-19 Thread Pierre-Marie de Rodat
The procedure Hide_Public_Entities is responsible for (conservatively) attempting to hide entities that have been previously made public by the semantic analyzer in package bodies. But it effectively does not run on nested instance bodies because instantiations are still pending by the time the en

[Ada] Spurious error on private type in ghost expression function

2020-06-19 Thread Pierre-Marie de Rodat
The compiler rejects an expression function declared in a generic package with Ghost aspect, when the expression of the function includes a reference to a private type declared outside of the package, whose full view has not yet been analyzed, and the Ghost mode is Ignore. Tested on x86_64-pc-linu

[Ada] AI12-0293-1 Remove pragma Assert

2020-06-19 Thread Pierre-Marie de Rodat
...and replace it with an explicit check, so it is enabled whether or not assertions are enabled. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Bob Duff gcc/ada/ * libgnat/a-ststbo.adb (Write): Replace pragma Assert with "if ... raise Constraint_Error".--- gcc/

[Ada] Further cleanup in constraint checking code for allocators

2020-06-19 Thread Pierre-Marie de Rodat
There is a second case where Expand_N_Assignment_Statement was applying range checks for allocators and it is also obsolete. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Eric Botcazou gcc/ada/ * exp_ch5.adb (Expand_N_Assignment_Statement): Do n

[Ada] Crash on compiling project with multiple subunits per file

2020-06-19 Thread Pierre-Marie de Rodat
This patch fixes the compiler whereby a project with manually specified Naming for subunits such that several of the subunits exist in the same file as the unit they are defined in. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-19 Justin Squirek gcc/ada/ * lib.adb (Check_

[Ada] AI12-0376 Relax RM 13.1(10) rule wrt primitive operations

2020-07-06 Thread Pierre-Marie de Rodat
After discussions at the ARG, the rule in RM 13.1(10) limiting representation aspects on derived types is removed by AI12-0376. It has also been confirmed that Default_Component_Value is a representation aspect. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * aspects.ads (I

[Ada] Wording problems with predicates (AI12-0099)

2020-07-06 Thread Pierre-Marie de Rodat
AI12-0099 corrects the RM wording for two issues. One is that the "not" operator is allowed in predicate-static expressions, which is already supported properly by GNAT. The other is that predicates get inherited in the case of concurrent types that extend from an interface with a predicate. For t

[Ada] Remove special case for processing null range in GNATprove

2020-07-06 Thread Pierre-Marie de Rodat
Historically both low and high range bounds were resolved with the range type, but we decided to resolve high bound with the range's base type. This appears to be necessary for having proper range checks in GNATprove mode, especially for null ranges, but it is no longer needed. This patch reverts

[Ada] Remove obsolete code in Eval_Attribute

2020-07-06 Thread Pierre-Marie de Rodat
The procedure does not deal with run-time checks at all, except in a very peculiar case, 'Pos applied to an integer type, causing multiple checks to be generated for this case. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Eval_Attribu

[Ada] Visibility error with aggregate in Declare_Expression

2020-07-06 Thread Pierre-Marie de Rodat
The local objects declared in a Declare_Expression must be available when the expression is resolved. THis patch makes these objects visible during resolution, by reinstalling the scope created during prior analysis of the Declare_Expression. This scope exists only for visibility processing and pl

[Ada] Fix evaluation of Enum_Rep applied to imported constant

2020-07-06 Thread Pierre-Marie de Rodat
Fixes an illegal call to Compile_Time_Known_Value with Empty parameter, which is now reported as a crash with switch -gnatdk. This is clearly a corner case; in preparation for a cleanup of some dubious code for Enum_Rep attribute. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Small cleanup throughout Exp_Ch9

2020-07-06 Thread Pierre-Marie de Rodat
This mostly replaces verbose lines with calls to the Entry_Index_Type accessor functions and also changes Collect_Entry_Families to using the same method as Build_Entry_Count_Expression to determine whether an entry family is large. No functional changes. Tested on x86_64-pc-linux-gnu, committed

[Ada] Predicates and the current instance of a subtype (AI12-0068)

2020-07-06 Thread Pierre-Marie de Rodat
AI12-0068 defines a reference to a current instance occurring in an aspect_specification of a type or subtype to be a value, not an object. This means that a Constrained attribute in such a context is always True. It also means that attributes that take a prefix that must be an object are illegal

[Ada] Refine use of access types in unnesting

2020-07-06 Thread Pierre-Marie de Rodat
When we pass an unconstrained value in an activation record, we pass it an access type instead of an address so that we can get the bounds in the nested subprogram. However, the current code does this only when the uplevel reference is a parameter and uses 'Access. There are cases, as introduced

[Ada] Fix bad interaction between Unchecked_Conversion and limited type

2020-07-06 Thread Pierre-Marie de Rodat
This prevents the compiler from aborting or crashing on the instantiation of Unchecked_Conversion on a limited type which is passed the result of a function call. The semantics of this operation are not very clear and the programmer is essentially on his/her own here, but the compiler should try to

[Ada] Set range checks flag on 'Update for GNATprove in expansion

2020-07-06 Thread Pierre-Marie de Rodat
Range check flag on scalar expression in attribute Update was originally set when this attribute is expanded into a sequence of assignment. However, in GNATprove mode we have a custom expansion, which does nothing with attribute Update; in particular, it didn't set the required range check. As a wo

[Ada] Crash on declaration with aggregate for unchecked union

2020-07-06 Thread Pierre-Marie de Rodat
This patch fixes a compiler abort on an object declaration whose expression is an aggregate for an unchecked union type. A declaration for an object of such a type is otherwise treated as a renaming of the expression (typically an object of the type), but this does work for an aggregate, which must

[Ada] Crash on derived type with rep. clause and renamed discriminant

2020-07-06 Thread Pierre-Marie de Rodat
This patch fixes a compiler abort on a declaration of subtype of a derived type DT whose declaration renames a discriminant of its parent type T, when there is a record representation clause for DT. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch5.adb (Find_Component)

[Ada] Improve run-time performance for large initialized allocators

2020-07-06 Thread Pierre-Marie de Rodat
This extends the optimization applied to large aggregates used to reset array objects to the case of allocators initialized by such aggregates. The aggregates must essentially satisfy the same conditions as in the former case, although aggregates explicitly giving the bounds of the allocation are

[Ada] Hang on generic declaration with ambiguous formal package

2020-07-06 Thread Pierre-Marie de Rodat
This patch fixes the compiler whereby malformed code featuring a generic package declaration with a formal package may result in an infinite loop when the name of the formal package is hidden by the formal parameter itself. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem

[Ada] Crash when an exception handler is executed with -gnatdk

2020-07-06 Thread Pierre-Marie de Rodat
In few routines we expect exceptions and handle them by falling back to an appropriate safe value (e.g. in Compile_Time_Known_Value we fall back to False and merely skip some optimizations). This is especially important while processing code with previous errors. However, this behaviour prevents u

[Ada] Use Stream_Element_Arrays internally for secure hash computations

2020-07-06 Thread Pierre-Marie de Rodat
Refactor share code for secure hash computations to use Stream_Element_Array instead of String as the internal buffer type. This resolves an issue where we would overlay a String on a user provided Stream_Element_Array when that user array is larger than the largest possible String. Tested on x86_

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