c++: Fix handling of internal fn calls in statement expressions [PR94385]
authorJakub Jelinek <jakub@redhat.com>
Mon, 30 Mar 2020 20:55:36 +0000 (22:55 +0200)
committerJakub Jelinek <jakub@redhat.com>
Mon, 30 Mar 2020 20:55:36 +0000 (22:55 +0200)
The following testcase ICEs, because the FE when processing the statement
expression changes the .VEC_CONVERT internal fn CALL_EXPR into .PHI call.
That is because the internal fn call is recorded in the base.u.ifn
field, which overlaps base.u.bits.lang_flag_1 which is used for
STMT_IS_FULL_EXPR_P, so this essentially does ifn |= 2 on little-endian.
STMT_IS_FULL_EXPR_P bit is used in:
cp-gimplify.c-  if (STATEMENT_CODE_P (code))
cp-gimplify.c-    {
cp-gimplify.c-      saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
cp-gimplify.c-      current_stmt_tree ()->stmts_are_full_exprs_p
cp-gimplify.c:        = STMT_IS_FULL_EXPR_P (*expr_p);
cp-gimplify.c-    }
and
pt.c-  if (STATEMENT_CODE_P (TREE_CODE (t)))
pt.c:    current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
so besides being wrong on some other codes, it actually isn't beneficial at
all to set it on anything else, so the following patch restricts it to
trees with STATEMENT_CODE_P TREE_CODE.

2020-03-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/94385
* semantics.c (add_stmt): Only set STMT_IS_FULL_EXPR_P on trees with
STATEMENT_CODE_P code.

* c-c++-common/pr94385.c: New test.

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr94385.c [new file with mode: 0644]

index e7c248a3c2fccff8d8595fe042b4b0276b573e71..be22bc091dd21ee8c6d2c0cc99fd5d87ce7f8c11 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94385
+       * semantics.c (add_stmt): Only set STMT_IS_FULL_EXPR_P on trees with
+       STATEMENT_CODE_P code.
+
 2020-03-28  Patrick Palka  <ppalka@redhat.com>
 
        PR c++/94306
index 38637bdf3f365774cdf7cd469a82052f4998f2f6..c7a6064e9f338bdf5a12b421c4e15ba5b6f7f492 100644 (file)
@@ -380,7 +380,8 @@ add_stmt (tree t)
 
       /* When we expand a statement-tree, we must know whether or not the
         statements are full-expressions.  We record that fact here.  */
-      STMT_IS_FULL_EXPR_P (t) = stmts_are_full_exprs_p ();
+      if (STATEMENT_CODE_P (TREE_CODE (t)))
+       STMT_IS_FULL_EXPR_P (t) = stmts_are_full_exprs_p ();
     }
 
   if (code == LABEL_EXPR || code == CASE_LABEL_EXPR)
index 90c9db8fbf57208e0a9ec5509e2bdf6a41dd6bb6..66c71f1c15fabc80c7b72ed163cdcb69a18c1238 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94385
+       * c-c++-common/pr94385.c: New test.
+
 2020-03-30  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
        * gcc.target/powerpc/pragma_power6.c: New.
diff --git a/gcc/testsuite/c-c++-common/pr94385.c b/gcc/testsuite/c-c++-common/pr94385.c
new file mode 100644 (file)
index 0000000..0611921
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR c++/94385 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+typedef int V __attribute__((__vector_size__(16)));
+typedef float W __attribute__((__vector_size__(16)));
+
+void
+foo (W *x, V *y)
+{
+  *y = (({ __builtin_convertvector (*x, V); }));
+}