[Ada] No_Implicit_Loops restriction and pragma Assert

2021-05-03 Thread Pierre-Marie de Rodat
When using e.g. pragma Assert (X'Initialized) combined with pragma Restrictions (No_Implicit_Loops), a violation is flagged when assertions are disabled, which is undesirable. Fixed by recognizing simple forms of dead paths used by pragma Assert when assertions are disabled. Tested on x86_64-pc-li

[Ada] Expansion in _postconditions confusing CodePeer

2021-05-03 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby extra flags and tests added to the internally generated _postconditions procedure confused and caused issues with CodePeer due to it treating the procedure as coming from source. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Remove confusing warning on type export

2021-05-03 Thread Pierre-Marie de Rodat
"exporting" a type may seem useless but is actually useful to set its convention and sometimes its external name. So simply remove this warning. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Set_Exported): Do not warn on exporting a type.diff --git a/gcc/ada

[Ada] Spurious warning about premature use of selected component

2021-05-03 Thread Pierre-Marie de Rodat
Compiler emits a warning on a selected component that is an actual in a function call, when the enclosing object has no explicit initialization and no discriminants, but the component type itself has partial initialization. Such a warning should be suppressed. Tested on x86_64-pc-linux-gnu, commi

[Ada] Fix calls to Error_Msg_NE instead of Error_Msg_N

2021-05-03 Thread Pierre-Marie de Rodat
Replace calls to Error_Msg_NE whose Msg parameters have no insertion characters corresponding to the E parameter with equivalent but simpler calls to Error_Msg_N. Code cleanup; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Profil

[Ada] Rename package instead of each routine

2021-05-03 Thread Pierre-Marie de Rodat
Package GNAT.Case_Util contained routines renamed from System.Case_Util. Few routines were missed. Renames entire package instead of renaming each routine separately. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-casuti.adb: Replace with "pragma No_Body".

[Ada] Allow attributes Version and Body_Version prefixed by entries

2021-05-03 Thread Pierre-Marie de Rodat
Prefix of attributes Version and Body_Version denotes any program unit, including protected entries, which were wrongly rejected this context. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Check_Program_Unit): Replace tests for Task_Kind and Protected

[Ada] Fix attributes Version and Body_Version for concurrent units

2021-05-03 Thread Pierre-Marie de Rodat
Attributes Version and Body_Version can be prefixed by program units, which include protected units and task units. Those attributes were wrongly accepted when prefixed by protected subtype, task subtype and by any object of a concurrent type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc

[Ada] Remove leading and trailing spaces in error messages

2021-05-03 Thread Pierre-Marie de Rodat
Remove trailing space in calls to Error_Msg_N routines. Cleanup only. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_disp.adb, sem_aggr.adb, sem_cat.adb, sem_ch10.adb, sem_ch12.adb, sem_ch3.adb, sem_ch4.adb, sem_ch5.adb, sem_ch6.adb, sem_ch8.adb, sem_ch9

[Ada] Error message on invalid prefixed procedure call

2021-05-03 Thread Pierre-Marie de Rodat
When the prefix of a call denotes an overloaded primitive operation, all possible interpretations are analyzed to determine the intended one. If all of them fail, then if the All_Errors flag is on all interpretations are analyzed anew to indicate why each one is illegal. If All_Errors is not set th

[Ada] Remove unused initial values in expansion of distributed calls

2021-05-03 Thread Pierre-Marie de Rodat
Default initialization of a local Fname variable was never used. Code cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_dist.adb (Build_From_Any_Call): Remove initial value for Fnam; fix style. (Build_To_Any_Call): Rem

[Ada] Ada.Strings.Unbounded.Aux.Set_String

2021-05-03 Thread Pierre-Marie de Rodat
The current version of Set_String is no longer used and not very useful and even unsafe with the introduction of a-stunau__shared.adb. Replace it with a more useful and safer version taking a callback to set the string. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgna

[Ada] Refine type of a counter object from Int to Nat

2021-05-03 Thread Pierre-Marie de Rodat
A local counter objects that are initialized with 0 and only incremented now have type Nat instead of Int. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb (Build_Finalize_Statements): Refine type of a local counter v

