public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* many unused function warnings in gdb 7.9 on darwin
@ 2015-02-24 16:33 Jack Howarth
  2015-02-26 16:48 ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Jack Howarth @ 2015-02-24 16:33 UTC (permalink / raw)
  To: gdb

   Building the gdb 7.9 release on x86_64-apple-darwin14 produces many
warnings of the form...

remote.c:2567:1: warning: unused function
'VEC_thread_item_t_embedded_size' [-Wunused-function]
DEF_VEC_O(thread_item_t);
^
./common/vec.h:435:20: note: expanded from macro 'DEF_VEC_O'
VEC_T(T);                                                                 \
                                                                          ^
./common/vec.h:863:22: note: expanded from macro '\
DEF_VEC_FUNC_O'
static inline size_t VEC_OP (T,embedded_size)                             \
                     ^
./common/vec.h:399:22: note: expanded from macro 'VEC_OP'
#define VEC_OP(T,OP) VEC_##T##_##OP
                     ^
<scratch space>:55:1: note: expanded from here
VEC_thread_item_t_embedded_size
^

Shouldn't those VEC declarations use a wrapper to avoid them on
targets not supporting that code?
           Jack

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: many unused function warnings in gdb 7.9 on darwin
  2015-02-24 16:33 many unused function warnings in gdb 7.9 on darwin Jack Howarth
@ 2015-02-26 16:48 ` Pedro Alves
  2015-02-26 17:03   ` Jack Howarth
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2015-02-26 16:48 UTC (permalink / raw)
  To: Jack Howarth, gdb

On 02/24/2015 04:33 PM, Jack Howarth wrote:
>    Building the gdb 7.9 release on x86_64-apple-darwin14 produces many
> warnings of the form...
> 
> remote.c:2567:1: warning: unused function
> 'VEC_thread_item_t_embedded_size' [-Wunused-function]
> DEF_VEC_O(thread_item_t);
> ^
> ./common/vec.h:435:20: note: expanded from macro 'DEF_VEC_O'
> VEC_T(T);                                                                 \
>                                                                           ^
> ./common/vec.h:863:22: note: expanded from macro '\
> DEF_VEC_FUNC_O'
> static inline size_t VEC_OP (T,embedded_size)                             \
>                      ^
> ./common/vec.h:399:22: note: expanded from macro 'VEC_OP'
> #define VEC_OP(T,OP) VEC_##T##_##OP
>                      ^
> <scratch space>:55:1: note: expanded from here
> VEC_thread_item_t_embedded_size
> ^
> 
> Shouldn't those VEC declarations use a wrapper to avoid them on
> targets not supporting that code?

AFAIK, -Wunused-function is supposed to be suppressed for
"static inline" functions:

 -Wunused-function
     Warn whenever a static function is declared but not defined
     or a non-inline static function is unused. This warning is
     enabled by -Wall.

Looks like a clang bug here?

(I suspect marking the function with attribute used would
work around this.)

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: many unused function warnings in gdb 7.9 on darwin
  2015-02-26 16:48 ` Pedro Alves
@ 2015-02-26 17:03   ` Jack Howarth
  2015-02-26 19:59     ` Jack Howarth
  0 siblings, 1 reply; 6+ messages in thread
From: Jack Howarth @ 2015-02-26 17:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

Filed http://llvm.org/bugs/show_bug.cgi?id=22712 on this issue.
            Jack

On Thu, Feb 26, 2015 at 5:17 AM, Pedro Alves <palves@redhat.com> wrote:
> On 02/24/2015 04:33 PM, Jack Howarth wrote:
>>    Building the gdb 7.9 release on x86_64-apple-darwin14 produces many
>> warnings of the form...
>>
>> remote.c:2567:1: warning: unused function
>> 'VEC_thread_item_t_embedded_size' [-Wunused-function]
>> DEF_VEC_O(thread_item_t);
>> ^
>> ./common/vec.h:435:20: note: expanded from macro 'DEF_VEC_O'
>> VEC_T(T);                                                                 \
>>                                                                           ^
>> ./common/vec.h:863:22: note: expanded from macro '\
>> DEF_VEC_FUNC_O'
>> static inline size_t VEC_OP (T,embedded_size)                             \
>>                      ^
>> ./common/vec.h:399:22: note: expanded from macro 'VEC_OP'
>> #define VEC_OP(T,OP) VEC_##T##_##OP
>>                      ^
>> <scratch space>:55:1: note: expanded from here
>> VEC_thread_item_t_embedded_size
>> ^
>>
>> Shouldn't those VEC declarations use a wrapper to avoid them on
>> targets not supporting that code?
>
> AFAIK, -Wunused-function is supposed to be suppressed for
> "static inline" functions:
>
>  -Wunused-function
>      Warn whenever a static function is declared but not defined
>      or a non-inline static function is unused. This warning is
>      enabled by -Wall.
>
> Looks like a clang bug here?
>
> (I suspect marking the function with attribute used would
> work around this.)
>
> Thanks,
> Pedro Alves
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: many unused function warnings in gdb 7.9 on darwin
  2015-02-26 17:03   ` Jack Howarth
