[Ada] Fix layout of tables in PDF version of GNAT RM

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Tables with small left columns and large right columns had colliding text in the PDF version of GNAT RM. Spotted while adding description of pragma Ada_2022. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementation_defined_characteristics.rst: Add

[Ada] Reset Reachable field when mutating label into loop entity

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
An entity flag Reachable now only applies to E_Label entities and needs to be explicitly reset when mutating labels into loop entities. Only needed to prevent cascaded errors when compiling a malicious ACATS test with -gnatq (try semantics, even if parse errors). Cleanup related to detection of un

[Ada] fix crash on Secondary_Stack_Size with discriminant

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes a crash caused by specifying the Secondary_Stack_Size aspect of a task type as the value of a discriminant of the task type, and then declaring a record component whose type is the task type, constrained to a discriminant of the record. Tested on x86_64-pc-linux-gnu, committed on

[Ada] Excess finalization on assignment with target name symbol

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
In cases where the Ada 2022 feature of target name symbols (@) is used and the evaluation of the name is side-effect free, the compiler creates a temporary object to hold the value of the target object for use as the value of "@" symbols in the right-hand side expression. In the case where the targ

[Ada] Use pygments for Ada code examples of elaboration control

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Only enhancement of formatting. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Change blocks from plain code to Ada.diff --git a/gcc/ada/doc/gnat_ugn/elaboration_order_handling_in_gnat.rst b/gcc/ada/doc/gnat_ugn/e

[Ada] Fix formatting glitches in GNAT User's Guide

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Only enhancement of formatting. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/gnat_and_program_execution.rst, doc/gnat_ugn/gnat_utility_programs.rst, doc/gnat_ugn/inline_assembler.rst: Fix typos and formatting glitches. * gnat_u

[Ada] Fix "S p e c" and "B o d y" file headers

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Fix Spec/Body headers in .adb/.ads files, respectively; all violations detected with grep and manually filtered because of .tmpl files. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_atag.adb, lib-util.ads, libgnat/g-decstr.adb, libgnat/g-exptty.adb, libgnat/g-s

[Ada] Add SUSE 32bit dependency

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
On SUSE 15, glibc-locale-base-32bit is needed to run 32bit versions of Libadalang tools. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/platform_specific_information.rst: Add glibc-locale-base-32bit as a dependency in SUSE distributions. * gnat_

[Ada] Update categorization of implementation restrictions

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Some of the restrictions were initially implemented as specific to GNAT, but now they are part of Ada; likewise, some of recently added restrictions were considered to be part of Ada, but are not yet in the standard. This patch updates their categorization based on Ada 202x Draft 32. Only a No_Imp

[Ada] Adapt proof of System.Arith_Double after update of Z3

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Update to version 4.8.14 of prover Z3 requires minor adjustments of the ghost code to add necessary intermediate assertions that drive the automatic proof. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb (Double_Divide, Scaled_Divide): Add interm

[Ada] Detect infinite loops with operators in exit conditions

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
To warn about infinite loops we detect variables referenced in loop exit conditions. We handle references within boolean operators, i.e. comparison and negation, which are likely to appear at the top level of the condition (e.g. "X > 0"). However, we can easily handle all operators, because they ar

[Ada] Do not create useless itype in Constrain_Access

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
In the case of a constrained access definition for a record component we are calling create_itype twice the former not being updated. This leads to a malformed node that crashes -gnatG when predicates are activated. Instead of creating a default Itype for Desig_Subtype, create it with the correct

[Ada] Fix spurious ambiguity for if_expression containing operator

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
It comes from a discrepancy in the analysis of binary operators, between the predefined ones for which we register an interpretation with the base type and the user-defined ones for which we register an interpretation with the subtype directly. This is harmless in almost all cases because the two

[Ada] New No_Local_Tagged_Types restriction

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Add new configuration restriction No_Local_Tagged_Types. This new restriction ensures at compile time that all tagged types are only declared at the library level. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-rident.ads (Restriction_Id): Add No_Local_Tag

