[Ada] Small addition and tweaks in documentation on freezing

2020-07-15 Thread Pierre-Marie de Rodat
Apart from the usual editorial tweaks, this documents the discrepancy between the aspect and the non-aspect cases for alignment settings in object declarations. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads (Delayed Freezing and Elaboration): Minor tweaks.

[Ada] Spurious accessibility error on allocator

2020-07-15 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby an allocator for a limited type may cause spurious accessibility errors due to a miscalculation of access levels on interally generated temporaries. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb (Make_Build_In_P

[Ada] Fix slices and qualified expressions being effectively volatile

2020-07-15 Thread Pierre-Marie de Rodat
Detecting effectively volatile objects in restricted contexts happens in two routines: Is_Effectively_Volatile_Object and Is_OK_Volatile_Context. Their handling of type conversions and slices were different; also none of them has been dealing with qualified expressions, which has been just added to

[Ada] Fix for possibly null ranges in 'Update and delta_aggregate

2020-07-15 Thread Pierre-Marie de Rodat
In expression like "(Arr with delta Low .. High => New_Component_Value)" bounds Low .. High might denote a null range. In this case both Low and High can be any values from the base type of the array's index type; they don't need to belong to the array's index type itself. This patch removes unnec

[Ada] Mark standard containers as not in SPARK

2020-07-15 Thread Pierre-Marie de Rodat
Use aspect SPARK_Mode with value Off in the spec and body of standard containers, bounded and unbounded versions, so that it is clearer that they cannot be used in SPARK code. Formal containers should be used instead. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a

[Ada] Missing error on operator call

2020-07-15 Thread Pierre-Marie de Rodat
In some cases where a procedure call is expected but a function is provided such as "Interfaces.C."=" (x, y);" GNAT would not generate any error message. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Procedure_Call): Detect use of operators in

[Ada] Fix logic in Allocate_Any_Controlled

2020-07-15 Thread Pierre-Marie de Rodat
If an exception is raised early in Allocate_Any_Controlled, no lock is taken yet and Unlock is called on a lock which isn't taken. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-stposu.adb (Allocate_Any_Controlled): Fix logic in lock/unlock.diff --git a/gc

[Ada] Do not generate elaboration code for alignment aspect

2020-07-15 Thread Pierre-Marie de Rodat
This prevents the compiler from generating elaboration code for a record declared with an initial value and an alignment aspect. The expression of an alignment aspect must be static so, in practice, there is no need to defer the elaboration of the object just because of it. Tested on x86_64-pc-li

[Ada] Cleanup code related to object overlays

2020-07-15 Thread Pierre-Marie de Rodat
Cleanup frontend code before routine Find_Overlaid_Entity will be reused in GNATprove backend. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Find_Overlaid_Entity): Fix style in comment. (Note_Possible_Modification): Simplify repeated calls to Ekind.di

[Ada] Target name is an object reference

2020-07-15 Thread Pierre-Marie de Rodat
Target name (i.e. "@"), which was introduced to Ada 202X in AI12-0125, denotes a constant object (RM 3.3(21.2/5)), even though target_name itself is not an object (RM 3.3(2)). This patch allows @ to be appear as a prefix for Address attribute (which requires an object). Also, it enables constructs

[Ada] Spurious error on Predicate_Failure aspect

2020-07-15 Thread Pierre-Marie de Rodat
GNAT would in some cases not resolve a Predicate_Failure aspect properly and generate spurious errors of the form: cannot find unique type for raise expression Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Add proper

[Ada] Ongoing work for AI12-0212: container aggregates

2020-07-15 Thread Pierre-Marie de Rodat
This patch modifies the parser to recognize iterated_element_associations, which may include a key_exprewsion to be used in a named aggregate such as a map. The new syntactic node N_Iterated_Element_Association is recognized throughout the compiler. The patch also extends the analysis and expansion

[Ada] Guard against access to wrong fields in Is_Renaming

2020-07-15 Thread Pierre-Marie de Rodat
Renamed_Entity is only valid for a few entities, using it on any entity passed to Is_Renaming can result in crashes. Fixing this requires making sure that Is_Renaming only uses Renamed_Entity on entities where this is allowed and uses Is_Renaming_Of_Object everywhere else. Tested on x86_64-pc-lin

[Ada] Cleanup in Convert_To_Positional after previous work

2020-07-15 Thread Pierre-Marie de Rodat
This adjusts the description of Flatten, removes an obsolete comment and uses Compile_Time_Known_Value as now done in Is_Static_Element. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Flatten): Adjust description. (Convert_To_Po

[Ada] AI12-0373 Additional check on Integer_Literal function

2020-07-16 Thread Pierre-Marie de Rodat
Part (1) clarifies that we anticipated in Statically_Names_Object, update comment accordingly. Part 4 (4) clarifies: 4.2.1(3/5) says that the only parameter of a user-defined Integer_Literal function is of type String. But it doesn't specify a mode. Since the parameter is passed a string literal,

[Ada] Incorrect static accessibility error in return aggregate

2020-07-16 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby a local object of a named access type used as an actual for an anonymous access discriminant within a return aggregate would lead to an incorrect accessibility level calculation and thus an incorrect compile-time accessibility error on such an object.

[Ada] Do not perform null exclusion static checks on generated entities

2020-07-16 Thread Pierre-Marie de Rodat
Performing null exclusion checks on generated entities can result in bogus error messages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Add Comes_From_Source call.diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb ---

[Ada] Simplify detection of others choice with just one value

2020-07-16 Thread Pierre-Marie de Rodat
Trivial cleanup with equality between universal integers, which should be much faster than subtraction. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_case.adb (Build_Choice): Simplify.diff --git a/gcc/ada/sem_case.adb b/gcc/ada/sem_case.adb ---

[Ada] Ada2020: AI12-0289 Implicitly null excluding anon access

2020-07-16 Thread Pierre-Marie de Rodat
This patch implements AI12-0289. In particular, if an untagged type T is completed with a tagged full type, and a parameter whose type is "access T", where T denotes the partial view in the subprogram spec, an explicit "not null" is required. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/

[Ada] Add centralized capacity check in Generic_Bignums

2020-07-16 Thread Pierre-Marie de Rodat
This replaces the special case done in "**" so far. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-genbig.adb ("**"): Remove capacity limit check. Improve code by using an extended return. (Normalize): Perform capacity limit check here instead whic

[Ada] Spurious accessibility error on allocator in generic instance

2020-07-16 Thread Pierre-Marie de Rodat
This patch fixes an error in the compiler whereby an allocator for a limited type may cause spurious accessibility errors due to a miscalculation of access levels on internally generated temporaries within the instance. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4

[Ada] Spurious redundant use clause warning

2020-07-16 Thread Pierre-Marie de Rodat
The recent change in Exp_Ch3.Freeze_Type exposes a latent issue in Sem_Ch8.Note_Redundant_Use when Load_RTU triggers at the wrong time, causing spurious redundant use clause warnings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Note_Redundant_Use): Add missi

[Ada] Handle N_Others_Choice case in range-building function

2020-07-16 Thread Pierre-Marie de Rodat
GNAT crashes when building static predicate functions out of a case expression that contain an "others" clause. This is because it attempts to call Is_OK_Static_Expression() on the N_Others_Choice of the case expression when trying to figure out whether the case is exhaustive or not. Fixing requir

[Ada] Disable Initialize_Scalars on runtime files

2020-07-16 Thread Pierre-Marie de Rodat
To avoid creating circular dependencies between runtime units and to allow compiling e.g. GNAT with Initialize_Scalars. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * frontend.adb: Disable Initialize_Scalars on runtime files.diff --git a/gcc/ada/frontend.adb b/gcc/ada/front

[Ada] Ada2020: AI12-0107 convention of By_Protected_Procedure

2020-07-16 Thread Pierre-Marie de Rodat
A prefixed view of a subprogram with aspect Synchronization being By_Protected_Procedure has convention protected. This new feature is documented in AI12-0107. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Has_By_Protected_Procedure_Prefixed_View): New

[Ada] AI12-0042: Type invariant checking rules

2020-07-16 Thread Pierre-Marie de Rodat
AI12-0042 specifies a couple of new rules for type invariants. The first is that when a type extension inherits a nonabstract subprogram that is a private operation of an ancestor type that has a class-wide invariant and the parent subprogram is visible at that point, the subprogram must be overrid

[Ada] Overflow in string streaming

2020-07-16 Thread Pierre-Marie de Rodat
The routine to output strings in an optimized manner has an overflow error in case of very large strings. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-ststop.ads: Fix typo. * libgnat/s-ststop.adb (Read, Write): Fix block number computation to avo

