PR c++/80605 - __is_standard_layout and zero-length array
authorJason Merrill <jason@redhat.com>
Thu, 25 May 2017 21:24:36 +0000 (17:24 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 25 May 2017 21:24:36 +0000 (17:24 -0400)
* class.c (check_bases): Use DECL_FIELD_IS_BASE.

From-SVN: r248470

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/g++.dg/ext/is_std_layout2.C [new file with mode: 0644]

index 279bcdb..9b7b586 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/80605 - __is_standard_layout and zero-length array
+       * class.c (check_bases): Use DECL_FIELD_IS_BASE.
+
 2017-05-25  Nathan Sidwell  <nathan@acm.org>
 
        Kill OVL_CURRENT, OVL_NEXT.
 
 2017-05-09  Jason Merrill  <jason@redhat.com>
 
+       PR c++/80605 - __is_standard_layout and empty base
        * class.c (check_bases): Ignore empty bases.
 
        PR c++/70979 - literal class and closure types
index 984fb09..eddc118 100644 (file)
@@ -1842,8 +1842,8 @@ check_bases (tree t,
            for (basefield = TYPE_FIELDS (basetype); basefield;
                 basefield = DECL_CHAIN (basefield))
              if (TREE_CODE (basefield) == FIELD_DECL
-                 && DECL_SIZE (basefield)
-                 && !integer_zerop (DECL_SIZE (basefield)))
+                 && !(DECL_FIELD_IS_BASE (basefield)
+                      && integer_zerop (DECL_SIZE (basefield))))
                {
                  if (field)
                    CLASSTYPE_NON_STD_LAYOUT (t) = 1;
diff --git a/gcc/testsuite/g++.dg/ext/is_std_layout2.C b/gcc/testsuite/g++.dg/ext/is_std_layout2.C
new file mode 100644 (file)
index 0000000..02dc4f7
--- /dev/null
@@ -0,0 +1,6 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+struct S { int a[0]; };
+struct T : public S { int b[0]; int c; };
+static_assert(!__is_standard_layout (T), "");