From: Tom Tromey Date: Thu, 15 Jan 2026 17:38:02 +0000 (-0700) Subject: Apply [noreturn] in more places X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9af1f41efbb56d1c9b51e9a59eced8d14331ff54;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index cc0e880346d..1a7cf448ffb 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -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, diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index f397417c1bc..d175ba67941 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -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. */ diff --git a/gdb/event-top.h b/gdb/event-top.h index eb1226efec0..a7d31d56a5d 100644 --- a/gdb/event-top.h +++ b/gdb/event-top.h @@ -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. */ diff --git a/gdb/exec.h b/gdb/exec.h index 346d15e1e98..98fbfdf2512 100644 --- a/gdb/exec.h +++ b/gdb/exec.h @@ -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 */ diff --git a/gdb/extension.h b/gdb/extension.h index ee34022450d..e351b5b672e 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -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. */ diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h index b99109f6696..89586e0c6ec 100644 --- a/gdb/gdbcore.h +++ b/gdb/gdbcore.h @@ -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. */ diff --git a/gdb/infcall.h b/gdb/infcall.h index 0ac19213740..9074fecc364 100644 --- a/gdb/infcall.h +++ b/gdb/infcall.h @@ -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 */ diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index 5bea5e7b9c4..cfa9d9c111d 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -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. */ diff --git a/gdb/typeprint.h b/gdb/typeprint.h index 3bfa1432abc..36bfbd28743 100644 --- a/gdb/typeprint.h +++ b/gdb/typeprint.h @@ -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); diff --git a/gdb/utils.h b/gdb/utils.h index f11e85559cc..531fae083d7 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -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. diff --git a/gdb/value.h b/gdb/value.h index 8dc3192f637..1ef3acd6054 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -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 ()))