aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJames A. Morrison <phython@gcc.gnu.org>2005-04-06 21:22:02 +0000
committerJames A. Morrison <phython@gcc.gnu.org>2005-04-06 21:22:02 +0000
commit3425638af52c359b893547b9dcde5cccd1bb67ac (patch)
treec13d1c358e9b4295a74856f820ffd37c7785c650 /gcc
parent53ae8e14b24bcaf60acdc0d8ee6683ea741cee13 (diff)
downloadgcc-3425638af52c359b893547b9dcde5cccd1bb67ac.zip
gcc-3425638af52c359b893547b9dcde5cccd1bb67ac.tar.gz
gcc-3425638af52c359b893547b9dcde5cccd1bb67ac.tar.bz2
c-common.c (handle_malloc_atttribute): Only set DECL_IS_MALLOC if the function returns a pointer type.
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. From-SVN: r97751
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-common.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr15443-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/pr15443-2.c15
5 files changed, 37 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index aa8bcc5..8751369 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 817d939..f68c853 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dc98fcd..2b354af 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..d6106b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr15443-1.c
@@ -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
index 0000000..d97fa25
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr15443-2.c
@@ -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));