On 10/18/2017 09:07 AM, Martin Liška wrote:
@@ -1182,7 +1182,13 @@ cxx_eval_builtin_function_call (const constexpr_ctx
*ctx, tree t, tree fun,
{
new_call = build_call_array_loc (EXPR_LOCATION (t), TREE_TYPE (t),
CALL_EXPR_FN (t), nargs, args);
- error ("%q+E is not a constant expression", new_call);
+
+ /* Do not allow__builtin_unreachable in constexpr function. */
+ if (DECL_FUNCTION_CODE (fun) == BUILT_IN_UNREACHABLE
+ && EXPR_LOCATION (t) == BUILTINS_LOCATION)
+ error ("constexpr call flows off the end of the function");
+ else
+ error ("%q+E is not a constant expression", new_call);
You don't need to build new_call in the new case, since you don't use it.
Also, please adjust the comment to say that a __builtin_unreachable call
with BUILTINS_LOCATION comes from cp_maybe_instrument_return.
OK with those changes.
Jason