[Ada] Remove excessive guards against inserting empty lists of actions

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Call to Insert_Actions with empty list does nothing, so there is no need to guard against such calls. Code cleanup; behavior is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Freeze_Itype): Remove excessive guard. * sem_ch5.adb (Analyze_Loop_

[Ada] Cleanup analysis of iterator specifications

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb (Check_Subtype_Definition): Remove redundant call to Present; style cleanup.diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb --- a/gcc/ada/sem_ch5.adb +++ b/gcc/a

[Ada] Cleanup analysis of quantified expressions with empty ranges

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Cleanup handling of quantified expressions before using it as an inspiration for fixing the handling of iterated component associations. Behavior is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Is_Empty_Range): Move error reporting to the

[Ada] Fix resolution of iterated component association

2022-09-05 Thread Marc Poulhiès via Gcc-patches
For iterator specification appearing inside an iterated component association, we just did ad-hoc, incomplete checks and delayed a proper analysis until the iterated component association is expanded into loop (and then reanalyzed). However, when the iterated component association is not expanded,

[Ada] New gnatbind switch -k

2022-09-05 Thread Marc Poulhiès via Gcc-patches
This switch can be used to disable the effect of -F when using -n explicitly or implicitly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * bindgen.adb (Gen_Elab_Calls): Check for Check_Elaboration_Flags. * bindusg.adb (Display): Add -k. * opt.ads (Check_Elab

[Ada] Detect expansion of iterated component associations into loops

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Iterated component associations are expanded into loops, which GNAT should detect as violating restriction No_Implicit_Loops; same for iterated element associations and delta array aggregates. Part of cleanups for correct handling of iterated component associations in SPARK. Tested on x86_64-pc-l

[Ada] Suppress warnings in trivial subprograms with finalization

2022-09-05 Thread Marc Poulhiès via Gcc-patches
There are heuristics for suppressing warnings about unused objects in trivial cases. In particular, we try to suppress warnings here: function F (A : Integer) return Some_Type; X : Some_Type; begin raise Not_Yet_Implemented; return X; end F; But it doesn't work if Some_

[Ada] Enable Error_Msg_GNAT_Extension for mixed decl/stmts

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Enable mixing of declarative items and statements under the -gnatX switch. The previous version used the -gnat2022 switch. In addition, change the error message so that it advertises the new feature when it is disabled. Instead of: declarations must come before "begin" we now say (without -gnatX

[Ada] Cleanup resolution of iterated component association

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Tune names of local entities. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Iterated_Component_Association): Change generic name Ent to a more intuitive Scop; rename Remove_Ref to Remove_Reference, so it can be instantiated as a traver

[Ada] Fix detection of unused warning suppression

2022-09-05 Thread Marc Poulhiès via Gcc-patches
The comment for Warnings_Off says: "clients should generally not test this flag directly, but instead use function Has_Warnings_Off". Primarily a code cleanup, as this only affects minor a corner case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Validate_U

[Ada] Secondary stack and i-c*

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Extend the previous changes related to Ada.Tags trigerring a dependency on the secondary stack to various i-c* packages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ali.adb (Scan_ALI): Special case i-c*.ali when setting Sec_Stack_Used.diff --git a/gcc/ada/ali.adb

[Ada] Fix bogus discriminant check failure for type with predicate

2022-09-05 Thread Marc Poulhiès via Gcc-patches
This reorders the processing in Freeze_Entity_Checks so that building the predicate functions, which first requires building discriminated checking functions for record types with a variant part, is done after processing and checking this variant part. Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Cleanup resolution of aggregates with mixed component associations

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Code cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Array_Aggregate): Change an inconsistent use of False into its local equivalent Failure.diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb --- a/gc

[Ada] Fix double identifiers in iterated component association

2022-09-05 Thread Marc Poulhiès via Gcc-patches
The iterated_component_association grammar construct appears in Ada RM in two syntactic forms: with iterator_specification and with defining_identifier. This is now properly reflected in the GNAT AST, while previously we had two defining_identifiers regardless of the syntactic form. Cleanup relate