[Ada] Correctly reject record aggregate using brackets

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Ada 2022 bracket syntax is only allowed for arrays and containers, not records. This change correctly rejects record aggregates using brackets along with few cases of brackets being used instead of parentheses. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-direct

[Ada] Fix Compile_Time_(Error|Warning) as non-configuration pragmas

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Uses of Compile_Time_Error and Compile_Time_Warning as configuration pragmas were detected with a custom check in semantic analysis. Now they are detected with an existing general check in parser. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_Pragma):

[Ada] Fix unbalanced paren in documentation marker for GNAT Studio

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Unbalanced parens can be found when editing in emacs using the "check-parens" command. Offending occurrences must be examined manually, because few of them are intentional. Minor cleanup of typos in documentation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/

[Ada] Sort Detect_Blocking alphabetically among names and pragmas

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
In GNAT User's Guide section about configuration pragmas the Detect_Blocking has been recently moved to an alphabetic order. This patch moves the its Name_Id and Pragma_Is in the source code to match this order. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * snames.ads-tmp

[Ada] Proof of 'Image support for unsigned integers

2022-05-11 Thread Pierre-Marie de Rodat via Gcc-patches
Prove System.Image_U, making the connection with the space available in the string as computed with System.Width_U and the functions that support the other direction of 'Value in System.Value_U. The units that support 'Image cannot be marked Pure anymore, as they now depend on non-pure units. Tes

[Ada] Document Aggregate_Individually_Assign as a configuration pragma

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Pragma Aggregate_Individually_Assign was apparently forgotten to be listed in the GNAT User's Guide as a configuration pragma. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/the_gnat_compilation_model.rst (Configuration Pragmas): Add Aggregate_Individua

[Ada] Reuse generic string hash for invocation signatures

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Use a generic string hash routine for hashing of invocation signatures. The System.String_Hash unit was added to GNAT in 2009 and shouldn't cause any bootstrap problems these days. To be safe, we don't use the GNAT.String_Hash renaming, which was added later. Cleanup related to a new restriction N

[Ada] Fix typos in syntax for implementation-defined pragmas

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Documentation cleanup. Spotted while looking at description of configuration pragmas. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: (Export_Object, Import_Object, Short_Descriptors): Fix pragma syntax specific

[Ada] Fix scope of block in expanded protected entry body

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
We expand protected entry body into procedure with a nested block. The scope of this block is naturally the enclosing procedure. However, the scope field was wrongly set to the entity of the enclosing procedure body (i.e. E_Subprogram_Body); now it is set to the entity of the enclosing procedure sp

[Ada] Fix style checking rule for square brackets in Ada 2022 and above

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
The square bracket syntax introduced in Ada 2022 was incorrectly handled by the style checker and incorrect spacing was enforced. The issue was in part caused by the wide character syntax (support removed starting from Ada 2022) that treats the square bracket as a valid identifier character. Teste

[Ada] Rewrite Sem_Ch4.Find_Boolean_Types

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Using a straight implementation like the one in Find_Arithmetic_Types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Find_Arithmetic_Types): Use local variables. (Find_Boolean_Types): Rewrite modeled on Find_Arithmetic_Types.diff --git a/gcc/ada/sem_ch

[Ada] Introduce hardbool Machine_Attribute for Ada

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Implement and document hardened booleans, from nonstandard boolean types with representation clauses to the extra validity checking performed on boolean types annotated with the "hardbool" Machine_Attribute pragma. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/

[Ada] Proof of 'Image support for signed integers

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Prove System.Image_I, similarly to the proof done for System.Image_U. The contracts make the connection between the result of Image_Integer, the available space computed with System.Width_U and the result of 'Value as computed by Value_Integer. I/O units that now depend on non-pure units are also

[Ada] Adapt CodePeer analysis of GNAT to changes in dependencies

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
New dependencies in s-imagei are causing issues for CodePeer analysis of GNAT source and libs. Updating the setup. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-imagef.adb: Justify false message from CodePeer.diff --git a/gcc/ada/libgnat/s-imagef.adb b/gcc/ada/li

[Ada] Plug loophole in Possible_Type_For_Conditional_Expression

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
We need to check that the designated subprograms of access-to-subprogram types are subtype conformant before registering a common interpretation. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Possible_Type_For_Conditional_Expression): Add test for subt

