Hi,

this patchlet fixes the column # of the unused parameter warnings emitted by do_warn_unused_parameter by explicitly passing DECL_SOURCE_LOCATION (decl) instead of wrongly relying on '+', which in this case ends up meaning the location of the function declaration. Tested x86_64-linux.

Thanks!
Paolo.

PS: sorry, not 100% sure about the maintainers of this file, I'm adding a couple of CCs.

////////////////////////
2013-09-09  Marc Glisse  <marc.gli...@inria.fr>
            Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58362
        * function.c (do_warn_unused_parameter): Use DECL_SOURCE_LOCATION.

/testsuite
2013-09-09  Marc Glisse  <marc.gli...@inria.fr>
            Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58362
        * c-c++-common/Wunused-parm-1.c: New.
Index: function.c
===================================================================
--- function.c  (revision 202365)
+++ function.c  (working copy)
@@ -5004,7 +5004,8 @@ do_warn_unused_parameter (tree fn)
     if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
        && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl)
        && !TREE_NO_WARNING (decl))
-      warning (OPT_Wunused_parameter, "unused parameter %q+D", decl);
+      warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_parameter,
+                 "unused parameter %qD", decl);
 }
 
 /* Generate RTL for the end of the current function.  */
Index: testsuite/c-c++-common/Wunused-parm-1.c
===================================================================
--- testsuite/c-c++-common/Wunused-parm-1.c     (revision 0)
+++ testsuite/c-c++-common/Wunused-parm-1.c     (working copy)
@@ -0,0 +1,5 @@
+/* PR c++/58362 */
+/* { dg-options "-Wunused-parameter" } */
+/* { dg-do compile } */
+
+void f (long s) { }  /* { dg-warning "14:unused parameter" } */

Reply via email to