On Mon, Jul 12, 2021 at 11:01:39AM +0200, Martin Liška wrote:
> We should not call candidates_list_and_hint if there are no candidates.
> 
> Ready after testing finishes?
> Thanks,
> Martin
> 
>       sanitizer/101425
> 
> gcc/ChangeLog:
> 
>       * gcc.c (check_offload_target_name): Call
>         candidates_list_and_hint only if we have a candidate.
> ---
>  gcc/gcc.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/gcc/gcc.c b/gcc/gcc.c
> index f086dd47b91..16a8aa8f17b 100644
> --- a/gcc/gcc.c
> +++ b/gcc/gcc.c
> @@ -4015,15 +4015,18 @@ check_offload_target_name (const char *target, 
> ptrdiff_t len)
>        error ("GCC is not configured to support %qs as offload target", 
> target2);
> -      const char *hint = candidates_list_and_hint (target2, s, candidates);
>        if (candidates.is_empty ())
>       inform (UNKNOWN_LOCATION, "no offloading targets configured");
> -      else if (hint)
> -     inform (UNKNOWN_LOCATION,
> -             "valid offload targets are: %s; did you mean %qs?", s, hint);
>        else
> -     inform (UNKNOWN_LOCATION, "valid offload targets are: %s", s);
> -      XDELETEVEC (s);
> +     {
> +       const char *hint = candidates_list_and_hint (target2, s, candidates);
> +       if (hint)
> +         inform (UNKNOWN_LOCATION,
> +                 "valid offload targets are: %s; did you mean %qs?", s, 
> hint);
> +       else
> +         inform (UNKNOWN_LOCATION, "valid offload targets are: %s", s);
> +       XDELETEVEC (s);
> +     }
>        return false;
>      }
>    return true;

Please move char *s; declaration into the new scope.
Ok with that change.

        Jakub

Reply via email to