[Ada] Crash on allocator in alternative accessibility modes

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue in the compiler whereby the level for allocated objects of anonymous access types was calculated incorrectly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Function_Or_Allocator_Level): Properly handle direct function call

[Ada] PR ada/102073

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Add missing return statements in socket.c as flagged by cppcheck. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ PR ada/102073 * socket.c (__gnat_gethostbyaddr, __gnat_inet_pton): Add missing return statements.diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c -

[Ada] Adjust documentation of -fdump-ada-spec in GNAT UG

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This explicitly documents the behavior for /include/-ending paths and also updates other parts of the description. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/the_gnat_compilation_model.rst (Binding generation): Document specific behavior for /includ

[Ada] Spurious non-variable error on implicitly dereferenced in-mode formal

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue in the compiler whereby taking 'Access of a protected subprogram based on an implicitly dereferenced protected object causes a spurious non-variable error when such an object is an in-mode access type formal. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Fix handling of 'Image acting as a prefix of a slice in CodePeer

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
In CodePeer mode attribute Image is not expanded and has its Etype set as the unconstrained String type. When this attribute appears as a prefix of an indexed component, we get a check; when it appears as a prefix of a slice, we don't get a check. For indexed components, the check effectively come

[Ada] Fix missing check on slice with a subtype indication

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
A slice range can be specified either by a subtype name, regular range, or subtype indication with constraints. The compiler missed the last case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Slice): Handle range given as a subtype indication.

[Ada] Fix handling of slices with subtype names

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
When resolving a slice with subtype name we created a shallow copy of the type range and applied range checks to this copy. This was wrong, because when applying checks we were modifying the type declaration itself (and the type could be anything, for example the predefined Integer type). Instead

[Ada] Declaration_Node for Itypes returns Empty or declaration

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch changes Declaration_Node for Itypes so that it either returns Empty or returns a proper declaration node. If the tree structure is that of a normal type or subtype declaration, so the parent of the Itype is that declaration, then we return the declaration. Otherwise, we return Empty rath

[Ada] Fix resolution of Declare_Expressions involving transient scopes

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch modifies the resolution of Declare_Expressions to avoid the use of a fake scope to perform name capture in the expression, because such a scope (needed to analyze the declarations of the construct) conflicts with the transient scopes that may be generated by the presence of calls in the

[Ada] Fix for a static Leading_Part attribute raising constraint error

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Attribute Leading_Part, when its second parameter is zero or negative, is now raising a constraint error when evaluated at compilation time just like it did when evaluated at run time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Eval_Attribute): Evaluation

[Ada] Add Ada RM description of Ada.Strings.Bounded as comments in the spec

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
To facilitate using the standard library, Ada RM description from section A.4.4 is added to the code as comments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strbou.ads: Add comments.diff --git a/gcc/ada/libgnat/a-strbou.ads b/gcc/ada/libgnat/a-strbou.ads --- a

[Ada] Fix comment about expansion of slices

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to handling of array accesses in CodePeer mode. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Selected_Range_Checks): Fix style. * exp_ch4.adb (Expand_N_Slice): Fix style and comment. * sem_res.adb (Resolve_Indexed_Component): Fi

[Ada] Emit specific SCOs for decisions of quantified expressions

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Coverage analysis on quantified expressions now requires always processing their predicate expression as a decision. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * scos.ads: Extend the documentation. * par_sco.adb (Process_Decisions): Emit specific SCOs for

[Ada] Remove repeated calls to Prefix in resolution of array accesses

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to recent fixes for resolution of array slices; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Indexed_Component, Resolve_Slice): Rename the local constant Name to Pref; remove repeated calls to

[Ada] Refactor duplicate code for pretty-printing GNAT AST

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Remove duplicated CASE branches detected by infer; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sprint.adb (Sprint_Node_Actual): Refactor code for generic package and subprogram declarations.diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint

[Ada] Minor comment fix in System.Regpat

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
If Data_First is set to the special value of -1 (the default), then we cannot look at Data (Data_First). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-regpat.ads: Change Data_First to Data'First. Change "still" to "always". Similar changes for Data_Last.

[Ada] Mark Ada.Text_IO in SPARK

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
Now that access-to-constant types are supported in SPARK, type File_Access is accepted and the public interface of Ada.Text_IO can be marked in SPARK. Fix a missing save/restore for the global variable storing whether SPARK_Mode should be ignored inside instances, around the analysis of a new unit

[Ada] Completion of support for AI12-0409 (attribute Preelaborable_Initialization)

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This set of changes implements proper checking of types completing private types in a generic unit where the full type has components of formal types of the generic and the private type has a Preelaborable_Initialization aspect given by a conjunction of one or more references to Preelab_Initializat

[Ada] Implement CUDA_Device

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This commit removes entities marked with the CUDA_Device pragma from the packages specs and bodies they exist in. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnat_cuda.adb (Remove_CUDA_Device_Entities): New function. (Expand_CUDA_Package): Call Remove_CUDA_Device

