[Ada] Improve code generated for dynamic discriminated aggregate

2020-06-10 Thread Pierre-Marie de Rodat
This changes the way some assignments of aggregates of dynamic discriminated record types are expanded by the front-end: they used to always give rise to the creation of a temporary, which is unnecessary if the by-copy semantics can be guaranteed. This also puts the treatment of qualified aggregat

[Ada] Remove Determine_License

2020-06-10 Thread Pierre-Marie de Rodat
The routine Determine_License is brittle and doesn't e.g. handle properly wide characters. Furthermore this is just a heuristic, which isn't really needed, so remove it to simplify maintenance and remove latent issues with wide characters. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06

[Ada] Fold Enum_Rep attribute in evaluation and not in expansion

2020-06-10 Thread Pierre-Marie de Rodat
Folding of Enum_Rep attribute was partly done in evaluation (for expressions like "Typ'Enum_Rep (Enum_Literal)") and partly in expansion (for expressions like "Enum_Literal'Enum_Rep". Moreover, some of the code in evaluation was dead and some of the code in expansion was violating internal assertio

[Ada] Disable unwanted warnings in Assertion_Policy(Ignore) mode

2020-06-10 Thread Pierre-Marie de Rodat
This patch fixes a bug where if pragma Assertion_Policy(Ignore) is in effect, if the only reference to a given declaration is in an Invariant, spurious warnings about unused entities are given. For example, if a compilation unit says "with X;", and the only reference to X is in an invariant, the co

[Ada] Add missing Sloc on new explicit dereferences

2020-06-10 Thread Pierre-Marie de Rodat
This makes sure that a Sloc is put on the dereferences inserted by the new procedure Copy_And_Maybe_Dereference. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Eric Botcazou gcc/ada/ * sem_util.adb (Copy_And_Maybe_Dereference): Temporarily copy

[Ada] Insert explicit dereferences when building actual subtype

2020-06-10 Thread Pierre-Marie de Rodat
This plugs the only loophole in the front-end through which implicit dereferences can reach the code generator without having being turned into explicit ones. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Eric Botcazou gcc/ada/ * sem_util.adb (C

[Ada] Remove obsolete code in Resolve_Call

2020-06-10 Thread Pierre-Marie de Rodat
This removes a block of code in Resolve_Call that inserts an explicit dereference for a call whose prefix is an access-to-subprogram type, but this processing is already done earlier in Analyze_Call. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Eric Botcaz

[Ada] Additional warnings on overlapping actuals of composite types

2020-06-10 Thread Pierre-Marie de Rodat
This patch enhances the warnings on overlapping actuals of composite types when only one of them is writable. If these parameters are passed by reference it is the case that assignment to one could have the undesirable effect of modifying the other inside the called subprogram. Tested on x86_64-pc

[Ada] AI12-0311 New checks for language-defined units

2020-06-10 Thread Pierre-Marie de Rodat
This Ada 202x AI defines among other things new check names. Recognize them as no-ops for now. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Arnaud Charlet gcc/ada/ * snames.ads-tmpl (Name_Characters_Assertion_Check, Name_Containers_Assertion_Check, Na

[Ada] Implement AI12-0162 Memberships and Unchecked_Unions

2020-06-10 Thread Pierre-Marie de Rodat
This makes sure that the semantics specified by this AI is observed by using an expression with actions in order to insert the PE raise statement in a membership context with multiple choices. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Eric Botcazou gcc/ada/ * exp_c

[Ada] Ada 202x AI12-0192 "requires late initialization"

2020-06-10 Thread Pierre-Marie de Rodat
Working on this AI it appeared that GNAT wasn't implementing the Ada 2012 notion of "require late initialization", so plug this hole and implement the new rule from AI12-0192 at the same time. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Arnaud Charlet gcc/ada/ * exp_

[Ada] Don't build equivalent record aggregate if type has predicates

2020-06-10 Thread Pierre-Marie de Rodat
Building equivalent record aggregates when the type of the aggregate has predicate functions can result in Gigi crashes if the type hasn't been frozen yet. Since Build_Equivalent_Record_Aggregate is an optimization, it's ok to disable it when encountering aggregates with predicates. Tested on x86_

[Ada] AI12-0364 Add a modular atomic arithmetic package

2020-06-10 Thread Pierre-Marie de Rodat
This new Ada 202x AI introduces a new package Modular_Arithmetic. Related discussion also suggested to rename the recently introduced Arithmetic package -> Integer_Arithmetic, for consistency, so this is done at the same time. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Arnaud C

[Ada] Remove useless code in Backend_Processing_Possible

2020-06-11 Thread Pierre-Marie de Rodat
The call to Set_Size_Known_At_Compile_Time in Backend_Processing_Possible happened just after querying Size_Known_At_Compile_Time several lines before. Both calls operated on the same type entity, so the call to "Set" routine had no effect and now is removed. Tested on x86_64-pc-linux-gnu, committ

[Ada] AI12-0356 Root_Storage_Pool_With_Subpools & Preelaborable_Init

2020-06-11 Thread Pierre-Marie de Rodat
This Ada 202x AI clarifies that Root_Storage_Pool_With_Subpools and Root_Subpool should have pragma Preelaborable_Initialization. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Arnaud Charlet gcc/ada/ * libgnat/s-stposu.ads (Root_Storage_Pool_With_Subpools, Root

[Ada] Fix unnesting crash with Predicate_Failure/no pred

2020-06-11 Thread Pierre-Marie de Rodat
This patch fixes a bug where if you have a Predicate_Failure aspect on a nested type, but no Predicate, Static_Predicate, or Dynamic_Predicate, the compiler crashes when compiled with assertions enabled. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Bob Duff gcc/ada/ *

[Ada] Refine type for sorting case-choices tables

2020-06-11 Thread Pierre-Marie de Rodat
Tables with case-choices are sorted by Sort_Case_Table with an insertion sort. Contrary to what comments for the Case_Table_Type says, this routine doesn't use the table element at index 0 as a placeholder. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Piotr Trojanek gcc/ada/

[Ada] Generate predicate checks for on assignments in records

2020-06-11 Thread Pierre-Marie de Rodat
When an assignment of an allocator the type of which has predicate checks is made inside of a record, GNAT generates a call to the predicate function. However, before this commit, GNAT wouldn't check if the subtype mark had a predicate, which would result in the predicate check function not being c

[Ada] Missing accessibility error on object in type conversion

2020-06-11 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby the compiler would incorrectly calculate accessibility levels of objects within type conversions - leading to potentially missing static and dynamic errors. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Justin Squirek gcc/ada/ * sem

[Ada] Make Object Specific Dispatch tables constant

2020-06-11 Thread Pierre-Marie de Rodat
Internally generated static dispatch tables are preferably put in ROM, so they are declared as constant where possible. However, the Object Specific Dispatch tables were declared as variables, even though they are initialized with static aggregates (with only literal integers) and are never modifie

[Ada] Simplify iteration over formal parameters for aliasing error

2020-06-11 Thread Pierre-Marie de Rodat
When iterating over pairs of formal parameters we now finish as soon as we find a single problematic pair; previously we continued iteration. This is just a simplification and a compiler performance improvement. Semantics is not affected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-

[Ada] Remove a dubious optimization for Object Specific Data dispatching

2020-06-11 Thread Pierre-Marie de Rodat
Routines Sem_Aggr.Build_Constrained_Itype and Sem_Ch3.Build_Subtype that create discriminated itypes were originally identical, but now they are subtly different. This patch removes one of their two subtle differences, namely a call to Set_Size_Known_At_Compile_Time that was meant as a very narrow

[Ada] Create constrained itypes for nested record aggregates

2020-06-11 Thread Pierre-Marie de Rodat
When resolving a record aggregate with a box as the value of one of its component that is itself of a discriminated record type, this box is replaced with an inner record aggregate. However, while a constrained itype is created for the outer record aggregate (as described in the comment of Resolve_

[Ada] Refine type of a counter-like variable

2020-06-11 Thread Pierre-Marie de Rodat
A local variable that is used as a counter (which is clear from both its comment and its used) will only be assigned with natural numbers. This is now reflected in its type. Code cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Piotr Trojanek

[Ada] Avoid "others => <>" association in resolved record aggregates

2020-06-11 Thread Pierre-Marie de Rodat
When resolving record aggregates, frontend was creating "others => <>" association to represent nested components, for example: type T1 (D1 : Boolean := False) is record C1 : Boolean := True; end record; type T2 is record C2 : T1; end record; X2 : T2 := (others => <>);

[Ada] Move duplicated routines for building itypes to Sem_Util

2020-06-11 Thread Pierre-Marie de Rodat
Routine Build_Constrained_Itype was created as an exact duplicate Build_Subtype with a comment suggesting that their code should be exported from Sem_Util and reused. Unfortunately, since then both routines diverged and now are subtly different, so reusing is not straightforward. However, it is sti

[Ada] Iterate with procedural version of Next routine where possible

2020-06-11 Thread Pierre-Marie de Rodat
Routine Next is implemented both as a procedure and as a function. The procedure variant seems meant to be used when iterating, e.g.: Next (Decl); because it is more readable than the corresponding functions: Decl := Next (Decl); (and it is inlined anyway, so there is no performance penal

[Ada] Consolidate handling of implicit dereferences into semantic analysis

2020-06-11 Thread Pierre-Marie de Rodat
This consolidates the handling of almost all the implicit dereferences allowed in Ada 95 into the semantic analysis phase of the compiler, and more precisely in the Resolve routine of the front-end. This both means that the generic code handling them in the expander is removed, and that various co

[Ada] Skip unnecessary iterations over constraint expressions

2020-06-11 Thread Pierre-Marie de Rodat
When looking for references to discriminants within constraint expressions we now stop once the first such a reference is found. This is just a tiny performance improvement; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Piotr Trojanek gcc/ada/

[Ada] Additional warnings on overlapping actuals of composite types

2020-06-11 Thread Pierre-Marie de Rodat
This patch refines the handling of warnings on overlapping actuals of composite types when only one of them is writable. Formals of a generic type are excluded, given that the warning will be given on any instance. Uniform treatment of formals and actuals. Tested on x86_64-pc-linux-gnu, committed

[Ada] Put_Image attribute

2020-06-11 Thread Pierre-Marie de Rodat
Work around the fact that Put_Image doesn't work for private types whose full type is real. Make Put_Image_Unknown print out the name of the type. Put_Image is still disabled by default for all types. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Bob Duff gcc/ada/ *

[Ada] Refine type of a routine parameter from Node_Id to Entity_Id

2020-06-11 Thread Pierre-Marie de Rodat
Routine Get_Value is only called with its Compon parameter equal to entity ids of components. This is now reflected in the type of this parameter. Code cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Piotr Trojanek gcc/ada/ * sem_a

[Ada] Allow specifying volatility refinement aspects for types

2020-06-11 Thread Pierre-Marie de Rodat
Previously, the four aspects Async_Readers, Async_Writers, Effective_Reads, and Effective_Writes could only be specified for volatile variables and for state abstractions. Allow specifying these aspects for volatile types. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Steve Baird

[Ada] Update SPARK RM rule numbers after removing a redundant rule

2020-06-11 Thread Pierre-Marie de Rodat
SPARK RM 7.1.3(8) has been deleted, but there were actually plenty of mistakes in references to rules 7.1.3(X). This patch fixes them in both comments and error messages. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Piotr Trojanek gcc/ada/ * sem_ch4.adb, sem_ch6.adb,

[Ada] Fix wrong access to large bit-packed arrays with reverse SSO

2020-06-11 Thread Pierre-Marie de Rodat
Large bit-packed arrays, i.e. whose size is greater than 64 bits, are implemented under the hood by means of arrays of storage units, the front-end generating the required mask-and-shifts operations to go back and forth between the two representations. These operations depend on the endianness of

[Ada] Fix assertion failure on entry call through unchecked conversion

2020-06-11 Thread Pierre-Marie de Rodat
The Safe_Unchecked_Type_Conversion predicate was invoking the Has_Discriminant predicate without checking that the Etype really Is_Type, which is not the case for Standard_Void_Type "returned" by entry calls. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Er

[Ada] Fix missing insertion of explicit dereference in instance

2020-06-11 Thread Pierre-Marie de Rodat
This adjusts the new Resolve_Implicit_Dereference procedure to the cases where nodes in an instance do not have the proper view of a type that was declared as private (a well-known limitation of the current implementation of generic instantiations for types that are only implicitly referenced in th

[Ada] Put_Image attribute

2020-06-11 Thread Pierre-Marie de Rodat
Work around bug in Put_Image of types in Remote_Types packages. Use the switch -gnatd_z to control enabling of Put_Image. Put_Image is still disabled by default for all types. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-11 Bob Duff gcc/ada/ * exp_put_image.adb (Build_

[Ada] Ada2020: update Big_Numbers.* specs

2020-06-12 Thread Pierre-Marie de Rodat
This patch updates the Put_Image facilities in the Big_Numbers packages to match the actual implementation of Put_Image. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Bob Duff gcc/ada/ * libgnat/a-nbnbin.adb, libgnat/a-nbnbin.ads, libgnat/a-nbnbin__gmp.adb, lib

[Ada] Implement AI12-0269 No_Return for functions

2020-06-12 Thread Pierre-Marie de Rodat
This implements the AI under the -gnat2020 switch, which extends the Ada 2005 No_Return aspect/pragma to functions and generic functions. As explained in the AI, functions subject to this aspect/pragma must still have a return statement, but it must be of a specific form. This also fixes the imple

[Ada] Small cleanup in handling of Ada 2012 implicit dereferences

2020-06-12 Thread Pierre-Marie de Rodat
This aligns the handling of Ada 2012 implicit dereferences in the Is_OK_Variable_For_Out_Formal predicate wih that in Is_Variable, and removes unreachable code as a result. This also makes more use of the Get_Reference_Discriminant helper function to retrieve the reference discriminant of a type.

[Ada] Put_Image attribute

2020-06-12 Thread Pierre-Marie de Rodat
Enable Put_Image for types that don't cause regressions (which is most types). Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Bob Duff gcc/ada/ * debug.adb: Remove usage of -gnatd_z. * exp_attr.adb, exp_put_image.ads, exp_put_image.adb: Clean up the enab

[Ada] Simplify getting discriminant value from a list of constraints

2020-06-12 Thread Pierre-Marie de Rodat
Routine Get_Discr_Value takes a name of a discriminant, not its entity, so its parameter should be a Node_Id, not an Entity_Id. Also, fix typo in its comment and refactor repeated calls in the body. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Piotr Troja

[Ada] Remove suppression for overlapping actuals in internal units

2020-06-12 Thread Pierre-Marie de Rodat
Detection of overlapping actuals was suppressed for internal units, because we were getting spurious warnings on container units. Now this suppression has no effect (most likely because ignore parameters of generic types). Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Piotr Trojan

[Ada] Reuse Is_Entry where possible

2020-06-12 Thread Pierre-Marie de Rodat
Replace a low-level membership test "Ekind_In (Id, E_Entry, E_Entry_Family)" with a high-level "Is_Entry (Id)", which is more readable. Semantics stays the same. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Piotr Trojanek gcc/ada/ * contracts.adb, einfo.adb, sem_ch4.a

[Ada] Detect overlapping actuals in entry calls

2020-06-12 Thread Pierre-Marie de Rodat
For subprograms we call Warn_On_Overlapping_Actuals in Resolve_Call; however, for protected entries we didn't call it at all, because Resolve_Call was executing Resolve_Entry_Call and returning early. As a result, we didn't detect overlapping actuals in entry calls. Now we do. Tested on x86_64-pc-

[Ada] Diagnose illegal overriding indicators in protected bodies

2020-06-12 Thread Pierre-Marie de Rodat
This patch adds checks to reject illegal overriding indicators that appear on subprogram declarations in protected bodies, where such a subprogram cannot override any operation. Fixes ACATS test B831006. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Ed Schonberg gcc/ada/

[Ada] ACATS 4.2Q - BDD2007

2020-06-12 Thread Pierre-Marie de Rodat
This acats test shows that we are not checking 13.1(9.2/5) for representation aspects, now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Arnaud Charlet gcc/ada/ * aspects.ads (Is_Representation_Aspect): New array. * sem_ch13.adb (Analyze_Aspect_Specifica

[Ada] Compiler crash on instance with overloaded actual and aspects

2020-06-12 Thread Pierre-Marie de Rodat
This patch fixes a crash in the compiler when handling an instantiation with a formal subprogram that carries an aspect specification, when the actual in the instantiation is an overloaded name. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Ed Schonberg gcc/ada/ * sem_

[Ada] Compiler locks up with -gnatX and formal subprogram with aspects

2020-06-12 Thread Pierre-Marie de Rodat
This patch fixes an infinite loop in the compiler on an instantiation that includes formal packages and formal subprograms with aspect specifications (but no pre- or postconditions), when compiling with -gnatX. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Ed Schonberg gcc/ada

[Ada] Bump secondary stack alignment factor in full runtimes

2020-06-12 Thread Pierre-Marie de Rodat
Use Standard'Maximum_Alignment * 2 unconditionally to accommodate possible requirements by user code compiled with specific cpu/arch options such as -mavx on x86 targets, which Gigi assumes the SS can handle. Such options influence what Standard'Maximum_Alignment returns and are typically not used

[Ada] ACATS 4.1Q - CDD2A04 - RLS not followed

2020-06-12 Thread Pierre-Marie de Rodat
The required level of support for elementary streaming includes support for 24 bits elements, which is added here. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-12 Arnaud Charlet gcc/ada/ * exp_strm.adb (Build_Elementary_Input_Call): Add support for 24 bits elemen

[Ada] Remove redundant iterations in checks for overlapping actuals

2020-06-12 Thread Pierre-Marie de Rodat
We were detecting overlapping actuals in a call like "Proc (A, B, C)" using two loops that iterated over all parameters, so we were examining 9 pairs: A-A, A-B, A-C B-A, B-B, B-C C-A, C-B, C-C Now the outer loop iterates over all parameters, while the inner loop always starts from the next

[Ada] Implement AI12-0175 Preelaborable packages with address clauses

2020-06-12 Thread Pierre-Marie de Rodat
This implements the AI under the -gnat2020 switch, which extends the set of calls that can be made during the elaboration of library units subject to the aspect/pragma Preelaborate, beyond the existing ones to static functions. Calls to certain functions that are essentially unchecked conversions

[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

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