[Ada] Revamp analysis of conditional expressions

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
The current implementation is skewed toward the first dependent expression and does not look into the interpretations of the others if the first one is not overloaded, which can create spurious ambiguities. And more precise error messages are now given if the types of the dependent expressions are

[Ada] Accept raise expressions as operands of boolean operators

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch restores the previous behaviour of a recently rewritten routine Sem_Ch4.Find_Boolean_Types for boolean operators where one of the operands is a raise-expression, e.g.: (raise Program_Error or else (X /= Y)) This change is required for the Entity field of the "or else" operator to be

[Ada] Remove redundant guard against Any_String

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
A sequence of checks for a valid Boolean argument fails when applied to Any_String because its component is not of a Boolean type. The explicit guard was unnecessary; it was only needed when a First_Index applied to Any_String would crash, but this was fixed soon after this guard was added. Cleanu

[Ada] Fix support for ISO-8859-15 and IBM CP 850 encoding

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
In ISO-8859-15, code for "lower y with diaeresis" is used for the upper case. In IBM CP 850, upper and lower o with stroke were missing. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * csets.adb (Fold_Latin_9): Fix y with diaeresis. (Fold_IBM_PC_850): Fix o with str

[Ada] Remove use of use-clauses in loaded runtime units

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
The spec of runtime units that may be loaded by the compiler should not contain use-clauses, for visibility to be correctly handled. Remove use-clauses that were introduced for the ghost big integers unit as part of the proof of runtime units. Tested on x86_64-pc-linux-gnu, committed on trunk gc

[Ada] Add ghost code to facilitate proof with SPARK

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Proof of generic units for Long_Long_Long_Unsigned instantiations is harder for provers, as they have to deal with larger values. Add ghost code to make the proof easier. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-imageu.adb (Set_Image_Unsigned): Add lemma.

[Ada] Remove front-end SJLJ processing

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
We no longer use the so called front-end SJLJ exception mechanism, so get rid of it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ali.adb, ali.ads, bcheck.adb, exp_ch11.adb, fe.h, gnat1drv.adb, opt.adb, opt.ads, targparm.adb, targparm.ads, lib-writ.adb: Ge

[Ada] Make debug printouts more robust

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
This patch improves some debug printouts so that they avoid crashing on invalid data. In addition, the relevant code uses Global_Name_Buffer all over the place. This patch cleans up some of those uses, in particular ones in the same code as the robustness changes, and code called by that code. Te

[Ada] Do not issue a warning on a postcondition of True or False

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Do not issue a warning about the postcondition of a function not mentioning its result when this postcondition is statically True or False, as this is a specification of non-termination (for value False) or a hint to SPARK prover for not inlining an expression function (for value True). In any case

[Ada] Remove useless pragma Warnings Off from runtime units

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
GNAT does not issue a warning anymore on a postcondition of True (used here to prevent inining inside GNATprove for proof). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valuei.ads: Remove pragma Warnings Off. * libgnat/s-valueu.ads: Same. * libgn

[Ada] Fix warning about generic subprograms withed but not instantiated

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler should warn when a generic subprogram unit is withed but not instantiated by the current main unit. This warning relies on flag Is_Instantiated, which was wrongly set when the generic unit was also withed and instantiated by some other unit. This change merely reverts a fix done 20 ye

[Ada] Fix warning about generic subprograms withed but not referenced

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
For warnings about unreferenced entities and unused WITH clauses we typically exclude references outside of the extended main source unit. However, we include references to variables of formal private types to warn in the instance if the corresponding type is not a fully initialized type. This spe

[Ada] Add more dummy names in Sem_Warn.Has_Junk_Name

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
To sync the names used in CodePeer (and SPARK) when filtering out warnings on e.g. unused variables. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_warn.adb (Has_Junk_Name): Add more dummy names.diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb --- a/gcc/ada/sem_

