[Ada] Plug loophole for built-in-place return with limited_with clause

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
When the result type of a function requiring built-in-place return is only visible through a limited_with clause, the compiled needs to wait for the nonlimited view to be available in order to compute whether the built-in-place return is needed, and this comprises tagging the function with the Retu

[Ada] Incorrect accessibility check on return of discriminated type

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby the presence of a call to a function returning a type with an access discriminant within an expanded loop condition caused the wrong value to be supplied for the extra- accessibility-of-result actual, thus causing incorrect checks within the call

[Ada] Adjust description of Pure_Function pragma

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
The current wording can be read as implying that the result of a call to a pure function does not depend on the context, which is incorrect. The pragma only guarantees the absence of side effects of such a call. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/imp

[Ada] Fix for resolution of overloaded subprogram for Iterable aspect

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
When resolving the Iterable aspect we look for a functions that are declared in the same scope as the annotated type and that have the required number and types formal parameters. However, we didn't guard against functions that have no formal parameter at all. Tested on x86_64-pc-linux-gnu, commit

[Ada] Update the documentation of functional containers

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
Functional containers are now controlled. Update the documentation accordingly. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/the_gnat_library.rst: Functional vectors, sets, and maps are now controlled. * gnat_rm.texi: Regenerate.diff --git a/gc

[Ada] Create new unbounded functional sequence

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
Add a new unbounded functional sequence. This sequence is indexed by Big_Positive and so is unbounded from the user and spark points view. Hower the actually implemented sequence are bounded by Count_Type'Last. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cfinse

[Ada] Tech debt: Remove code duplication

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects removes some code duplication within the GNAT compiler. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Remove_Side_Effects): Combine identical branches. * sem_attr.adb (Analyze_Attribute): Combine identical cases Att

[Ada] Compiler rejects legal allocator in record component constraint expression

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
In some cases when a legal allocator which defines a new subtype for the allocated object occurs as part of a record component constraint expression, the compiler would incorrectly reject the allocator. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Analyze_All

[Ada] Add Ada 2022 features to sets containers

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds some Ada 2022 features to the set children of Ada.Containers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cbhase.adb, libgnat/a-cbhase.ads, libgnat/a-cborse.adb, libgnat/a-cborse.ads, libgnat/a-cihase.adb, libgnat/a-cihase.ads,

[Ada] Assertions in Einfo.Utils

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
Add predicates on subtypes E and N. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo-utils.ads, einfo-utils.adb: Add predicates on subtypes E and N. Change some parameters to use the unpredicated subtypes, because they sometimes return e.g. Empty. Note

[Ada] Add GNAT specific pragmas to the equivalent Assertion_Policy for -gnata

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
All assertion pragmas are enabled by default when using -gnata. We need to add the GNAT specific ones to the list. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Debugging and Assertion Control): Add GNAT spec

[Ada] Single character argument in call to Quote_Argument raises error

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue in the compiler whereby calling Quote_Argument with an argument that is of size 1 may lead to a CONSTRAINT_ERROR raised at runtime due to an undersized buffer. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-os_lib.adb (Quote_Argument):

[Ada] Do not use front-end build-in-place mechanism for nonlimited types

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
It was only used in specific cases for controlled types but no longer provides any significant benefit in practice. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * debug.adb (d.9): Remove usage. * exp_ch6.adb (Expand_Simple_Function_Return): Remove redundant

[Ada] Give missing error on ambiguous operand of equality operator

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
When the code responsible for giving errors on ambiguous operands of comparison and equality operators was moved from the 1st phase (analysis) to the 2nd phase (resolution) of semantic processing, it was incorrectly restricted to the operator case, which was valid during the 1st phase but is not du

[Ada] Refactor duplicated resolution of Count and Index attributes

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
Attribute Index, which was added to Ada 2022 by AI12-0143, is resolved just like attribute Count. However, code duplication rightly triggered a CodePeer warning. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Resolve_Attribute): Refactor duplicated code for

[Ada] Use static stack allocation for small dynamic string concatenations

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
This changes the expanded code generated for dynamic concatenations to use a static array subtype for the temporary created on the stack if a small upper bound can be computed for the length of the result. Static stack allocation is preferred over dynamic allocation for code generation purposes.

[Ada] Add a RM entry for the functional infinite sequences

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
Modify the RM to take into account the new functional container. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/the_gnat_library.rst: Add the new entry. * gnat_rm.texi: Regenerate. patch.diff.gz Description: application/gzip

