[Ada] Reserving switch d_K for known problem isssues detection

2019-12-17 Thread Pierre-Marie de Rodat
This patch documents that switch -gnatd_K is reserved to enable machinery that detects known problem issues of previous releases. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-18 Javier Miranda gcc/ada/ * debug.adb: Document -gnatd_K as a reserved switch for the d

[Ada] Bad "already use-visible" warning re: use in private part

2019-12-17 Thread Pierre-Marie de Rodat
This patch fixes a bug in which if a parent package has a use clause in its private part, and a child of that parent has a use clause for the same thing in its context clause, the compiler incorrectly warns that the one in the child is redundant. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Do not propagate Object_Size onto Size for composite types

2019-12-17 Thread Pierre-Marie de Rodat
This gets rid of an old bypass used in the compiler, which would copy the value set in an Object_Size clause for record types onto Size. This means that a confirming Object_Size clause can prevent packing, which is counter-intuitive given that Object_Size is not supposed to pertain to packing at a

[Ada] Wrong error on hidden must-override primitive

2019-12-17 Thread Pierre-Marie de Rodat
The compiler gave a wrong error about "must override" in the following case. A private type is completed with a derived type that inherits a must-override function. Outside that package, a type extension of the private type is declared. The function on that type extension is not visible, and is n

[Ada] AI12-0282: shared variable control aspects on formal types

2019-12-17 Thread Pierre-Marie de Rodat
Ada202X allows some aspects related to shared variable control to appear on formal type declarations. These aspects represent new enforceable parts of the contract between generic units and instantiations. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-18 Ed Schonberg gcc/ada/

[Ada] Missing accessibility actuals on calls to interface conversion functions

2019-12-17 Thread Pierre-Marie de Rodat
In certain cases of conversions to interface types, the compiler generates a special function to handle the conversion. In cases where such a function has an extra accessibility-level formal and the target type of the conversion has a designated type that comes from a limited view (via limited_with

[Ada] Document the introduction of the Object_Size attribute in Ada 2020

2019-12-17 Thread Pierre-Marie de Rodat
This adds references to Ada 2020 in the section documenting the two size attributes used by GNAT, namely Object_Size and Value_Size, as well as in the head comment of Subtypes_Statically_Match. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-18 Eric Botcazou gcc/ada/ * einf

[Ada] Fix three-letter typos like "sss" in comments and docs

2019-12-17 Thread Pierre-Marie de Rodat
Fix three-letter typos like "alllowed" or "corrresponding". They can be detected with this command: $ grep "[[:alpha:]]\([[:lower:]]\+\)\1\1" ... but need to be manually filtered for things like "ieee", "dd-mm-" or hexadecimal literals. Tested on x86_64-pc-linux-gnu, committed on trunk 20

[Ada] Missing accessibility check on access discriminants

2019-12-17 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby compile-time checks on return aggregates with anonymous access discriminants were not performed when multiple of such discriminants were present, the aggregate was within an extended return statement, or the aggregate was within a qualified expression. Tested on x

[Ada] Fix overriding subprogram being incorrectly seen as returning

2021-07-05 Thread Pierre-Marie de Rodat
Before this commit, GNAT failed to notice that subprograms overriding non-returning subprograms could be renamings of non-returning subprograms and thus wrongfully emitted an error. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Check_Abstract_Overriding): Chec

[Ada] Do not catch 'N rem -1' in CodePeer_Mode

2021-07-05 Thread Pierre-Marie de Rodat
The special case used for catching the 'rem -1' operation is not useful to CodePeer, and in fact may be detrimental to its precision. Remove it in CodePeer_Mode. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_Op_Rem): Remove special case for rem -1

[Ada] Refactoring related to Returns_By_Ref

2021-07-05 Thread Pierre-Marie de Rodat
Split out the computation of Returns_By_Ref, to make subsequent changes easier. General cleanups. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads, sem_util.adb (Compute_Returns_By_Ref): New procedure to compute Returns_By_Ref, to avoid some code

[Ada] Print JSON continuation messages as separate messages

2021-07-05 Thread Pierre-Marie de Rodat
Printing continuation messages as a single JSON message was an error as consumers of the JSON output can take advantage of different locations of the continuation message. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Output_JSON_Message): Recursively call

[Ada] Fix crash when printing error message

2021-07-05 Thread Pierre-Marie de Rodat
Missing Chars on N were causing a crash - the solution is to set the Sloc from N and to use F_type's chars. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Profile): Use N's Sloc, F_type's chars.diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb --- a/gc

[Ada] Spurious error in instantiation with aggregate and private ancestor

2021-07-05 Thread Pierre-Marie de Rodat
Compiler rejects an instantiation but accepts the corresponding generic unit, when it includes a declaration for a private type whose full view is a record type with a controlled component, and the full view of an object of the type is given by an aggregate with default-initialized components. Tes

[Ada] Cleanup checking for compatible alignment

2021-07-05 Thread Pierre-Marie de Rodat
Code cleanup only related to handling of Address clauses in GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Has_Compatible_Alignment_Internal): Fix indentation of ELSIF comments; remove explicit calls to UI_To

[Ada] Turn GNAT_Annotate into its own pragma

2021-07-05 Thread Pierre-Marie de Rodat
GNAT_Annotate being an alias of Annotate rather than its own pragma results in issues for tools that rely on snames to get a list of available pragmas. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * aspects.ads: Add GNAT_Annotate aspect. * gnat1drv.adb (Adjust_Globa

[Ada] Move overriding rename error message from declaration to use

2021-07-05 Thread Pierre-Marie de Rodat
Posting the error message on the declaration of the renamed subprogram is more confusing than posting the message on the name of the renamed subprogram in the renaming. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Check_Abstract_Overriding): Post error messag

[Ada] Adapt SPARK checking after change in rules regarding heap modeling

2021-07-05 Thread Pierre-Marie de Rodat
Rules in SPARK RM section 3.10 regarding modeling of heap through dynamic (de)allocation has changed. As a result, the dependency contract of Ada.Unchecked_Deallocation can be added directly in the sources, and placement of allocators is not checked in the frontend anymore. Tested on x86_64-pc-lin

[Ada] Fix comment about the debug flag for strict alignment

2021-07-05 Thread Pierre-Marie de Rodat
The "strict alignment" compilation mode is controlled by -gnatd.a, as described in Adjust_Global_Switches. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ttypes.ads (Target_Strict_Alignment): Fix comment.diff --git a/gcc/ada/ttypes.ads b/gcc/ada/ttypes.ads --- a/gcc/ada/tty

[Ada] The Unix Epochalyse of 2038 - OS_Time

2021-07-05 Thread Pierre-Marie de Rodat
OS_Time is use mainly in the interface to the "C" part of the GNAT RTL. Change it to a 64-bit signed type on all targets. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.h (OS_Time): typedef as long long. * osint.adb (Underlying_OS_Time): Declare as 64-bit sig

[Ada] The Unix Epochalypse of 2038 - Use OS_Time

2021-07-05 Thread Pierre-Marie de Rodat
__gnat_set_file_time_name is called from Ada with OS_Time, but the C function argument is time_t. This is a violation of the interface rule that calls to the C parts use OS_Time. It currently works by accident. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.h (__gn

[Ada] Temporarily disable Ada 2022 Image and Put_Image support for tagged types

2021-07-05 Thread Pierre-Marie de Rodat
Revert to having support for Ada 2022's Image and Put_Image attributes of tagged types conditional on the -gnatd_z switch (as opposed to being enabled unconditionally). This is a temporary change, so the comments in debug.adb about the -gnatd_z switch have not been restored. Tested on x86_64-pc-li

[Ada] Fix missing minus sign in literal translation

2021-07-05 Thread Pierre-Marie de Rodat
When translating literals to big reals, the compiler would forget about the minus sign and turn a negative number into a positive one. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve): Insert minus sign if needed.diff --git a/gcc/ada/sem_res.adb b/gcc/ad

[Ada] The Unix Epochalyse of 2038 - OS_Time comparison

