diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-04-24 08:22:06 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-04-24 08:22:06 +0000 |
commit | 65b7f83fcb833ccbead60bbb1533884ad0898486 (patch) | |
tree | 268353894884ce2459e1f3b08adc4825b8ed0dd6 /gcc/c-semantics.c | |
parent | 2b686fc594fc9314f3585e5f0e32a8d15fb79765 (diff) | |
download | gcc-65b7f83fcb833ccbead60bbb1533884ad0898486.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41520 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-semantics.c')
-rw-r--r-- | gcc/c-semantics.c | 75 |
1 files changed, 4 insertions, 71 deletions
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c index c491335e1e8..13480480a43 100644 --- a/gcc/c-semantics.c +++ b/gcc/c-semantics.c @@ -48,8 +48,6 @@ void (*lang_expand_stmt) PARAMS ((tree)); variables and labels do not require any RTL generation. */ void (*lang_expand_decl_stmt) PARAMS ((tree)); -static tree prune_unused_decls PARAMS ((tree *, int *, void *)); - /* Create an empty statement tree rooted at T. */ void @@ -73,8 +71,9 @@ add_stmt (t) /* Add T to the statement-tree. */ TREE_CHAIN (last_tree) = t; last_tree = t; + /* When we expand a statement-tree, we must know whether or not the - statements are full-expresions. We record that fact here. */ + statements are full-expressions. We record that fact here. */ STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p (); /* Keep track of the number of statements in this function. */ @@ -105,7 +104,7 @@ add_decl_stmt (decl) returns a new TREE_LIST representing the top of the SCOPE_STMT stack. The TREE_PURPOSE is the new SCOPE_STMT. If BEGIN_P is zero, returns a TREE_LIST whose TREE_VALUE is the new SCOPE_STMT, - and whose TREE_PURPOSE is the matching SCOPE_STMT iwth + and whose TREE_PURPOSE is the matching SCOPE_STMT with SCOPE_BEGIN_P set. */ tree @@ -141,61 +140,6 @@ add_scope_stmt (begin_p, partial_p) return top; } -/* Remove declarations of internal variables that are not used from a - stmt tree. To qualify, the variable must have a name and must have - a zero DECL_SOURCE_LINE. We tried to remove all variables for - which TREE_USED was false, but it turns out that there's tons of - variables for which TREE_USED is false but that are still in fact - used. */ - -static tree -prune_unused_decls (tp, walk_subtrees, data) - tree *tp; - int *walk_subtrees ATTRIBUTE_UNUSED; - void *data ATTRIBUTE_UNUSED; -{ - tree t = *tp; - - if (t == NULL_TREE) - return error_mark_node; - - if (TREE_CODE (t) == DECL_STMT) - { - tree d = DECL_STMT_DECL (t); - if (!TREE_USED (d) && DECL_NAME (d) && DECL_SOURCE_LINE (d) == 0) - { - *tp = TREE_CHAIN (t); - /* Recurse on the new value of tp, otherwise we will skip - the next statement. */ - return prune_unused_decls (tp, walk_subtrees, data); - } - } - else if (TREE_CODE (t) == SCOPE_STMT) - { - /* Remove all unused decls from the BLOCK of this SCOPE_STMT. */ - tree block = SCOPE_STMT_BLOCK (t); - - if (block) - { - tree *vp; - - for (vp = &BLOCK_VARS (block); *vp; ) - { - tree v = *vp; - if (! TREE_USED (v) && DECL_NAME (v) && DECL_SOURCE_LINE (v) == 0) - *vp = TREE_CHAIN (v); /* drop */ - else - vp = &TREE_CHAIN (v); /* advance */ - } - /* If there are now no variables, the entire BLOCK can be dropped. - (This causes SCOPE_NULLIFIED_P (t) to be true.) */ - if (BLOCK_VARS (block) == NULL_TREE) - SCOPE_STMT_BLOCK (t) = NULL_TREE; - } - } - return NULL_TREE; -} - /* Finish the statement tree rooted at T. */ void @@ -209,9 +153,6 @@ finish_stmt_tree (t) *t = stmt; last_tree = NULL_TREE; - /* Remove unused decls from the stmt tree. */ - walk_stmt_tree (t, prune_unused_decls, NULL); - if (cfun && stmt) { /* The line-number recorded in the outermost statement in a function @@ -420,15 +361,7 @@ genrtl_decl_stmt (t) DECL_ANON_UNION_ELEMS (decl)); } else if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)) - { - if (DECL_ARTIFICIAL (decl) && ! TREE_USED (decl)) - /* Do not emit unused decls. This is not just an - optimization. We really do not want to emit - __PRETTY_FUNCTION__ etc, if they're never used. */ - DECL_IGNORED_P (decl) = 1; - else - make_rtl_for_local_static (decl); - } + make_rtl_for_local_static (decl); else if (TREE_CODE (decl) == LABEL_DECL && C_DECLARED_LABEL_FLAG (decl)) declare_nonlocal_label (decl); |