[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

[Ada] Do not create large objects for indefinite protected types

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This plugs a small loophole in the Needs_Secondary_Stack predicate for some protected types and record types containing protected components. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Caller_Known_Size_Record): Make entry assertion more robust and

[Ada] Extend No_Dependence restriction to code generation

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This makes it possible to report violations of the No_Dependence restriction during code generation, in other words outside of the Ada front-end proper. These violations are supposed to be only for child units of System, so the implementation is restricted to these cases. Tested on x86_64-pc-linux

[Ada] Spurious use_type clause warning

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby a spurious redundant use_type_clause warning gets issued when the clause appears in the context_clause of a package preceding a with_clause for a package with an identical use_clause in its specification. Tested on x86_64-pc-linux-gnu, committed

[Ada] Use right implementation type for nonbinary-modulus ops

2022-07-12 Thread Pierre-Marie de Rodat via Gcc-patches
If the flag Opt.Expand_Nonbinary_Modular_Ops is set (which occurs if -gnateg is specified) then we implement predefined operations for a modular type whose modulus is not a power of two by converting the operands to some other type (either a signed integer type or a modular type with a power-of-two

[Ada] Refine type for checking number of pragma arguments

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-prag.adb (Check_Arg_Count): Change parameter type from Int to Nat, because this parameter is compared to Arg_Count variable which is of type Nat. Also, it wouldn't make sense to check for

[Ada] Fix CodePeer warnings in GNAT sources

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes various redundant constructs or uninitialized variables identified by CodePeer in the GNAT frontend and runtime sources. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Expand_N_Extended_Return_Statement): Add default initialization for

[Ada] Fix proof of runtime unit System.Arith_64

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
After changes in provers and Why3, changes are needed to recover automatic proof of System.Arith_64. This is the first part of it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb (Lemma_Mult_Div, Lemma_Powers): New lemmas. (Prove_Sign_Quo

[Ada] Fix if expression returning slice

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler incorrectly assumed the prefix for a slice returned in one branch of an if expression has its bounds known at compile time and would crash when this is not true. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_If_Expression): Test for compi

[Ada] Fix internal error on untagged record type with equality operator

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
After the binding interpretation issued under AI12-0413, a user-defined primitive equality operator of an untagged record type hides the predefined equality operator in an instantiation, but this does not apply if the instantiation appears in the same declarative region as the type and before the d

[Ada] Clarify hardening command-line options that require explicit choices

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
Prefixes -fzero-call-used-regs and -fstrub could be mistaken for full command-line options with the references to them in the GNAT RM. Make it clearer that they require explicit choices. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/security_hardening_features

[Ada] Fix crash on frontend inlining of functions with single returns

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
When examining expression of the first declaration of the inlined body make sure that this declaration is in fact an object declaration. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Has_Single_Return): Add guard for the subsequent call to Expression.di

[Ada] Plug legality loophole for equality operator of untagged record types

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
In Ada 2012, the RM 4.5.2(9.8) clause prevents an equality operator for an untagged record type from being declared after the type is frozen. While the clause is implemented in GNAT, the implementation has a loophole which lets subprogram bodies that are not the completion of a declaration pass th

[Ada] Do not generate DW_TAG_typedef for constrained array types

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
It no longer serves any useful purpose at this point. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils.cc (gnat_pushdecl): Build DECL_ORIGINAL_TYPE only for pointer types.diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc

[Ada] Fix incorrect handling of Ghost aspect

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
When a formal generic type is marked as Ghost, the instantiation of that generic will contain a generic subtype for the actual with the Ghost pragma. Recognize this case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_Pragma): Recognize a generated sub

[Ada] Add support for defaulted Storage_Model_Type aspect and subaspects

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler currently rejects a Storage_Model_Type aspect that is not specified with an aggregate, or that has an aggregate that does not specify all defined "subaspects" (Address_Type, Null_Address, Allocate, etc.). The RFC for this feature defines the aspect to fully default to the native memory