[Ada] Small cleanup in body of System.Value_R

2022-09-05 Thread Marc Poulhiès via Gcc-patches
This is mostly stylistic but also adds a couple of missing comments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valuer.adb (Scan_Decimal_Digits): Consistently avoid initializing local variables. (Scan_Integral_Digits): Likewise. (Scan_R

[Ada] Create internal type for null array aggregate as an itype

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Internal type created for the null array aggregate of Ada 2022 was created as a temporary entity and then flagged as internal, but it is better to create this type directly as an itype. In particular, when the null array aggregate appears in a spec expression, its type declaration will not be atta

[Ada] Bad Default_Initial_Condition check for a not-default-initialized object

2022-09-05 Thread Marc Poulhiès via Gcc-patches
No Default_Initial_Condition check should be generated for an object declaration that has an explicit initial value. Previously this was implemented by testing the Has_Init_Expression flag, but this only works if the object declaration was created by the parser (since only the parser sets that attr

[Ada] Cleanup iteration over aggregate component associations

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Code cleanup related to fixes for iterated component associations in GNATprove ; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Container_Aggregate): Style cleanup. (Resolve_Record_Aggregate): Remove redundant g

[Ada] Move check for null array aggregates to expansion

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Despite recent changes to runtime checks for null array aggregates, GNATprove still struggles with N_Raise_Constraint_Error nodes inserted into AST by aggregate resolution. The ultimate fix is to move these checks to expansion (which is disabled in GNATprove mode) and explicitly emit a proof check

[Ada] Remove no longer referenced GNATprove utility routine for itypes

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Code cleanup related to itypes for Ada 2022 null array aggregates. Remove routine that was added in 2011 but is not referenced by GNATprove since 2015. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads (Itype_Has_Declaration): Remove spec. * sem_util.adb (

[Ada] Single-element Append performance improvement

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Ada.Containers.Vectors has two Append procedures that take an Element value; one takes a Count parameter and one does not (the count is implicitly one for the latter). For the former version, there was code that took a faster path if certain conditions were met and otherwise took a slower path; one

[Ada] Remove VMS specific routine that is no longer referenced

2022-09-05 Thread Marc Poulhiès via Gcc-patches
Code cleanup related to resctrition No_Local_Allocators. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.ads (Entry_Names_OK): Remove spec. * exp_util.adb (Entry_Names_OK): Remove body.diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb --- a/gcc/ada/ex

[Ada] Fix insertion of a runtime check for null array aggregate

2022-09-05 Thread Marc Poulhiès via Gcc-patches
A null array aggregate of Ada 2022 requires a conditional runtime check that was inserted as an if-statement. While gigi can handle statements inserted into a list of declarations, in GNATprove such a statement will cause a crash. It is better to insert a conditional raise node, which is properly h

[Ada] Fix inconsistent building of itypes for null array aggregates

2022-09-05 Thread Marc Poulhiès via Gcc-patches
To analyze Ada 2022 null array aggregates we introduced a dedicated routine and bypassed the code for ordinary array aggregates. However, the types for the array indexes created by this dedicated routine differed from the types created for ordinary array aggregates, i.e. itypes for null array aggre

[Ada] Improve detection of illegal Iterable aspects

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Handling of aspect Iterable was lacking guards against illegal code, so the compiler either crashed or emitted cryptic errors while expanding loops that rely on this aspect. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementation_defined_aspects.rst

[Ada] Add formal verification dependencies to libgnat

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Spec units for verification of the GNAT standard library with GNATprove must be listed as part of the libgnat package, as otherwise libadalang will complain about missing dependencies. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): In

[Ada] Correctly round Value attribute for floating point in more cases

2022-09-06 Thread Marc Poulhiès via Gcc-patches
This provides correct rounding in the IEEE 754 sense for the Value attribute of floating-point types in more cases, by bumping the number of significant bits used in the initial integer mantissa obtained from parsing. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s

[Ada] Tune message for illegal aspect Relaxed_Initialization

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Error message about illegal aspect Relaxed_Initialization was lacking a whitespace character. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): Fix error template.diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13

