]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Further increase the limit on the size of accepted Ada files
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 13 Apr 2021 15:07:36 +0000 (17:07 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 13 Apr 2021 15:11:15 +0000 (17:11 +0200)
It turns out that the limit on the size of accepted Ada files had been
already lowered earlier, namely when location ranges had been introduced.
Now we do not make use of location ranges in Ada so we can recoup the loss.

gcc/ada/
* gcc-interface/misc.c (gnat_init): Set default range bits to 0.
* gcc-interface/trans.c (extract_encoding): Delete.
(decode_name): Likewise.
(File_Name_to_gnu): New function.
(gigi): Call it to translate file names.  Replace assertion on
1-1 mapping between files and line maps with conditional error.

gcc/ada/gcc-interface/misc.c
gcc/ada/gcc-interface/trans.c

index d0867e00c852da0112e3bc4bf2ba19292278d80f..16bccb917eeb58d41a4749d323263a3cf5c499bc 100644 (file)
@@ -370,6 +370,9 @@ gnat_init (void)
   sbitsize_one_node = sbitsize_int (1);
   sbitsize_unit_node = sbitsize_int (BITS_PER_UNIT);
 
+  /* In Ada, we do not use location ranges.  */
+  line_table->default_range_bits = 0;
+
   /* Register our internal error function.  */
   global_dc->internal_error = &internal_error_function;
 
index ae7a52f3ca224bbe43431a98b38d90c0f8981139..5a55ca4f29ef3fb0139bd634236e58771bb37b26 100644 (file)
@@ -251,17 +251,27 @@ static tree build_raise_check (int, enum exception_info_kind);
 static tree create_init_temporary (const char *, tree, tree *, Node_Id);
 static bool maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk);
 
-/* Hooks for debug info back-ends, only supported and used in a restricted set
-   of configurations.  */
-static const char *extract_encoding (const char *) ATTRIBUTE_UNUSED;
-static const char *decode_name (const char *) ATTRIBUTE_UNUSED;
-
 /* This makes gigi's file_info_ptr visible in this translation unit,
    so that Sloc_to_locus can look it up when deciding whether to map
    decls to instances.  */
 
 static struct File_Info_Type *file_map;
 
+/* Return the string of the identifier allocated for the file name Id.  */
+
+static const char*
+File_Name_to_gnu (Name_Id Id)
+{
+  /* __gnat_to_canonical_file_spec translates file names from pragmas
+     Source_Reference that contain host style syntax not understood by GDB.  */
+  const char *name = __gnat_to_canonical_file_spec (Get_Name_String (Id));
+
+  /* Use the identifier table to make a permanent copy of the file name as
+     the name table gets reallocated after Gigi returns but before all the
+     debugging information is output.  */
+  return IDENTIFIER_POINTER (get_identifier (name));
+}
+
 /* This is the main program of the back-end.  It sets up all the table
    structures and then generates code.  */
 
@@ -315,23 +325,18 @@ gigi (Node_Id gnat_root,
 
   for (i = 0; i < number_file; i++)
     {
-      /* Use the identifier table to make a permanent copy of the filename as
-        the name table gets reallocated after Gigi returns but before all the
-        debugging information is output.  The __gnat_to_canonical_file_spec
-        call translates filenames from pragmas Source_Reference that contain
-        host style syntax not understood by gdb.  */
-      const char *filename
-       = IDENTIFIER_POINTER
-          (get_identifier
-           (__gnat_to_canonical_file_spec
-            (Get_Name_String (file_info_ptr[i].File_Name))));
-
       /* We rely on the order isomorphism between files and line maps.  */
-      gcc_assert ((int) LINEMAPS_ORDINARY_USED (line_table) == i);
+      if ((int) LINEMAPS_ORDINARY_USED (line_table) != i)
+       {
+         gcc_assert (i > 0);
+         error ("%s contains too many lines",
+                File_Name_to_gnu (file_info_ptr[i - 1].File_Name));
+       }
 
       /* We create the line map for a source file at once, with a fixed number
         of columns chosen to avoid jumping over the next power of 2.  */
-      linemap_add (line_table, LC_ENTER, 0, filename, 1);
+      linemap_add (line_table, LC_ENTER, 0,
+                  File_Name_to_gnu (file_info_ptr[i].File_Name), 1);
       linemap_line_start (line_table, file_info_ptr[i].Num_Source_Lines, 252);
       linemap_position_for_column (line_table, 252 - 1);
       linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
@@ -10401,27 +10406,6 @@ set_end_locus_from_node (tree gnu_node, Node_Id gnat_node)
     }
 }
 
-/* Return a colon-separated list of encodings contained in encoded Ada
-   name.  */
-
-static const char *
-extract_encoding (const char *name)
-{
-  char *encoding = (char *) ggc_alloc_atomic (strlen (name));
-  get_encoding (name, encoding);
-  return encoding;
-}
-
-/* Extract the Ada name from an encoded name.  */
-
-static const char *
-decode_name (const char *name)
-{
-  char *decoded = (char *) ggc_alloc_atomic (strlen (name) * 2 + 60);
-  __gnat_decode (name, decoded, 0);
-  return decoded;
-}
-
 /* Post an error message.  MSG is the error message, properly annotated.
    NODE is the node at which to post the error and the node to use for the
    '&' substitution.  */