8sa1-gcc/gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda3.C
Jason Merrill 0f50f6daa1 c++: tree walk into TYPENAME_TYPE.
While looking at 92583/92654 it occurred to me that typename types needed
the same fix.  So extract_locals_r also needs to see the TYPE_CONTEXT of a
TYPENAME_TYPE.  But it must not look through a typedef.

Most tree walking in the front end wants to walk through the syntactic form
of a type of expression, and doesn't care about the type referred to by a
typedef.  But min_vis_r does care.

gcc/cp/ChangeLog
2020-05-11  Jason Merrill  <jason@redhat.com>

	PR c++/92583
	PR c++/92654
	* tree.c (cp_walk_subtrees): Stop at typedefs.
	Handle TYPENAME_TYPE here.
	* pt.c (find_parameter_packs_r): Not here.
	(for_each_template_parm_r): Clear *walk_subtrees.
	* decl2.c (min_vis_r): Look through typedefs.
2020-05-11 16:18:11 -04:00

26 lines
665 B
C

// PR c++/92583
// { dg-do compile { target c++17 } }
template <int> struct a {
constexpr operator int() { return 42; }
};
template <typename> using b = int;
template <typename d, d> struct e {};
template <typename d, d g> using h = e<d, __integer_pack(g)...>;
template <typename j, typename k, k... index> void apply(j f, e<k, index...>) {
(f(a<index>{}), ...);
}
template <auto l, typename j> void m(j f) {
using k = b<decltype(l)>;
using n = h<k, l>;
apply(f, n{});
}
template <int, int c> void o() {
auto p = [](auto i) {
if constexpr (a<i>{}) ;
if constexpr (typename a<i>::t{}); // { dg-error "" }
};
m<c>(p);
}
auto q() { o<0, 1>; }