diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1993-01-27 19:21:01 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1993-01-27 19:21:01 -0500 |
commit | 97d17ac21c4835251b1b485584fafaa5b187968d (patch) | |
tree | be66600f445fa39265d1b3e4e6ab46e154f602c1 /gcc | |
parent | e15762df9d0d7f48680b2d839a3da37536461b1a (diff) | |
download | gcc-97d17ac21c4835251b1b485584fafaa5b187968d.zip gcc-97d17ac21c4835251b1b485584fafaa5b187968d.tar.gz gcc-97d17ac21c4835251b1b485584fafaa5b187968d.tar.bz2 |
(declare_function_name): If char_array_type_node isn't large enough
for the name, make a larger type.
From-SVN: r3368
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-common.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 1a8838a..3c51f0b 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -29,8 +29,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ void declare_function_name () { - tree decl, init; + tree decl, type, init; char *name, *printable_name; + int len; if (current_function_decl == NULL) { @@ -50,29 +51,43 @@ declare_function_name () printable_name = (*decl_printable_name) (current_function_decl, &kind); } + /* If the default size of char arrays isn't big enough for the name, + make a bigger one. */ + len = strlen (name) + 1; + type = char_array_type_node; + if (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TREE_TYPE (char_array_type_node))) + < len) + type = build_array_type (char_type_node, + build_index_type (build_int_2 (len, 0))); + push_obstacks_nochange (); - decl = build_decl (VAR_DECL, get_identifier ("__FUNCTION__"), - char_array_type_node); + decl = build_decl (VAR_DECL, get_identifier ("__FUNCTION__"), type); TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; DECL_SOURCE_LINE (decl) = 0; DECL_IN_SYSTEM_HEADER (decl) = 1; DECL_IGNORED_P (decl) = 1; - init = build_string (strlen (name) + 1, name); - TREE_TYPE (init) = char_array_type_node; + init = build_string (len, name); + TREE_TYPE (init) = type; DECL_INITIAL (decl) = init; finish_decl (pushdecl (decl), init, NULL_TREE); + len = strlen (printable_name) + 1; + type = char_array_type_node; + if (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TREE_TYPE (char_array_type_node))) + < len) + type = build_array_type (char_type_node, + build_index_type (build_int_2 (len, 0))); + push_obstacks_nochange (); - decl = build_decl (VAR_DECL, get_identifier ("__PRETTY_FUNCTION__"), - char_array_type_node); + decl = build_decl (VAR_DECL, get_identifier ("__PRETTY_FUNCTION__"), type); TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; DECL_SOURCE_LINE (decl) = 0; DECL_IN_SYSTEM_HEADER (decl) = 1; DECL_IGNORED_P (decl) = 1; - init = build_string (strlen (printable_name) + 1, printable_name); - TREE_TYPE (init) = char_array_type_node; + init = build_string (len, printable_name); + TREE_TYPE (init) = type; DECL_INITIAL (decl) = init; finish_decl (pushdecl (decl), init, NULL_TREE); } |