[Ada] Reorder subprogram spec and bodies in alphabetical order

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Required by the style guide and by future changes in this function. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Analyze_Membership_Op): Reorder subprogram spec and bodies in alphabetical order.diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb --

[Ada] Import binder globals as constant

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
The various __gl_XYZ binder globals prevent some link-time optimizations when imported as mutable. Work around this by turning them into constants. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-intman__android.adb, libgnarl/s-intman__lynxos.adb, libgnarl

[Ada] RTEMS: use hardware interrupts instead of signals for interrupt handling

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
RTEMS supports attaching interrupt handlers to hardware interrupt vectors, which is superior to the current approach of attaching handlers to signals. Direct attachment of handlers removes the execution overhead of converting hardware interrupts to signals and their subsequent propagation to the i

[Ada] Fix internal error on fixed-point divide, multiply and scaling

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
This fixes a couple of long-standing oversights in the fixed-point multiply implementation that were recently copied into the divide implementation and thus made more visible: when computing the operand size for compile-time known values, the negative case must be taken into account and comparisons

[Ada] Find an interpretation for membership test with a singleton value

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
When resolving type Color is (Blue, Orange); function Get_Color return Color is begin return Blue; end Get_Color; function Get_Color return String is begin return "Blue"; end Get_Color; Test : Boolean := Get_Color in Blue; we did not try all the possible interpretations of

[Ada] Remove constant arguments

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
All these arguments were identified programmatically as being always used with the same value (often the default one). As such, they can be omitted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ali.adb (Get_Name): Ignore_Spaces is always False. * bindo-graphs.adb

[Ada] Simplify membership tests with N_Generic_Declaration

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Use collective N_Generic_Declaration subtype instead of its members N_Generic_Subprogram_Declaration and N_Generic_Package_Declaration where reasonable. Code cleanup related to handling of Global contracts in generic units; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] RTEMS: use regular RTEMS API for minimum stack size calculation

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Use _POSIX_Threads_Minimum_stack_size instead of ada_pthread_minimum_stack_size so the runtime does not require the RTEMS kernel to be configured to have Ada support. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-parame__rtems.adb: use _POSIX_Threads_Mini

[Ada] Incorrect Dynamic_Predicate results for static arguments

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
In determining at run time whether a statically-known discrete value satisifies the predicate of a subtype where both - a Dynamic_Predicate aspect specification applies (directly or indirectly) to a subtype; and - at least one other predicate aspect specification (that is, either

[Ada] Warn about conversion with any predefined time types

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
We already had a warning for unchecked conversions that involve the private type Ada.Calendar.Time, whose representation might differ between releases and targets of the compiler. Now this warning is extended to Ada.Real_Time.Time and Ada.Real_Time.Time_Span, which is similarly non-portable. Previ

[Ada] Valid postconditions incorrectly rejected.

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
For users, 'Old attribute references are only allowed within postcondition expressions. Internally, the FE may build trees that transiently (before some subsequent transformation) violate these rules; this is ok, but these violations were being incorrectly flagged in some cases. Fix this problem.

[Ada] Runtime transition: System.Threads

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Rewrite the former System.Threads implementation for AE653 to work on the new Light runtime for VxWworks7r2Cert. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-thread.ads: Fix comments. Remove unused package imports. (Thread_Body_Exception_Exit):

[Ada] Remove redundant guard in expansion of dispatching calls

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Routines Make_Predefined_Primitive_Specs and Predefined_Primitive_Bodies, which create predefined primitives for derived tagged types, are only called when restriction No_Dispatching_Calls is inactive. There is no need to recheck this restriction when creating individual primitive operations relate

[Ada] Fix for atomic wrongly rejected on object of discriminated type

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
The reason is that the automatic alignment promotion is not yet performed in the case where the nominal subtype is of variable size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.c (promote_object_alignment): Add GNU_SIZE parameter and use it for

[Ada] Tweak the warning about missing local raises

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
This prevents the warning from being given when there may still be regular exception handlers in the code, although some of them have been turned into local raises, by querying the predicate that determines whether such regular handlers are removed or not in the front-end. Tested on x86_64-pc-linu

[Ada] Fix problematic import of type-generic GCC atomic builtin

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
This implements the support for most type-generic GCC atomic builtins. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/gigi.h (resolve_atomic_size): Declare. (list_third): New inline function. * gcc-interface/decl.c (type_for_atomic_builtin_p):

[Ada] Fix type conversion handling in validity checks

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
In case of a checked type conversion, correctly update Typ to match the expression being validated and call Analyze_And_Resolve on the modified expression. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Insert_Valid_Check): in case of checked type conver