[Ada] Fix indentation in generated AST construction functions

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
In the generated nmake.adb file the "return" keyword in function declarations was printed at the start of a line. Now it is correctly indented, which makes the generated code easier to read. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gen_il-gen.adb (Put_Make_Spec): Don'

[Ada] Handle properly user_defined literals given by operators.

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch expands the implementation of aspects Integer_Literal, Real_Literal and String_Literal, so that the value of the aspect, which must be a function name, can be specified by an Operator_Symbol. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Ope

[Ada] Document the current behaviour of -gnateA switch

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
The runtime checks for overlaping actual parameters, which gets enabled by the -gnateA switch, were introduced to combine proof and test for the antialiasing rules of SPARK. The original implementation of these checks contained few mistakes which resulted in spurious compilation errors. These are

[Ada] Incremental patch for restriction No_Dynamic_Accessibility_Checks

2021-10-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects various issues discovered during testing of the No_Dynamic_Accessibility_Checks restriction and documents the feature in the GNAT RM. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/standard_and_implementation_defined_restrictions.rst:

[Ada] Improve error message on missing all/for in quantified expression

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
When "for" or "some" keyword is missing from a quantified expression, it is interpreted as an iterated component association by GNAT, leading to misleading error messages such as: badquant.ads:4:07: error: expected type "Standard.Boolean" badquant.ads:4:07: error: found a composite type Recognize

[Ada] Proof of Ada.Strings.Maps

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
Nearly complete functional specification of this unit based on the Ada RM requirements in Ada RM A.4.2. The small differences are noted in comments. Also add comments from the Ada RM text. GNATprove proves both absence of runtime errors and that the code correctly implements the specified contrac

[Ada] Proof of Ada.Characters.Handling

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
Complete functional specification of this unit based on the Ada RM requirements in Ada RM A.3.2. This includes also obsolete subprograms moved to Ada.Characters.Conversions in Ada 2005. GNATprove proves both absence of runtime errors and that the code correctly implements the specified contracts.

[Ada] Improve message on missing all/for in pre-Ada-2022 modes

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
A previous change improves an error message to "missing ALL or SOME in quantified expression", but this was effective only -gnat2022 mode. This change allows the better error message to be printed in older language modes. It also treats the relevant features identically, except for the "...is an A

[Ada] Disable contract cases on formal containers

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
Just like postconditions, contract cases on formal containers use functional containers which might leak memory. Disable them. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfdlli.ads: Use pragma Assertion_Policy to disable contract cases at execution.

[Ada] Add Default_Initial_Condition to type Unbounded_String

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
SPARK emitted spurious checks on Unbounded_String variables that were not initialized. This patch adds a default initial condition to the type Unbounded_String so that they disappear. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strunb.ads, libgnat/a-strunb__sha

[Ada] Propagate Ghost status from parent to derived subprograms

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
When creating the entity of a derived subprogram we copy all kinds of properties from the parent, but we failed to copy the ghost status of the entity. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Derive_Subprogram): Copy ghost status from parent to d

[Ada] Rewrite operator entity in derived class-wide expressions

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
When building a derived class-wide pre- or postcondition we are mapping references to inherited formals and to the inherited subprogram itself. We now do the same for references to the inherited operator. Such references might appear as prefixes of the Result attribute, e.g. "="'Result. Tested on

[Ada] Front-end support for Storage_Model feature

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
This set of changes implements the GNAT front end's support for the new aspects Storage_Model_Type and Designated_Storage_Model. It also defines a set of functions intended to provide an interface for back ends to call to retrieve operations and other entities associated with types that specify the

[Ada] Improve error message on array aggregates

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
Contrary to record aggregates, array aggregate cannot mix named and positional associations. Make it clear in the error message. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Array_Aggregate): Improve error message.diff --git a/gcc/ada/sem_aggr.adb b/

[Ada] Add missing functions to Wide_Wide_Characters Handling

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
See RM A.3.6 and AI12-0260. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-zchhan.ads, libgnat/a-zchhan.adb (Character_Set_Version, Is_Basic, To_Basic): New. * libgnat/a-zchuni.ads, libgnat/a-zchuni.adb (Is_Basic, To_Basic): New.diff --git

[Ada] Add sys/time.h #include for QNX

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
As part of an improvement to the precision of Ada.Directories.Modification_Time, we use the type `struct timespec` when we can (if _POSIX_C_SOURCE is greater than 200809L). For QNX, we need to include the system header `sys/time.h` to get the type declaration, `time.h` does not have it. Tested on

[Ada] Remove left-overs of Unaligned_Valid attribute

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
The support for the attribute itself was removed a long time ago. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Expand_Fpt_Attribute): Likewise. * snames.ads-tmpl (Name_Unaligned_Valid): Delete.diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb

[Ada] Include errno.h in QNX specific part of the signal handling

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
To get access to the errno variable, we need to include errno.h. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * init.c (QNX): Add #include errno.h.diff --git a/gcc/ada/init.c b/gcc/ada/init.c --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -2551,6 +2551,7 @@ __gnat_install_han

