aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/module.cc
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-08-17 22:37:30 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2024-08-20 17:14:20 +1000
commitc1a53d9dcf9ebf0a6b4528a8c3eae48a583f272c (patch)
tree6496a4f668186f3c5ef103261cf1ac4723ca8a37 /gcc/cp/module.cc
parent6f115a8eeea41d383dfb1bbb1af6ac9a97aee180 (diff)
downloadgcc-c1a53d9dcf9ebf0a6b4528a8c3eae48a583f272c.zip
gcc-c1a53d9dcf9ebf0a6b4528a8c3eae48a583f272c.tar.gz
gcc-c1a53d9dcf9ebf0a6b4528a8c3eae48a583f272c.tar.bz2
c++/modules: Disable streaming definitions of non-vague-linkage GMF decls [PR115020]
The error in the linked PR is caused because 'DECL_THIS_STATIC' is true for the static member function, causing the streaming code to assume that this is an internal linkage GM entity that needs to be explicitly streamed, which then on read-in gets marked as a vague linkage function (despite being non-inline) causing import_export_decl to complain. However, I don't see any reason why we should care about this: definitions in the GMF should just be emitted as per usual regardless of whether they're internal-linkage or not. Actually the only thing we care about here are header modules, since they have no TU to write definitions into. As such this patch removes these conditions from 'has_definition' and updates some comments to clarify. PR c++/115020 gcc/cp/ChangeLog: * module.cc (has_definition): Only force writing definitions for header_module_p. gcc/testsuite/ChangeLog: * g++.dg/modules/pr115020_a.C: New test. * g++.dg/modules/pr115020_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r--gcc/cp/module.cc14
1 files changed, 7 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))