Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix implicit conversion warning produced by clang
@ 2016-06-14 17:56 Taras Tsugrii
  2016-06-14 19:08 ` John Baldwin
  2016-06-15  8:52 ` Yao Qi
  0 siblings, 2 replies; 4+ messages in thread
From: Taras Tsugrii @ 2016-06-14 17:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Taras Tsugrii

When compiling with clang, which is part of Xcode 7.3, following warnings
are emitted:
objcopy.c:224:50: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
static enum bfd_link_discard do_elf_stt_common = unchanged;
                             ~~~~~~~~~~~~~~~~~   ^~~~~~~~~
objcopy.c:4290:26: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
            do_elf_stt_common = elf_stt_common;
                              ~ ^~~~~~~~~~~~~~
objcopy.c:4292:26: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
            do_elf_stt_common = no_elf_stt_common;
                              ~ ^~~~~~~~~~~~~~~~~
3 errors generated.

This is risky, since essentially there is a coupling between 2 different
enum orderings. Also since by default warnings are promoted to errors
it breaks default build.

To reproduce: ./configure && make
Verified by: ./configure && make # above warnings disappear
---
 binutils/ChangeLog | 4 ++++
 binutils/objcopy.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index ff8161a..08be889 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2016-06-14  Taras Tsugrii  <taras.tsugriy@gmail.com>
+
+	* objcopy.c: Fix clang implicit conversion warning.
+
 2016-06-14  Alan Modra  <amodra@gmail.com>
 
 	* ar.c: Expand uses of bfd_my_archive.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 06fcea3..76170cb 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -221,7 +221,7 @@ static enum
 } do_debug_sections = nothing;
 
 /* Whether to generate ELF common symbols with the STT_COMMON type.  */
-static enum bfd_link_discard do_elf_stt_common = unchanged;
+static enum bfd_link_elf_stt_common do_elf_stt_common = unchanged;
 
 /* Whether to change the leading character in symbol names.  */
 static bfd_boolean change_leading_char = FALSE;
-- 
2.8.0-rc2


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

* Re: [PATCH] Fix implicit conversion warning produced by clang
  2016-06-14 17:56 [PATCH] Fix implicit conversion warning produced by clang Taras Tsugrii
@ 2016-06-14 19:08 ` John Baldwin
  2016-06-14 21:03   ` Pedro Alves
  2016-06-15  8:52 ` Yao Qi
  1 sibling, 1 reply; 4+ messages in thread
From: John Baldwin @ 2016-06-14 19:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Taras Tsugrii

On Tuesday, June 14, 2016 10:55:42 AM Taras Tsugrii wrote:
> When compiling with clang, which is part of Xcode 7.3, following warnings
> are emitted:
> objcopy.c:224:50: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
> static enum bfd_link_discard do_elf_stt_common = unchanged;
>                              ~~~~~~~~~~~~~~~~~   ^~~~~~~~~
> objcopy.c:4290:26: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
>             do_elf_stt_common = elf_stt_common;
>                               ~ ^~~~~~~~~~~~~~
> objcopy.c:4292:26: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
>             do_elf_stt_common = no_elf_stt_common;
>                               ~ ^~~~~~~~~~~~~~~~~
> 3 errors generated.
> 
> This is risky, since essentially there is a coupling between 2 different
> enum orderings. Also since by default warnings are promoted to errors
> it breaks default build.

I had the same patch in queue and just pushed it.  I have a few more patches
from clang warnings pending as well.  (I am testing with clang 3.8.0 in
FreeBSD.)  Some of clang's warnings are a bit noisy though and I haven't tried
to address the -Wunused-function spam from VEC() (I presume that GDB will
eventually switch the VEC stuff to templates which will fix that).  Also,
Some of the -Wtautological-compare warnings for things that do:

	if (foo >= 0 && foo <= bar)

where 'foo' is unsigned I haven't posted patches to "fix" as I'm not sure that
the existing code isn't more readable in its current form.

-- 
John Baldwin


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

* Re: [PATCH] Fix implicit conversion warning produced by clang
  2016-06-14 19:08 ` John Baldwin
@ 2016-06-14 21:03   ` Pedro Alves
  0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2016-06-14 21:03 UTC (permalink / raw)
  To: John Baldwin, gdb-patches; +Cc: Taras Tsugrii

On 06/14/2016 08:07 PM, John Baldwin wrote:
> Some of clang's warnings are a bit noisy though and I haven't tried
> to address the -Wunused-function spam from VEC()

For the VEC spam, see:

 https://llvm.org/bugs/show_bug.cgi?id=22712

Thanks,
Pedro Alves


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

* Re: [PATCH] Fix implicit conversion warning produced by clang
  2016-06-14 17:56 [PATCH] Fix implicit conversion warning produced by clang Taras Tsugrii
  2016-06-14 19:08 ` John Baldwin
@ 2016-06-15  8:52 ` Yao Qi
  1 sibling, 0 replies; 4+ messages in thread
From: Yao Qi @ 2016-06-15  8:52 UTC (permalink / raw)
  To: Taras Tsugrii; +Cc: gdb-patches

Hi Taras,
Thanks for the patch, but it should be sent to binutils@sourceware.org
mail list,
instead of gdb's.

On Tue, Jun 14, 2016 at 6:55 PM, Taras Tsugrii <ttsugrii@fb.com> wrote:
> diff --git a/binutils/ChangeLog b/binutils/ChangeLog
> index ff8161a..08be889 100644
> --- a/binutils/ChangeLog
> +++ b/binutils/ChangeLog
> @@ -1,3 +1,7 @@
> +2016-06-14  Taras Tsugrii  <taras.tsugriy@gmail.com>
> +
> +       * objcopy.c: Fix clang implicit conversion warning.
> +

ChangeLog entry describes "what is your change" rather than "why do you
change".

-- 
Yao (齐尧)


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

end of thread, other threads:[~2016-06-15  8:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14 17:56 [PATCH] Fix implicit conversion warning produced by clang Taras Tsugrii
2016-06-14 19:08 ` John Baldwin
2016-06-14 21:03   ` Pedro Alves
2016-06-15  8:52 ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox