[Ada] Remove repeated testing of Check_Validity_Of_Parameters

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

[Ada] Simplify processing of 'Valid_Scalars on array types

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

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

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

[Ada] Remove second warning for convention C_Variadic_n

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

[Ada] universal_access equality and 'Access attributes

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

[Ada] Fix validity checking for class-wide objects

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

[Ada] Decorate record delta aggregate for GNATprove

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

[Ada] Style checks on invalid UTF character cause crash

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

[Ada] AI12-0366 Changes to Big_Integer and Big_Real

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

[Ada] Fix small fallout of previous change for Analyze_Selected_Component

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

[Ada] Spurious condition warning on type conversion in return

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

[Ada] Small cleanup in Apply_Range_Check implementation

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

[Ada] Reject junk expressions in attribute Update

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

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

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

[Ada] Deal with enumeration types with very large size

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

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

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

[Ada] Fix small fallout of previous change for allocator

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

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

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

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

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

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

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

[Ada] AI12-0293-1 Remove pragma Assert

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

[Ada] Further cleanup in constraint checking code for allocators

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

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

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

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

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

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

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

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

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

[Ada] Remove obsolete code in Eval_Attribute

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

[Ada] Visibility error with aggregate in Declare_Expression

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

[Ada] Fix evaluation of Enum_Rep applied to imported constant

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

[Ada] Small cleanup throughout Exp_Ch9

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

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

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

[Ada] Refine use of access types in unnesting

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

[Ada] Fix bad interaction between Unchecked_Conversion and limited type

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

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

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

[Ada] Crash on declaration with aggregate for unchecked union

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

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

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

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

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

[Ada] Hang on generic declaration with ambiguous formal package

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

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

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

[Ada] Use Stream_Element_Arrays internally for secure hash computations

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

[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/

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