public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2590] c/101512 - fix missing address-taking in c_common_mark_addressable_vec
@ 2021-07-29  6:13 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-07-29  6:13 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e63d76234d18cac731c4f3610d513bd8b39b5520

commit r12-2590-ge63d76234d18cac731c4f3610d513bd8b39b5520
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Jul 21 09:14:24 2021 +0200

    c/101512 - fix missing address-taking in c_common_mark_addressable_vec
    
    c_common_mark_addressable_vec fails to look through C_MAYBE_CONST_EXPR
    in the case it isn't at the toplevel.
    
    2021-07-21  Richard Biener  <rguenther@suse.de>
    
            PR c/101512
    gcc/c-family/
            * c-common.c (c_common_mark_addressable_vec): Look through
            C_MAYBE_CONST_EXPR even if not at the toplevel.
    
    gcc/testsuite/
            * gcc.dg/torture/pr101512.c: New testcase.

Diff:
---
 gcc/c-family/c-common.c                 | 11 +++++++----
 gcc/testsuite/gcc.dg/torture/pr101512.c | 11 +++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index aacdfb46a02..21da679cd3c 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -6894,10 +6894,13 @@ complete_flexible_array_elts (tree init)
 void 
 c_common_mark_addressable_vec (tree t)
 {   
-  if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
-    t = C_MAYBE_CONST_EXPR_EXPR (t);
-  while (handled_component_p (t))
-    t = TREE_OPERAND (t, 0);
+  while (handled_component_p (t) || TREE_CODE (t) == C_MAYBE_CONST_EXPR)
+    {
+      if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
+	t = C_MAYBE_CONST_EXPR_EXPR (t);
+      else
+	t = TREE_OPERAND (t, 0);
+    }
   if (!VAR_P (t)
       && TREE_CODE (t) != PARM_DECL
       && TREE_CODE (t) != COMPOUND_LITERAL_EXPR)
diff --git a/gcc/testsuite/gcc.dg/torture/pr101512.c b/gcc/testsuite/gcc.dg/torture/pr101512.c
new file mode 100644
index 00000000000..a25da2aa0b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101512.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-w -Wno-psabi" } */
+
+int n();
+typedef unsigned long V __attribute__ ((vector_size (64)));
+V
+foo (int i, V v)
+{
+  i = ((V)(V){n()})[n()];
+  return v + i;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-29  6:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29  6:13 [gcc r12-2590] c/101512 - fix missing address-taking in c_common_mark_addressable_vec Richard Biener

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).