[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

[Ada] Fix serial port control setting on GNU/Linux

2020-11-30 Thread Pierre-Marie de Rodat
This fixes an issue when setting the control flags of the serial communication port. The c_cflag termios field should not be set with the baud rate. The speed of the communication is set using the c_ispeed and c_ospeed fields. Setting the baud rate into the c_cflag has unexpected results as it will

[Ada] Fix folding of comparison operators in GNATprove mode

2020-11-30 Thread Pierre-Marie de Rodat
Folding of comparison operators was disabled for GNATprove in assertion expressions (except for some special cases). However, folding itself is harmless. The problem was only in the current value optimizer, which interferes with assertions that act as cut points for proof. Tested on x86_64-pc-linu

[Ada] Improve error recovery

2020-11-30 Thread Pierre-Marie de Rodat
Function P_Formal_Part was unnecessarily calling Scan after calling T_Semicolon: T_Semicolon is already calling Scan to go past the comma-used-insted-of-semicolon. This avoids spurious cascaded errors in case of e.g: procedure P (A : Integer, B : Integer, C : Integer) is where ',' is used inst

[Ada] Compiler crash on limited conditional expressions

2020-11-30 Thread Pierre-Marie de Rodat
This patch fixes a bug in which if the expression of an expression function is a conditional expression of limited type, the compiler crashes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Expand_N_Object_Declaration): Avoid crash in case of conditiona

[Ada] Add stream-oriented attributes support for 128-bit integer types

2020-11-30 Thread Pierre-Marie de Rodat
This was overlooked in the original implementation of these types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (-xdr): Document that XDR is not supported for 128-bit integer types. * gnat_ugn.texi: R

[Ada] Implement -gnateb switch

2020-11-30 Thread Pierre-Marie de Rodat
The -gnateb switch instructs gnat to store configuration pragma files by their basename in ALI files instead of using absolute paths. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Describe -gnateb switch.

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

