[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

[Ada] Make runtime code 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/ * libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb, libgnat/a-cbhase.adb, libgnat/a-cbmutr.adb, libgnat/a-cborma.adb, libgnat/a-cborse.adb, libgnat/a-cobove.adb, libgnat/a

[Ada] Fix on computation of packed array size in case of error

2021-07-08 Thread Pierre-Marie de Rodat
In case of compilation error, the low and high bounds of the array type might have been replaced by an error node. Deal with this case by checking that the bounds are known at compile time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * layout.adb (Layout_Type): Add guard b

[Ada] Prevent crash on inspection point for unfrozen entity

2021-07-08 Thread Pierre-Marie de Rodat
Before this patch, the following program would make GNAT crash: procedure P is Unused_Var : Integer with Shared => False; pragma Inspection_Point; begin null; end tmp; This was because the Shared aspect resulted in a freeze node being inserted after the Inspection_Point pragma. This m

[Ada] Skip types in error for test to compute array size

2021-07-08 Thread Pierre-Marie de Rodat
After a syntax error, if the code is compiled with -gnatq, semantic analysis should still proceed without internal errors if possible. Add special case to recognize ill-formed array type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * layout.adb (Layout_Type): Do not call N

[Ada] Fix use of single question mark in error message

2021-07-08 Thread Pierre-Marie de Rodat
Single question marks are deprecated. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_prag.adb (Expand_Pragma_Inspection_Point): Fix error message.diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb --- a/gcc/ada/exp_prag.adb +++ b/gcc/ada/exp_prag.adb @@ -2

[Ada] Fix style in comments and code related to compilation units

2021-07-08 Thread Pierre-Marie de Rodat
Only style fixes; comments and code themselves are unchanged. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-load.adb (Load_Unit): Fix style in comment. * par-load.adb (Load): Likewise. * scng.adb (Initialize_Scanner): Fix whitespace.diff --git a/gcc/ada

[Ada] Prevent infinite recursion when there is no expected unit

2021-07-08 Thread Pierre-Marie de Rodat
The comment in Par.Load says "... or we are in big trouble, and abandon the compilation", but the code merely emitted errors and kept going. Now it emits errors, flags the problem in the unit table and gives up. Also, it was wrong for this routine to remove the unit, because the callers who add ent

[Ada] Replace low-level condition with a high-level call

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/ * lib-writ.adb (Ensure_System_Dependency): Simplify condition.diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -147,7 +147,7

[Ada] Restore context on failure in loading of renamed child unit

2021-07-08 Thread Pierre-Marie de Rodat
When loading of renamed child unit failed, we didn't properly restore the value of a global Parsing_Main_Extended_Source variable. This is primarily a cleanup change; behaviour is not affected (perhaps except for errors reported on complicated code that is illegal anyway). Tested on x86_64-pc-lin

[Ada] Remove redundant condition for listing compilation units

2021-07-08 Thread Pierre-Marie de Rodat
There is only one call to Unit_Display and it is guarded by the List_Units global variable. There is no need to retest this variable inside the Unit_Display routine. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch10.adb (Unit_Di

[Ada] Simplify redundant checks for non-empty lists

2021-07-08 Thread Pierre-Marie de Rodat
Simplify "Present (L) and then not Is_Empty_List (L)" into "not Is_Empty_List (L)", since Is_Empty_List can be called on No_List and returns True. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch12.adb, sem_ch6.adb, sem_ch9.adb,

[Ada] Fix violation of No_Implicit_Loops restriction for enumeration type

2021-07-08 Thread Pierre-Marie de Rodat
The perfect hash function generated by the compiler to speed up the Value attribute of an enumeration type contains an implicit loop and, therefore, violates the No_Implicit_Loops restriction when it is active. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_imgv.adb: Ad

[Ada] Spurious warning in generic instance

2021-07-08 Thread Pierre-Marie de Rodat
In the case of complex generic instantiations, the warning on component not being present can be spurious (corresponding to dead code for the given instance), so we disable it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads, sem_util.adb (Apply_Compile_

[Ada] AI12-0156 Use subtype indication in generalized iterators

2021-07-08 Thread Pierre-Marie de Rodat
Add syntax and semantic support for this new Ada 2022 feature. Support for proper accessibility levels to be investigated in a second step. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch5.adb (P_Iterator_Specification): Add support for access definition in lo

[Ada] Spurious style message on missing overriding indicator

2021-07-08 Thread Pierre-Marie de Rodat
In the presence of style switch -gnatyO, the compiler emits a spurious style violation message naming an inherited operation that does not come from an explicit subprogram declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * style.adb (Missing_Overriding): Do not emi

[Ada] Duplicated D lines in ali files

2021-07-08 Thread Pierre-Marie de Rodat
GNATcoverage possibly relies on the presence of the duplicate D lines in ALI files for its Source Coverage Obligation tables among different instantiations of a same generic. Mention this in comments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-writ.ads: Mention SCOs

[Ada] Rename sigtramp-vxworks-target.inc to sigtramp-vxworks-target.h

2021-07-08 Thread Pierre-Marie de Rodat
The .inc extension isn't recognized by gprconfig. The original motivation for using this extension was to match the convention of putting code in .inc ala unwind.inc. However it's easier in this situation to just rename it to a .h file. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Transient scope cleanup

2021-07-08 Thread Pierre-Marie de Rodat
Misc cleanups found while working on transient scopes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * comperr.adb (Compiler_Abort): Call Sinput.Unlock, because if this is called late, then Source_Dump would crash otherwise. * debug.adb: Correct documentation

[Ada] Use encoded names only with -fgnat-encodings=all

2021-07-08 Thread Pierre-Marie de Rodat
This disables the last special encoding done in Get_Encoded_Name, except when -fgnat-encodings=all is passed on the command line. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_dbug.adb (Get_Encoded_Name): Do not encode names of discrete types with custom bounds

[Ada] Diagnose properly illegal uses of Target_Name

2021-07-08 Thread Pierre-Marie de Rodat
Ada_2022 introduces the notion of Target_Name, written @, to be used in assignment statements, where it denotes the value of the left-hand side prior to the assignment. This patch diagnoses illegal uses of the target name outside of its legal context. Tested on x86_64-pc-linux-gnu, committed on tr

[Ada] Tune detection of illegal occurrences of target_name

2021-07-08 Thread Pierre-Marie de Rodat
Prevent AST climbing from going outside of the current program unit; tune style; add comments. Also, only set the Current_Assignment global variable when needed and clear it once the analysis of an assignment statement is done. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ *

[Ada] Remove Unknown_ functions

2021-07-08 Thread Pierre-Marie de Rodat
Remove the Unknown_ type representation attribute predicates from Einfo.Utils. "not Known_Alignment (...)" is at least as readable as "Unknown_Alignment (...)" -- we don't need a bunch of functions that just do a "not". Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo-u

[Ada] Avoid unnecessary call in preanalysis without freezing

2021-07-09 Thread Pierre-Marie de Rodat
Cleanup related to preanalysis in GNATprove mode; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Preanalyze_And_Resolve): Only call Set_Must_Not_Freeze when it is necessary to restore the previous value.diff --git a/gcc/

[Ada] Remove an unnecessary local constant

2021-07-09 Thread Pierre-Marie de Rodat
Code cleanup related to preanalysis in GNATprove mode; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Expression_Function): A local Expr constant was shadowing a global constant with the same name and the same va

[Ada] Refine types of local variables in analysis of expression functions

2021-07-09 Thread Pierre-Marie de Rodat
Code cleanup related to handing of static expression functions in GNATprove; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Expression_Function): Change types local variables from Entity_Id to Node_Id.diff --git a/gcc/ad

