From patchwork Wed Jul 26 18:49:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 794094 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-459065-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="umvENQVx"; 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 3xHkfy2Dgpz9rxl for ; Thu, 27 Jul 2017 04:49:27 +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=H6W/w15j/mGKNUiKz9aFy0uyX67JjJuMyYFLW9hLpNe+jCJEGO RXGia82Gt1CNclGZ0cfucMMQmNocbenlmy6dm0Qc2Im7QmOJMN/0vEwujWZZJl2x 5cvcCHbGCfD0XClB1xVgvlkVe4qbajUJswLX+FPOXMGeAsudnZ8Iz25a0= 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=lF96RdmRDkL+CcZcFGXYR489DE8=; b=umvENQVxppVaya/XAqkB vrbM2A/qAcogKxwTylTOjQIRcKtCErEotLKFu0XL1qYzWuw4Pl8DOMJy0+TInRd9 Ws6tG/MbImGWnRLXeU3WRi7IX5cNyOwvFaTCdAQKtEXEBj+BeQY1iXkKITxP5KBg 1ncquTPvPVwK982RmpB74/0= Received: (qmail 94445 invoked by alias); 26 Jul 2017 18:49:14 -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 94407 invoked by uid 89); 26 Jul 2017 18:49:13 -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, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Jul 2017 18:49:11 +0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v6QIn9go010123 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jul 2017 18:49:09 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v6QIn8nW014185 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jul 2017 18:49:09 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v6QIn8qJ032455; Wed, 26 Jul 2017 18:49:08 GMT Received: from [192.168.1.4] (/79.53.235.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Jul 2017 11:49:08 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 71570 ("[6/7/8 regression] ICE on invalid variable capture in cxx_incomplete_type_diagnostic...") Message-ID: <56593f23-748c-fd5f-9cad-0ba3fc4118ce@oracle.com> Date: Wed, 26 Jul 2017 20:49:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, avoiding the error recovery issues noticed in the bug seems just matter of early returning error_mark_node from add_capture, like we already do a few lines below in a similar case of ill-formed capture. Tested x86_64-linux. If we are going to fix this in a simply way, maybe we could also backport to 7... Thanks, Paolo. //////////////////// /cp 2017-07-26 Paolo Carlini PR c++/71570 * lambda.c (add_capture): Early return if we cannot capture by reference. /testsuite 2017-07-26 Paolo Carlini PR c++/71570 * g++.dg/cpp0x/lambda/lambda-ice17.C: New. Index: cp/lambda.c =================================================================== --- cp/lambda.c (revision 250586) +++ cp/lambda.c (working copy) @@ -529,7 +529,10 @@ add_capture (tree lambda, tree id, tree orig_init, else if (id != this_identifier && by_reference_p) { if (!lvalue_p (initializer)) - error ("cannot capture %qE by reference", initializer); + { + error ("cannot capture %qE by reference", initializer); + return error_mark_node; + } } else { Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C (revision 0) +++ testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/71570 +// { dg-do compile { target c++11 } } + +void foo (int); + +void foo (void) +{ + [&foo] // { dg-error "cannot capture" } + { + foo (0); + }; +}