[Ada] Make Declaration_Node return nondeclarations in fewer cases

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
This patch changes Declaration_Node to avoid returning certain strange node kinds. We don't avoid them all (in particular N_Null_Statement), but we document what it's returning with a pragma Assert. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo-utils.adb (Declaration

[Ada] Update the inactive GMP variant of Big_Integers

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
The GMP variant of Ada.Numerics.Big_Numbers.Big_Integers is currently not used, but since we keep it, it seems worth to keep it up-to-date with respect to the corresponding spec. Part of providing a gdb pretty-printer for Big_Integer objects. Tested on x86_64-pc-linux-gnu, committed on trunk gcc

[Ada] Relax INOX restrictions when casing on composite value.

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
When casing on a composite value, certain component types/subtypes were previously disallowed. These included access types, real types, nonstatic discrete subtypes, and others. This restriction is relaxed so that such components are now allowed, but no non-box value may be specified for such a comp

[Ada] Simplify iteration of record components when expanding equality

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Replace a confusing loop with two exit staments by a straightforward while loop with an explicit condition. Also, explicitly iterate over discriminants and components, not over entities. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_Composite_Equality):

[Ada] Fix bugs in Base_Type_Only (etc.) fields

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
If a field has Type_Only set to something other than No_Type_Only, then we need to fetch the field from a possibly different node. For example, the Modulus field has Type_Only = Base_Type_Only (and is documented as a "[base type only]" field in Einfo). Therefore if we try to get Modulus from node N

[Ada] Change format of the ?? warning insertion sequence

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Update all ?X? to ?.x? (likewise for [-gnatwx] * ?_x? -> [-gnatw_x] * ?.x? -> [-gnatw.x] With the support of the ?_x? insertion sequences, messages that related to -gnatw_a, -gnatw_c, -gnatw_p, -gnatw_r are now correctly advertised as relating to these. Tested on x86_64-pc-linux-gnu, committed o

[Ada] Follow-on cleanups for Uint fields

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Subsequent to prior major cleanups of Uint fields, this patch includes a few more, fairly minor, cleanups. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Fixed_Point_Type): Remove previously-inserted test for Uint_0; no longer needed. * ge

[Ada] Spurious error on user-defined literal and operator

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
This patch improves the handling of the Ada_2022 aspect involving user-defined literals on integers, reals, and strings, when the literal that must be converted to a type (for which the aspect is defined) appears as an operand of a predefined operator. The target type may be given by the type of th

[Ada] Remove gnatfind and gnatxref

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
These tools are no longer maintained and have never supported project files. They are replaced by the Ada Language Server which implements the Language Server Protocol. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/Make-lang.in, gcc-interface/Makefile.in: Rem

[Ada] Fix new CUDA kernel registration scheme

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
Removal of the previous kernel registration scheme unearthed mistakes in the new one, which were: - The new kernel registration code relied on the binder expansion phase, which didn't happen because the registration code was already generated by the binder. - The kernel handle passed to CUDA_Re

[Ada] Add empty constructors to the functional containers

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds empty constructors to the functional containers so that we can use them in expression functions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cofuma.ads, libgnat/a-cofuma.adb, libgnat/a-cofuse.ads, libgnat/a-cofuse.adb, libgnat/a-

[Ada] Delete no-longer-used Convert_To_Return_False flag

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
As a result of other recent changes, the Convert_To_Return_False flag is never set. The flag can be therefore be deleted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch11.adb (Expand_N_Raise_Expression): Remove Convert_To_Return_False test. * gen_il-f

[Ada] PR ada/105303 Fix use of Assertion_Policy in internal generics unit

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
The internal unit System.Generic_Array_Operations defines only generic subprograms. Thus, pragma Assertion_Policy inside the spec has no effect, as each instantiation is only subject to the assertion policy at the program point of the instantiation. Remove this confusing pragma, and add the pragma

