From patchwork Tue Aug 28 22:34:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 963164 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-484636-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="v0iAqLhy"; 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 420Nqs1rzgz9rvt for ; Wed, 29 Aug 2018 08:35:17 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=Efrsyoj++tuKy1hVO2Ln0EE3g1fiO ArzgUd1E/D55X1/Mbr9Vk0RaDiEP8581/+QVXMBTTiIIAGrICjXyGmo6iL+8cgD0 QcCjVWz9A00Yp7CTJlDzl5UDoabGw8J9j2eKg7+P/WOyxnHJWHV1mOFeWnCiNx7c yHWzzGheIVarKo= 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=uPWB8o/TebXxAwX1SX3FP1qWwvg=; b=v0i AqLhyIyTXSeaNdfBjIJjJnEZ4PuImp5UJlguPZzHAqdPsk+KJd1xe/chjTFC6pID 5UR8otwEc8Q7SXKxNbexbj1gQ0uP2bIqkPzbSHs1BcWgzZdR6OiZ6U3LVTq9VHEz ekCkQIDFtSURjnAVIto4Xgu0Me6x3UhrdyJ8SC0o= Received: (qmail 31081 invoked by alias); 28 Aug 2018 22:35:06 -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 30989 invoked by uid 89); 28 Aug 2018 22:35:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS 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; Tue, 28 Aug 2018 22:35:04 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 28E6886670; Tue, 28 Aug 2018 22:35:03 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBF9F7C746; Tue, 28 Aug 2018 22:35:02 +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 w7SMZ0xa017710; Wed, 29 Aug 2018 00:35:00 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w7SMYw4a017708; Wed, 29 Aug 2018 00:34:58 +0200 Date: Wed, 29 Aug 2018 00:34:58 +0200 From: Jakub Jelinek To: Jason Merrill , Nathan Sidwell Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix structured binding range for in generic lambda inside of template (PR c++/87122) Message-ID: <20180828223458.GS2218@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! The following testcase ICEs in tsubst_decomp_names, because the earlier tsubst_expr still with processing_template_decl called just tsubst_decomp_names, but didn't arrange for DECL_VALUE_EXPR to be set on the decomp identifier decls (which cp_finish_decomp does). Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and 8.x? 2018-08-28 Jakub Jelinek PR c++/87122 * pt.c (tsubst_expr) : If processing_template_decl and decl is structured binding decl, call cp_finish_decomp. * g++.dg/cpp1z/decomp47.C: New test. Jakub --- gcc/cp/pt.c.jj 2018-08-27 17:50:43.786489511 +0200 +++ gcc/cp/pt.c 2018-08-28 11:41:52.020677695 +0200 @@ -16832,6 +16832,8 @@ tsubst_expr (tree t, tree args, tsubst_f RANGE_FOR_IVDEP (stmt) = RANGE_FOR_IVDEP (t); RANGE_FOR_UNROLL (stmt) = RANGE_FOR_UNROLL (t); finish_range_for_decl (stmt, decl, expr); + if (decomp_first && decl != error_mark_node) + cp_finish_decomp (decl, decomp_first, decomp_cnt); } else { --- gcc/testsuite/g++.dg/cpp1z/decomp47.C.jj 2018-08-28 11:56:18.587275225 +0200 +++ gcc/testsuite/g++.dg/cpp1z/decomp47.C 2018-08-28 11:59:50.858747080 +0200 @@ -0,0 +1,32 @@ +// PR c++/87122 +// { dg-do run { target c++14 } } +// { dg-options "" } + +extern "C" void abort (); +struct S { int a, b; }; +int c; + +template +void +foo () +{ + S x[4] = { { N, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; + auto f = [](auto & y) { + for (auto & [ u, v ] : y) // { dg-warning "structured bindings only available with" "" { target c++14_down } } + { + if ((u & 1) != 1 || v != u + 1 || u < N || u > 7 || (c & (1 << u)) + || &u != &y[v / 2 - 1].a || &v != &y[v / 2 - 1].b) + abort (); + c |= 1 << u; + } + }; + f (x); +} + +int +main () +{ + foo<1> (); + if (c != 0xaa) + abort (); +}