[Ada] Time_IO.Image: Allow printing the time zone

2020-07-06 Thread Pierre-Marie de Rodat
This patch adds support to Image for the GNU standard format "%:::z", which prints the time zone in the format "+hh", "-hh", "+hh:mm", or "-hh:mm", as appropriate. We do not support any of the other standard GNU time-zone formats (%z, %:z, %::z, %Z). Tested on x86_64-pc-linux-gnu, committed on tru

[Ada] Time_IO.Value: Allow subseconds and time zones together

2020-07-06 Thread Pierre-Marie de Rodat
The syntax parsed by GNAT.Calendar.Time_IO.Value allowed a fraction of a second, or a time zone, but not both. This is a violation of the relevant ISO standard ISO-8601. This patch allows both to be specified. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-catii

[Ada] Implement Time_IO.Image with Time_Zone

2020-07-06 Thread Pierre-Marie de Rodat
This patch adds a new function Image in GNAT.Time_IO that takes a Time_Zone parameter rather than using local time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-catiio.ads, libgnat/g-catiio.adb (Image): New function. It might seem like the local-time Ima

[Ada] Correct time zone in GNAT.Calendar.Time_IO.Value

2020-07-06 Thread Pierre-Marie de Rodat
This patch fixes a bug in which if GNAT.Calendar.Time_IO.Value is called with an ISO date string, the time zone offset is computed incorrectly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-catiio.adb (Parse_ISO_8601): New name for Parse_ISO_8861_UTC. 86

[Ada] Ada2020: AI12-0198 potentially unevaluated array components

2020-07-06 Thread Pierre-Marie de Rodat
This patch implements AI12-0198-1, which enforces detecting components which belong to a non-static or null range of index values of an array aggregate. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads (Interval_Lists.Aggregate_Intervals): New subprogram.

[Ada] Avoid forced loading of System.Priority in CodePeer mode

2020-07-06 Thread Pierre-Marie de Rodat
The comment for routine Is_RTE explains that it is a more efficient equivalent of an equality testing with routine RTE. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Apply_Scalar_Range_Check): Use Is_RTE.diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb ---

[Ada] Remove SPARK-specific expansion of array aggregates

2020-11-24 Thread Pierre-Marie de Rodat
With analysis of the original array aggregate expressions (and not of the copies, as it used to be) and without removing references to index parameters of iterated_component_associations (which only need to be removed when expander is active) we no longer need any SPARK-specific code for array aggr

[Ada] Fix resolution of subtype_indication in delta aggregates

2020-11-24 Thread Pierre-Marie de Rodat
For a Subtype_Indication in ordinary array aggregates we explicitly call Resolve_Discrete_Subtype_Indication; for a Subtype_Indication in delta array aggregates we implicitly call Sem_Ch3.Analyze_Subtype_Indication, which is only meant to be used in declarations, not in expressions. This subtle di

[Ada] Use high-level Present instead of low-level equality test

2020-11-24 Thread Pierre-Marie de Rodat
Routine Present for Unit_Name_Type was introduced precisely to avoid equality tests with No_Unit_Name. Code cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-load.adb, lib-writ.adb, lib.adb, par-load.adb, rtsfind.adb, sem_ch10

[Ada] Fix spurious error on child library-level subprogram with aspects

2020-11-24 Thread Pierre-Marie de Rodat
GNAT used to reject such code with a spurious error about the aspect not being attached to the initial declaration. Now fixed. The workaround is to declare a library-level spec for the subprogram, to which the aspects are attached. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Implement Big_Integer.From_String fully

2020-11-24 Thread Pierre-Marie de Rodat
The previous implementation only supported up to 128bits integers, now provide a full implementation for unbounded integers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-nbnbin.adb (From_String): Implement fully.diff --git a/gcc/ada/libgnat/a-nbnbin.adb b/gcc/ad

[Ada] Wrong finalization in call with if expression

2020-11-24 Thread Pierre-Marie de Rodat
Changes made for "Bad access checks on if/case expression as actual" introduced a regression when dealing with transient objects: the processing of function calls in Add_Cond_Expression_Extra_Actual would remove the setting of the "hook" variable needed for proper finalization. Tested on x86_64-pc

