[Ada] Postcondition checks performed before finalization

2020-12-15 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby postconditions were incorrectly checked prior to the execution of finalization. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * contracts.adb, contracts.ads (Build_Postconditions_Procedure): Add declarations for Postc

[Ada] Fix serial port baud rate setting on GNU/Linux

2020-12-15 Thread Pierre-Marie de Rodat
This fixes an issue when setting the baud rate. The baud rate is set using the cfsetospeed and cfsetispeed system calls. The code is using speed_t for clarity. The non-blocking status is only reset when Block is True. And serial blocking mode is now properly set according to termios manual. Add do

Re: [Ada] Fix serial port baud rate setting on GNU/Linux

2020-12-16 Thread Pierre-Marie de Rodat
incremental builds. The actual correction is a few patches later in my porting queue: I’m about to commit it. Sorry for the trouble! -- Pierre-Marie de Rodat

[Ada] Another small adjustment to System.Value_R

2020-12-16 Thread Pierre-Marie de Rodat
This makes the code more explicit for the sake of static analyzers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valuer.adb (Scan_Decimal_Digits): Tweak overflow test. (Scan_Integral_Digits): Likewise.diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/l

[Ada] Add some OS constants to control serial port

2020-12-16 Thread Pierre-Marie de Rodat
This adds some OS constants that are needed to control the serial port on GNU/Linux. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * s-oscons-tmplt.c: Add some OS constants.diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c --- a/gcc/ada/s-oscons-tmplt.c +++ b/

[Ada] Mark generic body outside of SPARK

2020-12-16 Thread Pierre-Marie de Rodat
Unit Ada.Text_IO.Fixed_IO is now generic, which makes it necessary to exclude the generic body from SPARK explicitly because it uses type Long_Long_Float which is not supported in GNATprove. This ensures that the unit can be instantiated from SPARK code. Tested on x86_64-pc-linux-gnu, committed on

[Ada] Reject junk syntax for Contract_Cases/Test_Case/Subprogram_Variant

2020-12-16 Thread Pierre-Marie de Rodat
Reject contracts Contract_Cases, Test_Case and Subprogram_Variant whose expression is either "null", "(null record)" or has extra parentheses. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Analyze_Aspect_Specifications): Add a codefix for extra parent

[Ada] Fix gmem.out corruption by GNAT.Expect

2020-12-16 Thread Pierre-Marie de Rodat
GNAT.Expect.Non_Blocking_Spawn executes memory allocation/deallocation after calling fork on the child process side. The libgmem library could write to the same gmem.out file in the parent and child processes simultaneously before the child process would load and initialize the new executable file.

[Ada] Fix glitch in comment of System.Powten_Table

2020-12-16 Thread Pierre-Marie de Rodat
There is a typo in the formula to compute Maxpow exposed in the comment. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-powtab.ads (Maxpow): Use explicit formula in comment.diff --git a/gcc/ada/libgnat/s-powtab.ads b/gcc/ada/libgnat/s-powtab.ads --- a/gcc/ada/libg

[Ada] Fix integer-vs-float errors in example for Test_Case pragma

2020-12-16 Thread Pierre-Marie de Rodat
The example for Test_Case pragma was rejected by the compiler; now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst (Test_Case): Change integer to float literals. * gnat_rm.texi: Regenerate.diff --git a/gcc

[Ada] Fix possible uninitialized ATCB component use

2020-12-16 Thread Pierre-Marie de Rodat
When System.Memory implementation is using Debug_Pools, Common ATCB's uninitialized Global_Task_Lock_Nesting component may be used. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnarl/s-tporft.adb (Register_Foreign_Thread): Set Global_Task_Lock_Nesting before us

[Ada] Simplify membership tests with N_Subprogram_Call subtype

2020-12-16 Thread Pierre-Marie de Rodat
Simplify membership test on N_Procedure_Call_Statement and N_Function_Call using the collective N_Subprogram_Call subtype. Cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch6.adb, exp_util.adb, sem_ch4.adb, sem_disp.adb, sem

[Ada] Avoid artificial underflow in System.Val_Real

2020-12-16 Thread Pierre-Marie de Rodat
The final computation now needs to be protected against artificial underflow when the value is very small. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valrea.adb (Maxexp32): New constant array. (Maxexp64): Likewise. (Maxexp80): Likewise.