[Ada] Avoid repeated calls in analysis of expression functions

2021-07-09 Thread Pierre-Marie de Rodat
Code cleanup related to handing of static expression functions in GNATprove; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Expression_Function): Use Orig_N variable instead of repeated calls to Original_Node.diff --git

[Ada] Fix comment related to analysis of expression functions

2021-07-09 Thread Pierre-Marie de Rodat
Cleanup related to handing of static expression functions in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Expression_Function): Fix comment.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_c

[Ada] Avoid repeated computing of type of expression functions

2021-07-09 Thread Pierre-Marie de Rodat
Cleanup related to handing of static expression functions in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Expression_Function): Add variable to avoid repeated calls to Etype.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb ---

[Ada] Decouple analysis of static expression functions from GNATprove

2021-07-09 Thread Pierre-Marie de Rodat
Analysis of static expression functions happened inside an IF branch guarded by GNATprove_Mode. Cleanup related to handling of static expression functions in GNATprove mode; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Express

[Ada] Reorder preanalysis of static expression functions

2021-07-09 Thread Pierre-Marie de Rodat
Group two variants of preanalysis of expression functions. Code cleanup related to handling of static expression functions in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Expression_Function): Reorder code.diff --git a/gcc/ada/sem_ch6.adb b

[Ada] Update internal documentation of debugging information

2021-07-09 Thread Pierre-Marie de Rodat
This updates the documentation of the debugging information generated by the compiler present in the spec of the Exp_Dbug unit. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_dbug.ads: Update documentation of various items.diff --git a/gcc/ada/exp_dbug.ads b/gcc/ada/exp

