Files
gcc-reflection/gcc/testsuite/g++.dg/cpp1y/lambda-generic-enum2.C
Marek Polacek 409edcca33 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.
2022-04-27 13:09:05 -04:00

16 lines
268 B
C

// PR c++/105398
// { dg-do compile { target c++14 } }
auto f = [](auto &&m) {
enum E { _,e3,e2,e1,C4,C3,C2,C1 };
static constexpr int x_coeffs[3][4] = {
{e1,C2,C3,C4},
{e2,C1,C3,C4},
{e3,C1,C2,C4},
};
};
int main() {
f(0);
}