[Ada] Fix dispatching call to primitive function with controlling tagged result

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
When a dispatching call is made to a primitive function with a controlling tagged result, the call is dispatching on result and thus must return the class-wide type of the tagged type to accommodate all possible results. This was ensured by Expand_Dispatching_Call only in the common case where the

[Ada] Small housekeeping work in Expand_N_Object_Declaration

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
The local function Rewrite_As_Renaming can be called twice in certain circumstances, which is both not quite safe and unnecessary, so this replaces it with a local variable whose value is computed only once. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Avoid unwanted warnings for statically-known-successful assertions

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
The -gnatwc switch enables warnings for test condition outcomes that are known at compile time. Such warnings are unlikely to be useful in the case of an assertion expression (or a subexpression thereof), so do not generate them in that case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/

[Ada] vx7r2: do not include s-qnx.ads in the kernel and rtp runtimes

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
Target specific runtime files must be added to a the exclude list so the files don't automatically get copied to other runtimes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (ADA_EXCLUDE_SRCS): Add s-qnx.ads.diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefil

[Ada] Add Ada 2022 Key function to sets containers

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
This patch adds the new Generic_Keys.Key function to the set children of Ada.Containers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cbhase.ads, libgnat/a-cborse.ads, libgnat/a-cihase.ads, libgnat/a-ciorse.ads, libgnat/a-cohase.ads, libgnat/a-co

[Ada] Do not make procedure call with only tag-indeternminate actuals dispatching

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
The RM 3.9.2(19) clause says that the controlling tag value is statically determined to be the tag of the tagged type involved. As a matter of fact, the call would be made dispatching only as a by-product of the propagation of the controlling tag value to the tag-indeternminate actuals, but that's

[Ada] Call-initialize all controlled objects in place

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
This changes the compiler to build in place almost all objects that need finalization and are initialized with the result of a function call, thus saving a pair of Adjust/Finalize calls for the anonymous return object. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.

[Ada] Fix missing error on 'Access of constrained array

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
For X'Access, the designated subtype of the access type must statically match the nominal subtype of X. This patch fixes a bug where the error was not detected when there is an unrelated declaration of the form "Y : T := X;", where T is an unconstrained array subtype. Tested on x86_64-pc-linux-gn

[Ada] Enforce deferred constant completion rules

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
If a constrained subtype is given when a deferred constant is declared, then the subtype given in the completion is required (at compile time) to be subject to a statically matching constraint. This rule was not properly enforced in some cases and constructs that should have been rejected were inco

[Ada] Use static stack allocation for small string if-expressions

2022-07-04 Thread Pierre-Marie de Rodat via Gcc-patches
This changes the expanded code generated for if-expressions of 1-dimensional arrays to create a static temporary on the stack if a small upper bound can be computed for the length of a subtype covering the result. Static stack allocation is preferred over dynamic allocation for code generation pur

[Ada] Remove old vxworks6 from Makefile.rtl

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Pre vxworks7 code excepting legacy vxworks6 code is removed from Makefile.rtl and unused files are deleted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (*vxworks*): Remove most pre-vxworks7 code. * vxworks-arm-link.spec: Remove. * vxworks-e50

[Ada] Remove unimplemented convert_addresses declaration

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
convert_addresses is declared in adaint.h but is never referenced, so remove it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * adaint.h (convert_addresses): Remove function declaration.diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h --- a/gcc/ada/adaint.h +++ b/gcc/ada/ad

[Ada] Fix clearly unintentional dead analysis of attribute Code_Address

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
A new warning about unreachable code that follows calls to procedures with No_Return would flag a clearly unintentional dead call to Set_Address_Taken in analysis of Code_Address attribute. This patch resurrects the dead code, which is worth fixing regardless of the new warning. Tested on x86_64-

[Ada] Remove redundant guards in detection of unreachable code

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Routine Check_Unreachable_Code is only called on nodes belonging to a list of statements (and it wouldn't make sense to call it on anything else). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb (Check_Unreachable_Code): Remove redundant guard; the call t

[Ada] Remove comment about a long gone formal verification mode

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Remove outdated a comment about the very first SPARK experiments in GNAT. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Check_Missing_Return): Remove outdated comment.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ad

[Ada] Add RM reference to check for functions without a return statement

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Add comment to explain why we have an error and not just a warning. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Check_Missing_Return): Add reference to an RM rule.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/

[Ada] Combine system.ads files - vxworks6 constants.

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