[Ada] Replace calls to RTE with Is_RTE where possible

2021-05-03 Thread Pierre-Marie de Rodat
Replace expression of the form "X = RTE (...)" with "Is_RTE (X, ...)", which avoids loading of the unit where the ... entity is defined. In particular, a sequence of RTE_Available and RTE load the target unit where Is_RTE doesn't. This patch is primarily a code cleanup, but it also avoids unnecess

[Ada] Fix reference to SPARK RM rule in comment

2021-05-04 Thread Pierre-Marie de Rodat
Adding rule about a user-defined equality operation as SPARK RM 6.1.4(11) is changing the numeration of previous rules (11,12). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Check_Mode_Restriction_In_Enclosing_Context): Fix reference to SPARK RM rule

[Ada] Guard against leading and trailing spaces reappearing in errors

2021-05-04 Thread Pierre-Marie de Rodat
The leading and trailing spaces in error message strings have been recently removed. This patch adds an assertion to prevent those spaces from appearing again. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Error_Msg_Internal): Add assertion to prevent s

[Ada] Wrong membership test computation for interface type

2021-05-04 Thread Pierre-Marie de Rodat
When the left expression of a membership test is an object implementing an interface type, and the right operand of such membership test is a non-class wide interface type, the compiler generates code that, instead of comparing the actual tag of the left expression to the tag of the right operand,

[Ada] Preliminary cleanup in floating-point output implementation

2021-05-04 Thread Pierre-Marie de Rodat
This moves the low-level processing on characters to the package Img_Util, factors out common processing with fixed point, and overhauls the handling of negative zeros and rounding. This also removes the Is_Negative intrinsic function, which was only accessible from predefined units and is now unu

[Ada] Fix inconsistent handling of character set control switches

2021-05-04 Thread Pierre-Marie de Rodat
Switch -gnatic, where "c" denotes a character set, is described in the GNAT User's Guide sections 4.3.11 Character Set Control and 4.3.1 Alphabetical List of All Switches, but the latter section didn't mention '5' as an allowed value for "c". This is implemented in csets.adb, switch-c.adb (for the

[Ada] Check entries for formals of mode IN appearing as global outputs

2021-05-04 Thread Pierre-Marie de Rodat
Rule SPARK RM 6.1.4(13) only mentions "subprograms", but it is equally applicable to protected entries whose global inputs cannot appear as global outputs in nested subprograms. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Check_Mode_Restriction_In_Enclosing

[Ada] Reject constants of access-to-variable type as function globals

2021-05-04 Thread Pierre-Marie de Rodat
Constants of an access-to-variable type can only appear as global outputs in procedures, tasks and protected entries, not in functions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_Global_Item): Take subprogram kind into account when acceptin

[Ada] Reject formals of mode IN appearing as global outputs

2021-05-04 Thread Pierre-Marie de Rodat
Fix implementation of SPARK RM 6.1.4(13), which says: "... if the global_specification of the outer subprogram has an entity denoted by a global_item with a mode_specification of Input or the entity is a formal parameter with a mode of in" but the rule was only enforced for outer subprogr

[Ada] Missing finalization on generic instantiation

2021-05-04 Thread Pierre-Marie de Rodat
If some objects are declared in the body of a generic package, these objects are not finalized when the package is instantiated at the library level. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb (Build_Finalizer_Helper.New_Finalizer_Name): Unnest so th

[Ada] Use error marker for messages in GNATprove mode

2021-05-04 Thread Pierre-Marie de Rodat
Force the use of the "error:" marker for error messages in GNATprove. This helps distinguishing these messages from others like warnings, check messages and info messages, in particular when colored output is used. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnat1drv.adb

[Ada] Simplify use of a global name buffer for Global/Depends errors

2021-05-04 Thread Pierre-Marie de Rodat
Error messages about the Global/Depends contracts are constructed in the Global_Name_Buffer, but there is no need to store those messages as the Name_Id objects. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Role_Error, Usage_Error): Replace calls to

[Ada] Move match function for pragma Warnings to public spec

2021-05-04 Thread Pierre-Marie de Rodat
In order to use the same matching function in GNATprove for justifying messages through pragma Annotate as the matching function used for pragma Warnings, make that function publicly visible in Erroutc. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * erroutc.adb (Matches): M