[Ada] Premature finalization on build in place return and case expression

2020-11-24 Thread Pierre-Marie de Rodat
Is_Finalizable_Transient does not properly handle the case of a return containing an N_Expression_With_Actions (e.g. a case expression), causing a premature finalization of the return object. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Is_Finalizable_Transi

[Ada] Wrong resolution of universal_access = operators

2020-11-24 Thread Pierre-Marie de Rodat
The universal_access = and /= operators were not properly taken into account in all cases. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_type.adb (Add_One_Interp.Is_Universal_Operation): Account for universal_access = operator. (Disambiguate): Take into

[Ada] Fix String_Literal aspect spec checking problem for scalars.

2020-11-24 Thread Pierre-Marie de Rodat
Result type compatibility checking for the specified String_Literal function of a type was too strict, causing valid aspect specifications to be incorrectly rejected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Validate_Literal_Aspect): Call to Base_Type

[Ada] Fix internal error on multiple nested instantiations

2020-11-24 Thread Pierre-Marie de Rodat
This prevents the compiler from placing the freeze node of a package instance, used as actual parameter in a second instantiation, after this second instance, thus triggering an internal error later. The freezing code in Analyze_Associations already knows how to deal with this case, but the mechan

[Ada] Handle correctly current instance of PO in local subprogram Global

2020-11-24 Thread Pierre-Marie de Rodat
SPARK defines the current instance of a protected object as non-volatile for internal calls, which allows to use it in the Global contract of a local non-volatile function. This was not handled correctly, now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.ad

[Ada] Fix crash in GNATprove on inlined subprogram in default expression

2020-11-24 Thread Pierre-Marie de Rodat
The special inlining in GNATprove mode should recognize specially calls inside default expressions, which cannot be inlined. This was not done for calls in default expressions for discriminants, because the right analysis context was not set in that case. Now fixed. Tested on x86_64-pc-linux-gnu,

[Ada] Accept local objects in the prefix of attribute Loop_Entry

2020-11-24 Thread Pierre-Marie de Rodat
Fix implementation of SPARK RM 5.5.3.1(5) by accepting objects declared within the prefix of attribute Loop_Variant itself. This previous code didn't implement the "... but not within the prefix itself" part of the rule. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_at

[Ada] Implement No_Unrecognized_{Aspects,Pragmas} restrictions

2020-11-24 Thread Pierre-Marie de Rodat
This commit implements the No_Unrecognized_Aspects and No_Unrecognized_Pragmas restrictions described in AI12-0389. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-rident.ads (System.Rident): Register new restriction IDs. * par-ch13.adb (Get_Aspect_

[Ada] AI12-0394 Named Numbers and User-Defined Numeric Literals

2020-11-24 Thread Pierre-Marie de Rodat
Integer named numbers may now be used with types that have an Integer_Literal aspect. Real named numbers may be used with types that have a Real_Literal aspect with an overloading that takes two strings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Validate

[Ada] Small cleanup in the Ada.Text_IO hierarchy

2020-11-24 Thread Pierre-Marie de Rodat
This removes an implementation subtype declared in the Ada.Text_IO hierarchy that no longer seems to serve any useful purpose. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-wtdeio.adb (TFT): Delete and adjust throughout. * libgnat/

[Ada] Recognize delta and extension aggregates as objects

2020-11-24 Thread Pierre-Marie de Rodat
Ada RM 3.3 says that "aggregate" is an object, but GNAT represents "aggregate" either as N_Aggregate, N_Delta_Aggregate or N_Extension_Aggregate. With this patch both extension and delta aggregates are accepted where object is required, e.g. as a prefix of attribute Size. Tested on x86_64-pc-linu

[Ada] Compiler crash on assertion pragma in ghost region

2020-11-24 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby an assertion pragma within a ghost context whose expression causes the freezing of a non-ghost type causes the compiler to crash during compilation when ghost mode is disabled. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ *

[Ada] Fix inconsistent parameter of SPARK_Msg_NE

2020-11-24 Thread Pierre-Marie de Rodat
All calls to SPARK_Msg_NE except one were taking an entity as its second parameter; this patch does the same for one call that took an identifier. Code cleanup only; behaviour is unaffected, because both entity and identifier works in the same when given to SPARK_Msg_NE routine. Tested on x86_64-

[Ada] Replace chained if-then-elsif with case stmt for attribute ids

2020-11-24 Thread Pierre-Marie de Rodat
Handle attribute ids in SPARK-specific expansion with a case statement, just like they are handled in ordinary expansion. Code cleanup only, in preparation for fix related to attribute Constrained; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_

[Ada] Cannot process -S -o with GNAT LLVM

2020-11-24 Thread Pierre-Marie de Rodat
This is fixed by recognizing -S in Scan_Compiler_Args and taking it into account in Set_Output_Object_File_Name. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * opt.ads (Generate_Asm): New flag. * osint-c.adb (Set_Output_Object_File_Name): Accept any extensio

[Ada] Fix internal compilation error on circular type in SPARK code

2020-11-25 Thread Pierre-Marie de Rodat
When compiling or analyzing with GNATprove a piece of SPARK code with a circular definition involving an incomplete declaration and an access to it, the compilation/analysis may raise Program_Error in some cases. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem

[Ada] Fix crash on invalid `pragma Profile`

2020-11-25 Thread Pierre-Marie de Rodat
Before this commit, GNAT would crash when encountering uses of the `Profile` pragma that did not have an identifier as argument (e.g. `pragma Profile("a")`). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_Pragma): Emit error on wrong argument n

