Skip to content

Commit 17ba0ad

Browse files
Eric Botcazoupmderodat
authored andcommitted
[Ada] Fix type mismatch warnings during LTO bootstrap gcc-mirror#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) <E_Exception>: Remove old kludge for exceptions. <E_Record_Type>: 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.
1 parent d40dc31 commit 17ba0ad

File tree

4 files changed

+26
-43
lines changed

4 files changed

+26
-43
lines changed

gcc/ada/gcc-interface/decl.c

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -736,16 +736,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
736736
if (foreign && Is_Descendant_Of_Address (Underlying_Type (gnat_type)))
737737
gnu_type = ptr_type_node;
738738
else
739-
{
740-
gnu_type = gnat_to_gnu_type (gnat_type);
741-
742-
/* If this is a standard exception definition, use the standard
743-
exception type. This is necessary to make sure that imported
744-
and exported views of exceptions are merged in LTO mode. */
745-
if (TREE_CODE (TYPE_NAME (gnu_type)) == TYPE_DECL
746-
&& DECL_NAME (TYPE_NAME (gnu_type)) == exception_data_name_id)
747-
gnu_type = except_type_node;
748-
}
739+
gnu_type = gnat_to_gnu_type (gnat_type);
749740

750741
/* For a debug renaming declaration, build a debug-only entity. */
751742
if (Present (Debug_Renaming_Link (gnat_entity)))
@@ -3404,21 +3395,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
34043395

34053396
/* Fill in locations of fields. */
34063397
annotate_rep (gnat_entity, gnu_type);
3407-
3408-
/* If this is a record type associated with an exception definition,
3409-
equate its fields to those of the standard exception type. This
3410-
will make it possible to convert between them. */
3411-
if (gnu_entity_name == exception_data_name_id)
3412-
{
3413-
tree gnu_std_field;
3414-
for (gnu_field = TYPE_FIELDS (gnu_type),
3415-
gnu_std_field = TYPE_FIELDS (except_type_node);
3416-
gnu_field;
3417-
gnu_field = DECL_CHAIN (gnu_field),
3418-
gnu_std_field = DECL_CHAIN (gnu_std_field))
3419-
SET_DECL_ORIGINAL_FIELD_TO_FIELD (gnu_field, gnu_std_field);
3420-
gcc_assert (!gnu_std_field);
3421-
}
34223398
}
34233399
break;
34243400

@@ -7126,6 +7102,14 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
71267102
tree gnu_field, gnu_size, gnu_pos;
71277103
bool is_bitfield;
71287104

7105+
/* Force the type of the Not_Handled_By_Others field to be that of the
7106+
field in struct Exception_Data declared in raise.h instead of using
7107+
the declared boolean type. We need to do that because there is no
7108+
easy way to make use of a C compatible boolean type for the latter. */
7109+
if (gnu_field_id == not_handled_by_others_name_id
7110+
&& gnu_field_type == boolean_type_node)
7111+
gnu_field_type = char_type_node;
7112+
71297113
/* The qualifier to be used in messages. */
71307114
if (is_aliased)
71317115
field_s = "aliased&";

gcc/ada/gcc-interface/gigi.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ enum standard_datatypes
396396
/* Identifier for the name of the _Parent field in tagged record types. */
397397
ADT_parent_name_id,
398398

399-
/* Identifier for the name of the Exception_Data type. */
400-
ADT_exception_data_name_id,
399+
/* Identifier for the name of the Not_Handled_By_Others field. */
400+
ADT_not_handled_by_others_name_id,
401401