[Ada] Bad Valid_Scalars result if signed int component type signed has partial view.

2022-09-06 Thread Marc Poulhiès via Gcc-patches
For an object X of a composite type, the attribute X'Valid_Scalars should return False if and only if there exists at least one invalid scalar subcomponent of X. The validity test for a scalar part may include a range test. In some cases involving a private type that is implemented as a signed inte

[Ada] ICE handling discriminant-dependent index constraint for access component

2022-09-06 Thread Marc Poulhiès via Gcc-patches
The compiler would fail with an internal error in some cases involving a discriminated record type that provides a discriminant-dependent index constraint for the subtype of a component of an access-to-array type when a dereference of that component of some object is mentioned in a pre- or postcond

[Ada] Correctly round Value attribute for floating point in more cases

2022-09-06 Thread Marc Poulhiès via Gcc-patches
This provides correct rounding in the IEEE 754 sense for the Value attribute of floating-point types in more cases, by switching from tables of powers of 10 to tables of powers of 5 for precomputed values, thus making it possible to use a single divide for denormals and normalized numbers just abov

[Ada] Fix a bug in the contract of formal ordered sets

2022-09-06 Thread Marc Poulhiès via Gcc-patches
There are 2 main issues in the postcondition of the function Replace of the formal ordered sets, in the sub package Generic_Keys. One is related to the fact that when the element is changed, the key is also changed. The second one is due to the fact that the arrival of the new element might modify

[Ada] Document change to legality checks for Inox case statements

2022-09-06 Thread Marc Poulhiès via Gcc-patches
INOX (which is enabled via -gnatX) supports composite case-statement selectors. As a temporary measure, simplify the coverage-related compile-time checks for such case statements via two changes: an others choice is always required for such a case statement, and no legality checks relating to overl

[Ada] Cope with scalar subtypes that have a non-scalar basetype.

2022-09-06 Thread Marc Poulhiès via Gcc-patches
In some cases, the compiler builds a subtype entity Typ such that Is_Scalar (Typ) is True and Is_Scalar (Base_Type (Typ)) is False. This comes up in some cases involving a subtype of a private type, where the full view of the private type is a scalar type. In such a situation, it may also be the ca

[Ada] Temporarily simplify legality checks for Inox case statements

2022-09-06 Thread Marc Poulhiès via Gcc-patches
INOX (which is enabled via -gnatX) supports composite case-statement selectors. As a temporary measure, simplify the coverage-related compile-time checks for such case statements via two changes: an others choice is always required for such a case statement, and no legality checks relating to overl

[Ada] Place "at end" on body nodes

2022-09-06 Thread Marc Poulhiès via Gcc-patches
This patch fixes a bug where finalization code might refer to variables outside their lifetime. The previous version moved declarations into the Handled_Statement_Sequence (HSS), so that the "at end" handler of the HSS could handle exceptions raised by those declarations. The First_Real_Statement f

[Ada] Fix comment about mapping of parameters and inlining static funcs

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Fix glitch in a cross-reference in comment. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Replace_Formal): Fix name of the referenced routine.diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -4699,8 +4699

[Ada] Slice length computation bug in Generic_Bounded_Length generics

2022-09-06 Thread Marc Poulhiès via Gcc-patches
In some cases involving null slices, the Slice subprograms (both the function and the procedure) in each of the three Generic_Bounded_Length generic packages (for String, Wide_String, and Wide_Wide_String) could raise Constraint_Error in cases where this is incorrect. Tested on x86_64-pc-lin

[Ada] Cleanup unnecessary shadowing in expansion of attribute Old

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Old]): Remove unnecessary local constant that was shadowing another constant with the same initial value.diff --git a/

[Ada] Enforce matching of extra formals

