public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, Yao Qi <qiyaoltc@gmail.com>,
		Simon Marchi <simon.marchi@ericsson.com>,
		"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH 0/5] Remove a few hurdles of compiling with clang
Date: Mon, 12 Jun 2017 16:55:00 -0000	[thread overview]
Message-ID: <CA+=Sn1m85ZmRY8H85bvq1wi8faYZjrQBoMGjDhc4rLqs70p1UQ@mail.gmail.com> (raw)
In-Reply-To: <5a3de5613db0492e91585ab8497bb3d3@polymtl.ca>

On Mon, Jun 12, 2017 at 9:44 AM, Simon Marchi <simon.marchi@polymtl.ca> wrote:
> On 2017-06-12 18:23, Andrew Pinski wrote:
>>
>> On Mon, Jun 12, 2017 at 8:54 AM, Simon Marchi <simon.marchi@polymtl.ca>
>> wrote:
>>>
>>>  - gdb: Pass -x c++ to the compiler: GCC (and even the Intel compiler)
>>> supports this option too, at worst it's a neutral change for compiling
>>> with
>>> GCC.
>>
>>
>> Why is this needed?  Why can't you use clang++ or similar to force
>> compiling as C++?
>
>
> Sorry for being unclear.  I do use clang++ and it complains:
>
> $ clang++ test.c
> clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior
> is deprecated
>
> So using -x c++ is the only way I found to make it work (short of renaming
> the files).

Why is it deprecated?  I don't see a reason for that.


>
>>>  - gdb: Use -Werror when checking for (un)supported warning flags: it
>>> just
>>> forces the behavior to what's already the default with GCC.  Again, it's
>>> neutral at worst, at best it protects us if GCC ever decides to change
>>> its
>>> default behavior.
>>
>>
>>
>> Yes I think this is ok because gcc also does not warn about
>> unsupported warning flags unless there is an error.
>
>
> Hmm that's not what I observe:
>
> $ gcc test.c
> $ gcc test.c -Wfoo
> gcc: error: unrecognized command line option ‘-Wfoo’

Oh right GCC does error out about the positive case, it is the
negative case -Wno-foo it does not error out for.

>
>
>>>  - gdb: Add -Wno-mismatched-tags: We already have a system that tests
>>> which
>>> warning flags are supported by the current compiler, so this flag will
>>> not
>>> be included in the builds with GCC.  So it's neutral for GCC, and
>>> improves
>>> the situation for Clang with almost no effort.
>>
>>
>> This warning is a bug in clang and really should not be warned about
>> in either -Wall or -Wextra.  I have been complaining about this since
>> clang added this option.
>
>
>
>>>
>>>  - linux-low: Remove usage of "register" keyword: That's a good legacy
>>> code
>>> cleanup in any case, IMHO.
>>
>>
>> Yes and no.  I don't think register was deprecated in C++11.
>
>
> From what I understand, the register keyword has more or less no effect on
> compilers today, so it would be pretty much useless.  So we can remove it
> and we don't really care.

I am saying clang is broken here to some extend.  It is warning about
something which is not deprecated.  The fix is correct just I am
saying clang's warning is not correct.

>
>>>
>>>  - Add ATTRIBUTE_PRINTF to trace_start_error: It's actually a legit
>>> warning,
>>> I'm surprised GCC itself doesn't warn about that.
>>
>>
>> This warning does not make sense.  Can you give some more context?
>
>
> Sure, the actual error is:
>
> /home/emaisin/src/binutils-gdb/gdb/gdbserver/../nat/fork-inferior.c:582:13:
> error: format string is not a string literal [-Werror,-Wformat-nonliteral]
>   vwarning (fmt, ap);
>             ^~~
> 1 error generated.
>
> That code is at:
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/nat/fork-inferior.c;h=0913409e6dd01e78019e85068f2e34e8e744ec5b;hb=HEAD#l575
>
> The vwarning function is itself marked with ATTRIBUTE_PRINTF:
>
>  31 extern void vwarning (const char *fmt, va_list args)
>  32      ATTRIBUTE_PRINTF (1, 0);
>
> So it makes sense (I think) to complain that the value passed to fmt is not
> a literal, unless that value is also marked as being a format string.  Then
> it pushes the requirement of passing a literal to the caller.

Oh, the warning is a bit weird and worded incorrectly for this case.
the fix is correct though.

Thanks,
Andrew


>
> Simon

  reply	other threads:[~2017-06-12 16:55 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-10 19:58 Simon Marchi
2017-06-10 19:58 ` [PATCH 4/5] linux-low: Remove usage of "register" keyword Simon Marchi
2017-06-10 19:58 ` [PATCH 1/5] gdb: Pass -x c++ to the compiler Simon Marchi
2017-06-10 19:58 ` [PATCH 5/5] Add ATTRIBUTE_PRINTF to trace_start_error Simon Marchi
2017-06-14 19:49   ` Sergio Durigan Junior
2017-06-10 19:58 ` [PATCH 3/5] gdb: Add -Wno-mismatched-tags Simon Marchi
2017-06-10 19:58 ` [PATCH 2/5] gdb: Use -Werror when checking for (un)supported warning flags Simon Marchi
2017-06-11  2:36 ` [PATCH 0/5] Remove a few hurdles of compiling with clang Eli Zaretskii
2017-06-12  7:56   ` Yao Qi
2017-06-12 14:36     ` Eli Zaretskii
2017-06-12 15:54       ` Simon Marchi
2017-06-12 16:23         ` Andrew Pinski
2017-06-12 16:35           ` Pedro Alves
2017-06-12 16:37             ` Andrew Pinski
2017-06-12 16:45               ` Pedro Alves
2017-06-12 16:55                 ` Pedro Alves
2017-06-12 16:44           ` Simon Marchi
2017-06-12 16:55             ` Andrew Pinski [this message]
2017-06-12 17:00               ` Simon Marchi
2017-06-12 16:44         ` Eli Zaretskii
2017-06-13  9:14           ` Yao Qi
2017-06-13 10:23             ` Simon Marchi
2017-06-13 11:06               ` Pedro Alves
2017-06-13 11:08                 ` Simon Marchi
2017-06-13 14:38               ` Eli Zaretskii
2017-06-13 17:07                 ` Simon Marchi
2017-06-13 19:23                   ` Eli Zaretskii
2017-06-13 20:17                     ` Simon Marchi
2017-06-14  2:29                       ` Eli Zaretskii
2017-06-14 10:45                         ` Pedro Alves
2017-06-16 16:12                           ` John Baldwin
2017-06-13 15:22               ` Yao Qi
2017-06-13 15:44                 ` Eli Zaretskii
2017-06-14  9:07                   ` Yao Qi
2017-06-19  8:07                 ` Yao Qi
2017-06-13 10:44             ` Pedro Alves
2017-06-13 15:09               ` Joel Brobecker
2017-06-17 21:23 ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+=Sn1m85ZmRY8H85bvq1wi8faYZjrQBoMGjDhc4rLqs70p1UQ@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    --cc=simon.marchi@ericsson.com \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).