aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-12-09 04:52:51 -0800
committerNathan Sidwell <nathan@acm.org>2020-12-09 04:56:47 -0800
commitcf97b970fe598740ee0833729bcdce5dc3913f2d (patch)
tree4ab0ae5991d8bceef81fc69d7457c9b21fea2adf /gcc/cp/semantics.c
parent72217b5ddb2a15e2606f4b15b147dd59fe8e6216 (diff)
downloadgcc-cf97b970fe598740ee0833729bcdce5dc3913f2d.zip
gcc-cf97b970fe598740ee0833729bcdce5dc3913f2d.tar.gz
gcc-cf97b970fe598740ee0833729bcdce5dc3913f2d.tar.bz2
c++: Decl module-specific semantic processing
This adds the module-specific logic to the various declaration processing routines in decl.c and semantic.c. I also adjust the rtti type creation, as those are all in the global module, so we need to temporarily clear the module_kind, when they are being created. Finally, I added init and fini module processing with the initialier giving a fatal error if you try and turn it on (so don't do that yet). gcc/cp/ * decl.c (duplicate_decls): Add module-specific redeclaration logic. (cxx_init_decl_processing): Export the global namespace, maybe initialize modules. (start_decl): Reject local-extern in a module, adjust linkage of template var. (xref_tag_1): Add module-specific redeclaration logic. (start_enum): Likewise. (finish_enum_value_list): Export unscoped members of an exported enum. (grokmethod): Implement p1779 linkage of in-class defined functions. * decl2.c (no_linkage_error): Imports are ok. (c_parse_final_cleanups): Call fini_modules. * lex.c (cxx_dup_lang_specific): Clear some module flags in the copy. * module.cc (module_kind): Define. (module_may_redeclare, set_defining_module): Stubs. (init_modules): Error on modules. (fini_modules): Stub. * rtti.c (push_abi_namespace): Save and reset module_kind. (pop_abi_namespace): Restore module kind. (build_dynamic_cast_1, tinfo_base_init): Adjust. * semantics.c (begin_class_definition): Add module-specific logic. (expand_or_defer_fn_1): Keep bodies of more fns when modules_p.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d33ef42..92e32c8 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3220,6 +3220,19 @@ begin_class_definition (tree t)
t = make_class_type (TREE_CODE (t));
pushtag (TYPE_IDENTIFIER (t), t);
}
+
+ if (modules_p ())
+ {
+ if (!module_may_redeclare (TYPE_NAME (t)))
+ {
+ error ("cannot declare %qD in a different module", TYPE_NAME (t));
+ inform (DECL_SOURCE_LOCATION (TYPE_NAME (t)), "declared here");
+ return error_mark_node;
+ }
+ set_instantiating_module (TYPE_NAME (t));
+ set_defining_module (TYPE_NAME (t));
+ }
+
maybe_process_partial_specialization (t);
pushclass (t);
TYPE_BEING_DEFINED (t) = 1;
@@ -4506,7 +4519,8 @@ expand_or_defer_fn_1 (tree fn)
it out, even though we haven't. */
TREE_ASM_WRITTEN (fn) = 1;
/* If this is a constexpr function, keep DECL_SAVED_TREE. */
- if (!DECL_DECLARED_CONSTEXPR_P (fn))
+ if (!DECL_DECLARED_CONSTEXPR_P (fn)
+ && !(modules_p () && DECL_DECLARED_INLINE_P (fn)))
DECL_SAVED_TREE (fn) = NULL_TREE;
return false;
}