[Ada] Fix for visibility of aspect expressions inside generic units

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
When a generic unit contains references to global entities (i.e. entities declared outside of this generic unit), those references are saved: from the analyzed copy of a generic unit (which is then discarded) into a generic template (which is then instantiated, possibly many times). To save those r

[Ada] Revert recent change in debug info for vector array types

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
It lost too much useful information. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Do not set the debug type for vector types.diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc --- a/gcc/ada/gcc-in

[Ada] Generate debug info entry for user-defined access subtype

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
This is consistent with the other kinds of subtypes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : Do not reuse the TYPE_DECL of the base type.diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc --

[Ada] Fix wrong access check with access-to-unconstrained-array

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
The current implementation may create dangling references from a superset of the alias set of the dummy pointer-to-array type when it exists. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : Save and restore the alias set o

[Ada] Fix internal error on comparison with access function parameter

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
It comes from an overzealous assertion. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils2.cc (build_binary_op) : Also accept pointer-to-function types that are not variant of each other.diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-int

[Ada] Extend No_Dependence restriction to code generation

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
This reports violations for 4 units from gigi. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.cc (gigi): Report a violation of No_Dependence on System.Stack_Checking if Stack_Check_Probes_On_Target is not set and -fstack-check is specifie

[Ada] Handle bodies-to-inline just like generic templates

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
Originally bodies-to-inline created for the frontend inlining were analyzed with expansion disabled. Then, to facilitate inlining in GNATprove mode, the analysis was changed to preanalysis. However, preanalysis in this context works badly for calls in prefix notation, because preanalysis assigns e

[Ada] Fix internal error on instance of Ada.Task_Attributes at -O

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
This happens when there is a size mismatch, but this must be accepted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils.cc (unchecked_convert): Also pad in most cases if the source is not a scalar type but the destination is.diff --git a/gcc/ada/gc

[Ada] Use actual types instead of formal types consistently in debug info

2022-07-13 Thread Pierre-Marie de Rodat via Gcc-patches
This makes sure that the objects present in instantiations always have the actual type instead of a local variant of the formal type in the debugging information generated by the compiler (this was already the case when the actual type is a record, a protected or a task type). Tested on x86_64-pc-

[Ada] Fix up handling of ghost units PR104027 #2

2022-01-31 Thread Pierre-Marie de Rodat via Gcc-patches
The previous change was short-circuiting too much, the regular processing (in particular writing ALI files) was bypassed, causing troubles with e.g. gnatmake or gprbuild down the road. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ PR ada/104027 * gnat1drv.adb (Gnat1d

[Ada] doc/share/conf.py: fix string handling

2022-01-31 Thread Pierre-Marie de Rodat via Gcc-patches
The recent update on this script to handle strings rather than bytes missed a call to ".decode()", leading to a crash: AttributeError: 'str' object has no attribute 'decode' Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/share/conf.py: Remove spurious call to ".dec

[Ada] Cleanup listing of representation info

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * repinfo.adb (List_Entities): Simplify detection of entries; refactor potentially redundant comparison.diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb --- a/gcc/ada/repi

[Ada] Simplify building of inequality function body

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
Code cleanup related to expansion of equality for GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Make_Eq_Body): Refactor to avoid appending to an empty list; also, when exiting early we will not create any list; fix style in comment.d

[Ada] Avoid duplication for Sets functions

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
ARM A.18.7 96.9/3 and 96.12/3 state: > Equivalent to Constant_Reference (Container, Find (Container, Key)). > Equivalent to Reference_Preserving_Key (Container, Find (Container, Key)). Every other procedure and functions noted as "equivalent" for sets in this ARM function use these equivalences.

[Ada] Storage error on untagged prefixed subprogram calls with -gnatX

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler can crash when compiling the prefixed form of subprogram calls for untagged types when extensions are enabled. Problems can also manifest in cases where such calls occur in the absence of extensions being enabled. The source of this is that the Direct_Primitive_Operations lists were c

[Ada] Improve messages on incorrect state refinement in SPARK

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
The use of Abstract_State / Refined_State / Part_Of may lead to unclear messages for users. This patch adds continuation messages on common error messages, to explain the problem, or expands the existing error message. As a result of specializing error messages on misplaced pragmas, many error mes