[Ada] Mark private component renaming as coming from source

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
This marks the local renaming generated for private components of protected types as coming from source, so that the components are displayed when the 'info locals' command is used in GDB. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch9.adb (Install_Private_Data_Decl

[Ada] introduce stack scrub (strub) feature

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
This is the GNAT part of the patch that adds the strub attribute for function and variable types, command-line options, passes and adjustments to implement it, documentation, and tests. Besides documentation, the bulk of the patch adds strub(callable) to subprograms that the compiler may call impl

[Ada] Fix latent bug in set_end_locus_from_node

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
Avoid calling End_Label on the Empty node. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.c (set_end_locus_from_node): Check that Handled_Statement_Sequence is not Empty before calling End_Label, because the Empty node has no End_Label, a

[Ada] Add case to consider ENODEV a "file not found error"

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
Starting with VxWorks 21.03, a call to fopen() can now set errno to ENODEV if a prefix of the path does not match any known device. This led the runtime to raise the wrong exception type when trying to a file for which the parent directory did not exist and caused the acats testsuite to fail. This

[Ada] Do not unconditionally inline expression functions with -gnatd.8

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
This is necessary when expression functions are really too large. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.c (Subprogram_Body_to_gnu): Do not set the DECL_DISREGARD_INLINE_LIMITS flag if -gnatd.8 is specified.diff --git a/gcc/ada/gcc-interf

[Ada] Forbids use of Compile_Time_(Error|Warning) as configuration pragma

2021-10-05 Thread Pierre-Marie de Rodat via Gcc-patches
Before this commit, in case these pragmas were used inside adc file, gnat1 would fail with a `constraint_error` as it tries to get the context of the pragma. This commit induces a regression on dubious uses of these pragmas as configuration pragmas in ads/adb files. Review documentation on config

[Ada] Size of time_t in newer verions of VxWorks7

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Set the default size of time_t_bits to match the standard runtimes. The size must match that which is used in the VSB, since the same VSB is used to build all of the runtimes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-parame__ae653.ads (time_t_bits): Change t

[Ada] Simplify code for checks within an initialization procedure

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
It is simpler to access the type of first formal using semantic instead of syntactic query. Behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Compile_Time_Constraint_Error): Simplify getting the type of the first formal parameter.

[Ada] Fix crash on array component with Default_Value

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
When complaining about a compile-time constraint error within a default initialization procedure we assumed that this procedure initializes a record object. However, it can initialize an array object too. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Inside_I

[Ada] Do not clear Analyzed flag in expand if already set by preanalysis

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
During Expand, prevent the clearing of the Analyzed flag if it has already been set by Fold_Ureal. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * expander.adb (Expand): Skip clearing of Analyzed flag if already set for N_Real_Literal.diff --git a/gcc/ada/expander.ad

[Ada] RTEMS: use default stack checking emulation package

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Remove the RTEMS specific version of System.Stack_Checking.Operations as the internal RTEMS API it uses can only detect stack overflow after the event, whereas the stack checking emulation is meant to detect the stack overflow before it occurs. Use the standard System.Stack_Checking.Operations pack

[Ada] Simplify initialization of concurrent components

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Concurrent record types are either task record types or protected record types. Now we detect them collectively (when looking for any of them) or exclusively (when looking for one or the other). Cleanup code related to fixes in expansion of boxes in record aggregates. Behaviour is unaffected. Tes

[Ada] Remove redundant guard against an empty component list

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
There is no need to explicitly guard against an empty list where the subsequent iteration with First/Next/Present works fine. Cleanup related to expansion of aggregates in GNATprove mode; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb

[Ada] Move rewriting of boxes in aggregates from resolution to expansion

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Rewriting of boxes in record aggregates into the corresponding default values was done in resolution, where we special-cased access types and scalar types with a Default_Value aspect. However, this rewriting rather belong to expansion. Also, the special-casing didn't take Normalize_Scalars nor Ini

[Ada] Simplify detection of record components with default initialization

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
When detecting record components with default initialization we did two iteration over the component list; now we do only one. Also, there was no need to explicitly guard against an empty list where the subsequent iteration with First/Next/Present works fine. Cleanup related to expansion of aggre

[Ada] Simplify detection of delayed aggregates

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
Replace IF with a single RETURN statement. Cleanup related to expansion of aggregates in GNATprove mode; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Is_Delayed_Aggregate): Simplify.diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_agg

[Ada] Rewrite extended names in derived class-wide expressions

2021-10-11 Thread Pierre-Marie de Rodat via Gcc-patches
When building a derived class-wide pre- or postcondition we are mapping references to inherited formals and subprogram. Originally we only did it for simple names; recently we fixed this mapping to also work for operator symbols; with this patch we also do this for extended names. Tested on x86_6

[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/

<    27   28   29   30   31   32   33   34   35   >