aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2022-11-09sphinx: support installation if sphinx-build is missingMartin Liska1-6/+3
gcc/ChangeLog: * Makefile.in: Support installation if sphinx-build is missing. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Support installation if sphinx-build is missing. gcc/cp/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/d/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/fortran/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/go/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. Support installation if sphinx-build is missing. gcc/jit/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing.
2022-11-09sphinx: fix cross manual referencesMartin Liska1-1/+2
gcc/ada/ChangeLog: * doc/gnat_rm/index.rst: Fix cross manual refs. gcc/ChangeLog: * doc/gcc/gcc-command-options/options-controlling-the-kind-of-output.rst: Fix cross manual refs. * doc/gcc/language-standards-supported-by-gcc/references-for-other-languages.rst: Likewise. gcc/jit/ChangeLog: * doc/internals/index.rst: Fix cross manual refs. * doc/topics/contexts.rst: Likewise.
2022-11-09sphinx: add --with-sphinx-buildMartin Liska1-12/+12
gcc/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: * configure: Regenerate. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Support --with-sphinx-build. gcc/d/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/fortran/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/go/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/jit/ChangeLog: * Make-lang.in: Support --with-sphinx-build. libgomp/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise.. * configure: Regenerate. libiberty/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate. libitm/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate. libquadmath/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate.
2022-11-09sphinx: ada: port to SphinxMartin Liska20-62000/+247
gcc/ada/ChangeLog: * doc/gnat-style.rst: Moved to... * doc/gnat-style/index.rst: ...here. * doc/gnat_rm.rst: Moved to... * doc/gnat_rm/index.rst: ...here. * doc/gnat_ugn.rst: Moved to... * doc/gnat_ugn/index.rst: ...here. * doc/share/latex_elements.py: Moved to... * doc/share/ada_latex_elements.py: ...here. * gcc-interface/Make-lang.in: * doc/Makefile: Removed. * doc/share/conf.py: Removed. * doc/share/gnu_free_documentation_license.rst: Removed. * gnat-style.texi: Removed. * gnat_rm.texi: Removed. * gnat_ugn.texi: Removed. * doc/gnat-style/conf.py: New file. * doc/gnat-style/gnu_free_documentation_license.rst: New file. * doc/gnat_rm/conf.py: New file. * doc/gnat_rm/gnu_free_documentation_license.rst: New file. * doc/gnat_ugn/conf.py: New file. * doc/gnat_ugn/gnu_free_documentation_license.rst: New file. * doc/share/adabaseconf.py: New file. * doc/gnat_rm/security_hardening_features.rst: Add role. * doc/gnat_ugn/platform_specific_information.rst: Remove duplicate definition of |nbsp|.
2022-11-09Daily bump.GCC Administrator1-0/+296
2022-11-08ada: Fix oversight in implementation of allocators for storage modelsEric Botcazou1-7/+26
When the allocator is of an unconstrained array type and has an initializing expression, the copy of the initializing expression must be done separately from that of the bounds. gcc/ada/ * gcc-interface/utils2.cc (build_allocator): For unconstrained array types with a storage model and an initializing expression, copy the initialization expression separately from the bounds. In all cases with a storage model, pass the locally computed size for the store.
2022-11-08ada: Compile-time simplification of 'Image incorrectly ignores Put_ImageSteve Baird1-1/+3
In the case of Some_Enumeration_Type'Image (<some static value>), the compiler will replace this expression in its internal program representation with a corresponding string literal. This is incorrect if the Put_Image aspect has been specified (directly or via inheritance) for the enumeration type. gcc/ada/ * sem_attr.adb (Eval_Attribute): Don't simplify 'Image call if Put_Image has been specified.
2022-11-08ada: Clean up call to check if aspects are presentPiotr Trojanek7-16/+14
Code cleanup; semantics is unaffected. gcc/ada/ * exp_ch6.adb, exp_put_image.adb, sem_aggr.adb, sem_attr.adb, sem_ch5.adb, sem_type.adb, sem_util.adb: Replace "Present (Find_Aspect (...))" with "Has_Aspect".
2022-11-08ada: Adjust classwide contract expression preanalysisRonan Desplanques3-232/+267
Before this patch, a classwide contract expression was preanalyzed only when its primitive operation's type was frozen. It caused name resolution to be off in the cases where the freezing took place after the end of the declaration list the primitive operation was declared in. This patch makes it so that if the compiler gets to the end of the declaration list before the type is frozen, it preanalyzes the classwide contract expression, so that the names are resolved in the right context. gcc/ada/ * contracts.adb (Preanalyze_Class_Conditions): New procedure. (Preanalyze_Condition): Moved out from Merge_Class_Conditions in order to be spec-visible. * contracts.ads (Preanalyze_Class_Conditions): New procedure. * sem_prag.adb (Analyze_Pre_Post_Condition_In_Decl_Part): Call Preanalyze_Class_Conditions when necessary.
2022-11-08ada: Set Support_Atomic_Primitives for VxWorks 7 runtimesJohannes Kliemann12-8/+12
gcc/ada/ * libgnat/system-vxworks7-aarch64-rtp-smp.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-aarch64.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-arm-rtp-smp.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-arm.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-ppc-kernel.ads: Set Support_Atomic_Primitives to False. * libgnat/system-vxworks7-ppc-rtp-smp.ads: Set Support_Atomic_Primitives to False. * libgnat/system-vxworks7-ppc64-kernel.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-ppc64-rtp-smp.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-x86-kernel.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-x86-rtp-smp.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-x86_64-kernel.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-x86_64-rtp-smp.ads: Set Support_Atomic_Primitives to True.
2022-11-08ada: Small consistency fixEric Botcazou1-1/+1
gcc/ada/ * fe.h (Get_Warn_On_Questionable_Layout): Add void parameter.
2022-11-08ada: Propagate aspect Ghost when instantiating null formal proceduresPiotr Trojanek1-0/+2
When instantiating generic package that includes a formal subprogram declaration with Ghost aspect and a subprogram_default of null, e.g.: generic with procedure Proc is null with Ghost; package P is ... the Ghost aspect should be propagated to the internally generated null subprogram, so this null subprogram can be used in contexts that require ghost entities. gcc/ada/ * sem_ch12.adb (Instantiate_Formal_Subprogram): Copy aspect Ghost from formal subprogram declaration to the internally generated procedure.
2022-11-08ada: Implement RM 4.5.7(10/3) name resolution ruleEric Botcazou2-82/+156
This rule deals with the specific case of a conditional expression that is the operand of a type conversion and effectively distributes the conversion to the dependent expressions with the help of the dynamic semantics. gcc/ada/ * sem_ch4.adb (Analyze_Case_Expression): Compute the interpretations of the expression only at the end of the analysis, but skip doing it if it is the operand of a type conversion. (Analyze_If_Expression): Likewise. * sem_res.adb (Resolve): Deal specially with conditional expression that is the operand of a type conversion. (Resolve_Dependent_Expression): New procedure. (Resolve_Case_Expression): Call Resolve_Dependent_Expression. (Resolve_If_Expression): Likewise. (Resolve_If_Expression.Apply_Check): Take result type as parameter. (Resolve_Type_Conversion): Do not warn about a redundant conversion when the operand is a conditional expression.
2022-11-08ada: Enforce matching of extra formalsJavier Miranda13-458/+1437
This patch enforces matching of extra formals in overridden subprograms, subprogram renamings, and subprograms to which attributes 'Access, 'Unchecked_Access, or 'Unrestricted_Access is applied (for these access cases the subprogram is checked against its corresponding subprogram type). This enforcement is an internal consistency check, not an implementation of some language legality rule. gcc/ada/ * debug.adb (Debug_Flag_Underscore_XX): Switch -gnatd_X used temporarily to allow disabling extra formal checks. * exp_attr.adb (Expand_N_Attribute_Reference [access types]): Add extra formals to the subprogram referenced in the prefix of 'Unchecked_Access, 'Unrestricted_Access or 'Access; required to check that its extra formals match the extra formals of the corresponding subprogram type. * exp_ch3.adb (Stream_Operation_OK): Declaration moved to the public part of the package. (Validate_Tagged_Type_Extra_Formals): New subprogram. (Expand_Freeze_Record_Type): Improve the code that takes care of adding the extra formals of dispatching primitives; extended to add also the extra formals to renamings of dispatching primitives. * exp_ch3.ads (Stream_Operation_OK): Declaration moved from the package body. * exp_ch6.adb (Check_BIP_Actuals): Complete documentation. (Has_BIP_Extra_Formal): Subprogram declaration moved to the public part of the package. In addition, a parameter has been added to disable an assertion that requires its use with frozen entities. (Duplicate_Params_Without_Extra_Actuals): New subprogram. (Check_Subprogram_Variant): Emit the call without duplicating the extra formals since they will be added when the call is analyzed. (Expand_Call_Helper): Ensure that the called subprogram has all its extra formals, enforce assertion checking extra formals on thunks, and mark calls from thunks as processed-BIP-calls to avoid adding their extra formals twice. (Is_Build_In_Place_Function): Return False for entities with foreign convention. (Is_Build_In_Place_Function_Call): Return True also for not BIP functions that have BIP formals since the extra actuals are required. (Make_Build_In_Place_Call_In_Object_Declaration): Occurrences of Is_Return_Object replaced by the local variable Is_OK_Return_Object that evaluates to False for scopes with foreign convention. (Might_Have_Tasks): Fix check of class-wide limited record types. (Needs_BIP_Task_Actuals): Remove assertion to allow calling this function in more contexts; in addition it returns False for functions returning objects with foreign convention. (Needs_BIP_Finalization_Master): Likewise. (Needs_BIP_Alloc_Form): Likewise. (Validate_Subprogram_Calls): Check that the number of actuals (including extra actuals) of calls in the subtree N match their corresponding formals. * exp_ch6.ads (Has_BIP_Extra_Formal): Subprogram declaration moved to the public part of the package. In addition, a parameter has been added to disable an assertion that requires its use with frozen entities. (Is_Build_In_Place_Function_Call): Complete documentation. (Validate_Subprogram_Calls): Check that the number of actuals (including extra actuals) of calls in the subtree N match their corresponding formals. * freeze.adb (Check_Itype): Add extra formals to anonymous access subprogram itypes. (Freeze_Expression): Improve code that disables the addition of extra formals to functions with foreign convention. (Check_Extra_Formals): Moved to package Sem_Ch6 as Extra_Formals_OK. (Freeze_Subprogram): Add extra formals to non-dispatching subprograms. * frontend.adb (Frontend): Validate all the subprogram calls; it can be disabled using switch -gnatd_X * sem_ch3.adb (Access_Subprogram_Declaration): Defer the addition of extra formals to the freezing point so that we know the convention. (Check_Anonymous_Access_Component): Likewise. (Derive_Subprogram): Fix documentation. * sem_ch6.adb (Has_Reliable_Extra_Formals): New subprogram. (Check_Anonymous_Return): Fix check of access to class-wide limited record types. (Check_Untagged_Equality): Placed in alphabetical order. (Extra_Formals_OK): Subprogram moved from freeze.adb. (Extra_Formals_Match_OK): New subprogram. (Has_BIP_Formals): New subprogram. (Has_Extra_Formals): New subprograms. (Needs_Accessibility_Check_Extra): New subprogram. (Parent_Subprogram): New subprogram. (Add_Extra_Formal): Minor code cleanup. (Create_Extra_Formals): Enforce matching extra formals on overridden and aliased entities. * sem_ch6.ads (Extra_Formals_Match_OK): New subprogram. (Extra_Formals_OK): Subprogram moved from freeze.adb. * sem_eval.adb (Compile_Time_Known_Value): Improve predicate to avoid assertion failure; found working on this ticket; this change does not affect the behavior of the compiler because this subprogram has an exception handler that returns False when the assertion fails. * sem_util.adb (Needs_Result_Accessibility_Level): Do not return False for dispatching operations compiled with Ada_Version < 2012 since they they may be overridden by primitives compiled with Ada_Version >= Ada_2012.
2022-11-08ada: Move warnings switches -- initial workBob Duff11-23/+20
This patch prepares to move warning switches from Opt into Warnsw. gcc/ada/ * warnsw.ads, warnsw.adb, fe.h, err_vars.ads, errout.ads: Move Warning_Doc_Switch from Err_Vars to Warnsw. Access Warn_On_Questionable_Layout on the C side via a function rather than a variable, because we plan to turn the variables into renamings, and you can't Export renamings. * erroutc.adb, switch-c.adb, errout.adb: Likewise. * gcc-interface/decl.cc: Use Get_Warn_On_Questionable_Layout instead of Warn_On_Questionable_Layout. * gcc-interface/Makefile.in (GNATMAKE_OBJS): Add warnsw.o, because it is indirectly imported via Errout. * gcc-interface/Make-lang.in (GNATBIND_OBJS): Likewise and remove restrict.o (not needed).
2022-11-08ada: Align -gnatwc's documentation with its behaviorRonan Desplanques2-2/+2
Shortly after the -gnatwc flag was introduced, its behavior was tweaked, but its documentation was not updated accordingly. gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (-gnatwc): Fix flag documentation. * gnat_ugn.texi: Regenerate.
2022-11-08ada: Improve handling of declare expressions in deferred-freezing contextsSteve Baird1-0/+20
In some cases where a declare expression occurs in a deferred-freezing context (e.g., within the default value for a discriminant or for a formal parameter, or within the expression of an expression function), the compiler generates a bugbox. gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Do not perform expansion actions if In_Spec_Expression is true.
2022-11-08ada: Minor consistency tweaks in Sem_Ch4Eric Botcazou1-15/+24
This ensures that, during the analysis of the qualified expressions, type conversions and unchecked type conversions, the determination of the type of the node and the analysis of its expression are done in the same order. No functional changes. gcc/ada/ * sem_ch4.adb (Analyze_Qualified_Expression): Analyze the expression only after setting the type. (Analyze_Unchecked_Type_Conversion): Likewise. (Analyze_Short_Circuit): Likewise for the operands. (Analyze_Type_Conversion): Minor tweaks. (Analyze_Unchecked_Expression): Likewise.
2022-11-08ada: Remove redundant line in Analyze_Qualified_ExpressionEric Botcazou1-2/+0
The same statement is present a few lines above. gcc/ada/ * sem_ch4.adb (Analyze_Qualified_Expression): Remove redundant line.
2022-11-08ada: Preanalyze classwide contracts as spec expressionsRonan Desplanques1-2/+2
Classwide contracts are "spec expressions" as defined in the documentation in sem.ads. Before this patch, the instances of classwide contracts that are destined to class conditions merging were not preanalyzed as spec expressions. That caused preanalysis to emit spurious errors in some cases. gcc/ada/ * contracts.adb (Preanalyze_Condition): Use Preanalyze_Spec_Expression.
2022-11-08ada: Fix expansion of 'Wide_Image and 'Wide_Wide_Image on composite typesPiotr Trojanek4-7/+51
Attributes Wide_Image and Wide_Wide_Image applied to composite types are now expanded just like attribute Image. gcc/ada/ * exp_imgv.adb (Expand_Wide_Image_Attribute): Handle just like attribute Image. (Expand_Wide_Wide_Image_Attribute): Likewise. * exp_put_image.adb (Build_Image_Call): Adapt to also work for Wide and Wide_Wide attributes. * exp_put_image.ads (Build_Image_Call): Update comment. * rtsfind.ads (RE_Id): Support wide variants of Get. (RE_Unit_Table): Likewise.
2022-11-08ada: Fix inconsistent whitespace in Ada.Numerics.Generic_Complex_ArraysPiotr Trojanek2-4/+4
Cleanup only. gcc/ada/ * libgnat/a-ngcoar.ads, libgnat/a-ngcoar.adb: Remove extra spaces.
2022-11-08ada: Remove unneeded code in handling formal type defaultsPiotr Trojanek1-4/+2
Unneeded code found while experimenting with improved detection of unreferenced objects. gcc/ada/ * sem_ch12.adb (Validate_Formal_Type_Default): Remove call to Collect_Interfaces, which had no effect apart from populating a list that was not used; fix style.
2022-11-08ada: Cleanup local variable that is only set as an out parameterPiotr Trojanek2-10/+10
Minor improvements; found experimenting with improved detection of unreferenced objects. gcc/ada/ * exp_spark.adb (SPARK_Freeze_Type): Refine type of a local object. * sem_ch3.adb (Derive_Subprograms): Remove initial value for New_Subp, which is in only written as an out parameter and never read.
2022-11-08ada: Remove obsolete code in Resolve_If_ExpressionEric Botcazou1-12/+1
gcc/ada/ * sem_res.adb (Resolve_If_Expression): Remove obsolete special case.
2022-11-08ada: Reject limited objects in array and record delta aggregatesPiotr Trojanek1-0/+17
For array delta aggregates the base expression cannot be limited; for record delta aggregates the base expression can only be limited if it is a newly constructed object. gcc/ada/ * sem_aggr.adb (Resolve_Delta_Aggregate): Implement rules related to limited objects appearing as the base expression.
2022-11-08ada: Allow initialization of limited objects with delta aggregatesPiotr Trojanek1-0/+1
Objects of a limited type can be initialized with "aggregates", which is a collective term for ordinary aggregates (i.e. record aggregates and array aggregates), extension aggregates and finally for delta aggregates (introduced by Ada 2022). gcc/ada/ * sem_ch3.adb (OK_For_Limited_Init_In_05): Handle delta aggregates just like other aggregates.
2022-11-08ada: Reject record delta aggregates with limited expressionsPiotr Trojanek1-0/+10
Implement a missing check related to record delta aggregates. gcc/ada/ * sem_aggr.adb (Resolve_Delta_Record_Aggregate): Reject expressions of a limited types.
2022-11-08ada: Missing master of task causing assertion failureJavier Miranda1-1/+36
gcc/ada/ * exp_ch9.adb (Build_Master_Entity): Handle missing case: when the context of the master is a BIP function whose result type has tasks.
2022-11-08ada: Raise Tag_Error when Ada.Tags operations are called with No_TagPiotr Trojanek1-7/+15
Implement missing behavior of RM 13.9 (25.1/3): Tag_Error is raised by a call of Interface_Ancestor_Tags and Is_Descendant_At_Same_Level, if any tag passed is No_Tag. This change also fixes Descendant_Tag, which relies on Is_Descendant_At_Same_Level. The remaining operations already worked properly. gcc/ada/ * libgnat/a-tags.adb (Interface_Ancestor_Tags): Raise Tag_Error on No_Tag. (Is_Descendant_At_Same_Level): Likewise.
2022-11-08ada: Add new -gnatw_q switch to usage messageBob Duff1-0/+4
...along with -gnatw_Q. gcc/ada/ * usage.adb: Add -gnatw_q and -gnatw_Q.
2022-11-08Daily bump.GCC Administrator1-0/+219
2022-11-07ada: Document that gprof won't work on windows with PIE.Cedric Landet2-4/+11
Document that gprof won't work on windows with PIE and -no-pie must be used. gcc/ada/ * doc/gnat_ugn/gnat_and_program_execution.rst: Mention the needed -no-pie for windows to use gprof. * gnat_ugn.texi: Regenerate.
2022-11-07ada: Tune hash function for cross-reference entriesPiotr Trojanek1-2/+2
Tune the hash function that combines entity identifiers with source locations of where those entities are referenced. Previously the source location was multiplied by 2 ** 7 (i.e. shifted left by 7 bits), then added to the entity identifier, and finally divided modulo 2 ** 16 (i.e. masked to only use the lowest 16 bits). This hash routine caused collisions that could make some tests up to twice slower. With a large entity number the source location was only contributing few bits to the hash value. This large entity number might correspond to entity like Ada.Characters.Latin_1.NUL that occurs thousands of times in generated code. gcc/ada/ * lib-xref.adb (Hash): Tune hash function.
2022-11-07ada: Fix performance regression related to references in Refined_StatePiotr Trojanek1-27/+29
Recently added call to In_Pragma_Expression caused a performance regression. It might require climbing syntax trees of arbitrarily deep expressions, while previously references within pragmas were detected in bounded time. This patch restores the previous efficiency. However, while the original code only detected references directly within pragma argument associations, now we also detect references inside aggregates, e.g. like those in pragma Refined_State. gcc/ada/ * sem_prag.adb (Non_Significant_Pragma_Reference): Detect references with aggregates; only assign local variables Id and C when necessary.
2022-11-07ada: Use named notation in calls to Expand_Composite_EqualityBob Duff1-12/+18
Use named notation in calls to Expand_Composite_Equality. gcc/ada/ * exp_ch4.adb (Component_Equality, Expand_Array_Equality) (Expand_Record_Equality): Use named notation.
2022-11-07ada: New warning about noncomposing user-defined "="Bob Duff10-34/+145
Print warning for a user-defined "=" that does not compose as might be expected (i.e. is ignored for predefined "=" of a containing record or array type). This warning is enabled by -gnatw_q; we don't enable it by default because it generates too many false positives. We also don't enable it via -gnatwa. gcc/ada/ * exp_ch4.adb (Expand_Array_Equality): Do not test Ltyp = Rtyp here, because that is necessarily true. Move assertion thereof to more general place. (Expand_Composite_Equality): Pass in Outer_Type, for use in warnings. Rename Typ to be Comp_Type, to more clearly distinguish it from Outer_Type. Print warning when appropriate. * exp_ch4.ads: Minor comment fix. * errout.ads: There is no such pragma as Warning_As_Pragma -- Warning_As_Error must have been intended. Improve comment for ?x?. * exp_ch3.adb (Build_Untagged_Equality): Update comment to be accurate for more recent versions of Ada. * sem_case.adb (Choice_Analysis): Declare user-defined "=" functions as abstract. * sem_util.ads (Is_Bounded_String): Give RM reference in comment. * warnsw.ads, warnsw.adb (Warn_On_Ignored_Equality): Implement new warning switch -gnatw_q. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Document new warning switch. * gnat_ugn.texi: Regenerate.
2022-11-07ada: Inline composite node kind AST queriesPiotr Trojanek2-2/+3
Queries that ultimately examine the same field of an AST node (e.g. Nkind) are visibly more efficient when inlined. In particular, routines Is_Body_Or_Package_Declaration and Is_Body can apparently be inlined into a single Nkind membership test. This patch fixes some of the performance lost with the recent changes, which increased the number of calls to Is_Body_Or_Package_Declaration (as it is typically used to prevent AST search from climbing too far). However, it should be generally beneficial to inline routines like this. gcc/ada/ * sem_aux.ads (Is_Body): Annotate with Inline. * sem_util.ads (Is_Body_Or_Package_Declaration): Likewise.
2022-11-07ada: Fix inherited postconditions in inlined subprogramsBob Duff1-5/+10
Protect the building of postcondition pragmas in case the postcondition is not present due to inlining. gcc/ada/ * freeze.adb (Build_Inherited_Condition_Pragmas): Do nothing if A_Post is empty.
2022-11-07ada: Fixed elaboration of CUDA programs.Quentin Ochem1-9/+11
The names of imported / exported symbols were not consistent between the device and the host when compiling for CUDA. Remove the function Device_Ada_Final_Link_Name as it is no longer referenced. gcc/ada/ * bindgen.adb: fixed the way the device init and final symbols are computed, re-using the normal way these symbols would be computed with a __device_ prefix. Also fixed the "is null;" procedure on the host side which are not Ada 95, replaced with a procedure raising an exception as it should never be called. Remove the unused function Device_Ada_Final_Link_Name. Co-authored-by: Steve Baird <baird@adacore.com>
2022-11-07ada: Rework CUDA host-side invocation of device-side elaboration codeSteve Baird3-36/+34
When the binder is invoked with a "-d_c" switch, add an argument to that switch which is the library name on the device side; so "-d_c" becomes "-d_c=some_library_name". This does not effect the case where "-d_c" is specified as a switch for compilation (as opposed to binding). Use this new piece of information in the code generated by the binder to invoke elaboration code on the device side from the host side. gcc/ada/ * opt.ads: Declare new string pointer variable, CUDA_Device_Library_Name. Modify comments for existing Boolean variable Enable_CUDA_Device_Expansion. * switch-b.adb: When "-d_c" switch is encountered, check that the next character is an "'='; use the remaining characters to initialize Opt.CUDA_Device_Library_Name. * bindgen.adb: Remove (for now) most support for host-side invocation of device-side finalization. Make use of the new CUDA_Device_Library_Name in determining the string used to refer (on the host side) to the device-side initialization procedure. Declare the placeholder routine that is named in the CUDA_Execute pragma (and the CUDA_Register_Function call) as an exported null procedure, rather than as an imported procedure. It is not clear whether it is really necessary to specify the link-name for this should-never-be-called subprogram on the host side, but for now it shouldn't hurt to do so.
2022-11-07ada: Fix detection of external calls to protected objects in instancesPiotr Trojanek1-1/+1
Detection of external-vs-internal calls to protected objects relied on the scope stack. This didn't work when the call appeared in an instance of generic unit, because instances are analyzed in different context to where they appear. gcc/ada/ * exp_ch6.adb (Expand_Protected_Subprogram_Call): Examine scope tree and not the scope stack.
2022-11-07ada: Clean up unnecessary nesting in code for DLL librariesPiotr Trojanek2-44/+28
Code cleanup; issue spotted while examining routines with No_ prefix. gcc/ada/ * mdll.ads (Build_Import_Library): Fix grammar in comment. * mdll.adb (Build_Import_Library): Directly execute code of a nested routine; rename No_Lib_Prefix to Strip_Lib_Prefix.
2022-11-07ada: Suppress warnings on derived True/FalseBob Duff1-70/+49
GNAT normally warns on "return ...;" if the "..." is known to be True or False, but not when it is a Boolean literal True or False. This patch also suppresses the warning when the type is derived from Boolean, and has convention C or Fortran (and therefore True is represented as "nonzero"). Without this fix, GNAT would give warnings like "False is always False". gcc/ada/ * sem_warn.adb (Check_For_Warnings): Remove unnecessary exception handler. (Warn_On_Known_Condition): Suppress warning when we detect a True or False that has been turned into a more complex expression because True is represented as "nonzero". (Note that the complex expression will subsequently be constant-folded to a Boolean True or False). Also simplify to always print "condition is always ..." instead of special-casing object names. The special case was unhelpful, and indeed wrong when the expression is a literal.
2022-11-07ada: Deconstruct Safe_To_Capture_In_Parameter_ValuePiotr Trojanek2-118/+7
Recently routine Safe_To_Capture_Value was adapted, so that various data properties like validity/nullness/values are tracked also for in-parameters. Now a similar routine Safe_To_Capture_In_Parameter_Value, which was only used to track data nullness, is redundant, so this patch deconstructs it. Also the removed routine had at least few problems and limitations, for example: 1) it only worked for functions and procedures, but not for protected entries and task types (whose discriminants work very much like in-parameters) 2) it only worked for subprogram bodies with no spec, because of this dubious check (here simplified): if Nkind (Parent (Parent (Current_Scope))) /= N_Subprogram_Body then return False; 3) it only recognized references within short-circuit operators as certainly evaluated if they were directly their left hand expression, e.g.: X.all and then ... but not when they were certainly evaluated as part of a bigger expression on the left hand side, e.g.: (X.all > 0) and then ... 4) it categorizes parameters with 'Unrestricted_Access attribute as safe to capture, which is not necessarily wrong, but risky (because the object becomes aliased). Routine Safe_To_Capture_Value, which is kept by this patch, seems to behave better in all those situations, though it has its own problems as well and ideally should be further scrutinized. gcc/ada/ * checks.adb (Safe_To_Capture_In_Parameter_Value): Remove. * sem_util.adb (Safe_To_Capture_Value): Stop search at the current body.
2022-11-07ada: Flip warning suppression routine to positive meaningPiotr Trojanek1-16/+11
Subprogram names starting with No_ seem unnecessarily confusing. Cleanup related to improved detection of references to uninitialized objects; semantics is unaffected. gcc/ada/ * sem_warn.adb (Warn_On_In_Out): Remove No_ prefix; flip return values between True and False; adapt caller.
2022-11-07ada: Cleanup detection of code within generic instancesPiotr Trojanek4-8/+5
To check if a node is located in a generic instance we can either look at Instantiation_Location or at the Instantiation_Depth, but just looking at the location is simpler and more efficient. Cleanup related to improved detection of references to uninitialized objects; semantics is unaffected. gcc/ada/ * sem_ch13.adb (Add_Call): Just look at Instantiation_Depth. * sem_ch3.adb (Derive_Subprograms): Likewise. * sem_warn.adb (Check_References): Remove redundant filtering with Instantiation_Depth that follows filtering with Instantiation_Location. * sinput.adb (Instantiation_Depth): Reuse Instantiation_Location.
2022-11-07ada: Remove redundant suppression for non-modified IN OUT parametersPiotr Trojanek1-6/+4
Non-modified IN OUT parameters are first collected and then filtered by examining uses of their enclosing subprograms. In this filtering we don't need to look again at properties of the formal parameters themselves. Cleanup related to improved detection of references to uninitialized objects; semantics is unaffected. gcc/ada/ * sem_warn.adb (No_Warn_On_In_Out): For subprograms we can simply call Warnings_Off. (Output_Non_Modified_In_Out_Warnings): Remove repeated suppression.
2022-11-07ada: Reject boxes in delta array aggregatesPiotr Trojanek1-1/+12
Implement Ada 2022 4.3.4(11/5), which rejects box compound delimiter <> in delta record aggregates, just like another rule rejects it in delta array aggregates. gcc/ada/ * sem_aggr.adb (Resolve_Delta_Array_Aggregate): Reject boxes in delta array aggregates.
2022-11-07ada: Allow reuse of Enclosing_Declaration_Or_Statement by GNATprovePiotr Trojanek3-31/+31
Move routine Enclosing_Declaration_Or_Statement from body of Sem_Res to spec of Sem_Util, so it can be reused. In particular, GNATprove needs this functionality to climb from an arbitrary subexpression with target_name (@) to the enclosing assignment statement. Behaviour of the compiler is unaffected. gcc/ada/ * sem_res.adb (Enclosing_Declaration_Or_Statement): Moved to Sem_Util. * sem_util.ads (Enclosing_Declaration_Or_Statement): Moved from Sem_Res. * sem_util.adb (Enclosing_Declaration_Or_Statement): Likewise.