[Ada] Ongoing work for AI12-0212: container aggregates

2021-05-04 Thread Pierre-Marie de Rodat
This patch refines the handling of container aggregates with non-static sizes given with iterated component associations and iterated element associations. When necessary we construct an expression to be evaluated dynamically to guide the allocation of the container, prior to inserting elements. T

[Ada] Simplify iteration over formal parameters for Global/Depends check

2021-05-04 Thread Pierre-Marie de Rodat
Replace low-level First_Entity/Next_Entity with a high-level First_Formal/Next_Formal. The new code is easier to debug, because we don't even see local subprograms, objects, etc. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Collect_Global_Item): Iterate dire

[Ada] Fix inconsistent iteration with First_Formal and Next_Entity

2021-05-04 Thread Pierre-Marie de Rodat
Iteration routines should come in pairs, i.e. First_Formal with Next_Formal and First_Entity with Next_Entity. This patch fixes two occurrences where First_Formal was used with Next_Entity. Cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Reuse First_Formal for generic subprograms

2021-05-04 Thread Pierre-Marie de Rodat
Routine First_Formal works both for non-generic and generic subprograms, so patch removes a dubious special-casing for the latter. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-xref.adb (Generate_Reference_To_Formals): Remove dedicated branch for generic subpro

[Ada] Fix handling of access-to-variable objects in Global and Depends

2021-05-04 Thread Pierre-Marie de Rodat
Objects that typically would be constant, but can actually be written because they are of access-to-variable type, can appear as outputs in the Global and Depends contracts of non-functions (i.e. functions, procedures, generic functions, generic procedures, protected entries, task types and single

[Ada] Assert_Failure vs Assertion_Error

2021-05-04 Thread Pierre-Marie de Rodat
When Ada introduced Ada.Assertions.Assertion_Error, we made it a renaming of the existing System.Assertions.Assert_Failure as provisioned by the ARM, but we should have done it the other way around, so that the reference/first class exception is the one from the ARM in e.g. exception messages. Thi

[Ada] Refine type of a counter variable from Integer to Natural

2021-05-04 Thread Pierre-Marie de Rodat
A List_Name_Count variable is initialized with zero, then incremented and decremented in a stack-like manner, so it should never become negative. This gives us extra confidence, but otherwise the behaviour is not affected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ppr

[Ada] Do not "optimize" by converting Positive to Unsigned

2021-05-04 Thread Pierre-Marie de Rodat
Back out the previous change that tried to "optimize" in Expand_Concatenate. It turns out that this is actually a pessimization, and it causes codepeer to trip over a bunch of extra checks. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_Concatenate): Rem

[Ada] Minor tweak in pretty-printing of expressions

2021-05-04 Thread Pierre-Marie de Rodat
Printing of expressions is used in GNATprove to display parts of an assertion which are not proved, Here the printing is improved slightly for an expression-with-actions, so that the underlying expression is printed, instead of the corresponding AST form of the expression with Expr_Name. Tested on

[Ada] Reuse existing To_Mixed routine in pretty-printer

2021-05-04 Thread Pierre-Marie de Rodat
Unit Pprint, which implements pretty-printing of the AST, defined routine To_Mixed_Case, which was identical to System.Case_Util.To_Mixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * pprint.adb (To_Mixed): Removed.diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb ---

[Ada] Use function and not procedure UI_Image in pretty-printing

2021-05-04 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. The code for pretty-printing integer, real and string literals now looks the same. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * pprint.adb (Expr_Name): Simplify with functional variant of UI_Image.diff --git a/gcc/ada/pprint.

[Ada] Remove arbitrary and redundant qualification with Sinfo

2021-05-04 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Perhaps the extra qualification used to be necessary to avoid ambiguities, but it is no longer needed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * pprint.adb: Remove qualification of arbitrary calls to Sinfo.Expressions and

[Ada] Set constraint error on real division just like on integer division

2021-05-05 Thread Pierre-Marie de Rodat
In Eval_Arithmetic_Op we set Raises_Constraint_Error flag on integer division by zero, but we didn't set it for real division by zero. This only affects GNATprove, because GNAT sets this flag inside Apply_Compile_Time_Constraint_Error (which has an early return guarded by GNATprove_Mode). Possibly

