[5/5] c++/reflection: Fix missing return before throw_exception
Commit Message
gcc/cp/ChangeLog:
* reflect.cc (eval_current_function): Add missing return.
(eval_current_class): Likewise.
---
gcc/cp/reflect.cc | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
Comments
On Tue, Apr 07, 2026 at 07:08:26PM +0800, Yang Kun wrote:
> gcc/cp/ChangeLog:
> * reflect.cc (eval_current_function): Add missing return.
> (eval_current_class): Likewise.
> ---
> gcc/cp/reflect.cc | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
> index 1f8a7800f..07dd0103e 100644
> --- a/gcc/cp/reflect.cc
> +++ b/gcc/cp/reflect.cc
> @@ -6441,8 +6441,9 @@ eval_current_function (location_t loc, const constexpr_ctx *ctx,
> tree scope = reflect_current_scope (loc, ctx, call, non_constant_p,
> "std::meta::current_function");
> if (TREE_CODE (scope) != FUNCTION_DECL)
> - throw_exception (loc, ctx, "current scope does not represent a function",
> - fun, non_constant_p, jump_target);
> + return throw_exception (loc, ctx,
> + "current scope does not represent a function",
> + fun, non_constant_p, jump_target);
> return get_reflection_raw (loc, scope);
> }
>
> @@ -6460,9 +6461,10 @@ eval_current_class (location_t loc, const constexpr_ctx *ctx,
> && TYPE_P (DECL_CONTEXT (scope)))
> scope = DECL_CONTEXT (scope);
> if (!CLASS_TYPE_P (scope))
> - throw_exception (loc, ctx, "current scope does not represent a class"
> - " nor a member function",
> - fun, non_constant_p, jump_target);
> + return throw_exception (loc, ctx,
> + "current scope does not represent a class"
> + " nor a member function",
> + fun, non_constant_p, jump_target);
> return get_reflection_raw (loc, scope);
> }
LGTM, but same legal question applies.
Jakub
@@ -6441,8 +6441,9 @@ eval_current_function (location_t loc, const constexpr_ctx *ctx,
tree scope = reflect_current_scope (loc, ctx, call, non_constant_p,
"std::meta::current_function");
if (TREE_CODE (scope) != FUNCTION_DECL)
- throw_exception (loc, ctx, "current scope does not represent a function",
- fun, non_constant_p, jump_target);
+ return throw_exception (loc, ctx,
+ "current scope does not represent a function",
+ fun, non_constant_p, jump_target);
return get_reflection_raw (loc, scope);
}
@@ -6460,9 +6461,10 @@ eval_current_class (location_t loc, const constexpr_ctx *ctx,
&& TYPE_P (DECL_CONTEXT (scope)))
scope = DECL_CONTEXT (scope);
if (!CLASS_TYPE_P (scope))
- throw_exception (loc, ctx, "current scope does not represent a class"
- " nor a member function",
- fun, non_constant_p, jump_target);
+ return throw_exception (loc, ctx,
+ "current scope does not represent a class"
+ " nor a member function",
+ fun, non_constant_p, jump_target);
return get_reflection_raw (loc, scope);
}