From: Peter Bergner Date: Sat, 18 Jun 2022 04:43:23 +0000 (-0500) Subject: c: Handle initializations of opaque types [PR106016] X-Git-Tag: releases/gcc-12.2.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6aaaf20ee4ad9c85f3099ef425720547644fb08d;p=thirdparty%2Fgcc.git c: Handle initializations of opaque types [PR106016] The initial commit that added opaque types thought that there couldn't be any valid initializations for variables of these types, but the test case in the bug report shows that isn't true. The solution is to handle OPAQUE_TYPE initializations like the other scalar types. 2022-06-17 Peter Bergner gcc/ PR c/106016 * expr.cc (count_type_elements): Handle OPAQUE_TYPE. gcc/testsuite/ PR c/106016 * gcc.target/powerpc/pr106016.c: New test. (cherry picked from commit 975658b782f36dcf6eb190966d5b705977bfd5eb) --- diff --git a/gcc/expr.cc b/gcc/expr.cc index dee3fc6148c1..2103931c7407 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -6393,13 +6393,13 @@ count_type_elements (const_tree type, bool for_ctor_p) case OFFSET_TYPE: case REFERENCE_TYPE: case NULLPTR_TYPE: + case OPAQUE_TYPE: return 1; case ERROR_MARK: return 0; case VOID_TYPE: - case OPAQUE_TYPE: case METHOD_TYPE: case FUNCTION_TYPE: case LANG_TYPE: diff --git a/gcc/testsuite/gcc.target/powerpc/pr106016.c b/gcc/testsuite/gcc.target/powerpc/pr106016.c new file mode 100644 index 000000000000..3db8345dcc68 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106016.c @@ -0,0 +1,14 @@ +/* PR target/106016 */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* Make sure we do not ICE on the following test case. */ + +extern void bar (__vector_quad *); + +void +foo (__vector_quad *a, __vector_quad *b) +{ + __vector_quad arr[2] = {*a, *b}; + bar (&arr[0]); +}