diff options
author | Jason Merrill <jason@redhat.com> | 2018-01-30 14:05:12 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-01-30 14:05:12 -0500 |
commit | 8d79f003d366e17bb17a4b0a7aab01fea51ffa71 (patch) | |
tree | b3699f2a88c4d6b99ed8b84207a29f3aede1c2be /gcc | |
parent | b6019ab18c777ee68508ce0c7a289043d2f60bcd (diff) | |
download | gcc-8d79f003d366e17bb17a4b0a7aab01fea51ffa71.zip gcc-8d79f003d366e17bb17a4b0a7aab01fea51ffa71.tar.gz gcc-8d79f003d366e17bb17a4b0a7aab01fea51ffa71.tar.bz2 |
PR c++/84098 - ICE with lambda in template NSDMI.
* pt.c (instantiate_class_template_1): Ignore more lambdas.
From-SVN: r257199
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/constexpr-lambda19.C | 13 |
3 files changed, 26 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9737987..536a3e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-01-30 Jason Merrill <jason@redhat.com> + + PR c++/84098 - ICE with lambda in template NSDMI. + * pt.c (instantiate_class_template_1): Ignore more lambdas. + 2018-01-29 Jason Merrill <jason@redhat.com> PR c++/68810 - wrong location for reinterpret_cast error. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 6c5d06b..9516be8 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 0000000..a16d31c --- /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; +} |