[Ada] gnatbind: Fix No_Entry_Calls_In_Elaboration_Code message

2020-07-16 Thread Pierre-Marie de Rodat
This patch fixes a bug where gnatbind would suggest adding the No_Entry_Calls_In_Elaboration_Code restriction, when that restriction is already present. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * bindo-diagnostics.adb (Output_Invocation_Related_Suggestions): Use

[Ada] Implicit dereferencing in container indexing

2020-07-16 Thread Pierre-Marie de Rodat
The compiler was disallowing an access to a container to be used as the prefix of an indexing of the container, but implicit dereferencing is allowed in such a context (basically because a prefix can be an implicit_dereference, by RM 4.1(4); a Ramification note was added in RM 4.1.6(11.a/5), to cla

[Ada] Misplace of internal master renaming declaration

2020-07-16 Thread Pierre-Marie de Rodat
This patch fixes a regression introduced by the recent work done for tagged type constructors with task components. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Expand_N_Full_Type_Declaration): Ensure a _master declaration on limited types that might

[Ada] AI12-0004 Normalization and allowed characters

2020-07-16 Thread Pierre-Marie de Rodat
This Ada AI clarifies that Ada identifiers that contain characters that are not allowed in Normalization Form KC are illegal. It also introduces a new function Is_NFKC. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * scng.adb (Scan): Detect wide characters not in NFKC.

[Ada] Ongoing work for AI12-0212 : container aggregates

2020-07-16 Thread Pierre-Marie de Rodat
This patch adds support for indexed aggregates with both positional components and component associations that include multiple choices and range specifications. For indexed aggregates the expansion uses a separate pass, as suggested in AI12-0212, to compute the size of the resulting object and pre

[Ada] Spurious error in instance nested in formal package

2020-07-16 Thread Pierre-Marie de Rodat
This patch removes a spurious error in a compilation of a generic body GB that includes a formal package whose source GF includes a nested generic package NGF, and GB includes instances of NGF and of further generic units declared within NGF. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/

[Ada] AI12-0132 Freezing of renames_as_body

2020-07-16 Thread Pierre-Marie de Rodat
This AI clarifies that a renames-as-body freezes the expression of any expression function that it renames. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Analyze_Subprogram_Renaming): A renames-as-body freezes the expression of any expression function

[Ada] Set missing Parent field of block entity

2020-07-16 Thread Pierre-Marie de Rodat
This sets the Parent field of the block entity created in the case of a statement sequence by Expand_N_Accept_Statement to the newly created block statment, as done for example in Add_Block_Identifier. This is needed in peculiar cases where the block contains instantiations of packages with generi

[Ada] Ada2020: AI12-0117 Restriction No_Tasks_Unassigned_To_CPU

2020-07-16 Thread Pierre-Marie de Rodat
Implement the No_Tasks_Unassigned_To_CPU restriction. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnatbind.adb (Gnatbind): For No_Tasks_Unassigned_To_CPU, check that CPU has been set on the main subprogram. (Restriction_Could_Be_Set): Don't print

[Ada] Adjust heuristics about size of static aggregates

2020-07-16 Thread Pierre-Marie de Rodat
This patch adjusts the heuristics about the size of static aggregates, which determine whether an aggregate should be statically allocated. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Max_Aggregate_Size): Use the small size of 64 when copying is nee

[Ada] Wrong execution of Tan on large argument

2020-07-16 Thread Pierre-Marie de Rodat
The custom implementation of Tan in a-numaux__x86.adb has some holes for large values and will e.g. produce the wrong result on Tan (16367173.0 * 2.0**72). This is fixed by replacing the use of a-numaux__x86 by a-numaux__libc-x86.ads. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] x86-lynx178elf: use a-numaux.ads instead of a-numaux__libc-x86.ads

2020-07-27 Thread Pierre-Marie de Rodat
a-numaux__libc-x86.ads wraps around long double trig functions that Lynx178 does not have, so use the default a-numaux.ads instead to match what is offered on Lynx178. This is done by removing X86_TARGET_PAIRS from the x86-lynx178elf configuration as it is now redundant: the default a-numaux pacak

[Ada] AI12-0382: Loosen type-invariant overriding requirement of AI12-0042