2020-11-30 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 conversion rules. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-nbnbre.adb (Float_Convers

[Ada] Enable checks on runtime by default

2020-11-30 Thread Pierre-Marie de Rodat
These checks are not very costly these days and bring additional safety and security guarantees built into the Ada language, so enable them by default. It turns out that enabling checks on s-bitfie.adb makes a latent visibility bug appeared on strict alignment platform (related to alignment checks

[Ada] Expand integer-only implementation of ordinary fixed-point types

2020-11-30 Thread Pierre-Marie de Rodat
This change relaxes the conditions under which the implementation of ordinary fixed-point types uses only underlying integer instructions. These conditions are on the Small of the ordinary fixed-point types, which must now be a rational number whose factors are of a magnitude bounded relatively to

[Ada] Implement inheritance for Default_Initial_Condition and address other gaps

2020-11-30 Thread Pierre-Marie de Rodat
The existing (SPARK-based) implementation of Default_Initial_Condition aspects only applies DIC checks based on a type's own DIC (or only one DIC from an ancestor if the type doesn't specify one, but not from further up the ancestor chain), but Ada 202x (AI12-0265) specifies that all DICs of parent

[Ada] Fix internal error on extended return and fixed-point result

2020-11-30 Thread Pierre-Marie de Rodat
This prevents the expander from creating an access before elaboration issue for a temporary generated for a range check applied to the expression of a degenerate extended return statement (an extended return statement without an explicit do/end construct). Expand_N_Extended_Return_Statement has go

[Ada] Wrong replacement of Component.Discriminant

2020-11-30 Thread Pierre-Marie de Rodat
The procedure Replace_Discr_Ref added a few years ago is overzealous and triggers in too many cases in the case of multiple records with discriminants involved. It appears that this procedure is no longer needed at this stage, so simply remove it. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Remove all ^L characters

2020-11-30 Thread Pierre-Marie de Rodat
These control characters are mainly causing confusion at this stage, so remove them. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/Makefile.in, gcc-interface/trans.c: Remove ^L characters.diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-in

[Ada] Add support for compile time evaluation of Shift_Right_Arithmetic

2020-10-15 Thread Pierre-Marie de Rodat
After recent changes to evaluate logical Shift operations at compile time, do the same for the more complicated case of Shift_Right_Arithmetic as well as for Shift_Right/Shift_Left for signed integers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.adb (Eval_Intrin

[Ada] Ada2020: AI12-0180 Using subprograms and entries in invariants

2020-10-15 Thread Pierre-Marie de Rodat
This patch implements AI12-0180, so protected subprograms and invariants are directly visible within Invariant aspects. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Visible_Component): Enable this code for task and protected types, as well as record

[Ada] Warn on unknown aspect

2020-10-15 Thread Pierre-Marie de Rodat
Rather than generating a hard error on unknown aspects, generate a warning which is friendlier wrt compatibility across versions and is similar to what is done for unknown pragmas. We keep an error when -gnatd2 is used for now, for strict conformance until the Ada RM is also changed to allow this

[Ada] Double evaluation of predicate

2020-10-15 Thread Pierre-Marie de Rodat
In some case involving a type with a predicate and an inner package with a subprogram referencing the type, GNAT would call Add_Predicate twice on the same pragma node, causing tree sharing conflicts. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Add_Predicat

[Ada] Do not remove side effects from any object declarations in SPARK

2020-10-15 Thread Pierre-Marie de Rodat
In GNATprove mode we special-case the removal of side effect to do nothing for object declarations. However, this special casing applied only to some object declarations; now it applies to all. This patch only affects GNATprove, where it prevents recursive expansion of object declaration of a very

[Ada] Remove excessive defensive calls to Is_Type

2020-10-15 Thread Pierre-Marie de Rodat
It is excessive for Is_Type to guard a call to Is_Discrete_Type, because both are implemented as Ekind membership test and are equally likely to fail or succeed. Part of a cleanup in code related to propagation of subtype predicate flags. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada

[Ada] Ada_2020: Add aspect Aggregate to standard container units

2020-10-15 Thread Pierre-Marie de Rodat
This patch adds the Ada_2020 aspect Aggregate to standard containers (vectors, maps, and sets) that support the new construct. This patch also refines the resolution of record vs. container aggregates, and the resolution of the aggregate primitive Add_Indexed when the given name corresponds to an e

[Ada] Wrong use of Scope_Depth_Value

2020-10-15 Thread Pierre-Marie de Rodat
We've recently found that Scope_Depth_Value is sometimes called on the wrong nodes. This is fixed by adding proper assertions and updating the problematic call. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads, einfo.adb (Scope_Depth_Value, Set_Scope_Depth_

[Ada] Cleanup defensive guards for Null_Exclusion_Present

2020-10-15 Thread Pierre-Marie de Rodat
In routine Process_Subtype we had two calls to Null_Exclusion_Present (P): one guarded by "Present (P)" and the other by "Nkind (P) in ...". Now both calls are guarded by the conjunction of those guards. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Process_Su

[Ada] Spurious visibility on private with package

2020-10-15 Thread Pierre-Marie de Rodat
When a generic package has a private with clause, this clause may not be properly uninstalled, causing entities to be visible that shouldn't be. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch10.adb (Install_With_Clause): Fix implementation of Ada 2005 AI-262

[Ada] Refine type from Nat to Pos in Make_Index

2020-10-15 Thread Pierre-Marie de Rodat
Refine types to make the code easier to understand. Semantics is not affected; all the callers have been already respecting the more restrictive type of parameter anyway. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.ads, sem_ch3.adb (Make_Index): Refined type of

[Ada] Do not use maximal values from System in runtime units

2020-10-15 Thread Pierre-Marie de Rodat
This changes a few runtime units to use explicit bounds based on Long_Long_Integer instead of maximal values from System, which may become very large when 128-bit types are supported. They are used for index types and memory byte counts and, therefore, the magnitude provided by Long_Long_Integer i

[Ada] Bring defensive guard for Null_Exclusion_Present up to date

2020-10-15 Thread Pierre-Marie de Rodat
An expression for May_Have_Null_Exclusion variable mirrors an assertion in Null_Exclusion_Present. The assertion was then extended with another node kind and so May_Have_Null_Exclusion got out of date. The May_Have_Null_Exclusion is just a defensive code, so compilation is not affected. Tested on

[Ada] Fix access to uninitialized global variable when emitting error

2020-10-15 Thread Pierre-Marie de Rodat
When calling Error_Msg_FE with a message string that contains "<<" insertion characters, the error reporting machinery was accessing uninitialized Error_Msg_Warn variable to decide whether to emit error or a warning. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.a

[Ada] Remove obsolete DSP comment

2020-10-15 Thread Pierre-Marie de Rodat
Remove a reference to the "depressed stack pointer" method of doing returns of caller-unknown-size subtypes. DSP was removed from the compiler years ago. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_Simple_Function_Return): Remove DSP part of c

