aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2000-03-08 11:21:28 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2000-03-08 11:21:28 +0000
commit2ce07e2d9247f692e424385deb1e8b154bf1b388 (patch)
treed0c5ae25c2c3150c4c348ac64a3fdbdef73e015a /gcc/c-decl.c
parent8ce5ef1923e1bc826b4159ecee825db5fc9b8cd9 (diff)
downloadgcc-2ce07e2d9247f692e424385deb1e8b154bf1b388.zip
gcc-2ce07e2d9247f692e424385deb1e8b154bf1b388.tar.gz
gcc-2ce07e2d9247f692e424385deb1e8b154bf1b388.tar.bz2
c-common.h (make_fname_decl): Declare.
gcc: * c-common.h (make_fname_decl): Declare. * c-common.c (make_fname_decl): Define. (declare_hidden_char_array): Remove. (declare_function_name): Use make_fname_decl. * c-decl.c (c_make_fname_decl): New function. (init_decl_processing): Set make_fname_decl. gcc/cp: * decl.c (cp_make_fname_decl): New function. (wrapup_globals_for_namespace): Don't emit unused static vars. (init_decl_processing): Remove comment about use of array_domain_type. Set make_fname_decl. (cp_finish_decl): Remove __FUNCTION__ nadgering. * semantics.c (begin_compound_stmt): Remove current_function_name_declared flagging. (expand_stmt): Don't emit unused local statics. * typeck.c (decay_conversion): Don't treat __FUNCTION__ decls specially. From-SVN: r32418
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 6b5d295..8a57460 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -288,6 +288,7 @@ static tree grokdeclarator PARAMS ((tree, tree, enum decl_context,
int));
static tree grokparms PARAMS ((tree, int));
static void layout_array_type PARAMS ((tree));
+static tree c_make_fname_decl PARAMS ((tree, const char *, int));
/* C-specific option variables. */
@@ -3059,6 +3060,7 @@ init_decl_processing ()
pedantic_lvalues = pedantic;
/* Create the global bindings for __FUNCTION__ and __PRETTY_FUNCTION__. */
+ make_fname_decl = c_make_fname_decl;
declare_function_name ();
start_identifier_warnings ();
@@ -3085,6 +3087,43 @@ init_decl_processing ()
ggc_add_tree_root (&static_dtors, 1);
}
+/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give the
+ decl, NAME is the initialization string and TYPE_DEP indicates whether
+ NAME depended on the type of the function. As we don't yet implement
+ delayed emission of static data, we mark the decl as emitted
+ so it is not placed in the output. Anything using it must therefore pull
+ out the STRING_CST initializer directly. This does mean that these names
+ are string merging candidates, which C99 does not permit. */
+
+static tree
+c_make_fname_decl (id, name, type_dep)
+ tree id;
+ const char *name;
+ int type_dep ATTRIBUTE_UNUSED;
+{
+ tree decl, type, init;
+ size_t length = strlen (name);
+
+ type = build_array_type
+ (build_qualified_type (char_type_node, TYPE_QUAL_CONST),
+ build_index_type (build_int_2 (length, 0)));
+
+ decl = build_decl (VAR_DECL, id, type);
+ TREE_STATIC (decl) = 1;
+ TREE_READONLY (decl) = 1;
+ TREE_ASM_WRITTEN (decl) = 1;
+ DECL_SOURCE_LINE (decl) = 0;
+ DECL_ARTIFICIAL (decl) = 1;
+ DECL_IN_SYSTEM_HEADER (decl) = 1;
+ DECL_IGNORED_P (decl) = 1;
+ init = build_string (length + 1, name);
+ TREE_TYPE (init) = type;
+ DECL_INITIAL (decl) = init;
+ finish_decl (pushdecl (decl), init, NULL_TREE);
+
+ return decl;
+}
+
/* Return a definition for a builtin function named NAME and whose data type
is TYPE. TYPE should be a function type with argument types.
FUNCTION_CODE tells later passes how to compile calls to this function.