[Ada] Remove unreferenced Is_Selector_Name routine

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Function Is_Selector_Name was added in 1995 while experimenting with default expressions in record declarations. This experiment was abandoned after one day and this routine was never used since then. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.ads (Is_Selector_

[Ada] Reuse collective subtype for comparison operators where possible

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
Replace membership alternatives with N_Op_Compare. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Actuals): Simplify with N_Op_Compare. * sem_util.adb (Replace_Null_Operand, Null_To_Null_Address_Con

[Ada] Restore double quotes in debug printouts

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
A previous change in "Make debug printouts more robust" accidentally removed double quotes around identifiers in debug printouts. This patch restores those. So for example, we have: Prev_Entity = Node #10 N_Defining_Identifier "foo" (Entity_Id=795) and not: Prev_Entity = Node #10 N

[Ada] Skip postponed validation checks with compilation errors

2022-05-12 Thread Pierre-Marie de Rodat via Gcc-patches
If there are compilation errors then gigi doesn't backannotate the AST with sizes, alignment, etc. The postponed compilation validation checks can then easily crash or give spurious errors. We now just skip them. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnat1drv.adb (

[Ada] Ineffective use type clause warnings cause compile time crash

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby the presence of a generic instance featuring a use type clause at library level may cause a crash at compile time when warnings for ineffective use clauses are enabled and the type in question is already use visible. Tested on x86_64-pc-linux-gn

[Ada] Remove redundant guard in checks for volatile actuals

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
When flagging names of volatile objects occurring in actual parameters we guard against identifiers without entity. This is redundant, because earlier in the resolution of actual parameters we already guard against actuals with Any_Type. Code cleanup related to handling of volatile components; beh

[Ada] Accept effectively volatile components in actuals

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
In SPARK we forbid names that are effectively volatile for reading if they occur in actual subprogram parameters. We wrongly rejected references to components, which are not names in Ada. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Flag_Effectively_Volatile_

[Ada] Spurious access error in function returning type with access discriminant

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
This patch fixes an issue in the compiler whereby incorrect accessibility checks were generated in functions returning types with unconstrained access discriminants when the value supplied for the discriminant is a formal parameter. More specifically, accessibility checks for return statements fea

[Ada] Fix the Ada 2022 iterated component association RM reference

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Fix the error message pointing to the Ada reference section on mixed iterated component association being forbidden. Remove useless loop. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Array_Aggregate): Fix ARM reference. Remove useless loop.d

[Ada] Remove obsolete uses of Unchecked_Deallocation from Ada 83

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
In Ada 83 the Unchecked_Deallocation was a top-level unit; since Ada 95 it is an obsolete renaming of Ada.Unchecked_Deallocation. GNAT doesn't yet warn about uses of these obsolete renamings, but it still seems better to avoid them. Cleanup before adding a new instance of Unchecked_Deallocation. O

[Ada] Fix compiler crash on FOR iteration scheme over container

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
The front-end drops a freeze node on the floor because it puts the node into the Condition_Actions of an N_Iteration_Scheme of a FOR loop. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Insert_Actions) : Check that it is a WHILE iteration scheme before

[Ada] Remove obsolete uses of Unchecked_Conversion from Ada 83

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Similar to a recent removal of obsolete uses of Unchecked_Deallocation. In Ada 83 the Unchecked_Conversion was a top-level unit; since Ada 95 it is an obsolete renaming of Ada.Unchecked_Conversion. GNAT doesn't warn yet about uses of these obsolete renamings, but it still seems better to avoid the

[Ada] Improve expected type error messages

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
This patch improves error messages concerning type mismatches by printing the actual expected type in more cases instead of the expected type's first subtype. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Wrong_Type): Avoid using the first subtype of

[Ada] Crash in task body reference to discriminant

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler may crash processing the successor or predecessor of a task type discrete discriminant. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Resolve_Attribute): Ensure that attribute expressions are resolved at this stage; required for preanalyz

[Ada] Wrong address for class-wide interface access conversion

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler generates wrong code on instantiations of package Address_To_Access_Conversions when the generic formal is a class-wide interface type; this causes wrong dispatching calls when the access-to-class-wide-interface object returned by To_Pointer is used to dispatch a call. Tested on x86_6

