Message ID | 1632111261-18790-1-git-send-email-apinski@marvell.com |
---|---|
State | Committed |
Commit | e12f66d96fe41c8ef8a0d01b6a8394cd6bce3978 |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9FE53858434 for <patchwork@sourceware.org>; Mon, 20 Sep 2021 04:14:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9FE53858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632111296; bh=KmcfCS22UNVJA04wzMnUXOeYXUsBIfgjDNhYg1r1tRs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=LR1iOhrfQpoBE3oCUhi2iH19S82Y6gmVzc4YB+hLd7dhKxhp0xmIQrIbUkhWaP3vE iHsV9ObmtNC6PUeGtFq0sshN+Qomg7FEjLldcpOuRYcgsjUgaI4Adj+/qLxJbu5xCv XaCTixl0FGz9zU34m7apBSchXBMfIdWCaDaLUhwc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 69C2E3858D3C for <gcc-patches@gcc.gnu.org>; Mon, 20 Sep 2021 04:14:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 69C2E3858D3C Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18JLifoo021959 for <gcc-patches@gcc.gnu.org>; Sun, 19 Sep 2021 21:14:27 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3b6ascgv1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Sun, 19 Sep 2021 21:14:26 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 19 Sep 2021 21:14:24 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sun, 19 Sep 2021 21:14:24 -0700 Received: from linux.wrightpinski.org.com (unknown [10.69.242.197]) by maili.marvell.com (Postfix) with ESMTP id C07693F706C; Sun, 19 Sep 2021 21:14:24 -0700 (PDT) To: <gcc-patches@gcc.gnu.org> Subject: [PATCH] c: [PR32122] Require pointer types for computed gotos Date: Sun, 19 Sep 2021 21:14:21 -0700 Message-ID: <1632111261-18790-1-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: qe9Lh9jIl7fP9CUUYLCdZD5X9-uVIqAt X-Proofpoint-ORIG-GUID: qe9Lh9jIl7fP9CUUYLCdZD5X9-uVIqAt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-20_01,2021-09-17_02,2020-04-07_01 X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: apinski@marvell.com Cc: Andrew Pinski <apinski@marvell.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
c: [PR32122] Require pointer types for computed gotos
|
|
Commit Message
Li, Pan2 via Gcc-patches
Sept. 20, 2021, 4:14 a.m. UTC
From: Andrew Pinski <apinski@marvell.com>
So GCC has always accepted non-pointer types in computed gotos but
that was wrong based on the documentation:
Any expression of type void * is allowed.
So this fixes the problem by requiring the type to
be a pointer type.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR c/32122
gcc/c/ChangeLog:
* c-parser.c (c_parser_statement_after_labels): Pass
the c_expr instead of the tree to c_finish_goto_ptr.
* c-typeck.c (c_finish_goto_ptr): Change the second
argument type to c_expr.
* c-tree.h (c_finish_goto_ptr): Likewise.
Error out if the expression was not of a pointer type.
gcc/testsuite/ChangeLog:
* gcc.dg/comp-goto-5.c: New test.
* gcc.dg/comp-goto-6.c: New test.
---
gcc/c/c-parser.c | 2 +-
gcc/c/c-tree.h | 2 +-
gcc/c/c-typeck.c | 11 ++++++++++-
gcc/testsuite/gcc.dg/comp-goto-5.c | 11 +++++++++++
gcc/testsuite/gcc.dg/comp-goto-6.c | 6 ++++++
5 files changed, 29 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/comp-goto-5.c
create mode 100644 gcc/testsuite/gcc.dg/comp-goto-6.c
Comments
On 9/19/2021 10:14 PM, apinski--- via Gcc-patches wrote: > From: Andrew Pinski <apinski@marvell.com> > > So GCC has always accepted non-pointer types in computed gotos but > that was wrong based on the documentation: > Any expression of type void * is allowed. > > So this fixes the problem by requiring the type to > be a pointer type. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > PR c/32122 > > gcc/c/ChangeLog: > > * c-parser.c (c_parser_statement_after_labels): Pass > the c_expr instead of the tree to c_finish_goto_ptr. > * c-typeck.c (c_finish_goto_ptr): Change the second > argument type to c_expr. > * c-tree.h (c_finish_goto_ptr): Likewise. > Error out if the expression was not of a pointer type. > > gcc/testsuite/ChangeLog: > > * gcc.dg/comp-goto-5.c: New test. > * gcc.dg/comp-goto-6.c: New test. OK jeff
On Mon, Sep 20, 2021 at 09:41:03AM -0600, Jeff Law via Gcc-patches wrote: > > > On 9/19/2021 10:14 PM, apinski--- via Gcc-patches wrote: > > From: Andrew Pinski <apinski@marvell.com> > > > > So GCC has always accepted non-pointer types in computed gotos but > > that was wrong based on the documentation: > > Any expression of type void * is allowed. > > > > So this fixes the problem by requiring the type to > > be a pointer type. > > > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > > > PR c/32122 > > > > gcc/c/ChangeLog: > > > > * c-parser.c (c_parser_statement_after_labels): Pass > > the c_expr instead of the tree to c_finish_goto_ptr. > > * c-typeck.c (c_finish_goto_ptr): Change the second > > argument type to c_expr. > > * c-tree.h (c_finish_goto_ptr): Likewise. > > Error out if the expression was not of a pointer type. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.dg/comp-goto-5.c: New test. > > * gcc.dg/comp-goto-6.c: New test. > OK This change regressed: +FAIL: gcc.c-torture/compile/920826-1.c -O0 (test for excess errors) +FAIL: gcc.c-torture/compile/920826-1.c -O1 (test for excess errors) +FAIL: gcc.c-torture/compile/920826-1.c -O2 (test for excess errors) +FAIL: gcc.c-torture/compile/920826-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) +FAIL: gcc.c-torture/compile/920826-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) +FAIL: gcc.c-torture/compile/920826-1.c -O3 -g (test for excess errors) +FAIL: gcc.c-torture/compile/920826-1.c -Os (test for excess errors) +FAIL: gcc.c-torture/compile/920831-1.c -O0 (test for excess errors) +FAIL: gcc.c-torture/compile/920831-1.c -O1 (test for excess errors) +FAIL: gcc.c-torture/compile/920831-1.c -O2 (test for excess errors) +FAIL: gcc.c-torture/compile/920831-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) +FAIL: gcc.c-torture/compile/920831-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) +FAIL: gcc.c-torture/compile/920831-1.c -O3 -g (test for excess errors) +FAIL: gcc.c-torture/compile/920831-1.c -Os (test for excess errors) +FAIL: gcc.c-torture/compile/pr27863.c -O0 (test for excess errors) +FAIL: gcc.c-torture/compile/pr27863.c -O1 (test for excess errors) +FAIL: gcc.c-torture/compile/pr27863.c -O2 (test for excess errors) +FAIL: gcc.c-torture/compile/pr27863.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) +FAIL: gcc.c-torture/compile/pr27863.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) +FAIL: gcc.c-torture/compile/pr27863.c -O3 -g (test for excess errors) +FAIL: gcc.c-torture/compile/pr27863.c -Os (test for excess errors) +FAIL: gcc.c-torture/compile/pr70190.c -O0 (test for excess errors) +FAIL: gcc.c-torture/compile/pr70190.c -O1 (test for excess errors) +FAIL: gcc.c-torture/compile/pr70190.c -O2 (test for excess errors) +FAIL: gcc.c-torture/compile/pr70190.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) +FAIL: gcc.c-torture/compile/pr70190.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) +FAIL: gcc.c-torture/compile/pr70190.c -O3 -g (test for excess errors) +FAIL: gcc.c-torture/compile/pr70190.c -Os (test for excess errors) +FAIL: gcc.dg/torture/pr89135.c -O0 (test for excess errors) +FAIL: gcc.dg/torture/pr89135.c -O1 (test for excess errors) +FAIL: gcc.dg/torture/pr89135.c -O2 (test for excess errors) +FAIL: gcc.dg/torture/pr89135.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) +FAIL: gcc.dg/torture/pr89135.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) +FAIL: gcc.dg/torture/pr89135.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) +FAIL: gcc.dg/torture/pr89135.c -O3 -g (test for excess errors) +FAIL: gcc.dg/torture/pr89135.c -Os (test for excess errors) +FAIL: gcc.dg/torture/pr90071.c -O0 (test for excess errors) +FAIL: gcc.dg/torture/pr90071.c -O1 (test for excess errors) +FAIL: gcc.dg/torture/pr90071.c -O2 (test for excess errors) +FAIL: gcc.dg/torture/pr90071.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) +FAIL: gcc.dg/torture/pr90071.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) +FAIL: gcc.dg/torture/pr90071.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) +FAIL: gcc.dg/torture/pr90071.c -O3 -g (test for excess errors) +FAIL: gcc.dg/torture/pr90071.c -Os (test for excess errors) on both x86_64-linux and i686-linux. Jakub
On Wed, Sep 29, 2021 at 1:06 AM Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Mon, Sep 20, 2021 at 09:41:03AM -0600, Jeff Law via Gcc-patches wrote: > > > > > > On 9/19/2021 10:14 PM, apinski--- via Gcc-patches wrote: > > > From: Andrew Pinski <apinski@marvell.com> > > > > > > So GCC has always accepted non-pointer types in computed gotos but > > > that was wrong based on the documentation: > > > Any expression of type void * is allowed. > > > > > > So this fixes the problem by requiring the type to > > > be a pointer type. > > > > > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > > > > > PR c/32122 > > > > > > gcc/c/ChangeLog: > > > > > > * c-parser.c (c_parser_statement_after_labels): Pass > > > the c_expr instead of the tree to c_finish_goto_ptr. > > > * c-typeck.c (c_finish_goto_ptr): Change the second > > > argument type to c_expr. > > > * c-tree.h (c_finish_goto_ptr): Likewise. > > > Error out if the expression was not of a pointer type. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * gcc.dg/comp-goto-5.c: New test. > > > * gcc.dg/comp-goto-6.c: New test. > > OK > > This change regressed: > +FAIL: gcc.c-torture/compile/920826-1.c -O0 (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O1 (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O2 (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O3 -g (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -Os (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O0 (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O1 (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O2 (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O3 -g (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -Os (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O0 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O1 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O2 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O3 -g (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -Os (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O0 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O1 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O2 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O3 -g (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -Os (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O0 (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O1 (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O2 (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O3 -g (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -Os (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O0 (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O1 (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O2 (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O3 -g (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -Os (test for excess errors) > on both x86_64-linux and i686-linux. I literally just pushed the testsuite fixes for this. Thanks, Andrew > > Jakub >
On 9/29/2021 2:05 AM, Jakub Jelinek wrote: > On Mon, Sep 20, 2021 at 09:41:03AM -0600, Jeff Law via Gcc-patches wrote: >> >> On 9/19/2021 10:14 PM, apinski--- via Gcc-patches wrote: >>> From: Andrew Pinski <apinski@marvell.com> >>> >>> So GCC has always accepted non-pointer types in computed gotos but >>> that was wrong based on the documentation: >>> Any expression of type void * is allowed. >>> >>> So this fixes the problem by requiring the type to >>> be a pointer type. >>> >>> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. >>> >>> PR c/32122 >>> >>> gcc/c/ChangeLog: >>> >>> * c-parser.c (c_parser_statement_after_labels): Pass >>> the c_expr instead of the tree to c_finish_goto_ptr. >>> * c-typeck.c (c_finish_goto_ptr): Change the second >>> argument type to c_expr. >>> * c-tree.h (c_finish_goto_ptr): Likewise. >>> Error out if the expression was not of a pointer type. >>> >>> gcc/testsuite/ChangeLog: >>> >>> * gcc.dg/comp-goto-5.c: New test. >>> * gcc.dg/comp-goto-6.c: New test. >> OK > This change regressed: > +FAIL: gcc.c-torture/compile/920826-1.c -O0 (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O1 (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O2 (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -O3 -g (test for excess errors) > +FAIL: gcc.c-torture/compile/920826-1.c -Os (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O0 (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O1 (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O2 (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -O3 -g (test for excess errors) > +FAIL: gcc.c-torture/compile/920831-1.c -Os (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O0 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O1 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O2 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -O3 -g (test for excess errors) > +FAIL: gcc.c-torture/compile/pr27863.c -Os (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O0 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O1 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O2 (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -O3 -g (test for excess errors) > +FAIL: gcc.c-torture/compile/pr70190.c -Os (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O0 (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O1 (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O2 (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -O3 -g (test for excess errors) > +FAIL: gcc.dg/torture/pr89135.c -Os (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O0 (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O1 (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O2 (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -O3 -g (test for excess errors) > +FAIL: gcc.dg/torture/pr90071.c -Os (test for excess errors) And on a ton of embedded targets.... jeff
On 9/29/2021 2:08 AM, Andrew Pinski wrote: > On Wed, Sep 29, 2021 at 1:06 AM Jakub Jelinek via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: >> On Mon, Sep 20, 2021 at 09:41:03AM -0600, Jeff Law via Gcc-patches wrote: >>> >>> On 9/19/2021 10:14 PM, apinski--- via Gcc-patches wrote: >>>> From: Andrew Pinski <apinski@marvell.com> >>>> >>>> So GCC has always accepted non-pointer types in computed gotos but >>>> that was wrong based on the documentation: >>>> Any expression of type void * is allowed. >>>> >>>> So this fixes the problem by requiring the type to >>>> be a pointer type. >>>> >>>> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. >>>> >>>> PR c/32122 >>>> >>>> gcc/c/ChangeLog: >>>> >>>> * c-parser.c (c_parser_statement_after_labels): Pass >>>> the c_expr instead of the tree to c_finish_goto_ptr. >>>> * c-typeck.c (c_finish_goto_ptr): Change the second >>>> argument type to c_expr. >>>> * c-tree.h (c_finish_goto_ptr): Likewise. >>>> Error out if the expression was not of a pointer type. >>>> >>>> gcc/testsuite/ChangeLog: >>>> >>>> * gcc.dg/comp-goto-5.c: New test. >>>> * gcc.dg/comp-goto-6.c: New test. >>> OK >> This change regressed: >> +FAIL: gcc.c-torture/compile/920826-1.c -O0 (test for excess errors) >> +FAIL: gcc.c-torture/compile/920826-1.c -O1 (test for excess errors) >> +FAIL: gcc.c-torture/compile/920826-1.c -O2 (test for excess errors) >> +FAIL: gcc.c-torture/compile/920826-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) >> +FAIL: gcc.c-torture/compile/920826-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) >> +FAIL: gcc.c-torture/compile/920826-1.c -O3 -g (test for excess errors) >> +FAIL: gcc.c-torture/compile/920826-1.c -Os (test for excess errors) >> +FAIL: gcc.c-torture/compile/920831-1.c -O0 (test for excess errors) >> +FAIL: gcc.c-torture/compile/920831-1.c -O1 (test for excess errors) >> +FAIL: gcc.c-torture/compile/920831-1.c -O2 (test for excess errors) >> +FAIL: gcc.c-torture/compile/920831-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) >> +FAIL: gcc.c-torture/compile/920831-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) >> +FAIL: gcc.c-torture/compile/920831-1.c -O3 -g (test for excess errors) >> +FAIL: gcc.c-torture/compile/920831-1.c -Os (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr27863.c -O0 (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr27863.c -O1 (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr27863.c -O2 (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr27863.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr27863.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr27863.c -O3 -g (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr27863.c -Os (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr70190.c -O0 (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr70190.c -O1 (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr70190.c -O2 (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr70190.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr70190.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr70190.c -O3 -g (test for excess errors) >> +FAIL: gcc.c-torture/compile/pr70190.c -Os (test for excess errors) >> +FAIL: gcc.dg/torture/pr89135.c -O0 (test for excess errors) >> +FAIL: gcc.dg/torture/pr89135.c -O1 (test for excess errors) >> +FAIL: gcc.dg/torture/pr89135.c -O2 (test for excess errors) >> +FAIL: gcc.dg/torture/pr89135.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) >> +FAIL: gcc.dg/torture/pr89135.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) >> +FAIL: gcc.dg/torture/pr89135.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) >> +FAIL: gcc.dg/torture/pr89135.c -O3 -g (test for excess errors) >> +FAIL: gcc.dg/torture/pr89135.c -Os (test for excess errors) >> +FAIL: gcc.dg/torture/pr90071.c -O0 (test for excess errors) >> +FAIL: gcc.dg/torture/pr90071.c -O1 (test for excess errors) >> +FAIL: gcc.dg/torture/pr90071.c -O2 (test for excess errors) >> +FAIL: gcc.dg/torture/pr90071.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) >> +FAIL: gcc.dg/torture/pr90071.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors) >> +FAIL: gcc.dg/torture/pr90071.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) >> +FAIL: gcc.dg/torture/pr90071.c -O3 -g (test for excess errors) >> +FAIL: gcc.dg/torture/pr90071.c -Os (test for excess errors) >> on both x86_64-linux and i686-linux. > I literally just pushed the testsuite fixes for this. THanks. I wasn't looking forward to dealing with this on top of the threader stuff :-) jeff
On Mon, Sep 20, 2021 at 12:15 AM apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > From: Andrew Pinski <apinski@marvell.com> > > So GCC has always accepted non-pointer types in computed gotos but > that was wrong based on the documentation: > Any expression of type void * is allowed. > > So this fixes the problem by requiring the type to > be a pointer type. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > PR c/32122 > > gcc/c/ChangeLog: > > * c-parser.c (c_parser_statement_after_labels): Pass > the c_expr instead of the tree to c_finish_goto_ptr. > * c-typeck.c (c_finish_goto_ptr): Change the second > argument type to c_expr. > * c-tree.h (c_finish_goto_ptr): Likewise. > Error out if the expression was not of a pointer type. > > gcc/testsuite/ChangeLog: > > * gcc.dg/comp-goto-5.c: New test. > * gcc.dg/comp-goto-6.c: New test. > --- > gcc/c/c-parser.c | 2 +- > gcc/c/c-tree.h | 2 +- > gcc/c/c-typeck.c | 11 ++++++++++- > gcc/testsuite/gcc.dg/comp-goto-5.c | 11 +++++++++++ > gcc/testsuite/gcc.dg/comp-goto-6.c | 6 ++++++ > 5 files changed, 29 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/comp-goto-5.c > create mode 100644 gcc/testsuite/gcc.dg/comp-goto-6.c > > diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c > index fb1399e300d..bcd8a05489f 100644 > --- a/gcc/c/c-parser.c > +++ b/gcc/c/c-parser.c > @@ -6141,7 +6141,7 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, > c_parser_consume_token (parser); > val = c_parser_expression (parser); > val = convert_lvalue_to_rvalue (loc, val, false, true); > - stmt = c_finish_goto_ptr (loc, val.value); > + stmt = c_finish_goto_ptr (loc, val); > } > else > c_parser_error (parser, "expected identifier or %<*%>"); > diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h > index d50d0cb7f2d..a046c6b0926 100644 > --- a/gcc/c/c-tree.h > +++ b/gcc/c/c-tree.h > @@ -746,7 +746,7 @@ extern tree c_finish_expr_stmt (location_t, tree); > extern tree c_finish_return (location_t, tree, tree); > extern tree c_finish_bc_stmt (location_t, tree, bool); > extern tree c_finish_goto_label (location_t, tree); > -extern tree c_finish_goto_ptr (location_t, tree); > +extern tree c_finish_goto_ptr (location_t, c_expr val); > extern tree c_expr_to_decl (tree, bool *, bool *); > extern tree c_finish_omp_construct (location_t, enum tree_code, tree, tree); > extern tree c_finish_oacc_data (location_t, tree, tree); > diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c > index 49d1bb067a0..b472e448011 100644 > --- a/gcc/c/c-typeck.c > +++ b/gcc/c/c-typeck.c > @@ -10783,10 +10783,19 @@ c_finish_goto_label (location_t loc, tree label) > the GOTO. */ > > tree > -c_finish_goto_ptr (location_t loc, tree expr) > +c_finish_goto_ptr (location_t loc, c_expr val) > { > + tree expr = val.value; > tree t; > pedwarn (loc, OPT_Wpedantic, "ISO C forbids %<goto *expr;%>"); > + if (expr != error_mark_node > + && !POINTER_TYPE_P (TREE_TYPE (expr)) > + && !null_pointer_constant_p (expr)) > + { > + error_at (val.get_location (), > + "computed goto must be pointer type"); > + expr = build_zero_cst (ptr_type_node); > + } > expr = c_fully_fold (expr, false, NULL); > expr = convert (ptr_type_node, expr); > t = build1 (GOTO_EXPR, void_type_node, expr); > diff --git a/gcc/testsuite/gcc.dg/comp-goto-5.c b/gcc/testsuite/gcc.dg/comp-goto-5.c > new file mode 100644 > index 00000000000..d487729a5d4 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/comp-goto-5.c > @@ -0,0 +1,11 @@ > +/* PR c/32122 */ > +/* { dg-do compile } */ > +/* { dg-options "" } */ > + > +enum {a=1}; > +void foo() > +{ > + goto * > + a; /* { dg-error "computed goto must be pointer type" } */ > +} > + > diff --git a/gcc/testsuite/gcc.dg/comp-goto-6.c b/gcc/testsuite/gcc.dg/comp-goto-6.c > new file mode 100644 > index 00000000000..497f6cd76ca > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/comp-goto-6.c > @@ -0,0 +1,6 @@ > +/* PR c/32122 */ > +/* { dg-do compile } */ > +/* { dg-options "" } */ > +void foo(void *a) { goto *10000000; } /* { dg-error "computed goto must be pointer type" } */ > +void foo1(void *a) { goto *a; } > + > -- > 2.17.1 > Maybe add to one of the testcases a test to ensure that the cast-to-void workaround works successfully? e.g. void foo2(void *a) { goto *(void *)10000000; } /* { dg-bogus "computed goto must be pointer type" } */
On Fri, Oct 1, 2021 at 4:03 AM Eric Gallager via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Mon, Sep 20, 2021 at 12:15 AM apinski--- via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > From: Andrew Pinski <apinski@marvell.com> > > > > So GCC has always accepted non-pointer types in computed gotos but > > that was wrong based on the documentation: > > Any expression of type void * is allowed. > > > > So this fixes the problem by requiring the type to > > be a pointer type. > > > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > > > PR c/32122 > > > > gcc/c/ChangeLog: > > > > * c-parser.c (c_parser_statement_after_labels): Pass > > the c_expr instead of the tree to c_finish_goto_ptr. > > * c-typeck.c (c_finish_goto_ptr): Change the second > > argument type to c_expr. > > * c-tree.h (c_finish_goto_ptr): Likewise. > > Error out if the expression was not of a pointer type. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.dg/comp-goto-5.c: New test. > > * gcc.dg/comp-goto-6.c: New test. > > --- > > gcc/c/c-parser.c | 2 +- > > gcc/c/c-tree.h | 2 +- > > gcc/c/c-typeck.c | 11 ++++++++++- > > gcc/testsuite/gcc.dg/comp-goto-5.c | 11 +++++++++++ > > gcc/testsuite/gcc.dg/comp-goto-6.c | 6 ++++++ > > 5 files changed, 29 insertions(+), 3 deletions(-) > > create mode 100644 gcc/testsuite/gcc.dg/comp-goto-5.c > > create mode 100644 gcc/testsuite/gcc.dg/comp-goto-6.c > > > > diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c > > index fb1399e300d..bcd8a05489f 100644 > > --- a/gcc/c/c-parser.c > > +++ b/gcc/c/c-parser.c > > @@ -6141,7 +6141,7 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, > > c_parser_consume_token (parser); > > val = c_parser_expression (parser); > > val = convert_lvalue_to_rvalue (loc, val, false, true); > > - stmt = c_finish_goto_ptr (loc, val.value); > > + stmt = c_finish_goto_ptr (loc, val); > > } > > else > > c_parser_error (parser, "expected identifier or %<*%>"); > > diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h > > index d50d0cb7f2d..a046c6b0926 100644 > > --- a/gcc/c/c-tree.h > > +++ b/gcc/c/c-tree.h > > @@ -746,7 +746,7 @@ extern tree c_finish_expr_stmt (location_t, tree); > > extern tree c_finish_return (location_t, tree, tree); > > extern tree c_finish_bc_stmt (location_t, tree, bool); > > extern tree c_finish_goto_label (location_t, tree); > > -extern tree c_finish_goto_ptr (location_t, tree); > > +extern tree c_finish_goto_ptr (location_t, c_expr val); > > extern tree c_expr_to_decl (tree, bool *, bool *); > > extern tree c_finish_omp_construct (location_t, enum tree_code, tree, tree); > > extern tree c_finish_oacc_data (location_t, tree, tree); > > diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c > > index 49d1bb067a0..b472e448011 100644 > > --- a/gcc/c/c-typeck.c > > +++ b/gcc/c/c-typeck.c > > @@ -10783,10 +10783,19 @@ c_finish_goto_label (location_t loc, tree label) > > the GOTO. */ > > > > tree > > -c_finish_goto_ptr (location_t loc, tree expr) > > +c_finish_goto_ptr (location_t loc, c_expr val) > > { > > + tree expr = val.value; > > tree t; > > pedwarn (loc, OPT_Wpedantic, "ISO C forbids %<goto *expr;%>"); > > + if (expr != error_mark_node > > + && !POINTER_TYPE_P (TREE_TYPE (expr)) > > + && !null_pointer_constant_p (expr)) > > + { > > + error_at (val.get_location (), > > + "computed goto must be pointer type"); > > + expr = build_zero_cst (ptr_type_node); > > + } > > expr = c_fully_fold (expr, false, NULL); > > expr = convert (ptr_type_node, expr); > > t = build1 (GOTO_EXPR, void_type_node, expr); > > diff --git a/gcc/testsuite/gcc.dg/comp-goto-5.c b/gcc/testsuite/gcc.dg/comp-goto-5.c > > new file mode 100644 > > index 00000000000..d487729a5d4 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/comp-goto-5.c > > @@ -0,0 +1,11 @@ > > +/* PR c/32122 */ > > +/* { dg-do compile } */ > > +/* { dg-options "" } */ > > + > > +enum {a=1}; > > +void foo() > > +{ > > + goto * > > + a; /* { dg-error "computed goto must be pointer type" } */ > > +} > > + > > diff --git a/gcc/testsuite/gcc.dg/comp-goto-6.c b/gcc/testsuite/gcc.dg/comp-goto-6.c > > new file mode 100644 > > index 00000000000..497f6cd76ca > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/comp-goto-6.c > > @@ -0,0 +1,6 @@ > > +/* PR c/32122 */ > > +/* { dg-do compile } */ > > +/* { dg-options "" } */ > > +void foo(void *a) { goto *10000000; } /* { dg-error "computed goto must be pointer type" } */ > > +void foo1(void *a) { goto *a; } > > + > > -- > > 2.17.1 > > > > Maybe add to one of the testcases a test to ensure that the > cast-to-void workaround works successfully? > e.g. > void foo2(void *a) { goto *(void *)10000000; } /* { dg-bogus "computed > goto must be pointer type" } */ There actually were a few testcases which needed to be fixed up so there is no need for another one :). Thanks, Andrew
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index fb1399e300d..bcd8a05489f 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -6141,7 +6141,7 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, c_parser_consume_token (parser); val = c_parser_expression (parser); val = convert_lvalue_to_rvalue (loc, val, false, true); - stmt = c_finish_goto_ptr (loc, val.value); + stmt = c_finish_goto_ptr (loc, val); } else c_parser_error (parser, "expected identifier or %<*%>"); diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index d50d0cb7f2d..a046c6b0926 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -746,7 +746,7 @@ extern tree c_finish_expr_stmt (location_t, tree); extern tree c_finish_return (location_t, tree, tree); extern tree c_finish_bc_stmt (location_t, tree, bool); extern tree c_finish_goto_label (location_t, tree); -extern tree c_finish_goto_ptr (location_t, tree); +extern tree c_finish_goto_ptr (location_t, c_expr val); extern tree c_expr_to_decl (tree, bool *, bool *); extern tree c_finish_omp_construct (location_t, enum tree_code, tree, tree); extern tree c_finish_oacc_data (location_t, tree, tree); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 49d1bb067a0..b472e448011 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -10783,10 +10783,19 @@ c_finish_goto_label (location_t loc, tree label) the GOTO. */ tree -c_finish_goto_ptr (location_t loc, tree expr) +c_finish_goto_ptr (location_t loc, c_expr val) { + tree expr = val.value; tree t; pedwarn (loc, OPT_Wpedantic, "ISO C forbids %<goto *expr;%>"); + if (expr != error_mark_node + && !POINTER_TYPE_P (TREE_TYPE (expr)) + && !null_pointer_constant_p (expr)) + { + error_at (val.get_location (), + "computed goto must be pointer type"); + expr = build_zero_cst (ptr_type_node); + } expr = c_fully_fold (expr, false, NULL); expr = convert (ptr_type_node, expr); t = build1 (GOTO_EXPR, void_type_node, expr); diff --git a/gcc/testsuite/gcc.dg/comp-goto-5.c b/gcc/testsuite/gcc.dg/comp-goto-5.c new file mode 100644 index 00000000000..d487729a5d4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/comp-goto-5.c @@ -0,0 +1,11 @@ +/* PR c/32122 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum {a=1}; +void foo() +{ + goto * + a; /* { dg-error "computed goto must be pointer type" } */ +} + diff --git a/gcc/testsuite/gcc.dg/comp-goto-6.c b/gcc/testsuite/gcc.dg/comp-goto-6.c new file mode 100644 index 00000000000..497f6cd76ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/comp-goto-6.c @@ -0,0 +1,6 @@ +/* PR c/32122 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +void foo(void *a) { goto *10000000; } /* { dg-error "computed goto must be pointer type" } */ +void foo1(void *a) { goto *a; } +