public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] c++: Try to complete decomp types [PR95328]
@ 2020-09-17 17:23 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:23 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d7eff647ea25608fb78db15344f1460d352d2b50
commit d7eff647ea25608fb78db15344f1460d352d2b50
Author: Jakub Jelinek <jakub@redhat.com>
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 <jakub@redhat.com>
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 9f1444ccff6..07a6de62e22 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7813,6 +7813,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 <typename T>
+struct S
+{
+ int a, b;
+};
+
+template <typename T>
+void
+foo ()
+{
+ auto [a, b] = S<int>(); // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+}
+
+int
+main ()
+{
+ foo<int> ();
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 17:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:23 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] c++: Try to complete decomp types [PR95328] Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).