re PR fortran/70931 (ICE with -g in native_encode_initializer, bei dwarf2out.c:17768)
authorRichard Biener <rguenther@suse.de>
Fri, 6 May 2016 07:44:22 +0000 (07:44 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 6 May 2016 07:44:22 +0000 (07:44 +0000)
2016-05-06  Richard Biener  <rguenther@suse.de>

PR middle-end/70931
* dwarf2out.c (native_encode_initializer): Skip zero-sized fields.

* gfortran.dg/pr70931.f90: New testcase.

From-SVN: r235944

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr70931.f90 [new file with mode: 0644]

index e8f7c8f8e0e4a34bfebca13b731b618737fc65c3..3bf441a48f0edcf07587c0151342d3276581f2d0 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-06  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/70931
+       * dwarf2out.c (native_encode_initializer): Skip zero-sized fields.
+
 2016-05-06  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/70941
index ab851f4628b3d5cc7c53c611ea244b670f80c9a7..fb3f7b9eb3c12a1568ef55d602a1e97b694128c6 100644 (file)
@@ -17806,7 +17806,7 @@ native_encode_initializer (tree init, unsigned char *array, int size)
              fieldsize = tree_to_shwi (DECL_SIZE_UNIT (field));
              pos = int_byte_position (field);
              gcc_assert (pos + fieldsize <= size);
-             if (val
+             if (val && fieldsize != 0
                  && !native_encode_initializer (val, array + pos, fieldsize))
                return false;
            }
index d5b2df98e38714c8096bd7f75aa1ebe574f9c18e..13f71217cedd44b60148a19c4314d478a693c9ec 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-06  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/70931
+       * gfortran.dg/pr70931.f90: New testcase.
+
 2016-05-06  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/70941
diff --git a/gcc/testsuite/gfortran.dg/pr70931.f90 b/gcc/testsuite/gfortran.dg/pr70931.f90
new file mode 100644 (file)
index 0000000..08ecd68
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-options "-g" }
+program p
+   type t
+      integer :: a
+      integer :: b(0)
+   end type
+   type(t), parameter :: z = t(1, [2])
+   print *, z
+end