* 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
+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
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);
+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.
--- /dev/null
+/* { dg-do compile } */
+
+void f () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */
+
+int main ()
+{
+ /* This used to cause an ICE. */
+ f ();
+}
+
--- /dev/null
+/* { 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));