@ 2015-02-26 19:59     ` Jack Howarth
  2015-02-26 20:21       ` Paul_Koning
  0 siblings, 1 reply; 6+ messages in thread
From: Jack Howarth @ 2015-02-26 19:59 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

The clang developers have comments on this issue in
http://llvm.org/bugs/show_bug.cgi?id=22712#c1. They ask (as I did
originally) why we aren't wrapping these functions to keep them from
being declared on darwin if they aren't used.

On Thu, Feb 26, 2015 at 11:26 AM, Jack Howarth
<howarth.mailing.lists@gmail.com> wrote:
> Filed http://llvm.org/bugs/show_bug.cgi?id=22712 on this issue.
>             Jack
>
> On Thu, Feb 26, 2015 at 5:17 AM, Pedro Alves <palves@redhat.com> wrote:
>> On 02/24/2015 04:33 PM, Jack Howarth wrote:
>>>    Building the gdb 7.9 release on x86_64-apple-darwin14 produces many
>>> warnings of the form...
>>>
>>> remote.c:2567:1: warning: unused function
>>> 'VEC_thread_item_t_embedded_size' [-Wunused-function]
>>> DEF_VEC_O(thread_item_t);
>>> ^
>>> ./common/vec.h:435:20: note: expanded from macro 'DEF_VEC_O'
>>> VEC_T(T);                                                                 \
>>>                                                                           ^
>>> ./common/vec.h:863:22: note: expanded from macro '\
>>> DEF_VEC_FUNC_O'
>>> static inline size_t VEC_OP (T,embedded_size)                             \
>>>                      ^
>>> ./common/vec.h:399:22: note: expanded from macro 'VEC_OP'
>>> #define VEC_OP(T,OP) VEC_##T##_##OP
>>>                      ^
>>> <scratch space>:55:1: note: expanded from here
>>> VEC_thread_item_t_embedded_size
>>> ^
>>>
>>> Shouldn't those VEC declarations use a wrapper to avoid them on
>>> targets not supporting that code?
>>
>> AFAIK, -Wunused-function is supposed to be suppressed for
>> "static inline" functions:
>>
>>  -Wunused-function
>>      Warn whenever a static function is declared but not defined
>>      or a non-inline static function is unused. This warning is
>>      enabled by -Wall.
>>
>> Looks like a clang bug here?
>>
>> (I suspect marking the function with attribute used would
>> work around this.)
>>
>> Thanks,
>> Pedro Alves
>>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: many unused function warnings in gdb 7.9 on darwin
  2015-02-26 19:59     ` Jack Howarth
@ 2015-02-26 20:21       ` Paul_Koning
  2015-02-27  9:13         ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Paul_Koning @ 2015-02-26 20:21 UTC (permalink / raw)
  To: howarth.mailing.lists; +Cc: palves, gdb


> On Feb 26, 2015, at 2:41 PM, Jack Howarth <howarth.mailing.lists@gmail.com> wrote:
> 
> The clang developers have comments on this issue in
> http://llvm.org/bugs/show_bug.cgi?id=22712#c1. They ask (as I did
> originally) why we aren't wrapping these functions to keep them from
> being declared on darwin if they aren't used.

I can think of a good reason: they are used as cleaner replacements for macros, defined in header files.  So they are used in some files that include those headers, but not others.  That’s why GCC has that rule about not warning if the function is static inline.

	paul


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: many unused function warnings in gdb 7.9 on darwin
  2015-02-26 20:21       ` Paul_Koning
@ 2015-02-27  9:13         ` Pedro Alves
  0 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2015-02-27  9:13 UTC (permalink / raw)
  To: Paul_Koning, howarth.mailing.lists; +Cc: gdb

On 02/26/2015 07:55 PM, Paul_Koning@Dell.com wrote:
> 
>> On Feb 26, 2015, at 2:41 PM, Jack Howarth <howarth.mailing.lists@gmail.com> wrote:
>>
>> The clang developers have comments on this issue in
>> http://llvm.org/bugs/show_bug.cgi?id=22712#c1. They ask (as I did
>> originally) why we aren't wrapping these functions to keep them from
>> being declared on darwin if they aren't used.
> 
> I can think of a good reason: they are used as cleaner replacements for macros, defined in header files.  So they are used in some files that include those headers, but not others.  That’s why GCC has that rule about not warning if the function is static inline.

Right.  In this case the functions are a result of preprocessor magic
that implements a templated vector type and its methods, in C.  See it here:

 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/common/vec.h;h=41e41b5b22c9f5ec14711aac35ce4ae6bceab1e7;hb=HEAD

Now, the macros that define the static inline functions _are_ defined
in a header, but then those get expanded in the main source file,
resulting in static inline functions defined in the main source file.
I'm guessing that clang's rule of "header vs main source" is
missing that...

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-26 20:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-24 16:33 many unused function warnings in gdb 7.9 on darwin Jack Howarth
2015-02-26 16:48 ` Pedro Alves
2015-02-26 17:03   ` Jack Howarth
2015-02-26 19:59     ` Jack Howarth
2015-02-26 20:21       ` Paul_Koning
2015-02-27  9:13         ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).