2022-09-06 Thread Marc Poulhiès via Gcc-patches
This patch enforces matching of extra formals in overridden subprograms, subprogram renamings, and subprograms to which attributes 'Access, 'Unchecked_Access, or 'Unrestricted_Access is applied (for these access cases the subprogram is checked against its corresponding subprogram type). Tested on

[Ada] Fix formal parameters list for secondary stack allocation procedure

2022-09-06 Thread Marc Poulhiès via Gcc-patches
The introduction of the Alignment parameter for the secondary stack allocator in previous change was missing the corresponding change in the Build_Allocate_Deallocate_Proc when creating the formal parameters list. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb

[Ada] Handle new At_End expansion during unnesting

2022-09-06 Thread Marc Poulhiès via Gcc-patches
This patch modifies the marking of nested subprograms requiring static links, so that the changes made to "At end" procedures get handled properly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_unst.adb (Visit_Node): Add N_Block_Statement to the enclosing const

[Ada] Restore missing Aggregate aspect for Ada.Containers.Ordered_Sets.Set

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Ada RM A.18.9 includes a specification of the Aggregate aspect for the type Ada.Containers.Ordered_Sets. That aspect specification was deliberately commented out in a-coorse.ads at one time, but that workaround is no longer needed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Disable lock free protected implementation if target lacks support

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Do not select a lock free implementation if Targparm.Support_Atomic_Primitives is False (which indicates that the target cannot support it). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch9.adb (Allows_Lock_Free_Implementation): Return False if Support

[Ada] Improve documentation of validation checking control switches

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Correct incorrect text and clarify unclear text that has been identified in the "Validity Checking" section of the GNAT UG. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Improve -gnatVa, -gnatVc, -gnatVd, -gn

[Ada] Enable lock free protected implementation by default

