]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: move contracts init to contracts.cc
authorJason Merrill <jason@redhat.com>
Tue, 18 Oct 2022 20:56:06 +0000 (16:56 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 20 Oct 2022 17:33:08 +0000 (13:33 -0400)
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.

gcc/cp/contracts.cc
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/except.cc

index b1cf2875ce40c9f07c70dd9fb2252f53356c2857..0bc8305570d358af784c8d2c8cdb1754150c19a7 100644 (file)
@@ -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"
index 29d4946652588cdaff64c3526b5c8016f54af697..f011231acb33999b2c46a1d5d0051636dadc5896 100644 (file)
@@ -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);
index 1384358d0791c0024514b9fe1e9e03c67de52df2..edd57ee5d23775e608fa46ff52d8422e1eacc2f0 100644 (file)
@@ -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);
 
index c5636b5d53a78f411ffc6c4e56b0a967002511b4..2677a9b7678660aa58b88c67af7568580e8e77f4 100644 (file)
@@ -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