[Ada] Adapt proof of runtime unit s-arit32

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
After changes in GNATprove, adapt proof. Simply move an assertion up before it is first needed here. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-arit32.adb (Scaled_Divide32): Move assertion up.diff --git a/gcc/ada/libgnat/s-arit32.adb b/gcc/ada/libgnat/s-arit32

[Ada] Restore hiding of predefined "=" operator through class-wide type

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
The previous change introduced a backward incompatibility in the handling of a user-defined "=" operator for a class-wide type of a tagged type: it would previously hide the predefined "=" operator of the tagged type in the private case, but it no longer does in this case, while it still does in th

[Ada] Do not freeze profiles for dispatch tables

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
When static dispatch tables are built for library-level tagged types, the primitives (the subprogram themselves) are frozen; that's necessary because their address is taken. However, their profile, i.e. all the types present therein, is also frozen, which is not necessary after AI05-019 and is als

[Ada] Fix typo in comment for functional sets

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
Minor fix in a recently added comment. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cofuse.ads (Empty_Set): Fix typo in comment.diff --git a/gcc/ada/libgnat/a-cofuse.ads b/gcc/ada/libgnat/a-cofuse.ads --- a/gcc/ada/libgnat/a-cofuse.ads +++ b/gcc/ada/libgnat/a-co

[Ada] Tweaks to hardening docs

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
Mention when security hardening features are available in other languages. Expand the strub documentation a little, for clarity and completeness. Add missing 'aliased' and attribute to variables in strub example. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/

[Ada] Update proofs of double arithmetic unit after prover changes

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
Changes in GNATprove (translation to Why3 and provers) result in proofs being much less automatic, and requiring ghost code to detail intermediate steps. In some cases, it is better to use the new By mechanism to prove assertions in steps, as this avoids polluting the proof context for other proofs

[Ada] Introduce Opt.CCG_Mode

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
To handle code common to the old and the new CCG code generator. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnat1drv.adb, opt.ads, sem_ch7.adb: Introduce CCG_Mode.diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.

[Ada] Do not analyze expression functions for dispatch tables

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
There is no need to analyze expression functions that are primitives of a tagged type for its dispatch table because they will be analyzed at the end of the current scope. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Resolve_Attribute) : Don't analyze

[Ada] Do not freeze specifically for dispatch tables

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
The left-overs of the old freezing code in Make_DT are now redundant since the semantic analyzer performs the same task for the 'Access attribute. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_disp.adb (Make_DT): Remove remaining freezing code.diff --git a/gcc/ada/exp_

[Ada] Fix expansion of aggregate for discriminated limited extension

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
The presence of the discriminants prevents the values associated with the components of the parent type from being put into the sub-aggregate built for the _Parent component. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Expand_Record_Aggregate.Build_Back_End

[Ada] Incorrect determination of whether an expression is predicate-static

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
The expression given in a Static_Predicate aspect specification is required to be predicate-static. The implementation of this compile-time check was incorrect in some cases. There were problems in both directions: expressions that are not predicate-static were incorrectly treated as though they we

[Ada] Fix illegal Ada in s-dwalin.adb

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
Both the `System.Mmap` and `System.Object_Reader` packages are defining entities named `Offset` and they are both `use`d at the top of s-dwalin.adb. Therefore, the references to `Offset` throughout this file are ambiguous, and GNAT is supposed to complain. Since it does not for the moment, we fix

[Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby spurious unreferenced warnings are generated on formal parameters of null generic subprograms. These changes also fix the parsing of aspects on formal parameters such that the aspects now get properly set for all formal parameters in a parameter

[Ada] Avoid creating a finalization wrapper block for functions

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes a bug whereby if a function body has local objects that are finalizable, and has a return statement that requires generation of transient finalizable temps, and there are dynamic-sized objects requiring pushing/popping the (primary) stack at run time, and the function body has exce

[Ada] Fix -gnatw.f warnings not having the right insertion characters

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This caused these warnings not to be tagged with the switch causing them, which is an issue for tools ingesting GNAT's output. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_elab.adb (Process_Conditional_ABE_Access_Taken): Add '.f' insertion characters.diff --gi

[Ada] Deconstruct deferred references

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
While cleaning up and modifying code for unreferenced warnings we removed all calls to Defer_Reference, which was the only routine that populated the Deferred_References table. Consequently, all the code related to this table became dead. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Fix Warn_On_Late_Primitives messages not being properly tagged

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This caused tools ingesting GNAT's output to mislabel these messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_disp.adb (Warn_On_Late_Primitive_After_Private_Extension): Fix insertion character.diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb --- a

[Ada] Fix Warn_On_All_Unread_Out_Parameters not being properly tagged

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This caused tools ingesting GNAT's output to mislabel these messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_warn.adb (Warn_On_Useless_Assignment): Fix insertion character.diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb --- a/gcc/ada/sem_warn.ad

[Ada] Add insertion character for overlay modification warnings

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This enables tools that ingest GNAT's output to properly classify these messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Warn_Overlay): Add 'o' insertion character. * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Likewise. * sem_uti

[Ada] Add insertion character to Ineffective_Inline_Warnings messages

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This enables tools that ingest GNAT's output to properly classify these messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Check_Package_Body_For_Inlining): Add insertion character.diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb --- a/gcc/ada/

[Ada] Remove repeated description of support for Address clauses

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
The GNAT behaviour regarding the Ada RM requirement to support Address clauses for imported subprograms was documented twice: in section about packed types (which was a mistake) and in section about address clauses (where it belongs). Cleanup related to the use of packed arrays for bitset operatio

[Ada] Fix expansion of structural subprogram variants

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
When implementing structural subprogram variants we ignored them in expansion of the pragma itself, but not in expansion of a recursive subprogram call. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Check_Subprogram_Variant): Ignore structural

[Ada] Remove contract duplication in formal doubly linked lists

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
Remove a minor duplication in Post of a function of formal doubly linked lists. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfdlli.ads (Insert): Remove the duplication.diff --git a/gcc/ada/libgnat/a-cfdlli.ads b/gcc/ada/libgnat/a-cfdlli.ads --- a/gcc/ada/libgna

[Ada] Add "option" field to GNAT's -fdiagnostics-format=json output

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
This enables better integration with tools that handle GNAT's output. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * erroutc.ads (Get_Warning_Option): New function returning the option responsible for a warning if it exists. * erroutc.adb (Get_Warning_Option

[Ada] Fix spurious options being inserted in -fdiagnostics-format=json output

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
Without this patch, gnat would use `-gnatw?` as the default option for some of the default warnings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * erroutc.adb (Get_Warning_Option): Don't consider `?` as a valid option switch.diff --git a/gcc/ada/erroutc.adb b/gcc/a

[Ada] Simplify construction of a path to file

2022-05-30 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * osint.adb (Locate_File): Change variable to constant and initialize it by concatenation of directory, file name and NUL.diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb --- a/gcc

[Ada] Suppress warnings on membership test of ranges

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
For a membership test "X in A .. B", the compiler used to warn if it could prove that X is within one of the bounds. For example, if we know at compile time that X >= A, then the above could be replaced by "X <= B". This patch suppresses that warning, because there is really nothing wrong with th

[Ada] Incorrect code for anonymous access-to-function with convention C

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes a bug where the compiler generates incorrect code for a call via an object with convention C, whose type is an anonymous access-to-function type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo-utils.adb (Set_Convention): Call Set_Convention re

[Ada] Add inline documentation for Is_{Parenthesis,Enum_Array}_Aggregate

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Both flags were added when square brackets for array/container aggregates have been enabled with -gnat2022 without their corresponding inline documentation. This change adds the missing documention. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sinfo.ads: Add inline docume

