public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Peter Bergner <bergner@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-8682] c: Handle initializations of opaque types [PR106016]
Date: Fri, 12 Aug 2022 00:26:19 +0000 (GMT)	[thread overview]
Message-ID: <20220812002619.092193858D28@sourceware.org> (raw)

https://gcc.gnu.org/g:6aaaf20ee4ad9c85f3099ef425720547644fb08d

commit r12-8682-g6aaaf20ee4ad9c85f3099ef425720547644fb08d
Author: Peter Bergner <bergner@linux.ibm.com>
Date:   Fri Jun 17 23:43:23 2022 -0500

    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  <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.
    
    (cherry picked from commit 975658b782f36dcf6eb190966d5b705977bfd5eb)

Diff:
---
 gcc/expr.cc                                 |  2 +-
 gcc/testsuite/gcc.target/powerpc/pr106016.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/expr.cc b/gcc/expr.cc
index dee3fc6148c..2103931c740 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 00000000000..3db8345dcc6
--- /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]);
+}


                 reply	other threads:[~2022-08-12  0:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220812002619.092193858D28@sourceware.org \
    --to=bergner@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).