]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c: Handle initializations of opaque types [PR106016]
authorPeter Bergner <bergner@linux.ibm.com>
Sat, 18 Jun 2022 04:43:23 +0000 (23:43 -0500)
committerPeter Bergner <bergner@linux.ibm.com>
Tue, 26 Jul 2022 15:04:44 +0000 (10:04 -0500)
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  <bergner@linux.ibm.com>

gcc/
PR c/106016
* expr.cc (count_type_elements): Handle OPAQUE_TYPE.

gcc/testsuite/
PR c/106016
* gcc.target/powerpc/pr106016.c: New test.

gcc/expr.cc
gcc/testsuite/gcc.target/powerpc/pr106016.c [new file with mode: 0644]

index f9753d48245d56039206647be8576246a3b25ed3..80bb1b8a4c5b8350fb1b8f57a99fd52e5882fcb6 100644 (file)
@@ -6462,13 +6462,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 (file)
index 0000000..3db8345
--- /dev/null
@@ -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]);
+}