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 + + * c-common.c (handle_malloc_atttribute): Only set DECL_IS_MALLOC if + the function returns a pointer type. + 2005-04-06 Daniel Berlin * 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 + + * gcc.dg/15443-1.c: New test. + * gcc.dg/15443-2.c: Likewise. + 2005-04-06 Tobias Schl"uter * 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));