diff mbox series

c++, contracts: Ensure return statements on checkers.

Message ID 20240617121435.78654-1-iain@sandoe.co.uk
State New
Headers show
Series c++, contracts: Ensure return statements on checkers. | expand

Commit Message

Iain Sandoe June 17, 2024, 12:14 p.m. UTC
This is a minor tidy-up, tested on x86_64-darwin,
OK For trunk?
thanks
Iain

--- 8< ---

At present, for pre-conditions and for post-conditions with a void
return, we are not emitting a return statement. This patch adds the
relevant return statements.

gcc/cp/ChangeLog:

	* contracts.cc (finish_function_contracts): Add return
	statements to pre-condition and void post-cndition
	checking functions.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 gcc/cp/contracts.cc | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 634e3cf4fa9..0822624a910 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -2052,6 +2052,7 @@  finish_function_contracts (tree fndecl)
       DECL_PENDING_INLINE_P (pre) = false;
       start_preparsed_function (pre, DECL_ATTRIBUTES (pre), flags);
       remap_and_emit_conditions (fndecl, pre, PRECONDITION_STMT);
+      finish_return_stmt (NULL_TREE);
       tree finished_pre = finish_function (false);
       expand_or_defer_fn (finished_pre);
     }
@@ -2065,6 +2066,8 @@  finish_function_contracts (tree fndecl)
       remap_and_emit_conditions (fndecl, post, POSTCONDITION_STMT);
       if (!VOID_TYPE_P (TREE_TYPE (TREE_TYPE (post))))
 	finish_return_stmt (get_postcondition_result_parameter (fndecl));
+      else
+	finish_return_stmt (NULL_TREE);
 
       tree finished_post = finish_function (false);
       expand_or_defer_fn (finished_post);