2021-07-05 Thread Pierre-Marie de Rodat
The comment in the public section of the spec says the comparison ops are intrinsic, but that doesn't match the private part implementation and comment. Fix this. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-os_lib.ads: Import OS_Time comparison ops as i

[Ada] The Unix Epochalypse of 2038 (Warn about time_t in the compiler)

2021-07-05 Thread Pierre-Marie de Rodat
Add some comments to warn about the use of time_t in the host based tools since it's not practical to remove the declaration itself. Rename some formal parameters in internal subprograms to reflect the fact that OS_Time is the preferred interface type. Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Fix excessive check for alignment of overlaying objects

2021-07-05 Thread Pierre-Marie de Rodat
When generating alignment checks for Address representation clauses we optimized them away for clauses like: for X'Address use Arr (1)'Address; for X'Address use Rec.C'Address; but not: for X'Address use Obj'Address; even though the alignment of Obj is known. Tested on x86_64-pc-linux-gn

[Ada] Fix missing error messages when returning limited type

2021-07-05 Thread Pierre-Marie de Rodat
Check_Limited_Return originally used Comes_From_Source (N) in order to decide whether N was a return statement created from an extended return statement or not. This was a problem because the return statement from expression functions also have their Comes_From_Source flag set to false. The soluti

[Ada] Fix some "current instance" bugs

2021-07-05 Thread Pierre-Marie de Rodat
This started out as an Ada2022 ticket, but work on Ada 2022 constructs uncovered bugs that could affect pre-Ada2022 code. Fix those bugs. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): When building the assignme

[Ada] Adapt SPARK RM rule on non-effectively volatile abstract state

2021-07-05 Thread Pierre-Marie de Rodat
SPARK RM 7.1.3(8) has been updated to reflect the fact that abstract states which do have Async_Writers or Effective_Reads cannot have as constituents objects which are effectively volatile for reading, hence need not require that a function reading such an abstract state be marked as a volatile fu

[Ada] Reject overlays in Global/Depends/Initializes contracts

2021-07-05 Thread Pierre-Marie de Rodat
Object overlays, i.e. objects with an Address clause that specify the address of an overlaid object, are no longer allowed to appear in SPARK data and dependency flow contracts. Also, they do not contribute to the package state and so don't need to appear in Refined_State contracts. Tested on x86_

[Ada] Simplify and reuse Is_Concurrent_Interface

2021-07-05 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Stream_Operation_OK): Reuse Is_Concurrent_Interface. * sem_ch3.adb (Analyze_Interface_Declaration, Build_Derived_Record_Type): Likewise. * sem_

[Ada] Clean up Get_Index_Bounds

2021-07-05 Thread Pierre-Marie de Rodat
Replace some calls to procedure Get_Index_Bounds with calls to the function with the same name. Not all calls are replaced (some seem clearer as procedure calls). Change names to be more consistent with the RM. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb, exp

[Ada] Add Ada 2022 Image and Put_Image support for tagged types

2021-07-05 Thread Pierre-Marie de Rodat
GNAT's initial implementation of Ada 2022's Image and Put_Image attributes did not include full support for tagged types. Improve that level of support. This support is still disabled by default and is enabled via the -gnatd_z switch because it generates additional dispatching routines even for Ada

[Ada] INOX: prototype alternative accessibility model

2021-07-05 Thread Pierre-Marie de Rodat
This patch implements an experimental restriction No_Dynamic_Accessibility_Checks which presents the two alternative accessibility models. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Accessibility_Checks_Suppressed): Add check against restriction No_D

[Ada] Remove Ada.Strings.Text_Output and child units

2021-07-05 Thread Pierre-Marie de Rodat
The GNAT-defined package Ada.Strings.Text_Output has been replaced by the Ada-defined package Ada.Strings.Text_Buffers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-stobbu.adb, libgnat/a-stobbu.ads, libgnat/a-stobfi.adb, libgnat/a-stobfi.ads, lib

[Ada] Add Reference and Constant_Reference functions to formal containers