2022-09-06 Thread Marc Poulhiès via Gcc-patches
In the past, the Lock_Free aspect of a protected type (including an anonymous type) defaulted to False. In the case where an explicit "Lock_Free => True" aspect specification would be legal, the aspect now defaults to True (which means that a lock-free implementation is used to implement the type's

[Ada] Retain Has_Private_View flag for actuals of inlined subprograms

2022-09-06 Thread Marc Poulhiès via Gcc-patches
When instantiating a body to inline (either because frontend inlining is enabled with switch -gnatN or because of inlining-for-proof in GNATprove mode) we rewrite occurrences of formal parameters into the corresponding actual parameters. Then we switch type views, so that if the formal had a full v

[Ada] Fix missing name for access type in generic instantiation

2022-09-06 Thread Marc Poulhiès via Gcc-patches
Pointer types aren't named types in C so we need to take extra care in Ada to make sure that the name of access types is preserved. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils.cc (gnat_pushdecl): Preserve named TYPE_DECLs consistently for all

[Ada] Fix problematic line debug info attached to call to finalizer

2022-09-06 Thread Marc Poulhiès via Gcc-patches
The End_Label is not defined for body nodes so a small tweak is needed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.cc (At_End_Proc_to_gnu): Use the End_Label of the child Handled_Statement_Sequence for body nodes. (set_end_locus_from_

[Ada] Fix internal error on double renaming of private constant

2022-09-06 Thread Marc Poulhiès via Gcc-patches
The first renaming uses the type of the full view of the constant but not the second, which introduces problematic view conversions downstream. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.cc (Full_View_Of_Private_Constant): New function return

[Ada] Revert "Enforce matching of extra formals"

2022-09-12 Thread Marc Poulhiès via Gcc-patches
This reverts commit 51abc0cc8691daecd7cec8372e4988e9f3f1913c. Tested on x86_64-pc-linux-gnu, committed on trunk patch.diff.gz Description: application/gzip

[Ada] Parser and lexer cleanup

2022-09-12 Thread Marc Poulhiès via Gcc-patches
This patch makes various minor cleanup changes to the parser. No change in behavior. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-tchk.adb, par-util.adb, prep.adb, prepcomp.adb, scng.adb: Use "in" instead of chains of "=" connected with "or else". Like

[Ada] Disable Support_Atomic_Primitives on x86_64 VxWorks

2022-09-12 Thread Marc Poulhiès via Gcc-patches
The current configuration of the x86-64 VxWorks runtimes does not support atomic primitives. x86-64 VxWorks was missed from the previous patch. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-x86_64-kernel.ads: Set Support_Atomic_Primitives to

[Ada] Fix bugs in check-related warnings.

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Make sure warnings about wrong-length aggregates don't get suppressed. Such a warning (in a with-ed unit) can be the only explanation for an error about No_Elaboration_Code violations. Avoid passing a bogus "#" to Error_Msg. We really should never construct message templates by concatenating strin

[Ada] Disable Support_Atomic_Primitives on QNX and VxWorks targets

2022-09-12 Thread Marc Poulhiès via Gcc-patches
The current configuration of the QNX and VxWorks runtimes does not support atomic primitives. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-qnx-arm.ads: Set Support_Atomic_Primitives to false. * libgnat/system-vxworks7-aarch64.ads: Ditto.

[Ada] Fix issues with compiling ACATS test for user-defined literals

2022-09-12 Thread Marc Poulhiès via Gcc-patches
The draft ACATS test (which we developed) for the Ada 2022 feature of user-defined literals has compile-time problems that are fixed with this set of changes. Two of these involve the resolution of named numbers in the context where an implicit literal conversion can occur, and for equality when a

[Ada] Remove a no-longer-correct comment

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Remove a comment about the former use of the -gnatd9 switch (that switch is now unused). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * debug.adb: remove a comment.diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -1089,9

[Ada] Tech debt: Expansion of contracts

2022-09-12 Thread Marc Poulhiès via Gcc-patches
This patch modifies the expansion of contracts such that the statements and declarations of a subprogram with post-execution checks get moved to a local internally generated subprogram which the original subprogram calls directly followed by the required post-execution checks. This differs from th

[Ada] Lock_Free aspect takes precedence over Ceiling_Locking locking policy

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Allow the Lock_Free aspect of a protected type to be True (but only by explicit specification) if Ceiling_Locking locking policy has been specified. Clarify that the Lock_Free aspect takes precedence over the Ceiling_Locking policy in that case. Tested on x86_64-pc-linux-gnu, committed on trunk g

[Ada] Syntax error in Ada 2022 array aggregate causes bug box

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Check for the case where a user writes "in" instead of "of" in an aggregate like "[for E in Some_Array when Some_Filter (E) => E]". Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Array_Aggregate): Generate an appropriate error message i

[Ada] Do not mark user parameters of protected subprograms as artificial

2022-09-12 Thread Marc Poulhiès via Gcc-patches
This occurs because protected subprograms are not translated directly into object code but first rewritten as a pair of subprograms by the front-end. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch9.adb (Build_Protected_Spec): Tidy up and propagate the Comes_F

[Ada] Justify false alarm from CodePeer analysis of GNAT

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Branch is determined as dead following a test always False by CodePeer analysis, which is incorrect. Justify this false alarm with an appropriate pragma Annotate. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-imagei.adb (Image_Integer): Add justification.diff --g

[Ada] bugbox referencing INOX prefixed view of primitive op of modular type

2022-09-12 Thread Marc Poulhiès via Gcc-patches
The -gnatX switch enables naming a prefixed view of a subprogram with an untagged prefix. Compiling such a reference where the prefix is of a modular type could result in an internal compiler error. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Analyze

[Ada] Internal error compiling formal instance of generic with Initial_Condition

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Prevent the compiler from failing with an internal error in some cases involving an instance of a generic which takes as a formal parameter an instance of a second generic, where the second generic has an Initial_Condition aspect specification. Tested on x86_64-pc-linux-gnu, committed on trunk gc

[Ada] Reject use in SPARK of Asm intrinsics for code insertions

2022-09-12 Thread Marc Poulhiès via Gcc-patches
SPARK does not allow code insertions. This applies also to calls to Asm intrinsics defined in System.Machine_Code. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-maccod.ads: Mark package as SPARK_Mode Off.diff --git a/gcc/ada/libgnat/s-maccod.ads b/gcc/ada/libgnat

[Ada] Sync documentation of junk names with code

2022-09-12 Thread Marc Poulhiès via Gcc-patches
The list of junk entity names for which warnings are suppressed has been recently modified, so update the documentation accordingly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst (Pragma Unreferenced): Sync description

[Ada] Fix oversight in implementation of unnesting

2022-09-12 Thread Marc Poulhiès via Gcc-patches
The pass would traverse generic subprogram bodies, which are not expanded, thus stumbling on unexpected nodes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_unst.adb (Unnest_Subprograms.Search_Subprograms): Skip the subprogram bodies that are not to be unnested

[Ada] Remove SPARK containers from GNAT documentation

2022-09-12 Thread Marc Poulhiès via Gcc-patches
This patch removes documentation on the SPARK containers, now under the spark2014 repository. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/the_gnat_library.rst: Remove paragraphs about SPARK containers. * gnat_rm.texi, gnat_ugn.texi: Regenerate

[Ada] Cleanup routine for handling SPARK_Mode kinds

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Get_SPARK_Mode_Type): Fix header box; replace chained IF with a CASE statement.diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb --- a/gcc/ada/sem_prag.adb +++

