public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3143] compiler: better arg type checking for selected builtins Date: Fri, 7 Oct 2022 02:15:28 +0000 (GMT) [thread overview] Message-ID: <20221007021528.25D753858C62@sourceware.org> (raw) https://gcc.gnu.org/g:8a9e92b249c9c5a5371588b1e939a90a677b4fd3 commit r13-3143-g8a9e92b249c9c5a5371588b1e939a90a677b4fd3 Author: Than McIntosh <thanm@google.com> 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:
reply other threads:[~2022-10-07 2:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221007021528.25D753858C62@sourceware.org \ --to=ian@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).