From patchwork Tue Mar 12 11:21:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1055337 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-497750-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="uE1MAwwb"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="ZkSrrwJf"; 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 44JXbk39F3z9s47 for ; Tue, 12 Mar 2019 22:21:18 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=x/eEvqH7S0SaAOvvjtNypA/1esm6wWkLkD3cpy/xyzfnk5z162 aOV7wCbNce3l/GmG7oKBVPP9umKoTUP/9M/u9pU25b1/9lFBDAtx2FxpyR9QsYuz 7873oKPnMx0UKMPRJv2aZ7jKrGcyhBSY10t0eL4pES+7gnhJnhl1IuYuk= 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=W+IEK83KM5eCgT4rRYVpwDRhrQE=; b=uE1MAwwblkbi1aebPi8j lgiQ+SuBEuO86pSPqzXe0drTS0QoEfzOpmsnLfRKS5omLr18rGT2uFoLDr9Pzwa9 6gAw51mNQj340N4ME9qpkp1tOPp1F5IgGtAeKj2OgD4Kyfi3AqxpHbXW9qez1b6n jEjO1vAtWwyYyQARpG/QrkQ= Received: (qmail 66498 invoked by alias); 12 Mar 2019 11:21:11 -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 66489 invoked by uid 89); 12 Mar 2019 11:21:11 -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 autolearn=ham version=3.3.1 spammy=sk:cp_pars, 9.1.0, UD:method.c, methodc 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; Tue, 12 Mar 2019 11:21:09 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2CBJ0Ei181868; Tue, 12 Mar 2019 11:21:08 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=GEQ70ig2Rbd/YrupnB8JpUMk+0jYA0zHMgo64HzWycQ=; b=ZkSrrwJfr2aBe8FJ+5mUeRSGsVt8WC6+lppesR6Je+j5XlW9BXuhZ9nwzgzCX4N0efG9 /+cLEdS19RvK5rxHLTAC7KOIUYgae+HQRT8KjAC1j0k11KsSk2iqyXMiJo3SMR+fVHd6 HVLKEc46urMVCDnHv1zoVjdj9QNqHcPn/SQXSpUvNfcBAA+6C2x63B843HYlQHBecuBx 5gGt1cJjoxN6oy0SK6zMa1I6LWtbgBzUCtx21JPoPbWoyfweSerzgGKnrLP+Cow49a7+ ftaoPeCGSZgfSxVRsf3NdSw1SRtOGbGIQ3M2uWWKwZkGIAnuQgfe5IcLP5qo7ySg74Cd vw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2r44wu3xxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Mar 2019 11:21:07 +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 x2CBL7od018213 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Mar 2019 11:21:07 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2CBL60a014779; Tue, 12 Mar 2019 11:21:06 GMT Received: from [192.168.1.4] (/79.55.91.166) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 12 Mar 2019 04:21:06 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 89571 ("[9 Regression] ICE in nothrow_spec_p, at cp/except.c:1238") Message-ID: <5c63d088-3557-ccab-fe86-e16d8787cf13@oracle.com> Date: Tue, 12 Mar 2019 12:21:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, this is just an error recovery ICE but maybe we can fix it in time for 9.1.0, like c++/89488, which is somehow related. Indeed, the problem is again a !DEFERRED_NOEXCEPT_SPEC_P gcc_assert triggering where, earlier, process_subob_fn had maybe_instantiate_noexcept returning false (in c++/89448 the assertion triggered almost immediately, when merge_exception_specifiers was called). Anyway, what we committed for c++/89488 doesn't help here because the error_mark_node assigned to *spec_p is propagated back only up to build_over_call, where mark_used returns false but isn't acted upon because of the additional && !(complain & tf_error). Thus I had the idea of simply removing the latter (by itself a bit invasive at this stage) but that leads to duplicated diagnostics because then, in cp_parser_decltype_expr, when cp_parser_postfix_expression returns error_mark_node we go on and try a full expression too, and emit the same diagnostics again. Given the above we can imagine reworking the parser, which seems to me a bit tricky at this time, or we can go back to my initial proposal for c++/89488, attached below, which doesn't set *spec_p to error_mark_node when maybe_instantiate_noexcept returns false. My rationale being that, elsewhere, we very often discard completely the return value of maybe_instantiate_noexcept, thus it doesn't seem a big deal only using it to avoid immediately calling marge_exception_specifiers and ICE. If we do this, for c++/89448 we emit the additional "cannot convert" error, which may not be a bad thing, given that we used to emit it forever, and the same do both clang and edg, thus it looks like considering that 'zl ()' not completely broken may make sense for error-recovery purposes... Tested x86_64-linux. Thanks, Paolo. /////////////////////////////// /cp 2019-03-12 Paolo Carlini PR c++/89571 * method.c (process_subob_fn): Do not set *spec_p to error_mark_node when maybe_instantiate_noexcept returns false. /testsuite 2019-03-12 Paolo Carlini PR c++/89571 * g++.dg/cpp0x/noexcept36.C: New. * g++.dg/cpp0x/nsdmi15.C: Adjust. Index: cp/method.c =================================================================== --- cp/method.c (revision 269606) +++ cp/method.c (working copy) @@ -1254,15 +1254,10 @@ process_subob_fn (tree fn, tree *spec_p, bool *tri return; } - if (spec_p) + if (spec_p && maybe_instantiate_noexcept (fn)) { - if (!maybe_instantiate_noexcept (fn)) - *spec_p = error_mark_node; - else - { - tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)); - *spec_p = merge_exception_specifiers (*spec_p, raises); - } + tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)); + *spec_p = merge_exception_specifiers (*spec_p, raises); } if (!trivial_fn_p (fn) && !dtor_from_ctor) Index: testsuite/g++.dg/cpp0x/noexcept36.C =================================================================== --- testsuite/g++.dg/cpp0x/noexcept36.C (nonexistent) +++ testsuite/g++.dg/cpp0x/noexcept36.C (working copy) @@ -0,0 +1,22 @@ +// PR c++/89571 +// { dg-do compile { target c++11 } } + +struct z8 { + constexpr static int qq /* = 0 */; // { dg-error "initializer" } +}; + +template +struct kf { + kf (const kf &) noexcept (T::qq); // { dg-error "constant" } +}; + +struct lk { + kf e1; +}; + +template +T &sc (); + +struct b6 { + decltype (lk (sc ())) zz; +}; Index: testsuite/g++.dg/cpp0x/nsdmi15.C =================================================================== --- testsuite/g++.dg/cpp0x/nsdmi15.C (revision 269606) +++ testsuite/g++.dg/cpp0x/nsdmi15.C (working copy) @@ -3,6 +3,6 @@ struct zl { struct { - int x2 = zl (); // { dg-error "default member" } + int x2 = zl (); // { dg-error "default member|cannot convert" } } fx; };