[Ada] Use Actions field of freeze nodes for subprograms (continued)

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This case was missed in the previous change. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Freeze_Subprogram.Register_Predefined_DT_Entry): Put the actions into the Actions field of the freeze node instead of inserting them after it.diff --git

[Ada] Issue better error message for out-of-order keywords in record def

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Various cases of out-of-order keywords in the definition of a record were already detected. This adds a similar detection after NULL and RECORD keywords. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch3.adb (P_Known_Discriminant_Part_Opt): Reword error message

[Ada] Issue a warning on entity hidden in use_clause with -gnatwh

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Augment the warnings issued with switch -gnatwh, so that a warning is also issued when an entity from the package of a use_clause ends up hidden due to an existing visible homonym. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Use_One_Package): Possibly warn.

[Ada] arm-qnx-7.1: unwind goes wrong after regs restore

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
The usual increment of the pc to pc+2 for ARM is needed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * init.c (QNX): __gnat_adjust_context_for_raise: New implementation for arm-qnx.diff --git a/gcc/ada/init.c b/gcc/ada/init.c --- a/gcc/ada/init.c +++ b/gcc/ada/init

[Ada] Add reference counting in functional containers

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds reference counting to dynamically allocated pointers on arrays and elements used by the functional container. This is done by making both the arrays and the elements controlled. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cofuba.ads, libgnat/a-c

[Ada] Fix search for "for ... of" loop subprograms

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This patch makes the search for Get_Element_Access, Step (Next/Prev), Reference_Control_Type, and Pseudo_Reference (for optimized "for ... of" loops) more robust. In particular, we have a new Next procedure in Ada 2022, and we need to pick the right one. We have not yet added the new Next and oth

[Ada] Minor tweaks to dispatching support code

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_disp.ads (Expand_Interface_Thunk): Change type of Prim. * exp_disp.adb (Expand_Interface_Thunk): Declare Is_Predef_Op earlier, do not initialize Iface_Formal, use No idiom and tweaks

[Ada] Missing discriminant checks when accessing variant field

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
In some cases, the compiler would incorrectly fail to generate discriminant checks when accessing fields declared in a variant part. Correct some such cases; detect the remaining cases and flag them as unsupported. The formerly-problematic cases that are now handled correctly involve component refe

[Ada] Adjust warning switches

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This makes tagging more accurate. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_warn.adb (Check_References): Adjust conditions under which warning messages should be emitted and their tags as well.diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb --- a/g

[Ada] Fix composability of return on the secondary stack

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Having components that need to be returned on the secondary stack would not always force a record type to be returned on the secondary stack itself. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Returns_On_Secondary_Stack.Caller_Known_Size_Record): Di

[Ada] QNX shared libraries - arm-qnx build gnatlib .so's

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Shared libraries now fully supported on arm-qnx. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (GNATLIB_SHARED): Revert disablement for arm-qnx.diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1

[Ada] Adjust reference in comment

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This is needed after the creation of Returns_On_Secondary_Stack from the original Requires_Transient_Scope. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Indirect_Temp_Needed): Adjust reference in comment.diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.a

[Ada] Another case where freezing incorrectly suppresses checks

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Avoid improperly suppressing checks for the wrapper subprogram that is built when a null type extension inherits (and does not override) a function with a controlling result. This is a follow-up to other changes already made on this ticket. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ad

[Ada] Note that hardening features are experimental

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Some features haven't got customer feedback or made upstream yet. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/security_hardening_features.rst: Note that hardening features are experimental. * gnat_rm.texi: Regenerate.diff --git a/gcc/ada/doc/g

[Ada] Get rid of secondary stack for controlled components of limited types

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
The initial work didn't change anything for limited types because they use a specific return mechanism for functions called build-in-place where there is no anonymous return object, so the secondary stack was used only for the sake of consistency with the nonlimited case. This change aligns the li

