re PR c++/91925 (-fpack-struct causes a decltype with template to ICE)
authorJakub Jelinek <jakub@redhat.com>
Tue, 1 Oct 2019 16:19:04 +0000 (18:19 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 1 Oct 2019 16:19:04 +0000 (18:19 +0200)
PR c++/91925
* c-warn.c (check_alignment_of_packed_member): Ignore FIELD_DECLs
with NULL DECL_FIELD_OFFSET.

* g++.dg/conversion/packed2.C: New test.

From-SVN: r276415

gcc/c-family/ChangeLog
gcc/c-family/c-warn.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/packed2.C [new file with mode: 0644]

index eaea04b9635280fd3858a45db439c6c299753caf..811947a143c5ee1d4ac3c1d2ba802233a96a463a 100644 (file)
@@ -1,3 +1,9 @@
+2019-10-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/91925
+       * c-warn.c (check_alignment_of_packed_member): Ignore FIELD_DECLs
+       with NULL DECL_FIELD_OFFSET.
+
 2019-10-01  Richard Sandiford  <richard.sandiford@arm.com>
 
        * c-pretty-print.c (pp_c_specifier_qualifier_list): If a vector type
index bee5449bcb1690498f95a205afdafdf730d68587..8236525afc9f459afe1a28eeea978e0c5029492e 100644 (file)
@@ -2798,6 +2798,8 @@ check_alignment_of_packed_member (tree type, tree field, bool rvalue)
   /* Check alignment of the data member.  */
   if (TREE_CODE (field) == FIELD_DECL
       && (DECL_PACKED (field) || TYPE_PACKED (TREE_TYPE (field)))
+      /* Ignore FIELDs not laid out yet.  */
+      && DECL_FIELD_OFFSET (field)
       && (!rvalue || TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE))
     {
       /* Check the expected alignment against the field alignment.  */
index 995e1cb59f58b2f5e81ca0d047269d4bfb568d70..df6105f3d13f51b60874c6dae1b6e12c13d7084b 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/91925
+       * g++.dg/conversion/packed2.C: New test.
+
 2019-10-01  Bill Schmidt  <wschmdit@linux.ibm.com>
 
        * gcc.target/powerpc/pr91275.c: New.
diff --git a/gcc/testsuite/g++.dg/conversion/packed2.C b/gcc/testsuite/g++.dg/conversion/packed2.C
new file mode 100644 (file)
index 0000000..7df74dc
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/91925
+// { dg-do compile { target c++11 } }
+// { dg-options "-fpack-struct" }
+
+struct A {};
+int foo (A);
+struct B {
+  A a;
+  decltype (foo (a)) p;
+};
+template <typename T> T bar (T);
+class C {
+  A a;
+  decltype (bar (a)) p;
+};