On Sun, Sep 26, 2021 at 12:00 PM apinski--- via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> From: Andrew Pinski <apin...@marvell.com>
>
> The problem here is __builtin_shuffle when called with two arguments
> instead of 1, uses a SAVE_EXPR to put in for the 1st and 2nd operand
> of VEC_PERM_EXPR and when we go and gimplify the SAVE_EXPR, the type
> is now error_mark_node and that fails hard.
> This fixes the problem by adding a simple check for type of operand
> of SAVE_EXPR not to be error_mark_node.
>
> OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions.

OK.

Richard.

> gcc/ChangeLog:
>
>         PR c/94726
>         * gimplify.c (gimplify_save_expr): Return early
>         if the type of val is error_mark_node.
>
> gcc/testsuite/ChangeLog:
>
>         PR c/94726
>         * gcc.dg/pr94726.c: New test.
> ---
>  gcc/gimplify.c                 |  3 +++
>  gcc/testsuite/gcc.dg/pr94726.c | 11 +++++++++++
>  2 files changed, 14 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.dg/pr94726.c
>
> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> index 9163dcda438..943c5cb8f2d 100644
> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -6232,6 +6232,9 @@ gimplify_save_expr (tree *expr_p, gimple_seq *pre_p, 
> gimple_seq *post_p)
>    gcc_assert (TREE_CODE (*expr_p) == SAVE_EXPR);
>    val = TREE_OPERAND (*expr_p, 0);
>
> +  if (TREE_TYPE (val) == error_mark_node)
> +    return GS_ERROR;
> +
>    /* If the SAVE_EXPR has not been resolved, then evaluate it once.  */
>    if (!SAVE_EXPR_RESOLVED_P (*expr_p))
>      {
> diff --git a/gcc/testsuite/gcc.dg/pr94726.c b/gcc/testsuite/gcc.dg/pr94726.c
> new file mode 100644
> index 00000000000..d6911a644a4
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr94726.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +typedef unsigned int type __attribute__ ( ( vector_size ( 2*sizeof(int) ) ) 
> ) ;
> +type a , b;
> +/* { dg-message "note: previous declaration" "previous declaration" { target 
> *-*-* } .-1 } */
> +void foo ( void ) {
> +       type var = { 2 , 2 } ;
> +       b = __builtin_shuffle ( a , var ) ;
> +}
> +
> +void * a [ ] = { } ; /* { dg-error "conflicting types" } */
> --
> 2.17.1
>

Reply via email to