public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-contracts] c++: move contracts init to contracts.cc
@ 2022-10-21 1:23 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-10-21 1:23 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:de497a4f4b03e13c7a1084491de7afcc923f90f1
commit de497a4f4b03e13c7a1084491de7afcc923f90f1
Author: Jason Merrill <jason@redhat.com>
Date: Tue Oct 18 16:56:06 2022 -0400
c++: move contracts init to contracts.cc
gcc/cp/ChangeLog:
* cp-tree.h (init_contract_processing): Declare.
* decl.cc (cxx_init_decl_processing): Call it.
* contracts.cc (init_contract_processing): Move from...
* except.cc (init_exception_processing): ...here.
Diff:
---
gcc/cp/cp-tree.h | 1 +
gcc/cp/contracts.cc | 23 +++++++++++++++++++++++
gcc/cp/decl.cc | 3 +++
gcc/cp/except.cc | 16 ----------------
4 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 29d49466525..f011231acb3 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7751,6 +7751,7 @@ enum contract_matching_context
cmc_override
};
+extern void init_contract_processing ();
extern tree invalidate_contract (tree);
extern tree make_postcondition_variable (cp_expr);
extern tree make_postcondition_variable (cp_expr, tree);
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index b1cf2875ce4..0bc8305570d 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -1967,4 +1967,27 @@ apply_postcondition_to_return (tree expr)
return call;
}
+/* Set up built-ins for contracts. */
+
+void
+init_contract_processing (void)
+{
+ /* std::contract_violation */
+ tree tmp = build_function_type_list (integer_type_node,
+ boolean_type_node,
+ integer_type_node,
+ const_string_type_node,
+ const_string_type_node,
+ const_string_type_node,
+ const_string_type_node,
+ const_string_type_node,
+ integer_type_node,
+ NULL_TREE);
+ on_contract_violation_fn =
+ build_cp_library_fn_ptr ("__on_contract_violation", tmp, ECF_COLD);
+ on_contract_violation_never_fn =
+ build_cp_library_fn_ptr ("__on_contract_violation", tmp,
+ ECF_COLD | ECF_NORETURN);
+}
+
#include "gt-cp-contracts.h"
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 1384358d079..edd57ee5d23 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -5025,6 +5025,9 @@ cxx_init_decl_processing (void)
if (flag_exceptions)
init_exception_processing ();
+ if (flag_contracts)
+ init_contract_processing ();
+
if (modules_p ())
init_modules (parse_in);
diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc
index c5636b5d53a..2677a9b7678 100644
--- a/gcc/cp/except.cc
+++ b/gcc/cp/except.cc
@@ -60,22 +60,6 @@ init_exception_processing (void)
&& TREE_NOTHROW (terminate_fn));
pop_nested_namespace (std_node);
- tmp = build_function_type_list (integer_type_node,
- boolean_type_node,
- integer_type_node,
- const_string_type_node,
- const_string_type_node,
- const_string_type_node,
- const_string_type_node,
- const_string_type_node,
- integer_type_node,
- NULL_TREE);
- on_contract_violation_fn =
- build_cp_library_fn_ptr ("__on_contract_violation", tmp, ECF_COLD);
- on_contract_violation_never_fn =
- build_cp_library_fn_ptr ("__on_contract_violation", tmp,
- ECF_COLD | ECF_NORETURN);
-
/* void __cxa_call_unexpected(void *); */
tmp = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
call_unexpected_fn
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-21 1:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 1:23 [gcc/devel/c++-contracts] c++: move contracts init to contracts.cc Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).