From patchwork Mon Dec 13 08:58:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 48861 Return-Path: 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 EE57E3858409 for ; Mon, 13 Dec 2021 08:59:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE57E3858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1639385973; bh=DdGOmQf6tAtIA17acVPngKhJ4ZwgP6YmmD2H+eMbwXA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=F9MZxWRlT0tTJOjJFSmdgnwsIJ0uhdNLWX0JCw/9sovd9aJwtqBI5yh2IeTYwAvCT 0TDE61Ep35FrJxa2ZYOac+Rxo6lVUsqgZcQYDw8KJ+G8leBxXiDsRHvjJs4A3qjP3t A5hIQi4HUAWWuz623b4Nb1DhO+PsbBfE5zkljMv8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 37B6E3857C6C for ; Mon, 13 Dec 2021 08:58:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 37B6E3857C6C Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-481-4flVR4QZM8yJ9ZztwJGFwg-1; Mon, 13 Dec 2021 03:58:39 -0500 X-MC-Unique: 4flVR4QZM8yJ9ZztwJGFwg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E7C46118D; Mon, 13 Dec 2021 08:58:37 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 855E81000180; Mon, 13 Dec 2021 08:58:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1BD8wQqY684781 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 13 Dec 2021 09:58:27 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1BD8wQH2684780; Mon, 13 Dec 2021 09:58:26 +0100 Date: Mon, 13 Dec 2021 09:58:26 +0100 To: "Joseph S. Myers" , Marek Polacek Subject: [PATCH] c: Fix ICE on deferred pragma in unknown attribute arguments [PR103587] Message-ID: <20211213085826.GK2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! We ICE on the following testcase, because c_parser_balanced_token_sequence when encountering a deferred pragma will just use c_parser_consume_token which the FE doesn't allow for CPP_PRAGMA tokens (and if that wasn't the case, it could ICE on CPP_PRAGMA_EOL similarly). We don't know in what exact context the pragma appears when we don't know what those arguments semantically mean, so I think we should just skip over them, like e.g. the C++ FE does. And, I think (/[/{ vs. )/]/} from outside of the pragma shouldn't be paired with those inside of the pragma and it doesn't seem to be necessary to check that inside of the pragma line itself all the paren kinds are balanced. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2021-12-13 Jakub Jelinek PR c/103587 * c-parser.c (c_parser_balanced_token_sequence): For CPP_PRAGMA, consume the pragma and silently skip to the pragma eol. * gcc.dg/pr103587.c: New test. Jakub --- gcc/c/c-parser.c.jj 2021-12-09 15:37:27.000000000 +0100 +++ gcc/c/c-parser.c 2021-12-10 15:15:13.921471558 +0100 @@ -4846,6 +4846,11 @@ c_parser_balanced_token_sequence (c_pars case CPP_EOF: return; + case CPP_PRAGMA: + c_parser_consume_pragma (parser); + c_parser_skip_to_pragma_eol (parser, false); + break; + default: c_parser_consume_token (parser); break; --- gcc/testsuite/gcc.dg/pr103587.c.jj 2021-12-10 15:22:59.234875715 +0100 +++ gcc/testsuite/gcc.dg/pr103587.c 2021-12-10 15:18:52.196384249 +0100 @@ -0,0 +1,7 @@ +/* PR c/103587 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +[[foo::bar( +#pragma GCC ivdep +)]]; /* { dg-warning "attribute ignored" } */