aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2019-08-19[Ada] Further cleanup in inlining machineryEric Botcazou2-0/+8
This adds missing boilerplate stuff. No functional changes. 2019-08-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * inline.adb (Initialize, Lock): Deal with Called_Pending_Instantiations. From-SVN: r274656
2019-08-19[Ada] Legality of protected subp. implementing interface operationsEd Schonberg2-4/+27
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 ---- package B94 is type Prot2_Int is protected interface; procedure J (PI : in Prot2_Int; N : in Integer) is null; procedure K (PI : in out Prot2_Int; N : in Integer) is null; procedure L (PI : out Prot2_Int; N : in Integer) is null; procedure M (PI : access Prot2_Int; N : in Integer) is null; procedure N (PI : access constant Prot2_Int; N : in Integer) is null; protected type Protected_2 is new Prot2_Int with procedure N (N : in Integer); -- ERROR: {7;1} end Protected_2; end B94; 2019-08-19 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch6.adb (Check_Synchronized_Overriding): Complete predicate that applies legality check in 9.4 (11.9/2): if an inherited subprogram is implemented by a protected procedure or entry, its first paarameter must be out, in_out or access_to_varible. From-SVN: r274655
2019-08-19[Ada] Buffer reading overflow in dispatch table initializationJavier Miranda4-126/+142
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 initialization of dispatch tables overflows reading the parent dispatch table. This problem does not affect the execution of the program since the target dispatch table always has enough space to store the extra data, and after such copy the compiler generates code to complete the initialization of the dispatch table. The following test must compile and execute without errors. package pkg_a is type Root is tagged null record; end pkg_a; with pkg_a; procedure main is type Derived is new pkg_a.Root with null record; -- Test begin null; end main; Command: gnatmake -q main -fsanitize=address; ./main 2019-08-19 Javier Miranda <miranda@adacore.com> gcc/ada/ PR ada/65696 * exp_atag.ads, exp_atag.adb (Build_Inherit_Predefined_Prims): Adding formal to specify how many predefined primitives are inherited from the parent type. * exp_disp.adb (Number_Of_Predefined_Prims): New subprogram. (Make_Secondary_DT): Compute the number of predefined primitives of all tagged types (including tagged types not defined at library level). Previously we unconditionally relied on the Max_Predef_Prims constant value when building the dispatch tables of tagged types not defined at library level (thus consuming more memory for their dispatch tables than required). (Make_DT): Compute the number of predefined primitives that must be inherited from their parent type when building the dispatch tables of tagged types not defined at library level. Previously we unconditionally relied on the Max_Predef_Prims constant value when building the dispatch tables of tagged types not defined at library level (thus copying more data than required from the parent type). From-SVN: r274654
2019-08-19[Ada] Process type extensions for -gnatw.hBob Duff2-184/+243
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 Gaps is type Integer_16 is mod 2**16; type TestGap is tagged record Comp1 : Integer_16; end record; for TestGap use record Comp1 at 0 + 8 range 0..15; end record; type TestGap2 is new TestGap with record Comp2 : Integer_16; Comp3 : Integer_16; end record; for TestGap2 use record Comp2 at 08 + 8 range 0..15; Comp3 at 11 + 8 range 0..15; end record; end Gaps; 2019-08-19 Bob Duff <duff@adacore.com> gcc/ada/ * sem_ch13.adb (Record_Hole_Check): Procedure to check for holes that incudes processing type extensions. A type extension is processed by first calling Record_Hole_Check recursively on the parent type to compute the bit number after the last component of the parent. From-SVN: r274653
2019-08-19[Ada] Improve warnings about "too few elements" and "too many elements"Gary Dismukes4-12/+82
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 as an aggregate that has too few or too many components). The test below reports the following warnings when compiled with this command: $ gcc -c -gnatj78 length_warnings.adb length_warnings.adb:6:09: warning: too few elements for subtype of "Boolean_Array" defined at line 5, expected 10 elements; found 9 elements, "Constraint_Error" will be raised at run time length_warnings.adb:10:09: warning: too few elements for subtype of "Boolean_Array" defined at line 9, expected 2 elements; found 1 element, "Constraint_Error" will be raised at run time length_warnings.adb:14:09: warning: too many elements for subtype of "Boolean_Array" defined at line 13, expected 10 elements; found 11 elements, "Constraint_Error" will be raised at run time length_warnings.adb:18:09: warning: too many elements for subtype of "Boolean_Array" defined at line 17, expected 0 elements; found 1 element, "Constraint_Error" will be raised at run time length_warnings.adb:22:09: warning: too many elements for subtype of "Boolean_Array" defined at line 21, expected 1 element; found 2 elements, "Constraint_Error" will be raised at run time procedure Length_Check_Warnings is type Boolean_Array is array (Natural range <>) of Boolean; Bits_A : Boolean_Array (1 .. 10) := (True, True, True, True, True, True, True, True, True); -- Too few elements Bits_B : Boolean_Array (1 .. 2) := (1 => False); -- Too few elements Bits_C : Boolean_Array (1 .. 10) := (True, True, True, True, True, True, True, True, True, True, True); -- Too many elements Bits_D : Boolean_Array (1 .. 0) := (1 => True); -- Too many elements Bits_E : Boolean_Array (1 .. 1) := (True, False); -- Too many elements begin null; end Length_Check_Warnings; 2019-08-19 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * checks.adb (Length_Mismatch_Info_Message): New function in Selected_Length_Checks to return a message indicating the element counts for the mismatched lengths for a failed compile-time length check. (Plural_Or_Singular_Ending): Support function in Length_Mismatch_Info_Message to return either "" or "s", for concatenating to the end of words. (Selected_Length_Checks): Pass the result of Length_Mismatch_Info_Message as an extra warning message to Compile_Time_Constraint_Error to indicate the mismatched lengths for a failed compile-time length check. * sem_util.ads (Compile_Time_Constraint_Error): Add an optional message formal (Extra_Msg), defaulted to the empty string. * sem_util.adb (Compile_Time_Constraint_Error): Output an extra message following the main warning message (when Extra_Msg is not the empty string). From-SVN: r274652
2019-08-19[Ada] Enable use of GNAT.Sockets for VxWorks RTPPatrick Bernardi2-6/+8
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 that includes the INCLUDE_GETNAMEINFO component: with GNAT.Sockets; use GNAT.Sockets; procedure IPvX is procedure Print_Address_Info (Host, Serv : String; Family : Family_Type := Family_Unspec) is Addresses : Address_Info_Array := Get_Address_Info (Host, Serv, Family, Passive => False, Numeric_Host => False); begin Sort (Addresses, IPv6_TCP_Preferred'Access); end Print_Address_Info; begin Print_Address_Info ("localhost", "ssh"); end IPvX; 2019-08-19 Patrick Bernardi <bernardi@adacore.com> gcc/ada/ * socket.c: Removed the redefinition of getaddrinfo, getnameinfo and freeaddrinfo to internal VxWorks kernel calls because they are, well, internal kernel calls and cannot be called from RTPs. VxWorks provides the necessary components to call these routines directly. From-SVN: r274651
2019-08-19[Ada] Fix incorrect stub generation for types in instancesEric Botcazou2-3/+40
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 instance to let the usual disambiguation rules apply again to these types outside the instance. This in particular means that Exp_Dist cannot rely on it to detect subtypes representing generic actual types, hence the need for the new predicate. 2019-08-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_dist.adb (Is_Generic_Actual_Subtype): New predicate. (Build_From_Any_Call, Build_To_Any_Call, Build_TypeCode_Call): Use it instead of Is_Generic_Actual_Type flag to detect subtypes representing generic actual types. From-SVN: r274650
2019-08-19[Ada] Improve placement of warning on formals of generic subprogramsEd Schonberg2-1/+54
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 in the body of the subprogram. This patch makes the handling of both cases uniform. It is preferable to place the warning in the body because this also provides a better suggestion for the placement of an Unreferenced pragma to suppress the warning when desired. 2019-08-19 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_warn.adb (Check_References, Generic_Body_Formal): When a formal parameter of a generic subprogram is not referenced in the body, place the corresponding warning on the corresponding entity in the specification of the generic body, as is done for non-generic subprograms. gcc/testsuite/ * gnat.dg/warn28.adb, gnat.dg/warn28.ads: New testcase. From-SVN: r274649
2019-08-19[Ada] Factor out the "size for& too small..." error messageBob Duff5-5/+14
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. 2019-08-19 Bob Duff <duff@adacore.com> gcc/ada/ * errout.ads (Size_Too_Small_Message): New constant. * errout.adb, freeze.adb, sem_ch13.adb: Use it. From-SVN: r274648
2019-08-19[Ada] Fix internal error on subprogram instantiation with -gnatzcEric Botcazou2-14/+7
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_Declaration node now does the job for instantiations of generic subprograms. The following subprogram must compile again quietly with -gnatzc: with Gen_Proc; package RCI is pragma Remote_Call_Interface; procedure Inst_Proc is new Gen_Proc; procedure P (S : String); end RCI; generic procedure Gen_Proc (S : String); pragma Remote_Call_Interface (Gen_Proc); with Ada.Text_IO; use Ada.Text_IO; procedure Gen_Proc (S : String) is begin Put_Line ("Gen_Proc called: " & S); end Gen_Proc; 2019-08-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_dist.adb (Build_Package_Stubs): Do not specifically visit the declarations of an N_Subprogram_Instantiation node. From-SVN: r274647
2019-08-19[Ada] Document missing gnatmetric switchesBob Duff2-1/+61
2019-08-19 Bob Duff <duff@adacore.com> gcc/ada/ * doc/gnat_ugn/gnat_utility_programs.rst: Document missing metrics switches. From-SVN: r274646
2019-08-19[Ada] Minor refactoringsPiotr Trojanek3-9/+11
2019-08-19 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * sem_ch12.adb (Get_Unit_Instantiation_Node): Simplify Nkind_In membership test. * sem.adb (Depends_On_Main): Whitespace cleanup; only assign a local variable if needed. From-SVN: r274645
2019-08-19[Ada] Allow reading a borrowed object inside a call to a pledge functionClaire Dross3-0/+49
No impact on regular compilation. 2019-08-19 Claire Dross <dross@adacore.com> gcc/ada/ * sem_spark.ads, sem_spark.adb (Is_Pledge_Function): New parameter of the generic. Function used to decide whether a function is a pledge function. (Check_Not_Borrowed): Disable check inside the second parameter of a pledge function for the path borrowed by the first parameter. Also disable checks for entities inside a Global contract. From-SVN: r274644
2019-08-19[Ada] Add formal function parameter equality to SPARK containersJoffrey Huguet8-0/+16
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 equality function. 2019-08-19 Joffrey Huguet <huguet@adacore.com> gcc/ada/ * libgnat/a-cfdlli.ads, libgnat/a-cfhama.ads, libgnat/a-cfinve.ads, libgnat/a-cforma.ads, libgnat/a-cofove.ads, libgnat/a-cofuma.ads, libgnat/a-cofuve.ads: Add formal function parameter "=" (L, R : Element_Type) to the generic packages. From-SVN: r274643
2019-08-19[Ada] Opt: clean up left-overs of earlier implementation in commentEric Botcazou2-3/+8
2019-08-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * opt.ads: Clean up left-overs of earlier implementation in comment: From-SVN: r274642
2019-08-19[Ada] Representation clause for derived enumeration type is mishandledEd Schonberg2-1/+30
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 type, and this conversion freezes (prematurely) that base type, when the bounds are simply literals. As a result, a representation clause for the derived type is then rejected or ignared. This procedure recognizes the simple case of literal bounds in derived enumeration type declarations, which allows us to indicate that the conversions are not freeze points, and the subsequent representation clause can be accepted. 2019-08-19 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch3.adb (Derived_Enumeration_Type): Do no freeze anonymous base type if the bounds in the derived type declaration are literals of the type. gcc/testsuite/ * gnat.dg/rep_clause9.adb: New testcase. From-SVN: r274641
2019-08-19[Ada] Do not skip non-aliasing checking when inlining in GNATproveYannick Moy2-4/+9
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. 2019-08-19 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_res.adb (Resolve_Call): Check non-aliasing rules before GNATprove inlining. From-SVN: r274640
2019-08-19[Ada] Further cleanup in inlining machineryEric Botcazou3-55/+82
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 the call and not that of the instance in this case, although the strict conditions ensure that this doesn't make a real difference in practice. Now that the machinery can perform the pending instantiations on demand, we can optimistically add more of them when the instantiations are analyzed and thus remove the problematic handling at the point of call. No functional changes. 2019-08-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * inline.adb (Add_Inlined_Body): Do not add pending instantiations. * sem_ch12.adb (Needs_Body_Instantiated): New predicate. (Analyze_Package_Instantiation): Use it to decide whether to add a pending instantiation for the body of the package. From-SVN: r274639
2019-08-19[Ada] Fix thinko in Acc_Loop_to_gnuOlivier Hainque2-4/+7
This fixes a glitch introduced during the initial OpenACC work import process, causing crashes on any Acc_Parallel + Acc_Loop combination. 2019-08-19 Olivier Hainque <hainque@adacore.com> gcc/ada/ * gcc-interface/trans.c (Acc_Loop_to_gnu): Return the openacc BIND_EXPR node we have constructed on purpose. Remove unused variable. gcc/testsuite/ * gnat.dg/openacc1.adb: New testcase. From-SVN: r274638
2019-08-19[Ada] Define the -fdump-scos option in lang.optPierre-Marie de Rodat3-0/+11
2019-08-19 Pierre-Marie de Rodat <derodat@adacore.com> gcc/ada/ * gcc-interface/lang.opt (fdump-scos): Define. * gcc-interface/misc.c (gnat_handle_option): Handle OPT_fdump_scos. From-SVN: r274637
2019-08-14[Ada] Improve performance of Containers.Functional_BaseJoffrey Huguet3-54/+160
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 functional containers is improved with this patch. 2019-08-14 Joffrey Huguet <huguet@adacore.com> gcc/ada/ * libgnat/a-cofuba.ads: Add a Length attribute to type Container. Add a type Array_Base which replaces the previous Elements attribute of Container. (Content_Init): New subprogram. It is used to initialize the Base attribute of Container. * libgnat/a-cofuba.adb (Resize): New subprogram. It is used to resize the underlying array of a container if necessary. (=, <=, Find, Get, Intersection, Length, Num_Overlaps, Set, Union): Update to match changes in type declarations. (Add): Modify body to damp the time and space cost in a specific case. (Content_Init): New subprogram. It is used to initialize the Base attribute of Container. (Remove): Modify body to damp the time and space cost in a specific case. From-SVN: r274474
2019-08-14[Ada] Alignment may be specified as zeroBob Duff4-25/+42
An Alignment clause or an aspect_specification for Alignment may be specified as 0, which is treated the same as 1. 2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * sem_ch13.adb (Get_Alignment_Value): Return 1 for Alignment 0, and do not give an error. * doc/gnat_rm/representation_clauses_and_pragmas.rst: Update the corresponding documentation. * gnat_rm.texi: Regenerate. gcc/testsuite/ * gnat.dg/alignment15.adb: New testcase. From-SVN: r274473
2019-08-14[Ada] Further cleanup in inlining machineryEric Botcazou2-1/+6
This is visible if you pass a very small number by means of -gnateinn. 2019-08-14 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * inline.adb (Add_Pending_Instantiation): Fix off-by-one error in the comparison against the maximum number of instantiations. From-SVN: r274472
2019-08-14[Ada] Further cleanup in inlining machineryEric Botcazou2-1/+6
No practical functional changes. 2019-08-14 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * inline.adb (Add_Pending_Instantiation): Use greater-or-equal in the comparison against the maximum number of instantiations. From-SVN: r274471
2019-08-14[Ada] Do not crash with -gnatR3 on Ghost aspectsEd Schonberg3-0/+15
2019-08-14 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_aux.adb (Next_Rep_Item): If a node in the rep chain involves a Ghost aspect it may have been replaced by a null statement; use the original node to find next Rep_Item. * repinfo.adb (List_Entities): Do not list an Ignored Ghost_Entity, for which information may have been deleted. From-SVN: r274470
2019-08-14[Ada] Warn about unknown condition in Compile_Time_WarningBob Duff7-244/+360
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 off. The default is on. 2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * sem_prag.ads, sem_prag.adb (Process_Compile_Time_Warning_Or_Error): In parameterless version, improve detection of whether we are in a generic unit to cover the case of an instance within a generic unit. (Process_Compile_Time_Warning_Or_Error): Rename the two-parameter version to be Validate_Compile_Time_Warning_Or_Error, and do not export it. Issue a warning if the condition is not known at compile time. The key point is that the warning must be given only for pragmas deferred to the back end, because the back end discovers additional values that are known at compile time. Previous changes in this ticket have enabled this by deferring to the back end without checking for special cases such as 'Size. (Validate_Compile_Time_Warning_Or_Error): Rename to be Defer_Compile_Time_Warning_Error_To_BE. * warnsw.ads, warnsw.adb (Warn_On_Unknown_Compile_Time_Warning): Add new switches -gnatw_c and -gnatw_C to control the above warning. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Document new switches. * gnat_ugn.texi: Regenerate. gcc/testsuite/ * gnat.dg/warn27.adb: New testcase. From-SVN: r274469
2019-08-14[Ada] Further cleanup in the inlining machineryEric Botcazou2-4/+14
2019-08-14 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_ch12.adb (Might_Inline_Subp): Rework comment and restrict the shortcut based on Is_Inlined to the back-end inlining case. From-SVN: r274468
2019-08-14[Ada] Incorrect error on inline protected functionBob Duff2-0/+21
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 legal. 2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * inline.adb (Check_And_Split_Unconstrained_Function): Ignore protected functions to get rid of spurious error. The transformation done by this procedure triggers legality errors in the generated code in this case. gcc/testsuite/ * gnat.dg/inline19.adb, gnat.dg/inline19.ads: New testcase. From-SVN: r274467
2019-08-14[Ada] Defer processing of unknown CTW/E conditions to the back endBob Duff3-63/+31
2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Defer processing to the back end in all cases where the pragma's condition is not known at compile time during the front end (except in generics), as opposed to detecting 'Size attributes and the like. This ensures that we take advantage of whatever can be compile-time known after running the back end, as opposed to having the front end guess what the back end can do. Remove a little duplicated code at the call site. * gnat1drv.adb (Post_Compilation_Validation_Checks): Unlock the Elists while in Validate_Compile_Time_Warning_Errors, because it does analysis and name resolution, which sometimes involves adding Elists. From-SVN: r274466
2019-08-14[Ada] Compiler speedup with inlining across unitsEric Botcazou7-130/+385
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 for the presence of subprograms with an aspect/pragma Inline and, upon finding one, schedules the instantiation of its body. That's not very efficient because the compiler doesn't know yet if one of those inlined subprograms will eventually be called from the main unit. The new implementation arranges for the compiler to instantiate the body on demand, i.e. when it encounters a call to one of the inlined subprograms. That's still not optimal because, at this point, the compiler has not yet computed whether the call itself is reachable from the main unit (it will do this computation at the very end of the processing, just before sending the inlined units to the code generator) but that's nevertheless a net progress. The patch also enhances the -gnatd.j option to make it output the list of instances "inlined" this way. The following package is a simple example: with Q; procedure P is begin Q.Proc; end; package Q is procedure Proc; pragma Inline (Proc); end Q; with G; package body Q is package My_G is new G (1); procedure Proc is Val : constant Integer := My_G.Func; begin if Val /= 1 then raise Program_Error; end if; end; end Q; generic Value : Integer; package G is function Func return Integer; pragma Inline (Func); end G; package body G is function Func return Integer is begin return Value; end; end G; 2019-08-14 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * einfo.ads (Is_Called): Document new usage on E_Package entities. * einfo.adb (Is_Called): Accept E_Package entities. (Set_Is_Called): Likewise. * exp_ch6.adb (Expand_Call_Helper): Move code dealing with instances for back-end inlining to Add_Inlined_Body. * inline.ads: Remove with clauses for Alloc and Table. (Pending_Instantiations): Move to... * inline.adb: Add with clauses for Alloc, Uintp, Table and GNAT.HTable. (Backend_Instances): New variable. (Pending_Instantiations): ...here. (Called_Pending_Instantiations): New table. (Node_Table_Size): New constant. (Node_Header_Num): New subtype. (Node_Hash): New function. (To_Pending_Instantiations): New hash table. (Add_Inlined_Body): Bail out early for subprograms in the main unit or subunit. Likewise if the Is_Called flag is set. If the subprogram is an instance, invoke Add_Inlined_Instance. Call Set_Is_Called earlier. If the subrogram is within an instance, invoke Add_Inlined_Instance. Also deal with the case where the call itself is within an instance. (Add_Inlined_Instance): New procedure. (Add_Inlined_Subprogram): Remove conditions always fulfilled. (Add_Pending_Instantiation): Move the defence against ludicruous number of instantiations to here. When back-end inlining is enabled, associate an instantiation with its index in table and mark a few selected kinds of instantiations as always needed. (Initialize): Set Backend_Instances to No_Elist. (Instantiate_Body): New procedure doing the work extracted from... (Instantiate_Bodies): ...here. When back-end inlining is enabled, loop over Called_Pending_Instantiations instead of Pending_Instantiations. (Is_Nested): Minor tweak. (List_Inlining_Info): Also list the contents of Backend_Instances. * sem_ch12.adb (Might_Inline_Subp): Return early if Is_Inlined is set and otherwise set it before returning true. (Analyze_Package_Instantiation): Remove the defence against ludicruous number of instantiations. Invoke Remove_Dead_Instance instead of doing the removal manually if there is a guaranteed ABE. From-SVN: r274465
2019-08-14[Ada] Equality for nonabstract type derived from interface treated as abstractGary Dismukes3-6/+29
The compiler was creating an abstract function for the equality operation of a (nonlimited) interface type, and that could result in errors on generic instantiations that are passed nonabstract types derived from the interface type along with the derived type's inherited equality operation (complaining about an abstract subprogram being passed to a nonabstract formal). The "=" operation of an interface is supposed to be nonabstract (a direct consequence of the rule in RM 4.5.2(6-7)), so we now create an expression function rather than an abstract function. The function returns False, but the result is unimportant since a function of an abstract type can never actually be invoked (its arguments must generally be class-wide, since there can be no objects of the type, and calling it will dispatch). 2019-08-14 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * exp_ch3.adb (Predef_Spec_Or_Body): For an equality operation of an interface type, create an expression function (that returns False) rather than declaring an abstract function. * freeze.adb (Check_Inherited_Conditions): Set Needs_Wrapper to False unconditionally at the start of the loop creating wrappers for inherited operations. gcc/testsuite/ * gnat.dg/equal11.adb, gnat.dg/equal11_interface.ads, gnat.dg/equal11_record.adb, gnat.dg/equal11_record.ads: New testcase. From-SVN: r274464
2019-08-14[Ada] Strengthen Locked flagBob Duff3-8/+20
This patch strengthens the Locked flag, by Asserting that it is False on operations that might cause reallocation. No change in behavior (except in the presence of compiler bugs), so no test. 2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * table.adb: Assert that the table is not locked when increasing Last, even if it doesn't cause reallocation. In other words, assert that on operations that MIGHT cause reallocation. * table.ads: Fix comment accordingly. From-SVN: r274463
2019-08-14[Ada] Remove documentation of gnatelimArnaud Charlet2-267/+7
2019-08-14 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * doc/gnat_ugn/gnat_and_program_execution.rst: Remove documentation of gnatelim. From-SVN: r274462
2019-08-14[Ada] Tweak the sloc of Compile_Time_Warning warningsBob Duff2-3/+13
2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * sem_prag.adb (Validate_Compile_Time_Warning_Error): Attach the warning to the Sloc of the first pragma argument, rather than to the pragma itself. This is to make pragmas processed after the back end use the same Sloc as pragmas processed earlier, in the front end. There's no reason for this discrepancy, and it hinders further work on this ticket. From-SVN: r274461
2019-08-14[Ada] Minor: remove a ??? commentBob Duff2-1/+4
Minor: remove the ??? comment for the Inside_A_Generic flag. The current name is clear and concise, even though we are noun-ing the adjective "generic". 2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * sem.ads (Inside_A_Generic): Remove the ??? comment. From-SVN: r274460
2019-08-14[Ada] Remove obsolete Pending_Descriptor table and related bitsEric Botcazou4-34/+13
The table has been unused for a while. No functional changes. 2019-08-14 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * inline.ads (Pending_Descriptor): Delete. * inline.adb (Initialize): Do not initialize it. * sem_ch12.adb (Delay_Descriptors): Delete. (Analyze_Package_Instantiation): Call Set_Delay_Subprogram_Descriptors instead of Delay_Descriptors throughout. From-SVN: r274459
2019-08-14[Ada] Spurious error in discriminated aggregateBob Duff2-1/+8
This patch fixes a bug in which a spurious error is given on an aggregate of a type derived from a subtype with a constrained discriminant. 2019-08-14 Bob Duff <duff@adacore.com> gcc/ada/ * exp_aggr.adb (Init_Hidden_Discriminants): Avoid processing the wrong discriminant, which could be of the wrong type. gcc/testsuite/ * gnat.dg/discr57.adb: New testcase. From-SVN: r274458
2019-08-14[Ada] Fix internal error on inlined subprogram instanceEric Botcazou2-4/+6
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 computes the set of public entities to be exposed by a package. 2019-08-14 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_ch12.adb (Analyze_Instance_And_Renamings): Do not reset the Is_Generic_Instance flag previously set on the package generated for the instantiation of a generic subprogram. gcc/testsuite/ * gnat.dg/generic_inst11.adb, gnat.dg/generic_inst11_pkg.adb, gnat.dg/generic_inst11_pkg.ads: New testcase. From-SVN: r274457
2019-08-14[Ada] Crash on quantified expression in disabled assertionEd Schonberg2-0/+27
The defining identifier of a quantified expression may be the freeze point of its type. If the quantified expression appears in an assertion that is disavbled, the freeze node for that type may appear in a tree that will be discarded when the enclosing pragma is elaborated. To ensure that the freeze node is reachable for subsquent uses we must generate its freeze node explicitly when the quantified expression is analyzed. 2019-08-14 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_ch4.adb (Expand_N_Quantified_Expression): Freeze explicitly the type of the loop parameter. gcc/testsuite/ * gnat.dg/assert2.adb, gnat.dg/assert2.ads: New testcase. From-SVN: r274456
2019-08-14[Ada] Sem_Util: fix a bug in New_Copy_TreeJavier Miranda2-0/+20
No impact on GCC-based compilation. 2019-08-14 Javier Miranda <miranda@adacore.com> gcc/ada/ * sem_util.adb (New_Copy_Tree.Copy_Node_With_Replacement): Update the Chars attribute of identifiers. From-SVN: r274455
2019-08-14[Ada] Expose part of ownership checking for use in GNATproveYannick Moy3-33/+198
GNATprove needs to be able to call a subset of the ownership legality rules from marking. This is provided by a new function Sem_SPARK.Is_Legal. There is no impact on compilation. 2019-08-14 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_spark.adb, sem_spark.ads (Is_Legal): New function exposed for use in GNATprove, to test legality rules not related to permissions. (Check_Declaration_Legality): Extract the part of Check_Declaration that checks rules not related to permissions. (Check_Declaration): Call the new Check_Declaration_Legality. (Check_Type_Legality): Rename of Check_Type. Introduce parameters to force or not checking, and update a flag detecting illegalities. (Check_Node): Ignore attribute references in statement position. From-SVN: r274454
2019-08-14[Ada] Check SPARK restriction on Old/Loop_Entry with pointersYannick Moy2-5/+130
--#! r336866 --#! no-mail 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. 2019-08-14 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_spark.adb (Check_Old_Loop_Entry): New procedure to check correct use of Old and Loop_Entry. (Check_Node): Check subprogram contracts. (Check_Pragma): Check Loop_Variant. (Check_Safe_Pointers): Apply checking to library-level subprogram declarations as well, in order to check their contract. From-SVN: r274453
2019-08-14[Ada] Fix spurious ownership error in GNATproveYannick Moy2-1/+13
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. 2019-08-14 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_spark.adb (Is_Subpath_Expression): Take into account conversion and qualification. From-SVN: r274452
2019-08-14[Ada] Fix discrepancy in mechanism tracking private and full viewsEric Botcazou2-31/+84
This fixes a discrepancy in the mechanism tracking the private and full views of entities when entering and leaving scopes. This mechanism records private entities that are dependent on other private entities, so that the exchange done on entering and leaving scopes can be propagated. The propagation is done recursively on entering child units, but it was not done recursively on leaving them, which would leave the dependency chains in a uncertain state in this case. That's mostly visible when inlining across units is enabled for code involving a lot of generic units. 2019-08-14 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_ch7.adb (Install_Private_Declarations) <Swap_Private_Dependents>: Do not rely solely on the Is_Child_Unit flag on the unit to recurse. (Uninstall_Declarations) <Swap_Private_Dependents>: New function. Use it to recurse on the private dependent entities for child units. gcc/testsuite/ * gnat.dg/inline18.adb, gnat.dg/inline18.ads, gnat.dg/inline18_gen1-inner_g.ads, gnat.dg/inline18_gen1.adb, gnat.dg/inline18_gen1.ads, gnat.dg/inline18_gen2.adb, gnat.dg/inline18_gen2.ads, gnat.dg/inline18_gen3.adb, gnat.dg/inline18_gen3.ads, gnat.dg/inline18_pkg1.adb, gnat.dg/inline18_pkg1.ads, gnat.dg/inline18_pkg2-child.ads, gnat.dg/inline18_pkg2.ads: New testcase. From-SVN: r274451
2019-08-14[Ada] Fix a recent ACATS regression (c552001)Javier Miranda2-6/+32
2019-08-14 Javier Miranda <miranda@adacore.com> gcc/ada/ * exp_aggr.adb (Is_CCG_Supported_Aggregate): Return False for arrays with bounds not known at compile time. From-SVN: r274450
2019-08-14[Ada] Crash on precondition involving quantified expressionEd Schonberg2-1/+35
This patch fixes a compiler abort on a precondition whose condition includes a quantified expression. 2019-08-14 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_util.adb (New_Copy_Tree, Visit_Entity): A quantified expression includes the implicit declaration of the loop parameter. When a quantified expression is copied during expansion, for example when building the precondition code from the generated pragma, a new loop parameter must be created for the new tree, to prevent duplicate declarations for the same symbol. gcc/testsuite/ * gnat.dg/predicate12.adb, gnat.dg/predicate12.ads: New testcase. From-SVN: r274449
2019-08-14[Ada] Fix failing assertions on SPARK elaborationYannick Moy4-4/+23
Checking of SPARK elaboration rules may lead to assertion failures on a compiler built with assertions. Now fixed. There is no impact on compilation. 2019-08-14 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_disp.adb (Check_Dispatching_Operation): Update assertion for the separate declarations created in GNATprove mode. * sem_disp.ads (Is_Overriding_Subprogram): Update comment. * sem_elab.adb (SPARK_Processor): Fix test for checking of overriding primitives. From-SVN: r274448
2019-08-14[Ada] Small internal improvements to the inlining machineryEric Botcazou2-37/+44
No functional changes. 2019-08-14 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * inline.adb (Add_Inlined_Body): Tweak comments. (List_Inlining_Info): Also list information about non-main units. From-SVN: r274447
2019-08-14[Ada] Illegal selection of first object in a task type's body not detectedGary Dismukes2-1/+17
The compiler was improperly allowing selection of an object declared within a task body when the prefix was of the task type, specifically in the case where the object was the very first declared in the body (selections of later body declarations were being flagged). The flag Is_Private_Op was only set at the point of the first "private" declaration of the type in cases where the first declaration's name didn't match the selector. 2019-08-14 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): In the case where the prefix is of a concurrent type, and the selected entity matching the selector is the first private declaration of the type (such as the first local variable in a task's body), set Is_Private_Op. gcc/testsuite/ * gnat.dg/task5.adb: New testcase. From-SVN: r274446
2019-08-14[Ada] Minor refactoring in EinfoPiotr Trojanek2-1/+6
2019-08-14 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * einfo.adb (Is_Generic_Actual_Subprogram): Replace repeated calls to Ekind with Ekind_In. From-SVN: r274445