aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/m32c
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-03-16 22:00:29 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2024-03-19 12:21:41 +1100
commitc4845edfeaf44756ad9672e8d143f1c8f5c4c0f6 (patch)
treea59c6a93508e213e51ae5f804f94578409dbb104 /gcc/config/m32c
parent23409731ca4464471d4ef456d6aee50084d00c85 (diff)
downloadgcc-c4845edfeaf44756ad9672e8d143f1c8f5c4c0f6.zip
gcc-c4845edfeaf44756ad9672e8d143f1c8f5c4c0f6.tar.gz
gcc-c4845edfeaf44756ad9672e8d143f1c8f5c4c0f6.tar.bz2
c++: Fix handling of no-linkage decls for modules
When testing the changes for PR c++/112631 we discovered that currently we don't emit definitions of block-scope function declarations if they're not used in the module interface TU, which causes issues if they are used by importers. This patch fixes the handling of no-linkage declarations for C++20. In particular, a type declared in a function with vague linkage or declared in a module CMI could potentially be accessible outside its defining TU, and as such we can't assume that function declarations using that type can never be defined in another TU. A complication with handling this is that we're only strictly interested in declarations with a module CMI, but when parsing the global module fragment we don't yet know whether or not this module will have a CMI until we reach the "export module" line (or not). Since this case is IFNDR anyway (by [basic.def.odr] p11) we just tentatively assume while parsing the GMF that this module will have a CMI; once we see (or don't see) an 'export module' declaration we can commit to that knowledge for future declarations. gcc/cp/ChangeLog: * cp-tree.h (module_maybe_has_cmi_p): New function. * decl.cc (grokfndecl): Mark block-scope functions as public if they could be visible in other TUs. * decl2.cc (no_linkage_error): Don't error for declarations that could be defined in other TUs since C++20. Suppress duplicate errors from 'check_global_declaration'. * tree.cc (no_linkage_check): In relaxed mode, don't consider types in a module CMI to have no linkage. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/linkage-1.C: New test. * g++.dg/modules/block-decl-3.h: New test. * g++.dg/modules/block-decl-3_a.C: New test. * g++.dg/modules/block-decl-3_b.C: New test. * g++.dg/modules/block-decl-3_c.C: New test. * g++.dg/modules/linkage-1_a.C: New test. * g++.dg/modules/linkage-1_b.C: New test. * g++.dg/modules/linkage-1_c.C: New test. * g++.dg/modules/linkage-2.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/config/m32c')
0 files changed, 0 insertions, 0 deletions