[Ada] Ongoing work for AI12-0212: container aggregates

2021-05-05 Thread Pierre-Marie de Rodat
Add legality checks for indexed aggregates with component associations. RN 4.3.5 (28/5 - 30/5) specifies validity rules for indexed aggregates, intended to simplify implementation as well as the computation of the expected size of an indexed aggregate, such for an aggregaate of a vector type. Tes

[Ada] Implement tiered support for floating-point output operations

2021-05-05 Thread Pierre-Marie de Rodat
This changes the implementation of output operations for floating-point types from using Long_Long_Float for all floating-point types to using a base type tailored to the type being operated on. This comprises adjusting Ada.Text_IO.Float_IO and Ada.Text_IO.Complex_IO to the new approach, as well a

[Ada] Remove unnecessary parameter of Apply_Compile_Time_Constraint_Error

2021-05-05 Thread Pierre-Marie de Rodat
In routine Apply_Compile_Time_Constraint_Error the Rep parameter was disabling rewriting into N_Raise_Constraint_Error node. It is only referenced when this routine is called from GNATprove, but in GNATprove_Mode rewriting is disabled anyway. It seems cleaner to remove this parameter and keep this

[Ada] Refactor repeated call to Next when pretty-printing if-expressions

2021-05-05 Thread Pierre-Marie de Rodat
Code cleanup (and minuscule performance improvement); semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * pprint.adb (Expr_Name): Introduce local constants to make the code more readable and avoid repeated calls to Next to reach the ELSE

[Ada] Remove redundant explicit calls to UI_From_Int in comparisons

2021-05-05 Thread Pierre-Marie de Rodat
Relational operators for universal integers come in three variants, e.g.: function "=" (Left : Uint; Right : Uint) return Boolean renames UI_Eq; function "=" (Left : Int; Right : Uint) return Boolean renames UI_Eq; function "=" (Left : Uint; Right : Int) return Boolean renames UI_Eq; p

[Ada] Adjust expansion of perfect hash function for Value

2021-05-05 Thread Pierre-Marie de Rodat
This moves the declaration of the 4 tables to inside the function itself for reasons explained in the code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_imgv.ads (Build_Enumeration_Image_Tables): Adjust comment. * exp_imgv.adb (Build_Enumeration_Image_Tables):

[Ada] Use inline expansion of Image for enumeration types by default

2021-05-05 Thread Pierre-Marie de Rodat
This reduces the number of bootstrap dependencies for the compiler. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * debug.adb (d_x): Document new usage. * exp_imgv.adb (Expand_User_Defined_Enumeration_Image): Add Typ parameter and use it throughout the proces

[Ada] Handle defaults in declare_expressions in postconditions

2021-05-05 Thread Pierre-Marie de Rodat
In Ada2020 the expression for a postcondition can be a Declare_Expression containing object declarations with defaults. These defaults may generate local subtypes, but as for other default expressions their full expansion must be deferred, typically to the freeze point of the object being declared,

[Ada] Speed up enumeration'Value with perfect hash function

2021-05-05 Thread Pierre-Marie de Rodat
This speeds up the implementation of the Value attribute for enumeration types with more than 3 values by using a perfect hash function to do the lookup instead of a linear search. This also generizes the implementation of the associated support routines in the runtime, as well as that of the supp

[Ada] Don't emit style errors when parens are required

2021-05-05 Thread Pierre-Marie de Rodat
GNAT currently emits style errors for declare expressions in conditions even though their parens are required. This commit fixes that. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch5.adb (P_Condition): Check if expression is declare expression.diff --git a/gc

[Ada] Qualify internal access-to-subprogram types as not null

2021-05-05 Thread Pierre-Marie de Rodat
When an access-to-subprogram type is qualified as not null, then the compiler is likely to generate a more efficient code. This patch adds such qualifiers to the internal runtime bodies, so no clients of those runtime units are affected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Small cleanup in the Expand_Image_Attribute procedure

