Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
Building contracts wrappers in module context caused multiple issues:
trouble matching up built-in declarations of terminate, source_location,
etc, and emitting multiple versions of the wrappers in an importing TU.
All of these are fixed by moving them out of the module, effectively into
a private module fragment.
gcc/cp/ChangeLog:
* decl2.cc (c_parse_final_cleanups): Build contract wrappers
after finish_module_processing.
---
gcc/cp/decl2.cc | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index b1723b3d305..ab68e4c4609 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -6116,17 +6116,18 @@ c_parse_final_cleanups (void)
reconsider = true;
}
- if (flag_contracts)
- {
- emit_contract_wrapper_func (/*done*/true);
- maybe_emit_violation_handler_wrappers ();
- }
-
/* All templates have been instantiated. */
at_eof = 2;
void *module_cookie = finish_module_processing (parse_in);
+ if (flag_contracts)
+ {
+ /* Keep these out of the module to avoid duplicate definitions. */
+ emit_contract_wrapper_func (/*done*/true);
+ maybe_emit_violation_handler_wrappers ();
+ }
+
lower_var_init ();
generate_mangling_aliases ();
base-commit: 431b7c2e3e9d727d206100a946af9cc2d0926e91
--
2.56.0