From 2635ac76e8aeec35ca8e71af70eb838d99df1510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Tue, 5 May 2026 12:16:25 +0200 Subject: [PATCH] common : fix missing-noreturn warnings when compiling with clang 21 (#22702) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit common/arg.cpp:3719:9: error: function 'operator()' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn] 3719 | [](common_params & /*params*/, int /*value*/) { | ^ common/arg.cpp:3726:9: error: function 'operator()' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn] 3726 | [](common_params & /*params*/, int /*value*/) { | ^ common/arg.cpp:3733:9: error: function 'operator()' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn] 3733 | [](common_params & /*params*/, int /*value*/) { | ^ common/arg.cpp:3740:9: error: function 'operator()' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn] 3740 | [](common_params & /*params*/, int /*value*/) { | ^ common/arg.cpp:3747:9: error: function 'operator()' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn] 3747 | [](common_params & /*params*/, int /*value*/) { | ^ Signed-off-by: Adrien Gallouët --- common/arg.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/arg.cpp b/common/arg.cpp index a5951a7df..55ec9389b 100644 --- a/common/arg.cpp +++ b/common/arg.cpp @@ -427,6 +427,10 @@ static bool parse_bool_value(const std::string & value) { } } +[[noreturn]] static void arg_removed(const std::string & msg) { + throw std::invalid_argument("the argument has been removed. " + msg); +} + // // CLI argument parsing functions // @@ -3717,35 +3721,35 @@ common_params_context common_params_parser_init(common_params & params, llama_ex {"--draft", "--draft-n", "--draft-max"}, "N", "the argument has been removed. use --spec-draft-n-max or --spec-ngram-mod-n-max", [](common_params & /*params*/, int /*value*/) { - throw std::invalid_argument("the argument has been removed. use --spec-draft-n-max or --spec-ngram-mod-n-max"); + arg_removed("use --spec-draft-n-max or --spec-ngram-mod-n-max"); } ).set_spec().set_examples({LLAMA_EXAMPLE_SPECULATIVE, LLAMA_EXAMPLE_LOOKUP, LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_DRAFT_MAX")); add_opt(common_arg( {"--draft-min", "--draft-n-min"}, "N", "the argument has been removed. use --spec-draft-n-min or --spec-ngram-mod-n-min", [](common_params & /*params*/, int /*value*/) { - throw std::invalid_argument("the argument has been removed. use --spec-draft-n-min or --spec-ngram-mod-n-min"); + arg_removed("use --spec-draft-n-min or --spec-ngram-mod-n-min"); } ).set_spec().set_examples({LLAMA_EXAMPLE_SPECULATIVE, LLAMA_EXAMPLE_LOOKUP, LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_DRAFT_MIN")); add_opt(common_arg( {"--spec-ngram-size-n"}, "N", "the argument has been removed. use the respective --spec-ngram-*-size-n or --spec-ngram-mod-n-match", [](common_params & /*params*/, int /*value*/) { - throw std::invalid_argument("the argument has been removed. use the respective --spec-ngram-*-size-n"); + arg_removed("use the respective --spec-ngram-*-size-n"); } ).set_spec().set_examples({LLAMA_EXAMPLE_SERVER})); add_opt(common_arg( {"--spec-ngram-size-m"}, "N", "the argument has been removed. use the respective --spec-ngram-*-size-m", [](common_params & /*params*/, int /*value*/) { - throw std::invalid_argument("the argument has been removed. use the respective --spec-ngram-*-size-m"); + arg_removed("use the respective --spec-ngram-*-size-m"); } ).set_spec().set_examples({LLAMA_EXAMPLE_SERVER})); add_opt(common_arg( {"--spec-ngram-min-hits"}, "N", "the argument has been removed. use the respective --spec-ngram-*-min-hits", [](common_params & /*params*/, int /*value*/) { - throw std::invalid_argument("the argument has been removed. use the respective --spec-ngram-*-min-hits"); + arg_removed("use the respective --spec-ngram-*-min-hits"); } ).set_spec().set_examples({LLAMA_EXAMPLE_SERVER}));