This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64431] "-Wignored-qualifiers" warning gives misleading position in code
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 29 Dec 2014 01:50:20 +0000
- Subject: [Bug c++/64431] "-Wignored-qualifiers" warning gives misleading position in code
- Auto-submitted: auto-generated
- References: <bug-64431-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64431
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-12-29
CC| |manu at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
This is a problem also in C, however, in C++ it is trivial to fix:
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c (revision 218749)
+++ gcc/cp/decl.c (working copy)
@@ -9686,11 +9686,11 @@ grokdeclarator (const cp_declarator *dec
Make sure we have a valid type for the function to return. */
if (type_quals != TYPE_UNQUALIFIED)
{
if (SCALAR_TYPE_P (type) || VOID_TYPE_P (type))
- warning (OPT_Wignored_qualifiers,
+ warning_at (declspecs->locations[ds_const],
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. */
type_quals = TYPE_UNQUALIFIED;
}
I would suggest to add a testcase with explicit column numbers.
I added this to the list of EasyHacks and I'll leave it to a new dev to fix it
(see
https://gcc.gnu.org/wiki/GettingStarted#Basics:_Contributing_to_GCC_in_10_easy_steps
if you want to be the one)