This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Warning location fix, PR c++/69733
- From: Bernd Schmidt <bschmidt at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, Joseph Myers <joseph at codesourcery dot com>
- Date: Wed, 10 Feb 2016 20:26:42 +0100
- Subject: Warning location fix, PR c++/69733
- Authentication-results: sourceware.org; auth=none
- References: <56BB58E6 dot 8010209 at t-online dot de>
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
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. */