* C++ PATCH for c++/84098, ICE with lambda in template NSDMI
@ 2018-01-30 20:18 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2018-01-30 20:18 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 287 bytes --]
When instantiating the members of a class template, we don't need to
consider lambdas, as instantiating them will be handled when we get to
tsubst_lambda_expr. And now the new assert catches places we were
failing to ignore them, as here.
Tested x86_64-pc-linux-gnu, applied to trunk.
[-- Attachment #2: 84098.diff --]
[-- Type: text/plain, Size: 1819 bytes --]
commit d97240d44096258f2c5218560861631b908d1024
Author: Jason Merrill <jason@redhat.com>
Date: Mon Jan 29 17:31:42 2018 -0500
PR c++/84098 - ICE with lambda in template NSDMI.
* pt.c (instantiate_class_template_1): Ignore more lambdas.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6c5d06b9ebb..9516be893aa 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10527,6 +10527,11 @@ instantiate_class_template_1 (tree type)
{
if (TYPE_P (t))
{
+ if (LAMBDA_TYPE_P (t))
+ /* A closure type for a lambda in an NSDMI or default argument.
+ Ignore it; it will be regenerated when needed. */
+ continue;
+
/* Build new CLASSTYPE_NESTED_UTDS. */
tree newtag;
@@ -10594,11 +10599,10 @@ instantiate_class_template_1 (tree type)
&& DECL_OMP_DECLARE_REDUCTION_P (r))
cp_check_omp_declare_reduction (r);
}
- else if (DECL_CLASS_TEMPLATE_P (t)
+ else if ((DECL_CLASS_TEMPLATE_P (t) || DECL_IMPLICIT_TYPEDEF_P (t))
&& LAMBDA_TYPE_P (TREE_TYPE (t)))
- /* A closure type for a lambda in a default argument for a
- member template. Ignore it; it will be instantiated with
- the default argument. */;
+ /* A closure type for a lambda in an NSDMI or default argument.
+ Ignore it; it will be regenerated when needed. */;
else
{
/* Build new TYPE_FIELDS. */
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda19.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda19.C
new file mode 100644
index 00000000000..a16d31c59eb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda19.C
@@ -0,0 +1,13 @@
+// PR c++/84098
+// { dg-options -std=c++17 }
+
+struct A{};
+
+template < typename >
+struct Test{
+ static constexpr auto var = []{};
+};
+
+int main(){
+ (void)Test< A >::var;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-01-30 19:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-30 20:18 C++ PATCH for c++/84098, ICE with lambda in template NSDMI Jason Merrill
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).