if (DECL_EXPLICIT_INSTANTIATION (decl)
&& !DECL_EXTERNAL (decl))
setup_explicit_instantiation_definition_linkage (decl);
- if (DECL_IMPLICIT_INSTANTIATION (decl)
- || (DECL_EXPLICIT_INSTANTIATION (decl)
- && !DECL_EXTERNAL (decl))
- || (DECL_CLASS_SCOPE_P (decl)
- && !DECL_VTABLE_OR_VTT_P (decl)
- && !DECL_TEMPLATE_INFO (decl)))
+ /* Class static data members are handled in read_class_def. */
+ if (!DECL_CLASS_SCOPE_P (decl)
+ && (DECL_IMPLICIT_INSTANTIATION (decl)
+ || (DECL_EXPLICIT_INSTANTIATION (decl)
+ && !DECL_EXTERNAL (decl))))
note_vague_linkage_variable (decl);
}
if (!dyn_init)
DECL_ACCESS (d) = tree_cons (type, access, list);
}
}
+
+ if (TREE_CODE (decl) == VAR_DECL
+ && TREE_CODE (maybe_template) != TEMPLATE_DECL)
+ note_vague_linkage_variable (decl);
}
}
--- /dev/null
+// PR c++/122421
+// { dg-additional-options "-fmodules" }
+// { dg-module-cmi M }
+
+export module M;
+
+export template <typename T> struct Type {
+ static const int arr[3];
+};
+
+extern template const int Type<double>::arr[3];
+template <typename T> const int Type<T>::arr[] = { 42, 43, 44 };
+
+export Type<int> ti;
--- /dev/null
+// PR c++/122421
+// { dg-additional-options "-fmodules" }
+
+import M;
+
+int main() {
+ const int& a = Type<int>::arr[0];
+ const int& b = Type<double>::arr[0];
+}
+
+// { dg-final { scan-assembler {_ZNW1M4TypeIiE3arrE:} } }
+// { dg-final { scan-assembler-not {_ZNW1M4TypeIdE3arrE:} } }