From 7e231b2cfbfa5f99bbf581555ca74eaaba42ad7f Mon Sep 17 00:00:00 2001 From: Peter Bergner Date: Wed, 2 Dec 2020 18:12:59 -0600 Subject: [PATCH] c++: Treat OPAQUE_TYPE types as an aggregate type [PR97947] MODE_OPAQUE and the associated OPAQUE_TYPE were added to stop the optimizers from knowing how the bits in a variable with an opaque type are laid out. This makes them a kind of pseudo aggregate type and we need to treat them as such when we process the INIT initializer for variables with an opaque type. 2020-12-02 Peter Bergner gcc/cp/ PR c++/97947 * typeck2.c (digest_init_r): Handle OPAQUE_TYPE as an aggregate type. gcc/testsuite/ PR c++/97947 * g++.target/powerpc/pr97947.C: New test. --- gcc/cp/typeck2.c | 1 + gcc/testsuite/g++.target/powerpc/pr97947.C | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/g++.target/powerpc/pr97947.C diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 575c609a365..3fd2b174333 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1150,6 +1150,7 @@ digest_init_r (tree type, tree init, int nested, int flags, || VECTOR_TYPE_P (type) || code == RECORD_TYPE || code == UNION_TYPE + || code == OPAQUE_TYPE || code == COMPLEX_TYPE); /* "If T is a class type and the initializer list has a single diff --git a/gcc/testsuite/g++.target/powerpc/pr97947.C b/gcc/testsuite/g++.target/powerpc/pr97947.C new file mode 100644 index 00000000000..94e5ed6498b --- /dev/null +++ b/gcc/testsuite/g++.target/powerpc/pr97947.C @@ -0,0 +1,12 @@ +/* PR c++/97947 */ +/* { dg-do compile } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* Verify we do not ICE on the test below. */ + +void +bug (__vector_pair *src) +{ + volatile __vector_pair dd = *src; +} -- 2.30.2