[Ada] Document control flow redundancy

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Add documentation about -fharden-control-flow-redundancy. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/security_hardening_features.rst: Add subsection on Control Flow Redundancy. * gnat_rm.texi: Regenerate.diff --git a/gcc/ada/doc/gnat_rm/secur

[Ada] Do not overwrite limited view of result type

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
This removes obsolete code that overwrites a limited view present as the result type of a function during the tentative analysis of prefixed views for function calls involving tagged types. The original view is necessary for the code generator to break the circularity present in this setup. The ch

[Ada] Fix code example on representation clause

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
The column is superfluous, component names are missing. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/representation_clauses_and_pragmas.rst: Fix code snippet. * gnat_rm.texi: Regenerate.diff --git a/gcc/ada/doc/gnat_rm/representation_clauses_an

[Ada] Facilitate proof of Overwrite in bounded strings library

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Consistently use >= operator in both the code and contracts of function/procedure Overwrite, to facilitate proof, instead of the strict inequality > sometimes, as only New_Item remains in the result in the case of equal size too. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Handle IN iterator for class-wide derived object of iterator type

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
The compiler currently rejects iterating on an interface type derived from an iterator type. See Ada RM 5.5.1(6/3) and 5.5.2(3/3). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch5.adb (Analyze_Iterator_Specification): Fix Typ in the case of a class-wide deriv

[Ada] Implement late initialization rules for type extensions

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Default initialization of a record object is required to initialize any components that "require late initialization" after other components. This includes the case of a type extension; "late initialization" components of the parent type are required to be initialized after non-late-init extension

[Ada] Take into account GNSA_ROOT env var for prefix

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
The GNSA_ROOT environment variable can be used to indicate to the compiler how to find the runtime directory. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * osint.ads, osint.adb (Relocate_Path): If the GNSA_ROOT environment variable is set, we use that as the prefix

[Ada] Ada ABI change when building with assertions

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Compiling with and without assertions enabled the name of some generated symbols differ; this is an issue when using pre-built libraries. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Check_Inherited_Conditions): Dispatch table wrappers must be placed i

[Ada] Remove dependency on tampering checks and controlled types for formal

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Formal hashed sets and maps are now using a different type of hash table that does not require controlled types. This is possible because formal containers do not rely on tampering checks, as cursors do not hold a pointer to a single matching container, but are logical indexes that can be used with

[Ada] Adapt body of formal sets and maps for SPARK

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Remove violations of SPARK rules, to prepare for the proof of hashed sets and maps: - Make the type of hash tables not tagged, so that it will be possible to mark the type of nodes as having relaxed initialization. - Remove comparison of addresses as check or optimization: as a check, it is n

[Ada] Simplify helper units for formal hashed sets/maps

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
As tampering checks do not exist in formal hashed sets and maps, remove the machinery for such checks in the version of generic key and node operations for formal sets/maps. Update comments as well. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-chtgfk.adb (Checke

[Ada] Fix iterated component association for array aggregate

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Create a scope for the Ada 2022 iterated component association loops. In the case of elements needing finalization, the late expansion would crash on references to the loop variable within the loop body. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Gen_Loop)

[Ada] Extend hardcfr testing (documentation)

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Having realized that noreturn calls of __builtin_return are special, and other noreturn calls don't get edges to the exit block, I've realized the consequences of the logic to insert checking before noreturn and tail calls were not quite what I'd expected before. Specifically, noreturn calls other

[Ada] CUDA: use binder to generate kernel-registration code

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
Compiling CUDA code requires compiling code for the host (= CPU) and for the device (= GPU). Device code is embedded into the host code and must be registered with the CUDA runtime by the host. The original approach we took for registering CUDA kernels was to generate the registration-code on a un

[Ada] Only use alternate stack when needed

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
If we're not going to install a signal handler for SIGSEGV then we do not need an alternate stack to handle this signal (and e.g. stack overflows). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-taprop__linux.adb (Initialize): Do not use an alternate stac