[Ada] Add support for 128-bit integer types to GNAT.Random_Numbers

2020-11-25 Thread Pierre-Marie de Rodat
The support for 128-bit integer types was added to System.Random_Numbers but not to the twin package GNAT.Random_Numbers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-rannum.ads (Random): New functions returning 128-bit. * libgnat/g-rannum.adb (Random):

[Ada] Allow debugging finalization-related expanded code

2020-11-25 Thread Pierre-Marie de Rodat
exp_ch7.adb was missing calls to Set_Debug_Info_Needed on various entities to allow debugging via -gnatD, now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb (Build_Finalization_Master, Build_Finalizer, Build_Object_Declarations, Make_Deep_Array_Bo

[Ada] Unrecursify Set_Digit/Set_Image_Unsigned procedure

2020-11-25 Thread Pierre-Marie de Rodat
This patch remove recursion on Set_Digit and Set_Image_Unsigned procedure. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-imagei.adb (Set_Digits): Rewrite the procedure to remove recursion. (Image_Integer, Set_Image_Integer): Update assertions and

[Ada] Reinstate utime based code for vx6 in __gnat_copy_attribs

2020-11-25 Thread Pierre-Marie de Rodat
The previous change to __gnat_copy_attribs led to relying on utimes for timestamp propagation on VxWorks 6 as well, which results in undefined symbol references at runtime in most configurations for such targets. Restore the previous code for such environments, based on utime instead. Tested on x

[Ada] Adjust support for 128-bit integer types in System.Random_Numbers

2020-11-25 Thread Pierre-Marie de Rodat
While the default function returning 128-bit integer works correctly, Random_Discrete does not if it is instantiated on a 128-bit integer, since the magnitude of the returned numbers is still 64 bits. Note that no counterpart is needed in GNAT.Random_Numbers because the homonymous function in ther

[Ada] Crash on right shift operator for signed integers

2020-11-25 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby right shift operators on signed integers cause a compile-time crash when said shift operators are provided via pragma Provide_Shift_Operators. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/intrinsic_subprograms.

[Ada] Remove dead and duplicated diagnostics for generic access types

2020-11-25 Thread Pierre-Marie de Rodat
Access type parameters in instances of generic units were first checked with Subtypes_Match routine, and then their designated types were checked for matching constrained-ness; diagnostic code guarded by both conditions was duplicated. It turns out that the constrained-ness condition was never act

[Ada] Fix copy-paste mistake in diagnostics for aspect Effective_Writes

2020-11-25 Thread Pierre-Marie de Rodat
Mistake detected as a code duplicate. It only suppresses a more precise error on a code that is rejected as illegal anyway. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Replace duplicate of Effective_Reads.diff --git a/gcc/ada/se

[Ada] Consistently use explicit Entity_Id type instead of alias

2020-11-25 Thread Pierre-Marie de Rodat
By convention subprogram declarations in Einfo unit use alias "E" instead of Entity_Id, but subprogram bodies use full Entity_Id types. This patch fixes inconsistencies where alias "E" was used in subprogram bodies. Cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on

[Ada] Minimize side-effect removal in GNATprove mode

2020-11-25 Thread Pierre-Marie de Rodat
SPARK code is much more restricted in terms of possible side-effects inside expressions. As such, there is no need for aggressive removal of side-effects across all expressions in GNATprove mode. The benefit is that expressions are more self-contained, without the need to get information from hoist

[Ada] Don't constant-fold renamed qualified expressions

2020-11-25 Thread Pierre-Marie de Rodat
In a case like: X : Integer := 1; Y : Integer renames Integer'(X); the value of Y is changed by any subsequent assignments to X. Thus, replacing the use of X with a literal 1 would be a mistake. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch2.adb (Expand_Enti

[Ada] Use hardcoded names when converting aspects to pragmas

2020-11-25 Thread Pierre-Marie de Rodat
Now all calls to Make_Aitem_Pragma, which converts aspects to pragmas, use hardcoded names as the Pragma_Name parameters, because the required value is known statically (this actually prevents code reuse, but at least now all aspects are handled consistenttly). Other calls use Nam constant instead

[Ada] Simplify aspect processing with membership tests

2020-11-25 Thread Pierre-Marie de Rodat
Replace sequences of (in)equality tests with membership tests and sort alternatives alphabetically. Cleanup related to removal of duplicated code; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Detect aspect ident

[Ada] Remove shadowing by a nested subprogram parameter

2020-11-25 Thread Pierre-Marie de Rodat
In Expand_N_Exception_Renaming_Declaration we had a local constant "Nam" which was then shadowed by a parameter "Nam" in a nested function Evaluation_Required. Cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch8.adb (Expand_N_Except

[Ada] Spurious error on instance with predicated actual

2020-11-25 Thread Pierre-Marie de Rodat
This patch removes an error on an instantiation when the actual is a scalar type with a dynamic predicate, and its bounds are compatible with those of the corresponding formal parameter. Section 4.9.1 of the RM specifies that subtypes S1 and S2 can be statically compatible even if S1 is not static,

[Ada] Document attribute Has_Tagged_Values in GNAT RM

2020-11-25 Thread Pierre-Marie de Rodat
Attribute Has_Tagged_Values was implemented years ago, but never documented. Found while detecting duplicated code, as this attribute is processed very much like attribute Has_Access_Type and this duplication is also removed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ *

[Ada] Fix couple of minor issues with local exception propagation

2020-11-25 Thread Pierre-Marie de Rodat
The first one is that the propagation does not work if the raise statement uses a qualified name for the exception, because of an inconsistency in Expand_N_Raise_Statement. The second one is that a pragma Assert (False) does not propagate locally because the rewriting of the degenerate if statemen

[Ada] Further optimization with uninitialized aggregates

2020-11-25 Thread Pierre-Marie de Rodat
An object declaration for an unconstrained array includes an expression (most often an aggregate) that provides the bounds for the object. If the aggregate uses box initialization to provide those bounds, it is not necessary to construct the aggregate to complete the object declaration: the generat

[Ada] Compiler crash on named association in return aggregate

2020-11-26 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby static accessibility checks were incorrectly performed on non-discriminant components in return aggregates featuring named associations - causing spurious errors and crashes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * se

[Ada] Spurious error on formal package with overloaded subprograms

2020-11-26 Thread Pierre-Marie de Rodat
Compiler rejects an instantiation involving a formal package that contains adjacent subprogram declarations with the same name, because in the matching between entities in the formal package and the corresponding actual package, it maps two successive entities in the formal with the same entity (wi

[Ada] Issue advice for error regarding Old/Loop_Entry on unevaluated expr.

2020-11-26 Thread Pierre-Marie de Rodat
Ada puts some restrictions on the use of attributes Old, that SPARK mimics for attribute Loop_Entry, inside a "potentially unevaluated context". These restrictions can be lifted by using pragma Unevaluated_Use_Of_Old with argument Allow. Issue a message to indicate that to the user. Tested on x86_

[Ada] Simplify checks for library unit pragmas

2020-11-26 Thread Pierre-Marie de Rodat
If a library unit pragma is ignored then Check_Valid_Library_Unit_Pragma was rewriting it into a null statement; this null statement then was then detected by at the callsites to terminate analysis of the pragma. Now if a pragma is ignored, then Check_Valid_Library_Unit_Pragma raises an exception

[Ada] Incorrect runtime accessibility check on access discriminant

2020-11-26 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby returning an anonymous access discriminant of an anonymous access formal within a function that returns an anonymous access type may cause a malformed accessibility check to be generated. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] New warning on questionable missing parentheses

2020-11-26 Thread Pierre-Marie de Rodat
Warn on unparenthesized (in)equality as operand of and/or/xor, as this is a known source of confusion. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Equality_Op): Warn when -gnatwq is used (the default) and the problematic case is encountered.d

[Ada] Reuse Is_Access_Object_Type where possible

2020-11-26 Thread Pierre-Marie de Rodat
Simplify calls to Is_Access_Type followed by Is_Access_Subprogram_Type with Is_Access_Object_Type, which does exactly the same. Cleanup related to support for access-to-subprogram in flow analysis of GNATprove; semantics unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Pass base type to Set_Has_Own_Invariants

2020-11-26 Thread Pierre-Marie de Rodat
Set_Has_Own_Invariants is a [base type only] field, so should be passed the base type. Set_Has_Own_Invariants and Set_Has_Inherited_Invariants should assert that its parameter is a base type, but we don't do that as part of this change. That will happen as part of the variable-sized nodes change.

[Ada] Adjust documentation of Aft_Value and Scale_Value

2020-11-26 Thread Pierre-Marie de Rodat
This clears some confusion between them by citing the definition of the eponymous attributes in the RM and writing down their relationship. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads (Aft_Value): Adjust documentation. (Scale_Value): Likewise.diff --git

[Ada] Constraint_Error in Task_Wrapper and -u0

2020-11-26 Thread Pierre-Marie de Rodat
When using the gnatbind switch -u0 and a runtime built with checks on, we could get a range check error in System.Tasking.Stages.Task_Wrapper, now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-tassta.adb (Task_Wrapper): Fix computation of Pattern_

[Ada] Memory leak in concatenation with Initialize_Scalars

2020-11-26 Thread Pierre-Marie de Rodat
This patch fixes a memory leak in concatenation when pragma Initialize_Scalars or Normalize_Scalars is used. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_Concatenate): Call Set_No_Initialization on the N_Allocator node that is supposed to alloc

