From patchwork Sat Dec 23 00:34:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 852602 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-469795-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bdWEPBcq"; 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 3z3RMr5SPxz9ryQ for ; Sat, 23 Dec 2017 11:39:17 +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:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=bgfBb/IuLKO/IE+h/eD4GsEa858GVqw04+JheRqWgtjlqZP8y5 z+GYinfOxbKRpS1DaSnofljyAxAD5OGZadamPe6wpwAHPSjK0526g/w7ohhsnueK fgyr/Mccg0Hpjq+5C9Xs346dIgvczl7c8VqffQcpsuaXRwoWQLaOAry30= 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:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=K2zwG9zOsQMixeF7vyMpEDmw99w=; b=bdWEPBcq5paxIKa3jcOK kfxR/bQq0bo9lP76OGvbn60C3UfEETXL6dZuBhho4Imnccn8W+A+riOfBxHGlkzn /7JWSdO4km6YQXvyWAjsk4DKuUE17LjrwM6nuY0r+9WY/RvTPDuR9/rekz9qfJIf j6WEamWlv9XQutxcadO7TbM= Received: (qmail 106541 invoked by alias); 23 Dec 2017 00:39:09 -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 106515 invoked by uid 89); 23 Dec 2017 00:39:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=cures X-HELO: aserp2130.oracle.com Received: from aserp2130.oracle.com (HELO aserp2130.oracle.com) (141.146.126.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Dec 2017 00:39:07 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBN0bP9W038725; Sat, 23 Dec 2017 00:39:02 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2f1cnvr0hm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2017 00:39:02 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vBN0Z041032741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 23 Dec 2017 00:35:01 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vBN0YwbK027845; Sat, 23 Dec 2017 00:34:58 GMT Received: from [192.168.1.4] (/87.13.185.30) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Dec 2017 16:34:57 -0800 From: Paolo Carlini Subject: [C++ Patch] PR 78344 ("ICE on invalid c++ code (tree check: expected tree_list, have error_mark in cp_check_const_attributes, at cp/decl2.c:1347") To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell Message-ID: Date: Sat, 23 Dec 2017 01:34:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8753 signatures=668650 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712230007 X-IsSubscribed: yes Hi, in this error recovery issue cp_check_const_attributes and more generally cplus_decl_attributes have lots of troubles handling the error_mark_node returned by cp_parser_std_attribute_spec_seq, as called by cp_parser_direct_declarator. I fiddled quite a bit with these parsing facilities to eventually notice that boldly changing cp_parser_std_attribute_spec_seq to return NULL_TREE instead of error_mark_node when cp_parser_std_attribute_spec returns error_mark_node in the loop cures the bug at issue as a special case. I also noticed that in cp_parser_std_attribute_spec we are using token_pair::require_open / require_close very peculiarly, issuing a cp_parser_error when the returned bool is false instead of simply bailing out with error_mark_node and that in fact causes duplicate diagnostics about expected '(' / ')', respectively. Tested x86_64-linux. Thanks, Paolo. /////////////////////////// /cp 2017-12-22 Paolo Carlini PR c++/78344 * parser.c (cp_parser_std_attribute_spec_seq): When cp_parser_std_attribute_spec returns error_mark_node return back NULL_TREE instead of error_mark_node. * parser.c (cp_parser_std_attribute_spec): When token_pair::require_open / require_close returns false simply return error_mark_node, do not issue a duplicate cp_parser_error about expected '(' / ')', respectively. /testsuite 2017-12-22 Paolo Carlini PR c++/78344 * g++.dg/cpp0x/alignas13.C: New. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 255983) +++ cp/parser.c (working copy) @@ -25300,10 +25300,7 @@ cp_parser_std_attribute_spec (cp_parser *parser) matching_parens parens; if (!parens.require_open (parser)) - { - cp_parser_error (parser, "expected %<(%>"); - return error_mark_node; - } + return error_mark_node; cp_parser_parse_tentatively (parser); alignas_expr = cp_parser_type_id (parser); @@ -25333,10 +25330,7 @@ cp_parser_std_attribute_spec (cp_parser *parser) return error_mark_node; if (!parens.require_close (parser)) - { - cp_parser_error (parser, "expected %<)%>"); - return error_mark_node; - } + return error_mark_node; /* Build the C++-11 representation of an 'aligned' attribute. */ @@ -25367,7 +25361,7 @@ cp_parser_std_attribute_spec_seq (cp_parser *parse if (attr_spec == NULL_TREE) break; if (attr_spec == error_mark_node) - return error_mark_node; + return NULL_TREE; if (attr_last) TREE_CHAIN (attr_last) = attr_spec; Index: testsuite/g++.dg/cpp0x/alignas13.C =================================================================== --- testsuite/g++.dg/cpp0x/alignas13.C (nonexistent) +++ testsuite/g++.dg/cpp0x/alignas13.C (working copy) @@ -0,0 +1,5 @@ +// PR c++/78344 +// { dg-do compile { target c++11 } } + +alignas(double) int f alignas; // { dg-error "30:expected '\\('" } +alignas(double) int g alignas(double; // { dg-error "37:expected '\\)'" }