From: Jakub Jelinek Date: Mon, 30 Mar 2020 20:55:36 +0000 (+0200) Subject: c++: Fix handling of internal fn calls in statement expressions [PR94385] X-Git-Tag: embedded-9-2020q2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a6bf0e5fb11cc0e231ac016a1995caaa93fdc4a0;p=thirdparty%2Fgcc.git c++: Fix handling of internal fn calls in statement expressions [PR94385] 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 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. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d11c4c62ddf3..324e133a1250 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,12 @@ 2020-04-07 Jakub Jelinek Backported from mainline + 2020-03-30 Jakub Jelinek + + PR c++/94385 + * semantics.c (add_stmt): Only set STMT_IS_FULL_EXPR_P on trees with + STATEMENT_CODE_P code. + 2020-03-19 Jakub Jelinek PR c++/93931 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4bfb5d152934..559e38dbc14e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a1b7fd3e8a3..c32e6a86b8ba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,9 @@ Backported from mainline 2020-03-30 Jakub Jelinek + PR c++/94385 + * c-c++-common/pr94385.c: New test. + PR target/93069 * gcc.target/i386/avx512vl-pr93069.c: New test. * gcc.dg/vect/pr93069.c: New test. diff --git a/gcc/testsuite/c-c++-common/pr94385.c b/gcc/testsuite/c-c++-common/pr94385.c new file mode 100644 index 000000000000..0611921295c5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr94385.c @@ -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); })); +}