OSDN Git Service

2005-04-06 James A. Morrison <phython@gcc.gnu.org>
authorphython <phython@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 Apr 2005 21:22:02 +0000 (21:22 +0000)
committerphython <phython@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 Apr 2005 21:22:02 +0000 (21:22 +0000)
        * c-common.c (handle_malloc_atttribute): Only set DECL_IS_MALLOC if
        the function returns a pointer type.

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

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr15443-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr15443-2.c [new file with mode: 0644]

index aa8bcc5..8751369 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-06  James A. Morrison  <phython@gcc.gnu.org>
+
+       * c-common.c (handle_malloc_atttribute): Only set DECL_IS_MALLOC if
+       the function returns a pointer type.
+
 2005-04-06  Daniel Berlin  <dberlin@dberlin.org>
 
        * params.def (PARAM_SALIAS_MAX_IMPLICIT_FIELDS): New
index 817d939..f68c853 100644 (file)
@@ -4808,9 +4808,9 @@ static tree
 handle_malloc_attribute (tree *node, tree name, tree ARG_UNUSED (args),
                         int ARG_UNUSED (flags), bool *no_add_attrs)
 {
-  if (TREE_CODE (*node) == FUNCTION_DECL)
+  if (TREE_CODE (*node) == FUNCTION_DECL
+      && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*node))))
     DECL_IS_MALLOC (*node) = 1;
-  /* ??? TODO: Support types.  */
   else
     {
       warning ("%qE attribute ignored", name);
index dc98fcd..2b354af 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-06  James A. Morrison  <phython@gcc.gnu.org>
+
+       * gcc.dg/15443-1.c: New test.
+       * gcc.dg/15443-2.c: Likewise.
+
 2005-04-06  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * gfortran.dg/pr15754.f90: Change annotations to dg-error.
diff --git a/gcc/testsuite/gcc.dg/pr15443-1.c b/gcc/testsuite/gcc.dg/pr15443-1.c
new file mode 100644 (file)
index 0000000..d6106b5
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+void f () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */
+
+int main ()
+{
+       /* This used to cause an ICE.  */
+       f ();
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr15443-2.c b/gcc/testsuite/gcc.dg/pr15443-2.c
new file mode 100644 (file)
index 0000000..d97fa25
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+struct foo {
+       int bar;
+};
+
+typedef struct foo* bar;
+void f () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */
+int g () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */
+int* h () __attribute__ ((__malloc__));
+void* i () __attribute__ ((__malloc__));
+
+struct foo j () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */
+struct foo* k () __attribute__ ((__malloc__));
+bar l () __attribute__((malloc));