From: Jakub Jelinek <jakub@redhat.com>
To: Bernd Schmidt <bschmidt@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Jason Merrill <jason@redhat.com>,
Joseph Myers <joseph@codesourcery.com>
Subject: Re: Warning location fix, PR c++/69733
Date: Wed, 10 Feb 2016 19:33:00 -0000 [thread overview]
Message-ID: <20160210193338.GW3017@tucnak.redhat.com> (raw)
In-Reply-To: <56BB8EF2.1020500@redhat.com>
On Wed, Feb 10, 2016 at 08:26:42PM +0100, Bernd Schmidt wrote:
> This PR notes that in this warning:
> const.ii:5:25: warning: type qualifiers ignored on function return type
> [-Wignored-qualifiers]
> const double value() const {return val;}
> ^~~~~
>
> we are pointing at the wrong qualifier. Below I'm attaching a patch that
> makes it point at the first qualifier of the return type (or the return type
> in case it's a typedef with qualifiers) instead. However, it turns out this
> is not consistent with the C frontend, which points at the function name for
> this warning.
>
> I'm guessing we want to be consistent between frontends, and I also have a
> similar patch for C. Before I finalize it all with testcases and everything
> - which behaviour is desired?
Just a nit from compile time POV, wouldn't it be better to compute loc only
inside of the if (SCALAR_TYPE_P (type) || VOID_TYPE_P (type)) block, so that
it is not computed when it is not needed?
> --- gcc/cp/decl.c (revision 233217)
> +++ gcc/cp/decl.c (working copy)
> @@ -10009,8 +10009,14 @@ grokdeclarator (const cp_declarator *dec
>
> if (type_quals != TYPE_UNQUALIFIED)
> {
> + location_t loc;
> + loc = smallest_type_quals_location (type_quals,
> + declspecs->locations);
> + if (loc == UNKNOWN_LOCATION)
> + loc = declspecs->locations[ds_type_spec];
> if (SCALAR_TYPE_P (type) || VOID_TYPE_P (type))
> - warning (OPT_Wignored_qualifiers,
> + warning_at (loc,
> + OPT_Wignored_qualifiers,
> "type qualifiers ignored on function return type");
> /* We now know that the TYPE_QUALS don't apply to the
> decl, but to its return type. */
Jakub
prev parent reply other threads:[~2016-02-10 19:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <56BB58E6.8010209@t-online.de>
2016-02-10 19:26 ` Bernd Schmidt
2016-02-10 19:33 ` Jakub Jelinek [this message]
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=20160210193338.GW3017@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=bschmidt@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=joseph@codesourcery.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).