[Ada] Warn about unknown condition in Compile_Time_Warning

2019-08-14 Thread Pierre-Marie de Rodat
The compiler now warns if the condition in a pragma Compile_Time_Warning or Compile_Time_Error does not have a compile-time-known value. The warning is not given for pragmas in a generic template, but is given for pragmas in an instance. The -gnatw_c and -gnatw_C switches turn the warning on and o

[Ada] Fix spurious ownership error in GNATprove

2019-08-14 Thread Pierre-Marie de Rodat
Like Is_Path_Expression, function Is_Subpath_Expression should consider the possibility that the subpath is a type conversion or type qualification over the actual subpath node. This avoids spurious ownership errors in GNATprove. There is no impact on compilation. Tested on x86_64-pc-linux-gnu, c

[Ada] Alignment may be specified as zero

2019-08-14 Thread Pierre-Marie de Rodat
An Alignment clause or an aspect_specification for Alignment may be specified as 0, which is treated the same as 1. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-14 Bob Duff gcc/ada/ * sem_ch13.adb (Get_Alignment_Value): Return 1 for Alignment 0, and do not give a

[Ada] Incorrect error on inline protected function

2019-08-14 Thread Pierre-Marie de Rodat
This patch fixes a bug where if a protected function has a pragma Inline, and has no local variables, and the body consists of a single extended_return_statement, and the result type is an indefinite composite subtype, and inlining is enabled, the compiler gives an error, even though the program is

[Ada] Check SPARK restriction on Old/Loop_Entry with pointers

2019-08-14 Thread Pierre-Marie de Rodat
SPARK RM rule 3.10(14) restricts the use of Old and Loop_Entry attributes on prefixes of an owning or observing type (i.e. a type with access inside). There is no impact on compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-14 Yannick Moy gcc/ada/ * sem_spark.adb

[Ada] Improve performance of Containers.Functional_Base

2019-08-14 Thread Pierre-Marie de Rodat
This patch modifies the implementation of Functional_Base to damp the cost of its subprograms at runtime in specific cases. Instead of copying the entire underlying array to create a new container, containers can share the same Array_Base attribute. Performance on common use cases of formal and fun

[Ada] Fix internal error on inlined subprogram instance

2019-08-14 Thread Pierre-Marie de Rodat
This fixes a long-standing oddity in the procedure analyzing the instantiation of a generic subprogram, which would set the Is_Generic_Instance flag on the enclosing package generated for the instantiation but only to reset it a few lines below. Now this flag is relied upon by the machinery which

[Ada] Compiler speedup with inlining across units

2019-08-14 Thread Pierre-Marie de Rodat
This change is aimed at speeding up the inlining across units done by the Ada compiler when -gnatn is specified and in the presence of units instantiating a lot of generic packages. The current implementation is as follows: when a generic package is being instantiated, the compiler scans its spec

[Ada] Fix thinko in Acc_Loop_to_gnu

2019-08-19 Thread Pierre-Marie de Rodat
This fixes a glitch introduced during the initial OpenACC work import process, causing crashes on any Acc_Parallel + Acc_Loop combination. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-19 Olivier Hainque gcc/ada/ * gcc-interface/trans.c (Acc_Loop_to_gnu): Return the opena

[Ada] Further cleanup in inlining machinery

2019-08-19 Thread Pierre-Marie de Rodat
This gets rid of a small issue in the inlining machinery: under very peculiar circumstances, it would add a pending instantiation for the body of a generic package at the point of call to an inlined subprogram of the instance. That's theoritically problematic because the saved context is that of t

[Ada] Factor out the "size for& too small..." error message

2019-08-19 Thread Pierre-Marie de Rodat
Use a constant for the Size_Too_Small_Message, so if it changes, it won't change in one place but not another. DRY. It might be better to move this code out of errout.adb, but that's for another day. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-19 Bob Duff gcc/ada/ * er

[Ada] Representation clause for derived enumeration type is mishandled

2019-08-19 Thread Pierre-Marie de Rodat
This patch fixes an old-standing problem with premature freezing. When a derived type declaration includes a constraint, we generate a subtype declaration of an anonymous base type, with the constraint given in the original type declaration, Conceptually, the bounds are converted to the new base ty

[Ada] Improve placement of warning on formals of generic subprograms

2019-08-19 Thread Pierre-Marie de Rodat
This patch modifies the handling of warnings on unused formal parameters of generic subprograms. Previously such warnings were placed on the formal appearing in the subprogram declaration, in contrast with warnings on non-generic subprograms, where the warning is placed on the corresponding entity