[Ada] Improve CUDA host-side and device-side binder support

2022-09-12 Thread Marc Poulhiès via Gcc-patches
On the host-side, the binder now generates CUDA_Execute pragmas to invoke initialization and finalization on the device-side. The front end's expansion of these pragmas includes references to entities declared in package CUDA.Internal. Generate a with-clause so that unit will be available. Tested

[Ada] Fix validity checking on renamed Old attribute prefix

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Prefix of attribute Old is captured either as an object renaming or as an object declaration. This is now taken into account when applying validity checks. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Old]): Ad

[Ada] Temporary tweak new expansion of contracts

2022-09-12 Thread Marc Poulhiès via Gcc-patches
In the case of a function, the new expansion of contracts makes use of an extended return statement to store the result of the function in the return object while the post-conditions are evaluated. Unfortunately GNAT does not elide the copy of the return object for extended return statements for t

[Ada] Improve CUDA host-side and device-side binder support

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Use switches (one already existing, one newly added here) to indicate to the binder that CUDA support code is to be generated for either the host side or for the device side. Add an invocation of Adainit on the device side from Adainit on the host side; similarly for Adafinal. Tested on x86_64-pc-

[Ada] Storage_Error raised analyzing type with call in its range constraint

2022-09-12 Thread Marc Poulhiès via Gcc-patches
This patch corrects a problem in the compiler whereby the determination of scope levels during the generation of accessibility checks for function calls within range constraints leads to a compiler crash due to the type not being fully analyzed at the point in which its scope depth must be obtained

[Ada] Fix immediate assertion failure with -gnatd.1

2022-09-12 Thread Marc Poulhiès via Gcc-patches
The switch enables the front-end unnesting pass. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Relax assertion when front-end unnesting is enabled.diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc

[Ada] Reject 'Valid_Scalars on Unchecked_Union regardless of privacy

2022-09-12 Thread Marc Poulhiès via Gcc-patches
Attribute Valid_Scalars applied to prefix with an unchecked union component causes a legitimate crash in the backend. It was already rejected in the frontend for prefixes of a public type; now it is rejected in the frontend regardless of the type privacy. Tested on x86_64-pc-linux-gnu, committed o

[Ada] Accept explicit SPARK_Mode Auto as configuration pragma

2022-09-12 Thread Marc Poulhiès via Gcc-patches
An explicit value of Auto is now accepted for a configuration pragma SPARK_Mode, as a way to exempt a unit from complete adherence to SPARK rules when using a global configuration pragma file where SPARK_Mode=>On is specified. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ *

[Ada] Special-case printing of SPARK_Mode in error messages

2022-09-12 Thread Marc Poulhiès via Gcc-patches
For error messages with inserted names that include acronyms like SPARK or CPP, we want to preserve the casing. The list of special-cased named is currently the same as in gnatpp. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * erroutc.adb (Set_Msg_Insertion_Name): Special-c

[COMMITTED] rust: fix link serialization [PR108113]

2022-12-20 Thread Marc Poulhiès via Gcc-patches
The Make-lang.in was missing the link serialization support. PR rust/108113 gcc/rust * Make-lang.in (rust.serial): New variable. (rust1$(exeext)): Depend on $(rust.prev). Call LINK_PROGRESS. Signed-off-by: Marc Poulhiès --- Already reviewed and ACKed by Jakub: https://gi

[COMMITTED] ada: Fix support of Default_Component_Value aspect on derived types

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The support of the Default_Component_Value aspect on derived constrained array types is broken because of a couple of issues: 1) the derived types incorrectly inherit the initialization procedure of the ancestor types and 2) the propagation of the aspect does not work for cons

[COMMITTED] ada: Cannot reference ghost entity in class-wide precondition

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Javier Miranda gcc/ada/ * ghost.adb (Is_OK_Declaration): A reference to a Ghost entity may appear within the class-wide precondition of a helper subprogram. This context is treated as suitable because it was already verified when we were analyzing the origin

[COMMITTED] ada: Fix detection of function calls in object declarations

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The current code has relied on Original_Node to detect rewritten function calls in object declarations but that's not robust enough in the presence of function calls written in object notation. gcc/ada/ * exp_util.ads (Is_Captured_Function_Call): Declare. * e

[COMMITTED] ada: Adapt frontend optimization for aggregate assignment

2023-01-03 Thread Marc Poulhiès via Gcc-patches
The frontend currently relies on gigi to use efficient assignment in particular cases like: Some_Var.all := (others => (others => 0)); gigi would use memset to clear memory pointed to by Some_Var. In the case of an access with a Designated_Storage_Model aspect with a Copy_To procedure, memset

[COMMITTED] ada: Simplify [Small_]Integer_Type_For

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Bob Duff Make Small_Integer_Type_For call Integer_Type_For, so they share most of the code. Remove Standard_Long_Integer from consideration, because that's different on different machines (32- or 64-bit). Standard_Integer or Standard_Long_Long_Integer will be chosen. gcc/ada/ * e

[COMMITTED] ada: Fix parsing bug in GNAT.Formatted_String

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Ronan Desplanques Before this patch, GNAT.Formatted_String.Formatted_String failed to handle format strings with two or more specifiers whose widths were specified with the "*" syntax. This patch makes the parser correctly reset its bits of state related to width and precision parsing when

[COMMITTED] ada: Make Apply_Discriminant_Check.Denotes_Explicit_Dereference more robust

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The predicate implements the rules of the language so it needs to cope with constructs rewritten by the expander, in particular explicit dereferences that the expander uses liberally for various purposes. This change makes the detection of rewritten calls more robust and adds

[COMMITTED] ada: Fix calling convention of foreign functions returning limited type

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou Such functions use neither Ada 2005's build-in-place mechanism nor Ada 95's return-by-reference mechanism, but instead the common calling convention of functions returning a nonlimited by-reference type. gcc/ada/ * exp_ch6.adb (Is_Build_In_Place_Function): Adjust com

[COMMITTED] ada: GNAT UGN: Adjust wording in "Platform-specific Information" chapter

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Joel Brobecker The wording of the introduction paragraph specified an incomplete list of OSes. Rather than trying to update the list, this commit changes the text to make it more general. For those parts of this chapter which only apply to specific OSes, the documentation is written in a wa

[COMMITTED] ada: Fix unescaped quotes when combining fdiagnostics-format=json and gnatdJ

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Ghjuvan Lacambre This commit fixes a small bug where GNAT would emit unescaped quotes in its -fdiagnostics-format=json output when using -gnatdJ and emitting messages about operator functions (e.g. "="). gcc/ada/ * errout.adb (Write_JSON_Span): Escape subprogram name. Tested on x