2021-07-05 Thread Pierre-Marie de Rodat
Reference and Constant_Reference functions are added to all formal containers types, returning an access to an element in the container. This takes avantage of pointer support in SPARK. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfdlli.ads, libgnat/a-cfdlli.ad

[Ada] Spurious conformance error on expression function

2021-07-06 Thread Pierre-Marie de Rodat
Compiler rejects an expression function whose signature includes an access parameter with a null_exclusion indicator. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not perform conformance check when the subprogram bo

[Ada] Add GNAT RM text regarding Ada 2022 default Put_Image implementation

2021-07-06 Thread Pierre-Marie de Rodat
Add GNAT RM text indicating that users should not rely on the details of the text generated by the default implementation of T'Put_Image for any nonscalar type T. The compiler is free to change the details of such text, subject to the general guidance on this topic given in the Ada RM. Tested on x

[Ada] Support for Object.Op subprogram-call notation for untagged types

2021-07-06 Thread Pierre-Marie de Rodat
This is a prototype implementation of a language extension that allows calls to primitives of untagged types to be written using prefixed notation. That is, the first actual parameter of the call is given as a prefix using selected_component syntax, and the selector is a primitive operation of the

[Ada] Add Void_Or_Type_Kind and Exception_Or_Object_Kind

2021-07-06 Thread Pierre-Marie de Rodat
To be used in GNAT LLVM as declarations for parameters and variables. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-types.ads (Void_Or_Type_Kind, Exception_Or_Object_Kind): Declare. * gen_il-gen-gen_entities.adb: Likewise.diff --git a/gcc/ada/gen_il-

[Ada] Unix Epochalypse (s-osprim.adb)

2021-07-06 Thread Pierre-Marie de Rodat
System.OS_Primitives in libgnat for VxWorks imports Ssystem.OS_Interface in libgnarl, creating a dependency on libgnarl by libgnat. This works as long as the functions being referenced in OS_Primitives were pragma imported functions from the kernel, but this is no longer the case with a selectable

[Ada] Improper predicate check on view conversion

2021-07-06 Thread Pierre-Marie de Rodat
This patch removes an incorrect predicate check applied to a view conversion of a tagged object. Such a view conversion is an object and can appear as the target of an assignment statement, in which case no predicate check applies to the now-dead value. Tested on x86_64-pc-linux-gnu, committed on

[Ada] Make parent of N_Exception_Declaration be N_Declaration

2021-07-06 Thread Pierre-Marie de Rodat
The parent was Node_Kind before. This is a minor cleanup, and has no effect on the operation of the compiler. However, if we start declaring more objects of the various predicated subtypes, such as N_Declaration_Id, it would be good to get them right. Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Return when not working for procedures

2021-07-06 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby the experimental "return when" feature was not supported in procedures. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch6.adb (Get_Return_Kind): Properly handle the case of a "return when" statement in the procedur

[Ada] Tbuild cleanup

2021-07-06 Thread Pierre-Marie de Rodat
This patch removes some unnecessary unchecked conversions from the generated code. This makes the .dg output more readable in some cases, especially those involving finalization. Also misc cleanups. This patch does not change calls to Make_Unchecked_Type_Conversion to Unchecked_Convert_To, but we

[Ada] Missing space in error message for pattern matching

2021-07-06 Thread Pierre-Marie de Rodat
Some error messages issued regarding limitations of the current implementation of the GNAT extension for pattern matching are missing space characters. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_case.adb: Fix error message.diff --git a/gcc/ada/sem_case.adb b/gcc/ada

[Ada] Crash on use of 'Img on record type in expression

2021-07-06 Thread Pierre-Marie de Rodat
Compiler aborts on a use of attribute 'Img on an object of a record type, when the attribute reference occurs within a larger expression, such as a string comparison. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Process_Transient_In_Expression): Ensure that

[Ada] Spurious initialization of element iterators in "for of" loops

2021-07-06 Thread Pierre-Marie de Rodat
This patch corrects an issue in the compiler whereby initialization gets incorrectly performed on element iterators in "for of" loops. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch5.adb (Expand_Formal_Container_Element_Loop): Remove legacy expansion of eleme