[Ada] Propagate null-exclusion to anonymous access types

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
When analyzing an array or record type declaration whose component has a constrained access type, e.g.: type Buffer_Acc is not null access all String; type Buffer_Rec is record Data : Buffer_Acc (1 .. 10); end record; type Buffer_Arr is array (Boolean) of Buffer_Acc (1 .. 10);

[Ada] Fix bad interaction between Inline_Always and -gnateV + -gnata

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
The combination of pragma/aspect Inline_Always and -gnateV -gnata runs afoul of the handling of inlining across units by gigi, which does not inline a subprogram that calls nested subprograms if these subprograms are not themselves inlined. This condition does not apply to internally generated sub

[Ada] Enable using absolute paths in -fdiagnostics-format=json output

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This commit makes GNAT use absolute paths in -fdiagnostics-format=json's output when -gnatef is present on the command line. This makes life easier for tools that ingest GNAT's output. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_

[Ada] arm-qnx-7.1: unwind goes wrong after regs restore

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Bump the pc +3 total for Thumb mode, the same calculation that as is done for arm-linux. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * init.c (__gnat_adjust_context_for_raise) [QNX][__thumb2__]: Bump the pc an extra byte.diff --git a/gcc/ada/init.c b/gcc/ada/init.c

[Ada] Fix predicate check on object declaration

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
When subtype predicate checks are added for object declarations, it could lead to a compiler crash or to an incorrect check. When the subtype for the object being declared is built later by Analyze_Object_Declaration, the predicate check can't be applied on the object instead of a copy as the call

[Ada] Bug fix in "=" function of formal doubly linked list

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Correction of a typo regarding indexes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfdlli.adb ("="): Make the function properly loop over the right list.diff --git a/gcc/ada/libgnat/a-cfdlli.adb b/gcc/ada/libgnat/a-cfdlli.adb --- a/gcc/ada/libgnat/a-cf

[Ada] Do not freeze subprogram body without spec too early

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This fixes a small oddity whereby a subprogram body declared without a spec would be frozen before its entity is fully processed as an overloaded name. Now the latter step computes useful information, for example whether the body is a (late) primitive of a tagged type, which can be required during

[Ada] Fix classification of Subprogram_Variant as assertion pragma

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
This pragma was wrongly not recognized as an assertion pragma. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.ads (Assertion_Expression_Pragmas): Fix value for pragma Subprogram_Variant.diff --git a/gcc/ada/sem_prag.ads b/gcc/ada/sem_prag.ads --

[Ada] Rename Returns_On_Secondary_Stack into Needs_Secondary_Stack

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
The Returns_On_Secondary_Stack predicate is a misnomer because it must be invoked on a type and types do not return; as a matter of fact, the other Returns_XXX predicates apply to functions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Caller_Known_Size): Inv

[Ada] Fix missing space in error message

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
On illegal code like: type T is new Positive in range 1..5; the compiler was emitting message: error: extra "in"ignored ^^ which lacked a space character. A tiny diagnostic improvement; spotted while mistakenly typing an illegal test. Tested on x86_64-pc-linux-gnu, comm

[Ada] Combine system.ads files - arm and aarch64 qnx

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-qnx-arm.ads (Memory_Size): Compute based on Word_Size.diff --git a/gcc/ada/

[Ada] Combine system.ads file - vxworks7 kernel constants.

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-aarch64.ads (Word_Size): Compute based on Standard'Word_Size. (Mem

[Ada] Allow confirming volatile properties on No_Caching variables

2022-06-01 Thread Pierre-Marie de Rodat via Gcc-patches
Volatile variables marked with the No_Caching aspect can now have confirming aspects for other volatile properties, with a value of False. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * contracts.adb (Check_Type_Or_Object_External_Properties): Check the validity of

[Ada] Add contracts to Interfaces.C.Strings

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds Global contracts and preconditions to subprograms of Interfaces.C.Strings. Effects on allocated memory are modelled through an abstract state, C_Memory. The preconditions protect against Dereference_Error, but not Storage_Error (which is not handled by SPARK). This patch also disabl

