+ forbidden from doing so. */
+ if (/* If there is no definition, we cannot instantiate the
+ template. */
+ ! pattern_defined
+ /* If it's OK to postpone instantiation, do so. */
+ || defer_ok
+ /* If this is a static data member that will be defined
+ elsewhere, we don't want to instantiate the entire data
+ member, but we do want to instantiate the initializer so that
+ we can substitute that elsewhere. */
+ || (external_p && TREE_CODE (d) == VAR_DECL))
+ {
+ /* The definition of the static data member is now required so
+ we must substitute the initializer. */
+ if (TREE_CODE (d) == VAR_DECL
+ && !DECL_INITIAL (d)
+ && DECL_INITIAL (code_pattern))
+ {
+ tree ns;
+ tree init;
+
+ ns = decl_namespace_context (d);
+ push_nested_namespace (ns);
+ push_nested_class (DECL_CONTEXT (d));
+ init = tsubst_expr (DECL_INITIAL (code_pattern),
+ args,
+ tf_error | tf_warning, NULL_TREE);
+ DECL_INITIAL (d) = init;
+ cp_finish_decl (d, init, /*asmspec_tree=*/NULL_TREE,
+ LOOKUP_ONLYCONVERTING);
+ pop_nested_class ();
+ pop_nested_namespace (ns);
+ }
+
+ /* We restore the source position here because it's used by
+ add_pending_template. */