re PR c++/64079 (%+D in diagnostics breaks pragma GCC diagnostic)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Fri, 24 Jul 2015 20:20:13 +0000 (20:20 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 24 Jul 2015 20:20:13 +0000 (20:20 +0000)
2015-07-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR c++/64079
* toplev.c (check_global_declaration): Use DECL_SOURCE_LOCATION
and "%qD" in warning_at instead of "%q+D" in warning.

/testsuite
2015-07-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR c++/64079
* c-c++-common/Wunused-function-1.c: New.

From-SVN: r226191

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wunused-function-1.c [new file with mode: 0644]
gcc/toplev.c

index 773babe6d3ccdf1cfb795e865ec20fb26df7f572..264570832f75fd1fc33b0ad05ba12360fc01e2c0 100644 (file)
@@ -1,3 +1,9 @@
+2015-07-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/64079
+       * toplev.c (check_global_declaration): Use DECL_SOURCE_LOCATION
+       and "%qD" in warning_at instead of "%q+D" in warning.
+
 2015-07-24  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.c (ix86_call_abi_override): Call ix86_function_abi.
index 9db26430e0763300f687d39f5e3cf986a34fb04a..57bb26d014e98269539b750654952ab754b93691 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/64079
+       * c-c++-common/Wunused-function-1.c: New.
+
 2015-07-24  Tom de Vries  <tom@codesourcery.com>
 
        * gcc.dg/parloops-exit-first-loop-alt-2.c: Use debug print for
diff --git a/gcc/testsuite/c-c++-common/Wunused-function-1.c b/gcc/testsuite/c-c++-common/Wunused-function-1.c
new file mode 100644 (file)
index 0000000..9f85695
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR c++/64079 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-function" } */
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+
+static void bar() {}
+
+#pragma GCC diagnostic pop
index 91be24f7bcaa47e0cfb2dc225a818f6dc46bcad3..1bacb68889dc5c54f3541ed2b8cdf8c48055854b 100644 (file)
@@ -524,10 +524,11 @@ check_global_declaration (tree decl)
              && !DECL_STATIC_DESTRUCTOR (decl)))
       /* Otherwise, ask the language.  */
       && lang_hooks.decls.warn_unused_global (decl))
-    warning ((TREE_CODE (decl) == FUNCTION_DECL)
-            ? OPT_Wunused_function
-             : OPT_Wunused_variable,
-            "%q+D defined but not used", decl);
+    warning_at (DECL_SOURCE_LOCATION (decl),
+               (TREE_CODE (decl) == FUNCTION_DECL)
+               ? OPT_Wunused_function
+               : OPT_Wunused_variable,
+               "%qD defined but not used", decl);
 }
 
 /* Compile an entire translation unit.  Write a file of assembly