diff options
author | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-04-24 08:22:06 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-04-24 08:22:06 +0000 |
commit | 0ba8a114c724d36034e8996eefb7c94d4fe8aed0 (patch) | |
tree | 268353894884ce2459e1f3b08adc4825b8ed0dd6 /gcc/cp/pt.c | |
parent | dfbb4f347cf43b955f56ecbc9709b8836d395ee5 (diff) | |
download | gcc-0ba8a114c724d36034e8996eefb7c94d4fe8aed0.zip gcc-0ba8a114c724d36034e8996eefb7c94d4fe8aed0.tar.gz gcc-0ba8a114c724d36034e8996eefb7c94d4fe8aed0.tar.bz2 |
Lazy __FUNCTION__ generation.
gcc:
Lazy __FUNCTION__ generation.
* c-common.h (RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME,
RID_C99_FUNCTION_NAME): New _RIDs.
(CTI_FUNCTION_ID, CTI_PRETTY_FUNCTION_ID, CTI_FUNC_ID): Remove.
(CTI_FUNCTION_NAME_DECL, CTI_PRETTY_FUNCTION_NAME_DECL,
CTI_C99_FUNCTION_NAME_DECL, CTI_SAVED_FUNCTION_NAME_DECLS): New
global tree slots.
(function_id_node, pretty_function_id_node, func_id_node): Remove.
(c99_function_name_decl_node, function_name_decl_node,
pretty_function_name_decl_node, saved_function_name_decls):
Declare.
(struct language_function): Remove x_function_name_declared_p.
(make_fname_decl): Remove a parameter.
(declare_function_names): Remove prototype.
(start_fname_decls, finish_fname_decls): Prototype.
(fname_as_string): Likewise.
(fname_string, fname_decl): Likewise.
* c-common.c (make_fname_decl): Adjust.
(struct fname_var_t): New struct.
(fname_vars): New static array.
(declare_function_name): Remove.
(start_fname_decls, finish_fname_decls): New functions.
(fname_as_string): New function from remnants of
declare_function_name.
(fname_string, fname_decl): New functions.
* c-decl.c (c_function_name_declared_p): Remove.
(init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(c_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number. Call finish_decl.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
Remove c_function_name_declared_p.
(push_c_function_context): Don't push c_function_name_declared_p.
(pop_c_function_context): Don't pop c_function_name_declared_p.
(c_begin_compound_stmt): Don't check c_function_name_declared_p.
* c-parse.in (STRING_FUNC_NAME, VAR_FUNC_NAME): New tokens.
(program): Call finish_fname_decls for C.
(primary): Add VAR_FUNC_NAME.
(reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
(yylexname): If it's a STRING_FUNC_NAME generate the function name
now. Don't look for VAR_DECLs containing __FUNCTION__ et al.
* c-semantics.c (prune_unused_decls): Remove.
(finish_stmt_tree): Don't call prune_unused_decls.
(genrtl_decl_stmt): Don't prune unused decls here.
cp:
Lazy __FUNCTION__ generation.
* cp-tree.def (FUNCTION_NAME): Remove.
* cp-tree.h (function_name_declared_p): Remove.
(cp_fname_init): Prototype.
* decl.c (init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(cp_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number.
(cp_fname_init): New function.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
* lex.c (reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
* optimize.c (maybe_clone_body): Remove function_name_declared_p.
* parse.y (VAR_FUNC_NAME): New token.
(primary): Add VAR_FUNC_NAME.
* pt.c (tsubst_decl): Adjust a DECL_PRETTY_FUNCTION_P's
generation.
(tsubst, FUNCTION_NAME case): Remove.
(tsubst_copy, FUNCTION_NAME case): Remove.
(tsubst_expr, DECL_STMT case): Be careful with a
DECL_PRETTY_FUNCTION_P.
(instantiate_decl): Remove function_name_declared_p.
* semantics.c (begin_compound_statement): Don't call
declare_function_name here.
(setup_vtbl_ptr). Don't save & restore function_name_declared_p.
(finish_translation_unit): Call finish_fname_decls.
(expand_body): Remove function_name_declared_p.
* typeck2.c (digest_init): Allow any ERROR_MARK.
testsuite:
* gcc.dg/c99-func-2.c: Remove xfail.
* gcc.dg/c99-func-3.c: Remove xfail.
* gcc.dg/c99-func-4.c: Remove xfail.
From-SVN: r41520
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1b88a78..2a1dc44 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5987,10 +5987,9 @@ tsubst_decl (t, args, type) /* For __PRETTY_FUNCTION__ we have to adjust the initializer. */ if (DECL_PRETTY_FUNCTION_P (r)) { - DECL_INITIAL (r) = tsubst (DECL_INITIAL (t), - args, - /*complain=*/1, - NULL_TREE); + const char *name = (*decl_printable_name) + (current_function_decl, 2); + DECL_INITIAL (r) = cp_fname_init (name); TREE_TYPE (r) = TREE_TYPE (DECL_INITIAL (r)); } @@ -6794,24 +6793,6 @@ tsubst (t, args, complain, in_decl) return TREE_TYPE (e1); } - case FUNCTION_NAME: - { - const char *name; - int len; - tree type; - tree str; - - /* This code should match declare_hidden_char_array in - c-common.c. */ - name = (*decl_printable_name) (current_function_decl, 2); - len = strlen (name) + 1; - type = build_array_type (char_type_node, - build_index_type (size_int (len))); - str = build_string (len, name); - TREE_TYPE (str) = type; - return str; - } - default: sorry ("use of `%s' in template", tree_code_name [(int) TREE_CODE (t)]); @@ -7172,9 +7153,6 @@ tsubst_copy (t, args, complain, in_decl) in_decl), tsubst (TREE_TYPE (t), args, complain, in_decl)); - case FUNCTION_NAME: - return tsubst (t, args, complain, in_decl); - default: return t; } @@ -7254,7 +7232,10 @@ tsubst_expr (t, args, complain, in_decl) { init = DECL_INITIAL (decl); decl = tsubst (decl, args, complain, in_decl); - init = tsubst_expr (init, args, complain, in_decl); + if (DECL_PRETTY_FUNCTION_P (decl)) + init = DECL_INITIAL (decl); + else + init = tsubst_expr (init, args, complain, in_decl); if (decl != error_mark_node) { if (TREE_CODE (decl) != TYPE_DECL) @@ -9934,10 +9915,6 @@ instantiate_decl (d, defer_ok) /* Set up context. */ start_function (NULL_TREE, d, NULL_TREE, SF_PRE_PARSED); - /* We already set up __FUNCTION__, etc., so we don't want to do - it again now. */ - function_name_declared_p = 1; - /* Substitute into the body of the function. */ tsubst_expr (DECL_SAVED_TREE (code_pattern), args, /*complain=*/1, tmpl); |