[COMMITTED] ada: Fix premature finalization of return temporary

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou Various parts of the expander and the code generator must have a consistent view on which temporaries generated for return statements must be finalized because they are regular temporaries, and which ones must not be since they are allocated on the return stack directly. The

[COMMITTED] ada: Make Sem_Util.Is_Aliased_View predicate more robust

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The predicate implements the rules of the language so it needs to cope with constructs rewritten by the expander, in particular explicit dereferences that the expander uses liberally for various purposes. This change makes the detection of rewritten calls more robust, pluggin

[COMMITTED] ada: Fix GNAT.Formatted_String's handling of real values

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Ronan Desplanques Before this patch, passing a width and a precision through arguments with the "*" syntax always failed for real values in GNAT.Formatted_String's routines. gcc/ada/ * libgnat/g-forstr.adb (P_Flt_Format): Add "*" syntax handling. Tested on x86_64-pc-linux-gnu, co

[COMMITTED] ada: Another small adjustment to special resolution of membership test

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou This goes back to the original implementation but keeps the special size test with universal_integer to cope with its limited range. gcc/ada/ * sem_res.adb (Resolve_Membership_Op): Adjust again latest change. Tested on x86_64-pc-linux-gnu, committed on master. ---

[COMMITTED] ada: Fix format string parsing in GNAT.Formatted_String

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Ronan Desplanques Before this patch, format strings ending with "%%" (two consecutive percent signs) caused GNAT.Formatted_String."-" to give the wrong output, and cause the various GNAT.Formatted_String."&" to raise exceptions with misleading error messages. Also before this patch, a bug

[COMMITTED] ada: output.adb: fix newline being inserted when buffer is full

2023-01-03 Thread Marc Poulhiès via Gcc-patches
From: Ghjuvan Lacambre Before this commit, when GNAT needed to emit lines longer than the buffer, it accidentally inserted a newline in its output when attempting to flush its buffer. We fix this by using Flush_Buffer instead of Write_Eol in Write_Char. gcc/ada/ * output.adb (Write_Buf

[COMMITTED] ada: Fix incorrect warning about unreferenced packed arrays

2023-01-05 Thread Marc Poulhiès via Gcc-patches
From: Bob Duff This patch fixes a bug in which a reference to a renaming of a component of a packed array was not counted as a reference, and thus caused incorrect warnings about unreferenced objects. gcc/ada/ * sem_ch5.adb (Analyze_Assignment): Fix the bug by checking Original_

[COMMITTED] ada: Fix finalization issues in extended return statements

2023-01-05 Thread Marc Poulhiès via Gcc-patches
From: Eric Botcazou The first issue pertains to return objects of (class-wide) interface types, which need to be adjusted if the type is not inherently limited. The second issue is for return objects of non-class-wide types that are initialized by a function call, which can use a direct renaming

[COMMITTED] ada: Spurious error on Lock_Free protected type with discriminants

2023-01-05 Thread Marc Poulhiès via Gcc-patches
From: Justin Squirek This patch corrects an issue in the compiler whereby unprefixed discriminants appearing in protected subprograms were unable to be properly resolved - leading to spurious resolution errors. gcc/ada/ * sem_ch8.adb (Set_Entity_Or_Discriminal): Verify we are actually

[COMMITTED] ada: Adjust handling of "%g" in GNAT.Formatted_String

2023-01-05 Thread Marc Poulhiès via Gcc-patches
From: Ronan Desplanques The way the "%g" specifier was handled by GNAT.Formatted_String before this patch was very different from the behavior of C's printf. This patch makes the handling of "%g" in GNAT.Formatted_String closer to the behavior described in the specification of the C language. gc

[COMMITTED] ada: Update doc for -gnatw_q

2023-01-05 Thread Marc Poulhiès via Gcc-patches
From: Bob Duff The -gnatw_q switch turns on warnings for noncomposing "=" operators. This patch updates the doc to refer to relevant RM paragraphs. gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add RM references. * gnat_ugn.texi: Regenerate. Tested

<    1   2   3   4   5   6   7   8   9   >