[Ada] Regression on overloaded prefixed calls related to prefixed-call extension

2021-07-06 Thread Pierre-Marie de Rodat
The recently added extension of allowing prefixed-call notation for primitives of untagged types doesn't handle certain cases of prefixed calls where the prefix of the call is an overloaded function call. Specifically, this can occur when the result of some overloadings of the function have results

[Ada] Return_when_statement not working for non identifier return values

2021-07-06 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby the experimental "return when" feature was not supported for return values which were not identifiers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch6.adb (Get_Return_Kind): Removed. (Is_Extended): Created to ide

[Ada] Fix bug in casing on composite values with -gnatX

2021-07-06 Thread Pierre-Marie de Rodat
Fix a bug (which shows up as an assertion failure in gigi) having to do with the tree generated by the FE for a record-valued case-statement choice that has a subcomponent of an enumeration type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch5.adb (Expand_N_C

[Ada] Simplify dependency on System

2021-07-06 Thread Pierre-Marie de Rodat
Code cleanup related to loading of compilation units; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-writ.adb (Ensure_System_Dependency): Simplify by reusing a constant name.diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb --- a/

[Ada] Simplify unit loading with membership tests

2021-07-06 Thread Pierre-Marie de Rodat
Cleanup excessive whitespace and use membership tests in code related to loading of compilation units; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-load.adb (Load_Unit): Remove excessive whitespace. * lib.adb (Is_Internal_Unit, Is_Pred

[Ada] Simplify returning from Enclosing_Comp_Unit_Node

2021-07-06 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Enclosing_Comp_Unit_Node): When the loop exits the Current_Node is either an N_Compilation_Unit node or Empty, so simply return it without redundant checks.di

[Ada] Replace a question mark comment with assertion

2021-07-06 Thread Pierre-Marie de Rodat
Cleanup related to loading of compilation units. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib.adb (Remove_Unit): Replace defensive code with an assertion. * par-load.adb (Load): Address a question mark in the comment.diff --git a/gcc/ada/lib.adb b/gcc/

[Ada] Simplify code by removing local constant

2021-07-06 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * uname.adb (Add_Node_Name): Replace local constant whose initial expression was evaluated even when unnecessary with just that expression that is evaluated at most once and

[Ada] Handle malformed command line on Win32

2021-07-06 Thread Pierre-Marie de Rodat
In shells such as Win32 Cmd, malformed command line can be used to spawn processes. As a consequence when parsing a quoted argument, the closing double quote can be missing and a null character found instead. In that case, behave as if the closing double quote is found with the exception that trail

[Ada] Warn on statically known empty loop caused by constraint

2021-07-06 Thread Pierre-Marie de Rodat
Before this commit, GNAT would not warn about empty loops caused by constraints like in the following piece of code: procedure tmp is type T is mod 3; begin for I in T range -1..1 loop null; end loop; end; When the constrained type is modular, additional information about computed

[Ada] Implement missing constraint checks for default streaming operations

2021-07-06 Thread Pierre-Marie de Rodat
For a default (as opposed to user-defined) Read operation of a composite type with a scalar component, the RM says that in some cases the constraint check that is normally performed upon return from a procedure with an out-mode scalar parameter (in particular, the call to the procedure Scalar_Compo

[Ada] Enable Ada 2020 Put_Image and Image support for tagged types

2021-07-06 Thread Pierre-Marie de Rodat
Enable support for Ada 2020's Put_Image and Image attributes for tagged types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_put_image.adb: Eliminate references to Debug_Flag_Underscore_Z. Change the meaning of the function Enable_Put_Image. Previously

[Ada] Initialize Current_Error_Node

2021-07-06 Thread Pierre-Marie de Rodat
... because in case of compiler bugs, it can be accessed early, so it needs to be initialized. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * atree.ads (Current_Error_Node): Initialize to Empty.diff --git a/gcc/ada/atree.ads b/gcc/ada/atree.ads --- a/gcc/ada/atree.ads +++ b

[Ada] Unsynchronized access to a Boolean in tasking state

2021-07-07 Thread Pierre-Marie de Rodat
The Terminated flag for a task was being queried without first aquiring the task lock. It is not clear that this unsychronized access has ever caused a problem in practice, but the thread-sanitizer tool flags it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-tas

[Ada] Transient scope cleanup

2021-07-07 Thread Pierre-Marie de Rodat
Use Tbuild.Unchecked_Convert_To instead of Nmake.Make_Unchecked_Type_Conversion. This leads to more readable source code in the compiler, and also more readable .dg code, because it removes redundant unchecked conversions. There is only one remaining call to Make_Unchecked_Type_Conversion, which i

[Ada] Simplify iteration over pending instantiations

2021-07-07 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Instantiate_Bodies): Fix white in declaration. (Remove_Dead_Instance): Change iteration from WHILE to FOR.diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb --- a/gcc

[Ada] Tune discovery of No_Elaboration_Code restriction

2021-07-07 Thread Pierre-Marie de Rodat
When discovering violation of the No_Elaboration_Code restriction it is enough to find one unit that violates it; we don't need to examine all units. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-writ.adb (Write_ALI): Exit from l

[Ada] Add socket options to control keepalive on TCP connection

2021-07-07 Thread Pierre-Marie de Rodat
This adds socket options that are needed to control the keepalive status of TCP connections. The new options are Keep_Alive_Count, Keep_Alive_Idle, and Keep_Alive_Interval. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-socket.ads (Option_Name): Add Keep_Alive_Cou

[Ada] Simplify handling of Generate_Code flag for compilation units

2021-07-07 Thread Pierre-Marie de Rodat
There are three kinds of units that require code generation: the main unit, its corresponding spec and generic instances needed by the main unit. Previously the main unit and its corresponding spec were flagged as requiring code generation just before calling the backend, while instance units were

[Ada] Replace chopped string copy with renaming

2021-07-07 Thread Pierre-Marie de Rodat
Avoid local string copy with renaming, which both make the code shorter to read and should be marginally faster to execute. Code cleanup only related to loading of compilation units; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par.adb (Par): A lo

[Ada] Fix precondition of Cot for code analyzers

2021-07-07 Thread Pierre-Marie de Rodat
The precondition of Cot in Ada.Numerics.Generic_Elementary_Functions is not meant for execution (as enforced by the Assertion_Policy at the top of the file) but for analysis only. A conjunct in the precondition of Cot applied to two arguments (with a Cycle value) was incorrect, now fixed. Tested o

[Ada] Linker_Section_Pragma cleanup

2021-07-07 Thread Pierre-Marie de Rodat
Remove Linker_Section_Pragma field from Record_Field_Kind. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen-gen_entities.adb: Remove Linker_Section_Pragma field from Record_Field_Kind. Minor comment improvement.diff --git a/gcc/ada/gen_il-gen-gen_entities.

[Ada] Replace low-level membership tests with Is_Private_Type

2021-07-07 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb, exp_ch6.adb, sem_ch6.adb: Replace Ekind membership test in Private_Kind with a call to Is_Private_Type.diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb --- a/gcc

[Ada] Simplify code by reusing List_Length

2021-07-07 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_disp.adb (CPP_Num_Prims): Reuse List_Length.diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -588,19 +588,7 @@ package

[Ada] Reduce scope of local variables

2021-07-07 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Check_For_Primitive_Subprogram): Move declarations of local variables after nested subprogram bodies.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/a

