diff options
-rw-r--r-- | gcc/cp/module.cc | 14 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/pr115020_a.C | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/pr115020_b.C | 10 |
3 files changed, 27 insertions, 7 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index ce0ba69..7c42aea 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -11790,10 +11790,9 @@ has_definition (tree decl) if (DECL_DECLARED_INLINE_P (decl)) return true; - if (DECL_THIS_STATIC (decl) - && (header_module_p () - || (!DECL_LANG_SPECIFIC (decl) || !DECL_MODULE_PURVIEW_P (decl)))) - /* GM static function. */ + if (header_module_p ()) + /* We always need to write definitions in header modules, + since there's no TU to emit them in otherwise. */ return true; if (DECL_TEMPLATE_INFO (decl)) @@ -11826,11 +11825,12 @@ has_definition (tree decl) else { if (!DECL_INITIALIZED_P (decl)) + /* Not defined. */ return false; - if (header_module_p () - || (!DECL_LANG_SPECIFIC (decl) || !DECL_MODULE_PURVIEW_P (decl))) - /* GM static variable. */ + if (header_module_p ()) + /* We always need to write definitions in header modules, + since there's no TU to emit them in otherwise. */ return true; if (!TREE_CONSTANT (decl)) diff --git a/gcc/testsuite/g++.dg/modules/pr115020_a.C b/gcc/testsuite/g++.dg/modules/pr115020_a.C new file mode 100644 index 0000000..8c190f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/pr115020_a.C @@ -0,0 +1,10 @@ +// PR c++/115020 +// { dg-additional-options "-fmodules-ts -Wno-global-module" } +// { dg-module-cmi M:a } + +module; +struct Check { static void assertion(); }; +void Check::assertion() {} + +module M:a; +Check c; diff --git a/gcc/testsuite/g++.dg/modules/pr115020_b.C b/gcc/testsuite/g++.dg/modules/pr115020_b.C new file mode 100644 index 0000000..e299454 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/pr115020_b.C @@ -0,0 +1,10 @@ +// PR c++/115020 +// { dg-additional-options "-fmodules-ts -Wno-global-module" } +// { dg-module-cmi M } + +module; +struct Check { static void assertion(); }; + +export module M; +import :a; +void foo() { Check::assertion(); } |