From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 566693951894; Wed, 16 Sep 2020 19:22:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 566693951894 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600284136; bh=y/Q+rE6qCDSiDfvnVJmJOCxJPpubTeD+IwiY1rX2JZc=; h=From:To:Subject:Date:From; b=L4OL/1pQNovYSvGgLkQzIyOB9HwqT1FPPb7pzQjccCoKFmReY6YsC3MvIQxaEPf3O h+hQscaXPT9x73ibwayd4e2LwoBlrM0/aoOM2SCnNokvwHSfsKVw21rhtMmGd4Bl4W xJJDp5tQjMYXEA2jlcD3KdP2ezBJASwbhc1Uak6g= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-8900] c++: Try to complete decomp types [PR95328] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: b78ea59edbd354fed914d0f8eb78109db7316ce8 X-Git-Newrev: 8efa945b308307fd9b0313705f5826a8499de405 Message-Id: <20200916192216.566693951894@sourceware.org> Date: Wed, 16 Sep 2020 19:22:16 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2020 19:22:16 -0000 https://gcc.gnu.org/g:8efa945b308307fd9b0313705f5826a8499de405 commit r9-8900-g8efa945b308307fd9b0313705f5826a8499de405 Author: Jakub Jelinek Date: Thu May 28 23:40:54 2020 +0200 c++: Try to complete decomp types [PR95328] Two years ago Paolo has added the else if (processing_template_decl && !COMPLETE_TYPE_P (type)) pedwarn (...); lines into cp_finish_decomp. For type dependent decl we punt much earlier, but even for types which aren't type dependent COMPLETE_TYPE_P might be false as this testcase shows, so this patch tries to complete_type first (the reason for writing it that way is that it is then followed by another else if and if complete_type returns error_mark_node, we shouldn't report anything, as a bug should have been reported already. 2020-05-28 Jakub Jelinek PR c++/95328 * decl.c (cp_finish_decomp): Call complete_type before checking COMPLETE_TYPE_P. * g++.dg/cpp1z/decomp53.C: New test. (cherry picked from commit 3d8d5ddb539a5254c7ef83414377f4c74c7701d4) Diff: --- gcc/cp/decl.c | 2 ++ gcc/testsuite/g++.dg/cpp1z/decomp53.C | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6ff9cdf0afe..ec18f87e47f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7864,6 +7864,8 @@ cp_finish_decomp (tree decl, tree first, unsigned int count) error_at (loc, "cannot decompose lambda closure type %qT", type); goto error_out; } + else if (processing_template_decl && complete_type (type) == error_mark_node) + goto error_out; else if (processing_template_decl && !COMPLETE_TYPE_P (type)) pedwarn (loc, 0, "structured binding refers to incomplete class type %qT", type); diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp53.C b/gcc/testsuite/g++.dg/cpp1z/decomp53.C new file mode 100644 index 00000000000..b34e6ac7250 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp53.C @@ -0,0 +1,22 @@ +// PR c++/95328 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template +struct S +{ + int a, b; +}; + +template +void +foo () +{ + auto [a, b] = S(); // { dg-warning "structured bindings only available with" "" { target c++14_down } } +} + +int +main () +{ + foo (); +}