[Ada] Storage_Model_Object fails to return object entity

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
After a compilation unit containing a Designated_Storage_Model aspect was processed by the compiler front end, the aspect's expression was seen as not having been analyzed. In some cases this can lead to the Storage_Model_Object function not returning the entity of the associated model object (such

[Ada] Fix incorrect call to inherited function with limited return type

2022-05-13 Thread Pierre-Marie de Rodat via Gcc-patches
This is a return convention mismatch coming from a discrepancy of the Returns_By_Ref flag for the inherited function. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Derive_Subprogram): For a function, also copy the Returns_By_Ref flag from the parent.di

[Ada] Remove duplicated code for detecting enabled pragmas

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Routines Is_Enabled and Is_Enabled_Pragma are identical (except for comments); remove this duplication. Cleanup related to handling of volatile refinement aspects in SPARK; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Is_Enabled): R

[Ada] Clarify code for detecting volatile refinement properties

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Routine Type_Or_Variable_Has_Enabled_Property handles either types or objects; replace negation with an explicit positive condition. Cleanup related to handling of volatile refinement aspects in SPARK; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ *

[Ada] Pick volatile refinement property of a subtype from its base type

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Volatile refinement properties (e.g. Async_Writers), which refine the Volatile aspect in SPARK, are inherited by subtypes from their base types. In particular, this patch fixes handling of those properties for subtypes of private types. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Couple of small consistency tweaks

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
This aligns Analyze_Negation and Analyze_Unary_Op with the other similar procedures in Sem_Ch4. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch4.adb (Analyze_Negation): Minor tweak. (Analyze_Unary_Op): Likewise.diff --git a/gcc/ada/sem_

[Ada] Map gnatlib-shared to gnatlib-shared-dual for aarch64-vx7r2

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
This is an incremental change towards supporting shared libraries for VxWorks on aarch64. The aarch64-vx7r2 compiler supports compilation with -fpic/PIC. This change adds aarch64 to the list of CPUs for which GNATLIB_SHARED maps to gnatlib-shared-dual for vxworks7r2, so "make gnatlib-shared" actu

[Ada] Fix spurious error on limited view with incomplete type

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
The problem is that Install_Limited_With_Clause does not fully implement AI05-0129, in the case where a regular with clause is processed before a limited_with clause of the same package: the visible "shadow" entity is that of the incomplete type, instead of that of the full type per the AI. This r

[Ada] Improve building of untagged equality

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
When checking components of a record type for their own user-defined equality function it is enough to find just one such a component. Cleanup related to handling of user-defined equality in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Build_Untag

[Ada] Remove duplicated detection of user-defined equality

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Cleanup related to handling of user-defined equality in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (User_Defined_Eq): Replace duplicated code with a call to Get_User_Defined_Eq.diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb --- a/g

[Ada] Implement component finalization ordering rules for type extensions

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Finalization of a record object is required to finalize any components that have an access discriminant constrained by a per-object expression before other components. This includes the case of a type extension; "early finalization" components of the parent type are required to be finalized before

[Ada] Fix implementation issues with equality for untagged record types

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
This moves the implementation of AI12-0101 + AI05-0123 from the expander to the semantic analyzer and completes the implementation of AI12-0413, which are both binding interpretations in Ada 2012, fixing a few bugs in the process and removing a fair amount of duplicated code throughout. Tested on

[Ada] Fix internal error on predicate aspect with iterator

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
The semantic analysis of predicates involves a fair amount of tree copying because of both semantic and implementation considerations, and there is a difficulty with quantified expressions since they declare a new entity that cannot be shared between the various copies of the tree. This change imp

[Ada] Fix internal error on mix of controlled and protected types

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
The key is that the protected type is a (limited) private type, which fools a test in Cleanup_Scopes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Cleanup_Scopes): Test the underlying type.diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb --- a/gcc/ada/inli

[Ada] Accept calls to abstract subprograms in class-wide pre/post-conditions

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Fix a regression in the support for Ada 2022's treatment of calls to abstract subprograms in pre/post-conditions (thanks to Javier Miranda for producing this patch). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_disp.adb (Check_Dispatching_Context): When checking to se

[Ada] Fix internal error on iterated array aggregate

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
The front-end drops the declaration of a temporary on the floor because Insert_Actions fails to climb up out of an N_Iterated_Component_Association when the temporary is created during the analysis of its Discrete_Choices. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_

[Ada] Fix iterated element association loop var escaping loop scope

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Fix the escaping of the loop variable from the loop scope in both forms of iterated element associations (i.e. "for J in ..." and "for J of ..."). Create a dedicated scope around the analyses of both loops. Also create a copy of the Loop_Parameter_Specification instead of analyzing (and modifying)

[Ada] replace call to bzero in terminals.c by call to memset

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
bzero is marked as legacy in POSIX.1-2001, and using it triggers a deprecation warnings on some systems such as QNX. This change adjusts the one place where we use it in terminals.c to use memset instead. This, in turns, allows us to get rid of a hack for HP/UX and Solaris. Tested on x86_64-pc-lin

[Ada] Revise Storage_Model_Support operations to do checks and take objects and types

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
The functions in subpackage Storage_Model_Support (apart from the Has_*_Aspect functions) are revised to have assertions that will fail when passed a parameter that doesn't specify the appropriate aspect (either aspect Storage_Model_Type or Designated_Storage_Model), instead of returning Empty for

[Ada] Add #include in cstreams.c

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
When building the GNAT runtime for QNX, we get the following warning: | cstreams.c: In function '__gnat_full_name': | cstreams.c:209:5: warning: implicit declaration of function 'realpath' | [-Wimplicit-function-declaration] | 209 | realpath (nam, buffer); | | ^~~

[Ada] Fix thinko in QNX's implementation of __gnat_install_handler

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
On QNX, the sigaction handler is incorrectly installed via the sa_handler field of struct sigaction, rather than the sa_sigaction field. This triggers a compilation warning due to a mismatch between the function's signature and the field's type. | init.c:2614:18: warning: assignment to 'void (

[Ada] sigaction result not properly checked in __gnat_install_handler (QNX)

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
The QNX version of __gnat_install_handler calls sigaction for a number of signals, and then prints an error message when the the call failed. But unfortunately, except for the first call, we forgot to store sigaction's return value, so the check that ensues uses a potentially uninitialized variable

[Ada] GNAT.Debug_Pools: Improve documentation of the Stack_Trace_Depth parameter

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Setting this parameter to zero when calling the Configure procedure has the effect of disabling completely the tracking of the biggest memory users, which wasn't clear from the current documentation. So this patch enhances the documentation of both the Configure procedure as well as the Dump proce

[Ada] Don't crash on ghost packages when emitting CUDA symbols in ALI files

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Before this commit, a GNAT compiled with assertions would crash when attempting to emit CUDA symbols in ALI files for spark_mode/ghost packages, whose content is a single null statement. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * lib-writ.adb (Output_CUDA_Symbols): Chec

[Ada] Fix proof of double arithmetic units

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
Proof of an assertion is not automatic anymore. Add two assertions before it to guide the prover. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-aridou.adb (Double_Divide): Add intermediate assertions.diff --git a/gcc/ada/libgnat/s-aridou.adb b/gcc/ada/lib

[Ada] Freeze target type on qualified expression expansion

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
An object declaration (other than a deferred constant declaration) causes freezing where it occurs (13.14(6)), which means every name occurring within it causes freezing (13.14(4/1)), and when the name in a subtype_mark causes freezing, the denoted subtype is frozen (13.14(11)). Hence, one needs to

[Ada] Type invariant or postcondition may cause uninitialized memory reads

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
This patch corrects an error in the compiler whereby a function requiring the generation of a postconditions procedure may cause an uninitialized memory read when the return type Has_Unconstrained_Elements or is an unconstrained array. The error occurs because evaluation of postconditions happens

[Ada] Remove useless code related to current value propagation

2022-05-16 Thread Pierre-Marie de Rodat via Gcc-patches
The current value propagation applies only to assignable objects and doesn't make sense for subprogram entities. This was a mistake introduced when extending the current value propagation years ago. Cleanup related to fixing interference between expansion of attribute Loop_Entry and current value

<    24   25   26   27   28   29   30   31   32   33   >