From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2116) id 25D753858C62; Fri, 7 Oct 2022 02:15:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25D753858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665108928; bh=5Qt+Sj6J3qLoffrG7P8T3TAH49NQQISlXeCN40xwa18=; h=From:To:Subject:Date:From; b=Wm7X2kIT298oLjgN7heaaQ5I8RUaGX5+ncNhKwCY7W0shpihrkIL0Yi7+Hgf54RQU MK7tzde5fTdbmZdu2WTZ0T8NSu+9yIw08v5IVKNjAVPp+yKklHZ+/+pEM7nYZ5PCJ+ x/49AuCGDkwI48sKpzghLZ+c2xtG45NsXuVmEmWE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Ian Lance Taylor To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3143] compiler: better arg type checking for selected builtins X-Act-Checkin: gcc X-Git-Author: Than McIntosh X-Git-Refname: refs/heads/master X-Git-Oldrev: 629d04d35d819bdc26c30d215bc4ea66a74af15b X-Git-Newrev: 8a9e92b249c9c5a5371588b1e939a90a677b4fd3 Message-Id: <20221007021528.25D753858C62@sourceware.org> Date: Fri, 7 Oct 2022 02:15:28 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8a9e92b249c9c5a5371588b1e939a90a677b4fd3 commit r13-3143-g8a9e92b249c9c5a5371588b1e939a90a677b4fd3 Author: Than McIntosh Date: Thu Oct 6 15:58:59 2022 -0400 compiler: better arg type checking for selected builtins Tighten up the argument type checking for Builtin_call_expression to catch erroneous cases such as panic(panic("bad"))) where an argument void type is being passed to panic/alignof/sizeof. Fixes golang/go#56071. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/439815 Diff: --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/expressions.cc | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 4793c821eba..10ed3fee67c 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -8f1a91aeff400d572857895b7f5e863ec5a4d93e +50707b4b51266166ce9bcf9de187e35760ec50f9 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 2492d9fe735..247ae1bba34 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -10316,7 +10316,12 @@ Builtin_call_expression::do_check_types(Gogo*) case BUILTIN_PANIC: case BUILTIN_SIZEOF: case BUILTIN_ALIGNOF: - this->check_one_arg(); + if (this->check_one_arg()) + { + Expression* arg = this->one_arg(); + if (arg->type()->is_void_type()) + this->report_error(_("argument to builtin has void type")); + } break; case BUILTIN_RECOVER: