diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 3b25f956928..617bf4c68b1 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -11919,7 +11919,8 @@ has_definition (tree decl) since there's no TU to emit them in otherwise. */ return true; - if (!decl_maybe_constant_var_p (decl)) + if (!decl_maybe_constant_var_p (decl) + && !DECL_INLINE_VAR_P (decl)) return false; return true; diff --git a/gcc/testsuite/g++.dg/modules/inline-1_a.C b/gcc/testsuite/g++.dg/modules/inline-1_a.C new file mode 100644 index 00000000000..eafd450e667 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/inline-1_a.C @@ -0,0 +1,11 @@ +// { dg-additional-options -fmodules } +// { dg-module-do run } +export module M; + +inline int b = 42; +struct A +{ + static inline int a = 4200; +}; + +export inline int f() { return b+A::a; } diff --git a/gcc/testsuite/g++.dg/modules/inline-1_b.C b/gcc/testsuite/g++.dg/modules/inline-1_b.C new file mode 100644 index 00000000000..af319b16071 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/inline-1_b.C @@ -0,0 +1,8 @@ +// { dg-additional-options -fmodules } +import M; + +int main() +{ + if (f() != 4242) + __builtin_abort (); +}