From 7552c36afa1f9058bb39f336ae84f019621885a0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 1 Oct 2019 18:19:04 +0200 Subject: [PATCH] re PR c++/91925 (-fpack-struct causes a decltype with template to ICE) 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 | 6 ++++++ gcc/c-family/c-warn.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/conversion/packed2.C | 15 +++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/g++.dg/conversion/packed2.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index eaea04b9635..811947a143c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2019-10-01 Jakub Jelinek + + PR c++/91925 + * c-warn.c (check_alignment_of_packed_member): Ignore FIELD_DECLs + with NULL DECL_FIELD_OFFSET. + 2019-10-01 Richard Sandiford * c-pretty-print.c (pp_c_specifier_qualifier_list): If a vector type diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index bee5449bcb1..8236525afc9 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 995e1cb59f5..df6105f3d13 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-01 Jakub Jelinek + + PR c++/91925 + * g++.dg/conversion/packed2.C: New test. + 2019-10-01 Bill Schmidt * 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 index 00000000000..7df74dc110b --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/packed2.C @@ -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 T bar (T); +class C { + A a; + decltype (bar (a)) p; +}; -- 2.30.2