[Ada] Ada2020: AI12-0003 Specifying the standard storage pool

2020-10-15 Thread Pierre-Marie de Rodat
The standard storage pool can be specified in a Default_Storage_Pool pragma or aspect. This new feature is documented in AI12-0003-1. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_Pragma): Adding semantic support of Standard to Default_Storage

[Ada] Fix range check on constrained array with expanded index name

2020-10-15 Thread Pierre-Marie de Rodat
When detecting a type name we must look for both identifiers and expanded names. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Analyze_Subtype_Declaration): Recognize both identifiers and expanded names; use high-level Is_Scalar_Type instead of

[Ada] Crash on subtype of fixed-point type

2020-10-15 Thread Pierre-Marie de Rodat
This patch fixes a compiler abort on a subtype of a fixed-point type with a 'Small smaller than one. The bounds of a declared subtype of a fixed-point type where rescaled twice, leading to meaningless values (constraint-violating) for those bounds. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Get finalization right when a function returns a function call

2020-10-15 Thread Pierre-Marie de Rodat
When a function returns a function call, we want to avoid making an unnecessary copy. This is particularly important because of a bug which had the effect that when a copy was generated, the copied object was never finalized. If, as in the case of the example for this ticket, finalization was being

[Ada] GNAT-LLVM unnesting issues in elaboration code

2020-10-16 Thread Pierre-Marie de Rodat
There are cases involving limited class-wide allocators with an aggregate that result in if-statements in library-level elaboration code, where parts of the if-statement can contain a nested subprogram at the outer level of the statement lists, and the subprogram can make up-level references to obj

[Ada] Add Max_Integer_Size attribute and couple of helper functions

2020-10-16 Thread Pierre-Marie de Rodat
This introduces a new attribute Max_Integer_Size that can only be applied to Standard and yields the size of the largest supported integer type for the target. It is primarily intended to implement System.{Min,Max}_Int. This also implements a couple of internal helper functions in the compiler to

[Ada] Remove support for -gnatP and pragma Polling

2020-10-16 Thread Pierre-Marie de Rodat
This switch has never been very useful nor used in practice, so remove the associated code complexity. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl, gnat1drv.adb, expander.adb doc/gnat_rm/implementation_defined_pragmas.rst, doc/gnat_ugn/buildi

[Ada] Unique itypes names for unconstrained array object declaration

2020-10-16 Thread Pierre-Marie de Rodat
An unconstrained array object declaration might require two itypes: for object definition and for its initial value. Their names do not matter for the frontend, but GNATprove requires all types to have unique names (except private/full views). Tested on x86_64-pc-linux-gnu, committed on trunk gcc

[Ada] Reduce use of primary stack on string concatenation

2020-10-16 Thread Pierre-Marie de Rodat
Always using the primary stack when concatenating arrays can lead to a very large stack usage. To alleviate this, if the current scope is already using the secondary stack, then allocate the temporary object on the secondary stack as well. For the time being, this is for string concatenation, sinc

[Ada] Spurious visibility error on Declare_Expression with renames

2020-10-16 Thread Pierre-Marie de Rodat
The compiler rejects a declare expression whose declarations are only object renaming declarations, when the expression references those local objects. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Declare_Expression): Retrieve the created bloc

[Ada] Use new Max_Integer_Size attribute in system.ads files

2020-10-16 Thread Pierre-Marie de Rodat
This replaces the use of Long_Long_Integer by Standard'Max_Integer_Size in the definition of Min_Int, Max_Int and Max_Binary_Modulus. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-aix.ads: Likewise. * libgnat/system-darwin-arm

[Ada] SPARK: update for effectively volatile types and objects

2020-10-16 Thread Pierre-Marie de Rodat
SPARK Reference Manual has been updated to allow the use of volatile types and objects without Async_Writers or Effective_Reads in more places, as these references are not considered as external effects. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_G

[Ada] Constants no longer synchronised if they are access-to-variable