[Ada] Perform object rewriting as renaming only in the expander

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
The rewriting as renaming optimization for object declarations is done partly during analysis, guarded with Expander_Active, and partly during expansion, so it makes sense to do it entirely during expansion. This merges the two cases and removes obsolete or unnecessary conditions guarding the tran

[Ada] Remove redundant guard for call to List_Length with a No_List

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to a new detection of uninitialised local scalar objects; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb (Analyze_Block_Statement): Call to List_Length with No_List is safe and will return zero.diff --git a/g

[Ada] Cleanup in error about unreachable code

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup only; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb (Check_Unreachable_Code): Avoid explicit use of Sloc; this should also help when we finally use Source_Span for prettier error messages.diff --git a/gcc/ada/sem

[Ada] Spurious error on qualified prefix in Pack.Func'Result

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
When using a qualified name such as Pack.Func as the prefix of a 'Result attribute reference, the prefix is not fully resolved and may contain a chain of homonyms. Look for the expected function in the homonym chain instead of issuing an error if the first one is not the expected one. Tested on x8

[Ada] Cleanup repeated code for aggregate constraints checks

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to examining uses of Check_Unset_Reference for improved detection of uninitialised scalar objects. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Aggregate_Constraint_Checks): Fix whitespace; refactor repea

[Ada] Remove exception propagation during bootstrap

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
To help the bootstrap path, we want to keep the compiler free from any exception propagation during bootstrap. This has been broken recently in various places. Also introduce a way to more easily detect such breakage via the -DNO_EXCEPTION_PROPAGATION which can now be used as part of BOOT_CFLAGS.

[Ada] Remove unnecessary dead code after calls to nonreturning procedures

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
A new warning about unreachable code that follows calls to procedures with No_Return would flag some dead defensive code. Comments next to this code suggest that it was added to please some ancient version of the compiler, but recent releases of GNAT do not require such a code. Tested on x86_64-pc

[Ada] Remove repeated analysis for pragma Thread_Local_Storage

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
When analysing pragma Thread_Local_Storage its argument is analysed by the call to Check_Arg_Is_Library_Level_Local_Name. There is no need to reanalyse it. Code cleanup; behaviour is not affected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_Pragma):

[Ada] Annotate GNAT.Sockets with No_Return aspects

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Opportunity for extra annotations spotted while fixing detection of unreachable code that follows calls to procedures annotated with No_Return. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-socket.adb (Raise_Host_Error): Add No_Return aspect. (Raise_GAI_E

[Ada] Remove return statements after procedure calls that don't return

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
A new warning about unreachable code that follows calls to procedures with No_Return would flag many unnecessary return statements. Those returns statements were applied inconsistently, so this patch is actually more a style cleanup. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Misc cleanup related to finalization

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
This patch cleans up some code issues found while working on finalization, and adds some debugging aids. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb: Change two constants Is_Protected_Body and Is_Prot_Body to be Is_Protected_Subp_Body; these are not t

[Ada] Remove redundant protection against empty lists

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Calls to First on No_List intentionally return Empty node, so explicit guards against No_List are unnecessary. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_code.adb (Setup_Asm_IO_Args): Remove guard against No_List. * par

[Ada] Fix dangling bounds for array result of BIP functions

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
The implementation of the build-in-place return protocol for functions whose result type is an unconstrained array type generates dangling references to local bounds built on the stack for the result as soon as these bounds are not static. The reason is that the implementation treats the return ob

[Ada] qnx-7.1: ACATS cxag001 failure on qnx - realpath

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
The implementation of __gnat_full_name uses the CRTL realpath, however this function returns a null string so use the default implementation instead. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * cstreams.c (__gnat_full_name) [QNX]: Remove block.diff --git a/gcc/ada/cstrea

[Ada] Fix comments mentioning ancient flags related to objects references

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Flag May_Be_Modified under go a series of renamings between 1996 and 2002. It was changed to Not_Assigned, then to Not_Source_Assigned and finally to Never_Set_In_Source. Fix remaining references in comments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads (Not

[Ada] Reorder processing of default expressions to avoid repeated calls

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to improved detection of uninitialised objects; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Process_Formals): Avoid repeated calls to Expression.diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb ---

[Ada] Fix spurious error on object renaming with ghost type

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Renaming of an object of ghost type leads to a spurious error. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ghost.adb (Is_OK_Ghost_Context): Detect ghost type inside object renaming.diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb --- a/gcc/ada/ghost

[Ada] Reuse Get_Pragma_Arg to handle pragma argument associations

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to looking at pragma Thread_Local_Storage. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_Init_Statements): Reuse Get_Pragma_Arg. * exp_prag.adb (Arg_N): Likewise.diff --git a/gcc/ada/exp_ch3.adb b/gcc