402402
/* Types and decls used by the SJLJ exception mechanism. */
403403
ADT_jmpbuf_type,
@@ -467,7 +467,8 @@ extern GTY(()) tree gnat_raise_decls_ext[(int) LAST_REASON_CODE + 1];
467467
#define mulv64_decl gnat_std_decls[(int) ADT_mulv64_decl]
468468
#define mulv128_decl gnat_std_decls[(int) ADT_mulv128_decl]
469469
#define parent_name_id gnat_std_decls[(int) ADT_parent_name_id]
470-
#define exception_data_name_id gnat_std_decls[(int) ADT_exception_data_name_id]
470+
#define not_handled_by_others_name_id \
471+
gnat_std_decls[(int) ADT_not_handled_by_others_name_id]
471472
#define jmpbuf_type gnat_std_decls[(int) ADT_jmpbuf_type]
472473
#define jmpbuf_ptr_type gnat_std_decls[(int) ADT_jmpbuf_ptr_type]
473474
#define get_jmpbuf_decl gnat_std_decls[(int) ADT_get_jmpbuf_decl]

gcc/ada/gcc-interface/misc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const char **save_argv;
6363

6464
/* GNAT argc and argv generated by the binder for all Ada programs. */
6565
extern int gnat_argc;
66-
extern const char **gnat_argv;
66+
extern char **gnat_argv;
6767

6868
/* Ada code requires variables for these settings rather than elements
6969
of the global_options structure because they are imported. */
@@ -241,7 +241,7 @@ gnat_init_options (unsigned int decoded_options_count,
241241
save_argv[save_argc] = NULL;
242242

243243
/* Pass just the name of the command through the regular channel. */
244-
gnat_argv = (const char **) xmalloc (sizeof (char *));
244+
gnat_argv = (char **) xmalloc (sizeof (char *));
245245
gnat_argv[0] = xstrdup (save_argv[0]);
246246
gnat_argc = 1;
247247
}

gcc/ada/gcc-interface/trans.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,20 @@ gigi (Node_Id gnat_root,
461461
/* Name of the _Parent field in tagged record types. */
462462
parent_name_id = get_identifier (Get_Name_String (Name_uParent));
463463

464-
/* Name of the Exception_Data type defined in System.Standard_Library. */
465-
exception_data_name_id
466-
= get_identifier ("system__standard_library__exception_data");
464+
/* Name of the Not_Handled_By_Others field in exception record types. */
465+
not_handled_by_others_name_id = get_identifier ("not_handled_by_others");
467466

468467
/* Make the types and functions used for exception processing. */
469468
except_type_node = gnat_to_gnu_type (Base_Type (standard_exception_type));
470469

470+
for (t = TYPE_FIELDS (except_type_node); t; t = DECL_CHAIN (t))
471+
if (DECL_NAME (t) == not_handled_by_others_name_id)
472+
{
473+
not_handled_by_others_decl = t;
474+
break;
475+
}
476+
gcc_assert (DECL_P (not_handled_by_others_decl));
477+
471478
jmpbuf_type
472479
= build_array_type (gnat_type_for_mode (Pmode, 0),
473480
build_index_type (size_int (5)));
@@ -495,15 +502,6 @@ gigi (Node_Id gnat_root,
495502
NULL_TREE),
496503
NULL_TREE, is_default, true, true, true, false, false, NULL, Empty);
497504

498-
not_handled_by_others_decl = get_identifier ("not_handled_by_others");
499-
for (t = TYPE_FIELDS (except_type_node); t; t = DECL_CHAIN (t))
500-
if (DECL_NAME (t) == not_handled_by_others_decl)
501-
{
502-
not_handled_by_others_decl = t;
503-
break;
504-
}
505-
gcc_assert (DECL_P (not_handled_by_others_decl));
506-
507505
/* setjmp returns an integer and has one operand, which is a pointer to
508506
a jmpbuf. */
509507
setjmp_decl
@@ -5596,7 +5594,7 @@ Exception_Handler_to_gnu_fe_sjlj (Node_Id gnat_node)
55965594
gnu_except_ptr_stack->last (),
55975595
convert (TREE_TYPE (gnu_except_ptr_stack->last ()),
55985596
build_unary_op (ADDR_EXPR, NULL_TREE, gnu_expr)));
5599-
}
5597+
}
56005598
else
56015599
gcc_unreachable ();
56025600

0 commit comments

Comments
 (0)