[Ada] Refine types of variables for parsing formal object declarations

2020-12-16 Thread Pierre-Marie de Rodat
Local variables in parsing of formal object declarations take only positive values, so their types can be narrowed to Pos. Cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch12.adb (P_Formal_Object_Declarations): Refine types to

[Ada] Fix memory leak in GNAT.Expect.Non_Blocking_Spawn on Windows

2020-12-16 Thread Pierre-Marie de Rodat
It is not leaking on Linux because the memory heap is reinitialized when the new executable is loaded into the child process after calling fork. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/g-expect.adb (Non_Blocking_Spawn): Deallocate elements on Arg_List

[Ada] Remove inconsistent colons in messages for Ada 83 violations

2020-12-16 Thread Pierre-Marie de Rodat
Most of the errors of the form "(Ada 83) ..." don't have a colon; fix inconsistencies. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch3.adb (P_Modular_Type_Definition): Remove colon from error message. * sem_ch11.adb (Check_Duplication): Likewise.

[Ada] Fix typo in checks for implementation defined units

2020-12-16 Thread Pierre-Marie de Rodat
Fix mismatch in iterating over a range for Ada 2012 and referencing an array for Ada 95. This didn't affect the behaviour, because the referenced boolean flags in both arrays were the same for the iterated subrange. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * impunit.adb

[Ada] Simplify membership tests with N_Delay_Statement subtype

2020-12-16 Thread Pierre-Marie de Rodat
Simplify membership test on N_Delay_Relative_Statement and N_Delay_Until_Statement using the collective N_Delay_Statement subtype. Cleanup only; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch9.adb, sem_warn.adb: Simplify membership test.diff

[Ada] Code cleanup: rename ALI.Scope

2020-12-16 Thread Pierre-Marie de Rodat
Rename it to IS_Scope so that calling scope (node) under gdb is unambiguous, so ease debugging sessions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ali.ads, ali.adb, bindo-writers.adb, lib-writ.adb (Scope): Renamed to IS_Scope.diff --git a/gcc/ada/ali.adb b/gcc/

[Ada] Add contracts to Ada.Strings.Fixed

2020-12-16 Thread Pierre-Marie de Rodat
This adds complete postconditions and contract cases to subprograms in Ada.Strings.Fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strfix.ads: Add postconditions and contract cases to subprograms. patch.diff.gz Description: application/gzip

[Ada] Handle iterator filters on loop specifications over containers

2020-12-16 Thread Pierre-Marie de Rodat
A loop parameter specification over a container is rewrtten as an iterator specification, so that expansion can use the Iterator opwrations declared for the container type. If an Ada2020 interator filter appears on the loop_parameter_specification it must be transfered to the iterator, and preanaly

[Ada] armhf-linux: symbolic tracebacks

2020-12-16 Thread Pierre-Marie de Rodat
Implement symbolic tracebacks on armhf-linux. It's an ELF target so just a matter of some bookkeeping changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-objrea.ads (Object_Arch): Add ARM enum * libgnat/s-objrea.adb (Initialize): Add EM_ARM case.

Re: [Ada] Fix serial port baud rate setting on GNU/Linux

2020-12-16 Thread Pierre-Marie de Rodat
On Wed, Dec 16, 2020 at 1:18 PM Pierre-Marie de Rodat wrote: > Thank you. I can reproduce the issue: at this point I suspect that my > testing hasn’t detected this because of some inconsistency with my > incremental builds. The actual correction is a few patches later in my > portin

[Ada] Assert failure on b38105a in -gnat95 mode

2020-12-17 Thread Pierre-Marie de Rodat
A cascaded error leads to some confusion in this case, fixed by making Inherit_Predicate_Flags a no-op pre Ada 2012. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Inherit_Predicate_Flags): No-op before Ada 2012.diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_

[Ada] Spurious error on Type'Access and <>

2020-12-17 Thread Pierre-Marie de Rodat
When mixing the <> in an aggregrate and the default initialization of the Type involved by the box references Type'Access, GNAT may generate a spurious error of the form: "Access" attribute cannot be applied to type Fixed by only considering nodes that come from source in this legality check:

[Ada] Fixes for GNAT error/warning messages

