diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-09-17 07:38:23 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-09-17 07:38:23 +0000 |
commit | 8f17b5c5cbf15d0f3a548e94928caff9ffcfd7b8 (patch) | |
tree | 45edb9dcda813de0e477165a8b093d17332bda80 /gcc/cp | |
parent | 4797e955c6b44df4bef1d8d1c2ae9074480c6cf4 (diff) | |
download | gcc-8f17b5c5cbf15d0f3a548e94928caff9ffcfd7b8.zip gcc-8f17b5c5cbf15d0f3a548e94928caff9ffcfd7b8.tar.gz gcc-8f17b5c5cbf15d0f3a548e94928caff9ffcfd7b8.tar.bz2 |
splay-tree.c (splay_tree_predecessor): Fix typo in comment.
* splay-tree.c (splay_tree_predecessor): Fix typo in comment.
Convert the C front-end to use function-at-a-time mode.
* c-common.h: Include splay-tree.h.
(C_DECLARED_LABEL_FLAG): New macro.
(struct language_function): Add x_scope_stmt_stack and
x_function_name_declared_p.
(RECHAIN_STMTS): Move definition.
(lang_statment_code_p): Likewise.
(lang_expand_stmt): Likewise.
(lang_expand_decl_stmt): New variable.
(lang_expand_function_end): Likewise.
(current_scope_stmt_stack): New function.
(add_decl_stmt): Likewise.
(add_scope_stmt): Likewise.
(mark_stmt_tree): Likewise.
(struct c_lang_decl): New structure.
(DECL_SAVED_TREE): Define.
(c_mark_lang_decl): New function.
(c_expand_start_cond): Change prototype.
(c_finish_then): New function.
(c_finish_else): Likewise.
(current_function_name_declared): Remove.
(set_current_function_name_declared): Likewise.
(mark_c_language_function): Declare.
(case_compare): Likewise.
(c_add_case_label): Likewise.
(c_expand_expr): Likewise.
(c_safe_from_p): Likewise.
* c-common.c (lang_expand_function_end): New variable.
(struct if_elt): Add if_stmt.
(c_expand_start_cond): Add the if-statement to the statement-tree,
rather than generating RTL.
(c_finish_then): New function.
(c_expand_start_else): Don't generate RTL.
(c_finish_else): New function.
(c_expand_expr_stmt): Don't generate RTL.
(statement_code_p): Add SCOPE_STMT.
(case_compare): New function.
(c_add_case_label): Likewise.
(mark_stmt_tree): Likewise.
(c_mark_lang_decl): Likewise.
(mark_c_language_function): Likewise.
(c_expand_expr): Likewise.
(c_safe_from_p): Likewise.
* c-decl.c (c_stmt_tree): New variable
(c_scope_stmt_stack): Likewise.
(c_function_name_declared_p): Likewise.
(lang_expand_expr_stmt): Remove.
(poplevel): Don't call output_inline_function for nested
functions.
(pushdecl): Don't set DECL_CONTEXT for a local declaration of an
`extern' function.
(redeclaration_error_message): Change means of computing whether
or not a function is nested.
(lookup_label): Don't call label_rtx.
(init_decl_processing): Add more GC roots.
(start_decl): Add DECL_STMTs to the statement-tree, rather than
calling rest_of_decl_compilation.
(finish_decl): Don't call expand_decl.
(store_parm_decls): Begin the statement-tree, but don't generate
RTL.
(finish_function): Tie off the statement-tree. Call c_expand_body
if appropriate.
(c_expand_body): New function.
(push_c_function_context): Save more information.
(pop_c_function_contxt): Likewise.
(copy_lang_decl): Now that we use DECL_LANG_SPECIFIC, copy it.
(lang_mark_tree): Mark it.
(current_stmt_tree): Adjust.
(current_scope_stmt_stack): New function.
(do_case): Remove.
(set_current_name_declared): Likewise.
(c_begin_compound_stmt): Define.
(c_expand_decl_stmt): Likewise.
* c-lang.c: Include rtl.h and expr.h.
(lang_init): Set more language-specific hooks.
* c-lex.c: Include expr.h.
* c-parse.in: Changes throughout to add statements to the
statement-tree, rather than generating RTL after every statement.
* c-semantics.c (lang_expand_decl_stmt): Define.
(add_decl_stmt): New function.
(add_scope_stmt): Likewise.
(finish_stmt_tree): Tweak.
(genrtl_expr_stmt): Likewise.
(genrtl_decl_stmt): Handle local labels, and call
lang_expand_decl_stmt if required.
(genrtl_for_stmt): Fix line-number handling.
(genrtl_case_label): Handle cleanups.
(genrtl_asm_stmt): Don't call combine_strings.
(genrtl_compound_stmt): Simplify.
(expand_stmt): Handle SCOPE_STMTs.
* c-tree.h (struct lang_decl): New structure.
(C_DECLARED_LABEL_FLAG): Remove.
(c_begin_compound_stmt): Declare.
(c_expand_decl_stmt): Likewise.
(c_expand_start_case): Rename to c_start_case.
(c_finish_case): New function.
* c-typeck.c (start_init): Tweak setting of
constructor_incremental.
(c_expand_asm_operands): Tweak error-handling. Add to the
statement-tree.
(c_expand_return): Add to the statement-tree.
(c_expand_start_case): Rename to ...
(c_start_case): ... this.
(struct c_switch): New type.
(switch_stack): New variable.
(do_case): Simplify.
(c_finish_case): New function.
* dependence.c: Include expr.h.
(enum dependence_type): Change spelling of enumerals.
(check_node_dependence): Adjust.
* expr.h (lang_safe_from_p): Declare.
(safe_from_p): Likewise.
* expr.c (lang_safe_from_p): New variable.
(safe_from_p): Give it external linkage. Use lang_safe_from_p.
* stmt.c (expand_expr_stmt): Avoid clobberring of last_expr_type.
* toplev.c (rest_of_decl_compilation): Robustify.
* tree.c (contains_placeholder_p): Likewise.
* Makefile.in: Update dependencies.
* objc/objc-act.h: Adjust calculation of value for dummy_tree_code.
* objc/objc-act.c: Include rtl.h, expr.h, and c-common.h.
(objc_expand_function_end): New function.
(finish_method_def): Use it.
(init_objc): Initialize more language-specific hooks.
* objc/Make-lang.in: Update dependencies.
* cp-tree.h (struct cp_language_function): Remove
x_scope_stmt_stack and name_declared.
(current_scope_stmt_stack): Remove.
(function_name_declared_p): New macro.
(struct lang_decl_flags): Use c_lang_decl as a base class.
(context): Remove.
(struct lang_decl): Replace saved_tree with context.
(DECL_FRIEND_CONTEXT): Adjust accordingly.
(SET_DECL_FRIEND_CONTEXT): Likewise.
(DECL_VIRTUAL_CONTEXT): Likewise.
(DECL_SAVED_TREE): Remove.
(C_DECLARED_LABEL_FLAG): Likewise.
(cplus_expand_expr_stmt): Don't declare.
(add_decl_stmt): Likewise.
(add_scope_stmt): Likewise.
* decl.c (mark_stmt_tree): Remove.
(case_compare): Likewise.
(finish_case_label): Use c_add_case_label.
(init_decl_processing): Set more language-specific hooks.
(build_enumerator): Fix typo in comment.
(cplus_expand_expr_stmt): Remove.
(mark_lang_function): Use mark_c_language_function.
(lang_mark_tree): Use c_mark_lang_decl.
* decl2.c: Change order of inclusion.
* except.c: Likewise.
* expr.c (cplus_expand_expr): Remove handling of STMT_EXPR. Fall
back on c_expand_expr.
* friend.c: Include expr.h.
* init.c: Change order of inclusion.
* Makefile.in: Update dependencies.
* lex.h (free_lang_decl_chain): Remove.
* optimize.c (maybe_clone_body): Use function_name_declared_p.
* pt.c (build_template_decl): Don't copy DECL_VIRTUAL_CONTEXT if
it doesn't exist.
(instantiate_decl): Use function_name_declared_p.
* semantics.c (lang_expand_expr_stmt): Remove.
(set_current_function_name_declared): Likewise.
(current_function_name_declared): Likewise.
(begin_compound_stmt): Use function_name_declared_p.
(add_decl_stmt): Remove.
(setup_vtbl_ptr): Use function_name_declared_p.
(add_scope_stmt): Remove.
(current_scope_stmt_stack): New function.
(cp_expand_stmt): Don't handle SCOPE_STMTs.
(expand_body): Use function_name_declared_p.
* tree.c (cp_statement_code_p): Don't include SCOPE_STMT.
* typeck.c: Change order of includes.
(convert_sequence): Remove.
From-SVN: r36464
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 51 | ||||
-rw-r--r-- | gcc/cp/Makefile.in | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 40 | ||||
-rw-r--r-- | gcc/cp/decl.c | 205 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 2 | ||||
-rw-r--r-- | gcc/cp/except.c | 2 | ||||
-rw-r--r-- | gcc/cp/expr.c | 22 | ||||
-rw-r--r-- | gcc/cp/friend.c | 1 | ||||
-rw-r--r-- | gcc/cp/init.c | 2 | ||||
-rw-r--r-- | gcc/cp/lex.h | 2 | ||||
-rw-r--r-- | gcc/cp/optimize.c | 2 | ||||
-rw-r--r-- | gcc/cp/pt.c | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 97 | ||||
-rw-r--r-- | gcc/cp/tree.c | 1 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 34 |
15 files changed, 97 insertions, 371 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f54d9b3..66e3975 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,54 @@ +2000-09-16 Mark Mitchell <mark@codesourcery.com> + + * cp-tree.h (struct cp_language_function): Remove + x_scope_stmt_stack and name_declared. + (current_scope_stmt_stack): Remove. + (function_name_declared_p): New macro. + (struct lang_decl_flags): Use c_lang_decl as a base class. + (context): Remove. + (struct lang_decl): Replace saved_tree with context. + (DECL_FRIEND_CONTEXT): Adjust accordingly. + (SET_DECL_FRIEND_CONTEXT): Likewise. + (DECL_VIRTUAL_CONTEXT): Likewise. + (DECL_SAVED_TREE): Remove. + (C_DECLARED_LABEL_FLAG): Likewise. + (cplus_expand_expr_stmt): Don't declare. + (add_decl_stmt): Likewise. + (add_scope_stmt): Likewise. + * decl.c (mark_stmt_tree): Remove. + (case_compare): Likewise. + (finish_case_label): Use c_add_case_label. + (init_decl_processing): Set more language-specific hooks. + (build_enumerator): Fix typo in comment. + (cplus_expand_expr_stmt): Remove. + (mark_lang_function): Use mark_c_language_function. + (lang_mark_tree): Use c_mark_lang_decl. + * decl2.c: Change order of inclusion. + * except.c: Likewise. + * expr.c (cplus_expand_expr): Remove handling of STMT_EXPR. Fall + back on c_expand_expr. + * friend.c: Include expr.h. + * init.c: Change order of inclusion. + * Makefile.in: Update dependencies. + * lex.h (free_lang_decl_chain): Remove. + * optimize.c (maybe_clone_body): Use function_name_declared_p. + * pt.c (build_template_decl): Don't copy DECL_VIRTUAL_CONTEXT if + it doesn't exist. + (instantiate_decl): Use function_name_declared_p. + * semantics.c (lang_expand_expr_stmt): Remove. + (set_current_function_name_declared): Likewise. + (current_function_name_declared): Likewise. + (begin_compound_stmt): Use function_name_declared_p. + (add_decl_stmt): Remove. + (setup_vtbl_ptr): Use function_name_declared_p. + (add_scope_stmt): Remove. + (current_scope_stmt_stack): New function. + (cp_expand_stmt): Don't handle SCOPE_STMTs. + (expand_body): Use function_name_declared_p. + * tree.c (cp_statement_code_p): Don't include SCOPE_STMT. + * typeck.c: Change order of includes. + (convert_sequence): Remove. + 2000-09-14 Joseph S. Myers <jsm28@cam.ac.uk> * lex.c (reswords): Add _Complex. diff --git a/gcc/cp/Makefile.in b/gcc/cp/Makefile.in index 839e574..b81c4f0 100644 --- a/gcc/cp/Makefile.in +++ b/gcc/cp/Makefile.in @@ -265,7 +265,7 @@ class.o : class.c $(CXX_TREE_H) $(srcdir)/../flags.h \ call.o : call.c $(CXX_TREE_H) $(srcdir)/../flags.h \ $(srcdir)/../toplev.h $(RTL_H) $(EXPR_H) $(GGC_H) friend.o : friend.c $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H) \ - $(srcdir)/../toplev.h + $(srcdir)/../toplev.h $(EXPR_H) init.o : init.c $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H) \ $(EXPR_H) $(srcdir)/../toplev.h $(GGC_H) \ $(srcdir)/../except.h diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index de76e52..b7bc919 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -878,7 +878,6 @@ struct cp_language_function tree x_current_class_ptr; tree x_current_class_ref; tree x_eh_spec_try_block; - tree x_scope_stmt_stack; tree x_in_charge_parm; tree *x_vcalls_possible_p; @@ -889,7 +888,6 @@ struct cp_language_function int returns_null; int in_function_try_handler; int x_expanding_p; - int name_declared; int vtbls_set_up_p; struct named_label_use_list *x_named_label_uses; @@ -928,10 +926,6 @@ struct cp_language_function #define current_eh_spec_try_block cp_function_chain->x_eh_spec_try_block -/* The stack of SCOPE_STMTs for the current function. */ - -#define current_scope_stmt_stack cp_function_chain->x_scope_stmt_stack - /* The `__in_chrg' parameter for the current function. Only used for destructors. */ @@ -978,6 +972,12 @@ struct cp_language_function #define in_function_try_handler cp_function_chain->in_function_try_handler +/* Nonzero if __FUNCTION__ and its ilk have been declared in this + function. */ + +#define function_name_declared_p \ + (cp_function_chain->base.x_function_name_declared_p) + extern tree current_function_return_value; extern tree global_namespace; @@ -1811,6 +1811,8 @@ struct lang_type struct lang_decl_flags { + struct c_lang_decl base; + ENUM_BITFIELD(languages) language : 8; unsigned operator_attr : 1; @@ -1839,8 +1841,6 @@ struct lang_decl_flags unsigned generate_with_vtable_p : 1; unsigned dummy : 1; - tree context; - union { /* In a FUNCTION_DECL, VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is DECL_TEMPLATE_INFO. */ @@ -1872,8 +1872,9 @@ struct lang_decl tree befriending_classes; - /* In a FUNCTION_DECL, this is DECL_SAVED_TREE. */ - tree saved_tree; + /* For a virtual FUNCTION_DECL, this is DECL_VIRTUAL_CONTEXT. For a + non-virtual FUNCTION_DECL, this is DECL_FRIEND_CONTEXT. */ + tree context; /* In a FUNCTION_DECL, this is DECL_CLONED_FUNCTION. */ tree cloned_function; @@ -2168,12 +2169,12 @@ struct lang_decl the DECL_FRIEND_CONTEXT for `f' will be `S'. */ #define DECL_FRIEND_CONTEXT(NODE) \ ((DECL_FRIEND_P (NODE) && !DECL_FUNCTION_MEMBER_P (NODE)) \ - ? DECL_LANG_SPECIFIC (NODE)->decl_flags.context \ + ? DECL_LANG_SPECIFIC (NODE)->context \ : NULL_TREE) /* Set the DECL_FRIEND_CONTEXT for NODE to CONTEXT. */ #define SET_DECL_FRIEND_CONTEXT(NODE, CONTEXT) \ - (DECL_LANG_SPECIFIC (NODE)->decl_flags.context = (CONTEXT)) + (DECL_LANG_SPECIFIC (NODE)->context = (CONTEXT)) /* NULL_TREE in DECL_CONTEXT represents the global namespace. */ #define CP_DECL_CONTEXT(NODE) \ @@ -2183,7 +2184,7 @@ struct lang_decl /* For a virtual function, the base where we find its vtable entry. For a non-virtual function, the base where it is defined. */ #define DECL_VIRTUAL_CONTEXT(NODE) \ - (DECL_LANG_SPECIFIC (NODE)->decl_flags.context) + (DECL_LANG_SPECIFIC (NODE)->context) /* 1 iff NODE has namespace scope, including the global namespace. */ #define DECL_NAMESPACE_SCOPE_P(NODE) \ @@ -2409,12 +2410,6 @@ struct lang_decl the class definition is complete. */ #define TEMPLATE_PARMS_FOR_INLINE(NODE) TREE_LANG_FLAG_1 (NODE) -/* In a FUNCTION_DECL, the saved representation of the body of the - entire function. Usually a COMPOUND_STMT, but this may also be a - RETURN_INIT, CTOR_INITIALIZER, or TRY_BLOCK. */ -#define DECL_SAVED_TREE(NODE) \ - (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->saved_tree) - /* In a FUNCTION_DECL, the saved language-specific per-function data. */ #define DECL_SAVED_FUNCTION_DATA(NODE) \ (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.saved_language_function) @@ -2532,10 +2527,6 @@ extern int flag_new_for_scope; #define ARITHMETIC_TYPE_P(TYPE) \ (CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE) -/* Mark which labels are explicitly declared. - These may be shadowed, and may be referenced from nested functions. */ -#define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label) - /* Nonzero for _TYPE means that the _TYPE defines at least one constructor. */ #define TYPE_HAS_CONSTRUCTOR(NODE) (TYPE_LANG_FLAG_1(NODE)) @@ -3904,7 +3895,6 @@ extern tree start_method PARAMS ((tree, tree, tree)); extern tree finish_method PARAMS ((tree)); extern void hack_incomplete_structures PARAMS ((tree)); extern tree maybe_build_cleanup PARAMS ((tree)); -extern void cplus_expand_expr_stmt PARAMS ((tree)); extern void finish_stmt PARAMS ((void)); extern void replace_defarg PARAMS ((tree, tree)); extern void print_other_binding_stack PARAMS ((struct binding_level *)); @@ -4356,12 +4346,10 @@ extern tree finish_base_specifier PARAMS ((tree, tree)); extern void finish_member_declaration PARAMS ((tree)); extern void check_multiple_declarators PARAMS ((void)); extern tree finish_typeof PARAMS ((tree)); -extern void add_decl_stmt PARAMS ((tree)); extern void finish_decl_cleanup PARAMS ((tree, tree)); extern void finish_named_return_value PARAMS ((tree, tree)); extern void expand_body PARAMS ((tree)); extern void prep_stmt PARAMS ((tree)); -extern tree add_scope_stmt PARAMS ((int, int)); extern void do_pushlevel PARAMS ((void)); extern tree do_poplevel PARAMS ((void)); extern void finish_mem_initializers PARAMS ((tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4430d55..3b2a057 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -159,7 +159,6 @@ static void mark_named_label_lists PARAMS ((void *, void *)); static void mark_cp_function_context PARAMS ((struct function *)); static void mark_saved_scope PARAMS ((void *)); static void mark_lang_function PARAMS ((struct cp_language_function *)); -static void mark_stmt_tree PARAMS ((stmt_tree)); static void save_function_data PARAMS ((tree)); static void check_function_type PARAMS ((tree, tree)); static void destroy_local_var PARAMS ((tree)); @@ -176,7 +175,6 @@ static tree check_special_function_return_type PARAMS ((special_function_kind, tree, tree, tree)); static tree push_cp_library_fn PARAMS ((enum tree_code, tree)); static tree build_cp_library_fn PARAMS ((tree, enum tree_code, tree)); -static int case_compare PARAMS ((splay_tree_key, splay_tree_key)); static void store_parm_decls PARAMS ((tree)); #if defined (DEBUG_CP_BINDING_LEVELS) @@ -2411,16 +2409,6 @@ pop_nested_namespace (ns) scope isn't enough, because more binding levels may be pushed. */ struct saved_scope *scope_chain; -/* Mark ST for GC. */ - -static void -mark_stmt_tree (st) - stmt_tree st; -{ - ggc_mark_tree (st->x_last_stmt); - ggc_mark_tree (st->x_last_expr_type); -} - /* Mark ARG (which is really a struct saved_scope **) for GC. */ static void @@ -5156,21 +5144,6 @@ struct cp_switch static struct cp_switch *switch_stack; -static int -case_compare (k1, k2) - splay_tree_key k1; - splay_tree_key k2; -{ - /* Consider a NULL key (such as arises with a `default' label) to be - smaller than anything else. */ - if (!k1) - return k2 ? -1 : 0; - else if (!k2) - return k1 ? 1 : 0; - - return tree_int_cst_compare ((tree) k1, (tree) k2); -} - /* Called right after a switch-statement condition is parsed. SWITCH_STMT is the switch statement being parsed. */ @@ -5206,12 +5179,7 @@ finish_case_label (low_value, high_value) tree low_value; tree high_value; { - tree label; - tree cleanup; - tree type; tree cond; - tree case_label; - splay_tree_node node; if (! switch_stack) { @@ -5225,13 +5193,13 @@ finish_case_label (low_value, high_value) return; } - label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); - DECL_CONTEXT (label) = current_function_decl; - if (processing_template_decl) { + tree label; + /* For templates, just add the case label; we'll do semantic analysis at instantiation-time. */ + label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); add_stmt (build_case_label (low_value, high_value, label)); return; } @@ -5240,124 +5208,8 @@ finish_case_label (low_value, high_value) cond = SWITCH_COND (switch_stack->switch_stmt); if (cond && TREE_CODE (cond) == TREE_LIST) cond = TREE_VALUE (cond); - /* If there was an error processing the switch condition, bail now - before we get more confused. */ - if (!cond || cond == error_mark_node) - return; - type = TREE_TYPE (cond); - - if ((low_value && TREE_TYPE (low_value) - && POINTER_TYPE_P (TREE_TYPE (low_value))) - || (high_value && TREE_TYPE (high_value) - && POINTER_TYPE_P (TREE_TYPE (high_value)))) - error ("pointers are not permitted as case values"); - /* Case ranges are a GNU extension. */ - if (high_value && pedantic) - pedwarn ("ISO C++ forbids range expressions in switch statement"); - - if (low_value) - { - low_value = check_case_value (low_value); - low_value = convert_and_check (type, low_value); - } - if (high_value) - { - high_value = check_case_value (high_value); - high_value = convert_and_check (type, high_value); - } - - /* If an error has occurred, bail out now. */ - if (low_value == error_mark_node || high_value == error_mark_node) - return; - - /* If the LOW_VALUE and HIGH_VALUE are the same, then this isn't - really a case range, even though it was written that way. Remove - the HIGH_VALUE to simplify later processing. */ - if (tree_int_cst_equal (low_value, high_value)) - high_value = NULL_TREE; - if (low_value && high_value - && !tree_int_cst_lt (low_value, high_value)) - warning ("empty range specified"); - - /* Look up the LOW_VALUE in the table of case labels we already - have. */ - node = splay_tree_lookup (switch_stack->cases, (splay_tree_key) low_value); - /* If there was not an exact match, check for overlapping ranges. - There's no need to do this if there's no LOW_VALUE or HIGH_VALUE; - that's a `default' label and the only overlap is an exact match. */ - if (!node && (low_value || high_value)) - { - splay_tree_node low_bound; - splay_tree_node high_bound; - - /* Even though there wasn't an exact match, there might be an - overlap between this case range and another case range. - Since we've (inductively) not allowed any overlapping case - ranges, we simply need to find the greatest low case label - that is smaller that LOW_VALUE, and the smallest low case - label that is greater than LOW_VALUE. If there is an overlap - it will occur in one of these two ranges. */ - low_bound = splay_tree_predecessor (switch_stack->cases, - (splay_tree_key) low_value); - high_bound = splay_tree_successor (switch_stack->cases, - (splay_tree_key) low_value); - - /* Check to see if the LOW_BOUND overlaps. It is smaller than - the LOW_VALUE, so there is no need to check unless the - LOW_BOUND is in fact itself a case range. */ - if (low_bound - && CASE_HIGH ((tree) low_bound->value) - && tree_int_cst_compare (CASE_HIGH ((tree) low_bound->value), - low_value) >= 0) - node = low_bound; - /* Check to see if the HIGH_BOUND overlaps. The low end of that - range is bigger than the low end of the current range, so we - are only interested if the current range is a real range, and - not an ordinary case label. */ - else if (high_bound - && high_value - && (tree_int_cst_compare ((tree) high_bound->key, - high_value) - <= 0)) - node = high_bound; - } - /* If there was an overlap, issue an error. */ - if (node) - { - tree duplicate = CASE_LABEL_DECL ((tree) node->value); - - if (high_value) - { - error ("duplicate (or overlapping) case value"); - cp_error_at ("this is the first entry overlapping that value", - duplicate); - } - else if (low_value) - { - cp_error ("duplicate case value `%E'", low_value) ; - cp_error_at ("previously used here", duplicate); - } - else - { - error ("multiple default labels in one switch"); - cp_error_at ("this is the first default label", duplicate); - } - return; - } - - cleanup = last_cleanup_this_contour (); - if (cleanup) - { - static int explained = 0; - cp_warning_at ("destructor needed for `%#D'", TREE_PURPOSE (cleanup)); - warning ("where case label appears here"); - if (!explained) - { - warning ("(enclose actions of previous case statements requiring destructors in their own scope.)"); - explained = 1; - } - } + c_add_case_label (switch_stack->cases, cond, low_value, high_value); check_switch_goto (switch_stack->level); @@ -5365,16 +5217,6 @@ finish_case_label (low_value, high_value) own new (temporary) binding contour. */ current_binding_level->more_cleanups_ok = 0; current_function_return_value = NULL_TREE; - - /* Add a representation for the case label to the statement - tree. */ - case_label = build_case_label (low_value, high_value, label); - add_stmt (case_label); - - /* Register this case label in the splay tree. */ - splay_tree_insert (switch_stack->cases, - (splay_tree_key) low_value, - (splay_tree_value) case_label); } /* Return the list of declarations of the current level. @@ -6462,11 +6304,11 @@ init_decl_processing () /* Create all the identifiers we need. */ initialize_predefined_identifiers (); - /* Let the back-end now how to save and restore language-specific - per-function globals. */ + /* Fill in back-end hooks. */ init_lang_status = &push_cp_function_context; free_lang_status = &pop_cp_function_context; mark_lang_status = &mark_cp_function_context; + lang_safe_from_p = &c_safe_from_p; cp_parse_init (); init_decl2 (); @@ -13557,7 +13399,7 @@ build_enumerator (name, value, enumtype) if (context && context == current_class_type) /* This enum declaration is local to the class. We need the full - lang_decl so that we can record DECL_CLASS_CONTEXT, for example. */ + lang_decl so that we can record DECL_CLASS_CONTEXT, for example. */ decl = build_lang_decl (CONST_DECL, name, type); else /* It's a global enum, or it's local to a function. (Note local to @@ -14696,31 +14538,6 @@ maybe_build_cleanup (decl) return 0; } -/* Expand a C++ expression at the statement level. - This is needed to ferret out nodes which have UNKNOWN_TYPE. - The C++ type checker should get all of these out when - expressions are combined with other, type-providing, expressions, - leaving only orphan expressions, such as: - - &class::bar; / / takes its address, but does nothing with it. */ - -void -cplus_expand_expr_stmt (exp) - tree exp; -{ -#if 0 - /* We should do this eventually, but right now this causes regex.o from - libg++ to miscompile, and tString to core dump. */ - exp = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (exp), exp); -#endif - - /* If we don't do this, we end up down inside expand_expr - trying to do TYPE_MODE on the ERROR_MARK, and really - go outside the bounds of the type. */ - if (exp != error_mark_node) - expand_expr_stmt (exp); -} - /* When a stmt has been parsed, this function is called. */ void @@ -14801,17 +14618,17 @@ mark_lang_function (p) if (!p) return; + mark_c_language_function (&p->base); + ggc_mark_tree (p->x_ctor_label); ggc_mark_tree (p->x_dtor_label); ggc_mark_tree (p->x_current_class_ptr); ggc_mark_tree (p->x_current_class_ref); ggc_mark_tree (p->x_eh_spec_try_block); - ggc_mark_tree (p->x_scope_stmt_stack); ggc_mark_rtx (p->x_result_rtx); mark_named_label_lists (&p->x_named_labels, &p->x_named_label_uses); - mark_stmt_tree (&p->base.x_stmt_tree); mark_binding_level (&p->bindings); } @@ -14872,13 +14689,13 @@ lang_mark_tree (t) if (ld) { ggc_mark (ld); + c_mark_lang_decl (&ld->decl_flags.base); if (!DECL_GLOBAL_CTOR_P (t) && !DECL_GLOBAL_DTOR_P (t) && !DECL_THUNK_P (t)) ggc_mark_tree (ld->decl_flags.u2.access); else if (DECL_THUNK_P (t)) ggc_mark_tree (ld->decl_flags.u2.vcall_offset); - ggc_mark_tree (ld->decl_flags.context); if (TREE_CODE (t) != NAMESPACE_DECL) ggc_mark_tree (ld->decl_flags.u.template_info); else @@ -14886,7 +14703,7 @@ lang_mark_tree (t) if (CAN_HAVE_FULL_LANG_DECL_P (t)) { ggc_mark_tree (ld->befriending_classes); - ggc_mark_tree (ld->saved_tree); + ggc_mark_tree (ld->context); ggc_mark_tree (ld->cloned_function); if (!DECL_OVERLOADED_OPERATOR_P (t)) ggc_mark_tree (ld->u2.vtt_parm); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index a2cdb1d..b579f59 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -32,13 +32,13 @@ Boston, MA 02111-1307, USA. */ #include "system.h" #include "tree.h" #include "rtl.h" +#include "expr.h" #include "flags.h" #include "cp-tree.h" #include "decl.h" #include "lex.h" #include "output.h" #include "except.h" -#include "expr.h" #include "defaults.h" #include "toplev.h" #include "dwarf2out.h" diff --git a/gcc/cp/except.c b/gcc/cp/except.c index e872859..ee2cf44 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -27,10 +27,10 @@ Boston, MA 02111-1307, USA. */ #include "system.h" #include "tree.h" #include "rtl.h" +#include "expr.h" #include "cp-tree.h" #include "flags.h" #include "obstack.h" -#include "expr.h" #include "output.h" #include "except.h" #include "defaults.h" diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c index 39095ec..c49a2f9 100644 --- a/gcc/cp/expr.c +++ b/gcc/cp/expr.c @@ -133,28 +133,8 @@ cplus_expand_expr (exp, target, tmode, modifier) /* We don't need to generate any code for an empty class. */ return const0_rtx; - case STMT_EXPR: - { - tree rtl_expr; - rtx result; - - /* Since expand_expr_stmt calls free_temp_slots after every - expression statement, we must call push_temp_slots here. - Otherwise, any temporaries in use now would be considered - out-of-scope after the first EXPR_STMT from within the - STMT_EXPR. */ - push_temp_slots (); - rtl_expr = expand_start_stmt_expr (); - expand_stmt (STMT_EXPR_STMT (exp)); - expand_end_stmt_expr (rtl_expr); - result = expand_expr (rtl_expr, target, tmode, modifier); - pop_temp_slots (); - return result; - } - break; - default: - break; + return c_expand_expr (exp, target, tmode, modifier); } my_friendly_abort (40); /* NOTREACHED */ diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 950169a..1cc99052 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -22,6 +22,7 @@ Boston, MA 02111-1307, USA. */ #include "system.h" #include "tree.h" #include "rtl.h" +#include "expr.h" #include "cp-tree.h" #include "flags.h" #include "output.h" diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 5a86965..89619ee 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -26,11 +26,11 @@ Boston, MA 02111-1307, USA. */ #include "system.h" #include "tree.h" #include "rtl.h" +#include "expr.h" #include "cp-tree.h" #include "flags.h" #include "output.h" #include "except.h" -#include "expr.h" #include "toplev.h" #include "ggc.h" diff --git a/gcc/cp/lex.h b/gcc/cp/lex.h index 1439c18..272a917 100644 --- a/gcc/cp/lex.h +++ b/gcc/cp/lex.h @@ -88,6 +88,4 @@ extern int pending_lang_change; extern int yylex PARAMS ((void)); -extern struct lang_decl *free_lang_decl_chain; - #endif /* _CP_LEX_H */ diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index fdc1a52..be53216 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -1004,7 +1004,7 @@ maybe_clone_body (fn) VARRAY_FREE (id.fns); /* Now, expand this function into RTL, if appropriate. */ - cp_function_chain->name_declared = 1; + function_name_declared_p = 1; expand_body (finish_function (0)); pop_from_top_level (); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 99443b5..e3357a0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1985,7 +1985,8 @@ build_template_decl (decl, parms) DECL_CONTEXT (tmpl) = DECL_CONTEXT (decl); if (DECL_LANG_SPECIFIC (decl)) { - DECL_VIRTUAL_CONTEXT (tmpl) = DECL_VIRTUAL_CONTEXT (decl); + if (CAN_HAVE_FULL_LANG_DECL_P (decl)) + DECL_VIRTUAL_CONTEXT (tmpl) = DECL_VIRTUAL_CONTEXT (decl); DECL_STATIC_FUNCTION_P (tmpl) = DECL_STATIC_FUNCTION_P (decl); DECL_CONSTRUCTOR_P (tmpl) = DECL_CONSTRUCTOR_P (decl); DECL_NONCONVERTING_P (tmpl) = DECL_NONCONVERTING_P (decl); @@ -9689,7 +9690,7 @@ instantiate_decl (d, defer_ok) /* We already set up __FUNCTION__, etc., so we don't want to do it again now. */ - cp_function_chain->name_declared = 1; + function_name_declared_p = 1; /* Substitute into the body of the function. */ tsubst_expr (DECL_SAVED_TREE (code_pattern), args, diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 88eaa72..2f4432f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -77,19 +77,6 @@ static void genrtl_finish_function PARAMS ((tree)); substmt = cond; \ } while (0) -/* Wrapper since C and C++ expand_expr_stmt are different. */ - -expand_expr_stmt_fn lang_expand_expr_stmt = cplus_expand_expr_stmt; - -/* Wrapper function instead of #define for use with c-common code. */ - -void -set_current_function_name_declared (i) - int i; -{ - cp_function_chain->name_declared = i; -} - /* Returns non-zero if the current statement is a full expression, i.e. temporaries created during that statement should be destroyed at the end of the statement. */ @@ -112,16 +99,6 @@ current_stmt_tree () : &scope_chain->x_stmt_tree); } -/* One if we have already declared __FUNCTION__ (and related - variables) in the current function. Two if we are in the process - of doing so. */ - -int -current_function_name_declared () -{ - return cp_function_chain->name_declared; -} - /* Nonzero if TYPE is an anonymous union or struct type. We have to use a flag for this because "A union for which objects or pointers are declared is not an anonymous union" [class.union]. */ @@ -863,10 +840,10 @@ begin_compound_stmt (has_no_scope) /* If this is the outermost block of the function, declare the variables __FUNCTION__, __PRETTY_FUNCTION__, and so forth. */ if (cfun - && !(current_function_name_declared () ) + && !function_name_declared_p && !has_no_scope) { - cp_function_chain->name_declared = 1; + function_name_declared_p = 1; declare_function_name (); } @@ -962,20 +939,6 @@ finish_label_decl (name) add_decl_stmt (decl); } -/* Create a declaration statement for the declaration given by the - DECL. */ - -void -add_decl_stmt (decl) - tree decl; -{ - tree decl_stmt; - - /* We need the type to last until instantiation time. */ - decl_stmt = build_stmt (DECL_STMT, decl); - add_stmt (decl_stmt); -} - /* Generate the RTL for a SUBOBJECT. */ static void @@ -1216,10 +1179,10 @@ setup_vtbl_ptr (member_init_list, base_init_list) /* Don't declare __PRETTY_FUNCTION__ and friends here when we open the block for the if-body. */ - saved_cfnd = current_function_name_declared (); - cp_function_chain->name_declared = 1; + saved_cfnd = function_name_declared_p; + function_name_declared_p = 1; compound_stmt = begin_compound_stmt (/*has_no_scope=*/0); - cp_function_chain->name_declared = saved_cfnd; + function_name_declared_p = saved_cfnd; /* Make all virtual function table pointers in non-virtual base classes point to CURRENT_CLASS_TYPE's virtual function @@ -1240,48 +1203,12 @@ setup_vtbl_ptr (member_init_list, base_init_list) vtbls_set_up_p = 1; } +/* Returns the stack of SCOPE_STMTs for the current function. */ -/* Add a scope-statement to the statement-tree. BEGIN_P indicates - whether this statements opens or closes a scope. PARTIAL_P is true - for a partial scope, i.e, the scope that begins after a label when - an object that needs a cleanup is created. If BEGIN_P is nonzero, - 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 - SCOPE_BEGIN_P set. */ - -tree -add_scope_stmt (begin_p, partial_p) - int begin_p; - int partial_p; +tree * +current_scope_stmt_stack () { - tree ss; - tree top; - - /* Build the statement. */ - ss = build_stmt (SCOPE_STMT, NULL_TREE); - SCOPE_BEGIN_P (ss) = begin_p; - SCOPE_PARTIAL_P (ss) = partial_p; - - /* Keep the scope stack up to date. */ - if (begin_p) - { - current_scope_stmt_stack - = tree_cons (ss, NULL_TREE, current_scope_stmt_stack); - top = current_scope_stmt_stack; - } - else - { - top = current_scope_stmt_stack; - TREE_VALUE (top) = ss; - current_scope_stmt_stack = TREE_CHAIN (top); - } - - /* Add the new statement to the statement-tree. */ - add_stmt (ss); - - return top; + return &cfun->language->x_scope_stmt_stack; } /* Finish a parenthesized expression EXPR. */ @@ -2236,10 +2163,6 @@ cp_expand_stmt (t) genrtl_subobject (SUBOBJECT_CLEANUP (t)); break; - case SCOPE_STMT: - genrtl_scope_stmt (t); - break; - case RETURN_INIT: genrtl_named_return_value (); break; @@ -2483,7 +2406,7 @@ expand_body (fn) /* We don't need to redeclare __FUNCTION__, __PRETTY_FUNCTION__, or any of the other magic variables we set up when starting a function body. */ - cp_function_chain->name_declared = 1; + function_name_declared_p = 1; /* Expand the body. */ expand_stmt (DECL_SAVED_TREE (fn)); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 396b5c4..9b5e2be 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1081,7 +1081,6 @@ cp_statement_code_p (code) case CLEANUP_STMT: case START_CATCH_STMT: case CTOR_STMT: - case SCOPE_STMT: case CTOR_INITIALIZER: case RETURN_INIT: case TRY_BLOCK: diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e15a724..3a16526 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -34,11 +34,11 @@ Boston, MA 02111-1307, USA. */ #include "system.h" #include "tree.h" #include "rtl.h" +#include "expr.h" #include "cp-tree.h" #include "tm_p.h" #include "flags.h" #include "output.h" -#include "expr.h" #include "toplev.h" #include "defaults.h" @@ -54,9 +54,6 @@ static int comp_except_types PARAMS ((tree, tree, int)); static int comp_array_types PARAMS ((int (*) (tree, tree, int), tree, tree, int)); static tree common_base_type PARAMS ((tree, tree)); -#if 0 -static tree convert_sequence PARAMS ((tree, tree)); -#endif static tree lookup_anon_field PARAMS ((tree, tree)); static tree pointer_diff PARAMS ((tree, tree, tree)); static tree build_component_addr PARAMS ((tree, tree)); @@ -4745,35 +4742,6 @@ build_unary_op (code, xarg, noconvert) return error_mark_node; } -#if 0 -/* If CONVERSIONS is a conversion expression or a nested sequence of such, - convert ARG with the same conversions in the same order - and return the result. */ - -static tree -convert_sequence (conversions, arg) - tree conversions; - tree arg; -{ - switch (TREE_CODE (conversions)) - { - case NOP_EXPR: - case CONVERT_EXPR: - case FLOAT_EXPR: - case FIX_TRUNC_EXPR: - case FIX_FLOOR_EXPR: - case FIX_ROUND_EXPR: - case FIX_CEIL_EXPR: - return cp_convert (TREE_TYPE (conversions), - convert_sequence (TREE_OPERAND (conversions, 0), - arg)); - - default: - return arg; - } -} -#endif - /* Apply unary lvalue-demanding operator CODE to the expression ARG for certain kinds of expressions which are not really lvalues but which we can accept as lvalues. |