if (CLASS_TYPE_P (stype) && !COMPLETE_TYPE_P (complete_type (stype)))
/* Don't complain here, we'll complain about incompleteness
when we try to initialize the variable. */;
- else if (type_uses_auto (type))
- /* We don't know the actual type yet. */;
else if (!literal_type_p (type))
{
if (DECL_DECLARED_CONSTEXPR_P (decl))
&& (DECL_INITIAL (decl) || init))
DECL_INITIALIZED_IN_CLASS_P (decl) = 1;
- /* Do auto deduction unless decl is a function or an uninstantiated
- template specialization. */
if (TREE_CODE (decl) != FUNCTION_DECL
- && !(init == NULL_TREE
- && DECL_LANG_SPECIFIC (decl)
- && DECL_TEMPLATE_INSTANTIATION (decl)
- && !DECL_TEMPLATE_INSTANTIATED (decl))
&& (auto_node = type_uses_auto (type)))
{
tree d_init;
if (init == NULL_TREE)
- gcc_assert (CLASS_PLACEHOLDER_TEMPLATE (auto_node));
+ {
+ if (DECL_LANG_SPECIFIC (decl)
+ && DECL_TEMPLATE_INSTANTIATION (decl)
+ && !DECL_TEMPLATE_INSTANTIATED (decl))
+ {
+ /* init is null because we're deferring instantiating the
+ initializer until we need it. Well, we need it now. */
+ instantiate_decl (decl, /*defer_ok*/true, /*expl*/false);
+ return;
+ }
+
+ gcc_assert (CLASS_PLACEHOLDER_TEMPLATE (auto_node));
+ }
d_init = init;
if (d_init)
{
in check_initializer. Similarly for inline static data members. */
else if (DECL_P (decl)
&& (DECL_DECLARED_CONSTEXPR_P (decl)
- || undeduced_auto_decl (decl)
|| DECL_VAR_DECLARED_INLINE_P (decl)))
;
else if (cxx_dialect >= cxx11 && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
d = DECL_CLONED_FUNCTION (d);
if (DECL_TEMPLATE_INSTANTIATED (d)
+ || TREE_TYPE (d) == error_mark_node
|| (TREE_CODE (d) == FUNCTION_DECL
&& DECL_DEFAULTED_FN (d) && DECL_INITIAL (d))
|| DECL_TEMPLATE_SPECIALIZATION (d))
// { dg-do compile { target c++17 } }
template <typename> class A;
-template <class T> struct B { static A a{T::a}; };
+template <class T> struct B {
+ static A a{T::a}; // { dg-error "int" }
+};
void foo () { B<int> a; }