public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-437] c++: Local symbols do not get module manglings
@ 2022-05-13 14:19 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2022-05-13 14:19 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0ee9a62ef4b718ce7a66051f768c2bf5e1b62263

commit r13-437-g0ee9a62ef4b718ce7a66051f768c2bf5e1b62263
Author: Nathan Sidwell <nathan@acm.org>
Date:   Wed Apr 6 06:37:12 2022 -0700

    c++: Local symbols do not get module manglings
    
    Internal-linkage entity mangling is entirely implementation defined --
    there's no ABI issue.  Let's not mangle in any module attachment to
    them, it makes the symbols unnecessarily longer.
    
            gcc/cp/
            * mangle.cc (maybe_write_module): Check external linkage.
            gcc/testsuite/
            * g++.dg/modules/mod-sym-4.C: New.

Diff:
---
 gcc/cp/mangle.cc                         |  5 +++-
 gcc/testsuite/g++.dg/modules/mod-sym-4.C | 48 ++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index eb53e0ebeb4..75388e99bfd 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -916,7 +916,10 @@ maybe_write_module (tree decl)
   if (!DECL_NAMESPACE_SCOPE_P (decl))
     return;
 
-  if (TREE_CODE (decl) == NAMESPACE_DECL && DECL_NAME (decl))
+  if (!TREE_PUBLIC (STRIP_TEMPLATE (decl)))
+    return;
+
+  if (TREE_CODE (decl) == NAMESPACE_DECL)
     return;
 
   int m = get_originating_module (decl, true);
diff --git a/gcc/testsuite/g++.dg/modules/mod-sym-4.C b/gcc/testsuite/g++.dg/modules/mod-sym-4.C
new file mode 100644
index 00000000000..fbf54d00171
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/mod-sym-4.C
@@ -0,0 +1,48 @@
+// { dg-additional-options -fmodules-ts }
+
+// internal linkage symbol mangling is unspecified, but let's try and
+// be unchanged from non-module internal mangling.
+
+export module A;
+// { dg-module-cmi A }
+
+// { dg-final { scan-assembler {_ZL6addonev:} } }
+static void addone () {}
+// { dg-final { scan-assembler {_ZL1x:} } }
+static int x = 5;
+
+namespace {
+// { dg-final { scan-assembler {_ZN12_GLOBAL__N_14frobEv:} } }
+void frob () {}
+// { dg-final { scan-assembler {_ZN12_GLOBAL__N_11yE:} } }
+int y = 2;
+struct Bill
+{
+  void F ();
+};
+// { dg-final { scan-assembler {_ZN12_GLOBAL__N_14Bill1FEv:} } }
+void Bill::F() {}
+}
+
+// { dg-final { scan-assembler {_ZL4FrobPN12_GLOBAL__N_14BillE:} } }
+static void Frob (Bill *b)
+{
+  if (b) b->F();
+}
+
+namespace N {
+// { dg-final { scan-assembler {_ZN1NL5innerEv:} } }
+static void inner() {}
+// { dg-final { scan-assembler {_ZN1NL1zE:} } }
+static int z = 3;
+}
+
+// { dg-final { scan-assembler {_ZW1A6addsixv:} } }
+void addsix ()
+{
+  Frob(nullptr);
+  frob();
+  addone();
+  void(x + y + N::z);
+  N::inner();
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-13 14:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 14:19 [gcc r13-437] c++: Local symbols do not get module manglings Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).