summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphython <phython@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-06 21:22:02 +0000
committerphython <phython@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-06 21:22:02 +0000
commita5147fca1106e5c46821c63b14e8366a65ec0dff (patch)
treec13d1c358e9b4295a74856f820ffd37c7785c650
parentb37d9d865b7c4561b84c8dd9527fbc8d74fea6ef (diff)
downloadppe42-gcc-a5147fca1106e5c46821c63b14e8366a65ec0dff.tar.gz
ppe42-gcc-a5147fca1106e5c46821c63b14e8366a65ec0dff.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97751 138bc75d-0d04-0410-961f-82ee72b054a4
-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 aa8bcc5d20d..8751369fa8a 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 817d939be3b..f68c8532ebe 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 dc98fcd7d63..2b354af1a75 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 00000000000..d6106b5b353
--- /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 00000000000..d97fa2573ac
--- /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));
OpenPOWER on IntegriCloud