From patchwork Mon Jan 15 21:58:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 861090 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-471310-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="t6s0Y3oE"; 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 3zL6gc2KqNz9s7v for ; Tue, 16 Jan 2018 08:58:50 +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=EqAXRP0xnJHLiccq+ztLMPUDFLXkW T06/BZu8EdfLu6c/aVEBlG0j7zqkE6AGxxod3tdSZwW0UNqt4YXUAd8NBA3tIcKm TOuFxJzu54p9xjPfY+e5OkaGaXpjPqGs6B3kesT4XI/w6tsrigRaBOcUiarmOWRl kad/KUJD44CXeQ= 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=gFjH5ULiwzK8RNFtTscMYAl4RUI=; b=t6s 0Y3oEps0AfDkM4Bgan/VSCKhjnvn7Jh3gTyJmRCLCgyEzt0Auk5/iOtftXkEL4+z roTA73AQtSLWOH/W9nRSU8RCcr1sbKQOfPI7xmrDrZBrfI9R3+Sw2XLg+5r/9n94 4BS1QElH8vK9OUA8Smg9CrjqDkbrZquR/zrgPGUo= Received: (qmail 51048 invoked by alias); 15 Jan 2018 21:58:44 -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 51022 invoked by uid 89); 15 Jan 2018 21:58:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= 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; Mon, 15 Jan 2018 21:58:42 +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 98C8281E04; Mon, 15 Jan 2018 21:58:41 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-22.ams2.redhat.com [10.36.117.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27FC55D70C; Mon, 15 Jan 2018 21:58:40 +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 w0FLwca5013694; Mon, 15 Jan 2018 22:58:39 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w0FLwb0o013693; Mon, 15 Jan 2018 22:58:37 +0100 Date: Mon, 15 Jan 2018 22:58:37 +0100 From: Jakub Jelinek To: Jason Merrill , Nathan Sidwell Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix checking ICE in pt.c (PR c++/83817) Message-ID: <20180115215837.GF2063@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes Hi! function in this case can be either a CALL_EXPR or AGGR_INIT_EXPR. CALL_FROM_THUNK_P macro is defined in tree.h and so knows just about the generic CALL_EXPR, and the C++ FE adds AGGR_INIT_FROM_THUNK_P macro, which is defined the same (protected_flag) except for the checking, one requires a CALL_EXPR, another one AGGR_INIT_EXPR. So, this spot seemed to do the right thing actually when doing release checking, just in non-release checking it would ICE if function is AGGR_INIT_EXPR. From the AGGR_INIT_FROM_THUNK_P flag we later on set CALL_FROM_THUNK_P when we later generate the CALL_EXPR. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-01-15 Jakub Jelinek PR c++/83817 * pt.c (tsubst_copy_and_build) : If function is AGGR_INIT_EXPR rather than CALL_EXPR, set AGGR_INIT_FROM_THUNK_P instead of CALL_FROM_THUNK_P. * g++.dg/cpp1y/pr83817.C: New test. Jakub --- gcc/cp/pt.c.jj 2018-01-11 18:58:48.365391793 +0100 +++ gcc/cp/pt.c 2018-01-15 18:32:44.433150762 +0100 @@ -17819,7 +17819,10 @@ tsubst_copy_and_build (tree t, CALL_EXPR_REVERSE_ARGS (function) = rev; if (thk) { - CALL_FROM_THUNK_P (function) = true; + if (TREE_CODE (function) == CALL_EXPR) + CALL_FROM_THUNK_P (function) = true; + else + AGGR_INIT_FROM_THUNK_P (function) = true; /* The thunk location is not interesting. */ SET_EXPR_LOCATION (function, UNKNOWN_LOCATION); } --- gcc/testsuite/g++.dg/cpp1y/pr83817.C.jj 2018-01-15 18:34:37.494143930 +0100 +++ gcc/testsuite/g++.dg/cpp1y/pr83817.C 2018-01-15 18:34:05.212145878 +0100 @@ -0,0 +1,17 @@ +// PR c++/83817 +// { dg-do compile { target c++14 } } + +struct A; +struct B { template using C = A; }; +struct D : B { struct F { typedef C E; }; }; +struct G { + struct I { I (D, A &); } h; + D::F::E &k (); + D j; + G (G &&) : h (j, k ()) {} +}; +struct N { G l; }; +typedef N (*M)(N &); +struct H { const char *o; M s; }; +N foo (N &); +H r { "", [](auto &x) { return foo (x); }};