[Ada] Add contracts to System.Address_To_Access_Conversions

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds SPARK annotations to subprograms from System.Address_To_Access_Conversions. To_Pointer is considered to have no global items, if the returned value has no aliases. To_Address is forbidden in SPARK because addresses are not handled. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Fix iteration on formal vectors

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
We need to use Extended_Index for the Position parameter of the Element function in formal vectors so it is compatible with other primitives of the Iterable aspect. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfinve.ads (Element): Change the type of the

[Ada] Gnatbind crash during checksum calculation

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby gnatbind may crash during calculation of file checksums in certain corner cases due to uninitialized lookup tables. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnatbind.adb (Gnatbind): Add initialize call for Uintp

[Ada] Combine system.ads file - vxworks7 rtp constants

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-aarch64-rtp-smp.ads (Word_Size): Compute based on Standard'Word_Si

[Ada] Combine system.ads files - arm and aarch64 linux

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-linux-arm.ads (Memory_Size): Compute based on Word_Size.diff --git a/gcc/ad

[Ada] Propagate Has_Inherit{able,ed}_Invariants to base types

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
The two flags apply to base types only like Has_Own_Invariants. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Propagate_DIC_Attributes): Add ??? comment. (Propagate_Invariant_Attributes): Likewise. Propagate the Has_Inheritable_Invariants and

[Ada] Complete contracts of Interfaces.C.Strings subprograms

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds preconditions to Update procedures, to protect from Update_Error propagations. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/i-cstrin.ads (Update): Add precondition.diff --git a/gcc/ada/libgnat/i-cstrin.ads b/gcc/ada/libgnat/i-cstrin.ads --- a/gcc/a

[Ada] Issue errors on wrong context for ghost entities

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
References to ghost entities should only occur in ghost context. This was not checked systematically on all references. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch2.adb (Analyze_Identifier): Add checking for ghost context. * sem_ch5.adb (Analyze_I

[Ada] Fix preconditions of Interfaces.C.Strings

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Preconditions of Update procedures were always true when Offset was 0. The changes enable to protect from Update_Error when Offset is 0. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/i-cstrin.ads (Update): Update precondition.diff --git a/gcc/ada/libgnat/i-cstrin.a

[Ada] Fix detection of deferred constants for freezing error

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Testing Is_Frozen is not robust enough, so instead test that the full view has been seen and that the Has_Completion flag is set on it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Check_Expression_Function.Find_Constant): Make test for deferred consta

[Ada] Update documentation of GNAT.Dynamic_Tables

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Document that dynamic tables are defined aliased for backward compatibility. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-dyntab.ads (Table_Type): Update documentation.diff --git a/gcc/ada/libgnat/g-dyntab.ads b/gcc/ada/libgnat/g-dyntab.ads --- a/gcc/ada/libgnat

[Ada] vx7r2-arm/aarch64 - Support Atomic Primitives True

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This feature is an architecture feature, not an OS feature, so enable on vx7r2 for arm and aarch64 to coincide with what is done on similarly capable targets. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-arm.ads (Support_Atomic_Primitives):

[Ada] Build static dispatch tables always at the end of declarative part

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
The static dispatch tables of library-level tagged types are either built on the first object declaration or at the end of the declarative part of the package spec or body. There is no real need for the former case, and the tables are not built for other constructs that freeze (tagged) types. Ther