2020-10-16 Thread Pierre-Marie de Rodat
Implement changes in SPARK RM 9(1): previously an object was 'synchronized' if it was a constant, now constants are only synchronized if they are not of an access-to-variable type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads, sem_util.adb (Is_Access_Variable

[Ada] Ada2020: AI12-0129 Make protected objects more protecting

2020-10-16 Thread Pierre-Marie de Rodat
A Boolean aspect Exclusive_Functions is added to the language to change the semantic of protected functions to use a R/W lock instead of a Read lock. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * aspects.ads, snames.ads-tmpl: Add support for Exclusive_Functions asp

[Ada] Clean up in system.ads dependencies during compiler build

2020-10-16 Thread Pierre-Marie de Rodat
Having system.ads in libgnat can cause various kinds of inconsistencies, so we move it to gcc-interface. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/Make-lang.in: Update dependencies on system.ads, add gnatbind switch -t to avoid timestamp inconsist

[Ada] Legal actual type with inherited discriminants rejected in instantiation

2020-10-16 Thread Pierre-Marie de Rodat
When determining the legality of a generic parameter association for a formal type derived from a type that imposes a discriminant constraint, the compiler was incorrectly concluding that an actual type that inherits the constraint of the formal's parent type was not compatible with the formal type

[Ada] Attribute Img on derived types

2020-10-16 Thread Pierre-Marie de Rodat
Refinement of previous patch: the root type must be used for the image of enumeration types, because the literal map is attached to the root type even when derivations are present. Fixes several ACATS and fixedbugs regressions involving 'Image. Tested on x86_64-pc-linux-gnu, committed on trunk gc

[Ada] Avoid premature finalization of a function result

2020-10-16 Thread Pierre-Marie de Rodat
When a (simple) return statement in a function that returns a class-wide result type returns a call to a function that returns a specific result type, do not finalize that function result before returning it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Is_R

[Ada] Remove non-ASCII character

2020-10-16 Thread Pierre-Marie de Rodat
This is the first step in supporting [...] notation for aggregates in -gnatX mode. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-numeri.ads: Remove the greek letter.diff --git a/gcc/ada/libgnat/a-numeri.ads b/gcc/ada/libgnat/a-numeri.ads --- a/gcc/ada/libgnat/a-n

[Ada] Ada2020: parsing of qualified exprs with new agg syntax

2020-10-16 Thread Pierre-Marie de Rodat
This patch allows parsing of qualified expressions of the form T'[...] where [...] is a new syntax for aggregate in Ada 2020. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch4.adb (P_Name): Allow Tok_Left_Bracket in two places to call P_Qualified_Expressi

[Ada] Relax too strong assertions

2020-10-16 Thread Pierre-Marie de Rodat
Recent changes exposed that some assertions were too strong, now relaxed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * scil_ll.adb, sem_scil.adb: Update assertions.diff --git a/gcc/ada/scil_ll.adb b/gcc/ada/scil_ll.adb --- a/gcc/ada/scil_ll.adb +++ b/gcc/ada/scil_ll.adb @

[Ada] Finalization of uninitialized object with build in place call

2020-10-16 Thread Pierre-Marie de Rodat
In some cases combining a build in place function call returning a controlled object, part of another procedure call, if the function call raises an exception before executing the extended return statement, the caller would attempt to finalize the build in place result which has not been initialize

[Ada] Attribute Img on derived types

2020-10-16 Thread Pierre-Marie de Rodat
This patch fixes the handling of the Ada_2020 attribute Img when applied to derived types. If the type is private it is necessary to retrieve a non-private description of the type structure, by using an underlying view (which crosses the privacy boundary). The underlying view is that of the base ty

[Ada] Detect qualified type names for AI12-0027

2020-10-16 Thread Pierre-Marie de Rodat
Type in a view conversion can be both qualified and unqualified. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Is_View_Conversion): Detect qualified types. * sem_util.ads (Is_Actual_In_Out_Parameter): Fix style in comment.diff --git a/gcc/ada/

[Ada] Improvements to implementation of Ada_2020 attribute Reduce

2020-10-16 Thread Pierre-Marie de Rodat
AI12-0262 indicates that the reducer in an attribute reference 'Reduce must be either a binary function with same types for parameters and result, or else a procedure with an in_out parameter that serves as an accumulator. The function case includes attributes that are themselves funxtions: the onl

[Ada] Preelaborate rules not fully enforced

2020-10-16 Thread Pierre-Marie de Rodat
In particular RM10.2.1(8) states: 5 An elaborable construct is preelaborable unless its elaboration performs any of the following actions: ... 8 The evaluation of a primary that is a name of an object, unless the name is a static expression, or statically denotes a discri

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