2021-05-05 Thread Pierre-Marie de Rodat
This moves the inline expansion for user-defined enumeration types back into the normal flow of control, moves the declarations of local objects to where they are needed and removes an explicit check for private types in the enumeration case, which is now superfluous. No functional changes. Teste

[Ada] Use inline expansion of Image for standard boolean by default

2021-05-05 Thread Pierre-Marie de Rodat
This avoids a call to the runtime and a string copy. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * debug.adb (d_x): Document extended usage. * exp_imgv.adb (Expand_Standard_Boolean_Image): New procedure. (Expand_Image_Attribute): Call it to expand in line t

[Ada] Move Build_And_Insert_CUDA_Initialization to expansion phase

2021-05-05 Thread Pierre-Marie de Rodat
This function really had no business being called during analysis. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb (Expand_N_Package_Body): Add CUDA init call. * sem_ch7.adb (Analyze_Package_Body_Helper): Remove CUDA init call.diff --git a/gcc/ada

[Ada] Spurious warning on useless assignment with target name

2021-05-05 Thread Pierre-Marie de Rodat
An assignment to an entity E triggers an improper warning that an immediately preceding assignment to E is useless, when the right-hand side of the new assignment includes a target name, that is to say the Ada2020 use of "@" to designate the left-hand side of the assignment. Tested on x86_64-pc-li

[Ada] Detect unchecked union components with fully qualified names

2021-05-05 Thread Pierre-Marie de Rodat
Unchecked union components were detected only when declared with unqualified type names. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Component_Is_Unconstrained_UU): Detect both qualified and unqualified names of unchecked union components.diff --git

[Ada] Fix s-os_lib.adb so vectorizing compilation works

2021-05-05 Thread Pierre-Marie de Rodat
Fix s-os_lib.adb so vectorizing compilation works. Without this, the compiler crashes while compiling s-os_lib.adb. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-os_lib.adb (Missed_Drive_Letter): Simplify the code.diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/

[Ada] Remove redundant checks for empty lists

2021-05-05 Thread Pierre-Marie de Rodat
When iterating over list elements with First/Next there is no need to detect empty or non-existing list, because First intentionally returns Empty in those cases. Cleanup of code related to Unchecked_Unions; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Do not use hash function for enumeration Value with trampolines

2021-05-05 Thread Pierre-Marie de Rodat
This prevents the generation of the new perfect hash function for the Value attribute of local enumeration types when the target still uses trampolines to implement pointers to local subprograms. The generation of trampolines would be unexpected in these circumstances and maybe even forbidden by t

[Ada] Refine types of variables with call to Scope as their initial values

2021-05-05 Thread Pierre-Marie de Rodat
Call to Scope returns an Entity_Id, not just Node_Id. This patch refines the types in two occurrences of a call to Scope as an initial value. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (User_Defined_Primitive_Equality_

[Ada] Remove commented code

2021-05-05 Thread Pierre-Marie de Rodat
The comment indicates that "The whole section including this comment can be removed later ???", and 10 years qualifies as "later". Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Is_Possibly_Unaligned_Object): Remove commented code.diff --git a/gcc/ada/

[Ada] Incorrect accessibility level on actual in procedure call

2021-05-05 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby dispatching calls to subprograms featuring anonymous access formals may get incorrectly expanded in such a way so as to lead to spurious runtime accessibility check failures within the callee. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/

[Ada] Detect unchecked union subcomponents in nested variant parts

2021-05-05 Thread Pierre-Marie de Rodat
Routine Has_Unconstrained_UU_Component didn't traverse into nested variant parts of a record type definition. Now it precisely follows the Ada RM grammar to make sure that the traversal doesn't miss anything. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Has_U

[Ada] Fix expansion of attributes Input/Output for unchecked union types

2021-05-05 Thread Pierre-Marie de Rodat
Expansion of attributes Input/Output for unchecked unions didn't work, because it looked for a No_Elist where the AST has an empty list. Now we look for a default value of a first discriminant (because the default values must be given either for all or for none of the discrminants). Also, it was w

[Ada] Reuse Has_Defaulted_Discriminants where possible

