The NON_DEPENDENT_EXPR removal exposed that is_direct_enum_init can be
called in a template context on a CONSTRUCTOR that isn't type-dependent
but whose element is.
PR c++/112515
gcc/cp/ChangeLog:
* decl.cc (is_direct_enum_init): Check type-dependence of the
single element.
gcc/testsuite/ChangeLog:
* g++.dg/template/non-dependent30.C: New test.
&& CONSTRUCTOR_NELTS (init) == 1
/* DR 2374: The single element needs to be implicitly
convertible to the underlying type of the enum. */
+ && !type_dependent_expression_p (CONSTRUCTOR_ELT (init, 0)->value)
&& can_convert_arg (ENUM_UNDERLYING_TYPE (type),
TREE_TYPE (CONSTRUCTOR_ELT (init, 0)->value),
CONSTRUCTOR_ELT (init, 0)->value,
--- /dev/null
+// PR c++/112515
+// { dg-do compile { target c++11 } }
+
+enum E : int { };
+
+template<class T>
+E f(T t) {
+ return E{t.e};
+}