public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Mikhail Maltsev <maltsevm@gmail.com>,
	gcc-patches <gcc-patches@gnu.org>,
	Joseph Myers <joseph@codesourcery.com>,
	Marek Polacek <polacek@redhat.com>,
	David Malcolm <dmalcolm@redhat.com>
Subject: Re: [C PATCH] PR43651: add warning for duplicate qualifier
Date: Fri, 08 Apr 2016 17:55:00 -0000	[thread overview]
Message-ID: <5707F068.3050601@gmail.com> (raw)
In-Reply-To: <570241F0.3070705@gmail.com>

On 04/04/2016 04:29 AM, Mikhail Maltsev wrote:
> Hi all!
>
> Currently GCC produces pedantic warning, if variable declaration (or
> typedef) has duplicate qualifier, but only when compiling as C89 (not
> C99 or C11).

Presumably that's because C89 makes duplicating a type qualifier
a constraint violation while C99 and C11 allow them.

>
> The attached patch adds a new warning option to enable the same warning
> in C99 and C11.
> It also checks whether qualifiers come from macro
> expansion, e.g.:
>
> #define CT2 const int
> const CT2 x1;
> CT2 const x2;
>
> and does not warn in this case, but warns for, e.g.
>
> void foo(const int const *x) { }
> (because this probably meant to be "const int *const x")
>
> The name for new option "-Wduplicate-decl-specifier" and wording was
> chosen to match the same option in Clang.

My version of Clang also warns in C++ mode but if I'm reading
the patch right, GCC would warn only C mode.  I would find it
surprising if GCC provided the same option as Clang but didn't
make it available in the same languages.  Do you have some
reason for leaving it out that I'm not thinking of?

Also, in C11 mode, Clang issues the warning for duplicated
_Atomic qualifiers but it doesn't look like GCC would with
the patch.  Here again, unless there's some reason not to,
I would expect GCC to issue the same warning as Clang for
the same code.

Martin

  parent reply	other threads:[~2016-04-08 17:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-04 10:29 Mikhail Maltsev
2016-04-07 21:50 ` Joseph Myers
2016-04-08 11:42   ` Mikhail Maltsev
2016-04-08 17:55 ` Martin Sebor [this message]
2016-04-09 12:29   ` Mikhail Maltsev
2016-04-10 20:12     ` Martin Sebor
2016-04-28 12:00       ` [C PATCH PING] " Mikhail Maltsev
2016-05-10 20:10     ` [C PATCH] " Joseph Myers
2016-05-11 20:24       ` Mikhail Maltsev

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=5707F068.3050601@gmail.com \
    --to=msebor@gmail.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=maltsevm@gmail.com \
    --cc=polacek@redhat.com \
    /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).