2021-05-05 Thread Pierre-Marie de Rodat
Remove excessive defensive check from Has_Defaulted_Discriminants and reuse it where possible. Cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb, exp_ch9.adb, sem_ch3.adb: Reuse Has_Defaulted_Discriminants. *

[Ada] Remove redundant condition for Image attribute and Ada version

2021-05-06 Thread Pierre-Marie de Rodat
Routine Error_Msg_Ada_2012_Feature includes a test on Ada_Version, so there is no need to explicitly test the same condition just before the call. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Analyze_Image_Attribute): Remove redundant condition; add

[Ada] Remove excessive conditions in iterations across components

2021-05-06 Thread Pierre-Marie de Rodat
When iterating with First_Component/Next_Component we don't need to check that the Ekind of the iterator variable is E_Component. Code cleanup related to record equality and unchecked unions; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.a

[Ada] Crash on if_expression used as index of discriminant-dependent array

2021-05-06 Thread Pierre-Marie de Rodat
The compiler aborts on an if_expression used as an index when the object being indexed is a discriminant-dependent component, and the frontend generates an improper range check on the expression instead of the required index check. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Remove unused initial value in Read_Library_Info_From_Full

2021-05-06 Thread Pierre-Marie de Rodat
Remove an initial value of a local variable that were never used. Static analysis tools like CodePeer should easily recognize that this variable is only accessed after being written. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * osint.adb (Read_Library_Info_From_Full): Cle

[Ada] Fix restriction No_Enumeration_Maps on both Image attributes

2021-05-06 Thread Pierre-Marie de Rodat
Restriction No_Enumeration_Maps was only checked on Value attribute (and its Wide and Wide_Wide variants). Now it is checked also on Img, Image and its Wide and Wide_Wide variants, just like described in the GNAT RM. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.a

[Ada] Implement tiered support for floating-point exponentiation

2021-05-06 Thread Pierre-Marie de Rodat
This changes the implementation of floating-point exponentiation from using Long_Long_Float for all floating-point types to using a base type tailored to the type being operated on. The computation is done in double precision internally, which gives more accurate results for Long_Float and Long_Lo

[Ada] Remove hardcoded pragma Warnings from the formal vectors library

2021-05-06 Thread Pierre-Marie de Rodat
Pragma Warnings in the generic formal vectors library was only suppressing a message in one specific instantiation within one specific GNATprove test. This pragma was referring to "type T defined at line 4", which is exactly the type declared in that test; the suppression didn't work for any other

[Ada] Fix handling of PATs

2021-05-06 Thread Pierre-Marie de Rodat
When trying to compare two fields, one that's a packed array of known length and one that's a packed array of unknown length, Expand_Packed_Eq converts each side of the equality to its packed array type and then says that's enough if the types are modular integer types. That's correct, however, onl

[Ada] Make new implementation of System.Fat_Gen.Valid more robust

2021-05-06 Thread Pierre-Marie de Rodat
The comparison of any denormalized number with 0.0 may return True on hardware not supporting denormals, so we need to do a bit comparison. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-fatgen.adb (Valid): Do a bit comparison with 0.0 when denormalized nu

[Ada] Spurious constraint error on conversion of access types

2021-05-06 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby a spurious constraint error is raised at runtime on type conversions between access-to-discriminanted types when the object being converted is null. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Make_Discriminan

[Ada] Fix off-by-one bug in underflow handling of Scaling

2021-05-06 Thread Pierre-Marie de Rodat
Gradual underflow needs to be used for one more exponent. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-fatgen.adb (Scaling): Fix off-by-one bug for underflow.diff --git a/gcc/ada/libgnat/s-fatgen.adb b/gcc/ada/libgnat/s-fatgen.adb --- a/gcc/ada/libgnat/s-fatgen.

[Ada] Reset x87 FPU to 64-bit precision for floating-point I/O on Linux

2021-05-06 Thread Pierre-Marie de Rodat
This is basically done on all x86/x86-64 native systems except for Linux and makes it possible to work around other precision settings, e.g Java's. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * init.c (__gnat_init_float): Use full version on Linux too.diff --git a/gcc/ada/

[Ada] Make Is_OK_Static_Subtype use Is_Static_Subtype

