diff mbox

[RFA,2/3] Add missing ATTRIBUTE_NORETURNs

Message ID 1475000192-8789-3-git-send-email-tom@tromey.com
State New
Headers show

Commit Message

Tom Tromey Sept. 27, 2016, 6:16 p.m. UTC
This patch adds a couple of missing ATTRIBUTE_NORETURNs.  This lets
-Wimplicit-fallthrough recognize that a given case does not fall
through.

2016-09-27  Tom Tromey  <tom@tromey.com>

	* dwarf2loc.c (unimplemented): Add ATTRIBUTE_NORETURN.
	* completer.h (throw_max_completions_reached_error): Add
	ATTRIBUTE_NORETURN.
---
 gdb/ChangeLog   | 6 ++++++
 gdb/completer.h | 3 ++-
 gdb/dwarf2loc.c | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

Comments

Yao Qi Sept. 27, 2016, 11:30 p.m. UTC | #1
On Tue, Sep 27, 2016 at 7:16 PM, Tom Tromey <tom@tromey.com> wrote:
>  /* Wrapper to throw MAX_COMPLETIONS_REACHED_ERROR.  */
>
> -extern void throw_max_completions_reached_error (void);
> +extern void throw_max_completions_reached_error (void)
> +  ATTRIBUTE_NORETURN;
>

Don't we need to also add ATTRIBUTE_NORETURN to the definition of
throw_max_completions_reached_error?
Tom Tromey Sept. 28, 2016, 3:20 p.m. UTC | #2
>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:

>> -extern void throw_max_completions_reached_error (void);
>> +extern void throw_max_completions_reached_error (void)
>> +  ATTRIBUTE_NORETURN;

Yao> Don't we need to also add ATTRIBUTE_NORETURN to the definition of
Yao> throw_max_completions_reached_error?

No, it's sufficient to have an attribute on a prototype, if the
prototype is in scope when the definition is seen.  This seems to be the
normal approach in gdb, e.g., see error_no_arg.

Tom
Yao Qi Sept. 28, 2016, 5:39 p.m. UTC | #3
On Wed, Sep 28, 2016 at 4:20 PM, Tom Tromey <tom@tromey.com> wrote:
>>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:
>
>>> -extern void throw_max_completions_reached_error (void);
>>> +extern void throw_max_completions_reached_error (void)
>>> +  ATTRIBUTE_NORETURN;
>
> Yao> Don't we need to also add ATTRIBUTE_NORETURN to the definition of
> Yao> throw_max_completions_reached_error?
>
> No, it's sufficient to have an attribute on a prototype, if the
> prototype is in scope when the definition is seen.  This seems to be the
> normal approach in gdb, e.g., see error_no_arg.
>

Er... right.  Patch is good to me.
diff mbox

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fdd43ab..83b051f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@ 
 2016-09-27  Tom Tromey  <tom@tromey.com>
 
+	* dwarf2loc.c (unimplemented): Add ATTRIBUTE_NORETURN.
+	* completer.h (throw_max_completions_reached_error): Add
+	ATTRIBUTE_NORETURN.
+
+2016-09-27  Tom Tromey  <tom@tromey.com>
+
 	* xcoffread.c (scan_xcoff_symtab): Move comment later.
 	* symfile.c (section_is_mapped): Fix fall-through comment.
 	* stabsread.c (define_symbol, read_member_functions): Fix
diff --git a/gdb/completer.h b/gdb/completer.h
index 24bfee9..ff01f86 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -179,6 +179,7 @@  extern enum maybe_add_completion_enum
 
 /* Wrapper to throw MAX_COMPLETIONS_REACHED_ERROR.  */ 
 
-extern void throw_max_completions_reached_error (void);
+extern void throw_max_completions_reached_error (void)
+  ATTRIBUTE_NORETURN;
 
 #endif /* defined (COMPLETER_H) */
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index f9f3216..a29c9ed 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2917,7 +2917,7 @@  dwarf2_loc_desc_get_symbol_read_needs (const gdb_byte *data, size_t size,
 /* A helper function that throws an unimplemented error mentioning a
    given DWARF operator.  */
 
-static void
+static void ATTRIBUTE_NORETURN
 unimplemented (unsigned int op)
 {
   const char *name = get_DW_OP_name (op);