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
This commit is contained in:
James A. Morrison 2005-04-06 21:22:02 +00:00
parent 53ae8e14b2
commit 3425638af5
5 changed files with 37 additions and 2 deletions

View 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

View 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);

View 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.

View File

@ -0,0 +1,10 @@
/* { dg-do compile } */
void f () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */
int main ()
{
/* This used to cause an ICE. */
f ();
}

View File

@ -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));