2021-05-06 Thread Pierre-Marie de Rodat
The reason for this change is two-fold: - There is code duplication between Is_OK_Static_Subtype and Is_Static_Subtype - Is_Static_Subtype is more correct than Is_OK_Static_Subtype (e.g. the dynamic predicate checks are more complete in Is_Static_Subtype). Tested on x86_64-pc-linux-gnu, commit

[Ada] Set Raises_CE flag only in Apply_Compile_Time_Constraint_Error

2021-05-06 Thread Pierre-Marie de Rodat
Routine Apply_Compile_Time_Constraint_Error, when operating in GNAT mode, always sets Raises_Constraint_Error flag, so there is no need to follow it with calls to Set_Raises_Constraint_Error. These calls only had an effect in GNATprove mode, but they were following few calls to Apply_Compile_Time_C

[Ada] Do not second-guess the hardware for underflow handling of Scaling

2021-05-06 Thread Pierre-Marie de Rodat
This defers to the hardware implementation for the handling of underflow in the Scaling routine also in the case where denormals are not supported. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-fatgen.adb (Scaling): Use single handling of underflow. Add

[Ada] Assert failure on pragma Inline in procedure body

2021-05-06 Thread Pierre-Marie de Rodat
Is_Inline_Pragma isn't always dealing properly with N not being a list member and Spec_Id being null. This is now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Is_Inline_Pragma): Protect against N not being a list member in both branches.diff --

[Ada] Missing semantic error on ineffective Others_Clause

2021-05-06 Thread Pierre-Marie de Rodat
Compiler fails to reject an Others_Clause in an aggregate for a constrained array type when previous components of the aggregate cover the full index range of the array subtype, and the expression in the Others_Clause has a type incompatible with the component type of the array. The Others_Clause d

[Ada] In CodePeer mode, use regular-exception handling

2021-05-06 Thread Pierre-Marie de Rodat
After a change done for GNATProve in 2016, CodePeer_Mode was not using the regular exception mechanism. This resulted in imprecise control-flow graphs in some cases. Revert that change for CodePeer. And, since for GNATprove_Mode Operating_Mode is never Generate_Code, we can simplify the code a bit.

[Ada] AI12-0411: Add "bool" to Interfaces.C

2021-05-06 Thread Pierre-Marie de Rodat
This AI adds in Interfaces.C a binding to the C type _Bool/bool. Note that this AI makes ambiguous the construct pragma Assert (False) when using Interfaces.C. To hopefully provide slightly better backward compatibility, we make Interfaces.C.Extensions.bool a renaming of Interfaces.C.bool so that

[Ada] Bad expansion with -gnato2 and if expression

2021-05-06 Thread Pierre-Marie de Rodat
When dealing with -gnato2 inside an if expression, we might drop on the floor the If or Else_Nodes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_If_Expression): Apply_Arithmetic_Overflow_Check will not deal with Then/Else_Actions so s

[Ada] Avoid repeated analysis of constraint ranges

2021-05-06 Thread Pierre-Marie de Rodat
Don't call Analyse just before Process_Range_Expr_In_Decl, because the latter starts with a call to Analyze_And_Resolve anyway. This fixes a violation with the required sequencing in resolution of overloaded nodes that requires the Etype being Any_Type and Is_Overloading being False before calling

[Ada] ACATS 4.1R-c611a04: Class-wide preconditions in dispatching calls

2021-05-06 Thread Pierre-Marie de Rodat
This patch is a partial implementation of the semantics mandated in AI12-0195 concerning class-wide preconditions on dispatching calls: the precondition that applies is that of the denoted subprogram entity, not that of the body that is actually executed. Tested on x86_64-pc-linux-gnu, committed o

[Ada] Spurious error on protected call in inherited postcondition

2021-05-07 Thread Pierre-Marie de Rodat
An inherited class-wide precondition of a primitive of a protected type cannot include a call to a protected primitive of the type, as specified in AI12-0166. This patch adds a guard to verify that this legality rule applies only to a precondition and not to a postcondition. Tested on x86_64-pc-l

[Ada] Move Has_Inferable_Discriminants to Sem_Util