[Ada] Move registering code for predefined primitives to Exp_Disp

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This avoids making Expand_Interface_Thunk visible from the outside. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Freeze_Subprogram.Register_Predefined_DT_Entry): Move procedure to... * exp_disp.ads (Expand_Interface_Thu

[Ada] Fix spurious errors on ghost code in generics

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
After the recent fix for detecting illegal use of ghost entities in code, spurious errors could be raised on generic code with ghost, due to wrong setting of the ghost flags on copied entities from the generic to the instantiation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Refine previous changes on making symbols public/private

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Inline_Always procedures should be kept public for proper inter unit inlining. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch7.adb (Set_Referencer_Of_Non_Subprograms): New local procedure, used for code refactoring. Also take into account Inline_Alway

[Ada] Add precise subprogram identification to -fdiagnostics-format=json

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This commit adds information allowing identification of the subprogram surrounding the message emitted by gnat when using -gnatdJ along with -fdiagnostics-format=json. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Write_JSON_Span): Add subprogram name to emitte

[Ada] Fix spurious use of trampolines with interface types

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Function pointers must always be built with '[Unrestricted_]Access. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Init_Secondary_Tags.Initialize_Tag): Initialize the Offset_Func component by means of 'Unrestricted_Access.diff --git a/gcc/ada/exp_ch3.ad

[Ada] Rename GNATprove annotate pragma for termination to Always_Return

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
GNATprove changed the name of the pragma Annotate used to verify that a subprogram always returns normally. It is now called Always_Return instead of Terminating. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb: Use Always_Return instead of Terminating

[Ada] Make the functional Maps and Sets unbounded

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Before this patch, the Functional Sets ans Maps were bounded both from the user and the implementation points of view. To make them closer to mathematical Sets ans Maps, this patch removes the bounds from the contracts. Note that, in practice, they are still bounded by Count_Type'Last, even if the

[Ada] Fix references to old variables that have been refactored

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Local_Entity_Suppress and Global_Entity_Suppress variables referencing tables were refactored to Local_Suppress_Stack_Top and Global_Suppress_Stack_Top stacks back in 2007. Fix remaining references to these variables. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ad

[Ada] Remove redundant checks for missing lists

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
When iterating over list elements with First/Next there is no need to check if the list is present, because First intentionally returns Empty if list is not present and the condition of subsequent loop will not be satisfied. Code cleanup; semantics is unaffected. Occurrences of the redundant patt

[Ada] Get rid of secondary stack for most calls returning tagged types

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This eliminates the use of the secondary stack to return specific tagged types from functions in calls that are not dispatching on result, which comprises returning controlled types, by introducing thunks whose only purpose is to move the result from the primary to the secondary stack for primitive

[Ada] Never make symbols for thunks public

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
Thunks are only referenced locally by dispatch tables and never inlined. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Clear the Is_Public flag on thunks.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/

[Ada] Restore full generation of static dispatch tables with -gnatzr

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
The -gnatzr switch triggers the creation of distribution stubs for use by the implementation of PolyORB. Now these stubs declare tagged types and are generated at the very end of the analysis of compilation units, after the static dispatch tables have been built, so these tables are missing for th

[Ada] Couple of small preparatory adjustments

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Do not check the scope of anonymous access Itypes. * gcc-interface/trans.cc (Identifier_to_gnu): Do not translate the return type of a s

[Ada] Disable -flto when building the shared libgnat

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This setting isn't useful in this context. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/Makefile.in (gnatlib-shared-default): Add -fno-lto.diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in --- a/gcc/ada/gcc-interface/

[Ada] Fix record layout warnings not being tagged

2022-06-02 Thread Pierre-Marie de Rodat via Gcc-patches
This allows tools ingesting GNAT's output to properly classify these messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (warn_on_field_placement): Add insertion character '.q' to warning string.diff --git a/gcc/ada/gcc-interface/decl.cc b

[Ada] Reduce runtime dependencies on stage1

2022-01-05 Thread Pierre-Marie de Rodat via Gcc-patches
To simplify the bootstrap constraints, duplicate a few definitions in order to remove dependencies on a recent version of System.Case_Util, System.Crtl, System.OS_Lib. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * osint.adb (File_Names_Equal): Declare To_Lower locally.

<    28   29   30   31   32   33   34   35   >