Apply [noreturn] in more places

I looked at adding -Wmissing-noreturn to the warning flags.  This
resulted in too many false reports, IMO, so I am not planning to
submit it.

However, it did point out a few spots that legitimately should have
[[noreturn]].

In making this patch, my criterion was to mark up a function whose
contract is that it always throws an exception.  I did not include
functions that just happen to always throw (e.g.,
default_infcall_mmap).  That is, this patch uses the attribute as a
form of documentation and not really for its code-generation
application.

Tested by rebuilding.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey
2026-01-15 10:38:02 -07:00
parent 5a7e61beb2
commit 9af1f41efb
11 changed files with 14 additions and 12 deletions

View File

@@ -50,8 +50,8 @@ extern ULONGEST get_ulongest (const char **pp, int trailer = '\0');
/* Throws an error telling the user that ARGS starts with an option
unrecognized by COMMAND. */
extern void report_unrecognized_option_error (const char *command,
const char *args);
[[noreturn]] extern void report_unrecognized_option_error (const char *command,
const char *args);
/* Builds the help string for a command documented by PREFIX,

View File

@@ -273,7 +273,7 @@ extern int dwarf_reg_to_regnum_or_error (struct gdbarch *arch,
/* Helper function which throws an error if a synthetic pointer is
invalid. */
extern void invalid_synthetic_pointer ();
[[noreturn]] extern void invalid_synthetic_pointer ();
/* Fetch the value pointed to by a synthetic pointer. */

View File

@@ -64,7 +64,7 @@ extern void set_force_quit_flag ();
/* Control C eventually causes this to be called, at a convenient time. */
extern void quit ();
[[noreturn]] extern void quit ();
/* Helper for the QUIT macro. */

View File

@@ -108,6 +108,6 @@ extern void try_open_exec_file (const char *exec_file_host,
/* Report a "No executable file specified" error. */
extern void no_executable_specified_error ();
[[noreturn]] extern void no_executable_specified_error ();
#endif /* GDB_EXEC_H */

View File

@@ -247,7 +247,7 @@ extern int ext_lang_present_p (const struct extension_language_defn *);
extern int ext_lang_initialized_p (const struct extension_language_defn *);
extern void throw_ext_lang_unsupported
[[noreturn]] extern void throw_ext_lang_unsupported
(const struct extension_language_defn *);
/* Accessors for "public" attributes of the extension language definition. */

View File

@@ -35,7 +35,8 @@ extern int have_core_file_p (void);
/* Report a memory error with error(). */
extern void memory_error (enum target_xfer_status status, CORE_ADDR memaddr);
[[noreturn]] extern void memory_error (enum target_xfer_status status,
CORE_ADDR memaddr);
/* The string 'memory_error' would use as exception message. */

View File

@@ -69,6 +69,7 @@ extern struct value *
function to be included in the error message; may be NULL, in which
case the error message doesn't include a function name. */
extern void error_call_unknown_return_type (const char *func_name);
[[noreturn]] extern void error_call_unknown_return_type
(const char *func_name);
#endif /* GDB_INFCALL_H */

View File

@@ -270,7 +270,7 @@ struct parser_state : public expr_builder
/* Function called from the various parsers' yyerror functions to throw
an error. The error will include a message identifying the location
of the error within the current expression. */
void parse_error (const char *msg);
[[noreturn]] void parse_error (const char *msg);
/* If this is nonzero, this block is used as the lexical context for
symbol names. */

View File

@@ -207,7 +207,7 @@ void type_print_unknown_return_type (struct ui_file *stream);
/* Throw an error indicating that the user tried to use a symbol that
has unknown type. SYM_PRINT_NAME is the name of the symbol, to be
included in the error message. */
extern void error_unknown_type (const char *sym_print_name);
[[noreturn]] extern void error_unknown_type (const char *sym_print_name);
extern void val_print_not_allocated (struct ui_file *stream);

View File

@@ -327,7 +327,7 @@ extern void warn_cant_dump_core (const char *reason);
/* Dump core trying to increase the core soft limit to hard limit
first. */
extern void dump_core (void);
[[noreturn]] extern void dump_core ();
/* Copy NBITS bits from SOURCE to DEST starting at the given bit
offsets. Use the bit order as specified by BITS_BIG_ENDIAN.

View File

@@ -977,7 +977,7 @@ struct lval_funcs
/* Throw an error complaining that the value has been optimized
out. */
extern void error_value_optimized_out (void);
[[noreturn]] extern void error_value_optimized_out ();
/* Pointer to internal variable. */
#define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ()))