From 17ba0ad5294f51c15dcf1e1a176b6f15d71e905e Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 8 Feb 2021 11:24:56 +0000 Subject: [PATCH] [Ada] Fix type mismatch warnings during LTO bootstrap #6 gcc/ada/ * gcc-interface/gigi.h (enum standard_datatype): Remove ADT_exception_data_name_id and add ADT_not_handled_by_others_name_id. (exception_data_name_id): Delete. (not_handled_by_others_name_id): New macro. * gcc-interface/decl.c (gnat_to_gnu_entity) : Remove old kludge for exceptions. : Likewise. (gnat_to_gnu_field): Force character type on Not_Handled_By_Others. * gcc-interface/misc.c (gnat_argv): Change type to char **. (gnat_init_options): Adjust accordingly. * gcc-interface/trans.c (gigi): Set not_handled_by_others_name_id and use it to set not_handled_by_others_decl. (Exception_Handler_to_gnu_fe_sjlj): Fix indentation. --- gcc/ada/gcc-interface/decl.c | 34 +++++++++------------------------- gcc/ada/gcc-interface/gigi.h | 7 ++++--- gcc/ada/gcc-interface/misc.c | 4 ++-- gcc/ada/gcc-interface/trans.c | 24 +++++++++++------------- 4 files changed, 26 insertions(+), 43 deletions(-) diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index b4c4653052ca..232b552a60ca 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -736,16 +736,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if (foreign && Is_Descendant_Of_Address (Underlying_Type (gnat_type))) gnu_type = ptr_type_node; else - { - gnu_type = gnat_to_gnu_type (gnat_type); - - /* If this is a standard exception definition, use the standard - exception type. This is necessary to make sure that imported - and exported views of exceptions are merged in LTO mode. */ - if (TREE_CODE (TYPE_NAME (gnu_type)) == TYPE_DECL - && DECL_NAME (TYPE_NAME (gnu_type)) == exception_data_name_id) - gnu_type = except_type_node; - } + gnu_type = gnat_to_gnu_type (gnat_type); /* For a debug renaming declaration, build a debug-only entity. */ if (Present (Debug_Renaming_Link (gnat_entity))) @@ -3404,21 +3395,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* Fill in locations of fields. */ annotate_rep (gnat_entity, gnu_type); - - /* If this is a record type associated with an exception definition, - equate its fields to those of the standard exception type. This - will make it possible to convert between them. */ - if (gnu_entity_name == exception_data_name_id) - { - tree gnu_std_field; - for (gnu_field = TYPE_FIELDS (gnu_type), - gnu_std_field = TYPE_FIELDS (except_type_node); - gnu_field; - gnu_field = DECL_CHAIN (gnu_field), - gnu_std_field = DECL_CHAIN (gnu_std_field)) - SET_DECL_ORIGINAL_FIELD_TO_FIELD (gnu_field, gnu_std_field); - gcc_assert (!gnu_std_field); - } } break; @@ -7126,6 +7102,14 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, tree gnu_field, gnu_size, gnu_pos; bool is_bitfield; + /* Force the type of the Not_Handled_By_Others field to be that of the + field in struct Exception_Data declared in raise.h instead of using + the declared boolean type. We need to do that because there is no + easy way to make use of a C compatible boolean type for the latter. */ + if (gnu_field_id == not_handled_by_others_name_id + && gnu_field_type == boolean_type_node) + gnu_field_type = char_type_node; + /* The qualifier to be used in messages. */ if (is_aliased) field_s = "aliased&"; diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 807f50d1a9a3..49b85a4b161f 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -396,8 +396,8 @@ enum standard_datatypes /* Identifier for the name of the _Parent field in tagged record types. */ ADT_parent_name_id, - /* Identifier for the name of the Exception_Data type. */ - ADT_exception_data_name_id, + /* Identifier for the name of the Not_Handled_By_Others field. */ + ADT_not_handled_by_others_name_id, /* Types and decls used by the SJLJ exception mechanism. */ ADT_jmpbuf_type, @@ -467,7 +467,8 @@ extern GTY(()) tree gnat_raise_decls_ext[(int) LAST_REASON_CODE + 1]; #define mulv64_decl gnat_std_decls[(int) ADT_mulv64_decl] #define mulv128_decl gnat_std_decls[(int) ADT_mulv128_decl] #define parent_name_id gnat_std_decls[(int) ADT_parent_name_id] -#define exception_data_name_id gnat_std_decls[(int) ADT_exception_data_name_id] +#define not_handled_by_others_name_id \ + gnat_std_decls[(int) ADT_not_handled_by_others_name_id] #define jmpbuf_type gnat_std_decls[(int) ADT_jmpbuf_type] #define jmpbuf_ptr_type gnat_std_decls[(int) ADT_jmpbuf_ptr_type] #define get_jmpbuf_decl gnat_std_decls[(int) ADT_get_jmpbuf_decl] diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index d76b238221fc..f302cf0a6f02 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -63,7 +63,7 @@ const char **save_argv; /* GNAT argc and argv generated by the binder for all Ada programs. */ extern int gnat_argc; -extern const char **gnat_argv; +extern char **gnat_argv; /* Ada code requires variables for these settings rather than elements of the global_options structure because they are imported. */ @@ -241,7 +241,7 @@ gnat_init_options (unsigned int decoded_options_count, save_argv[save_argc] = NULL; /* Pass just the name of the command through the regular channel. */ - gnat_argv = (const char **) xmalloc (sizeof (char *)); + gnat_argv = (char **) xmalloc (sizeof (char *)); gnat_argv[0] = xstrdup (save_argv[0]); gnat_argc = 1; } diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 2a85cdefc0a9..9aeaf0381181 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -461,13 +461,20 @@ gigi (Node_Id gnat_root, /* Name of the _Parent field in tagged record types. */ parent_name_id = get_identifier (Get_Name_String (Name_uParent)); - /* Name of the Exception_Data type defined in System.Standard_Library. */ - exception_data_name_id - = get_identifier ("system__standard_library__exception_data"); + /* Name of the Not_Handled_By_Others field in exception record types. */ + not_handled_by_others_name_id = get_identifier ("not_handled_by_others"); /* Make the types and functions used for exception processing. */ except_type_node = gnat_to_gnu_type (Base_Type (standard_exception_type)); + for (t = TYPE_FIELDS (except_type_node); t; t = DECL_CHAIN (t)) + if (DECL_NAME (t) == not_handled_by_others_name_id) + { + not_handled_by_others_decl = t; + break; + } + gcc_assert (DECL_P (not_handled_by_others_decl)); + jmpbuf_type = build_array_type (gnat_type_for_mode (Pmode, 0), build_index_type (size_int (5))); @@ -495,15 +502,6 @@ gigi (Node_Id gnat_root, NULL_TREE), NULL_TREE, is_default, true, true, true, false, false, NULL, Empty); - not_handled_by_others_decl = get_identifier ("not_handled_by_others"); - for (t = TYPE_FIELDS (except_type_node); t; t = DECL_CHAIN (t)) - if (DECL_NAME (t) == not_handled_by_others_decl) - { - not_handled_by_others_decl = t; - break; - } - gcc_assert (DECL_P (not_handled_by_others_decl)); - /* setjmp returns an integer and has one operand, which is a pointer to a jmpbuf. */ setjmp_decl @@ -5596,7 +5594,7 @@ Exception_Handler_to_gnu_fe_sjlj (Node_Id gnat_node) gnu_except_ptr_stack->last (), convert (TREE_TYPE (gnu_except_ptr_stack->last ()), build_unary_op (ADDR_EXPR, NULL_TREE, gnu_expr))); -} + } else gcc_unreachable ();