From patchwork Thu Jan 31 22:51:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1034508 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-495052-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GN7ku3n6"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43rFpW0m7jz9sDX for ; Fri, 1 Feb 2019 09:51:30 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=dHmtM+abXggBfK3+6UKnSpF+dHvEK d5vRQIMcj0YukZOZv4UgFBI3BdShbvSbTTasjY8bZ5OZd4ySnnl8VM9r07noK7NV Xy0RG0zkoQFGH74+7EEeAB6JWry8cMD2hjFjW0zkUE5Z7c2OXDJtjnHF+FIFp1fz HILw5QmE/cPfYc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=y7l0/jD4MtD2asjiEfIZmeDmAk4=; b=GN7 ku3n66VEPOQrICsazzscDPpcTOKlwlRl4Fj1eiZXt6NE+QlLf2eFhrkdXAxM3KDf 8DdhSgRua4Eko3YpXSiYaN4fLKytdjH6gYRIbCw+jB6+g6nYQTuIM6JUsScKr4gR RPH9THDQy/SVKm+MO8NM2PO7BhWC11+zAOQOYQZo= Received: (qmail 63762 invoked by alias); 31 Jan 2019 22:51:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 63752 invoked by uid 89); 31 Jan 2019 22:51:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1395 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 Jan 2019 22:51:22 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84B7E2CD80F for ; Thu, 31 Jan 2019 22:51:21 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-106.ams2.redhat.com [10.36.116.106]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 294DA5D6AA; Thu, 31 Jan 2019 22:51:21 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x0VMpIpq001958; Thu, 31 Jan 2019 23:51:19 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x0VMpHkb001957; Thu, 31 Jan 2019 23:51:17 +0100 Date: Thu, 31 Jan 2019 23:51:17 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Reject invalid GNU attribute syntax (PR c++/87175) Message-ID: <20190131225117.GO2135@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi! THe following patch rejects invalid __attribute__ syntax where one or both opening parens are missing, but it is accepted anyway. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-01-31 Jakub Jelinek PR c++/87175 * parser.c (cp_parser_gnu_attributes_opt): Set ok to false if require_open failed. * g++.dg/ext/attrib57.C: New test. Jakub --- gcc/cp/parser.c.jj 2019-01-28 23:29:40.719949614 +0100 +++ gcc/cp/parser.c 2019-01-31 10:16:22.653631278 +0100 @@ -25768,9 +25768,11 @@ cp_parser_gnu_attributes_opt (cp_parser* cp_lexer_consume_token (parser->lexer); /* Look for the two `(' tokens. */ matching_parens outer_parens; - outer_parens.require_open (parser); + if (!outer_parens.require_open (parser)) + ok = false; matching_parens inner_parens; - inner_parens.require_open (parser); + if (!inner_parens.require_open (parser)) + ok = false; /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); --- gcc/testsuite/g++.dg/ext/attrib57.C.jj 2019-01-31 10:24:25.353702392 +0100 +++ gcc/testsuite/g++.dg/ext/attrib57.C 2019-01-31 10:23:57.007170898 +0100 @@ -0,0 +1,6 @@ +// PR c++/87175 +// { dg-do compile } +// { dg-options "" } + +struct __attribute__)) foo { }; // { dg-error "expected" } +struct __attribute__()) bar { };// { dg-error "expected" }