decl.c (gnat_to_gnu_entity): Don't generate debug info for inner record types if...
authorPierre-Marie de Rodat <derodat@adacore.com>
Sat, 9 Sep 2017 13:05:40 +0000 (13:05 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 9 Sep 2017 13:05:40 +0000 (13:05 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Don't
generate debug info for inner record types if -fgnat-encodings=minimal.
(gnat_to_gnu_entity) <E_Record_Subtype>: Use the ultimate base record
type as the debug type.

From-SVN: r251937

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/utils2.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/debug11.adb
gcc/testsuite/gnat.dg/debug12.adb
gcc/testsuite/gnat.dg/debug13.adb
gcc/testsuite/gnat.dg/debug14.adb [new file with mode: 0644]

index e929eff15fa18ef0f96867621e43390c6a43934f..dee1897e7b7f91507d917a0c3493b0196b2faa13 100644 (file)
@@ -1,3 +1,10 @@
+2017-09-09  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Don't
+       generate debug info for inner record types if -fgnat-encodings=minimal.
+       (gnat_to_gnu_entity) <E_Record_Subtype>: Use the ultimate base record
+       type as the debug type.
+
 2017-09-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (components_to_record): Do not reorder in non-
index 569e64db626a0983b2d40d0653d979897d9a6d5a..7b30497587497841f87332de23cfa29dc2e808d3 100644 (file)
@@ -3308,10 +3308,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
              = build_subst_list (gnat_entity, gnat_parent_type, definition);
 
            /* Set the layout of the type to match that of the parent type,
-              doing required substitutions.  */
-           copy_and_substitute_in_layout (gnat_entity, gnat_parent_type,
-                                          gnu_type, gnu_parent_type,
-                                          gnu_subst_list, debug_info_p);
+              doing required substitutions.  If we are in minimal GNAT
+              encodings mode, we don't need debug info for the inner record
+              types, as they will be part of the embedding variant record's
+              debug info.  */
+           copy_and_substitute_in_layout
+             (gnat_entity, gnat_parent_type, gnu_type, gnu_parent_type,
+              gnu_subst_list,
+              debug_info_p && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL);
          }
        else
          {
@@ -3439,7 +3443,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
              gnu_type = make_node (RECORD_TYPE);
              TYPE_NAME (gnu_type) = gnu_entity_name;
              if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
-               SET_TYPE_DEBUG_TYPE (gnu_type, gnu_base_type);
+               {
+                 /* Use the ultimate base record type as the debug type.
+                    Subtypes and derived types bring no useful
+                    information.  */
+                 Entity_Id gnat_debug_type = gnat_entity;
+                 while (Etype (gnat_debug_type) != gnat_debug_type)
+                   gnat_debug_type = Etype (gnat_debug_type);
+                 tree gnu_debug_type
+                   = TYPE_MAIN_VARIANT (gnat_to_gnu_type (gnat_debug_type));
+                 SET_TYPE_DEBUG_TYPE (gnu_type, gnu_debug_type);
+               }
              TYPE_PACKED (gnu_type) = TYPE_PACKED (gnu_base_type);
              TYPE_REVERSE_STORAGE_ORDER (gnu_type)
                = Reverse_Storage_Order (gnat_entity);
index 072e1052c16bffe5193a9f1c1a601c0a3e520561..6f109c731469cd6b8270d1bbf93ac3f2412eaf30 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2016, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2017, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
index 0f58fb777f3f3e972599249580bb8d0e5c1db160..35aadc7952de4bab6a13bec72f4992284845e359 100644 (file)
@@ -1,3 +1,7 @@
+2017-09-09  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * gnat.dg/debug14.adb: New test.
+
 2017-09-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/specs/atomic3.ads: New test.
index 5f60697a53634cd82e1734b57d1dad03fc732301..19c1c43486da9e7f0e8622deb9abb0781eacd0a7 100644 (file)
@@ -1,3 +1,4 @@
+--  { dg-do compile }
 --  { dg-options "-cargs -O0 -g -dA -fgnat-encodings=minimal -margs" }
 --
 --  This testcase checks that in the DWARF description of the variant type
index 07175968703ac5bd31994c3e3b3cba6d0307aabe..c236dc474d98e2c9330eba758a1cb0e657beb141 100644 (file)
@@ -1,3 +1,4 @@
+--  { dg-do compile }
 --  { dg-options "-cargs -gdwarf-4 -fdebug-types-section -dA -margs" }
 --  { dg-final { scan-assembler-times "DW_AT_location" 4 } }
 
index 4b94b3e6bf16417f1185b83472c32706409ad7a7..f54a4e09770241f1b834d69c6424c9e6ee942c70 100644 (file)
@@ -1,4 +1,5 @@
---  { dg-options "-cargs -O2 -g -margs" }
+-- { dg-do compile }
+-- { dg-options "-O2 -g" }
 
 package body Debug13 is
 
diff --git a/gcc/testsuite/gnat.dg/debug14.adb b/gcc/testsuite/gnat.dg/debug14.adb
new file mode 100644 (file)
index 0000000..2cb9107
--- /dev/null
@@ -0,0 +1,38 @@
+-- { dg-do compile }
+-- { dg-options "-g -fgnat-encodings=minimal" }
+
+procedure Debug14 is
+
+  type Db_Kind_T is (Raw, Relational, Object);
+
+  type Db_Model_T (Kind : Db_Kind_T) is
+    record
+
+      case Kind is
+
+        when Raw =>
+          Fs_Type : Integer;
+
+        when Relational | Object =>
+          Vendor_Id : Integer;
+
+          case Kind is
+            when Relational =>
+              N_Tables : Integer;
+
+            when others =>
+              null;
+          end case;
+
+      end case;
+
+    end record;
+
+  type Raw_Db_T is new Db_Model_T (Kind => Raw);
+  type Raw_Db_P is access Raw_Db_T;
+
+  Db : Raw_Db_P := new Raw_Db_T;
+
+begin
+  null;
+end;