public inbox for
 help / color / mirror / Atom feed
* Go patch committed: better argument checking for builtins
@ 2022-10-07  2:15 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2022-10-07  2:15 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 308 bytes --]

This patch to the Go frontend by Than McIntosh does some better
argument type checking for some builtin functions.  This avoids a
compiler crash on cases like panic(panic("bad")).  This fixes  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1037 bytes --]

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 @@
 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/ b/gcc/go/gofrontend/
index 2492d9fe735..247ae1bba34 100644
--- a/gcc/go/gofrontend/
+++ b/gcc/go/gofrontend/
@@ -10316,7 +10316,12 @@ Builtin_call_expression::do_check_types(Gogo*)
     case BUILTIN_PANIC:
-      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"));
+        }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-07  2:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-07  2:15 Go patch committed: better argument checking for builtins Ian Lance Taylor

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).