2020-07-27 Thread Pierre-Marie de Rodat
The requirement for overriding an inherited visible private operation when extending from an ancestor that specifies Type_Invariant'Class as specified in RM 7.3.2(6.1/4) (AI12-0042) was unintentionally overrestrictive. The rule is loosened by AI12-0382 so that it only applies to type extensions th

[Ada] Warnings on overloays involving generic In_Parameters

2020-07-27 Thread Pierre-Marie de Rodat
Warnings aare emitted when a declaration for a constant C has an address aspect or an address_specification clause of the form O'Address, where O is a previously declared entity that is not a constant, The warning must br supppressed if O is a generic formal In_Parameter, which is a constant within

[Ada] Add range check for GNATprove on 'Pos to Long_Integer conversion

2020-07-27 Thread Pierre-Marie de Rodat
In GNAT mode attribute Pos is typically expanded into either a type conversion (unless applied to enumeration types with custom representation values) and analysis of this type conversion adds check flags as required. In GNATprove mode we expand the attribute with Apply_Universal_Integer_Attribute

[Ada] AI12-0194: Language-defined aspects and entry bodies

2020-07-27 Thread Pierre-Marie de Rodat
AI12-0194 specifies that language-defined aspects aren't permitted on entry bodies, which is already effectively enforced by GNAT, however the error message given when Max_Entry_Queue_Length is applied to an entry body is potentially confusing, because it says that the aspect "must apply to a prote

[Ada] Unbounded string overriding control

2020-07-27 Thread Pierre-Marie de Rodat
Unbounded string operation has to raise Constraint_Error if resulting string going to be over Integer'Last length. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strunb.adb (Sum, Mul, Saturated_Sum, Saturated_Mul): New routines. Use them when resulting st

[Ada] Ada2020: wording of 'Image messages

2020-07-27 Thread Pierre-Marie de Rodat
Change the wording of error messages about 'Image to indicate that newer versions of the language allow more cases. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.ads, errout.adb (Error_Msg_Ada_2020_Feature): New procedure analogous to Error_Msg_Ada_2012_Feat

[Ada] Remove disabled code

2020-07-27 Thread Pierre-Marie de Rodat
This old code is likely made obsolete by recent changes related to the handling of the universal access "=" operator. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_attr.adb (Resolve_Attribute): Remove dead code.diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb -

[Ada] Remove obsolete special case in Switch_View

2020-07-27 Thread Pierre-Marie de Rodat
This removes obsolete code that would prevent a subtype dependent on a private type from having its views switched when those of the private type are switched by Switch_View. Not switching the views in this case is problematic because this is not in keeping with what the mechanism based on Install

[Ada] Ada2020: AI12-0304 Put_Image attrs of lang-def types

2020-07-27 Thread Pierre-Marie de Rodat
Implement Put_Image for the random number packages and for Ada.Containers.Vectors. More to come. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-rannum.ads, libgnat/s-rannum.adb: Add Put_Image. This will be inherited by the language-defined packages

[Ada] Bug in Enum_Subtype'Image in Ada 2020 mode

2020-07-27 Thread Pierre-Marie de Rodat
This patch fixes a bug in which Enum_Subtype'Image, where Enum_Subtype is a non-first subtype of an enumeration type, would return the image of the 'Pos -- that is, an integer instead of the text of the enumeration literal. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp

[Ada] AI12-0383 Renaming values

2020-07-27 Thread Pierre-Marie de Rodat
This AI allows names that denote values rather than objects to nevertheless be renamed using an object renaming. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch8.adb (Analyze_Object_Renaming): Allow values in Ada 2020 mode.diff --git a/gcc/ada/sem_ch8.adb b/gc

[Ada] AI12-0377 View conversions and out parameters revisited

2020-07-27 Thread Pierre-Marie de Rodat
This AI refines AI12-0074 to disallow cases of potential de-initializing of out parameters. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Actuals): Refine 6.4.1 rules as per AI12-0377.diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb --- a

[Ada] Wrong accessibility on 'Access of formal in call

2020-07-27 Thread Pierre-Marie de Rodat
This patch fixes a bug in the compiler whereby taking 'Access on a component of an anonymous access formal parameter and using such an expression as an actual in a call where the corresponding formal is also an anonymous access type will cause dynamic accessibility checks within the callee function

[Ada] Revert "Revamp dump and aux output names"

