From patchwork Wed Aug 29 09:56:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 963348 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-484666-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QaVaeHYc"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="nsVfd4NM"; 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 420gyg6zxrz9s3C for ; Wed, 29 Aug 2018 19:57:14 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=lv4R00DTn9zaQMk20Yu9kpfhnLTx6FIVOY/wzTBV5YwAP4Yjmf PTi1qSrny4pfxKTwpodnwsZDzDFpDB2LLhYyCLQ4X7IghNRaYkNSrREXlnzbVB8t G3YZZnxuStosDSR1PoHJjI9r2dDGqzB6JV6kW5l9SP1asjqiAmROafSNE= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=GZYpsiXIg5QvBP9a+ybsUYqmMnQ=; b=QaVaeHYcSQSpkTbJQ/rM CFU5N7LJIaKSn9mx+TULscXcIylUiYA1CQXC8wrOMBTFDTJ/EHJC1WydTcIpXxKo z0HSQkWx/WVkp9Gl+tvjGEEV0mBnAtrY5wErvWNr1BzcHAEyqpwJAzeAaP3AFUyN mdmM/h+lw05wCVfEMqmfwAQ= Received: (qmail 77819 invoked by alias); 29 Aug 2018 09:57:07 -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 77809 invoked by uid 89); 29 Aug 2018 09:57:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Aug 2018 09:57:05 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7T9s66n153210; Wed, 29 Aug 2018 09:57:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=gs5lTrs4/mXJnUrdzC+ATzHNlyZkRQ+GXzjdpYGGYVY=; b=nsVfd4NMYxJ2GrFhui4mKV8nnUHSooTF6eDsI7+8gMICCUnT46AKAgDR9sMQFuQH8CVF P2Q3KCCnbLATI3LSR3rnhm1pPBoQXpf3JCQeH97boo1/RFPxSfzQhamllr1Kn79aPRML Z/FXnxBtAg8UfvuRdKrLBr0jyOJgmmNQJsn1p+/uwN3uff7+ps6jWNpYf9owkPvfoezA EYJ2bpzsbEAyIUET8mrZdf75Txm7ANS1HT9739UoVas2HOWTsXTk603vh6uAafHNWMKA IO0BE6oZMw15kXXdMt6ewCE6Bfuk/ZpJS7W7fnb1GqfGADAmLGgkeipGog4BSd3rq2DI 2g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2m2xhtruu3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Aug 2018 09:57:02 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7T9v1AO027342 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Aug 2018 09:57:01 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7T9v19v004420; Wed, 29 Aug 2018 09:57:01 GMT Received: from [192.168.1.4] (/87.17.223.137) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 29 Aug 2018 02:57:00 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] Pr 85265 ("[concepts] ICE with missing identifier") Message-ID: Date: Wed, 29 Aug 2018 11:56:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, in this small error-recovery issue, we don't notice that cp_parser_identifier returns error_mark_node because the introduction-list is empty and we proceed to assign the error_mark_node to DECL_NAME (parm) to crash later in find_local_binding - in general the front-end doesn't expect to find an error_mark_node as DECL_NAME. I think we can simply add the check here too and early exit the loop in the cases at issue. I'm also consistently tweaking a bit error-recovery in the caller, cp_parser_template_introduction - note that currently nargs is never zero: due to the above slightly broken logic the vector has always at least an element (possibly with DECL_NAME == error_mark_node). Tested x86-64-linux. Thanks, Paolo. /////////////////////// /cp 2018-08-29 Paolo Carlini PR c++/85265 * parser.c (cp_parser_introduction_list): If cp_parser_identifier returns error_mark_node early exit the loop. (cp_parser_template_introduction): Improve error-recovery, remove error call about empty introduction-list. /testsuite 2018-08-29 Paolo Carlini PR c++/85265 * g++.dg/concepts/pr85265.C: New. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 263947) +++ cp/parser.c (working copy) @@ -15242,11 +15242,15 @@ cp_parser_introduction_list (cp_parser *parser) if (is_pack) cp_lexer_consume_token (parser->lexer); + tree identifier = cp_parser_identifier (parser); + if (identifier == error_mark_node) + break; + /* Build placeholder. */ tree parm = build_nt (WILDCARD_DECL); DECL_SOURCE_LOCATION (parm) = cp_lexer_peek_token (parser->lexer)->location; - DECL_NAME (parm) = cp_parser_identifier (parser); + DECL_NAME (parm) = identifier; WILDCARD_PACK_P (parm) = is_pack; vec_safe_push (introduction_vec, parm); @@ -27178,18 +27182,18 @@ cp_parser_template_introduction (cp_parser* parser matching identifiers. */ tree introduction_list = cp_parser_introduction_list (parser); + /* Look for closing brace for introduction. */ + if (!braces.require_close (parser)) + return true; + /* The introduction-list shall not be empty. */ int nargs = TREE_VEC_LENGTH (introduction_list); if (nargs == 0) { - error ("empty introduction-list"); + /* In cp_parser_introduction_list we have already issued an error. */ return true; } - /* Look for closing brace for introduction. */ - if (!braces.require_close (parser)) - return true; - if (tmpl_decl == error_mark_node) { cp_parser_name_lookup_error (parser, concept_name, tmpl_decl, NLE_NULL, Index: testsuite/g++.dg/concepts/pr85265.C =================================================================== --- testsuite/g++.dg/concepts/pr85265.C (nonexistent) +++ testsuite/g++.dg/concepts/pr85265.C (working copy) @@ -0,0 +1,6 @@ +// { dg-do compile { target c++14 } } +// { dg-additional-options "-fconcepts" } + +template concept bool C = true; + +C{} void foo(); // { dg-error "expected identifier" }