[Ada] Issue with unnesting of 'First/Last and renaming

2020-06-08 Thread Pierre-Marie de Rodat
If we're doing 'First or 'Last on a renamed variable, the backend may look at either the Etype of the variable or that of what it was renaming, so check both to see if we need to place it into the activation record. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Richard Kenner g

[Ada] Implement predicate checks on qualified expressions (AI12-0100)

2020-06-08 Thread Pierre-Marie de Rodat
Predicate checks are required by AI12-0100 when evaluating qualified expressions where the qualifying subtype has such checks. Errors rather than warnings must be issued on static qualified expressions and type conversions that violate a static predicate, so that's corrected here. There were also c

[Ada] Silence spurious warning on instances of formal vectors

2020-06-08 Thread Pierre-Marie de Rodat
Use pragma Warnings to silence a spurious warning that may occur in instances of formal vectors. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Claire Dross gcc/ada/ * libgnat/a-cofove.adb (Insert_Space): The computation of Index generates a spurious compiler wa

[Ada] Restore Snames.Name_SPARK as it used in the GNATprove backend

2020-06-08 Thread Pierre-Marie de Rodat
The Name_SPARK constant is no longer used in GNAT to implement the SPARK_05 restriction, but is still used in GNATprove to detect whether the SPARK.Heap unit has been explicitly WITH-ed. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Piotr Trojanek gcc/ada/ * snames.ads

[Ada] Spurious error on call to controlled primitive

2020-06-08 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby calls to controlled primitives for types which extend generic formals may be flagged at compile-time as being non-visible. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Justin Squirek gcc/ada/ * sem_ch4.adb (Analyze_One_Call): Add e

[Ada] Implement AI12-0291 (Jorvik profile)

2020-06-08 Thread Pierre-Marie de Rodat
The Jorvik profile is a newly defined profile, similar to the Ravenscar profile but less restrictive in some cases. It differs from the Ravenscar profile only in the removal of six restrictions and the relaxation of one (Ravenscar's Simple_Barriers restriction is replaced with a Pure_Barriers restr

[Ada] AI12-0085 Missing aspect cases for Remote_Types

2020-06-08 Thread Pierre-Marie de Rodat
This change adds a missing check on setting aspects Storage_Size and Storage_Pool on remote access-to-class-wide types. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Arnaud Charlet gcc/ada/ * sem_cat.ads: Fix typo. * sem_cat.adb (Validate_Remote_Access_To_Class

[Ada] Fix handling of 'Enum_Rep and renamings

2020-06-08 Thread Pierre-Marie de Rodat
Most cases were actually handled fine thanks to some special handling in exp_attr.adb, but cases of e.g. a renaming of renaming were not handled properly. Taking this opportunity to simplify the code and remove special cases by actually adding support for 'Enum_Rep directly in Eval_Type_Conversion.

[Ada] Implement AI12-0290 (Simple_Barriers restriction)

2020-06-08 Thread Pierre-Marie de Rodat
Change the existing implementation of the Simple_Barriers restriction to conform to the rules given in AI12-0290. Note that the new rules are in some cases more restrictive than the old rules (so that previously accepted barriers might now be rejected). For example, references to non-component subc

[Ada] Port a modified expansion of Enum_Rep from GNAT to GNATprove

2020-06-08 Thread Pierre-Marie de Rodat
Expansion of Enum_Rep in GNATprove is meant to be a subset of the expansion in GNAT, so it needs to be kept in sync with the frontend. Semantics of the compiler is not affected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Piotr Trojanek gcc/ada/ * exp_spark.adb (Expa

[Ada] AI12-0204 Renaming of a prefixed view

2020-06-08 Thread Pierre-Marie de Rodat
AI12-0204 clarified that the prefix of a prefixed view that is renamed or passed as a formal subprogram must be renamable as an object and similarly (was already checked by GNAT), the prefix of a prefixed view that has an implicit 'Access must be legal for 'Access and a generalized_indexing is ille

[Ada] Remove the Has_Dynamic_Range_Check flag

2020-06-08 Thread Pierre-Marie de Rodat
The flag was made obsolete some time ago and no fallout has been detected since then, so this change finally removes it. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Eric Botcazou gcc/ada/ * atree.adb (New_Copy): Do not clear Has_Dynamic_Range_Check. * checks.

[Ada] Implement AI12-0073 (Ravenscar disallows Synchronous_Barriers)

2020-06-08 Thread Pierre-Marie de Rodat
In Ada2020 the Ravenscar profile (but not the Jorvik profile) includes a "No_Dependence => Ada.Synchronous_Barriers" restriction. This is a binding interpretation so it applies also to earlier Ada versions, but the unit Ada.Synchronous_Barriers did not exist before Ada 2012. Tested on x86_64-pc-li

[Ada] Spurious error on instantiations with Taft_Amendment types and tasks

2020-06-09 Thread Pierre-Marie de Rodat
An access type whose designated type is an incomplete or class-wide type may end up designating a task type or a type with a task component. It is then necessary to associate the access type with the Master of the tasks that may be generated on an allocator for that access type. This is done by cre

[Ada] Remove bypass for instance bodies from Is_Visible_Component

2020-06-09 Thread Pierre-Marie de Rodat
This removes an obsolete bypass present for long in the predicate Is_Visible_Component, which is responsible for determining whether a component present in a private tagged record type is visible in its extensions. This bypass would essentially always return true in bodies of instances, but there

[Ada] Ada2020: AI12-0301 Predicates and Default_Value

2020-06-09 Thread Pierre-Marie de Rodat
This AI clarifies that predicate checks apply at object declaration for types that contain components with a Default_Value or Default_Component_Value. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * sem_util.ads, sem_util.adb (Is_Partially_Initi

[Ada] Refine implementation of AI05-0149 missing conversion checks

2020-06-09 Thread Pierre-Marie de Rodat
We were accepting conversion from anon-access-T'Class to access-all-T which is incorrect. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * sem_type.adb (Covers): Fix implementation of AI05-0149. * sem_res.adb: Fix typo.--- gcc/ada/sem_res

[Ada] Ada2020 AI12-0282: Shared variable control aspects in generics

2020-06-09 Thread Pierre-Marie de Rodat
This patch refines the checks and the corresponding error messsages on the legality of instantiations where some formal objects and their corresponding actuals may carry Atomic, Atonic_Components, Volatile, Volatile_Components, Independent, or Independent_Components aspect specifications. The lega

[Ada] Annotate Ada.Synchronous_Barriers with SPARK_Mode => Off

2020-06-09 Thread Pierre-Marie de Rodat
Synchronous barriers are currently not supported by GNATprove (i.e. it doesn't recognize that they are initialized by synchronous). They are specifically detected and rejected as not-in-SPARK, but it is more elegant to annotate the Ada.Synchronous runtime library unit with SPARK_Mode => Off. Compi

[Ada] Spurious overlap error on zero-sized arrays with -gnateV

2020-06-09 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby the compiler would incorrectly generate checks for overlapping formals (-gnateV) leading to spurious runtime errors when a zero-sized array actual gets passed alongside another formal declared in the same region. Tested on x86_64-pc-linux-gnu, committed on trun

[Ada] Crash on exit statement within predicated loop

2020-06-09 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby the compiler would crash if it encountered an exit statement featuring a loop identifier where such referenced loop iterates through a predicated type. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Justin Squirek gcc/ada/ * exp_ch5.

[Ada] Write_Invocation_Graph_Vertex: include lib item name

2020-06-09 Thread Pierre-Marie de Rodat
Make each invocation graph point to the corresponding library graph. Use this information in Write_Invocation_Graph_Vertex to print out the name of the library item containing this vertex. For procedures that take both the library graph and invocation graph as parameters, remove the library graph

[Ada] Add debugging message

2020-06-09 Thread Pierre-Marie de Rodat
When raising Program_Error due to an incorrect Kind transition, print a more informative debugging message. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Bob Duff gcc/ada/ * bindo-graphs.adb (Add_Edge_Kind_Check): Add the Image of the old and new Kinds to the r

[Ada] Membership test against a non-excluding subtype

2020-06-09 Thread Pierre-Marie de Rodat
GNAT ignores the null exclusion property of the target access type in a membership test (e.g. Ptr in Null_Excluding_Ptr_Type), this is fixed here. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_ch4.adb (Expand_N_In): Fix handling of null ex

[Ada] gnatbind: Correct assertions in Add_Edge_Kind_Check

2020-06-09 Thread Pierre-Marie de Rodat
This patch corrects the assertions in Add_Edge_Kind_Check. In particular, a spec-->body edge can come from an Invocation_Edge or a Forced_Edge in case of cycles. Other edges are added in a certain order. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Bob Duff gcc/ada/

[Ada] Disable assertion regarding Body_Before_Spec_Edge

2020-06-09 Thread Pierre-Marie de Rodat
This patch disables a sometimes-failing assertion. The assertion is failing because there is an invocation edge spec-->body, and then we later add a Body_Before_Spec_Edge for the SCC computation. This is a temporary fix; we need to investigate why the spec-->body invocation edge exists. Tested on

[Ada] Improve handling of null unbounded strings

2020-06-09 Thread Pierre-Marie de Rodat
This is a useful optimization to avoid contention around the shared empty string. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * libgnat/a-strunb__shared.ads, libgnat/a-strunb__shared.adb (Reference, Unreference): No-op for Empty_Shared

[Ada] Improve handling of aggregates in Side_Effect_Free

2020-06-09 Thread Pierre-Marie de Rodat
Side_Effect_Free was always assuming an aggregate isn't side effects free, but we can do better by taking advantage of the Compile_Time_Known_Aggregate flag. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_util.adb (Side_Effect_Free): Improv

[Ada] Implement AI12-0028: Import of variadic C functions

2020-06-09 Thread Pierre-Marie de Rodat
This implements the support for the new C_Variadic_n conventions, n ranging from 0 to 16, in all versions of the language since the AI is a binding interpretation. These new conventions are meant to be used in conjunction with the Import aspect/pragma to call variadic C functions with the special

[Ada] Expand more others aggregates statically

2020-06-09 Thread Pierre-Marie de Rodat
Now that there is no artifical limit on Convert_To_Positional, we use the same heuristics than in Aggr_Size_OK, to share the code and to generate static aggregates in more cases. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_aggr.adb (Max_

[Ada] Small cleanup in Einfo unit

2020-06-09 Thread Pierre-Marie de Rodat
This moves around the declarations of functions that are not in the right category, adds pragma Inline for others and fixes alphabetization issues. This also clearly splits the functions subject to pragma Inline from the procedures subject to the pragma, the former being read by XEINFO but not the

[Ada] Code clean ups and comments updates

2020-06-09 Thread Pierre-Marie de Rodat
We identify all the places where error messages are issued in the expander and should be issued in semantic analysis instead, for future clean ups. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_ch3.adb, exp_ch4.adb, exp_ch6.adb, exp_ch9.ad

[Ada] Missing check on private overriding of dispatching primitive

2020-06-09 Thread Pierre-Marie de Rodat
When a dispatching operation overrides an inherited subprogram, it must be subtype conformant with the inherited subprogram. Such check is not performed by the frontend on overriding primitives of private types which are declared before the full type declaration of the private type. Tested on x86

[Ada] Propagate DIC, Invariant and Predicate attributes to views

2020-06-09 Thread Pierre-Marie de Rodat
This change is a step towards propagating more consistently the DIC, Invariant and Predicate attributes between different views of the same type, in particular to the newly built underlying full views. It also cleans up the handling of the base types for the DIC and Invariant attributes, which loo

[Ada] Fix wrong type being used for range check generation

2020-06-09 Thread Pierre-Marie de Rodat
Before this commit, GNAT would use the type of the expression rather than that of the subtype mark in order to decide whether it should generate range checks or not. This means that in some cases, GNAT would decide that no range checks were needed, which was wrong. This issue went mostly unnoticed

[Ada] Ada2020 AI12-0282: Shared variable control aspects in generics

2020-06-09 Thread Pierre-Marie de Rodat
This patch further refines the checks and the corresponding error messsages on the legality of instantiations where some formal types and their corresponding actuals may carry Atomic, Volatile, etc. aspect specifications. The legality rules stated in RN 6.1 (12/5) are in fact backward-incompatibl

[Ada] Remove kludge for AI05-0087

2020-06-09 Thread Pierre-Marie de Rodat
This is a code clean up as part of removing all calls to Error_Msg* in the expander. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_ch5.adb (Expand_N_Assignment): Remove kludge for AI05-0087. * sem_ch12.adb (Validate_Derived

[Ada] Remove unreferenced GNATprove utility routine Get_Low_Bound

2020-06-10 Thread Pierre-Marie de Rodat
Routine Get_Low_Bound was added to frontend while moving utility routines from the GNATprove backend, but it is no longer referenced. (Surprisingly, there is no Get_High_Bound routine anywhere). Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Piotr Trojanek gcc/ada/ * se

[Ada] Reject illegal bodies for null procedures

2020-06-10 Thread Pierre-Marie de Rodat
The `if Token = ...` condition was added when aspect specifications were introduced in GNAT: aspect specification parsing is done as part of subprogram declaration parsing, and so once aspect specifications are parsed, it is necessary to re-start the subprogram declaration-parsing autotmata. But re

[Ada] Fix assertion failure on functions with contracts

2020-06-10 Thread Pierre-Marie de Rodat
This commit fixes a bug introduced in a previous commit that attempted to detect illegal body definitions on null procedures but did not account for the fact that function definitions such as `function F return Integer with Global => null is` could use the same path. This would result in an asserti

[Ada] Incorrect accessibility checks on functions calls

2020-06-10 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby the compiler would issue incorrect accessibility errors and checks for objects initialized by functions returning anonymous access types or type conversions where the operand is a function returning an anonymous access type. Tested on x86_64-pc-linux-gnu, commi

[Ada] Simplify detection of static membership choices

2020-06-10 Thread Pierre-Marie de Rodat
Membership test operators (i.e. "in" and "not in") have either the right operand present (when there is just one choice) or the list of alternatives present (when there are many choices), as documented in sinfo.ads. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Piotr Trojanek g

[Ada] Fix incorrect insertion of post-call actions in if-expression

2020-06-10 Thread Pierre-Marie de Rodat
When post-call actions need to be inserted in an expression context, an N_Expression_With_Actions node is used. That's not done here for the condition of an if-expression, so the change adds this case. It also deals with the case of a call to a primitive of a tagged type written in prefixed notat

[Ada] Classwide controlled obj not dispatching

2020-06-10 Thread Pierre-Marie de Rodat
Overriding dispatching primitives Initialize, Adjust or Finalize of a controlled type by means of a subprogram body that has no specification causes the frontend to initialize incorrectly the dispatch table slots of these primitives. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 J

[Ada] Revert workaround for expansion of Enum_Rep in GNATprove mode

2020-06-10 Thread Pierre-Marie de Rodat
A workaround for a bug in expansion of Enum_Rep attribute in the GNATprove mode was to expand First and Last attributes. Now with handling of Enum_Rep fixed we don't need this workaround anymore. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Piotr Trojanek gcc/ada/ * e

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

2020-06-10 Thread Pierre-Marie de Rodat
This patch implements AI12-0220, which adds contracts to Access_To_Subprogram types so that pre/postconditions are applied to all indirect calls through such an access type. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Ed Schonberg gcc/ada/ * einfo.ads (Access_Subprog

[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

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