2020-12-17 Thread Pierre-Marie de Rodat
These fixes aim at making GNAT messages more readable and uniform, just by following the current rules generally followed for messages: - start with a lowercase character - use ALL CAPITAL for keywords (so that they are properly quoted in the final message), Capitalized attribute/pragma names - u

[Ada] Compiler crash on protected component of controlled type

2020-12-17 Thread Pierre-Marie de Rodat
When declaring a component of a protected type as part of a controlled type, the compiler may crash trying to generate the finalize routine. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb (Make_Final_Call, Make_Init_Call): Take protected types into accou

[Ada] Spurious discriminant check on bounded synchronized queue

2020-12-17 Thread Pierre-Marie de Rodat
An improper run-time error is raised on a bounded synchronized queue when the container element is a discriminated type that is itself a bounded container. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cbsyqu.ads (Implementation): Provide a box initializa

[Ada] Do not generate encodings for fixed-point types by default

2020-12-17 Thread Pierre-Marie de Rodat
This flips the default for the generation of encodings for fixed-point types in the debugging information generated by the compiler. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_dbug.adb (Get_Encoded_Name): Generate encodings for fixed point types only if -fgn

[Ada] Crash on discriminant check with current instance

2020-12-17 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby a reference to the current instance of the type occurring within a subtype contraint causes a crash during backend expansion of associated discriminant checks. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Build

[Ada] Do not use exponentiation for common bases in floating-point Value

2020-12-17 Thread Pierre-Marie de Rodat
This changes the implementation of the Value attribute for floating-point types not to use exponentiation to compute the final value, at least for the common bases 2, 4, 8, 10 and 16. The powers of two use the Scaling attribute instead, while a precomputed table of powers is used for 10. The first

[Ada] Move folding of unchecked conversions from expansion to evaluation

2020-12-17 Thread Pierre-Marie de Rodat
Discrete values in unchecked conversions were only folded when compiling. Now they are also folded in GNATprove and semantics checking modes (-gnatc). This is particularly important for calls to static functions, since unchecked conversions are likely to appear for their actual parameters or resu

[Ada] Consistent wording for missing -gnat2020 switch

2020-12-17 Thread Pierre-Marie de Rodat
Reuse Error_Msg_Ada_2020_Feature to complain about a missing -gnat2020 switch when code that would be legal in Ada 2020 is compiled in an earlier language version. Also, refer to language construct and not to syntactic category of the missing feature, i.e. "declare expression" and not "declare_exp

[Ada] Ada2020: AI12-0400 Ambiguities associated with Vector

2020-12-17 Thread Pierre-Marie de Rodat
...Append and container aggregates. This patch implements the above AI, except we do not yet remove the Append procedures that append vectors (for compatibility reasons). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-cbdlli.adb, libgnat/a-cbdlli.ads, lib

[Ada] Prevent In_Check_Node routine from going too far in the parent chain

2020-12-17 Thread Pierre-Marie de Rodat
Routines that examine the parent chain of a subexpression don't need to cross the subprogram or package boundaries and go until the very root of the compilation unit. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (In_Check_Node): Add guard and rename Node to

[Ada] Better diagnostic for new language features

2020-12-17 Thread Pierre-Marie de Rodat
Complain about missing -gnat20xx switches when the code would be accepted in a newer version of Ada rather than silently rejecting it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * par-ch12.adb (P_Formal_Derived_Type_Definition): Complain about formal type with asp

[Ada] Prevent early exits without restoring a global variable

2020-12-17 Thread Pierre-Marie de Rodat
In Analyze_Case_Statement we save the current value of Unblocked_Exit_Count with the intention to restore it on exit. However, when returning early due to errors we failed to restore the previous value. It seems cleaner to only modify this variable after the possible early exits. Mainly just a cle

[Ada] Remove unused subprograms in validsw

2020-12-17 Thread Pierre-Marie de Rodat
Spotted by running GNATcoverage on GNAT sources, some subprograms are no longer used. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb: Remove, not used. * checks.ads: Likewise. * exp_ch6.adb: Likewise. * exp_ch7.adb: Likewise. * ex

[Ada] Code cleanup: remove Old_Requires_Transient_Scope

2020-12-17 Thread Pierre-Marie de Rodat
This temporary code kept 3+ years ago can now be removed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (New_Requires_Transient_Scope): Renamed Requires_Transient_Scope. (Requires_Transient_Scope, Old_Requires_Transient_Scope, Results_D

[Ada] Remove unused files

2020-12-17 Thread Pierre-Marie de Rodat
Spotted by running GNATcoverage on GNAT sources, some files are no longer used. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * symbols.ads, symbols.adb: Removed no longer used.diff --git a/gcc/ada/symbols.adb /dev/null deleted file mode 100644 --- a/gcc/ada/symbols.adb +++

[Ada] Crash on if expression inside declare expression

2020-12-17 Thread Pierre-Marie de Rodat
Combining an N_Expression_With_Actions within another N_Expression_With_Actions is causing inconsistencies and leads to dropping some actions on the floor. Fixed by creating a transient scope for declare expressions when needed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/

[Ada] Remove discriminant checks processing in gigi

2020-12-17 Thread Pierre-Marie de Rodat
There is a fallback code in gigi in case the front-end constructs trees referencing non existing record fields. At this stage, it's safer and cleaner to ensure that the front-end never generates such references, and eventually replace the code in gigi by a gcc_unreachable(). We are not quite there

[Ada] Performance of CW_Membership

2020-12-17 Thread Pierre-Marie de Rodat
CM_Membership is used implicitly by some tagged related constructs, and having it never inlined may cause performance issues, so move it to the spec by taking advantage of the recently added declare expressions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-tags.

[Ada] Refine type of a multi unit index number

2020-12-17 Thread Pierre-Marie de Rodat
With multi unit naming scheme (e.g. "unit.1.ada" and "unit.2.ada" instead of "unit.ads" and "unit.adb") the Multiple_Unit_Index global variable keeps the current index number. It is only assigned by routines that return non-negative numbers. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/a

[Ada] Fix socket timeout correction for Windows Server 2019 case

2020-06-08 Thread Pierre-Marie de Rodat
All Windows Servers till 2019 correcting the socket timeout for 500ms. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Dmitriy Anisimkov gcc/ada/ * socket.c (__gnat_minus_500ms): Remove IsWindowsVersionOrGreater from condition.--- gcc/ada/socket.c +++ gcc/ada/soc

[Ada] Add Depends contracts to Delete procedures of formal containers

2020-06-08 Thread Pierre-Marie de Rodat
Add a Depends contract to Delete procedures of formal containers to state that the output value of the Position cursor depends on no inputs (it is No_Element). This now ensures that no warnings will be emitted by GNATprove if this value is not used after a call to Delete. Tested on x86_64-pc-linux

[Ada] gnatbind: Deterministic No_Entry_Calls_In_Elaboration_Code messages

2020-06-08 Thread Pierre-Marie de Rodat
This patch fixes a bug in which the messages produced by gnatbind could be nondeterministic. In particular, the message: info: use pragma Restrictions (No_Entry_Calls_In_Elaboration_Code) could be missing, depending on details that should be irrelevant. Tested on x86_64-pc-linux-gnu, commit

[Ada] AI12-0226 Make objects more consistent

2020-06-08 Thread Pierre-Marie de Rodat
Clean up Analyze_Object_Renaming and Is_Object_Reference while implementing this new AI and recognize value conversion of objects as an object reference. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Arnaud Charlet gcc/ada/ * sem_ch8.adb (Analyze_Object_Renaming): Simp

[Ada] AI12-0309 Missing checks for pragma Suppress

2020-06-08 Thread Pierre-Marie de Rodat
Recognize (no-ops for now) new check names Program_Error_Check, Tasking_Check. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Arnaud Charlet gcc/ada/ * snames.ads-tmpl (Name_Program_Error_Check, Name_Tasking_Check): New constants. * types.ads (Program_Er

[Ada] Ada_2020: shared variable control aspects on formal derived types

2020-06-08 Thread Pierre-Marie de Rodat
This completes the implementation of AI12-0282, which allows variable control aspects to apply to formal types. This patch extends the implementation to handle properly formal derived types. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Ed Schonberg gcc/ada/ * par-ch12

[Ada] Reuse standard expansion of 'First and 'Last in GNATprove mode

2020-06-08 Thread Pierre-Marie de Rodat
Expansion of attribute Enum_Rep applied to First and Last attributes, both in the standard compilation mode and in the GNATprove mode, relies on those First and Last attributes being already expanded. However, they were only expanded in the standard compilation mode; now they are also expanded in t

[Ada] Reuse Get_Index_Subtype in the special expander for GNATprove

2020-06-08 Thread Pierre-Marie de Rodat
In the special expander that is only applied in GNATprove mode we had a code that duplicated Get_Index_Subtype routine from the standard expander. Now this routine is properly reused. Behaviour of both GNAT and GNATprove remains unchanged. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06

[Ada] Better code generation for nested aggregates

2020-06-08 Thread Pierre-Marie de Rodat
For aggregate components that are aggregates the frontend has been enhanced to evaluate if the inner aggregate depends on the variable being assigned to. This enhancement allows the compiler to avoid the generation of a temporary and thus generate better code for large nested aggregates. Tested on

[Ada] Do not warn on partial access to atomic object with address clause

2020-06-08 Thread Pierre-Marie de Rodat
This disables the warning given in the specific case of an atomic composite object subject to an address clause accessed partially, when the code is compiled in Ada 2020 mode, on the grounds that the semantics of these accesses to components of atomic composite objects is perfectly defined in Ada 2

[Ada] Issue with unnesting of 'First/Last and renaming

2020-06-08 Thread Pierre-Marie de Rodat
If we're doing 'First or 'Last on a renamed variable, the backend may look at either the Etype of the variable or that of what it was renaming, so check both to see if we need to place it into the activation record. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Richard Kenner g

[Ada] Implement predicate checks on qualified expressions (AI12-0100)

2020-06-08 Thread Pierre-Marie de Rodat
Predicate checks are required by AI12-0100 when evaluating qualified expressions where the qualifying subtype has such checks. Errors rather than warnings must be issued on static qualified expressions and type conversions that violate a static predicate, so that's corrected here. There were also c

[Ada] Silence spurious warning on instances of formal vectors

2020-06-08 Thread Pierre-Marie de Rodat
Use pragma Warnings to silence a spurious warning that may occur in instances of formal vectors. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Claire Dross gcc/ada/ * libgnat/a-cofove.adb (Insert_Space): The computation of Index generates a spurious compiler wa

[Ada] Restore Snames.Name_SPARK as it used in the GNATprove backend

2020-06-08 Thread Pierre-Marie de Rodat
The Name_SPARK constant is no longer used in GNAT to implement the SPARK_05 restriction, but is still used in GNATprove to detect whether the SPARK.Heap unit has been explicitly WITH-ed. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Piotr Trojanek gcc/ada/ * snames.ads

[Ada] Spurious error on call to controlled primitive

2020-06-08 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby calls to controlled primitives for types which extend generic formals may be flagged at compile-time as being non-visible. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Justin Squirek gcc/ada/ * sem_ch4.adb (Analyze_One_Call): Add e

[Ada] Implement AI12-0291 (Jorvik profile)

2020-06-08 Thread Pierre-Marie de Rodat
The Jorvik profile is a newly defined profile, similar to the Ravenscar profile but less restrictive in some cases. It differs from the Ravenscar profile only in the removal of six restrictions and the relaxation of one (Ravenscar's Simple_Barriers restriction is replaced with a Pure_Barriers restr

[Ada] AI12-0085 Missing aspect cases for Remote_Types

2020-06-08 Thread Pierre-Marie de Rodat
This change adds a missing check on setting aspects Storage_Size and Storage_Pool on remote access-to-class-wide types. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Arnaud Charlet gcc/ada/ * sem_cat.ads: Fix typo. * sem_cat.adb (Validate_Remote_Access_To_Class

[Ada] Fix handling of 'Enum_Rep and renamings

2020-06-08 Thread Pierre-Marie de Rodat
Most cases were actually handled fine thanks to some special handling in exp_attr.adb, but cases of e.g. a renaming of renaming were not handled properly. Taking this opportunity to simplify the code and remove special cases by actually adding support for 'Enum_Rep directly in Eval_Type_Conversion.

[Ada] Implement AI12-0290 (Simple_Barriers restriction)

2020-06-08 Thread Pierre-Marie de Rodat
Change the existing implementation of the Simple_Barriers restriction to conform to the rules given in AI12-0290. Note that the new rules are in some cases more restrictive than the old rules (so that previously accepted barriers might now be rejected). For example, references to non-component subc

[Ada] Port a modified expansion of Enum_Rep from GNAT to GNATprove

2020-06-08 Thread Pierre-Marie de Rodat
Expansion of Enum_Rep in GNATprove is meant to be a subset of the expansion in GNAT, so it needs to be kept in sync with the frontend. Semantics of the compiler is not affected. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Piotr Trojanek gcc/ada/ * exp_spark.adb (Expa

[Ada] AI12-0204 Renaming of a prefixed view

2020-06-08 Thread Pierre-Marie de Rodat
AI12-0204 clarified that the prefix of a prefixed view that is renamed or passed as a formal subprogram must be renamable as an object and similarly (was already checked by GNAT), the prefix of a prefixed view that has an implicit 'Access must be legal for 'Access and a generalized_indexing is ille

[Ada] Remove the Has_Dynamic_Range_Check flag

2020-06-08 Thread Pierre-Marie de Rodat
The flag was made obsolete some time ago and no fallout has been detected since then, so this change finally removes it. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-08 Eric Botcazou gcc/ada/ * atree.adb (New_Copy): Do not clear Has_Dynamic_Range_Check. * checks.

[Ada] Implement AI12-0073 (Ravenscar disallows Synchronous_Barriers)

2020-06-08 Thread Pierre-Marie de Rodat
In Ada2020 the Ravenscar profile (but not the Jorvik profile) includes a "No_Dependence => Ada.Synchronous_Barriers" restriction. This is a binding interpretation so it applies also to earlier Ada versions, but the unit Ada.Synchronous_Barriers did not exist before Ada 2012. Tested on x86_64-pc-li

[Ada] Spurious error on instantiations with Taft_Amendment types and tasks

2020-06-09 Thread Pierre-Marie de Rodat
An access type whose designated type is an incomplete or class-wide type may end up designating a task type or a type with a task component. It is then necessary to associate the access type with the Master of the tasks that may be generated on an allocator for that access type. This is done by cre

[Ada] Remove bypass for instance bodies from Is_Visible_Component

2020-06-09 Thread Pierre-Marie de Rodat
This removes an obsolete bypass present for long in the predicate Is_Visible_Component, which is responsible for determining whether a component present in a private tagged record type is visible in its extensions. This bypass would essentially always return true in bodies of instances, but there

[Ada] Ada2020: AI12-0301 Predicates and Default_Value

2020-06-09 Thread Pierre-Marie de Rodat
This AI clarifies that predicate checks apply at object declaration for types that contain components with a Default_Value or Default_Component_Value. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * sem_util.ads, sem_util.adb (Is_Partially_Initi

[Ada] Refine implementation of AI05-0149 missing conversion checks

2020-06-09 Thread Pierre-Marie de Rodat
We were accepting conversion from anon-access-T'Class to access-all-T which is incorrect. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * sem_type.adb (Covers): Fix implementation of AI05-0149. * sem_res.adb: Fix typo.--- gcc/ada/sem_res

[Ada] Ada2020 AI12-0282: Shared variable control aspects in generics

2020-06-09 Thread Pierre-Marie de Rodat
This patch refines the checks and the corresponding error messsages on the legality of instantiations where some formal objects and their corresponding actuals may carry Atomic, Atonic_Components, Volatile, Volatile_Components, Independent, or Independent_Components aspect specifications. The lega

[Ada] Annotate Ada.Synchronous_Barriers with SPARK_Mode => Off

2020-06-09 Thread Pierre-Marie de Rodat
Synchronous barriers are currently not supported by GNATprove (i.e. it doesn't recognize that they are initialized by synchronous). They are specifically detected and rejected as not-in-SPARK, but it is more elegant to annotate the Ada.Synchronous runtime library unit with SPARK_Mode => Off. Compi

[Ada] Spurious overlap error on zero-sized arrays with -gnateV

2020-06-09 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby the compiler would incorrectly generate checks for overlapping formals (-gnateV) leading to spurious runtime errors when a zero-sized array actual gets passed alongside another formal declared in the same region. Tested on x86_64-pc-linux-gnu, committed on trun

[Ada] Crash on exit statement within predicated loop

2020-06-09 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby the compiler would crash if it encountered an exit statement featuring a loop identifier where such referenced loop iterates through a predicated type. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Justin Squirek gcc/ada/ * exp_ch5.

[Ada] Write_Invocation_Graph_Vertex: include lib item name

2020-06-09 Thread Pierre-Marie de Rodat
Make each invocation graph point to the corresponding library graph. Use this information in Write_Invocation_Graph_Vertex to print out the name of the library item containing this vertex. For procedures that take both the library graph and invocation graph as parameters, remove the library graph

[Ada] Add debugging message

2020-06-09 Thread Pierre-Marie de Rodat
When raising Program_Error due to an incorrect Kind transition, print a more informative debugging message. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Bob Duff gcc/ada/ * bindo-graphs.adb (Add_Edge_Kind_Check): Add the Image of the old and new Kinds to the r

[Ada] Membership test against a non-excluding subtype

2020-06-09 Thread Pierre-Marie de Rodat
GNAT ignores the null exclusion property of the target access type in a membership test (e.g. Ptr in Null_Excluding_Ptr_Type), this is fixed here. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_ch4.adb (Expand_N_In): Fix handling of null ex

[Ada] gnatbind: Correct assertions in Add_Edge_Kind_Check

2020-06-09 Thread Pierre-Marie de Rodat
This patch corrects the assertions in Add_Edge_Kind_Check. In particular, a spec-->body edge can come from an Invocation_Edge or a Forced_Edge in case of cycles. Other edges are added in a certain order. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Bob Duff gcc/ada/

[Ada] Disable assertion regarding Body_Before_Spec_Edge

2020-06-09 Thread Pierre-Marie de Rodat
This patch disables a sometimes-failing assertion. The assertion is failing because there is an invocation edge spec-->body, and then we later add a Body_Before_Spec_Edge for the SCC computation. This is a temporary fix; we need to investigate why the spec-->body invocation edge exists. Tested on

[Ada] Improve handling of null unbounded strings

2020-06-09 Thread Pierre-Marie de Rodat
This is a useful optimization to avoid contention around the shared empty string. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * libgnat/a-strunb__shared.ads, libgnat/a-strunb__shared.adb (Reference, Unreference): No-op for Empty_Shared

[Ada] Improve handling of aggregates in Side_Effect_Free

2020-06-09 Thread Pierre-Marie de Rodat
Side_Effect_Free was always assuming an aggregate isn't side effects free, but we can do better by taking advantage of the Compile_Time_Known_Aggregate flag. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_util.adb (Side_Effect_Free): Improv

[Ada] Implement AI12-0028: Import of variadic C functions

2020-06-09 Thread Pierre-Marie de Rodat
This implements the support for the new C_Variadic_n conventions, n ranging from 0 to 16, in all versions of the language since the AI is a binding interpretation. These new conventions are meant to be used in conjunction with the Import aspect/pragma to call variadic C functions with the special

[Ada] Expand more others aggregates statically

2020-06-09 Thread Pierre-Marie de Rodat
Now that there is no artifical limit on Convert_To_Positional, we use the same heuristics than in Aggr_Size_OK, to share the code and to generate static aggregates in more cases. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_aggr.adb (Max_

[Ada] Small cleanup in Einfo unit

2020-06-09 Thread Pierre-Marie de Rodat
This moves around the declarations of functions that are not in the right category, adds pragma Inline for others and fixes alphabetization issues. This also clearly splits the functions subject to pragma Inline from the procedures subject to the pragma, the former being read by XEINFO but not the

[Ada] Code clean ups and comments updates

2020-06-09 Thread Pierre-Marie de Rodat
We identify all the places where error messages are issued in the expander and should be issued in semantic analysis instead, for future clean ups. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_ch3.adb, exp_ch4.adb, exp_ch6.adb, exp_ch9.ad

[Ada] Missing check on private overriding of dispatching primitive

2020-06-09 Thread Pierre-Marie de Rodat
When a dispatching operation overrides an inherited subprogram, it must be subtype conformant with the inherited subprogram. Such check is not performed by the frontend on overriding primitives of private types which are declared before the full type declaration of the private type. Tested on x86

[Ada] Propagate DIC, Invariant and Predicate attributes to views

2020-06-09 Thread Pierre-Marie de Rodat
This change is a step towards propagating more consistently the DIC, Invariant and Predicate attributes between different views of the same type, in particular to the newly built underlying full views. It also cleans up the handling of the base types for the DIC and Invariant attributes, which loo

[Ada] Fix wrong type being used for range check generation

2020-06-09 Thread Pierre-Marie de Rodat
Before this commit, GNAT would use the type of the expression rather than that of the subtype mark in order to decide whether it should generate range checks or not. This means that in some cases, GNAT would decide that no range checks were needed, which was wrong. This issue went mostly unnoticed

[Ada] Ada2020 AI12-0282: Shared variable control aspects in generics

2020-06-09 Thread Pierre-Marie de Rodat
This patch further refines the checks and the corresponding error messsages on the legality of instantiations where some formal types and their corresponding actuals may carry Atomic, Volatile, etc. aspect specifications. The legality rules stated in RN 6.1 (12/5) are in fact backward-incompatibl

[Ada] Remove kludge for AI05-0087

2020-06-09 Thread Pierre-Marie de Rodat
This is a code clean up as part of removing all calls to Error_Msg* in the expander. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-09 Arnaud Charlet gcc/ada/ * exp_ch5.adb (Expand_N_Assignment): Remove kludge for AI05-0087. * sem_ch12.adb (Validate_Derived

[Ada] Remove unreferenced GNATprove utility routine Get_Low_Bound

2020-06-10 Thread Pierre-Marie de Rodat
Routine Get_Low_Bound was added to frontend while moving utility routines from the GNATprove backend, but it is no longer referenced. (Surprisingly, there is no Get_High_Bound routine anywhere). Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Piotr Trojanek gcc/ada/ * se

[Ada] Reject illegal bodies for null procedures

2020-06-10 Thread Pierre-Marie de Rodat
The `if Token = ...` condition was added when aspect specifications were introduced in GNAT: aspect specification parsing is done as part of subprogram declaration parsing, and so once aspect specifications are parsed, it is necessary to re-start the subprogram declaration-parsing autotmata. But re

[Ada] Fix assertion failure on functions with contracts

2020-06-10 Thread Pierre-Marie de Rodat
This commit fixes a bug introduced in a previous commit that attempted to detect illegal body definitions on null procedures but did not account for the fact that function definitions such as `function F return Integer with Global => null is` could use the same path. This would result in an asserti

[Ada] Incorrect accessibility checks on functions calls

2020-06-10 Thread Pierre-Marie de Rodat
This patch corrects an issue whereby the compiler would issue incorrect accessibility errors and checks for objects initialized by functions returning anonymous access types or type conversions where the operand is a function returning an anonymous access type. Tested on x86_64-pc-linux-gnu, commi

[Ada] Simplify detection of static membership choices

2020-06-10 Thread Pierre-Marie de Rodat
Membership test operators (i.e. "in" and "not in") have either the right operand present (when there is just one choice) or the list of alternatives present (when there are many choices), as documented in sinfo.ads. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Piotr Trojanek g

[Ada] Fix incorrect insertion of post-call actions in if-expression

2020-06-10 Thread Pierre-Marie de Rodat
When post-call actions need to be inserted in an expression context, an N_Expression_With_Actions node is used. That's not done here for the condition of an if-expression, so the change adds this case. It also deals with the case of a call to a primitive of a tagged type written in prefixed notat

[Ada] Classwide controlled obj not dispatching

2020-06-10 Thread Pierre-Marie de Rodat
Overriding dispatching primitives Initialize, Adjust or Finalize of a controlled type by means of a subprogram body that has no specification causes the frontend to initialize incorrectly the dispatch table slots of these primitives. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 J

[Ada] Revert workaround for expansion of Enum_Rep in GNATprove mode

2020-06-10 Thread Pierre-Marie de Rodat
A workaround for a bug in expansion of Enum_Rep attribute in the GNATprove mode was to expand First and Last attributes. Now with handling of Enum_Rep fixed we don't need this workaround anymore. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Piotr Trojanek gcc/ada/ * e

[Ada] Ada_2020 AI12-0220: Pre/Postconditions on Access_To_Subprogram types

2020-06-10 Thread Pierre-Marie de Rodat
This patch implements AI12-0220, which adds contracts to Access_To_Subprogram types so that pre/postconditions are applied to all indirect calls through such an access type. Tested on x86_64-pc-linux-gnu, committed on trunk 2020-06-10 Ed Schonberg gcc/ada/ * einfo.ads (Access_Subprog

<    4   5   6   7   8   9   10   11   12   13   >