aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorAnthony Green <green@cygnus.com>1999-11-28 20:45:34 +0000
committerAnthony Green <green@gcc.gnu.org>1999-11-28 20:45:34 +0000
commit140592a0131cb2dc88d3f55b2671977f20c85be2 (patch)
tree64c16fe212dcb5f1d77505bd5b8e158441e8665e /gcc/c-common.c
parent8b4b9b7ad3d1bbc16516a5a73a6ba3c3c21d1822 (diff)
downloadgcc-140592a0131cb2dc88d3f55b2671977f20c85be2.zip
gcc-140592a0131cb2dc88d3f55b2671977f20c85be2.tar.gz
gcc-140592a0131cb2dc88d3f55b2671977f20c85be2.tar.bz2
tree.h (struct tree_decl): Add malloc_flag.
* tree.h (struct tree_decl): Add malloc_flag. (DECL_IS_MALLOC): Define. * c-common.c (attrs): Add A_MALLOC attribute. (init_attributes): Add this attribute to the table. (decl_attributes): Handle malloc attribute. * calls.c (special_function_p): Check for the malloc attribute. * extend.texi (Function Attributes): Document malloc attribute. From-SVN: r30689
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 742eba0..10c1624 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -140,7 +140,7 @@ int skip_evaluation;
enum attrs {A_PACKED, A_NOCOMMON, A_COMMON, A_NORETURN, A_CONST, A_T_UNION,
A_NO_CHECK_MEMORY_USAGE, A_NO_INSTRUMENT_FUNCTION,
A_CONSTRUCTOR, A_DESTRUCTOR, A_MODE, A_SECTION, A_ALIGNED,
- A_UNUSED, A_FORMAT, A_FORMAT_ARG, A_WEAK, A_ALIAS};
+ A_UNUSED, A_FORMAT, A_FORMAT_ARG, A_WEAK, A_ALIAS, A_MALLOC};
enum format_type { printf_format_type, scanf_format_type,
strftime_format_type };
@@ -481,6 +481,7 @@ init_attributes ()
add_attribute (A_ALIAS, "alias", 1, 1, 1);
add_attribute (A_NO_INSTRUMENT_FUNCTION, "no_instrument_function", 0, 0, 1);
add_attribute (A_NO_CHECK_MEMORY_USAGE, "no_check_memory_usage", 0, 0, 1);
+ add_attribute (A_MALLOC, "malloc", 0, 0, 1);
}
/* Default implementation of valid_lang_attribute, below. By default, there
@@ -617,6 +618,13 @@ decl_attributes (node, attributes, prefix_attributes)
warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
break;
+ case A_MALLOC:
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ DECL_IS_MALLOC (decl) = 1;
+ else
+ warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
+ break;
+
case A_UNUSED:
if (is_type)
TREE_USED (type) = 1;