]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/39554 (-Wdisallowed-function-list fails when #including <algorithm>)
authorJakub Jelinek <jakub@redhat.com>
Thu, 26 Mar 2009 19:27:17 +0000 (20:27 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 26 Mar 2009 19:27:17 +0000 (20:27 +0100)
PR c++/39554
* opts.c (warn_if_disallowed_function_p): Don't assume
get_callee_fndecl must return non-NULL.

* gcc.dg/wdisallowed-functions-3.c: New test.
* g++.dg/warn/Wdisallowed-functions-3.C: New test.

From-SVN: r145094

gcc/ChangeLog
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wdisallowed-functions-3.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/wdisallowed-functions-3.c [new file with mode: 0644]

index 947f34f30a284a86b4a90b775a4cdf193f8cce31..14fdabfaff88b830e7d54492fc93697c74f4718b 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/39554
+       * opts.c (warn_if_disallowed_function_p): Don't assume
+       get_callee_fndecl must return non-NULL.
+
 2009-03-26  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR rtl-optimization/39522
index 631977097ec099838d410003d219f574dcedd702..2d5184fcb0e3cdff088df4cd050c7d407ee3469e 100644 (file)
@@ -745,13 +745,21 @@ flag_instrument_functions_exclude_p (tree fndecl)
 void
 warn_if_disallowed_function_p (const_tree exp)
 {
-  if (TREE_CODE(exp) == CALL_EXPR
+  if (TREE_CODE (exp) == CALL_EXPR
       && VEC_length (char_p, warning_disallowed_functions) > 0)
     {
       int i;
       char *s;
-      const char *fnname =
-          IDENTIFIER_POINTER (DECL_NAME (get_callee_fndecl (exp)));
+      tree fndecl = get_callee_fndecl (exp);
+      const char *fnname;
+
+      if (fndecl == NULL)
+       return;
+
+      fnname = get_name (fndecl);
+      if (fnname == NULL)
+       return;
+
       for (i = 0; VEC_iterate (char_p, warning_disallowed_functions, i, s);
            ++i)
         {
index 0bc39a28ab30b2b0c6c12bef02dacb57e20412de..e3e6ab4932d3bcc1292ffc2f972f66e1762bc2e1 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/39554
+       * gcc.dg/wdisallowed-functions-3.c: New test.
+       * g++.dg/warn/Wdisallowed-functions-3.C: New test.
+
 2009-03-26  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/inline-33.c: Fix when pic.
diff --git a/gcc/testsuite/g++.dg/warn/Wdisallowed-functions-3.C b/gcc/testsuite/g++.dg/warn/Wdisallowed-functions-3.C
new file mode 100644 (file)
index 0000000..3ecfb0c
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/39554
+// { dg-do compile }
+// { dg-options "-Wdisallowed-function-list=bar" }
+
+void
+foo (void (*p) (), void (*bar) ())
+{
+  p ();
+  bar ();
+}
diff --git a/gcc/testsuite/gcc.dg/wdisallowed-functions-3.c b/gcc/testsuite/gcc.dg/wdisallowed-functions-3.c
new file mode 100644 (file)
index 0000000..5b8b31b
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR c++/39554 */
+/* { dg-do compile } */
+/* { dg-options "-Wdisallowed-function-list=bar" } */
+
+void
+foo (void (*p) (void), void (*bar) (void))
+{
+  p ();
+  bar ();
+}