extern void mark_needed (tree);
extern bool decl_needed_p (tree);
extern void note_vague_linkage_fn (tree);
-extern void note_variable_template_instantiation (tree);
+extern void note_vague_linkage_variable (tree);
extern tree build_artificial_parm (tree, tree, tree);
extern bool possibly_inlined_p (tree);
extern int parm_index (tree);
vec_safe_push (deferred_fns, decl);
}
-/* As above, but for variable template instantiations. */
+/* As above, but for variables. */
void
-note_variable_template_instantiation (tree decl)
+note_vague_linkage_variable (tree decl)
{
vec_safe_push (pending_statics, decl);
}
DECL_INITIALIZED_P (decl) = true;
if (maybe_dup && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (maybe_dup))
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = true;
+ if (DECL_IMPLICIT_INSTANTIATION (decl)
+ || (DECL_CLASS_SCOPE_P (decl)
+ && !DECL_VTABLE_OR_VTT_P (decl)
+ && !DECL_TEMPLATE_INFO (decl)))
+ note_vague_linkage_variable (decl);
}
DECL_INITIAL (decl) = init;
if (!dyn_init)
{
set_instantiating_module (d);
if (variable_template_p (gen_tmpl))
- note_variable_template_instantiation (d);
+ note_vague_linkage_variable (d);
instantiate_body (td, args, d, false);
}
--- /dev/null
+// PR c++/112899
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi M }
+
+export module M;
+
+export struct A {
+ static constexpr int x = -1;
+};
--- /dev/null
+// PR c++/112899
+// { dg-module-do run }
+// { dg-additional-options "-fmodules-ts" }
+
+import M;
+
+int main() {
+ const int& x = A::x;
+ if (x != -1)
+ __builtin_abort();
+}
--- /dev/null
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+
+template <bool _DecOnly>
+struct __from_chars_alnum_to_val_table {
+ static inline int value = 42;
+};
+
+inline unsigned char
+__from_chars_alnum_to_val() {
+ return __from_chars_alnum_to_val_table<false>::value;
+}
+
+template <bool Foo>
+static inline int nonclass_value = 42;
+
+inline unsigned char
+get_nonclass_val() {
+ return nonclass_value<false>;
+}
--- /dev/null
+// { dg-module-do link }
+// { dg-additional-options "-fmodules-ts" }
+
+import "init-6_a.H";
+
+int main() {
+ __from_chars_alnum_to_val();
+ get_nonclass_val();
+}