[Ada] Remove use of a global name buffer when locating a file

2022-07-05 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): Use Name_Find with a parameter and not with a global buffer.diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.

[Ada] Remove repeated setting of Never_Set_In_Source

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Formal parameters have their flag Never_Set_In_Source set at the beginning of Process_Formals routine (regardless of the parameter mode). There is no need to set it again when Process_Formals calls Set_Formal_Mode (for parameters of mode IN OUT and OUT). Code cleanup related to improved detection

[Ada] Remove kludge for validity checks on Long_Float type

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
This patch reverts a fix for a spurious warning for validity checks on type Long_Float. This fix was dubious (as it was only affecting Long_Float and not Float) and apparently is no longer needed. Cleanup related to improved detection of uninitialised scalar objects. Tested on x86_64-pc-linux-gnu

[Ada] Couple of small cleanups for Cloned_Subtype

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Make_Subtype_From_Expr): Do not set field to Empty. * sem_util.adb (Visit_Itype): Remove ??? comment.diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb --- a/gcc/ada/exp_util.a

[Ada] Warn about obsolete uses of renamed Ada 83 packages

2022-07-05 Thread Pierre-Marie de Rodat via Gcc-patches
Ada 83 packages like Unchecked_Conversion or Text_IO are obsolete since Ada 95. GNAT now warns about their uses when warnings on obsolescent featured (Annex J) is active. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst

[Ada] Incorrect emptying of CUDA global subprograms

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby no Corresponding_Spec was set for emptied CUDA global subprograms - leading to a malformed tree. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnat_cuda.adb (Empty_CUDA_Global_Subprogram): Set Specification and C

[Ada] Remove explicit call to Make_Unchecked_Type_Conversion

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
Respect a comment in sinfo.ads, which says: "Unchecked type conversion nodes should be created by calling Tbuild.Unchecked_Convert_To, rather than by directly calling Nmake.Make_Unchecked_Type_Conversion." No test appears to be affected by this change, so this is just a cleanup. Tested on x86_64-

[Ada] Fix incorrect itype sharing for case expression in limited type return

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler aborts with an internal error in gigi, but the problem is an itype incorrectly shared between several branches of an if_statement that has been created for a Build-In-Place return. Three branches of this if_statement contain an allocator statement and the latter two have been obtained

[Ada] Restore accidentally removed part of a comment about unset references

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
Fix an unintentionally removed comment. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Actuals): Restore first sentence of a comment.diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -4

[Ada] Vxworks7* - Makefile.rtl rtp vs rtp-smp cleanup

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
Only smp runtimes are built for vxworks7*, even though the -smp suffix is removed during install. Therefore, in general, the build macros for the non-smp runtimes are superfluous except on the legacy ppc-vxworks6 target where both the smp and non-smp runtime are built. Lastly, an error message is

[Ada] Cleanup use of local scalars in GNAT.Socket.Get_Address_Info

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
A cleanup opportunity spotted while working on improved detection of uninitialised local scalar objects. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-socket.adb (Get_Address_Info): Reduce scope of the Found variable; avoid repeated assignment inside the

[Ada] Remove old vxworks from Makefile.rtl - e500 port.

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
The powerpc e500 port has been LTS'd Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-e500-kernel.ads: Remove. * libgnat/system-vxworks7-e500-rtp-smp.ads: Likewise. * libgnat/system-vxworks7-e500-rtp.ads: Likewise.diff --git a/gcc/ada/l

[Ada] Fix spurious error for aggregate with box component choice

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
It comes from the Volatile_Full_Access (or Atomic) aspect: the aggregate is effectively analyzed/resolved twice and this does not work. It is fixed by calling Is_Full_Access_Aggregate before resolution. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Expand_Re

[Ada] Missing error on tagged type conversion

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler does not report an error on a type conversion to/from a tagged type whose parent type is an interface type and there is no relationship between the source and target types. This bug has been dormant since January/2016. This patch also improves the text of errors reported on interface

[Ada] Handle secondary stack memory allocations alignment

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
To accomodate cases where objects allocated on the secondary stack needed a more constrained alignement than Standard'Maximum_Alignement, the alignment for all allocations in the full runtime were forced on to be aligned on Standard'Maximum_Alignement*2. This changes removes this workaround and cor