[Ada] Simplify handling of sure errors in GNATprove mode

2021-07-07 Thread Pierre-Marie de Rodat
In cases where it is known statically that an exception will be raised, the frontend inserts a node of kind N_Raise_xxx_Error. This node kind was previously not supported in GNATprove, which required special handling for these cases in GNATprove mode. This is not needed anymore. Tested on x86_64-p

[Ada] Unchecked_Convert_To: set Parent

2021-07-07 Thread Pierre-Marie de Rodat
A previous change to Unchecked_Convert_To removed the setting of the Parent of the new node, because it was thought to be unnecessary. However, in rare cases, it is necessary because for example Remove_Side_Effects is called on the new node before attaching it to the tree. Tested on x86_64-pc-linu

[Ada] Timeout correction on Get_Socket_Option

2021-07-07 Thread Pierre-Marie de Rodat
The Set_Socket_Option shifts timeout for -500ms on old Windows versions, but Get_Socket_Option did +500ms for timeouts on all Windows versions. This commit fixes it and +500ms on Get_Socket_Option only for old Windows versions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ *

[Ada] Improve interactions between DSA and Put_Image routines for tagged types

2021-07-07 Thread Pierre-Marie de Rodat
Back out of an overly aggressive workaround for compilation problems associated with a Put_Image routine for a tagged type in a Remote_Types package and try a different (hopefully better) approach that is more consistent with how other predefined primitives are treated. Tested on x86_64-pc-linux-g