[Ada] Do not skip non-aliasing checking when inlining in GNATprove

2019-08-19 Thread Pierre-Marie de Rodat
When code is inlinined for proof in the special mode for GNATprove, Ada rules about non-aliasing should still be checked. Now fixed. There is no impact on compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-19 Yannick Moy gcc/ada/ * sem_res.adb (Resolve_Call): Che

[Ada] Legality of protected subp. implementing interface operations

2019-08-19 Thread Pierre-Marie de Rodat
This patch refines the predicate that implements rule in RM 9.4 (11.9/2) Compiling b94.ads must yield: b94.ads:11:17: illegal overriding of subprogram inherited from interface b94.ads:11:17: first formal of "N" declared at line 8 must be of mode "out", "in out" or access-to-variable -

[Ada] Improve warnings about "too few elements" and "too many elements"

2019-08-19 Thread Pierre-Marie de Rodat
When warning about length-check failures detected at compile time that are flagged with "too few elements" or "too many elements", the compiler now gives an additional message indicating the number of elements expected by the context versus how many are present in the conflicting expression (such a

[Ada] Buffer reading overflow in dispatch table initialization

2019-08-19 Thread Pierre-Marie de Rodat
For tagged types not defined at library level that derive from library level tagged types the compiler may generate code to initialize their dispatch table of predefined primitives copying from the parent type data stored in memory after the dispatch table of the parent; that is, at runtime the ini

[Ada] Enable use of GNAT.Sockets for VxWorks RTP

2019-08-19 Thread Pierre-Marie de Rodat
The recent introduction of GNAT.Sockets IPv6 support broke support for VxWorks RTPs due to the use of internal VxWorks kernel calls. This patch rectifies this by using the VxWorks public API for these routines. The following RTP should compile successfully on a Development profile VxWorks kernel t

[Ada] Fix internal error on subprogram instantiation with -gnatzc

2019-08-19 Thread Pierre-Marie de Rodat
This fixes a fallout of the recent change keeping the Is_Generic_Instance flag on the wrapper package built for the instantiation of a generic subprogram. There is no need to visit the Instance_Spec of an N_Subprogram_Instantiation node anymore because the regular processing for an N_Package_Decla

[Ada] Fix bogus compilation error with Elaborate_Body and -gnatN

2019-08-19 Thread Pierre-Marie de Rodat
This fixes a bogus compilation error when a unit with SPARK_Mode containing a pragma Elaborate_Body is with-ed by a generic unit containing an inlined subprogram, and front-end inlining is enabled. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-19 Eric Botcazou gcc/ada/ *

[Ada] Conversion routines between GNAT.OS_Lib.OS_Time and long integer

2019-08-19 Thread Pierre-Marie de Rodat
The new routines convert back and forth between private type OS_Time and a long integer which can be used in package Ada.Calendar.Conversions routines to convert to Ada.Calendar.Time. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-19 Dmitriy Anisimkov gcc/ada/ * libgnat/s-

[Ada] Lift restriction on instantiations that are compilation units

2019-08-19 Thread Pierre-Marie de Rodat
This change lifts the restriction that was still present in the new on-demand instantiation scheme for the body of generics instantiated in non-main units. The instantiations that are compilation units were still dealt with in the old-fashioned way, that is to say the decision of instantiating the

[Ada] Fix incorrect stub generation for types in instances

2019-08-19 Thread Pierre-Marie de Rodat
This fixes a fallout of a recent change clearing the Is_Generic_Actual_Type on the implicit full view of a private actual type in an instance. This flag is used to help disambiguating formal types instantiated on the same actual type within an instance, but it should be cleared outside the instanc

[Ada] Crash on object initialization that is call to expression function

2019-08-19 Thread Pierre-Marie de Rodat
This patch fixes a compiler abort on an object declaration for a class-wide type whose expression is a call to an expression function that returns type extension. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-19 Ed Schonberg gcc/ada/ * sem_res.adb (Resolve_Call): A call t

[Ada] Incorrect code for -gnateV switch

2019-08-19 Thread Pierre-Marie de Rodat
This patch corrects the code generated by the -gnateV switch in the case of a private type whose full type is a modular type, removing spurious run-time failures. In addition, this corrects the initialization of exception occurrences in exception handlers to avoid leaving data uninitialized, which

[Ada] Suppress warnings on unreferenced parameters of dispatching ops

2019-08-19 Thread Pierre-Marie de Rodat
If the -gnatwf switch is used to activate warnings on unreferenced formal parameters, the warning is no longer given if the subprogram is dispatching, because such warnings tend to be noise. It is quite common to have a parameter that is necessary just because the subprogram is overriding, or just

[Ada] Process type extensions for -gnatw.h

2019-08-19 Thread Pierre-Marie de Rodat
This patch enables gap detection in type extensions. With the -gnatw.h switch, on 64-bit machines, the following test should get warnings: gcc -c gaps.ads -gnatw.h gaps.ads:16:07: warning: 48-bit gap before component "Comp2" gaps.ads:17:07: warning: 8-bit gap before component "Comp3" package Gap

[Ada] Add formal function parameter equality to SPARK containers

2019-08-19 Thread Pierre-Marie de Rodat
This patch adds a formal function parameter "=" (L, R : Element_Type) to SPARK containers. The equality that is used by default for Element_Type after this patch is the primitive equality and not the predefined any more. It also allows to use any function with the appropriate signature for the equa

[Ada] Generate ada_target_properties

2019-08-19 Thread Pierre-Marie de Rodat
Generate target-dependent info into a file named ada_target_properties. This information is used by tools for static analysis: they need to know the size of standard types for a given run-time library. This metadata is meant to be saved at the root of the run-time directory. Tested on x86_64-pc-li

[Ada] Object_Size clause specifying 0 bits is illegal

2019-08-20 Thread Pierre-Marie de Rodat
The patch gives an error message on "for T'Object_Size use 0;". Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-20 Bob Duff gcc/ada/ * sem_ch13.adb (Object_Size): Give an error for zero. It really rubs me the wrong way that we don't honor "for T'Object_Size use

[Ada] Revert change for gnatprove that is no longer needed

2019-08-20 Thread Pierre-Marie de Rodat
Years ago, we adapted Get_Kind_Of_Unit so that gnatprove could use it to detect both bodies and specs of predefined units. However, this wasn't really needed: gnatprove could simply reuse Lib.In_Predefined_Unit and now it does. This patch simply reverts two commits mentioned above. No frontend te

[Ada] Improve generated code for initialization of atomics

2019-08-20 Thread Pierre-Marie de Rodat
This patch makes the temp for initialization of an atomic variable be constant. No change in behavior; no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-20 Bob Duff gcc/ada/ * freeze.adb (Is_Atomic_VFA_Aggregate): Make the temp for initialization of the atom

[Ada] Warn on Unchecked_Conversion to zero-sized array

2019-08-20 Thread Pierre-Marie de Rodat
The compiler usually warns on Unchecked_Conversion between types with mismatched sizes. This warning is now extended to the case where the target type is a zero-sized array. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-20 Bob Duff gcc/ada/ * sem_ch13.adb (Is_Null_Array):

[Ada] Get rid of linear searches in Lib

2019-08-20 Thread Pierre-Marie de Rodat
This change is aimed at removing a couple of linear searches in the units management code that can become problematic performance-wise when the number of loaded units is in the several hundreds, which can happen for large files even at -O0 without any inlining. It introduces an auxiliary hash tabl

[Ada] Pragma Warning_As_Error works for style warnings

2019-08-20 Thread Pierre-Marie de Rodat
Pragma Warning_As_Error now works for style warnings (messages that start with "(style)", enabled by -gnaty) the same way it works for regular warnings enabled by -gnatw. The following test should fail to build with style checks: gnat.adc: pragma Warning_As_Error ("two spaces required"); style.

[Ada] Spurious error in dispatching call with class-wide precondition

2019-08-20 Thread Pierre-Marie de Rodat
This patch fixes a spurious visibility error on a dispatching call to a subprogram with a classwide precondition, when the call qppears in the same declarative part as the subprogram declaration itself. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-20 Ed Schonberg gcc/ada/

[Ada] Suppress Initialize_Scalars for Persistent_BSS

2019-08-20 Thread Pierre-Marie de Rodat
If a variable has pragma Persistent_BSS, the compiler now automatically suppresses implicit initializations caused by Initialize_Scalars and Normalize_Scalars. Variables with Persistent_BSS cannot be initialized, and previously a pragma Suppress_Initialization was required before the pragma Persist

[Ada] New pragma Aggregate_Individually_Assign

2019-08-20 Thread Pierre-Marie de Rodat
Where possible GNAT will store the binary representation of a record aggregate in memory for space and performance reasons. This configuration pragma changes this behaviour so that record aggregates are instead always converted into individual assignment statements. The following package pack.ads:

[Ada] Enable delta_aggregate only in Ada 2020 mode

2019-08-20 Thread Pierre-Marie de Rodat
If the delta_aggregate feature is used, the -gnat2020 or -gnatX switch must be given. The following test must get an error if neither -gnat2020 nor -gnatX is specified: gcc -c delta_aggregate.ads -gnat2012 delta_aggregate.ads:4:18: delta_aggregate is an Ada 202x feature delta_aggregate.ads:4:18:

[Ada] More complete information level for -gnatR4 output

2019-08-20 Thread Pierre-Marie de Rodat
This instructs -gnatR4 to also list the Etype of a user-declared record subtype if it is compiler-generated, for example in: package P is type U_Arr is array (Integer range <>) of Character; type Rec1 (D1, D2 : Integer) is record C : U_Arr (D1 .. D2); end record; type Rec_N is

[Ada] Crash on Loop_Entry for while_loop involving substrings

2019-08-20 Thread Pierre-Marie de Rodat
When expanding a loop entry attribute for a while_loop we construct a function that incorporates the expanded condition of the loop. The itypes that may be generated in that expansion must carry the scope of the constructed function for proper handling in the backend. Tested on x86_64-pc-linux-gnu

[Ada] Efficiency improvement in bounded ordered containers

2019-08-20 Thread Pierre-Marie de Rodat
The Delete operations in the bounded ordered containers have been substantially sped up. No change in semantics, so no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-20 Bob Duff gcc/ada/ * libgnat/a-cborma.adb, libgnat/a-cborse.adb (Clear): Repeatedly call D

[Ada] Improve efficiency of aggregates with <>

2019-08-20 Thread Pierre-Marie de Rodat
The generated code has been improved so that aggregates with <> are more efficient. No change in behavior; no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-20 Bob Duff gcc/ada/ * exp_aggr.adb (Expand_Array_Aggregate): Use build-in-place in the nonlimited ca

[Ada] Illegal limited function call accepted in a type conversion

2019-08-20 Thread Pierre-Marie de Rodat
It's illegal to call a function with a result of an immutably limited type inside a type conversion that's used in one of the special contexts that allow such a function call by itself (see RM 7.5 (2.1-2.10)), such as in the initialization expression of an object declaration. The compiler was recur

[Ada] Inconsistent scope chain due to quantified expression

2019-08-20 Thread Pierre-Marie de Rodat
Routine Build_DIC_Procedure_Declaration appears to be heavily inspired by Build_Invariant_Procedure_Declaration; they both wrap an expression attached to a type inside an internal procedure. Initially none of them were calling Set_Last_Entity. For Build_Invariant_Procedure_Declaration this was fix

[Ada] Adapt GNATprove expansion for slices with access prefix

2019-08-20 Thread Pierre-Marie de Rodat
The special expansion done in GNATprove mode should be adapted to slices where the prefix has access type, like indexed expressions. There is no impact on compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-20 Yannick Moy gcc/ada/ * exp_spark.adb (Expand_SPARK_N_S

[Ada] Set GNAT.OS_Lib.GM_Split's granularity back to 1 second

2019-08-20 Thread Pierre-Marie de Rodat
The modification to round time up to even second was added decades ago. It was done to avoid unneeded recompilations when the project was built on non-FAT filesystems and then moved to FAT filesystems. Such a situation is now very rare and does not deserve time distortion. Tested on x86_64-pc-linu

[Ada] Crash on a Storage_Size aspect depending on attr. of another type

2019-08-20 Thread Pierre-Marie de Rodat
This patch fixes a crash on an aspect specification for Storage_Size for a type T when the expression for the aspect depends on attributes of a previously declared type that is not frozen yet. The temporary declaration that captures the value of the aspect must be part of the actions attached to t

[Ada] Improve speed of discriminated return types

2019-08-20 Thread Pierre-Marie de Rodat
The compiler now generates faster code for functions that return discriminated types in many cases where the size is known at compile time. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-20 Bob Duff gcc/ada/ * exp_ch6.adb (Needs_BIP_Alloc_Form): Call Requires_Trans

[Ada] Warning for out-of-order record representation clauses

2019-08-20 Thread Pierre-Marie de Rodat
The compiler can now warn for out-of-order record representation clauses. A warning is given if the order of component declarations, component clauses, and bit-level layout do not all agree. The warning is disabled by default, and may be enabled by the -gnatw_r switch. Tested on x86_64-pc-linux-g

[Ada] Missing attribute update in new_copy_tree

2019-08-21 Thread Pierre-Marie de Rodat
The compiler crashes processing an internally generated cloned tree that has a subprogram call with a named actual parameter. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-21 Javier Miranda gcc/ada/ * sem_util.adb (Update_Named_Associations): Update First_Named_Ac

[Ada] Max_Entry_Queue_Length aspect for protected entries

2019-08-21 Thread Pierre-Marie de Rodat
Allow values of negative one to be accepted as a valid parameter as a special case. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-21 Justin Squirek gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Modify documentation to reflect expected behavior.

[Ada] Ignore subprogram address in ownership checking

2019-08-21 Thread Pierre-Marie de Rodat
Ownership checking done as in GNATprove should ignore address of subprograms, as it applies only on objects. Now fixed. There is no impact on compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-21 Yannick Moy gcc/ada/ * sem_spark.adb (Process_Path): Do nothing on

[Ada] Undefined master in task with limited class-wide aliased entry formal

2019-08-21 Thread Pierre-Marie de Rodat
In the case of a task declaring an entry with an aliased formal parameter of a limited class-wide type, the front end was creating a master object (_master) for the access type generated for such an entry formal inside the task specification, even though such access types don't need an associated m

[Ada] Fix type mismatch in extended return statement expansion

2019-08-21 Thread Pierre-Marie de Rodat
This fixes a (sub)type mismatch in the expansion of an extended return statement generated for a built-in-place function that doesn't need a BIP_Alloc_Form parameter but returns unconstrained. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-21 Eric Botcazou g

[Ada] More precise propagation of Size attribute in generic instances

2019-08-21 Thread Pierre-Marie de Rodat
GNATprove analyzer for SPARK code depends on the frontend to accurately propagate the known value of Size attribute. This was not done for formal type parameters in generic instantiations. Now fixed. There is no impact on compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-21

[Ada] Fix assertion failure on derived private protected type

2019-08-21 Thread Pierre-Marie de Rodat
This fixes an assertion failure on the instantiation of a generic package on a type derived from the private view of a protected type, ultimately caused by Finalize_Address returning Empty for the subtype built for the generic actual type of the instantiation. Finalize_Address has a special proces

[Ada] Improve detection of end of the process by GNAT.Expect

2019-08-21 Thread Pierre-Marie de Rodat
'read' system call may be interrupted by signal with 'errno' is set to EINTER. In this case, re-try a few times. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-21 Vadim Godunko gcc/ada/ * libgnat/g-expect.adb (Expect_Internal): Attempt to read several times when 'r

[Ada] More complete information level for -gnatR4 output

2019-08-21 Thread Pierre-Marie de Rodat
This instructs -gnatR4 to also list the Etype of components in user-declared record types if it is compiler-generated, for example in: package P3 is type idx is range 1 .. 100; type Arr is array (Idx range <>) of Character; type Rec is record C : Arr (1 .. 5); end record;

[Ada] Do not rewrite argument of pragma Entry_Queue_Length in analysis

2019-08-21 Thread Pierre-Marie de Rodat
It was unusual for the analysis phase of compiler to rewrite static expression of pragma Entry_Queue_Length with its value. This typically happens when expanding the AST and only if needed for a given backend. In particular, GNATprove doesn't need such an expansion and actually needs the unrewritte

[Ada] Avoid spurious error in GNATprove mode on non-null access types

2019-08-21 Thread Pierre-Marie de Rodat
GNATprove directly handles non-null access checks, and requires that the frontend does not insert explicit checks in the form of conditional exceptions being raised. Now fixed. There is no impact on compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-21 Yannick Moy gcc/ada

[Ada] Fix wrong value of 'Size for slices of bit-packed arrays

2019-09-17 Thread Pierre-Marie de Rodat
This fixes a long-standing issue in the compiler which would return a wrong value for the Size attribute applied to slices of bit-packed arrays whose size is not a multiple of the storage unit. The problem is that the computation was done in the code generator after the bit-packed array had been i

[Ada] Refine conditions for calling Copy_Bitfield

2019-09-17 Thread Pierre-Marie de Rodat
Avoid calling Copy_Bitfield if there are volatile or independent components that might be read or written. The test is conservative. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Bob Duff gcc/ada/ * exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield): Add tests

[Ada] Avoid touching potentially nonexistent memory

2019-09-17 Thread Pierre-Marie de Rodat
...in cases where the Val_2 might cross a page boundary, and the second page is now known to exist. Copy_Bitfield is still disabled in the compiler: no test possible. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Bob Duff gcc/ada/ * libgnat/s-bituti.adb (Get_Val_2, Se

[Ada] Support for local unix sockets in GNAT.Sockets API

2019-09-17 Thread Pierre-Marie de Rodat
Sock_Addr_Type has Family_Unix variant now. This variant can be created with function Unix_Local_Addr call. And this variant is working in GNAT.Socket routines where it is appropriate. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Dmitriy Anisimkov gcc/ada/ * gsocket.h

[Ada] PR ada/91268 Do not redefine macros

2019-09-17 Thread Pierre-Marie de Rodat
This should fix PR ada/91268 by only defining macros if not already done. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Arnaud Charlet gcc/ada/ * adaint.c (_REENTRANT, _THREAD_SAFE): Only define if needed.--- gcc/ada/adaint.c +++ gcc/ada/adaint.c @@ -35,8 +35,14 @@

[Ada] Ada 2020: Raise expressions in limited contexts (AI12-0172)

2019-09-17 Thread Pierre-Marie de Rodat
This patch adds support for the use of raise expressions in more limited contexts (as described in the Ada Isssue AI12-0172). Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Javier Miranda gcc/ada/ * exp_ch3.adb (Build_Record_Init_Proc): Do not generate code to a

[Ada] In a generic use Presanalyze_Spec_Expression on Predicates

2019-09-17 Thread Pierre-Marie de Rodat
When verifying that the meaning of an aspect has not changed between the freeze point of the entity and the end of the declarations, we analkyze a copy of the expression to verify its conformance to previous analysis. If the expression contains overloaded references, these have to be resolved, whic

[Ada] GNAT.Expect (Expect_Internal): Try to call 'poll' few times

2019-09-17 Thread Pierre-Marie de Rodat
'poll' returns -1 in case of any error (including interruption by a signal), so call need to be repeated few times to avoid false failures. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Vadim Godunko gcc/ada/ * libgnat/g-expect.adb (Expect_Internal): Try to call 'poll'

[Ada] Clarify documentation for Stack_Usage

2019-09-17 Thread Pierre-Marie de Rodat
Clarify the documentation for Stack_Usage (both comments in the code, and user documentation) to note that tools like Valgrind won't work. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Bob Duff gcc/ada/ * doc/gnat_ugn/gnat_and_program_execution.rst: Clarify doc

[Ada] Force even timestamp in Windows ALI files

2019-09-17 Thread Pierre-Marie de Rodat
Old versions forced even file timestamp in Windows in GNAT.OS_Lib.GM_Split implementation. We removed this time distortion in GNAT.OS_Lib.GM_Split a few commits. But gprbuild became unnecessary recompiling the sources in 50% cases, when the source has odd file timestamp. This commit is restoring th

[Ada] A new utility routine for detecting attribute 'Old

2019-09-17 Thread Pierre-Marie de Rodat
Add a utility routine for detecting attribute 'Old. It will be immediately reused in the GNATprove backend. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Piotr Trojanek gcc/ada/ * sem_util.ads, sem_util.adb (Is_Attribute_Old): New utility routine.--- gcc/ada/se

[Ada] Raise Constraint_Error in overflow case involving rounding

2019-09-17 Thread Pierre-Marie de Rodat
Function Scaled_Divide in s-arith runtime unit computes the combined multiplication and division of its arguments ((X*Y) / Z). In a very special case where the quotient computed before rounding is 2**64-1, then rounding may lead to undesirable wrap-around, leading to a computed quotient of 0 instea

[Ada] Fix ineffective -gnatyN for separate compilation units

2019-09-17 Thread Pierre-Marie de Rodat
This fixes a recent regression introduced in the machinery giving style warnings: the -gnatyN switch no longer cancels an earlier -gnaty switch for separate compilation units. Running this command: gcc -c slib.adb -gnatyaAbcefhiIklmM25OnprStux -gnatyN On the following sources: package Slib is

[Ada] Don't accept illegal (e.g., Integer'(null)) generic actuals

2019-09-17 Thread Pierre-Marie de Rodat
Sem_Util.Wrong_Type usually emits an error message, but in some cases it does not. The code which prevents emitting an error message was going too far in some cases, causing illegal constructs to be accepted. For example, a qualified expression such as Integer'(null) might be passed in as an actual

[Ada] Update the character type comment in exp_dbug.ads

2019-09-17 Thread Pierre-Marie de Rodat
The character type comment in exp_dbug.ads documented the QU and QW encodings, but did not document the plain "Qc" encoding, where 'c' is the character itself. This patch updates the comment to follow the implementation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Tom Tromey

[Ada] Fix rounding of fixed-point arithmetic operation

2019-09-17 Thread Pierre-Marie de Rodat
Fixed-point multiplication, division and conversion may lead to calling the function Double_Divide in s-arit64 runtime unit. In the special case where arguments have the special values X = -2**63 and the absolute value of the product of its other arguments Y*Z = 2**64, the rounded value should be e

[Ada] Minor fixes mostly in comments of runtime arithmetic unit

2019-09-17 Thread Pierre-Marie de Rodat
Multiple comments in functions Double_Divide and Scaled_Divide were incorrect. Now fixed. Also change the expression (if Zhi /= 0 then Ylo * Zhi else 0) to the simpler equivalent (Ylo * Zhi) in Double_Divide. Also add a comment explaining why the implementation of Algorithm D for multiple-precisi

[Ada] Refine change for bit-packed slices

2019-09-17 Thread Pierre-Marie de Rodat
We use Long_Long_Integer'Size / 2 instead of 4 * 8 to support specifying a target configuration file where the largest integer is 32 bits instead of 64. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Arnaud Charlet gcc/ada/ * libgnat/s-bitfie.ads (Val_Bits, Val_Bytes):

[Ada] Add Remove primitive on functional maps

2019-09-17 Thread Pierre-Marie de Rodat
A primitive for removing a mapping from a functional map has been added. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Claire Dross gcc/ada/ * libgnat/a-cofuma.ads, libgnat/a-cofuma.adb (Remove): New function which returns a copy of the input container without

[Ada] Adding assertions on extra formals for BIP function calls

2019-09-17 Thread Pierre-Marie de Rodat
This patch adds assertions to ensure that the frontend passes to the backend the right number of extra parameters required for build in place function calls. No functional change. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Javier Miranda gcc/ada/ * exp_ch6.ads (Need

[Ada] Do not inline dispatching operations in GNATprove mode

2019-09-17 Thread Pierre-Marie de Rodat
In GNATprove, local subprograms without contracts are candidates for inlining, so that they are only analyzed in the context of their calls. This does not apply to dispatching operations, which may be called through dispatching, in an unknown calling context. Hence such operations should not be con

[Ada] Ignore missing ALI files in GNATprove mode

2019-09-17 Thread Pierre-Marie de Rodat
This change only affects GNATprove backend, where it avoids spurious errors on missing ALI files for units indirectly withed from the current unit and processed as part of a different .gpr project. No test provided, because only GNATprove is affected. Tested on x86_64-pc-linux-gnu, committed on t

[Ada] Avoid to close irrelevant file descriptors

2019-09-17 Thread Pierre-Marie de Rodat
'Close' subprogram of GNAT.Expect can close irrelevant file descriptors when 'Expect' was terminated by Process_Died exception and any file open operations was done before call to 'Close'. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Vadim Godunko gcc/ada/ * libgnat/g

[Ada] Support chained calls to traversal functions in SPARK

2019-09-17 Thread Pierre-Marie de Rodat
This change only affects the SPARK toolset. In the part of semantic analysis enforcing ownership rules for SPARK, it corrects a crash in analysis of a declaration of a local borrower whose definition is a chain of several calls to traversal functions. Tested on x86_64-pc-linux-gnu, committed on tr

[Ada] Fix possible suppressed overflows in arithmetic run-time

2019-09-17 Thread Pierre-Marie de Rodat
Function Double_Divide computes the division of its parameters (X / (Y*Z)) in a way that avoids overflows on signed integers, except in two specific cases, when X = -2**63, abs(Y) = abs(Z) = 1 (leading to an overflow in -To_Int(Qu)) and when X = -2**63 and Y*Z is large enough that Qu=0 and so the r

[Ada] Missing tagged type decoration in corresponding record subtypes

2019-09-17 Thread Pierre-Marie de Rodat
The frontend silently skips propagating attribute Is_Tagged_Type to the constrained corresponding record subtype associated with a protected type or task type with discriminants. This change does not affect the functionality of the compiler; it leaves more clean the decoration of internal entities.

[Ada] Remove section on pragma No_Run_Time

2019-09-17 Thread Pierre-Marie de Rodat
This pragma has been long obsolescent and confuses users. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-17 Ed Falis gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Remove section. * gnat_rm.texi, gnat_ugn.texi: Regenerate. patch.diff.gz Descrip

[Ada] GNATprove: avoid crash on illegal borrow during package elaboration

2019-09-17 Thread Pierre-Marie de Rodat
In GNATprove, a borrow during package elaboration is illegal, but a crash could be issued when analyzing the corresponding declaration. Now avoid analyzing the declaration in that case. There is no test as this does not impact compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-0

[Ada] Missing propagation of Has_Predicates in cloned subtypes

2019-09-17 Thread Pierre-Marie de Rodat
The frontend silently skips propagating attributes Has_Predicates and Predicate function to the internally built cloned subtype. This change does not affect the functionality of the compiler; it leaves more clean the decoration of internal entities. Tested on x86_64-pc-linux-gnu, committed on trun

[Ada] Fix typo in error message

2019-09-18 Thread Pierre-Marie de Rodat
An error message mentions "gnamake", where it meant to mention "gnatmake". Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-18 Tom Tromey gcc/ada/ * make.adb (Initialize): Fix typo.--- gcc/ada/make.adb +++ gcc/ada/make.adb @@ -3789,7 +3789,7 @@ package body Make is

[Ada] Avoid uninitialized variable in bounded containers

2019-09-18 Thread Pierre-Marie de Rodat
In function Copy in Ada.Containers.Bounded_Ordered_Sets and other bounded containers packages, remove a possible use of an uninitialized variable. This was not a bug, because the uninitialized variable could be used only if checks are suppressed, and the checks would have failed, leading to erroneo

[Ada] Fix errno for rename for the VxWorks 6 target

2019-09-18 Thread Pierre-Marie de Rodat
This fixes the wrong errno for rename when the file is not existing on a dosFs. In the end it makes Ada.Directories.Rename raising the right exception in the case we are trying to move a file in a non existing directory. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-18 Frederic Konra

[Ada] Fix style issues in functional maps

2019-09-18 Thread Pierre-Marie de Rodat
Rename global constants from I to J. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-09-18 Claire Dross gcc/ada/ * libgnat/a-cofuma.adb (Remove, Elements_Equal_Except, Keys_Included, Keys_Included_Except): Rename loop indexes and global c

[Ada] Fix 32/64bit mistake on SYSTEM_INFO component in s-win32

2019-09-18 Thread Pierre-Marie de Rodat
The dwActiveProcessorMask field in a SYSTEM_INFO structure on Windows should be DWORD_PTR, an integer the size of a pointer. In s-win32, it is currently declared as DWORD. This happens to work on 32bit hosts and is wrong on 64bit hosts, causing mishaps in accesses to this component and all the fol

[Ada] Missing accessibility check on discrim assignment

2019-09-18 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby assignments from anonymous access descriminants which are part of stand alone objects of anonymous access did not have runtime checks generated based on the accessibility level of the object according to ARM 3.10.2 (12.5/3). Tested on x86_64-pc-linux-gnu, committe

[Ada] Don't fail a front-end assertion if errors have already been detected

2019-09-18 Thread Pierre-Marie de Rodat
In sem_eval.adb, we have an assertion that the type of a "null" literal is an access type. It turns out that this assertion can fail when processing an illegal program, e.g. one that contains something like "Integer'(null)". This leads to differences in the compiler's generated output for such tes

[Ada] Factor out code for deciding statically known Constrained attributes

2019-09-18 Thread Pierre-Marie de Rodat
Create a separate routine in Exp_Util for deciding the value of the Constrained attribute when it is statically known. This routine is used in Exp_Attr and will be reused in the backend of GNATprove. There is no impact on compilation and hence no test. Tested on x86_64-pc-linux-gnu, committed on

[Ada] Ensure that Scan_Real result does not depend on trailing zeros

2019-09-18 Thread Pierre-Marie de Rodat
Previous change in that procedure to handle overflow issues during scanning removed the special handling for trailing zeros in the decimal part. Beside the absence of overflow during scanning the special handling of these zeros is still necessary. Tested on x86_64-pc-linux-gnu, committed on trunk

[Ada] Spurious run time error on anonymous access formals

2019-09-18 Thread Pierre-Marie de Rodat
This patch fixes an issue whereby subprograms with anonymous access formals may trigger spurious runtime accessibility errors when such formals are used as actuals in calls to nested subprograms. Running these commands: gnatmake -q pass.adb gnatmake -q fail.adb gnatmake -q test_main.adb g

<    16   17   18   19   20   21   22   23   24   25   >