[Ada] Issue warning on unused quantified expression

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
It is common that a quantified expression takes the form of a conjunction or disjunction. In such a case, it is expected that all conjuncts/ disjuncts reference the quantified variable. Not doing so can be either the symptom of an error, or of a non-optimal expression, as that sub-expression could

[Ada] Get rid of Frontend_Exceptions refs

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup and remove some unused system specs and references to same. These are specs that set Frontend_Exceptions, which is no longer used in GNAT. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl: Remove references to system-vxworks-ppc.ads and system-vxw

[Ada] Small cleanup in Eval_Integer_Literal

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
This removes an unreachable case in a nested predicate function as well as trims down a verbose condition. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.ads (Check_Non_Static_Context): Update documentation. * sem_eval.adb (In_Any_In

[Ada] Rewrite tests on Convention_Intrinsic

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
Testing for Convention_Intrinsic is not the proper way in order to spot intrinsic subprograms, calling the predicate Is_Intrinsic_Subprogram is. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_entity) : Replace test on Convention_Int

[Ada] Expose and use type-generic GCC atomic builtins

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
This exposes the newly added support for type-generic GCC atomic builtins to the user through the System.Atomic_Primitives package, where a generic version of the existing routines is added. This also uses this support in the implementation of the System.Atomic_Operations packages. Tested on x86_

[Ada] Prevent use of an uninitialized AST field with universal integer

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
A temporary workaround needed by GNATprove after cleaning up the handling of AST fields with universal integers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_spark.adb (Expand_SPARK_N_Attribute_Reference): Guard against equality of an uninitialized RM_Size fie

[Ada] Warning on nonmatching subtypes in fully conforming subprogram specs and bodies

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
When corresponding parameter subtypes or result subtypes denote different declarations between the declaration and body of a subprogram, but those are fully conforming, a warning will be issued indicating that the subtypes come from different declarations. In the case of anonymous access subtypes,

[Ada] tech debt: Clean up Uint fields, such as Esize

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
Use No_Uint to indicate "unknown" or "not yet known" for various fields whose type is Uint, instead of using Uint_0. Otherwise Uint_0 could be ambiguous -- it could also mean "value is known, and is zero". This patch does not fix all bugs in this area, but fixes most of them, and adds assertions th

[Ada] Refine type of a counter function for record delta aggregate

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
Distance of a variant in the enclosing type declaration is never negative. Code cleanup related to fix for boxes in record delta aggregates; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Variant_Depth): Refine type from Integer to

[Ada] Crash on object of protected type with defaulted access component

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects issues in the compiler whereby default initializing a protected type component of an access type containing controlled parts with an allocator causes a crash at compile-time at the point of an object declaration of such protected type. Tested on x86_64-pc-linux-gnu, committed o

[Ada] Missing accessibility check when returning discriminated types

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
In some cases where a function result type has an access discriminant part, Ada requires that the execution of a return statement include a check that the access discriminant does not designate an object whose accessibility level is too deep (Ada RM 6.5(21)). This check was being incorrectly omitte

[Ada] Reject boxes in delta record aggregates

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
Implement Ada 2022 4.3.1(17.3/5), prevents box compound delimiter <> to appear in record delta aggregates. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Delta_Record_Aggregate): Reject boxes in record delta aggregates.diff --git a/gcc/ada/sem_

[Ada] Factor out machine rounding operations

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
The RM 4.9(38/2) clause specifies that the rounding to be applied to a real static expression that is not part of a larger static expression is implementation defined, so it makes sense to have a single function implementing the operation. The change also sets the Is_Machine_Number flag more consi

[Ada] Fix problematic conversion of real literal in static context

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
This gets rid of a bogus error issued for the conversion to a static floating-point subtype of a named number which is not a machine number of this floating-point subtype but happens to be very close (or equal) to one of the nominal bounds of the subtype. This conversion may not change the value o

[Ada] Provide dummy body for big integers library used in reduced runtimes

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
The version of Ada.Numerics.Big_Numbers.Big_Integers used in the light and embedded runtimes is only meant for proof, not execution. As a result, all subprograms were previously marked as imported, but this leads to a spurious compilation error in GNAT. Work around that bug for now by providing a d