[Ada] Warn on slices of the form A (subtype) for all objects

2020-11-26 Thread Pierre-Marie de Rodat
GNAT emits a warning on slices of the form "A (subtype)" if A is a constant; a similar warning is now emitted if A is any object, e.g. formal parameter, loop parameter (when iterating over an array-of-arrays) or component. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_

[Ada] Sync wide Ada.String hashing units

2020-11-26 Thread Pierre-Marie de Rodat
The Wide_Wide_Hash version of Ada.Strings.Hash was instantiated as a library unit. Now all versions are instantiated in wrapper functions. Minor inconsistency, spotted while cleaning up code for categorization pragmas on instance units. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Remove duplicated calls to Set_Entity

2020-11-26 Thread Pierre-Marie de Rodat
Routine Set_Entity_With_Checks called Set_Entity, did some checks, and then called Set_Entity again. This second call was redundant and had no effect; this patch removes it. Those two calls appear to come from a sequence of refactorings: initially there was just a call to Set_Entity at the end; wh

[Ada] Crash on task declaration with Restriction_Warning (No_Tasking)

2020-11-26 Thread Pierre-Marie de Rodat
Compiler aborts when the Restriction_Warning (No_Tasking) appears as a configuration pragma, and the main unit includes a task declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings): when the restricti