2021-05-07 Thread Pierre-Marie de Rodat
Move the Has_Inferable_Discriminants utility to Sem_Util so that it can be reused inside GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Has_Inferable_Discriminants): Moved to Sem_Util. * sem_util.ads, sem_util.adb (Has_Inferable_Discriminants

[Ada] Raise Constraint_Error for Compose and Scaling if Machine_Overflows

2021-05-07 Thread Pierre-Marie de Rodat
This is an optional behavior specified by the RM and it makes sense to do it when T'Machine_Overflows is True for the sake of consistency. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-fatgen.adb (Scaling): Raise Constraint_Error in the overflow case when

[Ada] sigtramp: fix powerpc64 against -fPIC

2021-05-07 Thread Pierre-Marie de Rodat
Use a local label to set the TOC location on powerpc64 to prevent DT_TEXTREL, not supported by the VxWorks loader for shared libraries. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sigtramp-vxworks-target.inc: Use a local label for the TOC.diff --git a/gcc/ada/sigtramp-vx

[Ada] Minor efficiency improvement in containers

2021-05-07 Thread Pierre-Marie de Rodat
Move an assertion to be conditional on T_Check, so pragma Suppress (Tampering_Checks) will suppress it. Note that the Lock component being checked has the Atomic aspect. This is not a bug fix. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-conhel.adb (TC_Check):

[Ada] Fix signature mismatch for Defining_Entity

2021-05-07 Thread Pierre-Marie de Rodat
This fixes the signature mismatch recently introduced for Defining_Entity between the front-end proper and gigi. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads (Defining_Entity): Remove Empty_On_Errors parameter. (Defining_Entity_Or_Empty): New function

[Ada] Computation of Shift_Left and large signed values

2021-05-07 Thread Pierre-Marie de Rodat
The computation of Shift_Left on signed values might wrongly overflow instead of generating a negative value. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.adb (Fold_Shift): Fix computation of Shift_Left resulting in negative signed values.diff --git a/gcc

[Ada] Crash on imported object with deep initialization and No_Aborts

2021-05-07 Thread Pierre-Marie de Rodat
Compiler aborts on an object declaration without an expression, when the type of the object includes controlled components and thus requires deep initialization, there are various restrictions in effect that prevent Abort statements, and there is a later Import pragma that applies to the object bei

[Ada] Attribute Address is not an interfering context in SPARK

2021-05-07 Thread Pierre-Marie de Rodat
Allow taking the address of a volatile object in SPARK, as it doesn't cause problems related to interfering contexts. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Flag_Object): Ignore prefixes of attribute Address.diff --git a/gcc/ada/sem_res.adb b/gc

[Ada] Remove End_Interp_List from the overloaded resolution API

2021-05-07 Thread Pierre-Marie de Rodat
Routine End_Interp_List was part of the API for overloaded resolution from the very beginning. However, it quickly become unnecessary, because both adding and removing interpretation maintains a No_Interp marker at the end of the interpretation list. The only effect of this routine was that it pre

[Ada] Generate warning for negative literal of a modular type

2021-05-07 Thread Pierre-Marie de Rodat
A negative literal of a module type is interpreted with wrap-around as a large positive number. Warn if this value is not enclosed in a type qualification or type conversion explicitly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * opt.ads: Update comment for Warn_On_Suspi

[Ada] Spurious error with component of unchecked_union type

2021-05-07 Thread Pierre-Marie de Rodat
Compiler rejects an equality operation on a record type when the nominal subtype of a component is a constrained subtype of an Unchecked_Union type, and that subtype is declared outside of the enclosing record declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_

[Ada] Fix type mismatch warnings during LTO bootstrap #1

2021-05-07 Thread Pierre-Marie de Rodat
This sets convention C on enumeration types and functions declarations involving System.Address, and makes adjustements to fe.h accordingly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.ads (Set_Identifier_Casing): Add pragma Convention C. * eval_fat.ads (R

[Ada] Implement aspect No_Controlled_Parts

2021-05-07 Thread Pierre-Marie de Rodat
This patch implements the No_Controlled_Parts aspect defined in AI12-0256 which when specified for a type will verify such type or any ancestors of such type with contain no controlled components. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * aspects.ads: Add entries to re

<    1   2   3   4   5   6   7   8   9   10   >