ada: Make internal_error_function more robust
[official-gcc.git] / gcc / ada / gcc-interface / misc.cc
blob30319ae58b1b33228086fea5c7ea4f76207ba4b9
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * M I S C *
6 * *
7 * C Implementation File *
8 * *
9 * Copyright (C) 1992-2023, Free Software Foundation, Inc. *
10 * *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 3, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
17 * for more details. You should have received a copy of the GNU General *
18 * Public License distributed with GNAT; see file COPYING3. If not see *
19 * <http://www.gnu.org/licenses/>. *
20 * *
21 * GNAT was originally developed by the GNAT team at New York University. *
22 * Extensive contributions were provided by Ada Core Technologies Inc. *
23 * *
24 ****************************************************************************/
26 #include "config.h"
27 #include "system.h"
28 #include "coretypes.h"
29 #include "target.h"
30 #include "tree.h"
31 #include "diagnostic.h"
32 #include "opts.h"
33 #include "alias.h"
34 #include "fold-const.h"
35 #include "stor-layout.h"
36 #include "print-tree.h"
37 #include "toplev.h"
38 #include "tree-pass.h"
39 #include "langhooks.h"
40 #include "langhooks-def.h"
41 #include "plugin.h"
42 #include "calls.h" /* For pass_by_reference. */
43 #include "dwarf2out.h"
45 #include "ada.h"
46 #include "adadecode.h"
47 #include "types.h"
48 #include "atree.h"
49 #include "namet.h"
50 #include "nlists.h"
51 #include "snames.h"
52 #include "uintp.h"
53 #include "fe.h"
54 #include "sinfo.h"
55 #include "einfo.h"
56 #include "ada-tree.h"
57 #include "gigi.h"
59 /* Command-line argc and argv. These variables are global since they are
60 imported in back_end.adb. */
61 unsigned int save_argc;
62 const char **save_argv;
64 /* GNAT argc and argv generated by the binder for all Ada programs. */
65 extern int gnat_argc;
66 extern char **gnat_argv;
68 /* Ada code requires variables for these settings rather than elements
69 of the global_options structure because they are imported. */
70 #undef gnat_encodings
71 enum dwarf_gnat_encodings gnat_encodings = DWARF_GNAT_ENCODINGS_DEFAULT;
73 #undef optimize
74 int optimize;
76 #undef optimize_size
77 int optimize_size;
79 #undef flag_short_enums
80 int flag_short_enums;
82 #undef flag_stack_check
83 enum stack_check_type flag_stack_check = NO_STACK_CHECK;
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
89 /* Declare functions we use as part of startup. */
90 extern void __gnat_initialize (void *);
91 extern void __gnat_install_SEH_handler (void *);
92 extern void adainit (void);
93 extern void _ada_gnat1drv (void);
95 #ifdef __cplusplus
97 #endif
99 /* The parser for the language. For us, we process the GNAT tree. */
101 static void
102 gnat_parse_file (void)
104 int seh[2];
106 /* Call the target specific initializations. */
107 __gnat_initialize (NULL);
109 /* ??? Call the SEH initialization routine. This is to workaround
110 a bootstrap path problem. The call below should be removed at some
111 point and the SEH pointer passed to __gnat_initialize above. */
112 __gnat_install_SEH_handler ((void *)seh);
114 /* Call the front-end elaboration procedures. */
115 adainit ();
117 /* Call the front end. */
118 _ada_gnat1drv ();
120 /* Write the global declarations. */
121 gnat_write_global_declarations ();
124 /* Return language mask for option processing. */
126 static unsigned int
127 gnat_option_lang_mask (void)
129 return CL_Ada;
132 /* Decode all the language specific options that cannot be decoded by GCC.
133 The option decoding phase of GCC calls this routine on the flags that
134 are marked as Ada-specific. Return true on success or false on failure. */
136 static bool
137 gnat_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
138 int kind, location_t loc,
139 const struct cl_option_handlers *handlers)
141 enum opt_code code = (enum opt_code) scode;
143 switch (code)
145 case OPT_Wall:
146 handle_generated_option (&global_options, &global_options_set,
147 OPT_Wunused, NULL, value,
148 gnat_option_lang_mask (), kind, loc,
149 handlers, true, global_dc);
150 warn_uninitialized = value;
151 warn_maybe_uninitialized = value;
152 break;
154 case OPT_gant:
155 warning (0, "%<-gnat%> misspelled as %<-gant%>");
157 /* ... fall through ... */
159 case OPT_gnat:
160 case OPT_gnatO:
161 case OPT_fRTS_:
162 case OPT_I:
163 case OPT_fdump_scos:
164 case OPT_nostdinc:
165 case OPT_nostdlib:
166 /* These are handled by the front-end. */
167 break;
169 case OPT_fshort_enums:
170 case OPT_fsigned_char:
171 case OPT_funsigned_char:
172 /* These are handled by the middle-end. */
173 break;
175 case OPT_fbuiltin_printf:
176 /* This is ignored in Ada but needs to be accepted so it can be
177 defaulted. */
178 break;
180 default:
181 gcc_unreachable ();
184 Ada_handle_option_auto (&global_options, &global_options_set,
185 scode, arg, value,
186 gnat_option_lang_mask (), kind, loc,
187 handlers, global_dc);
188 return true;
191 /* Initialize options structure OPTS. */
193 static void
194 gnat_init_options_struct (struct gcc_options *opts)
196 /* Uninitialized really means uninitialized in Ada. */
197 opts->x_flag_zero_initialized_in_bss = 0;
199 /* We don't care about errno in Ada and it causes __builtin_sqrt to
200 call the libm function rather than do it inline. */
201 opts->x_flag_errno_math = 0;
202 opts->frontend_set_flag_errno_math = true;
205 /* Initialize for option processing. */
207 static void
208 gnat_init_options (unsigned int decoded_options_count,
209 struct cl_decoded_option *decoded_options)
211 /* Reconstruct an argv array for use of back_end.adb.
213 ??? back_end.adb should not rely on this; instead, it should work with
214 decoded options without such reparsing, to ensure consistency in how
215 options are decoded. */
216 save_argv = XNEWVEC (const char *, 2 * decoded_options_count + 1);
217 save_argc = 0;
218 for (unsigned int i = 0; i < decoded_options_count; i++)
220 size_t num_elements = decoded_options[i].canonical_option_num_elements;
222 if (decoded_options[i].errors
223 || decoded_options[i].opt_index == OPT_SPECIAL_unknown
224 || num_elements == 0)
225 continue;
227 /* Deal with -I- specially since it must be a single switch. */
228 if (decoded_options[i].opt_index == OPT_I
229 && num_elements == 2
230 && decoded_options[i].canonical_option[1][0] == '-'
231 && decoded_options[i].canonical_option[1][1] == '\0')
232 save_argv[save_argc++] = "-I-";
233 else
235 gcc_assert (num_elements >= 1 && num_elements <= 2);
236 save_argv[save_argc++] = decoded_options[i].canonical_option[0];
237 if (num_elements >= 2)
238 save_argv[save_argc++] = decoded_options[i].canonical_option[1];
241 save_argv[save_argc] = NULL;
243 /* Pass just the name of the command through the regular channel. */
244 gnat_argv = (char **) xmalloc (sizeof (char *));
245 gnat_argv[0] = xstrdup (save_argv[0]);
246 gnat_argc = 1;
249 /* Settings adjustments after switches processing by the back-end.
250 Note that the front-end switches processing (Scan_Compiler_Arguments)
251 has not been done yet at this point! */
253 static bool
254 gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
256 /* Excess precision other than "fast" requires front-end support. */
257 if (flag_excess_precision == EXCESS_PRECISION_STANDARD)
258 sorry ("%<-fexcess-precision=standard%> for Ada");
259 else if (flag_excess_precision == EXCESS_PRECISION_FLOAT16)
260 sorry ("%<-fexcess-precision=16%> for Ada");
262 flag_excess_precision = EXCESS_PRECISION_FAST;
264 /* No psABI change warnings for Ada. */
265 warn_psabi = 0;
267 /* No return type warnings for Ada. */
268 warn_return_type = 0;
270 /* No caret by default for Ada. */
271 if (!OPTION_SET_P (flag_diagnostics_show_caret))
272 global_dc->show_caret = false;
274 /* Copy global settings to local versions. */
275 gnat_encodings = global_options.x_gnat_encodings;
276 optimize = global_options.x_optimize;
277 optimize_size = global_options.x_optimize_size;
278 flag_stack_check = global_options.x_flag_stack_check;
279 flag_short_enums = global_options.x_flag_short_enums;
281 /* Unfortunately the post_options hook is called before the value of
282 flag_short_enums is autodetected, if need be. Mimic the process
283 for our private flag_short_enums. */
284 if (flag_short_enums == 2)
285 flag_short_enums = targetm.default_short_enums ();
287 return false;
290 /* Here is the function to handle the compiler error processing in GCC. */
292 static void
293 internal_error_function (diagnostic_context *context, const char *msgid,
294 va_list *ap)
296 text_info tinfo;
297 char *buffer, *p, *loc;
298 String_Template temp, temp_loc;
299 String_Pointer sp, sp_loc;
300 expanded_location xloc;
302 /* Warn if plugins present. */
303 warn_if_plugins ();
305 /* Dump the representation of the function. */
306 emergency_dump_function ();
308 /* Reset the pretty-printer. */
309 pp_clear_output_area (context->printer);
311 /* Format the message into the pretty-printer. */
312 tinfo.format_spec = msgid;
313 tinfo.args_ptr = ap;
314 tinfo.err_no = errno;
315 pp_format_verbatim (context->printer, &tinfo);
317 /* Extract a (writable) pointer to the formatted text. */
318 buffer = xstrdup (pp_formatted_text (context->printer));
320 /* Go up to the first newline. */
321 for (p = buffer; *p; p++)
322 if (*p == '\n')
324 *p = '\0';
325 break;
328 temp.Low_Bound = 1;
329 temp.High_Bound = p - buffer;
330 sp.Bounds = &temp;
331 sp.Array = buffer;
333 if (input_location == UNKNOWN_LOCATION)
335 loc = NULL;
336 temp_loc.Low_Bound = 1;
337 temp_loc.High_Bound = 0;
339 else
341 xloc = expand_location (input_location);
342 if (context->show_column && xloc.column != 0)
343 loc = xasprintf ("%s:%d:%d", xloc.file, xloc.line, xloc.column);
344 else
345 loc = xasprintf ("%s:%d", xloc.file, xloc.line);
346 temp_loc.Low_Bound = 1;
347 temp_loc.High_Bound = strlen (loc);
350 sp_loc.Bounds = &temp_loc;
351 sp_loc.Array = loc;
353 Compiler_Abort (sp, sp_loc, true);
356 /* Perform all the initialization steps that are language-specific. */
358 static bool
359 gnat_init (void)
361 /* Do little here, most of the standard declarations are set up after the
362 front-end has been run. Use the same `char' as C for Interfaces.C. */
363 build_common_tree_nodes (flag_signed_char);
365 /* In Ada, we use an unsigned 8-bit type for the default boolean type. */
366 boolean_type_node = make_unsigned_type (8);
367 TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
368 SET_TYPE_RM_MAX_VALUE (boolean_type_node,
369 build_int_cst (boolean_type_node, 1));
370 SET_TYPE_RM_SIZE (boolean_type_node, bitsize_int (1));
371 boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
372 boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
374 sbitsize_one_node = sbitsize_int (1);
375 sbitsize_unit_node = sbitsize_int (BITS_PER_UNIT);
377 /* In Ada, we do not use location ranges. */
378 line_table->default_range_bits = 0;
380 /* Register our internal error function. */
381 global_dc->internal_error = &internal_error_function;
383 return true;
386 /* Initialize the GCC support for exception handling. */
388 void
389 gnat_init_gcc_eh (void)
391 /* We shouldn't do anything if the No_Exceptions_Handler pragma is set,
392 though. This could for instance lead to the emission of tables with
393 references to symbols (such as the Ada eh personality routine) within
394 libraries we won't link against. */
395 if (No_Exception_Handlers_Set ())
396 return;
398 /* Tell GCC we are handling cleanup actions through exception propagation.
399 This opens possibilities that we don't take advantage of yet, but is
400 nonetheless necessary to ensure that fixup code gets assigned to the
401 right exception regions. */
402 using_eh_for_cleanups ();
404 /* Turn on -fexceptions, -fnon-call-exceptions and -fdelete-dead-exceptions.
405 The first one activates the support for exceptions in the compiler.
406 The second one is useful for two reasons: 1/ we map some asynchronous
407 signals like SEGV to exceptions, so we need to ensure that the insns
408 which can lead to such signals are correctly attached to the exception
409 region they pertain to, 2/ some calls to pure subprograms are handled as
410 libcall blocks and then marked as "cannot trap" if the flag is not set
411 (see emit_libcall_block). We should not let this be since it is possible
412 for such calls to actually raise in Ada.
413 The third one is an optimization that makes it possible to delete dead
414 instructions that may throw exceptions, most notably loads and stores,
415 as permitted in Ada.
416 Turn off -faggressive-loop-optimizations because it may optimize away
417 out-of-bound array accesses that we want to be able to catch.
418 If checks are disabled, we use the same settings as the C++ compiler,
419 except for the runtime on platforms where S'Machine_Overflow is true
420 because the runtime depends on FP (hardware) checks being properly
421 handled despite being compiled in -gnatp mode. */
422 flag_exceptions = 1;
423 flag_delete_dead_exceptions = 1;
424 if (Suppress_Checks)
426 if (!OPTION_SET_P (flag_non_call_exceptions))
427 flag_non_call_exceptions = Machine_Overflows_On_Target && GNAT_Mode;
429 else
431 if (!OPTION_SET_P (flag_non_call_exceptions))
432 flag_non_call_exceptions = 1;
433 flag_aggressive_loop_optimizations = 0;
434 warn_aggressive_loop_optimizations = 0;
437 init_eh ();
440 /* Initialize the GCC support for floating-point operations. */
442 void
443 gnat_init_gcc_fp (void)
445 /* Disable FP optimizations that ignore the signedness of zero if
446 S'Signed_Zeros is true, but don't override the user if not. */
447 if (Signed_Zeros_On_Target)
448 flag_signed_zeros = 1;
449 else if (!OPTION_SET_P (flag_signed_zeros))
450 flag_signed_zeros = 0;
452 /* Assume that FP operations can trap if S'Machine_Overflow is true,
453 but don't override the user if not. */
454 if (Machine_Overflows_On_Target)
455 flag_trapping_math = 1;
456 else if (!OPTION_SET_P (flag_trapping_math))
457 flag_trapping_math = 0;
460 /* Print language-specific items in declaration NODE. */
462 static void
463 gnat_print_decl (FILE *file, tree node, int indent)
465 switch (TREE_CODE (node))
467 case CONST_DECL:
468 print_node (file, "corresponding var",
469 DECL_CONST_CORRESPONDING_VAR (node), indent + 4);
470 break;
472 case FIELD_DECL:
473 print_node (file, "original field", DECL_ORIGINAL_FIELD (node),
474 indent + 4);
475 break;
477 case VAR_DECL:
478 if (DECL_LOOP_PARM_P (node))
479 print_node (file, "induction var", DECL_INDUCTION_VAR (node),
480 indent + 4);
481 break;
483 default:
484 break;
488 /* Print language-specific items in type NODE. */
490 static void
491 gnat_print_type (FILE *file, tree node, int indent)
493 switch (TREE_CODE (node))
495 case FUNCTION_TYPE:
496 case METHOD_TYPE:
497 print_node (file, "ci/co list", TYPE_CI_CO_LIST (node), indent + 4);
498 break;
500 case INTEGER_TYPE:
501 if (TYPE_MODULAR_P (node))
502 print_node_brief (file, "modulus", TYPE_MODULUS (node), indent + 4);
503 else if (TYPE_FIXED_POINT_P (node))
504 print_node (file, "scale factor", TYPE_SCALE_FACTOR (node),
505 indent + 4);
506 else if (TYPE_HAS_ACTUAL_BOUNDS_P (node))
507 print_node (file, "actual bounds", TYPE_ACTUAL_BOUNDS (node),
508 indent + 4);
509 else
510 print_node (file, "index type", TYPE_INDEX_TYPE (node), indent + 4);
512 /* ... fall through ... */
514 case ENUMERAL_TYPE:
515 case BOOLEAN_TYPE:
516 print_node_brief (file, "RM size", TYPE_RM_SIZE (node), indent + 4);
518 /* ... fall through ... */
520 case REAL_TYPE:
521 print_node_brief (file, "RM min", TYPE_RM_MIN_VALUE (node), indent + 4);
522 print_node_brief (file, "RM max", TYPE_RM_MAX_VALUE (node), indent + 4);
523 break;
525 case ARRAY_TYPE:
526 print_node (file,"actual bounds", TYPE_ACTUAL_BOUNDS (node), indent + 4);
527 break;
529 case VECTOR_TYPE:
530 print_node (file,"representative array",
531 TYPE_REPRESENTATIVE_ARRAY (node), indent + 4);
532 break;
534 case RECORD_TYPE:
535 if (TYPE_FAT_POINTER_P (node) || TYPE_CONTAINS_TEMPLATE_P (node))
536 print_node (file, "unconstrained array",
537 TYPE_UNCONSTRAINED_ARRAY (node), indent + 4);
538 else
539 print_node (file, "Ada size", TYPE_ADA_SIZE (node), indent + 4);
540 break;
542 case UNION_TYPE:
543 case QUAL_UNION_TYPE:
544 print_node (file, "Ada size", TYPE_ADA_SIZE (node), indent + 4);
545 break;
547 default:
548 break;
551 if (TYPE_CAN_HAVE_DEBUG_TYPE_P (node) && TYPE_DEBUG_TYPE (node))
552 print_node_brief (file, "debug type", TYPE_DEBUG_TYPE (node), indent + 4);
554 if (TYPE_IMPL_PACKED_ARRAY_P (node) && TYPE_ORIGINAL_PACKED_ARRAY (node))
555 print_node_brief (file, "original packed array",
556 TYPE_ORIGINAL_PACKED_ARRAY (node), indent + 4);
559 /* Return the name to be printed for DECL. */
561 static const char *
562 gnat_printable_name (tree decl, int verbosity)
564 const char *coded_name = IDENTIFIER_POINTER (DECL_NAME (decl));
565 char *ada_name = (char *) ggc_alloc_atomic (strlen (coded_name) * 2 + 60);
567 __gnat_decode (coded_name, ada_name, 0);
569 if (verbosity == 2 && !DECL_IS_UNDECLARED_BUILTIN (decl))
571 Set_Identifier_Casing (ada_name, DECL_SOURCE_FILE (decl));
572 return ggc_strdup (Name_Buffer);
575 return ada_name;
578 /* Return the name to be used in DWARF debug info for DECL. */
580 static const char *
581 gnat_dwarf_name (tree decl, int verbosity ATTRIBUTE_UNUSED)
583 gcc_assert (DECL_P (decl));
584 return (const char *) IDENTIFIER_POINTER (DECL_NAME (decl));
587 /* Return the descriptive type associated with TYPE, if any. */
589 static tree
590 gnat_descriptive_type (const_tree type)
592 if (TYPE_STUB_DECL (type))
593 return DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type));
594 else
595 return NULL_TREE;
598 /* Return the underlying base type of an enumeration type. */
600 static tree
601 gnat_enum_underlying_base_type (const_tree)
603 /* Enumeration types are base types in Ada. */
604 return void_type_node;
607 /* Return the type to be used for debugging information instead of TYPE or
608 NULL_TREE if TYPE is fine. */
610 static tree
611 gnat_get_debug_type (const_tree type)
613 if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type))
614 return TYPE_DEBUG_TYPE (type);
615 else
616 return NULL_TREE;
619 /* Provide information in INFO for debugging output about the TYPE fixed-point
620 type. Return whether TYPE is handled. */
622 static bool
623 gnat_get_fixed_point_type_info (const_tree type,
624 struct fixed_point_type_info *info)
626 tree scale_factor;
628 /* Do nothing if the GNAT encodings are used. */
629 if (!TYPE_IS_FIXED_POINT_P (type)
630 || gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
631 return false;
633 scale_factor = TYPE_SCALE_FACTOR (type);
635 /* We expect here only a finite set of pattern. See fixed-point types
636 handling in gnat_to_gnu_entity. */
638 if (TREE_CODE (scale_factor) == RDIV_EXPR)
640 tree num = TREE_OPERAND (scale_factor, 0);
641 tree den = TREE_OPERAND (scale_factor, 1);
643 /* See if we have a binary or decimal scale. */
644 if (TREE_CODE (den) == POWER_EXPR)
646 tree base = TREE_OPERAND (den, 0);
647 tree exponent = TREE_OPERAND (den, 1);
649 /* We expect the scale factor to be 1 / 2 ** N or 1 / 10 ** N. */
650 gcc_assert (num == integer_one_node
651 && TREE_CODE (base) == INTEGER_CST
652 && TREE_CODE (exponent) == INTEGER_CST);
654 switch (tree_to_shwi (base))
656 case 2:
657 info->scale_factor_kind = fixed_point_scale_factor_binary;
658 info->scale_factor.binary = -tree_to_shwi (exponent);
659 return true;
661 case 10:
662 info->scale_factor_kind = fixed_point_scale_factor_decimal;
663 info->scale_factor.decimal = -tree_to_shwi (exponent);
664 return true;
666 default:
667 gcc_unreachable ();
671 /* If we reach this point, we are handling an arbitrary scale factor. We
672 expect N / D with constant operands. */
673 gcc_assert (TREE_CODE (num) == INTEGER_CST
674 && TREE_CODE (den) == INTEGER_CST);
676 info->scale_factor_kind = fixed_point_scale_factor_arbitrary;
677 info->scale_factor.arbitrary.numerator = num;
678 info->scale_factor.arbitrary.denominator = den;
679 return true;
682 gcc_unreachable ();
685 /* Return true if types T1 and T2 are identical for type hashing purposes.
686 Called only after doing all language independent checks. At present,
687 this is only called when both types are FUNCTION_TYPE or METHOD_TYPE. */
689 static bool
690 gnat_type_hash_eq (const_tree t1, const_tree t2)
692 gcc_assert (FUNC_OR_METHOD_TYPE_P (t1) && TREE_CODE (t1) == TREE_CODE (t2));
693 return fntype_same_flags_p (t1, TYPE_CI_CO_LIST (t2),
694 TYPE_RETURN_BY_DIRECT_REF_P (t2),
695 TREE_ADDRESSABLE (t2));
698 /* Do nothing (return the tree node passed). */
700 static tree
701 gnat_return_tree (tree t)
703 return t;
706 /* Get the alias set corresponding to a type or expression. */
708 static alias_set_type
709 gnat_get_alias_set (tree type)
711 /* If this is a padding type, use the type of the first field. */
712 if (TYPE_IS_PADDING_P (type))
713 return get_alias_set (TREE_TYPE (TYPE_FIELDS (type)));
715 /* If this is an extra subtype, use the base type. */
716 else if (TYPE_IS_EXTRA_SUBTYPE_P (type))
717 return get_alias_set (get_base_type (type));
719 /* If the type is an unconstrained array, use the type of the
720 self-referential array we make. */
721 else if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE)
722 return
723 get_alias_set (TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (type)))));
725 /* If the type can alias any other types, return the alias set 0. */
726 else if (TYPE_P (type)
727 && !TYPE_IS_DUMMY_P (type)
728 && TYPE_UNIVERSAL_ALIASING_P (type))
729 return 0;
731 return -1;
734 /* GNU_TYPE is a type. Return its maximum size in bytes, if known,
735 as a constant when possible. */
737 static tree
738 gnat_type_max_size (const_tree gnu_type)
740 /* First see what we can get from TYPE_SIZE_UNIT, which might not
741 be constant even for simple expressions if it has already been
742 elaborated and possibly replaced by a VAR_DECL. */
743 tree max_size_unit = max_size (TYPE_SIZE_UNIT (gnu_type), true);
745 /* If we don't have a constant, see what we can get from TYPE_ADA_SIZE,
746 which should stay untouched. */
747 if (!tree_fits_uhwi_p (max_size_unit)
748 && RECORD_OR_UNION_TYPE_P (gnu_type)
749 && !TYPE_FAT_POINTER_P (gnu_type)
750 && TYPE_ADA_SIZE (gnu_type))
752 tree max_ada_size = max_size (TYPE_ADA_SIZE (gnu_type), true);
754 /* If we have succeeded in finding a constant, round it up to the
755 type's alignment and return the result in units. */
756 if (tree_fits_uhwi_p (max_ada_size))
757 max_size_unit
758 = size_binop (EXACT_DIV_EXPR,
759 round_up (max_ada_size, TYPE_ALIGN (gnu_type)),
760 bitsize_unit_node);
763 return max_size_unit;
766 static tree get_array_bit_stride (tree);
768 /* Provide information in INFO for debug output about the TYPE array type.
769 Return whether TYPE is handled. */
771 static bool
772 gnat_get_array_descr_info (const_tree const_type,
773 struct array_descr_info *info)
775 tree type = const_cast<tree> (const_type);
776 tree first_dimen, dimen;
777 bool is_packed_array, is_array;
778 int i;
780 /* Temporaries created in the first pass and used in the second one for thin
781 pointers. The first one is an expression that yields the template record
782 from the base address (i.e. the PLACEHOLDER_EXPR). The second one is just
783 a cursor through this record's fields. */
784 tree thinptr_template_expr = NULL_TREE;
785 tree thinptr_bound_field = NULL_TREE;
787 /* If we have an implementation type for a packed array, get the orignial
788 array type. */
789 if (TYPE_IMPL_PACKED_ARRAY_P (type) && TYPE_ORIGINAL_PACKED_ARRAY (type))
791 type = TYPE_ORIGINAL_PACKED_ARRAY (type);
792 is_packed_array = true;
794 else
795 is_packed_array = false;
797 /* First pass: gather all information about this array except everything
798 related to dimensions. */
800 /* Only handle ARRAY_TYPE nodes that come from GNAT. */
801 if (TREE_CODE (type) == ARRAY_TYPE
802 && TYPE_DOMAIN (type)
803 && TYPE_INDEX_TYPE (TYPE_DOMAIN (type)))
805 is_array = true;
806 first_dimen = type;
809 /* As well as array types embedded in a record type with their bounds. */
810 else if (TREE_CODE (type) == RECORD_TYPE
811 && TYPE_CONTAINS_TEMPLATE_P (type)
812 && gnat_encodings != DWARF_GNAT_ENCODINGS_ALL)
814 /* This will be our base object address. Note that we assume that
815 pointers to this will actually point to the array field (thin
816 pointers are shifted). */
817 tree placeholder_expr = build0 (PLACEHOLDER_EXPR, type);
818 tree placeholder_addr
819 = build_unary_op (ADDR_EXPR, NULL_TREE, placeholder_expr);
821 tree bounds_field = TYPE_FIELDS (type);
822 tree bounds_type = TREE_TYPE (bounds_field);
823 tree array_field = DECL_CHAIN (bounds_field);
824 tree array_type = TREE_TYPE (array_field);
826 /* Shift back the address to get the address of the template. */
827 tree shift_amount
828 = fold_build1 (NEGATE_EXPR, sizetype, byte_position (array_field));
829 tree template_addr
830 = build_binary_op (POINTER_PLUS_EXPR, TREE_TYPE (placeholder_addr),
831 placeholder_addr, shift_amount);
832 template_addr
833 = fold_convert (TYPE_POINTER_TO (bounds_type), template_addr);
835 thinptr_template_expr
836 = build_unary_op (INDIRECT_REF, NULL_TREE, template_addr);
837 thinptr_bound_field = TYPE_FIELDS (bounds_type);
839 is_array = false;
840 first_dimen = array_type;
843 else
844 return false;
846 /* Second pass: compute the remaining information: dimensions and
847 corresponding bounds. */
849 /* If this array has fortran convention, it's arranged in column-major
850 order, so our view here has reversed dimensions. */
851 const bool convention_fortran_p = TYPE_CONVENTION_FORTRAN_P (first_dimen);
853 if (TYPE_PACKED (first_dimen))
854 is_packed_array = true;
856 /* ??? For row major ordering, we probably want to emit nothing and
857 instead specify it as the default in Dw_TAG_compile_unit. */
858 info->ordering = (convention_fortran_p
859 ? array_descr_ordering_column_major
860 : array_descr_ordering_row_major);
861 info->rank = NULL_TREE;
863 /* Count the number of dimensions and determine the element type. */
864 i = 1;
865 dimen = TREE_TYPE (first_dimen);
866 while (TREE_CODE (dimen) == ARRAY_TYPE && TYPE_MULTI_ARRAY_P (dimen))
868 i++;
869 dimen = TREE_TYPE (dimen);
871 info->ndimensions = i;
872 info->element_type = dimen;
874 /* Too many dimensions? Give up generating proper description: yield instead
875 nested arrays. Note that in this case, this hook is invoked once on each
876 intermediate array type: be consistent and output nested arrays for all
877 dimensions. */
878 if (info->ndimensions > DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN
879 || TYPE_MULTI_ARRAY_P (first_dimen))
881 info->ndimensions = 1;
882 info->element_type = TREE_TYPE (first_dimen);
885 /* Now iterate over all dimensions in source order and fill the info
886 structure. */
887 for (i = (convention_fortran_p ? info->ndimensions - 1 : 0),
888 dimen = first_dimen;
889 IN_RANGE (i, 0, info->ndimensions - 1);
890 i += (convention_fortran_p ? -1 : 1),
891 dimen = TREE_TYPE (dimen))
893 /* We are interested in the stored bounds for the debug info. */
894 tree index_type = TYPE_INDEX_TYPE (TYPE_DOMAIN (dimen));
896 if (is_array)
898 /* GDB does not handle very well the self-referencial bound
899 expressions we are able to generate here for XUA types (they are
900 used only by XUP encodings) so avoid them in this case. Note that
901 there are two cases where we generate self-referencial bound
902 expressions: arrays that are constrained by record discriminants
903 and XUA types. */
904 if (TYPE_CONTEXT (first_dimen)
905 && TREE_CODE (TYPE_CONTEXT (first_dimen)) != RECORD_TYPE
906 && CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (index_type))
907 && gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
909 info->dimen[i].lower_bound = NULL_TREE;
910 info->dimen[i].upper_bound = NULL_TREE;
912 else
914 info->dimen[i].lower_bound
915 = maybe_character_value (TYPE_MIN_VALUE (index_type));
916 info->dimen[i].upper_bound
917 = maybe_character_value (TYPE_MAX_VALUE (index_type));
921 /* This is a thin pointer. */
922 else
924 info->dimen[i].lower_bound
925 = build_component_ref (thinptr_template_expr, thinptr_bound_field,
926 false);
927 thinptr_bound_field = DECL_CHAIN (thinptr_bound_field);
929 info->dimen[i].upper_bound
930 = build_component_ref (thinptr_template_expr, thinptr_bound_field,
931 false);
932 thinptr_bound_field = DECL_CHAIN (thinptr_bound_field);
935 /* The DWARF back-end will output BOUNDS_TYPE as the base type of
936 the array index, so get to the base type of INDEX_TYPE. */
937 while (TREE_TYPE (index_type))
938 index_type = TREE_TYPE (index_type);
940 info->dimen[i].bounds_type = maybe_debug_type (index_type);
941 info->dimen[i].stride = NULL_TREE;
944 /* These are Fortran-specific fields. They make no sense here. */
945 info->allocated = NULL_TREE;
946 info->associated = NULL_TREE;
947 info->data_location = NULL_TREE;
949 if (gnat_encodings != DWARF_GNAT_ENCODINGS_ALL)
951 /* When arrays contain dynamically-sized elements, we usually wrap them
952 in padding types, or we create constrained types for them. Then, if
953 such types are stripped in the debugging information output, the
954 debugger needs a way to know the size that is reserved for each
955 element. This is why we emit a stride in such situations. */
956 tree source_element_type = info->element_type;
958 while (true)
960 if (TYPE_DEBUG_TYPE (source_element_type))
961 source_element_type = TYPE_DEBUG_TYPE (source_element_type);
962 else if (TYPE_IS_PADDING_P (source_element_type))
963 source_element_type
964 = TREE_TYPE (TYPE_FIELDS (source_element_type));
965 else
966 break;
969 if (TREE_CODE (TYPE_SIZE_UNIT (source_element_type)) != INTEGER_CST)
971 info->stride = TYPE_SIZE_UNIT (info->element_type);
972 info->stride_in_bits = false;
975 /* We need to specify a bit stride when it does not correspond to the
976 natural size of the contained elements. ??? Note that we do not
977 support packed records and nested packed arrays. */
978 else if (is_packed_array)
980 info->stride = get_array_bit_stride (info->element_type);
981 info->stride_in_bits = true;
985 return true;
988 /* Given the component type COMP_TYPE of a packed array, return an expression
989 that computes the bit stride of this packed array. Return NULL_TREE when
990 unsuccessful. */
992 static tree
993 get_array_bit_stride (tree comp_type)
995 struct array_descr_info info;
996 tree stride;
998 /* Simple case: the array contains an integral type: return its RM size. */
999 if (INTEGRAL_TYPE_P (comp_type))
1000 return TYPE_RM_SIZE (comp_type);
1002 /* Likewise for record or union types. */
1003 if (RECORD_OR_UNION_TYPE_P (comp_type) && !TYPE_FAT_POINTER_P (comp_type))
1004 return TYPE_ADA_SIZE (comp_type);
1006 /* The gnat_get_array_descr_info debug hook expects a debug tyoe. */
1007 comp_type = maybe_debug_type (comp_type);
1009 /* Otherwise, see if this is an array we can analyze; if it's not, punt. */
1010 memset (&info, 0, sizeof (info));
1011 if (!gnat_get_array_descr_info (comp_type, &info) || !info.stride)
1012 return NULL_TREE;
1014 /* Otherwise, the array stride is the inner array's stride multiplied by the
1015 number of elements it contains. Note that if the inner array is not
1016 packed, then the stride is "natural" and thus does not deserve an
1017 attribute. */
1018 stride = info.stride;
1019 if (!info.stride_in_bits)
1021 stride = fold_convert (bitsizetype, stride);
1022 stride = build_binary_op (MULT_EXPR, bitsizetype,
1023 stride, build_int_cst (bitsizetype, 8));
1026 for (int i = 0; i < info.ndimensions; ++i)
1028 tree count;
1030 if (!info.dimen[i].lower_bound || !info.dimen[i].upper_bound)
1031 return NULL_TREE;
1033 /* Put in count an expression that computes the length of this
1034 dimension. */
1035 count = build_binary_op (MINUS_EXPR, sbitsizetype,
1036 fold_convert (sbitsizetype,
1037 info.dimen[i].upper_bound),
1038 fold_convert (sbitsizetype,
1039 info.dimen[i].lower_bound)),
1040 count = build_binary_op (PLUS_EXPR, sbitsizetype,
1041 count, build_int_cst (sbitsizetype, 1));
1042 count = build_binary_op (MAX_EXPR, sbitsizetype,
1043 count,
1044 build_int_cst (sbitsizetype, 0));
1045 count = fold_convert (bitsizetype, count);
1046 stride = build_binary_op (MULT_EXPR, bitsizetype, stride, count);
1049 return stride;
1052 /* GNU_TYPE is a subtype of an integral type. Set LOWVAL to the low bound
1053 and HIGHVAL to the high bound, respectively. */
1055 static void
1056 gnat_get_subrange_bounds (const_tree gnu_type, tree *lowval, tree *highval)
1058 *lowval = TYPE_MIN_VALUE (gnu_type);
1059 *highval = TYPE_MAX_VALUE (gnu_type);
1062 /* Return the bias of GNU_TYPE, if any. */
1064 static tree
1065 gnat_get_type_bias (const_tree gnu_type)
1067 if (TREE_CODE (gnu_type) == INTEGER_TYPE
1068 && TYPE_BIASED_REPRESENTATION_P (gnu_type)
1069 && gnat_encodings != DWARF_GNAT_ENCODINGS_ALL)
1070 return TYPE_RM_MIN_VALUE (gnu_type);
1072 return NULL_TREE;
1075 /* GNU_TYPE is the type of a subprogram parameter. Determine if it should be
1076 passed by reference by default. */
1078 bool
1079 default_pass_by_ref (tree gnu_type)
1081 /* We pass aggregates by reference if they are sufficiently large for
1082 their alignment. The ratio is somewhat arbitrary. We also pass by
1083 reference if the target machine would either pass or return by
1084 reference. Strictly speaking, we need only check the return if this
1085 is an In Out parameter, but it's probably best to err on the side of
1086 passing more things by reference. */
1088 if (AGGREGATE_TYPE_P (gnu_type)
1089 && (!valid_constant_size_p (TYPE_SIZE_UNIT (gnu_type))
1090 || compare_tree_int (TYPE_SIZE_UNIT (gnu_type),
1091 TYPE_ALIGN (gnu_type)) > 0))
1092 return true;
1094 if (pass_by_reference (NULL, function_arg_info (gnu_type, /*named=*/true)))
1095 return true;
1097 if (targetm.calls.return_in_memory (gnu_type, NULL_TREE))
1098 return true;
1100 return false;
1103 /* GNU_TYPE is the type of a subprogram parameter. Determine if it must be
1104 passed by reference. */
1106 bool
1107 must_pass_by_ref (tree gnu_type)
1109 /* We pass only unconstrained objects, those required by the language
1110 to be passed by reference, and objects of variable size. The latter
1111 is more efficient, avoids problems with variable size temporaries,
1112 and does not produce compatibility problems with C, since C does
1113 not have such objects. */
1114 return (TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE
1115 || TYPE_IS_BY_REFERENCE_P (gnu_type)
1116 || (TYPE_SIZE_UNIT (gnu_type)
1117 && TREE_CODE (TYPE_SIZE_UNIT (gnu_type)) != INTEGER_CST));
1120 /* This function is called by the front-end to enumerate all the supported
1121 modes for the machine, as well as some predefined C types. F is a function
1122 which is called back with the parameters as listed below, first a string,
1123 then seven ints. The name is any arbitrary null-terminated string and has
1124 no particular significance, except for the case of predefined C types, where
1125 it should be the name of the C type. For integer types, only signed types
1126 should be listed, unsigned versions are assumed. The order of types should
1127 be in order of preference, with the smallest/cheapest types first.
1129 In particular, C predefined types should be listed before other types,
1130 binary floating point types before decimal ones, and narrower/cheaper
1131 type versions before more expensive ones. In type selection the first
1132 matching variant will be used.
1134 NAME pointer to first char of type name
1135 DIGS number of decimal digits for floating-point modes, else 0
1136 COMPLEX_P nonzero is this represents a complex mode
1137 COUNT count of number of items, nonzero for vector mode
1138 FLOAT_REP Float_Rep_Kind for FP, otherwise undefined
1139 PRECISION number of bits used to store data
1140 SIZE number of bits occupied by the mode
1141 ALIGN number of bits to which mode is aligned. */
1143 void
1144 enumerate_modes (void (*f) (const char *, int, int, int, int, int, int, int))
1146 tree const c_types[]
1147 = { float_type_node, double_type_node, long_double_type_node };
1148 const char *const c_names[]
1149 = { "float", "double", "long double" };
1150 int iloop;
1152 /* We are going to compute it below. */
1153 fp_arith_may_widen = false;
1155 for (iloop = 0; iloop < NUM_MACHINE_MODES; iloop++)
1157 machine_mode i = (machine_mode) iloop;
1158 machine_mode inner_mode = i;
1159 bool float_p = false;
1160 bool complex_p = false;
1161 bool vector_p = false;
1162 bool skip_p = false;
1163 int digs = 0;
1164 unsigned int nameloop;
1165 Float_Rep_Kind float_rep = IEEE_Binary; /* Until proven otherwise */
1167 switch (GET_MODE_CLASS (i))
1169 case MODE_INT:
1170 break;
1171 case MODE_FLOAT:
1172 float_p = true;
1173 break;
1174 case MODE_COMPLEX_INT:
1175 complex_p = true;
1176 inner_mode = GET_MODE_INNER (i);
1177 break;
1178 case MODE_COMPLEX_FLOAT:
1179 float_p = true;
1180 complex_p = true;
1181 inner_mode = GET_MODE_INNER (i);
1182 break;
1183 case MODE_VECTOR_INT:
1184 vector_p = true;
1185 inner_mode = GET_MODE_INNER (i);
1186 break;
1187 case MODE_VECTOR_FLOAT:
1188 float_p = true;
1189 vector_p = true;
1190 inner_mode = GET_MODE_INNER (i);
1191 break;
1192 default:
1193 skip_p = true;
1196 if (float_p)
1198 const struct real_format *fmt = REAL_MODE_FORMAT (inner_mode);
1200 /* ??? Cope with the ghost XFmode of the ARM port. */
1201 if (!fmt)
1202 continue;
1204 /* Be conservative and consider that floating-point arithmetics may
1205 use wider intermediate results as soon as there is an extended
1206 Motorola or Intel mode supported by the machine. */
1207 if (fmt == &ieee_extended_motorola_format
1208 || fmt == &ieee_extended_intel_96_format
1209 || fmt == &ieee_extended_intel_96_round_53_format
1210 || fmt == &ieee_extended_intel_128_format)
1212 #ifdef TARGET_FPMATH_DEFAULT
1213 if (TARGET_FPMATH_DEFAULT == FPMATH_387)
1214 #endif
1215 fp_arith_may_widen = true;
1218 if (fmt->b == 2)
1219 digs = (fmt->p - 1) * 1233 / 4096; /* scale by log (2) */
1221 else if (fmt->b == 10)
1222 digs = fmt->p;
1224 else
1225 gcc_unreachable ();
1228 /* First register any C types for this mode that the front end
1229 may need to know about, unless the mode should be skipped. */
1230 if (!skip_p && !vector_p)
1231 for (nameloop = 0; nameloop < ARRAY_SIZE (c_types); nameloop++)
1233 tree type = c_types[nameloop];
1234 const char *name = c_names[nameloop];
1236 if (TYPE_MODE (type) == i)
1238 f (name, digs, complex_p, 0, float_rep, TYPE_PRECISION (type),
1239 TREE_INT_CST_LOW (TYPE_SIZE (type)), TYPE_ALIGN (type));
1240 skip_p = true;
1244 /* If no predefined C types were found, register the mode itself. */
1245 int nunits, precision, bitsize;
1246 if (!skip_p
1247 && GET_MODE_NUNITS (i).is_constant (&nunits)
1248 && GET_MODE_PRECISION (i).is_constant (&precision)
1249 && GET_MODE_BITSIZE (i).is_constant (&bitsize))
1250 f (GET_MODE_NAME (i), digs, complex_p,
1251 vector_p ? nunits : 0, float_rep,
1252 precision, bitsize, GET_MODE_ALIGNMENT (i));
1256 /* Return the size of the FP mode with precision PREC. */
1259 fp_prec_to_size (int prec)
1261 opt_scalar_float_mode opt_mode;
1263 FOR_EACH_MODE_IN_CLASS (opt_mode, MODE_FLOAT)
1265 scalar_float_mode mode = opt_mode.require ();
1266 if (GET_MODE_PRECISION (mode) == prec)
1267 return GET_MODE_BITSIZE (mode);
1270 gcc_unreachable ();
1273 /* Return the precision of the FP mode with size SIZE. */
1276 fp_size_to_prec (int size)
1278 opt_scalar_float_mode opt_mode;
1280 FOR_EACH_MODE_IN_CLASS (opt_mode, MODE_FLOAT)
1282 scalar_mode mode = opt_mode.require ();
1283 if (GET_MODE_BITSIZE (mode) == size)
1284 return GET_MODE_PRECISION (mode);
1287 gcc_unreachable ();
1290 static GTY(()) tree gnat_eh_personality_decl;
1292 /* Return the GNAT personality function decl. */
1294 static tree
1295 gnat_eh_personality (void)
1297 if (!gnat_eh_personality_decl)
1298 gnat_eh_personality_decl = build_personality_function ("gnat");
1299 return gnat_eh_personality_decl;
1302 /* Get a value for the SARIF v2.1.0 "artifact.sourceLanguage" property,
1303 based on the list in SARIF v2.1.0 Appendix J. */
1305 static const char *
1306 gnat_get_sarif_source_language (const char *)
1308 return "ada";
1311 /* Initialize language-specific bits of tree_contains_struct. */
1313 static void
1314 gnat_init_ts (void)
1316 MARK_TS_COMMON (UNCONSTRAINED_ARRAY_TYPE);
1318 MARK_TS_TYPED (UNCONSTRAINED_ARRAY_REF);
1319 MARK_TS_TYPED (LOAD_EXPR);
1320 MARK_TS_TYPED (NULL_EXPR);
1321 MARK_TS_TYPED (PLUS_NOMOD_EXPR);
1322 MARK_TS_TYPED (MINUS_NOMOD_EXPR);
1323 MARK_TS_TYPED (POWER_EXPR);
1324 MARK_TS_TYPED (ATTR_ADDR_EXPR);
1325 MARK_TS_TYPED (STMT_STMT);
1326 MARK_TS_TYPED (LOOP_STMT);
1327 MARK_TS_TYPED (EXIT_STMT);
1330 /* Return the size of a tree with CODE, which is a language-specific tree code
1331 in category tcc_constant, tcc_exceptional or tcc_type. The default expects
1332 never to be called. */
1334 static size_t
1335 gnat_tree_size (enum tree_code code)
1337 gcc_checking_assert (code >= NUM_TREE_CODES);
1338 switch (code)
1340 case UNCONSTRAINED_ARRAY_TYPE:
1341 return sizeof (tree_type_non_common);
1342 default:
1343 gcc_unreachable ();
1347 /* Return the lang specific structure attached to NODE. Allocate it (cleared)
1348 if needed. */
1350 struct lang_type *
1351 get_lang_specific (tree node)
1353 if (!TYPE_LANG_SPECIFIC (node))
1354 TYPE_LANG_SPECIFIC (node) = ggc_cleared_alloc<struct lang_type> ();
1355 return TYPE_LANG_SPECIFIC (node);
1358 /* Definitions for our language-specific hooks. */
1360 #undef LANG_HOOKS_NAME
1361 #define LANG_HOOKS_NAME "GNU Ada"
1362 #undef LANG_HOOKS_IDENTIFIER_SIZE
1363 #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct tree_identifier)
1364 #undef LANG_HOOKS_TREE_SIZE
1365 #define LANG_HOOKS_TREE_SIZE gnat_tree_size
1366 #undef LANG_HOOKS_INIT
1367 #define LANG_HOOKS_INIT gnat_init
1368 #undef LANG_HOOKS_OPTION_LANG_MASK
1369 #define LANG_HOOKS_OPTION_LANG_MASK gnat_option_lang_mask
1370 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
1371 #define LANG_HOOKS_INIT_OPTIONS_STRUCT gnat_init_options_struct
1372 #undef LANG_HOOKS_INIT_OPTIONS
1373 #define LANG_HOOKS_INIT_OPTIONS gnat_init_options
1374 #undef LANG_HOOKS_HANDLE_OPTION
1375 #define LANG_HOOKS_HANDLE_OPTION gnat_handle_option
1376 #undef LANG_HOOKS_POST_OPTIONS
1377 #define LANG_HOOKS_POST_OPTIONS gnat_post_options
1378 #undef LANG_HOOKS_PARSE_FILE
1379 #define LANG_HOOKS_PARSE_FILE gnat_parse_file
1380 #undef LANG_HOOKS_TYPE_HASH_EQ
1381 #define LANG_HOOKS_TYPE_HASH_EQ gnat_type_hash_eq
1382 #undef LANG_HOOKS_GETDECLS
1383 #define LANG_HOOKS_GETDECLS hook_tree_void_null
1384 #undef LANG_HOOKS_PUSHDECL
1385 #define LANG_HOOKS_PUSHDECL gnat_return_tree
1386 #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
1387 #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL hook_bool_const_tree_false
1388 #undef LANG_HOOKS_GET_ALIAS_SET
1389 #define LANG_HOOKS_GET_ALIAS_SET gnat_get_alias_set
1390 #undef LANG_HOOKS_PRINT_DECL
1391 #define LANG_HOOKS_PRINT_DECL gnat_print_decl
1392 #undef LANG_HOOKS_PRINT_TYPE
1393 #define LANG_HOOKS_PRINT_TYPE gnat_print_type
1394 #undef LANG_HOOKS_TYPE_MAX_SIZE
1395 #define LANG_HOOKS_TYPE_MAX_SIZE gnat_type_max_size
1396 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
1397 #define LANG_HOOKS_DECL_PRINTABLE_NAME gnat_printable_name
1398 #undef LANG_HOOKS_DWARF_NAME
1399 #define LANG_HOOKS_DWARF_NAME gnat_dwarf_name
1400 #undef LANG_HOOKS_GIMPLIFY_EXPR
1401 #define LANG_HOOKS_GIMPLIFY_EXPR gnat_gimplify_expr
1402 #undef LANG_HOOKS_TYPE_FOR_MODE
1403 #define LANG_HOOKS_TYPE_FOR_MODE gnat_type_for_mode
1404 #undef LANG_HOOKS_TYPE_FOR_SIZE
1405 #define LANG_HOOKS_TYPE_FOR_SIZE gnat_type_for_size
1406 #undef LANG_HOOKS_TYPES_COMPATIBLE_P
1407 #define LANG_HOOKS_TYPES_COMPATIBLE_P gnat_types_compatible_p
1408 #undef LANG_HOOKS_GET_ARRAY_DESCR_INFO
1409 #define LANG_HOOKS_GET_ARRAY_DESCR_INFO gnat_get_array_descr_info
1410 #undef LANG_HOOKS_GET_SUBRANGE_BOUNDS
1411 #define LANG_HOOKS_GET_SUBRANGE_BOUNDS gnat_get_subrange_bounds
1412 #undef LANG_HOOKS_GET_TYPE_BIAS
1413 #define LANG_HOOKS_GET_TYPE_BIAS gnat_get_type_bias
1414 #undef LANG_HOOKS_DESCRIPTIVE_TYPE
1415 #define LANG_HOOKS_DESCRIPTIVE_TYPE gnat_descriptive_type
1416 #undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
1417 #define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE gnat_enum_underlying_base_type
1418 #undef LANG_HOOKS_GET_DEBUG_TYPE
1419 #define LANG_HOOKS_GET_DEBUG_TYPE gnat_get_debug_type
1420 #undef LANG_HOOKS_GET_FIXED_POINT_TYPE_INFO
1421 #define LANG_HOOKS_GET_FIXED_POINT_TYPE_INFO gnat_get_fixed_point_type_info
1422 #undef LANG_HOOKS_ATTRIBUTE_TABLE
1423 #define LANG_HOOKS_ATTRIBUTE_TABLE gnat_internal_attribute_table
1424 #undef LANG_HOOKS_BUILTIN_FUNCTION
1425 #define LANG_HOOKS_BUILTIN_FUNCTION gnat_builtin_function
1426 #undef LANG_HOOKS_INIT_TS
1427 #define LANG_HOOKS_INIT_TS gnat_init_ts
1428 #undef LANG_HOOKS_EH_PERSONALITY
1429 #define LANG_HOOKS_EH_PERSONALITY gnat_eh_personality
1430 #undef LANG_HOOKS_DEEP_UNSHARING
1431 #define LANG_HOOKS_DEEP_UNSHARING true
1432 #undef LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS
1433 #define LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS true
1434 #undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE
1435 #define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE gnat_get_sarif_source_language
1437 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
1439 #include "gt-ada-misc.h"