aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2022-07-04[Ada] Add Ada 2022 Key function to sets containersBob Duff6-0/+18
This patch adds the new Generic_Keys.Key function to the set children of Ada.Containers. gcc/ada/ * libgnat/a-cbhase.ads, libgnat/a-cborse.ads, libgnat/a-cihase.ads, libgnat/a-ciorse.ads, libgnat/a-cohase.ads, libgnat/a-coorse.ads (Key): New function that takes a Container parameter, implemented as an expression function, so it is self explanatory (doesn't need a comment).
2022-07-04[Ada] Fix length of title underlines.Vasiliy Fofanov1-3/+3
gcc/ada/ * doc/gnat_rm/the_gnat_library.rst: Fix length of title underlines.
2022-07-04[Ada] Compiler rejects legal allocator in record component constraint expressionSteve Baird1-4/+13
In some cases when a legal allocator which defines a new subtype for the allocated object occurs as part of a record component constraint expression, the compiler would incorrectly reject the allocator. gcc/ada/ * sem_ch4.adb (Analyze_Allocator): After calling Insert_Action to insert a subtype declaration associated with an allocator, the subtype declaration will usually be analyzed. But not always. Add an explicit call to Preanalyze to cope with the unusual case. The subtype declaration must be at least preanalyzed before the call to Sem_Ch3.Process_Subtype a little while later, during which we analyze an identifier that refers to the subtype.
2022-07-04[Ada] Avoid unwanted warnings for statically-known-successful assertionsSteve Baird2-2/+8
The -gnatwc switch enables warnings for test condition outcomes that are known at compile time. Such warnings are unlikely to be useful in the case of an assertion expression (or a subexpression thereof), so do not generate them in that case. gcc/ada/ * sem_warn.adb (Warn_On_Constant_Valid_Condition): Do not generate a warning if the expression in question is an assertion expression, or a subexpression thereof. But do call Test_Comparison so that it can generate warnings for the cases that it generates warnings for. * sem_prag.ads: Modify Assertion_Expression_Pragma constant so that the predicate Sem_Util.In_Assertion_Expression_Pragma returns True for the expression of a Compile_Time_Error pragma.
2022-07-04[Ada] Add a RM entry for the functional infinite sequencesJulien Bortolussi2-203/+249
Modify the RM to take into account the new functional container. gcc/ada/ * doc/gnat_rm/the_gnat_library.rst: Add the new entry. * gnat_rm.texi: Regenerate.
2022-07-04[Ada] Give missing error on ambiguous operand of equality operatorEric Botcazou1-15/+20
When the code responsible for giving errors on ambiguous operands of comparison and equality operators was moved from the 1st phase (analysis) to the 2nd phase (resolution) of semantic processing, it was incorrectly restricted to the operator case, which was valid during the 1st phase but is not during the 2nd phase. gcc/ada/ * sem_res.adb (Resolve_Comparison_Op): Deal with ambiguous operands in all cases. (Resolve_Equality_Op): Likewise, except for the case of the implicit inequality operator created for a user-defined operator that is not an intrinsic subprogram.
2022-07-04[Ada] Add Ada 2022 features to sets containersBob Duff14-8/+482
This patch adds some Ada 2022 features to the set children of Ada.Containers. gcc/ada/ * libgnat/a-cbhase.adb, libgnat/a-cbhase.ads, libgnat/a-cborse.adb, libgnat/a-cborse.ads, libgnat/a-cihase.adb, libgnat/a-cihase.ads, libgnat/a-ciorse.adb, libgnat/a-ciorse.ads, libgnat/a-cohase.adb, libgnat/a-cohase.ads, libgnat/a-conhel.adb, libgnat/a-conhel.ads, libgnat/a-coorse.adb, libgnat/a-coorse.ads: Add Has_Element, Element, Query_Element, and Next subprograms that take a Set parameter. Add Tampering_With_Cursors_Prohibited function. These are all new in Ada 2022.
2022-07-04[Ada] Update the documentation of functional containersClaire Dross2-42/+38
Functional containers are now controlled. Update the documentation accordingly. gcc/ada/ * doc/gnat_rm/the_gnat_library.rst: Functional vectors, sets, and maps are now controlled. * gnat_rm.texi: Regenerate.
2022-07-04[Ada] Add GNAT specific pragmas to the equivalent Assertion_Policy for -gnataClaire Dross2-20/+52
All assertion pragmas are enabled by default when using -gnata. We need to add the GNAT specific ones to the list. gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (Debugging and Assertion Control): Add GNAT specific assertion pragmas to the equivalent Assertion_Policy for the -gnata option. * gnat_ugn.texi: Regenerate.
2022-07-04[Ada] Incorrect accessibility check on return of discriminated typeJustin Squirek2-11/+10
This patch corrects an error in the compiler whereby the presence of a call to a function returning a type with an access discriminant within an expanded loop condition caused the wrong value to be supplied for the extra- accessibility-of-result actual, thus causing incorrect checks within the callee at the point of return. This change also corrects a problem where spurious "null value not allowed" warnings were generated for tagged type declarations with an access discriminant specified as "null." gcc/ada/ * sem_disp.adb (Most_Descendant_Use_Clause): Remove call to deprecated Is_Internal. * sem_util.adb (Innermost_Master_Scope_Depth): Use Find_Enclosing_Scope instead of Nearest_Dynamic_Scope to avoid cases where relevant scopes get skipped leading to an incorrect scope depth calculation.
2022-07-04[Ada] Plug loophole for built-in-place return with limited_with clauseEric Botcazou1-1/+2
When the result type of a function requiring built-in-place return is only visible through a limited_with clause, the compiled needs to wait for the nonlimited view to be available in order to compute whether the built-in-place return is needed, and this comprises tagging the function with the Returns_By_Ref flag. gcc/ada/ * exp_ch6.adb (Build_In_Place_Formal): Also compute Returns_By_Ref for the function if the extra formals were not built initially.
2022-07-04[Ada] Fix for resolution of overloaded subprogram for Iterable aspectPiotr Trojanek1-0/+1
When resolving the Iterable aspect we look for a functions that are declared in the same scope as the annotated type and that have the required number and types formal parameters. However, we didn't guard against functions that have no formal parameter at all. gcc/ada/ * sem_ch13.adb (Resolve_Iterable_Operation): Add guard to prevent crash when the examined function has no formal parameters and Etype is called on Empty entity.
2022-07-04[Ada] Create new unbounded functional sequenceJulien Bortolussi4-0/+683
Add a new unbounded functional sequence. This sequence is indexed by Big_Positive and so is unbounded from the user and spark points view. Hower the actually implemented sequence are bounded by Count_Type'Last. gcc/ada/ * libgnat/a-cfinse.adb, libgnat/a-cfinse.ads: Implementation files of the sequence. * Makefile.rtl, impunit.adb: Take into account the add of the new files
2022-07-04[Ada] Adjust description of Pure_Function pragmaEric Botcazou2-7/+7
The current wording can be read as implying that the result of a call to a pure function does not depend on the context, which is incorrect. The pragma only guarantees the absence of side effects of such a call. gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst (Pure_Function): Fix ambiguous wording about context dependence. * gnat_rm.texi: Regenerate.
2022-06-03Daily bump.GCC Administrator1-0/+302
2022-06-02diagnostics: add SARIF output formatDavid Malcolm1-0/+11
This patch adds support to gcc's diagnostic subsystem for emitting diagnostics in SARIF, aka the Static Analysis Results Interchange Format: https://sarifweb.azurewebsites.net/ by extending -fdiagnostics-format= to add two new options: -fdiagnostics-format=sarif-stderr and: -fdiagnostics-format=sarif-file The patch targets SARIF v2.1.0 This is a JSON-based format suited for capturing the results of static analysis tools (like GCC's -fanalyzer), but it can also be used for plain GCC warnings and errors. SARIF supports per-event metadata in diagnostic paths such as ["acquire", "resource"] and ["release", "lock"] (specifically, the threadFlowLocation "kinds" property: SARIF v2.1.0 section 3.38.8), so the patch extends GCC"s diagnostic_event subclass with a "struct meaning" with similar purpose. The patch implements this for -fanalyzer so that the various state-machine-based warnings set these in the SARIF output. The heart of the implementation is in the new file diagnostic-format-sarif.cc. Much of the rest of the patch is interface classes, isolating the diagnostic subsystem (which has no knowledge of e.g. tree or langhook) from the "client" code in the compiler proper cc1 etc). The patch adds a langhook for specifying the SARIF v2.1.0 "artifact.sourceLanguage" property, based on the list in SARIF v2.1.0 Appendix J. The patch adds automated DejaGnu tests to our testsuite via new scan-sarif-file and scan-sarif-file-not directives (although these merely use regexps, rather than attempting to use a proper JSON parser). I've tested the patch by hand using the validator at: https://sarifweb.azurewebsites.net/Validation and the react-based viewer at: https://microsoft.github.io/sarif-web-component/ which successfully shows most of the information (although not paths, and not CWE IDs), and I've fixed all validation errors I've seen (though bugs no doubt remain). I've also tested the generated SARIF using the VS Code extension linked to from the SARIF website; I'm a novice with VS Code, but it seems to be able to handle my generated SARIF files (e.g. showing the data in the SARIF tab, and showing squiggly underlines under issues, and when I click on them, it visualizes the events in the path inline within the source window). Has anyone written an Emacs mode for SARIF files? (pretty please) gcc/ChangeLog: * Makefile.in (OBJS): Add tree-diagnostic-client-data-hooks.o and tree-logical-location.o. (OBJS-libcommon): Add diagnostic-format-sarif.o; reorder. (CFLAGS-tree-diagnostic-client-data-hooks.o): Add TARGET_NAME. * common.opt (fdiagnostics-format=): Add sarif-stderr and sarif-file. (sarif-stderr, sarif-file): New enum values. * diagnostic-client-data-hooks.h: New file. * diagnostic-format-sarif.cc: New file. * diagnostic-path.h (enum diagnostic_event::verb): New enum. (enum diagnostic_event::noun): New enum. (enum diagnostic_event::property): New enum. (struct diagnostic_event::meaning): New struct. (diagnostic_event::get_logical_location): New vfunc. (diagnostic_event::get_meaning): New vfunc. (simple_diagnostic_event::get_logical_location): New vfunc impl. (simple_diagnostic_event::get_meaning): New vfunc impl. * diagnostic.cc: Include "diagnostic-client-data-hooks.h". (diagnostic_initialize): Initialize m_client_data_hooks. (diagnostic_finish): Clean up m_client_data_hooks. (diagnostic_event::meaning::dump_to_pp): New. (diagnostic_event::meaning::maybe_get_verb_str): New. (diagnostic_event::meaning::maybe_get_noun_str): New. (diagnostic_event::meaning::maybe_get_property_str): New. (get_cwe_url): Make non-static. (diagnostic_output_format_init): Handle DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR and DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE. * diagnostic.h (enum diagnostics_output_format): Add DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR and DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE. (class diagnostic_client_data_hooks): New forward decl. (class logical_location): New forward decl. (diagnostic_context::m_client_data_hooks): New field. (diagnostic_output_format_init_sarif_stderr): New decl. (diagnostic_output_format_init_sarif_file): New decl. (get_cwe_url): New decl. * doc/invoke.texi (-fdiagnostics-format=): Add sarif-stderr and sarif-file. * doc/sourcebuild.texi (Scan a particular file): Add scan-sarif-file and scan-sarif-file-not. * langhooks-def.h (lhd_get_sarif_source_language): New decl. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): New macro. (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE. * langhooks.cc (lhd_get_sarif_source_language): New. * langhooks.h (lang_hooks::get_sarif_source_language): New field. * logical-location.h: New file. * plugin.cc (struct for_each_plugin_closure): New. (for_each_plugin_cb): New. (for_each_plugin): New. * plugin.h (for_each_plugin): New decl. * tree-diagnostic-client-data-hooks.cc: New file. * tree-diagnostic.cc: Include "diagnostic-client-data-hooks.h". (tree_diagnostics_defaults): Populate m_client_data_hooks. * tree-logical-location.cc: New file. * tree-logical-location.h: New file. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/analyzer/ChangeLog: * checker-path.cc (checker_event::get_meaning): New. (function_entry_event::get_meaning): New. (state_change_event::get_desc): Add dump of meaning of the event to the -fanalyzer-verbose-state-changes output. (state_change_event::get_meaning): New. (cfg_edge_event::get_meaning): New. (call_event::get_meaning): New. (return_event::get_meaning): New. (start_consolidated_cfg_edges_event::get_meaning): New. (warning_event::get_meaning): New. * checker-path.h: Include "tree-logical-location.h". (checker_event::checker_event): Construct m_logical_loc. (checker_event::get_logical_location): New. (checker_event::get_meaning): New decl. (checker_event::m_logical_loc): New. (function_entry_event::get_meaning): New decl. (state_change_event::get_meaning): New decl. (cfg_edge_event::get_meaning): New decl. (call_event::get_meaning): New decl. (return_event::get_meaning): New decl. (start_consolidated_cfg_edges_event::get_meaning): New. (warning_event::get_meaning): New decl. * pending-diagnostic.h: Include "diagnostic-path.h". (pending_diagnostic::get_meaning_for_state_change): New vfunc. * sm-file.cc (file_diagnostic::get_meaning_for_state_change): New vfunc impl. * sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change): Likewise. * sm-sensitive.cc (exposure_through_output_file::get_meaning_for_state_change): Likewise. * sm-taint.cc (taint_diagnostic::get_meaning_for_state_change): Likewise. * varargs.cc (va_list_sm_diagnostic::get_meaning_for_state_change): Likewise. gcc/c/ChangeLog: * c-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (c_get_sarif_source_language): New. * c-tree.h (c_get_sarif_source_language): New decl. gcc/cp/ChangeLog: * cp-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (cp_get_sarif_source_language): New. gcc/d/ChangeLog: * d-lang.cc (d_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/fortran/ChangeLog: * f95-lang.cc (gfc_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/go/ChangeLog: * go-lang.cc (go_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/objc/ChangeLog: * objc-act.h (objc_get_sarif_source_language): New decl. * objc-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (objc_get_sarif_source_language): New. gcc/testsuite/ChangeLog: * c-c++-common/diagnostic-format-sarif-file-1.c: New test. * c-c++-common/diagnostic-format-sarif-file-2.c: New test. * c-c++-common/diagnostic-format-sarif-file-3.c: New test. * c-c++-common/diagnostic-format-sarif-file-4.c: New test. * gcc.dg/analyzer/file-meaning-1.c: New test. * gcc.dg/analyzer/malloc-meaning-1.c: New test. * gcc.dg/analyzer/malloc-sarif-1.c: New test. * gcc.dg/plugin/analyzer_gil_plugin.c (gil_diagnostic::get_meaning_for_state_change): New vfunc impl. * gcc.dg/plugin/diagnostic-test-paths-5.c: New test. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add diagnostic-test-paths-5.c to tests for diagnostic_plugin_test_paths.c. * lib/gcc-dg.exp: Load scansarif.exp. * lib/scansarif.exp: New test. libatomic/ChangeLog: * testsuite/lib/libatomic.exp: Add load_gcc_lib of scansarif.exp. libgomp/ChangeLog: * testsuite/lib/libgomp.exp: Add load_gcc_lib of scansarif.exp. libitm/ChangeLog: * testsuite/lib/libitm.exp: Add load_gcc_lib of scansarif.exp. libphobos/ChangeLog: * testsuite/lib/libphobos-dg.exp: Add load_gcc_lib of scansarif.exp. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-06-02[Ada] Update copyright noticesPierre-Marie de Rodat3-3/+3
gcc/ada/ * gcc-interface/gigi.h: Update copyright notice. * gcc-interface/lang-specs.h: Likewise. * gcc-interface/utils.cc: Likewise.
2022-06-02[Ada] Remove left-overs of front-end SJLJ processingEric Botcazou3-117/+4
gcc/ada/ * gcc-interface/gigi.h (enum standard_datatypes): Remove values for the SJLJ exception mechanism. (jmpbuf_type): Delete. (jmpbuf_ptr_type): Likewise. (get_jmpbuf_decl): Likewise. (set_jmpbuf_decl): Likewise. (get_excptr_decl): Likewise. (not_handled_by_others_decl): Likewise. (setjmp_decl): Likewise. (update_setjmp_buf_decl): Likewise. (raise_nodefer_decl): Likewise. (set_block_jmpbuf_decl): Likewise. (get_block_jmpbuf_decl): Likewise. * gcc-interface/trans.cc (gigi): Delete dead code. * gcc-interface/utils.cc (gnat_binding_level): Remove JMPBUF_DECL. (gnat_pushlevel): Do not clear it. (set_block_jmpbuf_decl): Delete. (get_block_jmpbuf_decl): Likewise.
2022-06-02[Ada] Fix record layout warnings not being taggedGhjuvan Lacambre1-8/+8
This allows tools ingesting GNAT's output to properly classify these messages. gcc/ada/ * gcc-interface/decl.cc (warn_on_field_placement): Add insertion character '.q' to warning string.
2022-06-02[Ada] Disable -flto when building the shared libgnatArnaud Charlet1-2/+2
This setting isn't useful in this context. gcc/ada/ * gcc-interface/Makefile.in (gnatlib-shared-default): Add -fno-lto.
2022-06-02[Ada] Couple of small preparatory adjustmentsEric Botcazou2-6/+11
No functional changes. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity): Do not check the scope of anonymous access Itypes. * gcc-interface/trans.cc (Identifier_to_gnu): Do not translate the return type of a subprogram here.
2022-06-02[Ada] Restore full generation of static dispatch tables with -gnatzrEric Botcazou3-15/+38
The -gnatzr switch triggers the creation of distribution stubs for use by the implementation of PolyORB. Now these stubs declare tagged types and are generated at the very end of the analysis of compilation units, after the static dispatch tables have been built, so these tables are missing for the tagged types of the stubs. Therefore this change defers the generation of static dispatch tables for compilation units, which is the common case, until after the stubs are (potentially) generated. For the other cases, in particular the generic instances that are not compilation units, nothing is changed. gcc/ada/ * exp_ch7.adb (Expand_N_Package_Body): Build static dispatch tables only for units that are not compilation units, unless they are generic instances. Do not push a scope for this. (Expand_N_Package_Declaration): Build static dispatch tables only for units that are both not compilation units and generic instances. * exp_disp.adb (Build_Static_Dispatch_Tables): Remove redundant early return. Push a scope for package bodies. * sem_ch10.adb: Add with and use clauses for Exp_Disp. (Analyze_Compilation_Unit): Build static dispatch tables here.
2022-06-02[Ada] Never make symbols for thunks publicEric Botcazou1-0/+7
Thunks are only referenced locally by dispatch tables and never inlined. gcc/ada/ * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Clear the Is_Public flag on thunks.
2022-06-02[Ada] Remove redundant checks for missing listsPiotr Trojanek13-463/+411
When iterating over list elements with First/Next there is no need to check if the list is present, because First intentionally returns Empty if list is not present and the condition of subsequent loop will not be satisfied. Code cleanup; semantics is unaffected. Occurrences of the redundant pattern were found with: $ grep First -B 3 | less and examining the output for the calls to Present. gcc/ada/ * exp_ch13.adb, exp_ch5.adb, exp_ch9.adb, exp_strm.adb, sem_ch10.adb, sem_ch13.adb, sem_ch5.adb, sem_ch6.adb, sem_ch8.adb, sem_elab.adb, sem_eval.adb, sem_prag.adb, sem_util.adb: Remove checks for the missing list before iterating with First/Next; reindent code and refill comments.
2022-06-02[Ada] Get rid of secondary stack for most calls returning tagged typesEric Botcazou19-299/+558
This eliminates the use of the secondary stack to return specific tagged types from functions in calls that are not dispatching on result, which comprises returning controlled types, by introducing thunks whose only purpose is to move the result from the primary to the secondary stack for primitive functions that are controlling on result, and referencing them in the dispatch table in lieu of the primitive functions. The implementation reuses the existing machinery of interface thunks and thus creates another kind of thunks, secondary stack thunks, which only perform a call to the primitive function and return the result. gcc/ada/ * einfo.ads (Has_Controlling_Result): Document new usage. (Is_Thunk): Document secondary stack thunks. (Returns_By_Ref): Adjust. * exp_ch6.adb (Caller_Known_Size): Return true for tagged types. (Expand_N_Extended_Return_Statement): Do not call Set_By_Ref. (Expand_Simple_Function_Return): For a BIP return with an Alloc_Form parameter, mark the node as returning on the secondary stack. Replace call to Is_Limited_Interface with Is_Limited_View. Deal wit secondary stack thunks. Do not call Set_By_Ref. Optimize the case of a call to a function whose type also needs finalization. (Needs_BIP_Task_Actuals): Replace Thunk_Entity with Thunk_Target. (Needs_BIP_Finalization_Master): Cosmetic fixes. (Needs_BIP_Alloc_Form): Check No_Secondary_Stack restriction and return true for tagged types. * exp_ch7.adb (Transient Scope Management): Update description. * exp_disp.adb (Expand_Dispatching_Call): Always set Returns_By_Ref on designated type if the call is dispatching on result. Tidy up. (Expand_Interface_Thunk): Change type of Thunk_Code from Node_Id to List_Id. Change type of local variables from Node_Id to Entity_Id. Propagate Aliased_Present flag to create the formals and explicitly set Has_Controlling_Result to False. Build a secondary stack thunk if necessary in the function case. (Expand_Secondary_Stack_Thunk): New function. (Make_Secondary_DT): Build secondary stack thunks if necessary. (Make_DT): Likewise. (Register_Predefined_Primitive): Likewise. (Register_Primitive): Likewise. * exp_util.ads (Is_Secondary_Stack_Thunk): Declare. (Thunk_Target): Likewise. * exp_util.adb (Is_Secondary_Stack_Thunk): New function. (Thunk_Target): Likewise. * fe.h (Is_Secondary_Stack_Thunk): Declare. (Thunk_Target): Likewise. * gen_il-fields.ads (Opt_Field_Enum): Remove By_Ref. * gen_il-gen-gen_nodes.adb (N_Simple_Return_Statement): Likewise. (N_Extended_Return_Statement): Likewise. * sem_ch6.adb (Analyze_Subprogram_Specification): Skip check for abstract return type in the thunk case. (Create_Extra_Formals): Replace Thunk_Entity with Thunk_Target. * sem_disp.adb (Check_Controlling_Formals): Skip in the thunk case. * sem_util.adb: Add use and with clauses for Exp_Ch6. (Compute_Returns_By_Ref): Do not process procedures and only set the flag for direct return by reference. (Needs_Secondary_Stack): Do not return true for specific tagged types and adjust comments accordingly. * sinfo.ads (By_Ref): Delete. (N_Simple_Return_Statement): Remove By_Ref. (N_Extended_Return_Statement): Likewise. * gcc-interface/ada-tree.h (TYPE_RETURN_UNCONSTRAINED_P): Delete. * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Do not use it. Return by direct reference if the return type needs the secondary stack as well as for secondary stack thunks. * gcc-interface/gigi.h (fntype_same_flags_p): Remove parameter. * gcc-interface/misc.cc (gnat_type_hash_eq): Adjust to above change. * gcc-interface/trans.cc (finalize_nrv): Replace test on TYPE_RETURN_UNCONSTRAINED_P with TYPE_RETURN_BY_DIRECT_REF_P. (Subprogram_Body_to_gnu): Do not call maybe_make_gnu_thunk for secondary stack thunks. (Call_to_gnu): Do not test TYPE_RETURN_UNCONSTRAINED_P. (gnat_to_gnu) <N_Simple_Return_Statement>: In the return by direct reference case, test for the presence of Storage_Pool on the node to build an allocator. (maybe_make_gnu_thunk): Deal with Thunk_Entity and Thunk_Target. * gcc-interface/utils.cc (fntype_same_flags_p): Remove parameter.
2022-06-02[Ada] Fix references to old variables that have been refactoredMarc Poulhiès3-20/+20
Local_Entity_Suppress and Global_Entity_Suppress variables referencing tables were refactored to Local_Suppress_Stack_Top and Global_Suppress_Stack_Top stacks back in 2007. Fix remaining references to these variables. gcc/ada/ * einfo.ads: Fix reference to Global_Entity_Suppress and Local_Entity_Suppress variable in the comments. * sem.ads: Likewise. * sem_prag.adb: Likewise.
2022-06-02[Ada] Rename GNATprove annotate pragma for termination to Always_ReturnClaire Dross3-5/+5
GNATprove changed the name of the pragma Annotate used to verify that a subprogram always returns normally. It is now called Always_Return instead of Terminating. gcc/ada/ * libgnat/s-aridou.adb: Use Always_Return instead of Terminating to annotate termination for GNATprove. * libgnat/s-arit32.adb: Idem. * libgnat/s-spcuop.ads: Idem.
2022-06-02[Ada] Make the functional Maps and Sets unboundedJulien Bortolussi11-49/+100
Before this patch, the Functional Sets ans Maps were bounded both from the user and the implementation points of view. To make them closer to mathematical Sets ans Maps, this patch removes the bounds from the contracts. Note that, in practice, they are still bounded by Count_Type'Last, even if the user is not aware of it anymore. This patch removed constraints on length of sets and maps from the preconditions of functions. The function Length and Num_Overlaps now return a Big_Natural. gcc/ada/ * libgnat/a-cofuse.ads, libgnat/a-cofuse.adb, libgnat/a-cofuma.ads, libgnat/a-cofuma.adb: Make Length and Num_Overlaps return Big_Natural. * libgnat/a-cforse.ads, libgnat/a-cforse.adb, libgnat/a-cforma.adb, libgnat/a-cfhase.ads, libgnat/a-cfhase.adb, libgnat/a-cfhama.adb, libgnat/a-cfdlli.adb: Adapt code to handle Big_Integers instead of Count_Type.
2022-06-02[Ada] Fix spurious use of trampolines with interface typesEric Botcazou1-2/+2
Function pointers must always be built with '[Unrestricted_]Access. gcc/ada/ * exp_ch3.adb (Init_Secondary_Tags.Initialize_Tag): Initialize the Offset_Func component by means of 'Unrestricted_Access.
2022-06-02[Ada] Add precise subprogram identification to -fdiagnostics-format=jsonGhjuvan Lacambre1-6/+15
This commit adds information allowing identification of the subprogram surrounding the message emitted by gnat when using -gnatdJ along with -fdiagnostics-format=json. gcc/ada/ * errout.adb (Write_JSON_Span): Add subprogram name to emitted JSON.
2022-06-02[Ada] Refine previous changes on making symbols public/privateArnaud Charlet1-41/+44
Inline_Always procedures should be kept public for proper inter unit inlining. gcc/ada/ * sem_ch7.adb (Set_Referencer_Of_Non_Subprograms): New local procedure, used for code refactoring. Also take into account Inline_Always pragma when deciding to make a symbol public for C generation.
2022-06-02[Ada] Fix spurious errors on ghost code in genericsYannick Moy1-0/+5
After the recent fix for detecting illegal use of ghost entities in code, spurious errors could be raised on generic code with ghost, due to wrong setting of the ghost flags on copied entities from the generic to the instantiation. gcc/ada/ * atree.adb (New_Copy): Reset flags related to ghost entities before marking the new node.
2022-06-02[Ada] Move registering code for predefined primitives to Exp_DispEric Botcazou3-117/+118
This avoids making Expand_Interface_Thunk visible from the outside. No functional changes. gcc/ada/ * exp_ch6.adb (Freeze_Subprogram.Register_Predefined_DT_Entry): Move procedure to... * exp_disp.ads (Expand_Interface_Thunk): Move declaration to... (Register_Predefined_Primitive): Declare. * exp_disp.adb (Expand_Interface_Thunk): ...here. (Register_Predefined_Primitive): ...here and change into a function returning List_Id.
2022-06-02[Ada] Build static dispatch tables always at the end of declarative partEric Botcazou2-36/+28
The static dispatch tables of library-level tagged types are either built on the first object declaration or at the end of the declarative part of the package spec or body. There is no real need for the former case, and the tables are not built for other constructs that freeze (tagged) types. Therefore this change removes the former case, thus causing the tables to be always built at the end of the declarative part; that's orthogonal to freezing and the tagged types are still frozen at the appropriate place. Moreover, it wraps the code in the Actions list of a freeze node (like for the nonstatic case) so that it is considered elaboration code by the processing done in Sem_Elab and does not disturb it. No functional changes. gcc/ada/ * exp_ch3.adb (Expand_Freeze_Record_Type): Adjust comment. (Expand_N_Object_Declaration): Do not build static dispatch tables. * exp_disp.adb (Make_And_Insert_Dispatch_Table): New procedure. (Build_Static_Dispatch_Tables): Call it to build the dispatch tables and wrap them in the Actions list of a freeze node.
2022-06-02[Ada] vx7r2-arm/aarch64 - Support Atomic Primitives TrueDoug Rupp4-0/+4
This feature is an architecture feature, not an OS feature, so enable on vx7r2 for arm and aarch64 to coincide with what is done on similarly capable targets. gcc/ada/ * libgnat/system-vxworks7-arm.ads (Support_Atomic_Primitives): Set True. * libgnat/system-vxworks7-arm-rtp-smp.ads: Likewise. * libgnat/system-vxworks7-aarch64.ads: Likewise. * libgnat/system-vxworks7-aarch64-rtp-smp.ads: Likewise:
2022-06-02[Ada] Update documentation of GNAT.Dynamic_TablesJavier Miranda1-7/+4
Document that dynamic tables are defined aliased for backward compatibility. gcc/ada/ * libgnat/g-dyntab.ads (Table_Type): Update documentation.
2022-06-02[Ada] Fix detection of deferred constants for freezing errorEric Botcazou1-1/+2
Testing Is_Frozen is not robust enough, so instead test that the full view has been seen and that the Has_Completion flag is set on it. gcc/ada/ * freeze.adb (Check_Expression_Function.Find_Constant): Make test for deferred constants more robust.
2022-06-02[Ada] Fix preconditions of Interfaces.C.StringsJoffrey Huguet1-2/+8
Preconditions of Update procedures were always true when Offset was 0. The changes enable to protect from Update_Error when Offset is 0. gcc/ada/ * libgnat/i-cstrin.ads (Update): Update precondition.
2022-06-02[Ada] Issue errors on wrong context for ghost entitiesYannick Moy3-8/+79
References to ghost entities should only occur in ghost context. This was not checked systematically on all references. gcc/ada/ * sem_ch2.adb (Analyze_Identifier): Add checking for ghost context. * sem_ch5.adb (Analyze_Implicit_Label_Declaration): Treat implicit labels like other entities by setting their ghost status according to context. * ghost.adb (Check_Ghost_Context): Adapt checking.
2022-06-02[Ada] Complete contracts of Interfaces.C.Strings subprogramsJoffrey Huguet1-3/+8
This patch adds preconditions to Update procedures, to protect from Update_Error propagations. gcc/ada/ * libgnat/i-cstrin.ads (Update): Add precondition.
2022-06-02[Ada] Removal of dead code Analyze_Label_EntityYannick Moy2-22/+0
gcc/ada/ * sem_ch5.adb (Analyze_Label_Entity): Remove body. * sem_ch5.ads (Analyze_Label_Entity): Remove spec.
2022-06-02[Ada] Propagate Has_Inherit{able,ed}_Invariants to base typesEric Botcazou1-4/+4
The two flags apply to base types only like Has_Own_Invariants. gcc/ada/ * sem_util.adb (Propagate_DIC_Attributes): Add ??? comment. (Propagate_Invariant_Attributes): Likewise. Propagate the Has_Inheritable_Invariants and Has_Inherited_Invariants to the base type of the target type.
2022-06-02[Ada] Combine system.ads files - arm and aarch64 linuxDoug Rupp1-1/+1
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. gcc/ada/ * libgnat/system-linux-arm.ads (Memory_Size): Compute based on Word_Size.
2022-06-02[Ada] Combine system.ads file - vxworks7 rtp constantsDoug Rupp9-18/+18
Systemitize Word_Size and Memory_Size declarations rather than hard code with numerical values or OS specific Long_Integer size. gcc/ada/ * libgnat/system-vxworks7-aarch64-rtp-smp.ads (Word_Size): Compute based on Standard'Word_Size. (Memory_Size): Compute based on Word_Size. * libgnat/system-vxworks7-arm-rtp-smp.ads: Likewise. * libgnat/system-vxworks7-e500-rtp-smp.ads: Likewise. * libgnat/system-vxworks7-e500-rtp.ads: Likewise. * libgnat/system-vxworks7-ppc-rtp-smp.ads: Likewise. * libgnat/system-vxworks7-ppc-rtp.ads: Likewise. * libgnat/system-vxworks7-ppc64-rtp-smp.ads: Likewise. * libgnat/system-vxworks7-x86-rtp-smp.ads: Likewise. * libgnat/system-vxworks7-x86-rtp.ads: Likewise.
2022-06-02[Ada] Gnatbind crash during checksum calculationJustin Squirek4-0/+8
This patch corrects an error in the compiler whereby gnatbind may crash during calculation of file checksums in certain corner cases due to uninitialized lookup tables. gcc/ada/ * gnatbind.adb (Gnatbind): Add initialize call for Uintp * gnatls.adb (Gnatls): Likewise. * gprep.adb (Gnatprep): Likewise. * make.adb (Initialize): Likewise.
2022-06-02[Ada] Fix iteration on formal vectorsClaire Dross4-4/+4
We need to use Extended_Index for the Position parameter of the Element function in formal vectors so it is compatible with other primitives of the Iterable aspect. gcc/ada/ * libgnat/a-cfinve.ads (Element): Change the type of the Position parameter to Extended_Index. * libgnat/a-cfinve.adb (Element): Idem. * libgnat/a-cofove.ads (Element): Idem. * libgnat/a-cofove.adb (Element): Idem.
2022-06-02[Ada] Add contracts to System.Address_To_Access_ConversionsJoffrey Huguet1-2/+4
This patch adds SPARK annotations to subprograms from System.Address_To_Access_Conversions. To_Pointer is considered to have no global items, if the returned value has no aliases. To_Address is forbidden in SPARK because addresses are not handled. gcc/ada/ * libgnat/s-atacco.ads (To_Pointer): Add Global => null. (To_Address): Add SPARK_Mode => Off.
2022-06-02[Ada] Add contracts to Interfaces.C.StringsJoffrey Huguet2-16/+57
This patch adds Global contracts and preconditions to subprograms of Interfaces.C.Strings. Effects on allocated memory are modelled through an abstract state, C_Memory. The preconditions protect against Dereference_Error, but not Storage_Error (which is not handled by SPARK). This patch also disables the use of To_Chars_Ptr, which creates an alias between an ownership pointer and the abstract state, and the use of Free, in SPARK code. Thus, memory leaks will happen if the user creates the Chars_Ptr using New_Char_Array and New_String. gcc/ada/ * libgnat/i-cstrin.ads (To_Chars_Ptr): Add SPARK_Mode => Off. (Free): Likewise. (New_Char_Array): Add global contracts and Volatile attribute. (New_String): Likewise. (Value, Strlen, Update): Add global contracts and preconditions. * libgnat/i-cstrin.adb: Add SPARK_Mode => Off to the package body.
2022-06-02Daily bump.GCC Administrator1-0/+272
2022-06-01[Ada] Allow confirming volatile properties on No_Caching variablesYannick Moy2-25/+30
Volatile variables marked with the No_Caching aspect can now have confirming aspects for other volatile properties, with a value of False. gcc/ada/ * contracts.adb (Check_Type_Or_Object_External_Properties): Check the validity of combinations only when No_Caching is not used. * sem_prag.adb (Analyze_External_Property_In_Decl_Part): Check valid combinations with No_Caching.