OSDN Git Service

PR c++/39554
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Mar 2009 19:27:17 +0000 (19:27 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Mar 2009 19:27:17 +0000 (19:27 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145094 138bc75d-0d04-0410-961f-82ee72b054a4

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 947f34f..14fdabf 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 6319770..2d5184f 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 0bc39a2..e3e6ab4 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 ();
+}