diff options
author | Nathan Sidwell <nathan@acm.org> | 2022-04-06 06:37:12 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2022-05-13 07:18:52 -0700 |
commit | 0ee9a62ef4b718ce7a66051f768c2bf5e1b62263 (patch) | |
tree | 9e941fa106bf0b71c2fa471b2d336215cd952e68 | |
parent | af34279921f4bb95b07c0be7fce9baeffafcb53d (diff) | |
download | gcc-0ee9a62ef4b718ce7a66051f768c2bf5e1b62263.zip gcc-0ee9a62ef4b718ce7a66051f768c2bf5e1b62263.tar.gz gcc-0ee9a62ef4b718ce7a66051f768c2bf5e1b62263.tar.bz2 |
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.
-rw-r--r-- | gcc/cp/mangle.cc | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/mod-sym-4.C | 48 |
2 files changed, 52 insertions, 1 deletions
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc index eb53e0e..75388e9 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 0000000..fbf54d0 --- /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(); +} |