diff options
author | Nathan Sidwell <nathan@acm.org> | 2022-05-09 04:51:32 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2022-05-12 03:44:59 -0700 |
commit | 78c8b0b980341f28de96da518a38bf85bbd24d98 (patch) | |
tree | 217867ee60c1cb15c1567f28bf680885ec4ce7a0 /gcc/cp/parser.cc | |
parent | 3c9364f29e7e47eb9de33f2d8843d5b00284ceca (diff) | |
download | gcc-78c8b0b980341f28de96da518a38bf85bbd24d98.zip gcc-78c8b0b980341f28de96da518a38bf85bbd24d98.tar.gz gcc-78c8b0b980341f28de96da518a38bf85bbd24d98.tar.bz2 |
c++: Support module language-decl semantics
In modules purview, one can attach a declaration to the global module
(i.e. not the named module in whence the declaration appears), using a
language declaration:
export module Foo;
extern "C++" void *operator new (std::size_t);
This implements those semantics.
gcc/cp/
* parser.cc (cp_parser_linkage_specification): Implement
global module attachment semantics.
gcc/testsuite/
* g++.dg/modules/lang-3_a.C: New.
* g++.dg/modules/lang-3_b.C: New.
* g++.dg/modules/lang-3_c.C: New.
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r-- | gcc/cp/parser.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 84f379c..8969ed0 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -16189,6 +16189,8 @@ cp_parser_linkage_specification (cp_parser* parser, tree prefix_attr) linkage = get_identifier (TREE_STRING_POINTER (linkage)); /* We're now using the new linkage. */ + unsigned saved_module = module_kind; + module_kind &= ~MK_ATTACH; push_lang_context (linkage); /* Preserve the location of the innermost linkage specification, @@ -16235,6 +16237,7 @@ cp_parser_linkage_specification (cp_parser* parser, tree prefix_attr) /* We're done with the linkage-specification. */ pop_lang_context (); + module_kind = saved_module; /* Restore location of parent linkage specification, if any. */ parser->innermost_linkage_specification_location = saved_location; |