On Thu, May 7, 2020 at 9:48 AM Jakub Jelinek via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi!
>
> If the second argument of __builtin_speculation_safe_value is
> error_mark_node (or has such a type), we ICE during
> useless_typ_conversion_p.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

OK.

Richard.

> 202-05-06  Jakub Jelinek  <ja...@redhat.com>
>
>         PR c/94968
>         * c-common.c (speculation_safe_value_resolve_params): Return false if
>         error_operand_p (val2).
>         (resolve_overloaded_builtin) <case BUILT_IN_SPECULATION_SAFE_VALUE_N>:
>         Remove extraneous semicolon.
>
>         * gcc.dg/pr94968.c: New test.
>
> --- gcc/c-family/c-common.c.jj  2020-04-27 16:10:23.795726234 +0200
> +++ gcc/c-family/c-common.c     2020-05-06 12:37:40.708539995 +0200
> @@ -6716,6 +6716,8 @@ speculation_safe_value_resolve_params (l
>        tree val2 = (*params)[1];
>        if (TREE_CODE (TREE_TYPE (val2)) == ARRAY_TYPE)
>         val2 = default_conversion (val2);
> +      if (error_operand_p (val2))
> +       return false;
>        if (!(TREE_TYPE (val) == TREE_TYPE (val2)
>             || useless_type_conversion_p (TREE_TYPE (val), TREE_TYPE (val2))))
>         {
> @@ -7400,7 +7402,7 @@ resolve_overloaded_builtin (location_t l
>        {
>         tree new_function, first_param, result;
>         enum built_in_function fncode
> -         = speculation_safe_value_resolve_call (function, params);;
> +         = speculation_safe_value_resolve_call (function, params);
>
>         if (fncode == BUILT_IN_NONE)
>           return error_mark_node;
> --- gcc/testsuite/gcc.dg/pr94968.c.jj   2020-05-06 12:50:10.865191796 +0200
> +++ gcc/testsuite/gcc.dg/pr94968.c      2020-05-06 12:49:52.366471532 +0200
> @@ -0,0 +1,8 @@
> +/* PR c/94968 */
> +/* { dg-do compile } */
> +
> +int
> +foo (void)
> +{
> +  __builtin_speculation_safe_value (1, x);     /* { dg-error "undeclared" } 
> */
> +}                                              /* { dg-message "each 
> undeclared identifier is reported only once" "" { target *-*-* } .-1 } */
>
>         Jakub
>

Reply via email to