]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR debug/33316 (ICE on valid variable-length automatic array in const struct)
authorJakub Jelinek <jakub@redhat.com>
Mon, 24 Sep 2007 09:17:10 +0000 (11:17 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 24 Sep 2007 09:17:10 +0000 (11:17 +0200)
PR debug/33316
* dwarf2out.c (modified_type_die): Handle TYPE_DECL with NULL
DECL_NAME.
* dbxout.c (dbxout_type): Likewise.

* gcc.dg/debug/pr33316.c: New test.

From-SVN: r128709

gcc/ChangeLog
gcc/dbxout.c
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/pr33316.c [new file with mode: 0644]

index 80b357dda382928b57168877a904c9367096758a..42d02125d917185b5d3d56458c92a43bf5b13df5 100644 (file)
@@ -1,3 +1,10 @@
+2007-09-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/33316
+       * dwarf2out.c (modified_type_die): Handle TYPE_DECL with NULL
+       DECL_NAME.
+       * dbxout.c (dbxout_type): Likewise.
+
 2007-09-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        * configure.ac (ld_vers): Support GNU linker version xx.xx.*
index e7553edb4dee722cfefbb9461a7be298269838d5..963f5a3ce49f246fcf7affb1fb863aa895b00378 100644 (file)
@@ -2023,7 +2023,11 @@ dbxout_type (tree type, int full)
               another type's definition; instead, output an xref
               and let the definition come when the name is defined.  */
            stabstr_S ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
-           if (TYPE_NAME (type) != 0)
+           if (TYPE_NAME (type) != 0
+               /* The C frontend creates for anonymous variable length
+                  records/unions TYPE_NAME with DECL_NAME NULL.  */
+               && (TREE_CODE (TYPE_NAME (type)) != TYPE_DECL
+                   || DECL_NAME (TYPE_NAME (type))))
              dbxout_type_name (type);
            else
              {
index 6c764166de46924f55900d4df53d3489ccb03556..2d8932ae358fdb7cb1d4d4e2c59d0b0134bb0837 100644 (file)
@@ -8518,7 +8518,8 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
      don't output a DW_TAG_typedef, since there isn't one in the
      user's program; just attach a DW_AT_name to the type.  */
   if (name
-      && (TREE_CODE (name) != TYPE_DECL || TREE_TYPE (name) == qualified_type))
+      && (TREE_CODE (name) != TYPE_DECL
+         || (TREE_TYPE (name) == qualified_type && DECL_NAME (name))))
     {
       if (TREE_CODE (name) == TYPE_DECL)
        /* Could just call add_name_and_src_coords_attributes here,
index b9b825795fa307fc6c2761c501b14b2d42a0bb7b..7bfa71fc79c23029b500ce9cc0477344697cbafc 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/33316
+       * gcc.dg/debug/pr33316.c: New test.
+
 2007-09-20  Paolo Carlini  <pcarlini@suse.de>
 
        PR c++/33459
diff --git a/gcc/testsuite/gcc.dg/debug/pr33316.c b/gcc/testsuite/gcc.dg/debug/pr33316.c
new file mode 100644 (file)
index 0000000..d43478b
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR debug/33316 */
+
+int
+foo (void *x, int y)
+{
+  const struct { int d[y]; } *a = x;
+  return a[0].d[0];
+}
+
+int
+bar (void *x, int y)
+{
+  const struct S { int d[y]; } *a = x;
+  return a[0].d[0];
+}