diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 3b25f9569280f784360f3c97fea1d8e7f467af0b..617bf4c68b1876ef93e0cab2765e0a7922a4d90b 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 0000000000000000000000000000000000000000..eafd450e6677dfea9465552dbf464bbd24fbcd5a --- /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 0000000000000000000000000000000000000000..af319b16071087eceb183e714d8942ef5abd2596 --- /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 (); +}