aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-08-15 09:30:20 +0000
committerRichard Stallman <rms@gnu.org>1993-08-15 09:30:20 +0000
commit4724b3dea0b8f73223bf5bf45b0ff019c70fccd8 (patch)
tree040674da827827c22eb4f8f80be94e7d461bf148 /gcc
parent0bc9c2526844e064f4f032d0de56164a7c44581f (diff)
downloadgcc-4724b3dea0b8f73223bf5bf45b0ff019c70fccd8.zip
gcc-4724b3dea0b8f73223bf5bf45b0ff019c70fccd8.tar.gz
gcc-4724b3dea0b8f73223bf5bf45b0ff019c70fccd8.tar.bz2
(declare_hidden_char_array): New function to factor out duplicate code in declare_function_name.
(declare_hidden_char_array): New function to factor out duplicate code in declare_function_name. Don't set DECL_EXTERNAL (which is illegal without TREE_PUBLIC) to prevent output; instead, set TREE_ASM_WRITTEN. (declare_function_name): Use declare_hidden_char_array. From-SVN: r5161
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-common.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index e5a84d2..8d10aa3 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -27,14 +27,14 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
extern struct obstack permanent_obstack;
+static void declare_hidden_char_array PROTO((char *, char *));
+
/* Make bindings for __FUNCTION__ and __PRETTY_FUNCTION__. */
void
declare_function_name ()
{
- tree decl, type, init;
char *name, *printable_name;
- int len;
if (current_function_decl == NULL)
{
@@ -54,44 +54,34 @@ 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)));
+ declare_hidden_char_array ("__FUNCTION__", name);
+ declare_hidden_char_array ("__PRETTY_FUNCTION__", printable_name);
+}
- push_obstacks_nochange ();
- 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;
- DECL_EXTERNAL (decl) = 1;
- init = build_string (len, name);
- TREE_TYPE (init) = type;
- DECL_INITIAL (decl) = init;
- finish_decl (pushdecl (decl), init, NULL_TREE);
+static void
+declare_hidden_char_array (name, value)
+ char *name, *value;
+{
+ tree decl, type, init;
+ int vlen;
- len = strlen (printable_name) + 1;
+ /* If the default size of char arrays isn't big enough for the name,
+ make a bigger one. */
+ vlen = strlen (value) + 1;
type = char_array_type_node;
- if (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TREE_TYPE (char_array_type_node)))
- < len)
+ if (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TREE_TYPE (type))) < vlen)
type = build_array_type (char_type_node,
- build_index_type (build_int_2 (len, 0)));
+ build_index_type (build_int_2 (vlen, 0)));
push_obstacks_nochange ();
- decl = build_decl (VAR_DECL, get_identifier ("__PRETTY_FUNCTION__"), type);
+ decl = build_decl (VAR_DECL, get_identifier (name), type);
TREE_STATIC (decl) = 1;
TREE_READONLY (decl) = 1;
+ TREE_ASM_WRITTEN (decl) = 1;
DECL_SOURCE_LINE (decl) = 0;
DECL_IN_SYSTEM_HEADER (decl) = 1;
DECL_IGNORED_P (decl) = 1;
- DECL_EXTERNAL (decl) = 1;
- init = build_string (len, printable_name);
+ init = build_string (vlen, value);
TREE_TYPE (init) = type;
DECL_INITIAL (decl) = init;
finish_decl (pushdecl (decl), init, NULL_TREE);