summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>1992-05-22 20:33:20 +0000
committerrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>1992-05-22 20:33:20 +0000
commitf4e3c278ccc1b2aa208a0944f7b09860c1ffbd1a (patch)
tree7563cb6789d2ea397a02a4bbb6dc3acb789068d5 /gcc/c-common.c
parentda14af53fdf33a0b39350c3ecf1c574ae7069944 (diff)
downloadgcc-f4e3c278ccc1b2aa208a0944f7b09860c1ffbd1a.tar.gz
*** empty log message ***
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@1052 138bc75d-0d04-0410-961f-82ee72b054a4
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 e01b37fade1..0c8118e39f3 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. */