2020-07-27 Thread Pierre-Marie de Rodat
This reverts commit 593627b4562814d2206e53e9ad6ce2e85295aa58. That commit was installed in GCC by mistake, bringing it in sync with an earlier, internal transitory state that had just been resolved in a separate patch. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * switch.

[Ada] Switch Ada_Version_Runtime to Ada 2020

2020-07-27 Thread Pierre-Marie de Rodat
Now that we're adding more and more Ada 2020 specific aspects in runtime units, this is the convenient thing to do. Note that this doesn't impact the Ada version used by user code. Also fix a latent bug in sem_ch3 along the way, showing up when System.Atomic_Primitives generic children are compile

[Ada] Refactor pragma argument getters

2020-07-27 Thread Pierre-Marie de Rodat
This refactoring replaces exp_prag.adb's Arg1, Arg2 and Arg3 functions with a new function Arg_N which enables fetching any pragma arguments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_prag.adb (Arg1, Arg2, Arg3): Removed. (Arg_N): New function.diff --git a/

[Ada] Replace in Ordered_Maps gets tampering failure

2019-10-10 Thread Pierre-Marie de Rodat
This patch fixes a bug in which a call such as Some_Map.Replace(10, Some_Map(5)) fails a tampering check. This happens with the Some_Map(5) notation, or with the equivalent explicit call to Constant_Reference. A call to Some_Map.Delete(10, Some_Map(5)) fails in the same way. Other children of Ada.C

[Ada] Spurious visibility error in predicate in generic instance

2019-10-10 Thread Pierre-Marie de Rodat
Compilation_Unit pragmas that appear after the corresponding unit are analyzed before the declarations in the unit, in order to set proper categorization flags and verify that they are respected by those declarations. If the unit is a child unit and also the instance of a generic child unit the par

[Ada] Use declared type for deciding on SPARK pointer rules

2019-10-10 Thread Pierre-Marie de Rodat
A constant of pointer type is considered as mutable in SPARK, according to SPARK RM 3.10, but this should be based on the declared type of the constant instead of its underlying type. This rule has been already reflected in a recent commit for the Depends contract; this commit is for the Global co

[Ada] 'others' in conditional_expressions

2019-10-10 Thread Pierre-Marie de Rodat
This patch fixes a bug in which an 'others' array aggregate in a dependent_expression of a conditional_expression is rejected, even in cases where 'others' is legal. See RM-4.3.3(15.1). Running this command: gcc -c others_test.ads On the following sources: package Others_Test is X : Strin

[Ada] T'Size in pragma Compile_Time_Error

2019-10-10 Thread Pierre-Marie de Rodat
If a pragma Compile_Time_Error contains T'Size, then T'Size can be computed as 0 instead of the correct value, causing missing or extra error messages. The same applies to pragma Compile_Time_Warning. This patch fixes that bug. Running these commands: gcc -c -g -O0 -gnata fillers-neq_error.ads

[Ada] Plug minor loophole for integer named number

2019-10-10 Thread Pierre-Marie de Rodat
Analyze_Number_Declaration contains a fast track for the case where the expression of an integer named number is a literal, but it fails to set the Debug_Info_Needed flag on the named number. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-10-10 Eric Botcazou gc

[Ada] Flag Sec_Stack_Used incorrectly set by ghost code

2019-10-10 Thread Pierre-Marie de Rodat
Correct an issue where ghost code will set the flag Sec_Stack_Used even though the code will be eliminated and result in the program not using the secondary stack. This could confuse the binder into importing objects from System.Secondary_Stack even though that package is not in the program's closu

[Ada] Fix awkward placement of freeze node for actual subtype

2019-10-10 Thread Pierre-Marie de Rodat
In the case where the tyoe of the formal has a predicate, the compiler generates a freeze node for the actual subtype of the formal that is placed just before the declaration of that subtype. No big deal, but awkward enough as to warrant a correction. No functional changes. Tested on x86_64-pc-l

[Ada] Spurious restriction violation on Ghost code

2019-10-10 Thread Pierre-Marie de Rodat
This patch fixes a spurious error when expanding the code for a function that appears in a Ghost context, when return return type of the function is unconstrainedm and the restriction No_Secondary_Stack is active. Running this command: gcc -c repro_main.adb On the following sources: with Boun

