aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface
AgeCommit message (Collapse)AuthorFilesLines
3 daysada: Fix internal error on aspect in complex object declarationEric Botcazou1-6/+24
The sufficient conditions are that the aspect be deferred and the object be rewritten as a renaming because of the complex initialization expression. gcc/ada/ChangeLog: * gcc-interface/trans.cc (gnat_to_gnu) <N_Object_Renaming_Declaration>: Deal with objects whose elaboration is deferred. (process_freeze_entity): Deal with renamed objects whose elaboration is deferred.
7 daysada: Give a warning for huge imported objectsEric Botcazou1-25/+36
This is a follow-up to a recent change, where a warning was implemented for huge library-level objects. However it is not given if the objects are imported, although an indirection is also added for them under the hood to match the export side. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Give a warning for huge imported objects as well.
7 daysada: Get rid of TYPE_ALIGN_OK flag in gcc-interfaceEric Botcazou6-19/+41
The TYPE_ALIGN_OK flag had originally been a GCC flag tested in the RTL expander and was at some point kicked out of the middle-end to become a pure Gigi flag. But it's only set for tagged types and CW-equivalent types and can be replaced by a explicit predicate without too much work. gcc/ada/ChangeLog: * gcc-interface/ada-tree.h (TYPE_ALIGN_OK): Delete. * gcc-interface/decl.cc (gnat_to_gnu_entity): Do not set it. * gcc-interface/gigi.h (standard_datatypes): Add ADT_tag_name_id. (tag_name_id): New macro. (type_is_tagged_or_cw_equivalent): New inline predicate. * gcc-interface/trans.cc (gigi): Initialize tag_name_id. (gnat_to_gnu) <N_Unchecked_Type_Conversion>: Replace tests on TYPE_ALIGN_OK with calls to type_is_tagged_or_cw_equivalent. (addressable_p): Likewise. * gcc-interface/utils.cc (convert): Likewise. * gcc-interface/utils2.cc (build_binary_op): Likewise.
7 daysada: Fix crash on reference to aliased object of packed array type with -gEric Botcazou1-0/+2
This happens when the object is declared in another compilation unit. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_get_array_descr_info): In the record type case, bail out if the original array type cannot be retrieved.
7 daysada: Implement overflow checking for unsigned typesEric Botcazou2-32/+79
The implementation is essentially mirrored from the one for signed types. gcc/ada/ChangeLog: * gcc-interface/gigi.h (standard_datatypes): Add ADT_uns_mulv64_decl and ADT_uns_mulv128_decl. (uns_mulv64_decl): New macro. (uns_mulv128_decl): Likewise. * gcc-interface/trans.cc (gigi): Create the uns_mulv64_decl and uns_mulv128_decl declarations. (gnat_to_gnu) <N_Op_Add>: Perform an overflow check for unsigned integer addition, subtraction and multiplication if required. <N_Op_Minus>: Perform an overflow check for unsigned integer negation if required. (build_unary_op_trapv): Add support for unsigned types. (build_binary_op_trapv): Likewise. <MINUS_EXPR>: Perform the check if the LHS is zero in the signed case as well.
9 daysada: Platform-specific import for read() and write()Tonu Naks1-2/+3
read() and write() return int on windows, whereas on Posix systems the return type is ssize_t (effectively long_int). The object file was added to GNAT_ADA_OBJS only, although the unit is also in the compilation closure of GNATbind, but this was harmless because the object file was essentially empty; that is no longer the case. gcc/ada/ChangeLog: * libgnat/s-crtl.ads (read, write): remove import * libgnat/s-crtl__mingw.adb: body for windows * libgnat/s-crtl.adb: body for all the other targets * Makefile.rtl: configure s-crtl.adb/libgnat/s-crtl__mingw.adb * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Alphabetize. (GNATBIND_OBJS): Add ada/libgnat/s-crtl.o. Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
2025-07-31Ada: Fix miscompilation of GNAT tools with -march=znver3Eric Botcazou1-4/+4
The throw and catch sides of the Ada exception machinery disagree about the BIGGEST_ALIGNMENT setting. gcc/ada/ PR ada/120440 * gcc-interface/Makefile.in (GNATLINK_OBJS): Add s-excmac.o. (GNATMAKE_OBJS): Likewise.
2025-07-28ada: Minor typo fix in commentMarc Poulhiès1-1/+1
gcc/ada/ChangeLog: * gcc-interface/trans.cc (gnat_to_gnu): Fix typo in comment.
2025-07-25diagnostics: make context::m_source_printing privateDavid Malcolm1-1/+1
No functional change intended. gcc/ada/ChangeLog: * gcc-interface/misc.cc: Make diagnostics::context::m_source_printing private. gcc/analyzer/ChangeLog: * program-point.cc: Make diagnostics::context::m_source_printing private. gcc/c-family/ChangeLog: * c-common.cc: Make diagnostics::context::m_source_printing private. * c-format.cc: Likewise. * c-opts.cc: Likewise. gcc/ChangeLog: * diagnostic.h (diagnostic_set_caret_max_width): Drop forward decl. (diagnostic_same_line): Make diagnostics::context::m_source_printing private. * diagnostics/context.cc (diagnostic_set_caret_max_width): Convert to... (diagnostics::context::set_caret_max_width): ...this. * diagnostics/context.h (diagnostics::context::get_source_printing_options): New accessors. (diagnostics::context::m_source_printing): Make private. * diagnostics/html-sink.cc: Make diagnostics::context::m_source_printing private. * diagnostics/paths-output.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/selftest-context.cc: Likewise. * diagnostics/selftest-context.h (diagnostics::selftest::test_context::colorize_source): New. (diagnostics::selftest::test_context::show_labels): New. (diagnostics::selftest::test_context::show_line_numbers): New. (diagnostics::selftest::test_context::show_ruler): New. (diagnostics::selftest::test_context::show_event_links): New. (diagnostics::selftest::test_context::set_caret_char): New. * diagnostics/source-printing.cc: Make diagnostics::context::m_source_printing private. * diagnostics/text-sink.h: Likewise. * libgdiagnostics.cc: Likewise. * opts.cc: Likewise. * toplev.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Make diagnostics::context::m_source_printing private. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_show_trees.cc: Make diagnostics::context::m_source_printing private. * gcc.dg/plugin/diagnostic_plugin_test_inlining.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_string_literals.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: convert diagnostic_t to enum class diagnostics::kindDavid Malcolm1-6/+6
No functional change intended. gcc/ChangeLog: * Makefile.in: Replace diagnostic.def with diagnostics/kinds.def. * config/aarch64/aarch64.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * config/i386/i386-options.cc: Likewise. * config/s390/s390.cc: Likewise. * diagnostic-core.h: Replace typedef diagnostic_t with enum class diagnostics::kind in diagnostics/kinds.h and include it. * diagnostic-global-context.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * diagnostic.cc: Likewise. * diagnostic.h: Likewise. * diagnostics/buffering.cc: Likewise. * diagnostics/buffering.h: Likewise. * diagnostics/context.h: Likewise. * diagnostics/diagnostic-info.h: Likewise. * diagnostics/html-sink.cc: Likewise. * diagnostic.def: Move to... * diagnostics/kinds.def: ...here and update for diagnostic_t becoming enum class diagnostics::kind. * diagnostics/kinds.h: New file, based on material in diagnostic-core.h. * diagnostics/lazy-paths.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * diagnostics/option-classifier.cc: Likewise. * diagnostics/option-classifier.h: Likewise. * diagnostics/output-spec.h: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/selftest-context.cc: Likewise. * diagnostics/selftest-context.h: Likewise. * diagnostics/sink.h: Likewise. * diagnostics/source-printing.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * diagnostics/text-sink.h: Likewise. * gcc.cc: Likewise. * libgdiagnostics.cc: Likewise. * lto-wrapper.cc: Likewise. * opts-common.cc: Likewise. * opts-diagnostic.h: Likewise. * opts.cc: Likewise. * rtl-error.cc: Likewise. * substring-locations.cc: Likewise. * toplev.cc: Likewise. gcc/ada/ChangeLog: * gcc-interface/trans.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/analyzer/ChangeLog: * pending-diagnostic.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * program-point.cc: Likewise. gcc/c-family/ChangeLog: * c-common.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * c-format.cc: Likewise. * c-lex.cc: Likewise. * c-opts.cc: Likewise. * c-pragma.cc: Likewise. * c-warn.cc: Likewise. gcc/c/ChangeLog: * c-errors.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * c-parser.cc: Likewise. * c-typeck.cc: Likewise. gcc/cobol/ChangeLog: * util.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/cp/ChangeLog: * call.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * constexpr.cc: Likewise. * cp-tree.h: Likewise. * decl.cc: Likewise. * error.cc: Likewise. * init.cc: Likewise. * method.cc: Likewise. * module.cc: Likewise. * parser.cc: Likewise. * pt.cc: Likewise. * semantics.cc: Likewise. * typeck.cc: Likewise. * typeck2.cc: Likewise. gcc/d/ChangeLog: * d-diagnostic.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/fortran/ChangeLog: * cpp.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * error.cc: Likewise. * options.cc: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/m2/ChangeLog: * gm2-gcc/m2linemap.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * gm2-gcc/rtegraph.cc: Likewise. gcc/rust/ChangeLog: * backend/rust-tree.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * backend/rust-tree.h: Likewise. * resolve/rust-ast-resolve-expr.cc: Likewise. * resolve/rust-ice-finalizer.cc: Likewise. * resolve/rust-ice-finalizer.h: Likewise. * resolve/rust-late-name-resolver-2.0.cc: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. * lib/gcc-dg.exp: Likewise. libcpp/ChangeLog: * internal.h: Update comment for diagnostic_t becoming enum class diagnostics::kind. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: move diagnostic_context to diagnostics::context in its own headerDavid Malcolm1-1/+1
No functional change intended. gcc/ada/ChangeLog: * gcc-interface/misc.cc: Update for diagnostic_context becoming diagnostics::context. gcc/analyzer/ChangeLog: * program-point.cc: : Update for diagnostic_context becoming diagnostics::context, and for diagnostic_source_print_policy becoming diagnostics::source_print_policy. gcc/c-family/ChangeLog: * c-common.h: Update for diagnostic_context becoming diagnostics::context. * c-opts.cc: Likewise. gcc/c/ChangeLog: * c-objc-common.cc: Update for diagnostic_context becoming diagnostics::context. * c-tree.h: Likewise. gcc/ChangeLog: * coretypes.h: Update for diagnostic_context becoming diagnostics::context. * diagnostic-global-context.cc: Likewise. * diagnostic.cc: Likewise. Also for diagnostic_option_classifier becoming diagnostics::option_classifier. * diagnostic.h (diagnostic_text_starter_fn): Rename to... (diagnostics::text_starter_fn): ...this, and move to diagnostics/context.h. (get_printer): Rename to... (diagnostics::get_printer): ...this, and move to diagnostics/context.h. (class diagnostic_option_manager): Rename to... (class diagnostics::option_manager): ...this, and move to diagnostics/context.h. (class diagnostic_option_classifier): Rename to... (class diagnostics::option_classifier): ...this, and move to diagnostics/context.h. (struct diagnostic_source_printing_options): Rename to... (struct diagnostics::source_printing_options): ...this, and move to diagnostics/context.h. (class diagnostic_column_policy): Rename to... (class diagnostics::column_policy): ...this, and move to diagnostics/context.h. (class diagnostic_location_print_policy): Rename to... (class diagnostics::location_print_policy): ...this, and move to diagnostics/context.h. (class html_label_writer): Rename to... (class diagnostics::html_label_writer): ...this, and move to diagnostics/context.h. (class diagnostic_source_print_policy): Rename to... (class diagnostics::source_print_policy): ...this, and move to diagnostics/context.h. (struct diagnostic_counters): Rename to... (struct diagnostics::counters): ...this, and move to diagnostics/context.h. (class diagnostic_context): Rename to... (class diagnostics::context): ...this, and move to diagnostics/context.h. (diagnostic_text_starter): Rename to... (diagnostics::text_starter): ...this, and move to diagnostics/context.h. (diagnostic_start_span): Rename to... (diagnostics::start_span): ...this, and move to diagnostics/context.h. (diagnostic_text_finalizer): Rename to... (diagnostics::text_finalizer): ...this, and move to diagnostics/context.h. Include "diagnostics/context.h". * diagnostics/buffering.h: Update for diagnostic_context becoming diagnostics::context; similarly for diagnostic_counters. * diagnostics/client-data-hooks.h: Likewise. * diagnostics/context.h: New file, taken from material in diagnostic.h. * diagnostics/html-sink.cc: : Update for diagnostic_context becoming diagnostics::context. * diagnostics/html-sink.h: Likewise. * diagnostics/lazy-paths.cc: Likewise for diagnostic_option_manager. * diagnostics/output-file.h: Likewise for diagnostic_context. * diagnostics/output-spec.cc: Likewise. * diagnostics/output-spec.h: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/sarif-sink.h: Likewise. * diagnostics/sink.h: Likewise. * diagnostics/source-printing.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * diagnostics/text-sink.h: Likewise. * gcc-rich-location.h: Likewise. * gcc.cc: Likewise. * gdbinit.in: Likewise. * langhooks-def.h: Likewise. * langhooks.cc: Likewise. * langhooks.h: Likewise. * libgdiagnostics.cc: Likewise. * optc-gen.awk: Likewise. * opth-gen.awk: Likewise. * opts-common.cc: Likewise. * opts-diagnostic.cc: Likewise. * opts-diagnostic.h: Likewise. * opts-global.cc: Likewise. * opts.cc: Likewise. * opts.h: Likewise. * selftest-diagnostic.cc: Likewise. * selftest-diagnostic.h: Likewise. * toplev.cc: Likewise. * tree-diagnostic-client-data-hooks.cc: Likewise. * tree-diagnostic.cc: Likewise. * tree-diagnostic.h: Likewise. gcc/cp/ChangeLog: * cp-tree.h: Update for diagnostic_context becoming diagnostics::context. * error.cc: Likewise. * module.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Update for diagnostic_context becoming diagnostics::context. gcc/jit/ChangeLog: * dummy-frontend.cc: Update for diagnostic_context becoming diagnostics::context. * jit-playback.h: Likewise. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc: Update for diagnostic_text_finalizer becoming diagnostics::text_finalizer. * resolve/rust-late-name-resolver-2.0.cc: Likewise. gcc/testsuite/ChangeLog: * g++.dg/plugin/show_template_tree_color_plugin.cc: Update for moves to namespace diagnostics. * gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25ada: Minor cleanupMarc Poulhiès1-15/+16
Renamed local variables to make it easier to read. gcc/ada/ChangeLog: * gcc-interface/utils.cc (update_pointer_to): Renamed ptr/old_ptr, ref/old_ref.
2025-07-21Error handling for hard register constraintsStefan Schulze Frielinghaus1-4/+5
This implements error handling for hard register constraints including potential conflicts with register asm operands. In contrast to register asm operands, hard register constraints allow more than just one register per operand. Even more than just one register per alternative. For example, a valid constraint for an operand is "{r0}{r1}m,{r2}". However, this also means that we have to make sure that each register is used at most once in each alternative over all outputs and likewise over all inputs. For asm statements this is done by this patch during gimplification. For hard register constraints used in machine description, error handling is still a todo and I haven't investigated this so far and consider this rather a low priority. gcc/ada/ChangeLog: * gcc-interface/trans.cc (gnat_to_gnu): Pass null pointer to parse_{input,output}_constraint(). gcc/analyzer/ChangeLog: * region-model-asm.cc (region_model::on_asm_stmt): Pass null pointer to parse_{input,output}_constraint(). gcc/c/ChangeLog: * c-typeck.cc (build_asm_expr): Pass null pointer to parse_{input,output}_constraint(). gcc/ChangeLog: * cfgexpand.cc (n_occurrences): Move this ... (check_operand_nalternatives): and this ... (expand_asm_stmt): and the call to gimplify.cc. * config/s390/s390.cc (s390_md_asm_adjust): Pass null pointer to parse_{input,output}_constraint(). * gimple-walk.cc (walk_gimple_asm): Pass null pointer to parse_{input,output}_constraint(). (walk_stmt_load_store_addr_ops): Ditto. * gimplify-me.cc (gimple_regimplify_operands): Ditto. * gimplify.cc (num_occurrences): Moved from cfgexpand.cc. (num_alternatives): Ditto. (gimplify_asm_expr): Deal with hard register constraints. * stmt.cc (eliminable_regno_p): New helper. (hardreg_ok_p): Perform a similar check as done in make_decl_rtl(). (parse_output_constraint): Add parameter for gimplify_reg_info and validate hard register constrained operands. (parse_input_constraint): Ditto. * stmt.h (class gimplify_reg_info): Forward declaration. (parse_output_constraint): Add parameter. (parse_input_constraint): Ditto. * tree-ssa-operands.cc (operands_scanner::get_asm_stmt_operands): Pass null pointer to parse_{input,output}_constraint(). * tree-ssa-structalias.cc (find_func_aliases): Pass null pointer to parse_{input,output}_constraint(). * varasm.cc (assemble_asm): Pass null pointer to parse_{input,output}_constraint(). * gimplify_reg_info.h: New file. gcc/cp/ChangeLog: * semantics.cc (finish_asm_stmt): Pass null pointer to parse_{input,output}_constraint(). gcc/d/ChangeLog: * toir.cc: Pass null pointer to parse_{input,output}_constraint(). gcc/testsuite/ChangeLog: * gcc.dg/pr87600-2.c: Split test into two files since errors for functions test{0,1} are thrown during expand, and for test{2,3} during gimplification. * lib/scanasm.exp: On s390, skip lines beginning with #. * gcc.dg/asm-hard-reg-error-1.c: New test. * gcc.dg/asm-hard-reg-error-2.c: New test. * gcc.dg/asm-hard-reg-error-3.c: New test. * gcc.dg/asm-hard-reg-error-4.c: New test. * gcc.dg/asm-hard-reg-error-5.c: New test. * gcc.dg/pr87600-3.c: New test. * gcc.target/aarch64/asm-hard-reg-2.c: New test. * gcc.target/s390/asm-hard-reg-7.c: New test.
2025-07-04Ada: Switch from ACATS 2.6 to ACATS 4.2 testsuiteEric Botcazou1-1/+1
This effectively adds 250 new tests, i.e. around 10% more tests. gcc/ada/ * gcc-interface/Make-lang.in (ACATSDIR): Change to acats-4.
2025-07-04ada: Fix alignment violation for chain of aligned and misaligned composite typesEric Botcazou1-1/+3
This happens when aggressive optimizations are enabled (i.e. -O2 and above) because the ivopts pass fails to properly mark the new memory accesses it is creating as misaligned by means of the build_aligned_type function. gcc/ada/ChangeLog: * gcc-interface/utils.cc (make_packable_type): Clear the TYPE_PACKED flag in the case where the alignment is bumped.
2025-07-04ada: Remove strange elaboration code generated for Cluster type in ↵Eric Botcazou1-3/+7
System.Pack_NN Initialization procedures are turned into functions under the hood and, even when they are null (empty), the compiler may generate a convoluted sequence of instructions that return uninitialized data and, therefore, is useless. gcc/ada/ChangeLog: * gcc-interface/trans.cc (Subprogram_Body_to_gnu): Do not generate a block-copy out for a null initialization procedure when the _Init parameter is not passed in.
2025-07-04ada: Disable previous change for enumeration typesEric Botcazou1-3/+3
The debugger cannot correctly interpret the return value in this case. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Only apply the transformation to integer types.
2025-07-04ada: Add missing guards to previous changeEric Botcazou1-0/+4
We need to make sure that an integer type exists for the given size. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Add guards.
2025-07-04ada: Improve code generated for return of Out parameter with access typeEric Botcazou2-4/+38
The second problem occurs on 64-bit platforms where there is a second Out parameter that is smaller than the access parameter, creating a hole in the return structure. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): In the case of a subprogram using the Copy-In/Copy-Out mechanism, deal specially with the case of 2 parameters of differing sizes. * gcc-interface/trans.cc (Subprogram_Body_to_gnu): In the case of a subprogram using the Copy-In/Copy-Out mechanism, make sure the types are consistent on the two sides for all the parameters.
2025-07-03Ada: Remove left-overs of front-end exception mechanismEric Botcazou1-30/+0
It was removed from the compiler a few releases ago. gcc/ada/ * gcc-interface/Makefile.in (gnatlib-sjlj): Delete. (gnatlib-zcx): Do not modify Frontend_Exceptions constant. * libgnat/system-linux-loongarch.ads (Frontend_Exceptions): Delete.
2025-07-03ada: Fix poor code generated for return of Out parameter with access typeEric Botcazou1-2/+3
The record type of the return object is unnecessarily given BLKmode. gcc/ada/ChangeLog: * gcc-interface/decl.cc (type_contains_only_integral_data): Do not return false only because the type contains pointer data.
2025-07-03ada: Enforce alignment constraint for large Object_Size clausesEric Botcazou1-1/+15
The constraint is that the Object_Size must be a multiple of the alignment in bits. But it's enforced only when the value of the clause is lower than the Value_Size rounded up to the alignment in bits, not for larger values. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Use default messages for errors reported for Object_Size clauses. (validate_size): Give an error for stand-alone objects of composite types if the specified size is not a multiple of the alignment.
2025-07-03ada: Fix alignment violation for mix of aligned and misaligned composite typesEric Botcazou1-18/+23
This happens when the chain of initialization procedures is called on the subcomponents and causes the creation of temporaries along the way out of alignment considerations. Now these temporaries are not necessary in the context and were not created until recently, so this gets rid of them. gcc/ada/ChangeLog: * gcc-interface/trans.cc (addressable_p): Add COMPG third parameter. <COMPONENT_REF>: Do not return true out of alignment considerations for non-strict-alignment targets if COMPG is set. (Call_to_gnu): Pass true as COMPG in the call to the addressable_p predicate if the called subprogram is an initialization procedure.
2025-07-03ada: Fix wrong finalization of constrained subtype of unconstrained array typeEric Botcazou1-6/+32
This implements the Is_Constr_Array_Subt_With_Bounds flag for allocators. gcc/ada/ChangeLog: * gcc-interface/trans.cc (gnat_to_gnu) <N_Allocator>: Allocate the bounds alongside the data if the Is_Constr_Array_Subt_With_Bounds flag is set on the designated type. <N_Free_Statement>: Take into account the allocated bounds if the Is_Constr_Array_Subt_With_Bounds flag is set on the designated type.
2025-07-03ada: Fix missing error on too large Component_Size not multiple of storage unitEric Botcazou1-5/+11
This is a small regression introduced a few years ago. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_component_type): Validate the Component_Size like the size of a type only if the component type is actually packed.
2025-07-01ada: Split the unit System.Case_Utilities into two parts.Steve Baird2-1/+3
The package System.Case_Utilities provides some subprograms that do not make use of the secondary stack and some that do. When compiling in a context where no secondary stack support is provided, this makes the entire package unusable (and similarly for any other package that withs this package). Split the package into two packages named Case_Utilities_NSS and Case_Utilities (NSS is for "no secondary stack"). The first package declares the subprograms that do not need secondary stack support. The second package declares the remaining subprograms, as well as renamings of everything declared in the first part. A client that continues to reference Case_Utilities is largely unaffected by this change. But if we change a client to reference Case_Utilities_NSS instead, that removes an obstacle that would otherwise prevent using that client unit in a no-secondary-stack-support environment. We then make that change to the body of package System.Val_Util. gcc/ada/ChangeLog: * Makefile.rtl: Add entry for new unit's object file. * libgnat/s-casuti.adb: Remove bodies of subprograms that were moved to the new unit. * libgnat/s-casuti.ads: Replace (with renamings) declarations for subprograms that moved to the new unit. * libgnat/s-cautns.adb: Body for new unit (a new source file). * libgnat/s-cautns.ads: Spec for new unit (a new source file). * libgnat/s-valuti.adb: Use the new unit instead of the old one. * gcc-interface/Make-lang.in: Add entries for new unit's object file. * gcc-interface/Makefile.in: Likewise.
2025-06-26diagnostics: make 5 more fields of diagnostic_context privateDavid Malcolm1-1/+1
No functional change intended. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_init): Use diagnostic_context::set_internal_error_callback. gcc/c-family/ChangeLog: * c-opts.cc (c_common_diagnostics_set_defaults): Use diagnostic_context::set_permissive_option. gcc/cp/ChangeLog: * error.cc (cxx_initialize_diagnostics): Use diagnostic_context::set_adjust_diagnostic_info_callback. gcc/ChangeLog: * diagnostic.h (diagnostic_context::set_permissive_option): New. (diagnostic_context::set_fatal_errors): New. (diagnostic_context::set_internal_error_callback): New. (diagnostic_context::set_adjust_diagnostic_info_callback): New. (diagnostic_context::inhibit_notes): New. (diagnostic_context::m_opt_permissive): Make private. (diagnostic_context::m_fatal_errors): Likewise. (diagnostic_context::m_internal_error): Likewise. (diagnostic_context::m_adjust_diagnostic_info): Likewise. (diagnostic_context::m_inhibit_notes_p): Likewise. (diagnostic_inhibit_notes): Delete. * opts.cc (common_handle_option): Use diagnostic_context::set_fatal_errors. * toplev.cc (internal_error_function): Use diagnostic_context::set_internal_error_callback. (general_init): Likewise. (process_options): Use diagnostic_context::inhibit_notes. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-06-23Ada: Replace hardcoded GNAT commands for GNAT toolsNicolas Boulenguez1-8/+9
This replaces the hardcoded gnat{make,link,bind,ls} commands with expansion of the GNAT{MAKE,BIND} variables computed by the configure machinery, during the build of the GNAT tools. The default GNATMAKE_FOR_HOST duplicates the default GNATMAKE, and someone setting GNATMAKE in the toplevel configuration may want it applied for all host compilations. Direct assignment of GNATMAKE_FOR_HOST keeps working. gcc/ada/ PR ada/120106 * gcc-interface/Make-lang.in: Set GNAT{MAKE,BIND,LINK_LS}_FOR_HOST from GNAT{MAKE,BIND} instead of using hardcoded commands. gnattools/ PR ada/120106 * configure.ac: Remove ACX_NONCANONICAL_HOST and add ACX_PROG_GNAT. * configure: Regenerate. * Makefile.in: Do not substitute host_noncanonical but substitute GNATMAKE and GNATBIND. Set GNAT{MAKE,BIND,LINK_LS}_FOR_HOST from GNAT{MAKE,BIND} instead of using hardcoded commands.
2025-06-23Ada: Introduce GNATMAKE_FOR_BUILD Makefile variableNicolas Boulenguez1-1/+3
This gets rid of the hardcoded 'gnatmake' command used during the build. / PR ada/120106 * Makefile.tpl: Add GNATMAKE_FOR_BUILD to {HOST,BASE_TARGET}_EXPORTS * Makefile.in: Regenerate. * configure.ac: Set the default and substitute the variable. * configure: Regenerate. gcc/ada/ PR ada/120106 * Make-generated.in: Use GNATMAKE_FOR_BUILD instead of gnatmake. * gcc-interface/Makefile.in: Likewise.
2025-06-12ada: Fix code size increase with pragma Aggregate_Individually_AssignEric Botcazou1-1/+19
The problem is that individual assignments have to preserve the other bits of the target, in other words the original semantics of aggregates, where the anonymous object is entirely constructed, is partially lost. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Generate a zero-initialization for the anonymous object of a small aggregate allocated on the stack. (inline_status_for_subprog): Minor tweak.
2025-06-06ada: Refactor the implementation of gnat diagnosticsViljar Indus2-30/+15
The goal of this patch is to remove the implementation from the Diagnostic objects and port the new features over to the Error_Msg_Objects. gcc/ada/ChangeLog: * debug.adb: Mark -gnatd_D as unused. * diagnostics-repository.adb: Move to... * errid.adb: ...here. * diagnostics-repository.ads: Move to... * errid.ads: ...here. * errout.adb (Error_Msg_Internal): Add new arguments for the new attributes of Error_Msg_Objects. (Error_Msg): Likewise. (Error_Msg_N): Likewise. (Labeled_Span): New method for creating Labeled_Span-s (Primary_Label_Span): New method for creating primary Labeled_Spans. (Secondary_Labeled_Span): New method for creating secondary Labeled_Spans. (Edit): New method for creating Edit elements. (Fix): New method for creating Fix elements. (Error_Msg_F): Simplify code for evaluating the span. (Error_Msg_FE): Likewise. (Error_Msg_NE): Likewise. (Error_Msg_NEL): Likewise. (Error_Msg_N_Gigi): New method that is used as a wrapper for the Error_Msg_xxx methods that have the new arguments. This function is later mapped to the Error_Msg method used inside gigi. (Error_Msg_NE_Gigi): Likewise. (Write_JSON_Span): Ensure that the Style prefix is included that is removed when parsing the message is reinserted to the JSON report. (Output_Messages): Use the new Pretty_Printer and Sarif_Printer packages to print the messages and remove the old implementation for the pretty printer. (Set_Msg_Text): Remove message kind insertion characters from the final message text to avoid some message kinds being duplicated. (To_Full_Span_First): New method for creating a span for a node. (To_Full_Span): Likewise. * errout.ads: Add the specs for all of the newly added functions. * diagnostics-pretty_emitter.adb: Move to... * erroutc-pretty_emitter.adb: ...here. * diagnostics-pretty_emitter.ads: Move to... * erroutc-pretty_emitter.ads: ...here. * diagnostics-sarif_emitter.adb: Move to... * erroutc-sarif_emitter.adb: ...here. * diagnostics-sarif_emitter.ads: Move to... * erroutc-sarif_emitter.ads: ...here. * erroutc.adb (Next_Error_Msg): New method for iterating to the next error message. (Next_Continuation_Msg): New method for iterating to the next continuation message. (Primary_Location): New method for returning the first primary location for the error message. (Get_Human_Id): New method for returning the human readable name for the switch associated with this error message. (Get_Doc_Switch): New method for creating the tag for the switch used in the error message. (Output_Text_Within): Change the method to operating on Strings instead of String pointers. (Output_Msg_Text): Simplify implementation for generating the error message. (Prescan_Message): Make the String handling more error proof. * erroutc.ads (Error_Msg_Object): Add new attributes that were added to Diagnostic objects to Error_Msg_Objects. Add new methods for handling the new error objects. * diagnostics-switch_repository.adb: Move to... * errsw.adb: ...here. * errutil.adb (Error_Msg): Initialize all of the new attributes added to Error_Msg_Object-s. * fe.h (Error_Msg_N): Update the binding. (Error_Msg_NE): Update the binding. For now the error_msg methods in gigi will use the old simplified interface for those methods. * diagnostics-json_utils.adb: Move to... * json_utils.adb: ...here. * diagnostics-json_utils.ads: Move to... * json_utils.ads: ...here. * par-endh.adb: Replace the old error_msg calls with the updated interface. * sem_aggr.adb: Likewise. * sem_ch13.adb: Likewise. * sem_ch4.adb: Likewise. * sem_ch9.adb: Likewise. * diagnostics-brief_emitter.adb: Removed. * diagnostics-brief_emitter.ads: Removed. * diagnostics-constructors.adb: Removed. * diagnostics-constructors.ads: Removed. * diagnostics-converter.adb: Removed. * diagnostics-converter.ads: Removed. * diagnostics-switch_repository.ads: Removed. * diagnostics-utils.adb: Removed. * diagnostics-utils.ads: Removed. * diagnostics.adb: Removed. * diagnostics.ads: Removed. * errsw.ads: New file. Based on diagnostics-switch_repository.ads. It additionally contains all the switch enumerations. * gcc-interface/Make-lang.in: Update compilation dependencies. * gcc-interface/Makefile.in: Likewise.
2025-06-05ada: Remove ghost code and SPARK annotations from runtime unitsArnaud Charlet1-5/+0
This is a clean up to facilitate maintenance now that these units have been proven. gcc/ada/ChangeLog: * exp_util.adb, rtsfind.adb, rtsfind.ads, sem_prag.adb: Remove references to RO_GH_Big_Integer and Ada_Numerics_Big_Numbers_Big_Integers_Ghost. * libgnat/a-strfix.adb, libgnat/a-strmap.adb, libgnat/a-strsea.adb, libgnat/a-strsup.adb, libgnat/i-c.ads, libgnat/i-c.adb, libgnat/s-aridou.adb, libgnat/s-aridou.ads, libgnat/s-arit128.adb, libgnat/s-arit128.ads, libgnat/s-arit32.adb, libgnat/s-arit32.ads, libgnat/s-arit64.adb, libgnat/s-arit64.ads, libgnat/s-casuti.adb, libgnat/s-exnint.ads, libgnat/s-exnlli.ads, libgnat/s-exnllli.ads, libgnat/s-expint.ads, libgnat/s-explli.ads, libgnat/s-expllli.ads, libgnat/s-explllu.ads, libgnat/s-expllu.ads, libgnat/s-expmod.adb, libgnat/s-expmod.ads, libgnat/s-exponn.adb, libgnat/s-exponn.ads, libgnat/s-expont.adb, libgnat/s-expont.ads, libgnat/s-exponu.adb, libgnat/s-exponu.ads, libgnat/s-imaged.ads, libgnat/s-imaged.adb, libgnat/s-expuns.ads, libgnat/s-imagef.ads, libgnat/s-imagef.adb, libgnat/s-imagei.adb, libgnat/s-imagei.ads, libgnat/s-imageu.adb, libgnat/s-imageu.ads, libgnat/s-imgboo.adb, libgnat/s-imde128.ads, libgnat/s-imde32.ads, libgnat/s-imde64.ads, libgnat/s-imfi128.ads, libgnat/s-imfi32.ads, libgnat/s-imfi64.ads, libgnat/s-imgboo.ads, libgnat/s-imgint.ads, libgnat/s-imglli.ads, libgnat/s-imgllli.ads, libgnat/s-imglllu.ads, libgnat/s-imgllu.ads, libgnat/s-imguns.ads, libgnat/s-valboo.adb, libgnat/s-valboo.ads, libgnat/s-valint.ads, libgnat/s-vallli.ads, libgnat/s-valllli.ads, libgnat/s-vallllu.ads, libgnat/s-valllu.ads, libgnat/s-valuns.ads, libgnat/s-valuti.adb, libgnat/s-valuti.ads, libgnat/s-valuei.adb, libgnat/s-valuei.ads, libgnat/s-valueu.ads, libgnat/s-valueu.adb, libgnat/s-veboop.adb, libgnat/s-veboop.ads, libgnat/s-widint.ads, libgnat/s-widlli.ads, libgnat/s-widllli.ads, libgnat/s-widlllu.ads, libgnat/s-widllu.ads, libgnat/s-widthi.adb, libgnat/s-widthu.adb, libgnat/s-widthu.ads, libgnat/s-widuns.ads: Remove ghost code and SPARK annotations. * libgnat/a-nbnbig.ads, libgnat/a-nbnbig.adb, libgnat/s-spark.ads, libgnat/s-spcuop.adb, libgnat/s-spcuop.ads, libgnat/s-vaispe.adb, libgnat/s-vaispe.ads, libgnat/s-vauspe.adb, libgnat/s-vauspe.ads, libgnat/s-vs_int.ads, libgnat/s-vs_lli.ads, libgnat/s-vs_llu.ads, libgnat/s-vs_uns.ads, libgnat/s-valspe.adb, libgnat/s-valspe.ads, libgnat/s-vsllli.ads, libgnat/s-vslllu.ads: Removed. * Makefile.rtl: Update list of runtime units. * gcc-interface/Make-lang.in: Remove object files.
2025-05-24Ada: move ACATS 2.6 testsuite to acats-2 directoryEric Botcazou1-1/+1
This is in preparation for the installation of the ACATS 4.2 testsuite. gcc/ada/ * gcc-interface/Make-lang.in (ACATSDIR): Use acats-2 directory. gcc/testsuite/ * ada/acats/*: Rename into ada/acats-2/*. * ada/acats-2/run_all.sh: Adjust to above renaming. * ada/acats-2/support/impdefc.a: New file.
2025-05-13Remove -q quiet option from some GNAT bootstrap command linesNicolas Boulenguez1-1/+1
gcc/ada/ PR ada/87778 * Make-generated.in: Remove -q gnatmake option. * gcc-interface/Makefile.in: Likewise.
2025-04-27Drop targetm.promote_prototypes from C, C++ and Ada frontendsH.J. Lu1-24/+0
Remove the targetm.calls.promote_prototypes call from C, C++ and Ada frontends. gcc/ PR c/48274 PR middle-end/112877 PR middle-end/118288 * gimple.cc (gimple_builtin_call_types_compatible_p): Remove the targetm.calls.promote_prototypes call. * tree.cc (tree_builtin_call_types_compatible_p): Likewise. gcc/ada/ PR middle-end/112877 * gcc-interface/utils.cc (create_param_decl): Remove the targetm.calls.promote_prototypes call. gcc/c/ PR c/48274 PR middle-end/112877 PR middle-end/118288 * c-decl.cc (start_decl): Remove the targetm.calls.promote_prototypes call. (store_parm_decls_oldstyle): Likewise. (finish_function): Likewise. * c-typeck.cc (convert_argument): Likewise. (c_safe_arg_type_equiv_p): Likewise. gcc/cp/ PR middle-end/112877 * call.cc (type_passed_as): Remove the targetm.calls.promote_prototypes call. (convert_for_arg_passing): Likewise. * typeck.cc (cxx_safe_arg_type_equiv_p): Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-07Ada: Fix wrong 'Access to aliased constrained array of controlled typeEric Botcazou2-6/+22
For technical reasons, the recently reimplemented finalization machinery for controlled types requires arrays of controlled types to be allocated with their bounds, including in the case where their nominal subtype is constrained. However, in this case, the type of 'Access for the arrays is pointer-to-constrained-array and, therefore, its value must designate the array itself and not the bounds. gcc/ada/ * gcc-interface/utils.cc (convert) <POINTER_TYPE>: Use fold_convert to convert between thin pointers. If the source is a thin pointer with zero offset from the base and the target is a pointer to its array, displace the pointer after converting it. * gcc-interface/utils2.cc (build_unary_op) <ATTR_ADDR_EXPR>: Use fold_convert to convert the address before displacing it.
2025-03-25Add support of --enable-host-pie to the native Ada compilerEric Botcazou2-39/+60
gcc/ada/ PR ada/119440 * gcc-interface/Make-lang.in (GCC_LINK): Filter out -pie in stage 1 (GCC_LLINK): Likewise. * gcc-interface/Makefile.in (COMPILER): Delete and replace by CC. (COMPILER_FLAGS): Delete. (ALL_COMPILERFLAGS): Delete and replace by ALL_CFLAGS. (ALL_ADAFLAGS): Move around. (enable_host_pie): New substituted variable. (LD_PICFLAG): Likewise. Do not add it to TOOLS_LIBS. (LIBIBERTY): Test enable_host_pie. (LIBGNAT): Likewise and use libgnat_pic.a if yes. (TOOLS_FLAGS_TO_PASS): Pass $(PICFLAG) under CFLAGS & $(LD_PICFLAG) under LDFLAGS. Also pass through ADA_CFLAGS. (common-tools): Add $(ALL_CFLAGS) $(ADA_CFLAGS) to the --GCC string of $(GNATLINK) commands. (../../gnatdll$(exeext)): Likewise. (gnatmake-re): Likewise. (gnatlink-re): Likewise. (gnatlib-shared-dual): Remove all the object files at the end. gnattools/ PR ada/119440 * configure.ac (host-pie): New switch. (host-bind-now): Likewise. Substitute PICFLAG and LD_PICFLAG. * configure: Regenerate. * Makefile.in (PICFLAG): New substituted variable. (LD_PICFLAG): Likewise. (TOOLS_FLAGS_TO_PASS): Pass $(PICFLAG) under CFLAGS & $(LD_PICFLAG) under LDFLAGS. Do not pass -I- under ADA_INCLUDES. (TOOLS_FLAGS_TO_PASS_RE): Likewise.
2025-03-19Fix misoptimization at -O2 in LTO modeEric Botcazou1-0/+8
This is a regression in recent releases. The problem is that the IPA mod/ref pass looks through the (nominal) type of a pointer-to-discriminated-type parameter in a call to a subprogram in order to see the (actual) type used for the dereferences of the parameter in the callee, which is a pointer-to-constrained-subtype. Historically the discriminated type is marked with the may_alias attribute because of the symmetric effect for the argument in the caller, so we mark the constrained subtype with the attribute now for the sake of the callee. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: Set the may_alias attribute if a specific GCC type is built.
2025-01-31Fix wrong elaboration for allocator at library level of dynamic libraryEric Botcazou1-6/+10
The problem was preexisting for class-wide allocators, but now occurs for allocators of controlled types too, because of the recent overhaul of the finalization machinery. gcc/ada/ * gcc-interface/utils.cc (gnat_pushdecl): Clear TREE_PUBLIC on functions really nested in another function.
2025-01-22d,ada/spec: only sub nostd{inc,lib} rather than nostd{inc,lib}*Arsen Arsenović1-3/+3
This prevents the gcc driver erroneously accepting -nostdlib++ when it should not when Ada was enabled. Also, similarly, -nostdinc* (where * is nonempty) is unhandled by either the Ada or D compiler, so the spec should not substitute those either (thanks for pointing that out, Jakub). Brought to my attention by Michał Górny <mgorny@gentoo.org>. gcc/ada/ChangeLog: * gcc-interface/lang-specs.h: Replace %{nostdinc*} %{nostdlib*} with %{nostdinc} %{nostdlib}. gcc/d/ChangeLog: * lang-specs.h: Replace %{nostdinc*} with %{nostdinc}. gcc/testsuite/ChangeLog: * gcc.dg/driver-nostdlibstar.c: New test.
2025-01-07Update copyright years.Marc Poulhiès19-19/+19
2025-01-07ada: Drop g-cpp* units not needed by the compilerAlexandre Oliva1-6/+0
Having moved __gnat_convert_caught_object to g-cstyin.o, we can drop other g-cpp* units that are now needed by programs that actually use their APIs to get more information about C++ exceptions and type_info objects. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS): Drop g-cpp, g-cppexc and g-cppstd.
2025-01-07ada: Do not create temporaries for initialization statementsEric Botcazou1-1/+14
Assignment statements marked with the No_Ctrl_Actions or No_Finalize_Actions flag are initialization statements and, therefore, no temporaries are needed to hold the value of the right-hand side for them. gcc/ada/ChangeLog: * gcc-interface/trans.cc (Call_to_gnu): Always use the return slot optimization if the parent node is an initialization statement. (gnat_to_gnu) <N_Assignment_Statement>: Build an INIT_EXPR instead of a MODIFY_EXPR if this is an initialization statement.
2025-01-07ada: Add "finally" GNAT extensionRonan Desplanques1-0/+23
This patch adds a new reserved word, "finally", and accompanying new syntax that's similar to the Java equivalent. gcc/ada/ChangeLog: * atree.adb (Parent_Or_List_Containing): New function. * atree.ads (Parent_Or_List_Containing): Likewise. * gen_il-fields.ads: Add new field. * gen_il-gen-gen_nodes.adb (Gen_Nodes): Extend handled sequence of statements node. * par-ch11.adb (P_Handled_Sequence_Of_Statements, P_Exception_Handler): Add new syntactic construct. * par-ch5.adb (P_Sequence_Of_Statements): Likewise. * par.adb: Likewise. * par-util.adb (Check_Future_Keyword): Warn that "finally" becomes a reserved word with extensions. * scans.adb (Initialize_Ada_Keywords): Add new reserved word. * snames.adb-tmpl: Likewise. * snames.ads-tmpl: Likewise. * scans.ads: Likewise. * sem_ch11.adb (Analyze_Handled_Statements): Adapt to new node field. * sem_ch5.adb (Analyze_Exit_Statement): Add legality check. (Analyze_Goto_Statement): Likewise. * sem_ch6.adb (Analyze_Return_Statement): Likewise. * sinfo-utils.adb (Lowest_Common_Ancestor, Destroy_Element): New subprograms. * sinfo-utils.ads (Lowest_Common_Ancestor): New function. * sinfo.ads: Add documentation for new field. * xsnamest.adb: Fix typo in comment. * doc/gnat_rm/gnat_language_extensions.rst: Document new extension. * warnsw.adb: Add new option. * warnsw.ads: Likewise. * exp_ch11.adb (Expand_N_Handled_Sequence_Of_Statements): Add abort deferral to finally part. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate. * gcc-interface/trans.cc (Handled_Sequence_Of_Statements_to_gnu): Handle finally statements.
2025-01-06Ada: fix spurious relinking of gnatbind for cross compilersEric Botcazou1-3/+7
The problem has been introduced by r15-1881. gcc/ada PR ada/118247 * gcc-interface/Make-lang.in (GNATTOOLS_CROSS_MV): Copy gnatbind instead of moving it.
2025-01-03ada: Handle C++ exception hierarchiesAlexandre Oliva1-0/+10
This patch introduces support for defining exceptions in Ada with C++'s notion of exception type compatibility, such as handling occurrences of derived types, and obtaining class-wide access to the thrown/raised objects. As a bonus, it adds support for C++ dependent (wrapped) exceptions, and introduces types and interfaces to match C++'s std::type_info and std::exception. Support for C++ exceptions with base-type matching, added to raise-gcc by calling subprograms in Ada units, requires these units and their dependencies to be linked into programs that link with raise-gcc. gcc/ada/ChangeLog: * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-cpp, g-cppstd, and g-cstyin. * doc/gnat_rm/interfacing_to_other_languages.rst (Interfacing to C++): Document class-wide matching and new interfaces. * exp_prag.adb (Expand_Pragma_Import_Or_Interface): Add class-wide exception matching support with 'B' as language identifier. * libgnat/a-exexpr.adb (Setup_Current_Excep): Add Id formal. (Set_Foreign_Occurrence): Likewise. (Propagate_GCC_Exception): Adjust. (Set_Exception_Parameter): Likewise. (Unhandled_Except_Handler): Likewise. * libgnat/g-cpp.ads: New. * libgnat/g-cppexc.adb (Raise_Cpp_Exception): Match 'B' lang id. (Get_Object_Address): New. (Get_Object): Rewrite. (Get_Access_To_Object): New. (Get_Access_To_Tagged_Object): New. (Get_Type_Info): New. (Convert_Caught_Object): New. * libgnat/g-cppexc.ads (Get_Object_Address): New. (Get_Object): Note the Cpp Convention requirement. (Get_Access_To_Object): New. (Get_Access_To_Tagged_Object): New. (Get_Type_Info): New. * libgnat/g-cppstd.adb: New. * libgnat/g-cppstd.ads: New. * libgnat/g-csclex.ads: New, unused. * libgnat/g-cstyin.adb: New. * libgnat/g-cstyin.ads: New. * libgnat/g-excact.adb (Exception_Language): New. (Is_Foreign_Exception): Rewrite. * libgnat/g-excact.ads (Exception_Languages): New. (Exception_Language): New. * libgnat/s-stalib.ads (Lang): Document 'B'. * raise-gcc.c (__gnat_setup_current_excep): Add Exception_Id formal. (CXX_DEPENDENT_EXCEPTION_CLASS): New. (cxx_type_info): New. (__cxa_exception): Rename exceptionType to encompass PrimaryException. (_GNAT_Exception): Drop wrapper. (EID_For): Adjust. (exception_class_eq): Likewise. (__gnat_exception_language_is_cplusplus): New. (__gnat_exception_language_is_ada): New. (__gnat_convert_caught_object): Declare. (__gnat_get_cxx_dependent_exception): New. (__gnat_maybe_get_cxx_dependent_exception): New. (__gnat_get_cxx_exception_type_info): New. (__gnat_obtain_caught_object): New. (is_handled_by): Adjust. [!CERT] Add eid formal, handle dependent exceptions and base-type matches. (get_action_description_for) [!CERT]: Add eid formal. Adjust. (personality_body): Adjust. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS) [!STAGE1]: Add new g-cpp, g-cppstd, g-cstyin + preexisting g-cppexc and i-cstrin. * gnat-style.texi: Regenerate. * gnat_rm.texi: Regenerate.
2024-12-14opts: Use OPTION_SET_P instead of magic value 2 for -fshort-enums default ↵Jakub Jelinek1-1/+1
[PR118011] The magic values for default (usually -1 or sometimes 2) for some options are from times we haven't global_options_set, I think we should eventually get rid of all of those. The PR is about gcc -Q --help=optimizers reporting -fshort-enums as [enabled] when it is disabled. For this the following patch is just partial fix; with explicit gcc -Q --help=optimizers -fshort-enums or gcc -Q --help=optimizers -fno-short-enums it already worked correctly before, with this patch it will report even with just gcc -Q --help=optimizers correct value on most targets, except 32-bit arm with some options or defaults, so I think it is a step in the right direction. But, as I wrote in the PR, process_options isn't done before --help= and even shouldn't be in its current form where it warns on some option combinations or errors or emits sorry on others, so I think ideally process_options should have some bool argument whether it is done for --help= purposes or not, if yes, not emit warnings and just adjust the options, otherwise do what it currently does. 2024-12-14 Jakub Jelinek <jakub@redhat.com> PR c/118011 gcc/ * opts.cc (init_options_struct): Don't set opts->x_flag_short_enums to 2. * toplev.cc (process_options): Test !OPTION_SET_P (flag_short_enums) rather than flag_short_enums == 2. gcc/ada/ * gcc-interface/misc.cc (gnat_post_options): Test !OPTION_SET_P (flag_short_enums) rather than flag_short_enums == 2.
2024-12-13ada: Fix internal error on packed record with 0-size componentEric Botcazou1-1/+17
The problem is that the order of components listed in a constant CONSTRUCTOR does not match that of the associated record type. gcc/ada/ChangeLog: * gcc-interface/utils2.cc (compare_elmt_bitpos): Deal specially with 0-sized components when the bit position is the same.
2024-12-13ada: Pass artificial_p to create_type_declTom Tromey1-2/+2
The recent "nameless types" change to gcc-interface caused the gdb pretty-printer for VSS to fail. This happens because one call to create_type_decl unconditionally passes "true" as the "artificial_p" parameter. This patch changes this call to instead pass the entity's local artificial_p value instead. This makes sense, I think, because the type decl being created for debug purposes (as the comment says) is there to represent the relevant entity from the source. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity): Pass artificial_p to create_type_decl.
2024-11-26ada: Do not use ATTR_ADDR_EXPR for 'Unrestricted_AccessEric Botcazou1-3/+8
Unlike for 'Access or 'Unchecked_Access, the Attribute_to_gnu routine passes ATTR_ADDR_EXPR to build_unary_op for 'Unrestricted_Access, which causes the processing done in build_unary_op to flatten the reference, in particular to remove all intermediate (view) conversions, which may be problematic for the SUBSTITUTE_PLACEHOLDER_IN_EXPR machinery. gcc/ada/ChangeLog: * gcc-interface/trans.cc (Attribute_to_gnu) <Attr_Access>: Do not pass ATTR_ADDR_EXPR to build_unary_op for 'Unrestricted_Access.