aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/expressions.cc
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2022-10-06 15:58:59 -0400
committerIan Lance Taylor <iant@golang.org>2022-10-06 19:15:18 -0700
commit8a9e92b249c9c5a5371588b1e939a90a677b4fd3 (patch)
treed9e43103bc474b751177b57e4a422b19a27c7bb5 /gcc/go/gofrontend/expressions.cc
parent629d04d35d819bdc26c30d215bc4ea66a74af15b (diff)
downloadgcc-8a9e92b249c9c5a5371588b1e939a90a677b4fd3.zip
gcc-8a9e92b249c9c5a5371588b1e939a90a677b4fd3.tar.gz
gcc-8a9e92b249c9c5a5371588b1e939a90a677b4fd3.tar.bz2
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
Diffstat (limited to 'gcc/go/gofrontend/expressions.cc')
-rw-r--r--gcc/go/gofrontend/expressions.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 2492d9f..247ae1b 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: