From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 8F58B3857C53; Mon, 12 Jul 2021 09:35:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F58B3857C53 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2240] offloading: fix -foffload hinting X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/heads/master X-Git-Oldrev: 1e72c24d2f3b1427f5e117e371928e7af50d2036 X-Git-Newrev: 9b8b37d1b6301855213b8d4860feaeb74d464c6b Message-Id: <20210712093533.8F58B3857C53@sourceware.org> Date: Mon, 12 Jul 2021 09:35:33 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2021 09:35:33 -0000 https://gcc.gnu.org/g:9b8b37d1b6301855213b8d4860feaeb74d464c6b commit r12-2240-g9b8b37d1b6301855213b8d4860feaeb74d464c6b Author: Martin Liska Date: Mon Jul 12 10:59:06 2021 +0200 offloading: fix -foffload hinting PR sanitizer/101425 gcc/ChangeLog: * gcc.c (check_offload_target_name): Call candidates_list_and_hint only if we have a candidate. Diff: --- gcc/gcc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/gcc.c b/gcc/gcc.c index f086dd47b91..12b3440c342 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -4001,7 +4001,6 @@ check_offload_target_name (const char *target, ptrdiff_t len) } if (!c) { - char *s; auto_vec candidates; size_t olen = strlen (OFFLOAD_TARGETS) + 1; char *cand = XALLOCAVEC (char, olen); @@ -4015,15 +4014,19 @@ 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); + { + char *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;