aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1992-05-22 20:33:20 +0000
committerRichard Stallman <rms@gnu.org>1992-05-22 20:33:20 +0000
commit7da551a2e80eeb4f2b3fa8765e84b79e899d934c (patch)
tree7563cb6789d2ea397a02a4bbb6dc3acb789068d5 /gcc/c-common.c
parent88d92ca5b290f6bd966ebfa9ca98652763f61b18 (diff)
downloadgcc-7da551a2e80eeb4f2b3fa8765e84b79e899d934c.zip
gcc-7da551a2e80eeb4f2b3fa8765e84b79e899d934c.tar.gz
gcc-7da551a2e80eeb4f2b3fa8765e84b79e899d934c.tar.bz2
*** empty log message ***
From-SVN: r1052
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index e01b37f..0c8118e 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -27,6 +27,53 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#undef NULL
#define NULL 0
+/* Make bindings for __NAME__ and __PRINTABLE_NAME__. */
+
+void
+declare_function_name ()
+{
+ tree decl, init;
+ char *name, *printable_name;
+
+ if (current_function_decl == NULL)
+ {
+ name = "";
+ printable_name = "top level";
+ }
+ else
+ {
+ char *kind = "function";
+ if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
+ kind = "method";
+ name = IDENTIFIER_POINTER (DECL_NAME (current_function_decl));
+ printable_name = (*decl_printable_name) (current_function_decl, &kind);
+ }
+
+ push_obstacks_nochange ();
+ decl = build_decl (VAR_DECL, get_identifier ("__NAME__"),
+ char_array_type_node);
+ TREE_STATIC (decl) = 1;
+ TREE_READONLY (decl) = 1;
+ TREE_NO_UNUSED_WARNING (decl) = 1;
+ DECL_IGNORED_P (decl) = 1;
+ init = build_string (strlen (name) + 1, name);
+ TREE_TYPE (init) = char_array_type_node;
+ DECL_INITIAL (decl) = init;
+ finish_decl (pushdecl (decl), init, NULL_TREE);
+
+ push_obstacks_nochange ();
+ decl = build_decl (VAR_DECL, get_identifier ("__PRINTABLE_NAME__"),
+ char_array_type_node);
+ TREE_STATIC (decl) = 1;
+ TREE_READONLY (decl) = 1;
+ TREE_NO_UNUSED_WARNING (decl) = 1;
+ DECL_IGNORED_P (decl) = 1;
+ init = build_string (strlen (printable_name) + 1, printable_name);
+ TREE_TYPE (init) = char_array_type_node;
+ DECL_INITIAL (decl) = init;
+ finish_decl (pushdecl (decl), init, NULL_TREE);
+}
+
/* Given a chain of STRING_CST nodes,
concatenate them into one STRING_CST
and give it a suitable array-of-chars data type. */