[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

[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

[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

[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

[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

[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

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

[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

[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

[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

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

[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

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

[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

[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

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

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

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

[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

[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

[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

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

[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):

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

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

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

[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] 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] 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] 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 *

[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):

[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).

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

[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

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

[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

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

[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

[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

[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

[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

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

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

[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

[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

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

[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

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

[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

[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] 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] 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 @@

[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

[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

[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

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

[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

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

[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

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

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

[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

[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

[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. *

[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

[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] 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.

[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

[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

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

[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

[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

[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

[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

[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] 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 +++

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

[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

[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

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

[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. *

[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

[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

[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

  1   2   3   4   5   6   7   8   9   >