* Warning location fix, PR c++/69733
[not found] <56BB58E6.8010209@t-online.de>
@ 2016-02-10 19:26 ` Bernd Schmidt
2016-02-10 19:33 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Bernd Schmidt @ 2016-02-10 19:26 UTC (permalink / raw)
To: GCC Patches, Jason Merrill, Joseph Myers
[-- Attachment #1: Type: text/plain, Size: 724 bytes --]
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?
Bernd
[-- Attachment #2: qual-loc.diff --]
[-- Type: text/x-patch, Size: 765 bytes --]
Index: gcc/cp/decl.c
===================================================================
--- 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. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Warning location fix, PR c++/69733
2016-02-10 19:26 ` Warning location fix, PR c++/69733 Bernd Schmidt
@ 2016-02-10 19:33 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2016-02-10 19:33 UTC (permalink / raw)
To: Bernd Schmidt; +Cc: GCC Patches, Jason Merrill, Joseph Myers
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-10 19:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <56BB58E6.8010209@t-online.de>
2016-02-10 19:26 ` Warning location fix, PR c++/69733 Bernd Schmidt
2016-02-10 19:33 ` Jakub Jelinek
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).