[Ada] Spurious visibility error on formal package with Abstract_State

2019-10-10 Thread Pierre-Marie de Rodat
Compiler rejects a formal package in a generic unit, when the corresponding generic package includes the SPARK aspect Abstract_State, and the name introduced by the aspect is referenced in the generic package. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-10-10 Ed Schonberg gcc/ada/

[Ada] Do not inline subprograms with deep parameter/result in GNATprove

2019-10-10 Thread Pierre-Marie de Rodat
Subprograms with a parameter or function result with deep type should not be inlined in the special mode for GNATprove, as inlining may lead to spurious violations of SPARK borrow-checking rules for pointers. There is no impact on compilation and thus no test. Tested on x86_64-pc-linux-gnu, commi

[Ada] Ensure constructor is a C++ constructor

2019-10-10 Thread Pierre-Marie de Rodat
Freeze_Subprogram has special handling of C++ constructor interfacing. This is currently implicit but assuming we introduce other conventions (e.g. Java) the current code won't hold. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-10-10 Arnaud Charlet gcc/ada/ * freeze.adb (Fr

[Ada] Handling up-level references in loops within library-level declarations

2019-10-10 Thread Pierre-Marie de Rodat
For GNAT-LLVM, we now wrap top-level loop statements in library package declaration lists within a procedure when there are nested subprograms within the loop that might make up-level references to entities of the loop (or to entities of loops and blocks nested within the outer loop for that matter

[Ada] Assertion_Policy (Ignore) ignores invariants

2019-10-10 Thread Pierre-Marie de Rodat
A pragma Assertion_Policy (Ignore) was ignored with respect to invariants; invariants are checked even in the presence of this pragma. This patch fixes that bug. Running these commands: gcc -S -fverbose-asm -g ess-main.adb -gnata grep Invariant ess-main.s On the following sources: pragma As

[Ada] Fix inlining of subprograms with deep param/result in GNATprove

2019-10-10 Thread Pierre-Marie de Rodat
In the special inlining done for GNATprove, subprograms with parameters or result of deep type (i.e. containing an access type) should not be inlined. This was the purpose of a previous patch. But this should not be applied to private types whose completion has SPARK_Mode Off, as these types are no

[Ada] Add pragma Preelaborable_Initialization to Stream_IO.File_Type

2019-10-10 Thread Pierre-Marie de Rodat
Pragma Preelaborable_Initialization is added to type File_Type in package Ada.Streams.Stream_IO, per the Binding Interpretation of AI12-0102. No other source or tool changes are required. No test needed. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-10-10 Gary Dismukes gcc/ada/

[Ada] Generation of procedures for blocks occurring in elaboration code for LLVM

2019-10-10 Thread Pierre-Marie de Rodat
For compilers such as GNAT-LLVM that requiring unnesting of subprograms that make up-level references, the GNAT front end needs to check for block statements occurring within elaboration of library-level packages, and transform those into procedures that can be passed an activation-record parameter

[Ada] Unnesting issues with entry families and accept statements

2019-10-10 Thread Pierre-Marie de Rodat
The case of a protected entry family body with a nested subprogram wasn't recognized for purposes of unnesting, leading to unhandled up-level references, because Has_Nested_Subprogram was incorrectly returning False. This was due to Set_Has_Nested_Subprogram not being called on the procedure create

[Ada] Spurious warning on call with out parameter in expression function

2019-10-10 Thread Pierre-Marie de Rodat
If the exprsssion in an expression function includes a function call with an out-parameter, the corresponding assignment may be flagged as redundant because it is analyzed twice, once in the expression function and once in the body constructed for it. Running this command: gcc -c -gnatg warn.ad

[Ada] Get rid of spurious error for _Tag on extension with reverse bit order

2019-10-10 Thread Pierre-Marie de Rodat
This prevents the compiler from issuing a spurious error for the _Tag component of a tagged record extension if the parent type has a Bit_Order clause specifying the reverse order and a component clause. The cause is a simple off-by-one bug in the artificial component clause synthetized for the _Ta

[Ada] Change pragma Compile_Time_Error to force compile-time evaluation

2020-05-25 Thread Pierre-Marie de Rodat
Issue an error now when the expression in pragma Compile_Time_Error cannot be evaluated at compile time. This allows static analyzers like GNATprove to rely on such expressions always being False. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-05-25 Yannick Moy gcc/ada/ * doc

[Ada] Fix spurious error on checking of null Abstract_State

2020-05-25 Thread Pierre-Marie de Rodat
A declaration of an object inside a declare block of elaboration code should not count as hidden state of the package. Nor should declarations inside a task or an entry. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-05-25 Yannick Moy gcc/ada/ * sem_util.adb (Check

[Ada] Spurious accessibility error on return aggregate in GNATprove mode

2020-05-25 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby valid actuals within return aggregates could trigger spurious accessibility errors in GNATprove mode. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-05-25 Justin Squirek gcc/ada/ * sem_ch6.adb (Check_Return_Obj_Accessibility): Use original

[PATCH 1/2] gcc-changelog: remove file descriptor leaks

2020-05-26 Thread Pierre-Marie de Rodat
Currently, running gcc-changelog's unit tests may clutter the output with tons of warnings such as: .../contrib/gcc-changelog/git_email.py:40: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/tmpt5okd4qp.patch' mode='r' encoding='UTF-8'> lines = open(self.filename).re

[PATCH 2/2] gcc-changelog: handle entries with multi-line file lists

2020-05-26 Thread Pierre-Marie de Rodat
This extends the ChangeLog entries parsing machinery to handle entries that cover multiple files spanning over multiple lines. For instance: * first_file_patched.c, second_file_patched.c, third_file_patched.c, fourth_file_patched.c: Do things. contrib/ * gcc-changelog/git_commit.

Re: [PATCH 1/2] gcc-changelog: remove file descriptor leaks

2020-05-26 Thread Pierre-Marie de Rodat
On 26/05/2020 17:04, Martin Liška wrote: Oh, that's new for me. I've never seen the warning. Please install the patch. That was the first time I saw it as well. :-) I just pushed the commit on master. -- Pierre-Marie de Rodat

Re: [PATCH 2/2] gcc-changelog: handle entries with multi-line file lists

2020-05-26 Thread Pierre-Marie de Rodat
install it with the change. Done and pushed. Thank you for the quick review! -- Pierre-Marie de Rodat

[PATCH] gcc-changelog: enhance handling of renamings

2020-05-27 Thread Pierre-Marie de Rodat
So far, we expect from a commit that renames a file to contain a changelog entry only for the new name. For example, after the following commit: $ git move foo bar $ git commit We expect the following changelog: * bar: Renamed from foo. Git does not keep track of renamings, only file d

Re: [PATCH] gcc-changelog: enhance handling of renamings

2020-05-28 Thread Pierre-Marie de Rodat
t. We'll need here a skip based on version of unidiff. So something like: @pytest.mark.skipif ? I'm going to prepare a counter-part for mklog that can also handle file renaming. Thanks! The updated patch is attached. -- Pierre-Marie de Rodat >From 42b48c97cb30bcc1b05679ced3cb946551b

Re: [PATCH] gcc-changelog: enhance handling of renamings

2020-05-28 Thread Pierre-Marie de Rodat
On 28/05/2020 11:09, Martin Liška wrote: On 5/28/20 11:05 AM, Pierre-Marie de Rodat wrote: Thanks! The updated patch is attached. The patch is fine, please install it. Now pushed. Thank you again. -- Pierre-Marie de Rodat

[Ada] Reuse Is_Package_Or_Generic_Package where possible

2020-06-02 Thread Pierre-Marie de Rodat
Replace a low-level Ekind_In with a high-level Is_Package_Or_Generic_Package wrapper where possible. Arguably the wrapper was introduced to make the code easier to read, so let's use it; semantics is unaffected. Modified expressions were detected with: $ grep "Ekind_In " *|grep E_Package|grep E

[Ada] Do not set the bounds of integer types to be universal

2020-06-02 Thread Pierre-Marie de Rodat
This changes the type set on the bounds of signed integer types declared by the programmer: instead of Universal_Integer, it is set to the anonymous base type created by the declaration. The reason is that Universal_Integer must be a type as large as the largest supported integer type and, therefo

[Ada] Fix bogus error for clause on derived type with variant part

2020-06-02 Thread Pierre-Marie de Rodat
This prevents the compiler from giving a bogus error message on the representation clause specified for a discriminated record type that is derived from an untagged discriminated record type with a variant part, when the representation clause gives overlapping positions to components in different v

[Ada] Fix small oversight in latest change for Replace_Discriminants

2020-06-02 Thread Pierre-Marie de Rodat
This prevents the compiler from giving a bogus error on a discriminated record type derived from an untagged discriminated record type with a variant part, when the subtype of the discriminant of the former is more constrained than that of the latter and the variant part contains a discrete choice

[Ada] Use Standard.Natural on indices in support routines for Ada.Tags

2020-06-02 Thread Pierre-Marie de Rodat
This changes the type set on indices and ranges that are made of integer literals in the support routines for Ada.Tags generated during expansion: instead of Universal_Integer, it is set to Standard.Natural, which is the index type used in a-tags.ads. The reason is that Universal_Integer must be a

[Ada] Unnesting bugs with array renamings generated for quantified expr

2020-06-02 Thread Pierre-Marie de Rodat
A quantified expression for an array object within a postcondition (and presumably in other contexts) results in the creation of a renaming of the array object (such as the formal parameter of the enclosing postcondition procedure), and when the array's corresponding subtype has nonstatic bounds th

[Ada] Fix minor discrepancy in Expand_N_Attribute_Reference

2020-06-02 Thread Pierre-Marie de Rodat
This fixes a minor discrepancy in Expand_N_Attribute_Reference, which still thinks that the Alignment primitive operation for tagged types is a function call returning Integer, while it's a selected component returning Natural these days. No functional changes. Tested on x86_64-pc-linux-gnu, comm

[Ada] Remove dead code for detecting hidden package state

2020-06-02 Thread Pierre-Marie de Rodat
When climbing the chain of scopes (using Sinfo.Scope) we always process unique entities, e.g. an E_Procedure even for entities that syntactically reside in E_Subprogram_Body; same for tasks, entries and packages. There is no need to expect E_Package_Body, because it never occurs. The removed dead

[Ada] Use Standard.Natural on bit references to packed arrays

2020-06-02 Thread Pierre-Marie de Rodat
This changes the type set on bit references made to packed arrays: instead of Universal_Integer, it is set to Standard.Natural. The reason is that Universal_Integer must be a type as large as the largest supported integer type and, therefore, can be much larger than what is really needed here. No

[Ada] ICE during unnesting when nested subprograms have address taken

2020-06-02 Thread Pierre-Marie de Rodat
When doing subprogram unnesting for GNAT-LLVM (or CCG), the compiler can crash when it tries to access an unreachable enclosing subprogram that contains nested subprograms that are marked reachable due to having Access or Unchecked_Access applied to them. This is fixed by ensuring that the subprogr

[Ada] Remove degenerate Treat_Fixed_As_Integer mechanism

2020-06-02 Thread Pierre-Marie de Rodat
The Treat_Fixed_As_Integer mechanism has been degenerate for quite some time and the flag is only set on divide nodes at this point. We can use the same trick as in the multiply case to get rid of it altogether, with the positive by-product that the compiler will stop doing divisions of small fixe

[Ada] Statement SCO code for degenerate subprograms

2020-06-02 Thread Pierre-Marie de Rodat
Use statement SCO code 'X' to specifically identify the statement SCOs for degenerate subprogram bodies (null procedures and expression functions). This allows coverage analysis tools to apply specific processing for these cases if necessary, and ensures consistency with SCOs generated through sour

[Ada] Accept objects from nested packages in Initializes contract

2020-06-02 Thread Pierre-Marie de Rodat
Objects and abstract states declared in nested packages should be allowed to appear in the Initializes contract of the enclosing package. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-02 Piotr Trojanek gcc/ada/ * sem_prag.adb (Collect_States_And_Objects): Call itself on

[Ada] Compiler crash processing controlled type primitive

2020-06-02 Thread Pierre-Marie de Rodat
The compiler crashes processing the body of dispatching primitive that is a function whose controlling type is a tagged private type and its full view is a derivation of a controlled type. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-02 Javier Miranda gcc/ada/ * sem_util

[Ada] Get rid of more references to Universal_Integer in expanded code

2020-06-02 Thread Pierre-Marie de Rodat
This further tweaks the expanded code generated by the front-end, so as to avoid having references to Universal_Integer reaching the code generator, either directly or indirectly through attributes returning Universal_Integer. The reason is that Universal_Integer must be a type as large as the lar

<    2   3   4   5   6   7   8   9   10   11   >