[Ada] Improve code generated for aggregates of VFA type

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
This avoids using a full access for constants internally generated from assignments of aggregates with a Volatile_Full_Access type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/gigi.h (simple_constant_p): Declare. * gcc-interface/decl.cc (gnat_to_gnu

[Ada] Small tweak to gnat_to_gnu_subprog_type

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Constify a local variable and move a couple of others around.diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc --- a/gcc/

[Ada] Spurious non-callable warning on prefixed call in class condition

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby a function call in prefix notation within a class condition causes a spurious error claiming the name in the call is a non-callable entity when there exists a type extension in the same unit extended with a component featuring the same name as th

[Ada] Indexing error when calling GNAT.Regpat.Match

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby a buffer sizing error fails to get raised when compiling a regex expression with an insufficiently sized Pattern_Matcher as the documentation indicated. This, in turn, could lead to indexing errors when attempting to call Match with the malformed

[Ada] Deferred constant considered as not preelaborable

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
Fix detection of non-preelaborable constructs for checking SPARK elaboration rules, which was tagging deferred constant declarations as not preelaborable. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Is_Non_Preelaborable_Construct): Fix for deferred

[Ada] Simplify regular expression that matches 8 consecutive digits

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
Makefile cleanup; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/Make-lang.in (ada/generated/gnatvsn.ads): Simplify regular expression. The "interval expression", i.e. \{8\} is part of the POSIX regular expressions, so

[Ada] Support ghost generic formal parameters

2022-07-06 Thread Pierre-Marie de Rodat via Gcc-patches
This adds support in GNAT for ghost generic formal parameters, as included in SPARK RM 6.9. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ghost.adb (Check_Ghost_Context): Delay checking for generic associations. (Check_Ghost_Context_In_Generic_Association):

[Ada] Remove excessive guard in detection of access-to-variable objects

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
It is safe to call Is_Access_Variable without calling Is_Access_Object_Type before. Compiler cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Is_Variable): Remove excessive guard.diff --git a/gcc/ada/sem_util.adb b/gcc/ada/

[Ada] Warn about unreachable code after calls with No_Return

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
GNAT was already warning about unreachable code after raise/goto/exit statements, but not after calls to procedures with No_Return. Now this warning is extended. Also, previously the warning was suppressed for unreachable RETURN after RAISE statements. Now this suppression is narrowed to functions

[Ada] Clean up scanner

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch removes some obsolete code in the scanner and related files, and corrects some comments. Tok_Special is used only by the preprocessor, and uses only the two characters '#' and '$'. It might be simpler to have a single flag indicating we're scanning for preprocessing, instead of the Spec

[Ada] Add new unbounded and indefinite formal doubly linked list

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
Before this patch, the only formal doubly linked lists were bounded and definite. This means that it is necessary to provide their maximum length or capacity at instantiation and that they can only be used with definite element types. The formal lists added by this patch are unbounded and indefini

[Ada] Add one more leading underscore to couple of exported symbols

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
For the sake of consistency with other runtime units. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-stchop.ads: Use a double underscore prefix for symbols.diff --git a/gcc/ada/libgnat/s-stchop.ads b/gcc/ada/libgnat/s-stchop.ads --- a/gcc/ada/libgnat/s-stchop.ads

[Ada] Ignore exceptions in task termination handlers

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes a bug in which if the environment task has a specific termination handler, and that handler raises an exception, the handler is called recursively, causing infinite recursion. The RM requires such exceptions to be ignored. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada

[Ada] Fix missing Overflow and Range checks

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
While doing Preanalysis (as is the case during ghost code handling), some range and/or overflow checks can be saved (see Saved_Checks in checks.adb) and later one omitted as they would be redundant (see Find_Check in checks.adb). In the case of ghost code, the node being Preanalyzed is a temporary

[Ada] Proper freezing for dispatching expression functions.

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
In the case of an expression function that is a primitive function of a tagged type, freezing the tagged type needs to freeze the function (and its return expression). A bug in this area could result in incorrect behavior both at compile time and at run time. At compile time, freezing rule violatio

[Ada] Fix spurious warning on unreferenced internal generic instance

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch removes a spurious warning, saying that an internal entity of a generic formal package is unreferenced. The immediate cause of this warning is that the internal entity is explicitly flagged as coming from source. The explicit flagging was added decades ago to fix a missing cross-referen