[Ada] Proof of the runtime support for attribute 'Width

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
This proves the absence of runtime errors and the functional spec of function System.Width_U which implements the runtime support for attribute 'Width. It requires using the library unit Ada.Numerics.Big_Numbers.Big_Integers because it was not possible to achieve even absence of runtime errors by

[Ada] Remove unnecessary call to No_Uint_To_0

2021-10-20 Thread Pierre-Marie de Rodat via Gcc-patches
This call to No_Uint_To_0 was unnecessary. We should try to remove all calls to No_Uint_To_0; they are all questionable. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_entity): Remove unnecessary call to No_Uint_To_0.diff --git a/gc

[Ada] Fix deleted Compile_Time warnings causing crashes

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Count_Compile_Time_Pragma_Warnings also counted deleted pragmas. This caused discrepancies ultimately leading to a crash when Compile_Time warnings were suppressed by a Warnings(Off, ...) pragma. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * erroutc.adb (Count_Compile_Time

[Ada] Issue error on invalid use of Ghost inside pragma Predicate

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Checking for ghost placement was only occurring inside the various versions of predicate aspects, not inside the pragma Predicate. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Freeze_Entity_Checks): Perform same check on predicate expressi

[Ada] Renamed_Or_Alias cleanup

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
There are three "fields" that are aliases for the Renamed_Or_Alias field: Alias, Renamed_Entity, and Renamed_Object. The getters and setters were (mis)used more or less interchangeably, in violation of the comments. This patch adds assertions to enforce the comments, and changes all of the call si

[Ada] Ada 2022: Class-wide types and formal abstract subprograms

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Ada 2022 specifies that when the controlling type of a formal abstract subprogram declaration is a formal type, and the actual type is a class-wide type T'Class, the actual subprogram can be an implicitly declared subprogram corresponding to a primitive operation of type T (AI12-0165-1/05). Tested

[Ada] Shutdown codepeer message

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Which is a false positive, caused by a confusion on the expanded code for pragma Loop_Variant. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-widthu.adb: Add pragma Annotate.diff --git a/gcc/ada/libgnat/s-widthu.adb b/gcc/ada/libgnat/s-widthu.adb --- a/gcc/ada/lib

[Ada] Don't expect enumeration literals to be renamings

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
When using cross-reference information to get subprogram effects in SPARK (i.e. its reads and writes), we were calling Renamed_Object on enumeration literals. This was pointless but harmless; now it rightly triggers an assertion failure in developer builds, so avoid that. Tested on x86_64-pc-linux

[Ada] Reference in Unbounded_String is almost never null

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
There are two variants of the Ada.Strings.Unbounded_String package, with and without atomic reference counters. The underlying pointer is never null in one variant (and had a null-excluding type) and almost never null in the other variant (and now has a null-excluding type as well). Cleanup relate

[Ada] Initialize variable to Empty

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
CodePeer was warning about this variable being potentially used without being initialized. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Analyze_Subprogram_Renaming): Set New_S to Empty.diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb --- a/gcc/ada/sem_c

[Ada] Do not expect execv to return 0

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
When spawning subprocesses with fork & execv there is no need to check the result of execve, because it either succeeds and does not return or fails and returns -1. This is only a code cleanup related to the use of fork-vs-vfork in GNATprove; behaviour is unaffected, though the GNAT runtime librar

[Ada] Remove redundant guard in expansion of dispatching calls

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Routine Predefined_Primitive_Bodies, which create predefined primitives for derived tagged types, is only called with non-interface types entities (which is even enforced with an assertion at the very start of its body). There is no need to recheck this condition when creating individual primitive

[Ada] Simplify detection of a parent interface equality

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
Replace subtle conditions on First_Entity/Last_Entity with a straightforward Number_Formals/First_Formal/Last_Formal. Code cleanup related to handling of dispatching equality in SPARK. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Predefined_Primitive_Bodies)

[Ada] Global contracts on expression functions in Ada.Strings.Superbounded

2021-10-25 Thread Pierre-Marie de Rodat via Gcc-patches
For consistency, add Global => null contracts also to expression functions in the Ada.Strings.Superbounded package. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strsup.ads (Super_Length, Super_Element, Super_Slice): Add Global contracts.diff --git a/gcc/

[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

<    2   3   4   5   6   7   8   9   >