[Ada] Fix bugs in Value_Size clauses and refactor

2021-07-07 Thread Pierre-Marie de Rodat
Size and Value_Size clauses are documented to be the same, except that Value_Size is allowed for nonfirst subtypes, and Size is allowed for objects. This was far from true, which caused bugs such as ignoring Value_Size for access types, in cases where a Size clause would trigger the use of thin poi

[Ada] Replace obsolete calls that use global name buffer

2021-07-07 Thread Pierre-Marie de Rodat
Code cleanup related to loading of compilation units; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * uname.adb (Get_Body_Name, Get_Parent_Body_Name, Get_Parent_Spec_Name, Get_Spec_Name, Is_Child_Name, Is_Body_Name, Is_Spec_Name, Name

[Ada] Use bounded string buffer in Get_Unit_Name

2021-07-07 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * uname.adb (Get_Unit_Name): Simplify with a bounded string buffer; also, this addresses a ??? comment about the max length being exceeded.diff --git a/gcc/ada/uname.adb b/gc

[Ada] Fix location of errors about volatile compatibility

2021-07-07 Thread Pierre-Marie de Rodat
Ada 2022 errors about volatile compatibility between generic actual and formal types were emitted on type declaration; now they are emitted at the actual type within the generic instance. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch12.adb (Check_Shared_Variable_Con

[Ada] Implement new legality checks specified by AI12-0412

2021-07-07 Thread Pierre-Marie de Rodat
Ada 2022, in AI12-0412, specifies that certain uses of primitives of an abstract type that have Pre'Class or Post'Class aspect are illegal when an aspect is given with a nonstatic expression. Specifically, if the primitive is nonabstract and has such aspects, it's illegal to make a nondispatching c

[Ada] Code cleanups in System.Atomic_Counters

2021-07-07 Thread Pierre-Marie de Rodat
In particular, now that we are using Atomic_Unsigned which is marked Atomic, we no longer need to mark Atomic_Counter.Value explicitly atomic. We can also get rid of all uses of 'Unrestricted_Access Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-atocou.ads, libgn

[Ada] Minor code cleanup

2021-07-07 Thread Pierre-Marie de Rodat
To help codepeer analysis. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-debpoo.adb (Code_Address_For_Allocate_End): Default Initialize.diff --git a/gcc/ada/libgnat/g-debpoo.adb b/gcc/ada/libgnat/g-debpoo.adb --- a/gcc/ada/libgnat/g-debpoo.adb +++ b/gcc/a

[Ada] Simplify code by reusing Remove on list of primitive operations

2021-07-07 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_Pragma): Simplify processing of pragma CPP_Constructor.diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_p

[Ada] Optimize away certain elaboration checks

2021-07-07 Thread Pierre-Marie de Rodat
The body of every primitive subprogram contains an elaboration check, in case a dispatching call is made. These checks happen even in the static model. This patch removes the checks if pragma Pure or Preelaborate is present, because they cannot fail in that case. Tested on x86_64-pc-linux-gnu, com

[Ada] Keepalive control on Windows

2021-07-07 Thread Pierre-Marie de Rodat
Windows headers in GCC could miss some available constants. Hardcode TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL constants for such case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * s-oscons-tmplt.c (TCP_KEEPCNT TCP_KEEPIDLE, TCP_KEEPINTVL): Hardcode on Windows

[Ada] Front-end inlining and instantiations of UC

2021-07-07 Thread Pierre-Marie de Rodat
A recent change exposed a latent bug where the Is_Intrinsic_Subprogram flag was not propagated properly, leading to errors from the front-end inlining of the form: cannot inline "xxx" (nested function instantiation) Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch1

[Ada] Stronger assertion about flag for checking static expressions

2021-07-07 Thread Pierre-Marie de Rodat
Ensure that Checking_For_Potentially_Static_Expression flag is manipulated in a stack-like manner (with stack depth 1 at the most). The previous assertion didn't prevent us from setting the flag to True or to False twice in a row. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Assertion errors on concurrent types with -gnatc and extensions enabled

2021-07-07 Thread Pierre-Marie de Rodat
When expansion is disabled (such as with -gnatc), there are cases where uses of concurrent types can lead to an Assertion_Failure when extensions are enabled (by use of -gnatX, or due to instantiation of a predefined library generic, such as Unchecked_Conversion), because Primitive_Operations can r

[Ada] Remove unused define

2021-07-07 Thread Pierre-Marie de Rodat
__MINWGW32__ is typo and was not working, but anyway the MSG_WAITALL is defined on Windows. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * s-oscons-tmplt.c (MSG_WAITALL): Remove wrong #ifdef __MINWGW32__.diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt

[Ada] Simplify string manipulation related to preprocessing

2021-07-08 Thread Pierre-Marie de Rodat
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sinput-l.adb (Load_File): Simplify foreword manipulation with concatenation; similar for filename with preprocessed output.diff --git a/gcc/ada/sinput-l.adb b/gcc/ada/sinput-l.adb

[Ada] Avoid linear search when ensuring dependency on System

2021-07-08 Thread Pierre-Marie de Rodat
Replace a linear search with a hash table query. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-writ.adb (Ensure_System_Dependency): Replace search in Lib.Units with a search in Lib.Unit_Names.diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb --- a/gcc/ad

[Ada] Make tools compatible with No_Dynamic_Accessibility_Checks

2021-07-08 Thread Pierre-Marie de Rodat
To help experiment with this new model. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * make.adb, osint.adb: Make code compatible with No_Dynamic_Accessibility_Checks restriction.diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb --- a/gcc/ada/make.adb +++ b/gcc/ada/ma

[Ada] Revert meaning of -gnatd_b

2021-07-08 Thread Pierre-Marie de Rodat
As part of experimenting with No_Dynamic_Accessibility_Checks, it seems that reverting the meaning of -gnatd_b is a better default for this experiment. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * debug.adb, sem_util.adb: Revert meaning of -gnatd_b. * sem_res.adb:

[Ada] Incorrect iteration over hashed containers after multiple Inserts

2021-07-08 Thread Pierre-Marie de Rodat
Cursors for Hashed maps and hashed sets include a component that speeds up iteration over these containers. However, in the presence of multiple insertions into the corresponding hash-tables, this component may become unreliable when a cursor obtained before an iteration is compared with a cursor d

[Ada] Add No_Tasking restriction is system.ads for bootstrap

2021-07-08 Thread Pierre-Marie de Rodat
Make it explicit that tasking is not used in the compiler, which also allows generating simpler and more efficient code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/system.ads: Add No_Tasking restriction.diff --git a/gcc/ada/gcc-interface/system.ads b/gcc/a

[Ada] Unsynchronized concurrent access to a Boolean variable

2021-07-08 Thread Pierre-Marie de Rodat
If an exception declaration occurs in a nonstatic scope (for example, within the body of a task type), System.Exception_Table.Register_Exception is to be called the first (and *only* the first) time the declaration is elaborated. A library-level "this exception has been registered" Boolean flag wa

[Ada] Compute sizes when possible for packed array with Component_Size

2021-07-08 Thread Pierre-Marie de Rodat
For a packed constrained array type with a Component_Size clause, it may be possible to compute both its RM_Size and Esize. Do this as it benefits GNATprove for checking validity of overlays. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * layout.adb (Layout_Type): Special c

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