c++: enum in generic lambda at global scope [PR105398]
commit409edcca331296b53842c50d3b789e1b1ccc05e5
authorMarek Polacek <polacek@redhat.com>
Tue, 26 Apr 2022 20:12:58 +0000 (26 16:12 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 27 Apr 2022 17:09:05 +0000 (27 13:09 -0400)
tree864786d1a89ee3d1955c8753cd57f333f10d28a1
parent948e8e401023f6c3153f6d0c449bc5c2899ee7b7
c++: enum in generic lambda at global scope [PR105398]

We crash compiling this test since r11-7993 which changed
lookup_template_class_1 so that we only call tsubst_enum when

  !uses_template_parms (current_nonlambda_scope ())

But here current_nonlambda_scope () is the global NAMESPACE_DECL ::, which
doesn't have a type, therefore is considered type-dependent.  So we don't
call tsubst_enum, and crash in tsubst_copy/CONST_DECL because we didn't
find the e1 enumerator.

I don't think any namespace can depend on any template parameter, so
this patch tweaks uses_template_parms.

PR c++/105398

gcc/cp/ChangeLog:

* pt.cc (uses_template_parms): Return false for any NAMESPACE_DECL.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/lambda-generic-enum2.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp1y/lambda-generic-enum2.C [new file with mode: 0644]