[Ada] Improve error message on illegal prefixed procedure call

2020-11-26 Thread Pierre-Marie de Rodat
This patch improves an error message on an illegal prefixed procedure call Obj.Name (Args) when Name denotes a visible component of Obj, as well as a primitive operation of the type of Obj. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Call_And_Resolve

[Ada] Replace warning suppression with assertion

2020-11-26 Thread Pierre-Marie de Rodat
Routine Resolve_Membership_Op didn't reference its Typ parameter and instead suppressed warning with a suspicious pragma Warning. This could be rather pragma Unreferenced, but actually we can reference the type in assertion that enforces an existing comment. Tested on x86_64-pc-linux-gnu, committe

[Ada] Ada 2020 AI12-0401 Renaming of qualified expression of variable

2020-11-26 Thread Pierre-Marie de Rodat
This AI restricts renaming of a qualified expression to cases where the operand is a constant, or the target subtype statically matches the nominal subtype of the operand, or is unconstrained with no predicates. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (An

[Ada] Ada.Numerics.Big_Numbers.Big_Reals.To_Big_Real looses precision

2020-11-26 Thread Pierre-Marie de Rodat
The initial implementation was simply using 'Image which will loose precision in some cases. Fixed by always using a sufficient number of digits. To_Big_Real could be made more efficient by not going through strings, this is left for a later step. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Add support for 128-bit fixed-point types on 64-bit platforms

2020-11-26 Thread Pierre-Marie de Rodat
This also reimplements the I/O support for all fixed-point types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Likewise. (GNATRTL_128BIT_OBJS): Likewise. (GNATRTL_128BIT_PAIRS): Add new 128-bit variants. * cs

[Ada] Fix oversignt in genericized package System.Value_R

2020-11-27 Thread Pierre-Marie de Rodat
Pragma Annotate for CodePeer must immediately follow the designated line. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valuer.adb (Scan_Raw_Real): Move pragma Annotate around and adjust its parameters.diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/l

[Ada] Error in Big_Real comparison

2020-11-27 Thread Pierre-Marie de Rodat
The code would incorrectly compare using absolute values, which was a left over for another implementation incorrectly carried over. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-nbnbre.adb ("=", "<"): Fix.diff --git a/gcc/ada/libgnat/a-nbnbre.adb b/gcc/ada/libgn

[Ada] Emit error messages for null/generic nonreturning procedures

2020-11-27 Thread Pierre-Marie de Rodat
This commit adds checks for rule 6.5.1 4/3 of the Ada RM which declares nonreturning procedures and nonreturning generic procedure instances illegal. The reason this check is performed in sem_prag.adb rather than in Check_Returns in sem_ch6.adb is that generic procedure instances won't have their

[Ada] Small tweaks to new implementation of Set_Image_Fixed

2020-11-27 Thread Pierre-Marie de Rodat
This removes a use of the absolute value that could potentially fail the overflow check and add assertions guarding a second use and the manipulation of string buffers, the latter for the sake of CodePeer. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-imagef.adb

[Ada] Optimize magnitude of integer operations for fixed point

2020-11-27 Thread Pierre-Marie de Rodat
In most cases, the common operations for fixed-point types are implemented by means of corresponding integer operations, in particular multiplication and division. Because scaling is required to go back and forth between the two representations, the expander needs to control the magnitude of opera

[Ada] To_Big_Integer and 128bits integers

2020-11-27 Thread Pierre-Marie de Rodat
Add support for the recently added 128bits integer support in Big_Integers.To_Big_Integer. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-genbig.ads, libgnat/s-genbig.adb (To_Bignum): New variant taking an Unsigned_128. * libgnat/a-nbnbin.adb (To_B

[Ada] Move down call to Narrow_Large_Operation in Expand_N_Op_Multiply

2020-11-27 Thread Pierre-Marie de Rodat
It can block the transformation of the multiplication by a power of 2 into a shift operation when the context is Universal_Integer and checks are disabled. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_Op_Multiply): Move down block calling Nar

[Ada] Adjust head comment of various subprograms in Exp_Fixd

2020-11-27 Thread Pierre-Marie de Rodat
None of these programs analyzes the resulting node on return any more. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_fixd.adb (Build_Conversion): Adjust head comment. (Build_Divide): Likewise. (Build_Double_Divide): Likewise. (Build_Multiply): L

[Ada] Do not compile predefined units with -gnatp in gnatmake

2020-11-27 Thread Pierre-Marie de Rodat
This aligns the behavior of gnatmake with the way the runtime is now built. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * make.adb (GNAT_Flag): Change to "-gnatg". (Compile): Adjust comments accordingly.diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb --- a/gcc/ada

[Ada] Restore general case for folding comparison of static strings

2020-11-27 Thread Pierre-Marie de Rodat
When reorganizing the mechanism which evaluates relational operators and potentially folds them, the "General case" in routine Eval_Relational_Op was put into an ELSE branch. This was subtly wrong, because it must be executed unless the special case in the THEN branch exits with a RETURN statement.

[Ada] Optimize generation of checks for fixed-point types

2020-11-27 Thread Pierre-Marie de Rodat
This set of changes aimed at optimizing the generation of range and overflow checks for fixed-point types contains two parts: 1. a cleanup to the generation of range checks for type conversions involving fixed-point types, which is now more clearly deferred entirely to after the expans

[Ada] Reimplement Ada.Numerics.Big_Numbers.Big_Reals.Float_Conversions

2020-11-27 Thread Pierre-Marie de Rodat
This reimplements the aforementioned generic package according to the requirements of the Ada 2020 RM, namely that To_Big_Real be exact and that From_Big_Real use the common floating-point conversion rules, which are round to nearest, ties to even, in GNAT as per IEEE 754. Tested on x86_64-pc-linu

[Ada] Change parameter from access type to mode out

2020-11-27 Thread Pierre-Marie de Rodat
Replace an access type parameter, which is unusual in the GNAT sources and more difficult to understand, with a parameter of mode out. Code cleanup only; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.ads (Compile_Time_Compare): Change para

[Ada] Abort defer mismatch with SJLJ exceptions

2020-11-27 Thread Pierre-Marie de Rodat
Enabling checks in the runtime made a latent bug with the sjlj runtime visible. We used to handle abort deferral differently between GCC ZCX and GNAT "Front-End" SJLJ, which is no longer the case with GCC SJLJ, so remove differences to simplify the code and fix the inconsistency. Tested on x86_64-

[Ada] Assertion_Policy is not a valid assertion policy

2020-11-27 Thread Pierre-Marie de Rodat
The following pragma is currently accepted: pragma Assertion_Policy (Assertion_Policy => Ignore); because of what appears to be a typo in a previous commit on this topic. With this patch the above pragma is rejected as illegal. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Sync doc and code for pragma Assertion_Policy

2020-11-27 Thread Pierre-Marie de Rodat
In the listing of assertion kinds accepted for pragma Assertion_Policy some items were wrongly included while other were missing. Now this listing is synchronized with Sem_Prag.Is_Valid_Assertion_Kind. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementatio

[Ada] Default_Initial_Condition assertion policy is now RM defined

2020-11-27 Thread Pierre-Marie de Rodat
Default_Initial_Condition was created for SPARK, but has been adopted by Ada 202x, so now it is an RM defined aspect and an assertion policy. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: (Assertion_Policy): Move "Def

[Ada] To_GM_Time returning invalid value for Invalid_Time

2020-11-27 Thread Pierre-Marie de Rodat
Some code currently relies on To_GM_Time returning some reasonable value in this case rather than e.g. raising an exception and it appears that Windows returns 1970-01-01 except with second set to -1 (triggering an exception), while linux returns 1970-01-01 minus 1 second (so 1969-12-31 at 23:59:59

[Ada] Implement AI12-0187 (Stable properties of abstract data types)

2020-11-27 Thread Pierre-Marie de Rodat
This is only an initial implementation, subject to many limitations. Some interactions with derived types and inheritance are not implemented. Other limitations are idenitified in the code with "???" comments. However, Stable_Properties and Stable_Properties'Class aspect specifications are implem

[Ada] Do not use 128-bit division for 64-bit fixed-point types

2020-11-27 Thread Pierre-Marie de Rodat
This restricts the use of 128-bit division for fixed-point types to the cases where there is a 128-bit type in the source code, that is to say this prevents the compiler from using it for 64-bit types. This is done mainly for the sake of backward compatibility with earlier compilers not supporting

[Ada] Do not apply range checks inside generics in GNATprove mode

2020-11-27 Thread Pierre-Marie de Rodat
Similar to what is done for compilation, range checks should not be applied inside generics during GNATprove analysis. This fixes an assertion failure in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Selected_Range_Checks): Adapt the condition for

[Ada] Small improvement to System.Value_R.Scan_Raw_Real

2020-11-27 Thread Pierre-Marie de Rodat
This makes System.Value_R.Scan_Raw_Real round the extra digit it returns to the caller, so that it is precise to the last 'Aft digits for strings that are the exact representation of a number, i.e. not already rounded. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/

[Ada] Restore access type instead of mode out parameter

2020-11-27 Thread Pierre-Marie de Rodat
Replace an access type parameter, which is unusual in the GNAT sources and more difficult to understand, with a parameter of mode out. Code cleanup only; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.ads (Compile_Time_Compare): Restore par

[Ada] Reference before declaration on C392015

2020-11-27 Thread Pierre-Marie de Rodat
When working on LLVM/CCG, we found that the generated tree had a wrong reference before declaration usage. Fixed for LLVM/CCG. The issue might still be latent with Modify_Tree_For_C, but this expansion will disappear in the future, so not worth bothering. Tested on x86_64-pc-linux-gnu, committed o

[Ada] Wrong compile time evaluation of Shift_Right

2020-11-27 Thread Pierre-Marie de Rodat
When using the Shift_Right operator on negative values (e.g. -1 on a signed type), the wrong value is incorrectly folded after recent changes in sem_eval.adb to add compile time evaluation of the shift operators. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.adb (

[Ada] Small tweaks to couple of Value routines

2020-11-27 Thread Pierre-Marie de Rodat
This fixes a minor oversight in Integer_To_Fixed and restricts the previous change to System.Value_R.Scan_Raw_Real for the sake of backward compatibility with earlier conversions of the compiler. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valuef.adb (Integer_T

[Ada] Confusion in Transform_Function_Array and internal subprograms

2020-11-30 Thread Pierre-Marie de Rodat
Generating an internal subprogram (e.g. array comparison functions) returning an array, the Transform_Function_Array mechanism gets confused and references the wrong entities in some cases. Fix this discrepency by directly transforming these functions into procedures instead of triggering the gener

[Ada] Add continuation message when others choice not allowed

2020-11-30 Thread Pierre-Marie de Rodat
In a context where the bounds of an array aggregate are not known, the aggregate is not allowed to include an "others" choice. The error message given by GNAT now includes a suggestion to qualify the aggregate with a constrained subtype to fix the issue. Tested on x86_64-pc-linux-gnu, committed on

[Ada] Spurious visibility error in subprogram body in with_clause

2020-11-30 Thread Pierre-Marie de Rodat
Compiler rejects a use of a name in a subprogram body that appears in a with_clause, when the name is that of an inherited function for a local derived type, and is hidden by an explicit declaration of a non-overloadable homonym, and other homonyms exist in the environment of the subprogram body.

[Ada] Small cleanup in System.Value_F

2020-11-30 Thread Pierre-Marie de Rodat
This removes a superflous processing during the conversion to fixed point. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valuef.adb (Integer_To_Fixed): Do not modify numerator or denominator in order to reduce the exponent.diff --git a/gcc/ada/libgnat/s-v

[Ada] Crash on ghost assignment check for illegal code

2020-11-30 Thread Pierre-Marie de Rodat
This patch fixes a bug, where an assignment of the form X(Y).Z := ... causes the compiler to crash when X does not refer to a visible declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Error_Msg_NEL): Do not call Set_Posted if errors are being i

[Ada] Potential read of uninitialized variable in exp_dist.adb

2020-11-30 Thread Pierre-Marie de Rodat
Found by using -gnatVa and Initialize_Scalars on GNAT sources. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_dist.adb (RCI_Cache): Initialize.diff --git a/gcc/ada/exp_dist.adb b/gcc/ada/exp_dist.adb --- a/gcc/ada/exp_dist.adb +++ b/gcc/ada/exp_dist.adb @@ -902,7 +902,7

[Ada] Spurious error on iterator over container with modified private part

2020-11-30 Thread Pierre-Marie de Rodat
The compiler rejects an element iterator (for .. of) over a container that extends a predefined container with additional operations in the private part, when these added operations overload existing GNAT-specific private operations used to optimize such loops. Tested on x86_64-pc-linux-gnu, commi

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