[Ada] Incremental patch for restriction No_Dynamic_Accessibility_Checks

2021-07-09 Thread Pierre-Marie de Rodat
This patch corrects various issues discovered during testing of the No_Dynamic_Accessibility_Checks restriction leading to level miscalculation errors. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads (Type_Access_Level): Add new optional parameter Assoc_

[Ada] Inconsistency between declaration and body of predicate functions

2021-07-09 Thread Pierre-Marie de Rodat
We need to declare a predicate function along with its type but can only generate the body at freeze point which may be in a separate scope, leading to inconsistencies. So fix this by deferring the generation of the predicate function declaration and fix latent bugs uncovered along the way. While

[Ada] Initialize local variables related to static expression functions

2021-07-09 Thread Pierre-Marie de Rodat
Explicitly initialize local variables related to analysis of expression functions to prevent spurious checks from static analysers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Expression_Function): Initialize Orig_N and Typ variables.diff --g

[Ada] aarch64-rtems6: use wraplf variant for a-nallfl

2021-07-09 Thread Pierre-Marie de Rodat
Since newlib doesn't implement correctly long double, use the wraplf variant for a-nallfl. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (LIBGNAT_TARGET_PAIRS) : Use the wraplf variant of Aux_Long_Long_Float.diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/

[Ada] Add paragraph about representation changes and Scalar_Storage_Order

2021-07-09 Thread Pierre-Marie de Rodat
This in particular documents the new warning given on overlays. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementation_defined_attributes.rst (Scalar_Storage_Order): Add paragraph about representation changes. * gnat_rm.texi: Regen

[Ada] Fix typo in comment related to derived discriminated types

2021-07-09 Thread Pierre-Marie de Rodat
Minor typo; found while fixing handling of tagged types in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.ads (Map_Types): Fix typo.diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -915,7 +

[Ada] Fix invalid JSON for derived variant record with -gnatRj

2021-07-09 Thread Pierre-Marie de Rodat
This prevents the output of -gnatRj from containing several "variant" fields for an extension with a variant part of a tagged type with a variant part. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * repinfo.ads (JSON output format): Document adjusted key name. * rep

[Ada] Fix layout of contracts

2021-07-09 Thread Pierre-Marie de Rodat
Fix layout of contracts in libgnat/a-strunb.ads and libgnat/a-strunb__shared.ads so that it is the same in both files. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strunb.ads, libgnat/a-strunb__shared.ads: Fix layout in contracts.diff --git a/gcc/ada/lib

[Ada] Add source file name to gnat bug box

2021-07-09 Thread Pierre-Marie de Rodat
...in case Current_Error_Node is Empty, which will cause it to print "No source file position information available". At least now we have the file name being compiled. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * comperr.adb (Compiler_Abort): Print source file name.diff

[Ada] Declare time_t uniformly based on a system parameter

2021-07-09 Thread Pierre-Marie de Rodat
The declaration of time_t is in flux based on it's overflow in Year 2038, so declare it uniformly based on System.Parameter.time_t_bits to ease this transition and also enable VxWorks targets which allow it to be parameterized, to be rebuilt more easily by one source change. Two changes of note: s

[Ada] Crash on inlined separate subprogram

2021-07-09 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby a pragma Inline appearing after a subprogram body stub to which it applies and where no specification is present causes a compile time crash. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Check_Pragma_Inline):

[Ada] Add -gnatX support for casing on discriminated values

2021-07-09 Thread Pierre-Marie de Rodat
Improve existing support for the Ada extension feature of casing on composite values to handle casing on values that are discriminated or have discriminated subcomponents. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch5.adb (Expand_General_Case_Statement): Add new fu

[Ada] Crash on expansion of BIP construct in -gnatf mode

2021-07-09 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby an assignment to a limited interface access type causes a crash when the right hand side has an unresolvable function call in prefix notation and verbose errors are enabled via (-gnatf). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Improve performance of Ada.Containers.Doubly_Linked_Lists.Generic_Sorting.Sort

2021-07-09 Thread Pierre-Marie de Rodat
The previous implementation could exhibit quadratic behavior in some cases (e.g., if the input was already sorted or almost sorted). The new implementation uses an N log N worst case algorithm. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cdlili.adb: Reimplement

[Ada] Add missed OS constant values

2021-07-09 Thread Pierre-Marie de Rodat
Add IPV6_FLOWINFO and IF_NAMESIZE values into generated package System.OS_Constants. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gsocket.h: Include net/if.h to get IF_NAMESIZE constant. * s-oscons-tmplt.c: Define IPV6_FLOWINFO for Linux.diff --git a/gcc/ada/gsock

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