[Ada] Document System.Atomic_Counters as supported on ARM and AARCH64

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
Unit System.Atomic_Counters on ARM and AARCH64 is supported via GCC builtins. This patch makes the documentation consistent with Makefile.rtl and with comments in s-atocou.ads. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/the_gnat_library.rst (System.Atomic_Co

[Ada] Sort list of Ada runtime units in Makefile.rtl

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
Sort to simplify review and insertion of future units. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * Makefile.rtl (GNATRTL_TASKING_OBJS): Sort. (GNATRTL_NONTASKING_OBJS): Sort.diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl --- a/gcc/ada/Makefile.rtl +++ b

[Ada] Sync whitespace between variants of Indefinite_Holders unit

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
Remove insignificant whitespace diffs between atomic and non-atomic variants of Ada.Containers.Indefinite_Holders. This will simplify review and modification of both variants in the future. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-coinho.ads: Sync whitespace

[Ada] Replace low-level detection of subprograms with high-level wrapper

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to handling of dispatching equality in GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb, sem_cat.adb, sem_ch10.adb, sem_ch12.adb, sem_elim.adb, sem_util.adb: Replace uses of Subprogram_Kind with

[Ada] Add query for extended precision floating-point types

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
This query is used in GNATprove to identify extended precision (80-bits) floating-point types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Is_Extended_Precision_Floating_Point_Type): New function. * sem_util.ads (Is_Extended_Precision_Floati

[Ada] Improve error messages for dot notation when -gnatX not used

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
With extensions allowed (whether switch -gnatX or pragma Extensions_Allowed is used), dot notation is allowed on untagged types for primitives of the type. Improve the error messages issued when extensions are not allowed, in particular when allowing extensions would make the code legal. Tested on

[Ada] Fix small discrepancy between -gnatG and -gnatD[G] outputs

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
The outputs generated for the same compilation by -gnatG and -gnatD[G] are not strictly identical: the former lacks a few freeze nodes, which can be quite confusing. So this change aligns the former with the latter. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sprint.ads

[Ada] Create object file for ignored ghost compilation unit

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
If the compilation unit we're compiling is an ignored ghost, we need to ensure that an object file is generated. This happens automatically for the GCC backend since it always generates the .o file, but for GNAT LLVM, the backend isn't called. So we need to be sure that we explicitly generate the f

[Ada] Spurious warning when using 'Type_Key on generic formal

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an issue in the compiler whereby spurious compile-time warnings get raised when the attribute 'Type_Key is applied to a generic formal type. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Type_Key): Avoid premature use warnings when the

[Ada] Do not free task for _parent

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
When a task was stored in a record, GNAT would mistakenly generate a call to free_task twice, the first being correct and triggered by the freeing of the record, the second being incorrect and generated from recursing through the record's _parent. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Fix issues with ignored ghost code and unnesting

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
Unnesting needs to be run after all ignored ghost code is removed so that it doesn't try to put entities into activation records that will be removed. Also, don't add subprograms that are ignored into the list of inlined subprograms. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Improve support for casing on types with controlled parts

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
INOX allows casing on composite values. In some cases of bindings for subcomponents, the compiler introduced copying which led to compiler failures associated with finalizing those copies. In such cases a bound object now provides a constant view of the appropriate subcomponent of the selector obje

[Ada] Fix typo in comment

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
I guess "tnat" means that. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Aggregate): Fix typo in comment.diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -891,7 +891,7 @@ package body Se

[Ada] Tidy up freezing code for instantiations

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
This cleans up the code implementing freezing for instantiations, in order to clearly separate it from semantic analysis and to make the package and subprogram paths more alike. No functional changes. Note that a couple of subprograms are renamed but not re-alphabetized to avoid making the change

[Ada] Tidy up freezing code for instantiations (continued)

2021-12-01 Thread Pierre-Marie de Rodat via Gcc-patches
This re-alphabetizes local subprograms after the previous change. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch12.adb (Freeze_Package_Instance): Move up. patch.diff.gz Description: application/gzip

<    22   23   24   25   26   27   28   29   30   31   >