From patchwork Fri Oct 7 02:15:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp82205wrs; Thu, 6 Oct 2022 19:16:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ERb4MdSCd+nJ5F7Kiwv6WzYANLbM7akuMnPblLUh4HdkpOJzMA2MU98vVDJOLGwzELvRl X-Received: by 2002:a17:906:8a46:b0:781:7171:74d0 with SMTP id gx6-20020a1709068a4600b00781717174d0mr2262753ejc.214.1665108998111; Thu, 06 Oct 2022 19:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665108998; cv=none; d=google.com; s=arc-20160816; b=ia1M6/xX7jcT0LHHSdbkaAl+cRYYFaqDGXlr4LA78V2odIxYMpPXmy1JUzz35tcjqI cj2a2uPfWJhxBsqSlUL4z0465JH2U7cuq2bfM2rKEdmo2sLvAHbUNKnckjy80ji9wPZj t7etxgvx2H3M/uG3p82krKYZ5nVHKuyc60GmEpQS9qJieL0Gv8yMqsGbh0gdbF7WBBqe vfZHHaf13xB1LoGV/bxLyUd8a82Sc5p/527YbpB1LGNoz2emrPFd58hPgGeqjarHgUkn p3epU7sm+/ugzsS3Z80Ej7+OL/AN+r83LKTFdDSUoijRfAg/qkyV0P4bDNLOPMYVA2B6 /ElQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=Vgzt0frZ9k5TyPgf+dwkqEcdtZAj/zA6/N0rWEy0zDs=; b=yK0/21po3CcCEWnPvRCmuryUUuPtHTEl/+CqLDy5MEQ8UG4m9FPB6KaRwe2QgaD2g8 LplX3iNFcZkvao7tPBkXjALUZ9hSkf6+ByJkGi3XpveSDljwLYEivXNFkaE/MGbo9qdj tGpcdyN4pqP7J7cYZN1KmFH5TWlRHu1K2CokHDAB++GnEidrTdcHV2hvz3dNDCwKgBSL G8fRz853EdMNga1VWmTwti79S2oRqPajhFmCLBhdYaIIOe7d+F3NeKPcbqzs50f1IBRI LHsTnopf4iwQG7zR5lhjzt5vdVtBGUrkaTMKYvgILO4e50J2Ex1YPaRVrtxX7RgUH3qO rdig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=La3xrBa0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i10-20020a1709064fca00b007879f5efba7si1177910ejw.872.2022.10.06.19.16.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 19:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=La3xrBa0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1C0D93857C69 for ; Fri, 7 Oct 2022 02:16:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C0D93857C69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665108997; bh=Vgzt0frZ9k5TyPgf+dwkqEcdtZAj/zA6/N0rWEy0zDs=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=La3xrBa0FcIUfpiNOn3oH0dXfBB0wvnbQ8iX8sjQQShVhbUanlzX9o3xPimIRe+Vm nGxq83XIMliTAcc+DLmag5X94fMYKQEEYq/HfOXRRPnlPb0tK6iNqrenedEFAyBsBo cm9Al0ridY2zA7s5XOF5f246yKM1CBqsJsBFqIT8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id B570B3858C62 for ; Fri, 7 Oct 2022 02:15:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B570B3858C62 Received: by mail-pf1-x42e.google.com with SMTP id i6so3729171pfb.2 for ; Thu, 06 Oct 2022 19:15:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Vgzt0frZ9k5TyPgf+dwkqEcdtZAj/zA6/N0rWEy0zDs=; b=d/dOIWYkkQ1Z7tuSYUB5JCQFY364hPMMa1be5XchVOAblj/kO8NeU6qjP6kGUB3Zxb 1Ykp6JSrY0GS63mvhmYW8VRuY9ITvatas2T1uiT5I1Ia6xDarPo4lLX9bRk4Lbx4ROx2 4NvjGsLIijAunxuoUZaHBTV/kAIoTPsAqERgY7PbGwghaQ83mNgZO/v/Ab99jG9cZvnx h5Z6F0/yNQDUpY7puydvmKVwZkmt7qm9vwn2XUFbaacrfehl4HJ+wpjCYm/mKw2drE/b YfDnD0YdbcMpc7QPwwCTdU3ZlPsfw0XoYaW8RhHA7dFAj3+yn0Ho2cfVERqZG9qC3kz+ HbZA== X-Gm-Message-State: ACrzQf1nIbSryCiDLmESQkNe6jbgUyz4t37VKTkkNGOmpAMe1tk6t9wz 5eOSUEdbYnc5Omy6DlffsolFoJdxvC1GmM5PViRYCM+ZZaICqA== X-Received: by 2002:a05:6a00:806:b0:561:41d2:609 with SMTP id m6-20020a056a00080600b0056141d20609mr2535086pfk.62.1665108951120; Thu, 06 Oct 2022 19:15:51 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 6 Oct 2022 19:15:39 -0700 Message-ID: Subject: Go patch committed: better argument checking for builtins To: gcc-patches , gofrontend-dev X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Lance Taylor via Gcc-patches From: Ian Lance Taylor Reply-To: Ian Lance Taylor Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745993332655602881?= X-GMAIL-MSGID: =?utf-8?q?1745993332655602881?= 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 https://go.dev/issue/56071. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 05c581aef882b3a6369acde2d37a437ef144705c 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: