aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2019-08-21[Ada] Improve detection of end of the process by GNAT.ExpectVadim Godunko2-5/+16
'read' system call may be interrupted by signal with 'errno' is set to EINTER. In this case, re-try a few times. 2019-08-21 Vadim Godunko <godunko@adacore.com> gcc/ada/ * libgnat/g-expect.adb (Expect_Internal): Attempt to read several times when 'read' returns non-positive. From-SVN: r274791
2019-08-21[Ada] Minor refactorings/reformattingsPiotr Trojanek6-19/+25
2019-08-21 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * einfo.adb (Is_Discriminal): Remove extra parens. (Is_Constant_Object): Simplify by reusing Ekind_In. (Is_Prival): Remove extra parens. * checks.adb, exp_ch4.adb, sem_ch3.adb, sem_spark.adb: Minor reformattings. From-SVN: r274790
2019-08-21[Ada] Allow for of iteration on formal vectorsClaire Dross2-1/+54
2019-08-21 Claire Dross <dross@adacore.com> gcc/ada/ * libgnat/a-cofove.ads (Vector): Add an Iterable aspect to allow iteration. (Iter_First, Iter_Next): Primitives used for iteration. From-SVN: r274789
2019-08-21[Ada] More precise propagation of Size attribute in generic instancesYannick Moy2-0/+13
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. 2019-08-21 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_ch3.adb (Analyze_Subtype_Declaration): Inherit RM_Size field for formal type parameters in generic instantiations. From-SVN: r274788
2019-08-21[Ada] Update references to the SPARK RMYannick Moy2-6/+10
2019-08-21 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_spark.adb: Update references to the SPARK RM. From-SVN: r274787
2019-08-21[Ada] More complete information level for -gnatR4 outputEric Botcazou2-16/+36
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; end P3; 2019-08-21 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * repinfo.adb (List_Array_Info): In -gnatR4 mode, set the relevant flag on the component type here instead of... (List_Object_Info): Likewise for the object type. (List_Entities): ...here. In -gnatR4 mode, recurse into entities local to a record type. (List_Component_Layout): In -gnatR4 mode, mark the type as relevant. From-SVN: r274786
2019-08-21[Ada] Add the System.Bitfield_Utils runtime unitBob Duff7-3/+686
2019-08-21 Bob Duff <duff@adacore.com> gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-bitutil.o and s-biutin.o. * exp_ch5.adb (Expand_Assign_Array_Bitfield): New function to generate a call to Copy_Bitfield. This is disabled for now. (Expand_Assign_Array_Loop_Or_Bitfield): New function to decide whether to call Expand_Assign_Array_Bitfield. (Expand_Assign_Array): Call Expand_Assign_Array_Loop_Or_Bitfield instead of Expand_Assign_Array_Loop. * libgnat/s-bitfie.ads, libgnat/s-bituti.adb, libgnat/s-bituti.ads: New units. * rtsfind.ads: Add enum literals for accessing Copy_Bitfield. From-SVN: r274785
2019-08-21[Ada] Bindo.Graphs: Minor typo fixesPiotr Trojanek3-2/+8
2019-08-21 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * bindo-graphs.ads (Iterate_Edges_To_Successors): Fix typo in pragma Inline. * bindo-graphs.adb (Delete_Edge): Fix layout in parameter list. From-SVN: r274784
2019-08-21[Ada] Undefined master in task with limited class-wide aliased entry formalGary Dismukes2-1/+20
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 master. The master object wasn't being copied into the procedure expanded for the task body, but a renaming for the master appeared in the statements of the task body, and the LLVM back end rejects this since the master object doesn't appear in the expanded task procedure (for some reason, gigi doesn't complain). This is fixed by suppressing the creation of the master object in the case where the access-to-limited-class-wide access type is the type of a component in an entry's parameter block. This is similar to the suppression done for the master object in other cases, where the access type designates a type explicitly containing tasks (though the suppression involves testing Comes_From_Source in that case). No simple test (and this only affects the LLVM-based compiler). 2019-08-21 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * exp_ch3.adb (Build_Master): Suppress call to Build_Class_Wide_Master in the case where the access-to-limited-class-wide type was created for a component in an entry's formal parameter block (Is_Parameter_Block_Component_Type), to prevent a master from being created for such access types generated by the front end in a task spec for entry formals in a parameter block. Add a ??? about whether this suppression should be done more generally (such as by using Comes_From_Source). From-SVN: r274783
2019-08-21[Ada] Fix type mismatch in extended return statement expansionEric Botcazou2-25/+68
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. 2019-08-21 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_ch6.adb (Expand_N_Extended_Return_Statement): In the case of a built-in-place function that doesn't need a BIP_Alloc_Form parameter but returns unconstrained, build the return consistently using the function's result subtype. Remove bypass added in previous change. From-SVN: r274782
2019-08-21[Ada] Do not rewrite argument of pragma Entry_Queue_Length in analysisPiotr Trojanek3-10/+10
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 unrewritten AST to detect references to constants declared with SPARK_Mode => Off within a code with SPARK_Mode => On. This change has no impact on compilation, so no frontend test is provided. 2019-08-21 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * sem_prag.adb (Max_Entry_Queue_Length): Do not substitute expression of the pragma argument with its value during analysis. * sem_util.adb (Get_Max_Queue_Length): Compute value of the pragma argument when needed. From-SVN: r274781
2019-08-21[Ada] Avoid spurious error in GNATprove mode on non-null access typesYannick Moy2-0/+11
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. 2019-08-21 Yannick Moy <moy@adacore.com> gcc/ada/ * checks.adb (Install_Null_Excluding_Check): Do not install check in GNATprove mode. From-SVN: r274780
2019-08-21[Ada] Ignore subprogram address in ownership checkingYannick Moy2-0/+6
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. 2019-08-21 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_spark.adb (Process_Path): Do nothing on address of subprogram. From-SVN: r274779
2019-08-21[Ada] Fix assertion failure on derived private protected typeEric Botcazou2-4/+10
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 processing for untagged derivations of private views, but it would no longer trigger for the subtype because this subtype is now represented as a subtype of an implicit derived base type instead of as the derived type of an implicit subtype previously. 2019-08-21 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_util.adb (Finalize_Address): Deal consistently with subtypes of private protected types. gcc/testsuite/ * gnat.dg/prot9.adb, gnat.dg/prot9_gen.ads, gnat.dg/prot9_pkg1.ads, gnat.dg/prot9_pkg2.ads: New testcase. From-SVN: r274778
2019-08-21[Ada] Replace low-level membership tests with high-level routinesPiotr Trojanek4-4/+10
Code cleanup to improve readablity. Semantics unaffected. 2019-08-21 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * exp_util.adb (Corresponding_Runtime_Package): Use high-level Is_Protected_Type. * sem_ch8.adb (Analyze_Renamed_Entry): Likewise. * sem_ch9.adb (Analyze_Requeue): Likewise. From-SVN: r274777
2019-08-21[Ada] Missing attribute update in new_copy_treeJavier Miranda2-7/+18
The compiler crashes processing an internally generated cloned tree that has a subprogram call with a named actual parameter. 2019-08-21 Javier Miranda <miranda@adacore.com> gcc/ada/ * sem_util.adb (Update_Named_Associations): Update First_Named_Actual when the subprogram call has a single named actual. gcc/testsuite/ * gnat.dg/implicit_param.adb, gnat.dg/implicit_param_pkg.ads: New testcase. From-SVN: r274776
2019-08-21[Ada] doc/Makefile: automatically create doc/share/_staticJoel Brobecker2-5/+15
2019-08-21 Joel Brobecker <brobecker@adacore.com> gcc/ada/ * doc/Makefile (mk_empty_dirs): New (PHONY) rule. (%.html, %.pdf, %.txt, %.info, %.texinfo): Add dependencies on mk_empty_dirs. From-SVN: r274775
2019-08-21[Ada] Max_Entry_Queue_Length aspect for protected entriesJustin Squirek5-13/+39
Allow values of negative one to be accepted as a valid parameter as a special case. 2019-08-21 Justin Squirek <squirek@adacore.com> gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Modify documentation to reflect expected behavior. * gnat_rm.texi: Regenerate. * sem_prag.adb (Analyze_Pragma): Modify handling of pragma Max_Entry_Queue_Length to not reject integer values of negative one. * sem_util.adb (Get_Max_Queue_Length): Add processing for values of negative one to fit within the current scheme. From-SVN: r274774
2019-08-20[Ada] Unnesting: take inlining (-gnatn) into accountArnaud Charlet2-7/+41
This affects only LLVM-based compilation. 2019-08-20 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * exp_unst.adb (Unnest_Subprograms, Unnest_Subprogram): Take inlining (-gnatn) into account. From-SVN: r274743
2019-08-20[Ada] Crash on a Storage_Size aspect depending on attr. of another typeEd Schonberg2-10/+39
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 the freeze node for T. 2019-08-20 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_ch13.adb (Expand_N_Attribute_Definition_Clause, case Storage_Size): If the expression for Storage_Size is not static it may depend on characterstics of another type that may bot be frozen yet, so the elaboration of the expression for the aspect must be attached directly to the freeze actions of the type to which it applies. gcc/testsuite/ * gnat.dg/storage_size1.adb: New testcase. From-SVN: r274742
2019-08-20[Ada] Inconsistent scope chain due to quantified expressionPiotr Trojanek2-0/+7
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 fixed previously. For Build_DIC_Procedure_Declaration this is fixed here. The issue affects the GNATprove tool and is not visible to end users of the GNAT compiler. No simple test is available because this would require a debug session. 2019-08-20 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * exp_util.adb (Build_DIC_Procedure_Declaration): Set the last entity of the generated Default_Initial_Condition procedure in order to construct a proper entity chain. From-SVN: r274741
2019-08-20[Ada] Adapt GNATprove expansion for slices with access prefixYannick Moy2-20/+28
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. 2019-08-20 Yannick Moy <moy@adacore.com> gcc/ada/ * exp_spark.adb (Expand_SPARK_N_Slice_Or_Indexed_Component): Renaming of function to apply to slices as well. (Expand_SPARK): Expand prefix of slices of access type. From-SVN: r274740
2019-08-20[Ada] Improve efficiency of aggregates with <>Bob Duff2-3/+16
The generated code has been improved so that aggregates with <> are more efficient. No change in behavior; no test. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * exp_aggr.adb (Expand_Array_Aggregate): Use build-in-place in the nonlimited case in STEP 4. This improves the efficiency of things like (1 .. 1000 => <>). We still generate some code for that, unfortunately, but it is much improved. (Aggr_Assignment_OK_For_Backend): Return false if <> components are present. From-SVN: r274739
2019-08-20[Ada] Improve speed of discriminated return typesBob Duff3-71/+103
The compiler now generates faster code for functions that return discriminated types in many cases where the size is known at compile time. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * exp_ch6.adb (Needs_BIP_Alloc_Form): Call Requires_Transient_Scope rather than checking constrainedness and so forth. We have previously improved Requires_Transient_Scope to return False in various cases, notably a limited record with an access discriminant. This change takes advantage of that to avoid using the secondary stack for functions returning such types. (Make_Build_In_Place_Call_In_Allocator): Be consistent by calling Needs_BIP_Alloc_Form rather than Is_Constrained and so forth. * sem_ch4.adb (Analyze_Allocator): The above change causes the compiler to generate code that is not legal Ada, in particular an uninitialized allocator for indefinite subtype. This is harmless, so we suppress the error message in this case. From-SVN: r274738
2019-08-20[Ada] Minor reformattingsGary Dismukes26-88/+94
2019-08-20 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * ali.adb, ali.ads, aspects.adb, checks.ads, checks.adb, doc/gnat_rm/implementation_defined_pragmas.rst, doc/gnat_ugn/building_executable_programs_with_gnat.rst, einfo.ads, exp_aggr.adb, exp_ch11.adb, exp_ch3.ads, exp_ch4.adb, exp_disp.adb, inline.adb, libgnat/a-locale.ads, libgnat/s-soflin.ads, par_sco.adb, repinfo.adb, sem_ch5.adb, sem_disp.adb, sem_elab.adb, sem_eval.adb, sem_spark.adb, sem_spark.ads, sinfo.ads: Minor reformattings, typo fixes and and rewordings. From-SVN: r274737
2019-08-20[Ada] Set GNAT.OS_Lib.GM_Split's granularity back to 1 secondDmitriy Anisimkov2-8/+6
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. 2019-08-20 Dmitriy Anisimkov <anisimko@adacore.com> gcc/ada/ * adaint.c (__gnat_to_gm_time): On _WIN32, don't round time up to even second. From-SVN: r274736
2019-08-20[Ada] Fix propagation of compiler internal flagEd Schonberg2-0/+23
No change in behavior for GCC-based compilations. 2019-08-20 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): If actual type is private and distinct from nominal type in declaration, propagate flags Is_Constr_Subt_For_U_Nominal and _UN_Aliased to full view of private type. From-SVN: r274735
2019-08-20[Ada] Crash on Loop_Entry for while_loop involving substringsEd Schonberg2-0/+27
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. 2019-08-20 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_attr.adb (Expand_Loop_Entry_Attribute): 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 gigi. gcc/testsuite/ * gnat.dg/loop_entry2.adb: New testcase. From-SVN: r274734
2019-08-20[Ada] Spurious error in dispatching call with class-wide preconditionEd Schonberg2-11/+47
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. 2019-08-20 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_disp.adb (Build_Class_Wide_Check, Replace_Formals): When a dispatching call tp a subprogram with a class-wide precondition occurrs in the same declarative part as the ancestor subprogram being called, the`expression for the precondition has not been analyzed yet. Such a call may appear, e.g. in an expression function. In that case, the replacement of formals by actuals in the call cannot use the formal entities of the subprogram being called, and the occurrence of the formals in the expression must be located by name (Chars fields) as would be done at a later freeze point, when the expression is resolved in the context of the subprogram itself. gcc/testsuite/ * gnat.dg/tagged5.adb, gnat.dg/tagged5.ads: New testcase. From-SVN: r274733
2019-08-20[Ada] Suppress Initialize_Scalars for Persistent_BSSBob Duff2-3/+27
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 Persistent_BSS. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * sem_prag.adb (Persistent_BSS): If an initialization is present because of Initialize_Scalars or Normalize_Scalars, generate an implicit pragma Suppress_Initialization to remove that, because initialization is not allowed for these variables. Other initializations remain illegal. From-SVN: r274732
2019-08-20[Ada] Illegal limited function call accepted in a type conversionGary Dismukes2-5/+34
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 recursively applying OK_For_Limited_Init_In_05 to the expression inside of a rewritten type conversion, rather than directly to the Original_Node itself (which is what was cased on to get to the type conversion case alternative), which allowed such illegal initialization, and that's corrected by this fix. However, when the expression is not a rewriting of a user-written conversion, the recursive call to OK_For_Limited_Init_In_05 must be applied to the Expression of the conversion. 2019-08-20 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * sem_ch3.adb (OK_For_Limited_Init_In_05): In the case of type conversions, apply the recursive call to the Original_Node of the expression Exp rather than the Expression of the Original_Node, in the case where Exp has been rewritten; otherwise, when Original_Node is the same as Exp, apply the recursive call to the Expression. (Check_Initialization): Revise condition for special check on type conversions of limited function calls to test Original_Node (avoiding spurious errors on expanded unchecked conversions applied to build-in-place dispatching calls). gcc/testsuite/ * gnat.dg/type_conv2.adb, gnat.dg/type_conv2.ads: New testcase. From-SVN: r274731
2019-08-20[Ada] New pragma Aggregate_Individually_AssignPatrick Bernardi8-829/+903
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: -- pack.ads pragma Aggregate_Individually_Assign; pragma Restrictions (No_Multiple_Elaboration); package Pack is type A_Rec is record A, B, C, D : Boolean; end record; A : A_Rec := (True, False, True, True); end Pack; when compiled with gcc -c -gnatdg pack.ads should produce the following output: Source recreated from tree for Pack (spec) ------------------------------------------ pragma aggregate_individually_assign; pragma restrictions (no_multiple_elaboration); package pack is type pack__a_rec is record a : boolean; b : boolean; c : boolean; d : boolean; end record; freeze pack__a_rec [ procedure pack__a_recIP (_init : out pack__a_rec) is begin %push_constraint_error_label () %push_program_error_label () %push_storage_error_label () null; %pop_constraint_error_label %pop_program_error_label %pop_storage_error_label return; end pack__a_recIP; ] pack__a : pack__a_rec := ( a => true, b => false, c => true, d => true); pack__a.a := true; pack__a.b := false; pack__a.c := true; pack__a.d := true; null; end pack; 2019-08-20 Patrick Bernardi <bernardi@adacore.com> gcc/ada/ * exp_aggr.adb (Expand_Record_Aggregate): Always convert a record Aggregate to assignment statements if the option Aggregate_Individually_Assign is set. * opt.ads (Aggregate_Individually_Assign): New option. * par-prag.adb (Prag): Add Pragma_Aggregate_Individually_Assign. * sem_prag.adb (Analyze_Pragma): Likewise. * snames.ads-tmpl: Add Pragma_Aggregate_Individually_Assign and Name_Aggregate_Individually_Assign. * doc/gnat_rm/implementation_defined_pragmas.rst: Document pragma Aggregate_Individually_Assign. * gnat_rm.texi: Regenerate. From-SVN: r274730
2019-08-20[Ada] Enable delta_aggregate only in Ada 2020 modeBob Duff3-2/+13
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: compile with -gnatX package Delta_Aggregate is X : String := "Hello"; Y : String := (X with delta 1 => 'h'); end Delta_Aggregate; 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * par-ch4.adb: Minor wording change in error messages. * sem_aggr.adb (Resolve_Delta_Aggregate): Emit an error for Ada versions prior to Ada 2020. From-SVN: r274729
2019-08-20[Ada] Improve generated code for initialization of atomicsBob Duff2-0/+7
This patch makes the temp for initialization of an atomic variable be constant. No change in behavior; no test. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * freeze.adb (Is_Atomic_VFA_Aggregate): Make the temp for initialization of the atomic variable be constant. This is cleaner, and might improve efficiency. From-SVN: r274728
2019-08-20[Ada] More complete information level for -gnatR4 outputEric Botcazou2-0/+14
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 new Rec1 (1, 2); end P; 2019-08-20 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * repinfo.adb (List_Record_Info): In -gnatR4 mode, set the relevant flag on the implicit base type of a record subtype. From-SVN: r274727
2019-08-20[Ada] Fix a folding issue with System'To_AddressBob Duff2-3/+16
2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * sem_eval.adb (Expr_Value): Implement the case of an unchecked conversion of a static expression. From-SVN: r274726
2019-08-20[Ada] Warn on Unchecked_Conversion to zero-sized arrayBob Duff2-16/+59
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. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * sem_ch13.adb (Is_Null_Array): New function, used to detect the null array case; used to warn about uncheckedly converting to a zero-sized array. It is unfortunate that we can't just check the size, and warn on all cases of converting from a nonzero-sized type to a zero-sized one. That's because "0" means two different things: "size is zero" and "size is unknown". Until we fix that design flaw, we need this more targeted fix. gcc/testsuite/ * gnat.dg/unchecked_convert14.adb: New testcase. From-SVN: r274725
2019-08-20[Ada] Efficiency improvement in bounded ordered containersBob Duff3-2/+12
The Delete operations in the bounded ordered containers have been substantially sped up. No change in semantics, so no test. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * libgnat/a-cborma.adb, libgnat/a-cborse.adb (Clear): Repeatedly call Delete. This avoids clearing the free list, which substantially speeds up future Delete operations. From-SVN: r274724
2019-08-20[Ada] Warning for out-of-order record representation clausesBob Duff6-13/+148
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. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * sem_ch13.adb (Component_Order_Check): New procedure to check for out-of-order clauses. * warnsw.ads, warnsw.adb: New -gnatw_r switch. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Document new switch. * gnat_ugn.texi: Regenerate. From-SVN: r274723
2019-08-20[Ada] Object_Size clause specifying 0 bits is illegalBob Duff2-0/+10
The patch gives an error message on "for T'Object_Size use 0;". 2019-08-20 Bob Duff <duff@adacore.com> 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 0;", but it's not important enough to fix. In any case, if we're not going to obey the clause, we should give an error. gcc/testsuite/ * gnat.dg/object_size1.adb: New testcase. From-SVN: r274722
2019-08-20[Ada] Pragma Warning_As_Error works for style warningsBob Duff13-195/+253
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.adb: procedure Style is X : Integer; begin null; --Hello end; gnatmake -q -f -g style.adb -gnaty should get: style.adb:2:04: warning: variable "X" is never read and never assigned style.adb:5:06: error: (style) two spaces required [warning-as-error] style.adb:6:01: (style) "end Style" required gnatmake: "style.adb" compilation error and no executable should be created. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * errout.adb (Error_Msg_Internal): Set Warn_Err in case of Is_Style_Msg. * erroutc.adb (Output_Msg_Text): Do Warnings_Treated_As_Errors processing and [warning-as-error] modification for style messages. Clean up code, simplify, remove unnecessary block statement, add renaming of table entry. * erroutc.ads (Warning_Treated_As_Error): Fix comment: no such thing as Set_Warning_As_Error. * opt.ads: Clean up comments and move related declarations near each other. * par-prag.adb: Process Warning_As_Error. This is necessary because many style warning happen during parsing. * sem_prag.adb: Use new Acquire_Warning_Match_String. * sem_util.ads, sem_util.adb (Acquire_Warning_Match_String): New function shared by par-prag.adb and sem_prag.adb. Replaces the procedure in sem_prag.adb. Avoid use of global variables. * stringt.ads, stringt.adb (To_String): New function to convert String_Id to String. * doc/gnat_rm/implementation_defined_pragmas.rst: Document the new feature. * gnat_rm.texi: Regenerate. From-SVN: r274721
2019-08-20[Ada] Get rid of linear searches in LibEric Botcazou5-26/+116
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 table to record a mapping between the name of units and their entry in the units table, and then replaces the linear searches by lookups in this names table. This can save up to 2% of the compilation time spent in the front-end in some cases. There should be no functional changes, except in the error message issued for circular unit dependencies in very peculiar and convoluted cases. 2019-08-20 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * lib.ads: Add with clause for GNAT.HTable. Add pragma Inline for Is_Loaded and alphabetize the list. (Unit_Name_Table_Size): New constant. (Unit_Name_Header_Num): New subtype. (Unit_Name_Hash): New function declaration. (Unit_Names): New simple hash table. (Init_Unit_Name): New procedure declaration. * lib.adb (Set_Unit_Name): Unregister the old name in the table, if any, and then register the new name. (Init_Unit_Name): New procedure. (Is_Loaded): Reimplement using a lookup in the names table. (Remove_Unit): Unregister the name. (Unit_Name_Hash): New function. * lib-load.adb (Create_Dummy_Package_Unit): Call Init_Unit_Name. (Load_Unit): Use a lookup in the names table to find out whether the unit has already been loaded. Call Init_Unit_Name and then Remove_Unit if the loading has failed. (Make_Child_Decl_Unit): Call Init_Unit_Name. (Make_Instance_Unit): Likewise. * lib-writ.adb (Ensure_System_Dependency): Likewise. From-SVN: r274720
2019-08-20[Ada] Sem_Ch13: fix uninitialized parameter static analysis warningBob Duff2-0/+6
No functional change. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * sem_ch13.adb (Record_Hole_Check): Initialize After_Last. From-SVN: r274719
2019-08-20[Ada] Revert change for gnatprove that is no longer neededPiotr Trojanek2-13/+9
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 test provided, because the removed comment is clear that this doesn't affect the compiler. Other tools similarly should not be affected (at least they were not when this change was introduced in 2012). 2019-08-20 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * impunit.adb (Get_Kind_Of_Unit): Revert change for adapting this routine for gnatprove. From-SVN: r274718
2019-08-20[Ada] Document requirements for Pragma Lock_FreeArnaud Charlet3-0/+65
2019-08-20 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Document requirements for Pragma Lock_Free. * gnat_rm.texi: Regenerate. From-SVN: r274717
2019-08-20[Ada] Initialize gnat_argc/gnat_argv only the first timePhilippe Gil2-4/+16
2019-08-20 Philippe Gil <gil@adacore.com> gcc/ada/ * bindgen.adb (Gen_Main): Set gnat_argc/gnat_argv to argc/argv only when still uninitialized. From-SVN: r274716
2019-08-20[Ada] Fix documentation for GNAT.Command_Line.Exit_From_Command_LineBob Duff2-2/+7
2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * libgnat/g-comlin.ads (Exit_From_Command_Line): Fix documentation for GNAT.Command_Line. From-SVN: r274715
2019-08-20[Ada] Add missing dot at the end of lang.opt doc for -fdump-scosPierre-Marie de Rodat2-1/+7
2019-08-20 Pierre-Marie de Rodat <derodat@adacore.com> gcc/ada/ PR ada/91492 * gcc-interface/lang.opt (-fdump-scos): Add missing dot at the end of the documentation. From-SVN: r274714
2019-08-20Use function_arg_info for TARGET_PASS_BY_REFERENCERichard Sandiford2-1/+6
The hook is passed the unpromoted type mode instead of the promoted mode. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * doc/tm.texi: Regenerate. * targhooks.h (hook_pass_by_reference_must_pass_in_stack): Update accordingly. (hook_bool_CUMULATIVE_ARGS_arg_info_false): Declare. * targhooks.c (hook_pass_by_reference_must_pass_in_stack): Take a function_arg_info instead of a mode, type and named flag. (hook_bool_CUMULATIVE_ARGS_arg_info_false): New function. * calls.h (pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * calls.c (pass_by_reference): Likewise. (pass_va_arg_by_reference): Update call accordingly. (initialize_argument_information): Likewise. (emit_library_call_value_1): Likewise. * function.c (assign_parm_find_data_types): Likewise. * var-tracking.c (prepare_call_arguments): Likewise. * stor-layout.c: Include calls.h. (compute_record_mode): Update call to targetm.calls.pass_by_reference. * config/aarch64/aarch64.c (aarch64_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/alpha/alpha.c (alpha_pass_by_reference): Likewise. * config/arc/arc.c (arc_pass_by_reference): Likewise. * config/arm/arm.c (arm_pass_by_reference): Likewise. * config/bfin/bfin.c (bfin_pass_by_reference): Likewise. * config/c6x/c6x.c (c6x_pass_by_reference): Likewise. (c6x_call_saved_register_used): Update call to pass_by_reference. * config/cris/cris.c (cris_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/epiphany/epiphany.c (epiphany_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. (epiphany_arg_partial_bytes): Update call accordingly. * config/ft32/ft32.c (ft32_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. (ft32_arg_partial_bytes): Update call accordingly. * config/i386/i386.c (ix86_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/iq2000/iq2000.c (iq2000_pass_by_reference): Likewise. * config/m32c/m32c.c (m32c_pass_by_reference): Likewise. * config/m32r/m32r.c (m32r_pass_by_reference): Likewise. (m32r_return_in_memory): Update call accordingly. * config/mips/mips.c (mips_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/mmix/mmix.c (mmix_pass_by_reference): Likewise. * config/mn10300/mn10300.c (mn10300_pass_by_reference): Likewise. * config/moxie/moxie.c (moxie_pass_by_reference): Likewise. (moxie_arg_partial_bytes): Update call accordingly. * config/msp430/msp430.c (msp430_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/nvptx/nvptx.c (nvptx_pass_by_reference): Likewise. * config/or1k/or1k.c (or1k_pass_by_reference): Likewise. * config/pa/pa.c (pa_pass_by_reference): Likewise. * config/riscv/riscv.c (riscv_pass_by_reference): Likewise. (riscv_return_in_memory): Update call accordingly. * config/rs6000/rs6000-internal.h (rs6000_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/rs6000/rs6000-call.c (rs6000_pass_by_reference): Likewise. (rs6000_parm_needs_stack): Update call to pass_by_reference. * config/s390/s390.c (s390_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. (s390_call_saved_register_used): Update call accordingly. * config/sh/sh.c (sh_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/sparc/sparc.c (sparc_pass_by_reference): Likewise. * config/spu/spu.c (spu_pass_by_reference): Likewise. * config/tilegx/tilegx.c (tilegx_pass_by_reference): Likewise. * config/tilepro/tilepro.c (tilepro_pass_by_reference): Likewise. * config/v850/v850.c (v850_pass_by_reference): Likewise. * config/visium/visium.c (visium_pass_by_reference): Likewise. gcc/ada/ * gcc-interface/misc.c (default_pass_by_ref): Update call to pass_by_reference. From-SVN: r274698
2019-08-19[Ada] Fix documentation for stream oriented attributesBob Duff3-33/+39
2019-08-19 Bob Duff <duff@adacore.com> gcc/ada/ * doc/gnat_rm/implementation_advice.rst: Fix documentation for stream oriented attributes. * gnat_rm.texi: Regenerate. From-SVN: r274666