[Ada] Remove out-of-range warning in unreachable code

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch removes a warning in examples like this: if cond then return; -- or other jump end if; X := ...; -- where the value is out of range where cond is known at compile time. It could, for example, be a generic formal parameter that is known to be True in some instances.

[Ada] Avoid namespace pollution for Next and Previous

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch renames Next and Previous in a-convec.ads and other containers to be _Next and _Previous, to avoid namespace pollution. The compiler now uses the leading-underscore names to look them up. The scanner is changed to allow this. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Fix buffer overrun for small string concatenation at -O0

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
The concatenation routines may read too much data on the source side when the destination buffer is larger than the final result. This change makes sure that this does not happen any more and also removes obsolete stuff. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * rtsfi

[Ada] Ignore switches for controlling frontend warnings in GNATprove mode

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
In the special mode for GNATprove, ignore switches controlling frontend warnings, like already done for the control of style checks warnings. Also remove special handling of warning mode in Errout to make up for the previous division of control between -gnatw (GNAT) and --warnings (GNATprove). Tes

[Ada] Refine heuristics for unreachable-code warnings

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch refines the heuristics for when we warn about unreachable code, to avoid common false alarms. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb (Check_Unreachable_Code): Refine heuristics. * sem_util.ads, sem_util.adb (Is_Static_Constant_Name): R

[Ada] Vxworks7* - Makefile.rtl rtp vs rtp-smp cleanup - remove unused files

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
Only smp runtimes are built for vxworks7*, even though the -smp suffix is removed during install. This change removes unused system packages for rtp runtimes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/system-vxworks7-ppc-rtp.ads: Remove * libgnat/system

[Ada] Accept aspect Yield on subprogram bodies acting as specs

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
A small fix for the aspect Yield defined in AI12-0279 for Ada 2022, to accept aspect given for a subprogram body which acts as its own spec. For example: procedure Switch with Yield => True is begin ... end Switch; Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Make it clear that gnatmake passes the ball to gprbuild if -P is set

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
Also move -P switch description to the top of the switches list. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * makeusg.adb, doc/gnat_ugn/building_executable_programs_with_gnat.rst: Move -P to the top of switches list and make it clear that gnatmake

[Ada] Warn on unset objects in packages with no bodies

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
Fix an inconsistency, where GNAT was warning about references to unset objects inside generic packages with no bodies but not inside ordinary packages with no bodies. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch7.adb (Analyze_Package_Declaration): Check references

[Ada] Suppress warning in g-socthi__vxworks.adb

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
Follow-on to previous change, which missed the vxworks version of this package. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-socthi__vxworks.adb (C_Connect): Suppress new warning.diff --git a/gcc/ada/libgnat/g-socthi__vxworks.adb b/gcc/ada/libgnat/g-socthi__vxwo

[Ada] Simplify rewriting of attributes into Boolean literals

2022-07-12 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/ * sem_attr.adb (Set_Boolean_Result): Simplify using Boolean_Literals.diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@

[Ada] Fix confusing error expression on an unknown restriction

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
When pragma Restriction is used with an unknown restriction identifier, it is better to not process the restriction expression, as it will likely produce confusing error message. In particular, an odd message appeared when there was a typo in the restriction identifier whose expression requires sp

[Ada] Annotate libraries with returning annotation

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch annotates SPARK-annotated libraries with returning annotations (Always_Return, Might_Not_Return) to remove the warnings raised by GNATprove about missing annotations. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/a-reatim.ads, libgnat/a-cfdlli.ads,

[Ada] Ada 2020: Allow declarative items mixed with statements

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch implements a syntactic language extension that allows declarative items to appear in a sequence of statements. For example: for X in S'Range loop Item : Character renames S (X); Item := Transform (Item); end loop; Previously, declare/begin/end was required, whi

[Ada] Don't check for misspelling of Not_A_Restriction_Id

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
When looking for a misspelling of a restriction identifier we should ignore the Not_A_Restriction_Id literal, because it doesn't represent any restriction. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings): Fi

[Ada] Fix inconsistent comment about expansion of exception declarations

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch11.adb (Expand_N_Exception_Declaration): Sync comment with declaration in System.Standard_Library.diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp

[Ada] Fix 0-sized secondary stack allocations

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
The Has_Enough_Free_Memory was not correctly reporting a completely full chunk in the case of a 0-sized allocation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-secsta.adb (Has_Enough_Free_Memory): Check for full chunk before computing the available size

  1   2   3   4   5   6   7   8   9   >