diff options
author | Martin v. Löwis <loewis@informatik.hu-berlin.de> | 1998-05-07 22:06:26 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-05-07 22:06:26 -0400 |
commit | 2c73f9f57ac31b4c79c8e9282c748e3294cd7e95 (patch) | |
tree | b63320f941aa58f44dbdc20a5d48fb3384cb73c1 | |
parent | 0d33d22e9ff0d6cba03b7ef6f099f215b260c7e1 (diff) | |
download | gcc-2c73f9f57ac31b4c79c8e9282c748e3294cd7e95.zip gcc-2c73f9f57ac31b4c79c8e9282c748e3294cd7e95.tar.gz gcc-2c73f9f57ac31b4c79c8e9282c748e3294cd7e95.tar.bz2 |
massive namespace patch
From-SVN: r19631
-rw-r--r-- | gcc/cp/ChangeLog | 240 | ||||
-rw-r--r-- | gcc/cp/call.c | 106 | ||||
-rw-r--r-- | gcc/cp/class.c | 397 | ||||
-rw-r--r-- | gcc/cp/cp-tree.def | 9 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 102 | ||||
-rw-r--r-- | gcc/cp/decl.c | 847 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 694 | ||||
-rw-r--r-- | gcc/cp/error.c | 6 | ||||
-rw-r--r-- | gcc/cp/except.c | 4 | ||||
-rw-r--r-- | gcc/cp/exception.cc | 35 | ||||
-rw-r--r-- | gcc/cp/friend.c | 4 | ||||
-rw-r--r-- | gcc/cp/inc/exception | 4 | ||||
-rw-r--r-- | gcc/cp/inc/new | 12 | ||||
-rw-r--r-- | gcc/cp/inc/new.h | 2 | ||||
-rw-r--r-- | gcc/cp/inc/typeinfo | 4 | ||||
-rw-r--r-- | gcc/cp/init.c | 25 | ||||
-rw-r--r-- | gcc/cp/lang-options.h | 2 | ||||
-rw-r--r-- | gcc/cp/lang-specs.h | 1 | ||||
-rw-r--r-- | gcc/cp/lex.c | 32 | ||||
-rw-r--r-- | gcc/cp/method.c | 63 | ||||
-rw-r--r-- | gcc/cp/new.cc | 3 | ||||
-rw-r--r-- | gcc/cp/new1.cc | 4 | ||||
-rw-r--r-- | gcc/cp/new2.cc | 2 | ||||
-rw-r--r-- | gcc/cp/parse.c | 1562 | ||||
-rw-r--r-- | gcc/cp/parse.y | 14 | ||||
-rw-r--r-- | gcc/cp/pt.c | 117 | ||||
-rw-r--r-- | gcc/cp/ptree.c | 5 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 4 | ||||
-rw-r--r-- | gcc/cp/search.c | 39 | ||||
-rw-r--r-- | gcc/cp/sig.c | 15 | ||||
-rw-r--r-- | gcc/cp/spew.c | 15 | ||||
-rw-r--r-- | gcc/cp/tinfo.cc | 4 | ||||
-rw-r--r-- | gcc/cp/tinfo.h | 2 | ||||
-rw-r--r-- | gcc/cp/tinfo2.cc | 1 | ||||
-rw-r--r-- | gcc/cp/tree.c | 131 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 38 |
36 files changed, 2839 insertions, 1706 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8c4b6ba..887026d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,243 @@ +Mon Apr 27 07:17:38 1998 Martin von Loewis <loewis@informatik.hu-berlin.de> + + * cp-tree.def (OVERLOAD): New node. + * cp-tree.h (BINDING_TYPE, SET_IDENTIFIER_GLOBAL_VALUE, + SET_IDENTIFIER_NAMESPACE_VALUE): Define. + (NAMESPACE_BINDING): Remove. + (IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_NAMESPACE_VALUE): Use + namespace_binding. + (OVL_FUNCTION, OVL_CHAIN, OVL_CURRENT, OVL_NEXT, OVL_USED): + Define. + (tree_overload): New struct. + (IDENTIFIER_TYPE_VALUE): Use identifier_type_value. + (REAL_IDENTIFIER_TYPE_VALUE): Define. + (IDENTIFIER_HAS_TYPE_VALUE): Use IDENTIFIER_TYPE_VALUE. + (lang_decl_flags): Remove in_namespace. + (lang_decl): Remove chain. + (DECL_CHAIN, DECL_NAMESPACE): Remove. + (flag_honor_std): Declare extern. + (identifier_type_value, pushdecl_namespace_level, push_using_decl, + namespace_binding, set_namespace_binding, + lookup_function_nonclass, cat_namespace_levels, + set_decl_namespace, lookup_arg_dependent, binding_init, ovl_cons, + scratch_ovl_cons, ovl_member, build_overload): Declare. + (decl_list_length, get_namespace_id, current_namespace_id, + overloaded_globals_p): Remove. + (lookup_using_namespace, qualified_lookup_using_namespace): Change + return type. + (push_scratch_obstack): New macro. + * call.c (add_function_candidate): Special-case type of OVERLOAD node. + (build_user_conversions_1): Iterate using OVL_NEXT for ctors, + convs, fns. + (build_new_function_call): Iterate using OVL_CHAIN. + Print DECL_NAME in when reporting ambiguities. + (build_object_call): Iterate using OVL_NEXT for fns, convs. + (build_new_op): Call lookup_function_nonclass. + Iterate using OVL_NEXT. + (build_op_delete_call): Change detection of members. + Do not wrap TREE_LIST around fields and single global functions. + (build_over_call): Don't push a class level if the context is a + namespace. + (build_new_method_call): Iterate using OVL_NEXT. + * class.c (add_method): Chain overloaded members using + build_overload. Remove copying of method. + (grow_method): When iterating through the obstack, expect OVERLOAD + nodes. Chain overload members. + (finish_struct_methods): Chain overload members. Unpack OVERLOAD + nodes in call to get_baselinks. + (duplicate_tag_error): Expect OVERLOAD nodes when unchaining. + (finish_struct_1): Iterate over ctor using OVL_NEXT. Handle + fdecls that are OVERLOAD nodes. + (validate_lhs): New function. + (instantiate_type): Do not copy OVERLOAD nodes. Remove dead + code. Use DECL_NAME in error messages. Split code between global + and member function processing. + * decl.c (global_type_node): New static variable. + (in_std): New global. + (struct binding_level): New field usings. + (resume_binding_level): Assert that we are not in a class. + (toplevel_bindings_p): Just check for namespace_p or + pseudo_global. + (resume_level): Remove. + (find_binding): New function. + (binding_for_name): Call it. + (namespace_binding, set_namespace_binding): New functions. + (push_namespace): Associate binding level with new namespace, + resume_binding_level for existing namespace. Remove old code. + Fake std by counting. + (store_bindings): Use REAL_IDENTIFIER_TYPE_VALUE. + (maybe_push_to_top_level): Save current namespace. + (pop_from_top_level): Restore saved namespace. + (pop_namespace): Call suspend_binding_level. Remove old code. + (cat_namespace_levels): New function. + (set_identifier_type_value_with_scope): For namespace bindings, + set BINDING_TYPE, and use global_type_node. + Use REAL_IDENTIFIER_TYPE_VALUE otherwise. + (identifier_type_value): New function. + (pushtag): If no context, use current_namespace. + (duplicate_decls): Don't process DECL_CHAIN. + (pushdecl): Set DECL_CONTEXT to current_namespace, if it is not + already set. Never reset it to NULL_TREE. Lookup global variables + in their namespace. Push overloaded templates if they are on + namespace level. + (pushdecl_namespace_level): New function. + (pushdecl_top_level): Implement using pushdecl_namespace_level. + (pushdecl_using_decl): New function. + (overloaded_globals_p): Remove. + (push_overloaded_decl): Create OVERLOAD nodes, and iterate through + them. Use namespace_binding and set_namespace_value. + (redeclaration_error_message): Complain if the declarations come + from different namespaces. + (lookup_tag): On namespace level, look in the BINDING_TYPE. + (lookup_namespace_name): Pass tree_bindings from stack. Remove + old code. + (select_decl): New function. + (lookup_name_real): Call it for qualified and unqualified lookup. + Pass tree_bindings from the stack. + If prefer_type is 1, also accept namespaces. + (lookup_function_nonclass): New function. + (init_decl_processing): Set the binding level of the global + namespace to global_binding_level. + Build a proper type list for __builtin_apply. + Initialize std_node to "fake std" if flag_honor_std is set. + Initialize global_type_node. + Allocated bad_alloc in namespace std if flag_honor_std. + (define_function): Set the DECL_CONTEXT to the current_namespace. + (start_decl): A namespace is not considered as a context here. If + the DECL_CONTEXT is a namespace, push the decl. + (cp_finish_decl): Check for namespaces used as initializers. + (grokfndecl): Add namespace parameter. Remove processing of + DECL_CHAIN. + (grokvardecl): Add namespace parameter. + (grokdeclarator): Process SCOPEs that are namespaces. For + mangling, temporarily set the DECL_CONTEXT on anonymous structs. + (start_function): Check for contexts that are namespaces. + Set context for declarations that have not been pushed. + (store_parm_decls): Check for ::main only. + (finish_function): Likewise. + (start_method): Check for contexts that are namespaces. + (start_method): Remove DECL_CHAIN processing. + * decl2.c (flag_honor_std): Declare. + (lang_decode_option): Set it if -fhonor-std or -fnew-abi is given. + (decl_namespace_list): New static global. + (grok_x_components): Ignore namespaces as type contexts. + (check_classfn): Expect OVERLOAD nodes. + (grokfield): Remove DECL_CHAIN processing. + (finish_file): Call cat_namespace_levels. + (merge_functions): New function. + (ambiguous_decl): Rewrite. + (lookup_using_namespace): Produce tree_bindings. + (qualified_lookup_using_namespace): Likewise. + (set_decl_namespace, decl_namespace, current_decl_namespace, + push_decl_namespace, pop_decl_namespace): New functions. + (arg_lookup): New struct. + (add_function, arg_assoc_namespace, arg_assoc_class, + arg_assoc_type, arg_assoc_args, arg_assoc, lookup_arg_dependent): + New functions. + (get_namespace_id, current_namespace_id): Remove. + (do_toplevel_using_decl): Rewrite. + (do_class_using_decl): Complain about namespace qualifiers. + (do_using_directive): Sorry if not on namespace level. Complain + about unknown namespaces. + * error.c (dump_aggr_type): Check for namespace contexts. + * except.c (init_exception_processing): Push terminate into std. + * friend.c (is_friend): A namespace is not a context, here. + * init.c (expand_member_init): Remove DECL_CHAIN processing. + (build_offset_ref): Process OVERLOAD nodes. + * lang-specs.h (__HONOR_STD): Define if -fnew-abi or -fhonor-std. + * lex.c (identifier_type): Loop using OVL_CHAIN. + (see_typename): Set looking_for_typename to 2. + (real_yylex): Likewise. + (do_identifier): Expect OVERLOAD nodes instead of TREE_LISTs. + (do_scoped_id): Expect OVERLOAD nodes. + Change calling convention for qualified_lookup_using_namespace. + (build_lang_decl): Don't set in_namespace anymore. + * method.c (typevec_size): New global. + (build_overload_nested_name): Return if global_namespace. + Otherwise, always expect a declaration context. + (build_qualified_name): Likewise. + Make sure we don't write beyond typevec_size. + (build_decl_overload_real): Likewise. + Allocate one extra slot for the namespace. + (hack_identifier): Mark code dead. + Process OVERLOAD and NAMESPACE_DECL nodes. + * parse.y (program): Pop namespaces until in global namespace. + (extdef): In a using-declaration, don't discard the identifier if + there is no declaration. + (left_curly): Ignore type contexts which are namespaces. + (typename_sub2): Use IDENTIFIER_TYPE_VALUE to retrieve the type + used as scope. + * pt.c (template_class_depth): Expect types to be namespaces. + (determine_specialization): Simplify by expecting OVERLOAD nodes. + (push_template_decl): Push into namespace level. + Reset ctx if it is a namespace. + Set DECL_CONTEXT to current_namespace if not set already. + Ignore real contexts that are namespaces. + (mangle_class_name_for_template): Skip global_namespace. + Mangle other namepaces as declarations. + (lookup_template_function): Set type of OVERLOAD nodes to unknown. + (lookup_template_class): Push into namespace of context. + If the context is a namespace, set it to global_namespace. + Use id_context for mangling. + (for_each_template_parm): Handle OVERLOAD and NAMESPACE_DECL nodes. + (tsubst_friend_function): Ignore namespace contexts. + Push into namespace level. + (tsubst): Handle NAMESPACE_DECL nodes. + Remove DECL_CHAIN processing. + (type_unification_real): Recognize OVERLOAD instead of TREE_LIST nodes. + * ptree.c (print_lang_identifier): Print bindings. + (lang_print_xnode): Print OVERLOAD nodes. + * rtti.c (init_rtti_processing): Push type_info into std. + * search.c (lookup_fnfields_here): Expect OVERLOAD nodes. + (lookup_fnfields_1, get_virtuals_named_this, get_matching_virtual, + dfs_debug_mark, dfs_pushdecls, dfs_compress_decls, add_conversions, + lookup_fnfields_here): Likewise. + Process all nodes, instead of going through TREE_CHAIN. + * sig.c (build_signature_pointer_or_reference_type): Set context + to global_namespace. + (build_signature_table_constructor): Expect OVERLOAD nodes. + * spew.c (yylex): Save old setting of looking_for_typename. + * tree.c (decl_list_length): Remove. + (binding_init): New function. + (count_functions): Rewrite. + (is_overloaded_fn): Expect OVERLOAD nodes. + (really_overloaded_fn, get_first_fn, lvalue_type): Likewise. + (ovl_cons, scratch_ovl_cons, build_overload, build_overload_after, + ovl_member): New functions. + * typeck.c (require_complete_type): Expect OVERLOAD nodes. + (type_unknown_p): Likewise. + (require_instantiated_type): Likewise. + (build_component_ref): Declare code dead. + (build_x_function_call): Create and expect OVERLOAD nodes. + (build_function_call_real): Check for ::main only. + (build_unary_op): Likewise. Expect OVERLOAD nodes. + (convert_for_assignment): Check for TREE_LIST before accessing + TREE_VALUE. + * decl.c (duplicate_decls): Check for namespace bindings instead + of global bindings. + (pushdecl, push_overloaded_decl, lookup_tag, lookup_name_real, + lookup_name_current_level, start_decl, xref_tag, + finish_enum): Likewise. + * init.c (build_offset_ref): Likewise. + * search.c (lookup_field): Likewise. + (lookup_fnfields): Likewise. + (dfs_debug_mark): Likewise. + * decl.c (poplevel): Use SET_IDENTIFIER_TYPE_VALUE. + (poplevel_class, pop_from_top_level): Likewise. + * decl2.c (finish_method): Likewise. + * class.c (build_vtable): Use SET_IDENTIFIER_GLOBAL_VALUE. + * decl.c (record_builtin_type): Likewise. + (init_decl_processing, grokfndecl): Likewise. + * lex.c (get_time_identifier, do_identifier, do_scoped_id): Likewise. + (make_lang_type): Likewise. + * parse.y (make_thunk): Likewise. + * pt.c (tsubst): Likewise. + * tree.c (debug_binfo): Likewise. + * exception.cc, new.cc, new1.cc, new2.cc, tinfo.cc, tinfo.h, + tinfo2.cc, inc/new.h: Add std qualifications. + * inc/new: Wrap with namespace std if __HONOR_STD. + * inc/typeinfo: Likewise. + Fri May 8 00:43:50 1998 Jason Merrill <jason@yorick.cygnus.com> * call.c (build_user_type_conversion_1): Handle second_conv diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c79fafc..e9ca9af 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1117,6 +1117,9 @@ add_function_candidate (candidates, fn, arglist, flags) tree argtype = TREE_TYPE (arg); tree t; + /* An overloaded function does not have an argument type */ + if (TREE_CODE (arg) == OVERLOAD) + argtype = unknown_type_node; argtype = cp_build_type_variant (argtype, TREE_READONLY (arg), TREE_THIS_VOLATILE (arg)); @@ -2044,20 +2047,21 @@ build_user_type_conversion_1 (totype, expr, flags) ctors = TREE_VALUE (ctors); } - for (; ctors; ctors = DECL_CHAIN (ctors)) + for (; ctors; ctors = OVL_NEXT (ctors)) { - if (DECL_NONCONVERTING_P (ctors)) + tree ctor = OVL_CURRENT (ctors); + if (DECL_NONCONVERTING_P (ctor)) continue; - if (TREE_CODE (ctors) == TEMPLATE_DECL) + if (TREE_CODE (ctor) == TEMPLATE_DECL) { - templates = scratch_tree_cons (NULL_TREE, ctors, templates); + templates = scratch_tree_cons (NULL_TREE, ctor, templates); candidates = - add_template_candidate (candidates, ctors, + add_template_candidate (candidates, ctor, NULL_TREE, args, NULL_TREE, flags); } else - candidates = add_function_candidate (candidates, ctors, + candidates = add_function_candidate (candidates, ctor, args, flags); if (candidates) @@ -2072,7 +2076,7 @@ build_user_type_conversion_1 (totype, expr, flags) for (; convs; convs = TREE_CHAIN (convs)) { - tree fn = TREE_VALUE (convs); + tree fns = TREE_VALUE (convs); int convflags = LOOKUP_NO_CONVERSION; tree ics; @@ -2083,9 +2087,9 @@ build_user_type_conversion_1 (totype, expr, flags) if (TREE_CODE (totype) == REFERENCE_TYPE) convflags |= LOOKUP_NO_TEMP_BIND; - if (TREE_CODE (fn) != TEMPLATE_DECL) + if (TREE_CODE (fns) != TEMPLATE_DECL) ics = implicit_conversion - (totype, TREE_TYPE (TREE_TYPE (fn)), 0, convflags); + (totype, TREE_TYPE (TREE_TYPE (OVL_CURRENT (fns))), 0, convflags); else /* We can't compute this yet. */ ics = error_mark_node; @@ -2093,8 +2097,9 @@ build_user_type_conversion_1 (totype, expr, flags) if (TREE_CODE (totype) == REFERENCE_TYPE && ics && ICS_BAD_FLAG (ics)) /* ignore the near match. */; else if (ics) - for (; fn; fn = DECL_CHAIN (fn)) + for (; fns; fns = OVL_NEXT (fns)) { + tree fn = OVL_CURRENT (fns); struct z_candidate *old_candidates = candidates; if (TREE_CODE (fn) == TEMPLATE_DECL) @@ -2240,7 +2245,7 @@ build_new_function_call (fn, args) if (really_overloaded_fn (fn)) { - tree t; + tree t1; tree templates = NULL_TREE; args = resolve_args (args); @@ -2248,8 +2253,9 @@ build_new_function_call (fn, args) if (args == error_mark_node) return error_mark_node; - for (t = TREE_VALUE (fn); t; t = DECL_CHAIN (t)) + for (t1 = fn; t1; t1 = OVL_CHAIN (t1)) { + tree t = OVL_FUNCTION (t1); if (TREE_CODE (t) == TEMPLATE_DECL) { templates = scratch_tree_cons (NULL_TREE, t, templates); @@ -2267,7 +2273,7 @@ build_new_function_call (fn, args) if (candidates && ! candidates->next) return build_function_call (candidates->fn, args); cp_error ("no matching function for call to `%D (%A)'", - TREE_PURPOSE (fn), args); + DECL_NAME (OVL_FUNCTION (fn)), args); if (candidates) print_z_candidates (candidates); return error_mark_node; @@ -2278,7 +2284,7 @@ build_new_function_call (fn, args) if (cand == 0) { cp_error ("call of overloaded `%D (%A)' is ambiguous", - TREE_PURPOSE (fn), args); + DECL_NAME (OVL_FUNCTION (fn)), args); print_z_candidates (candidates); return error_mark_node; } @@ -2293,6 +2299,9 @@ build_new_function_call (fn, args) return build_over_call (cand, args, LOOKUP_NORMAL); } + /* This is not really overloaded. */ + fn = OVL_CURRENT (fn); + return build_function_call (fn, args); } @@ -2325,11 +2334,12 @@ build_object_call (obj, args) if (fns) { - tree fn = TREE_VALUE (fns); + tree base = TREE_PURPOSE (fns); mem_args = scratch_tree_cons (NULL_TREE, build_this (obj), args); - for (; fn; fn = DECL_CHAIN (fn)) + for (fns = TREE_VALUE (fns); fns; fns = OVL_NEXT (fns)) { + tree fn = OVL_CURRENT (fns); if (TREE_CODE (fn) == TEMPLATE_DECL) { templates = scratch_tree_cons (NULL_TREE, fn, templates); @@ -2343,7 +2353,7 @@ build_object_call (obj, args) (candidates, fn, mem_args, LOOKUP_NORMAL); if (candidates) - candidates->basetype_path = TREE_PURPOSE (fns); + candidates->basetype_path = base; } } @@ -2351,13 +2361,15 @@ build_object_call (obj, args) for (; convs; convs = TREE_CHAIN (convs)) { - tree fn = TREE_VALUE (convs); - tree totype = TREE_TYPE (TREE_TYPE (fn)); + tree fns = TREE_VALUE (convs); + tree totype = TREE_TYPE (TREE_TYPE (OVL_CURRENT (fns))); + tree fn; if (TREE_CODE (totype) == POINTER_TYPE && TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE) - for (; fn; fn = DECL_CHAIN (fn)) + for (; fns; fns = OVL_NEXT (fn)) { + fn = OVL_CURRENT (fn); if (TREE_CODE (fn) == TEMPLATE_DECL) { templates = scratch_tree_cons (NULL_TREE, fn, templates); @@ -2477,7 +2489,7 @@ build_new_op (code, flags, arg1, arg2, arg3) arglist = scratch_tree_cons (NULL_TREE, arg2, arg3); if (flags & LOOKUP_GLOBAL) return build_new_function_call - (lookup_name_nonclass (fnname), arglist); + (lookup_function_nonclass (fnname, arglist), arglist); /* FIXME */ rval = build_method_call @@ -2499,9 +2511,11 @@ build_new_op (code, flags, arg1, arg2, arg3) tree rval; if (flags & LOOKUP_GLOBAL) - return build_new_function_call - (lookup_name_nonclass (fnname), - build_scratch_list (NULL_TREE, arg1)); + { + arglist = build_scratch_list (NULL_TREE, arg1); + return build_new_function_call + (lookup_function_nonclass (fnname, arglist), arglist); + } arglist = scratch_tree_cons (NULL_TREE, arg1, build_scratch_list (NULL_TREE, arg2)); @@ -2576,23 +2590,23 @@ build_new_op (code, flags, arg1, arg2, arg3) else arglist = build_scratch_list (NULL_TREE, arg1); - fns = lookup_name_nonclass (fnname); - /* + Koenig lookup */ + fns = lookup_function_nonclass (fnname, arglist); if (fns && TREE_CODE (fns) == TREE_LIST) fns = TREE_VALUE (fns); - for (; fns; fns = DECL_CHAIN (fns)) + for (; fns; fns = OVL_NEXT (fns)) { - if (TREE_CODE (fns) == TEMPLATE_DECL) + tree fn = OVL_CURRENT (fns); + if (TREE_CODE (fn) == TEMPLATE_DECL) { - templates = scratch_tree_cons (NULL_TREE, fns, templates); + templates = scratch_tree_cons (NULL_TREE, fn, templates); candidates - = add_template_candidate (candidates, fns, NULL_TREE, + = add_template_candidate (candidates, fn, NULL_TREE, arglist, TREE_TYPE (fnname), flags); } else - candidates = add_function_candidate (candidates, fns, arglist, flags); + candidates = add_function_candidate (candidates, fn, arglist, flags); } if (IS_AGGR_TYPE (TREE_TYPE (arg1))) @@ -2606,10 +2620,11 @@ build_new_op (code, flags, arg1, arg2, arg3) if (fns) { - tree fn = TREE_VALUE (fns); + tree basetype = TREE_PURPOSE (fns); mem_arglist = scratch_tree_cons (NULL_TREE, build_this (arg1), TREE_CHAIN (arglist)); - for (; fn; fn = DECL_CHAIN (fn)) + for (fns = TREE_VALUE (fns); fns; fns = OVL_NEXT (fns)) { + tree fn = OVL_CURRENT (fns); tree this_arglist; if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) @@ -2631,7 +2646,7 @@ build_new_op (code, flags, arg1, arg2, arg3) (candidates, fn, this_arglist, flags); if (candidates) - candidates->basetype_path = TREE_PURPOSE (fns); + candidates->basetype_path = basetype; } } @@ -2860,7 +2875,8 @@ build_op_new_call (code, type, args, flags) return build_method_call (dummy, fnname, args, NULL_TREE, flags); } else - return build_new_function_call (lookup_name_nonclass (fnname), args); + return build_new_function_call + (lookup_function_nonclass (fnname, args), args); } /* Build a call to operator delete. This has to be handled very specially, @@ -2908,9 +2924,12 @@ build_op_delete_call (code, addr, size, flags) if (fns) { +#if 0 + /* It is unnecessary to wrap another TREE_LIST around it. (MvL) */ /* Build this up like build_offset_ref does. */ fns = build_tree_list (error_mark_node, fns); TREE_TYPE (fns) = build_offset_type (type, unknown_type_node); +#endif } else fns = lookup_name_nonclass (fnname); @@ -2957,15 +2976,15 @@ build_op_delete_call (code, addr, size, flags) /* instantiate_type will always return a plain function; pretend it's overloaded. */ if (TREE_CODE (fns) == FUNCTION_DECL) - fns = scratch_tree_cons (NULL_TREE, fns, NULL_TREE); + fns = scratch_ovl_cons (fns, NULL_TREE); fn = instantiate_type (fntype, fns, 0); if (fn != error_mark_node) { - if (TREE_CODE (TREE_VALUE (fns)) == TREE_LIST) + if (TREE_CODE (fns) == TREE_LIST) /* Member functions. */ - enforce_access (TREE_PURPOSE (TREE_VALUE (fns)), fn); + enforce_access (TREE_PURPOSE (fns), fn); return build_function_call (fn, expr_tree_cons (NULL_TREE, addr, args)); } @@ -3268,12 +3287,14 @@ build_over_call (cand, args, flags) we must be careful to do name lookup in the scope of S<T>, rather than in the current class. */ - if (DECL_REAL_CONTEXT (fn)) + if (DECL_REAL_CONTEXT (fn) + && TREE_CODE (DECL_REAL_CONTEXT (fn)) != NAMESPACE_DECL) pushclass (DECL_REAL_CONTEXT (fn), 2); arg = tsubst_expr (arg, DECL_TI_ARGS (fn), NULL_TREE); - if (DECL_REAL_CONTEXT (fn)) + if (DECL_REAL_CONTEXT (fn) + && TREE_CODE (DECL_CONTEXT (fn)) != NAMESPACE_DECL) popclass (0); } converted_args = expr_tree_cons @@ -3540,7 +3561,7 @@ build_new_method_call (instance, name, args, basetype_path, flags) return error_mark_node; if (fns) { - tree t = TREE_VALUE (fns); + tree fn = TREE_VALUE (fns); if (name == ctor_identifier && TYPE_USES_VIRTUAL_BASECLASSES (basetype) && ! (flags & LOOKUP_HAS_IN_CHARGE)) { @@ -3548,8 +3569,9 @@ build_new_method_call (instance, name, args, basetype_path, flags) args = scratch_tree_cons (NULL_TREE, integer_one_node, args); } mem_args = scratch_tree_cons (NULL_TREE, instance_ptr, args); - for (; t; t = DECL_CHAIN (t)) + for (; fn; fn = OVL_NEXT (fn)) { + tree t = OVL_CURRENT (fn); tree this_arglist; /* We can end up here for copy-init of same or base class. */ diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 5f054f0..fe5b861 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -710,7 +710,8 @@ build_vtable (binfo, type) /* Set TREE_PUBLIC and TREE_EXTERN as appropriate. */ import_export_vtable (decl, type, 0); - IDENTIFIER_GLOBAL_VALUE (name) = decl = pushdecl_top_level (decl); + decl = pushdecl_top_level (decl); + SET_IDENTIFIER_GLOBAL_VALUE (name, decl); /* Initialize the association list for this type, based on our first approximation. */ TYPE_BINFO_VTABLE (type) = decl; @@ -1072,42 +1073,24 @@ void add_method (type, fields, method) tree type, *fields, method; { - /* We must make a copy of METHOD here, since we must be sure that - we have exclusive title to this method's DECL_CHAIN. */ - tree decl; - push_obstacks (&permanent_obstack, &permanent_obstack); - { - decl = copy_node (method); - if (DECL_RTL (decl) == 0 - && (!processing_template_decl - || !uses_template_parms (decl))) - { - make_function_rtl (decl); - DECL_RTL (method) = DECL_RTL (decl); - } - } if (fields && *fields) - { - /* Take care not to hide destructor. */ - DECL_CHAIN (decl) = DECL_CHAIN (*fields); - DECL_CHAIN (*fields) = decl; - } + *fields = build_overload (method, *fields); else if (CLASSTYPE_METHOD_VEC (type) == 0) { tree method_vec = make_node (TREE_VEC); - if (TYPE_IDENTIFIER (type) == DECL_NAME (decl)) + if (TYPE_IDENTIFIER (type) == DECL_NAME (method)) { /* ??? Is it possible for there to have been enough room in the current chunk for the tree_vec structure but not a tree_vec plus a tree*? Will this work in that case? */ obstack_free (current_obstack, method_vec); obstack_blank (current_obstack, sizeof (struct tree_vec) + sizeof (tree *)); - if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl))) - TREE_VEC_ELT (method_vec, 1) = decl; + if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (method))) + TREE_VEC_ELT (method_vec, 1) = method; else - TREE_VEC_ELT (method_vec, 0) = decl; + TREE_VEC_ELT (method_vec, 0) = method; TREE_VEC_LENGTH (method_vec) = 2; } else @@ -1117,7 +1100,7 @@ add_method (type, fields, method) plus a tree*? Will this work in that case? */ obstack_free (current_obstack, method_vec); obstack_blank (current_obstack, sizeof (struct tree_vec) + 2*sizeof (tree *)); - TREE_VEC_ELT (method_vec, 2) = decl; + TREE_VEC_ELT (method_vec, 2) = method; TREE_VEC_LENGTH (method_vec) = 3; obstack_finish (current_obstack); } @@ -1130,15 +1113,13 @@ add_method (type, fields, method) /* Adding a new ctor or dtor. This is easy because our METHOD_VEC always has a slot for such entries. */ - if (TYPE_IDENTIFIER (type) == DECL_NAME (decl)) + if (TYPE_IDENTIFIER (type) == DECL_NAME (method)) { - int idx = !!DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl)); - /* TREE_VEC_ELT (method_vec, idx) = decl; */ - if (decl != TREE_VEC_ELT (method_vec, idx)) - { - DECL_CHAIN (decl) = TREE_VEC_ELT (method_vec, idx); - TREE_VEC_ELT (method_vec, idx) = decl; - } + int idx = !!DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (method)); + /* TREE_VEC_ELT (method_vec, idx) = method; */ + if (method != TREE_VEC_ELT (method_vec, idx)) + TREE_VEC_ELT (method_vec, idx) = + build_overload (method, TREE_VEC_ELT (method_vec, idx)); } else { @@ -1177,7 +1158,7 @@ add_method (type, fields, method) } obstack_finish (ob); - TREE_VEC_ELT (method_vec, len) = decl; + TREE_VEC_ELT (method_vec, len) = method; TREE_VEC_LENGTH (method_vec) = len + 1; CLASSTYPE_METHOD_VEC (type) = method_vec; @@ -1194,8 +1175,8 @@ add_method (type, fields, method) } } } - DECL_CONTEXT (decl) = type; - DECL_CLASS_CONTEXT (decl) = type; + DECL_CONTEXT (method) = type; + DECL_CLASS_CONTEXT (method) = type; pop_obstacks (); } @@ -1866,16 +1847,11 @@ grow_method (fndecl, method_vec_ptr) tree *testp = &TREE_VEC_ELT (method_vec, 2); while (testp < (tree *) obstack_next_free (&class_obstack) - && (*testp == NULL_TREE || DECL_NAME (*testp) != DECL_NAME (fndecl))) + && (*testp == NULL_TREE || DECL_NAME (OVL_CURRENT (*testp)) != DECL_NAME (fndecl))) testp++; if (testp < (tree *) obstack_next_free (&class_obstack)) - { - tree *p; - for (p = testp; *p; ) - p = &DECL_CHAIN (*p); - *p = fndecl; - } + *testp = build_overload (fndecl, *testp); else { obstack_ptr_grow (&class_obstack, fndecl); @@ -1966,14 +1942,14 @@ finish_struct_methods (t, fn_fields, nonprivate_method) if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (fn_fields))) { /* Destructors go in slot 1. */ - DECL_CHAIN (fn_fields) = TREE_VEC_ELT (method_vec, 1); - TREE_VEC_ELT (method_vec, 1) = fn_fields; + TREE_VEC_ELT (method_vec, 1) = + build_overload (fn_fields, TREE_VEC_ELT (method_vec, 1)); } else { /* Constructors go in slot 0. */ - DECL_CHAIN (fn_fields) = TREE_VEC_ELT (method_vec, 0); - TREE_VEC_ELT (method_vec, 0) = fn_fields; + TREE_VEC_ELT (method_vec, 0) = + build_overload (fn_fields, TREE_VEC_ELT (method_vec, 0)); } } else if (IDENTIFIER_TYPENAME_P (fn_name)) @@ -2057,7 +2033,8 @@ finish_struct_methods (t, fn_fields, nonprivate_method) for (i = 2; i < len; i++) { TREE_VEC_ELT (baselink_vec, i) - = get_baselinks (baselink_binfo, t, DECL_NAME (TREE_VEC_ELT (method_vec, i))); + = get_baselinks (baselink_binfo, t, + DECL_NAME (OVL_CURRENT (TREE_VEC_ELT (method_vec, i)))); if (TREE_VEC_ELT (baselink_vec, i) != 0) any_links = 1; } @@ -2098,8 +2075,8 @@ duplicate_tag_error (t) tree unchain = TREE_VEC_ELT (method_vec, i); while (unchain != NULL_TREE) { - TREE_CHAIN (unchain) = NULL_TREE; - unchain = DECL_CHAIN (unchain); + TREE_CHAIN (OVL_CURRENT (unchain)) = NULL_TREE; + unchain = OVL_NEXT (unchain); } } } @@ -3675,8 +3652,8 @@ finish_struct_1 (t, warn_anon) for (ctor = TREE_VEC_ELT (method_vec, 0); ctor; - ctor = DECL_CHAIN (ctor)) - if (! TREE_PRIVATE (ctor)) + ctor = OVL_NEXT (ctor)) + if (! TREE_PRIVATE (OVL_CURRENT (ctor))) { nonprivate_ctor = 1; break; @@ -3710,10 +3687,19 @@ finish_struct_1 (t, warn_anon) int i = 2; tree tmp; + /* Functions are represented as TREE_LIST, with the purpose + being the type and the value the functions. Other members + come as themselves. */ if (TREE_CODE (fdecl) == TREE_LIST) { + /* Ignore base type this came from. */ + fdecl = TREE_VALUE (fdecl); + } + if (TREE_CODE (fdecl) == OVERLOAD) + { + /* We later iterate over all functions. */ flist = fdecl; - fdecl = TREE_VALUE (flist); + fdecl = OVL_FUNCTION (flist); } name = DECL_NAME (fdecl); @@ -3746,12 +3732,11 @@ finish_struct_1 (t, warn_anon) /* Make type T see field decl FDECL with access ACCESS.*/ if (flist) { - fdecl = TREE_VALUE (flist); - while (fdecl) + while (flist) { - if (alter_access (t, fdecl, access) == 0) + if (alter_access (t, OVL_FUNCTION (flist), access) == 0) break; - fdecl = DECL_CHAIN (fdecl); + flist = OVL_CHAIN (flist); } } else @@ -4921,6 +4906,29 @@ pop_lang_context () /* Type instantiation routines. */ +static tree +validate_lhs (lhstype, complain) + tree lhstype; + int complain; +{ + if (TYPE_PTRMEMFUNC_P (lhstype)) + lhstype = TYPE_PTRMEMFUNC_FN_TYPE (lhstype); + + if (TREE_CODE (lhstype) == POINTER_TYPE) + { + if (TREE_CODE (TREE_TYPE (lhstype)) == FUNCTION_TYPE + || TREE_CODE (TREE_TYPE (lhstype)) == METHOD_TYPE) + lhstype = TREE_TYPE (lhstype); + else + { + if (complain) + error ("invalid type combination for overload"); + return error_mark_node; + } + } + return lhstype; +} + /* This function will instantiate the type of the expression given in RHS to match the type of LHSTYPE. If errors exist, then return error_mark_node. If only complain is COMPLAIN is set. If we are @@ -4955,7 +4963,10 @@ instantiate_type (lhstype, rhs, complain) return error_mark_node; } - rhs = copy_node (rhs); + /* We don't overwrite rhs if it is an overloaded function. + Copying it would destroy the tree link. */ + if (TREE_CODE (rhs) != OVERLOAD) + rhs = copy_node (rhs); /* This should really only be used when attempting to distinguish what sort of a pointer to function we have. For now, any @@ -5016,6 +5027,9 @@ instantiate_type (lhstype, rhs, complain) return function; } + /* I could not trigger this code. MvL */ + my_friendly_abort (980326); +#if 0 my_friendly_assert (TREE_CODE (field) == FIELD_DECL, 178); my_friendly_assert (!(TREE_CODE (TREE_TYPE (field)) == FUNCTION_TYPE || TREE_CODE (TREE_TYPE (field)) == METHOD_TYPE), @@ -5056,6 +5070,7 @@ instantiate_type (lhstype, rhs, complain) error ("no appropriate overload exists for COMPONENT_REF"); return error_mark_node; } +#endif return rhs; } @@ -5064,149 +5079,167 @@ instantiate_type (lhstype, rhs, complain) explicit_targs = TREE_OPERAND (rhs, 1); rhs = TREE_OPERAND (rhs, 0); } - /* fall through */ + /* fall through */ + my_friendly_assert (TREE_CODE (rhs) == OVERLOAD, 980401); - case TREE_LIST: + case OVERLOAD: { - tree elem, baselink, name = NULL_TREE; - int globals = overloaded_globals_p (rhs); + tree elem, elems; - /* First look for an exact match. Search either overloaded - functions or member functions. May have to undo what - `default_conversion' might do to lhstype. */ + /* First look for an exact match. Search overloaded + functions. May have to undo what `default_conversion' + might do to lhstype. */ - if (TYPE_PTRMEMFUNC_P (lhstype)) - lhstype = TYPE_PTRMEMFUNC_FN_TYPE (lhstype); + lhstype = validate_lhs (lhstype, complain); + if (lhstype == error_mark_node) + return lhstype; - if (TREE_CODE (lhstype) == POINTER_TYPE) - { - if (TREE_CODE (TREE_TYPE (lhstype)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (lhstype)) == METHOD_TYPE) - lhstype = TREE_TYPE (lhstype); - else - { - if (complain) - error ("invalid type combination for overload"); - return error_mark_node; - } - } - - if (TREE_CODE (lhstype) != FUNCTION_TYPE && globals > 0) + if (TREE_CODE (lhstype) != FUNCTION_TYPE) { + rhs = DECL_NAME (OVL_FUNCTION (rhs)); if (complain) - cp_error ("cannot resolve overloaded function `%D' based on non-function type", - TREE_PURPOSE (rhs)); + cp_error("cannot resolve overloaded function `%D' " + "based on non-function type", rhs); return error_mark_node; } - - if (globals > 0) - { - elem = get_first_fn (rhs); - /* If there are explicit_targs, only a template function - can match. */ - if (explicit_targs == NULL_TREE) - while (elem) + + elems = rhs; + /* If there are explicit_targs, only a template function + can match. */ + if (explicit_targs == NULL_TREE) + while (elems) + { + elem = OVL_FUNCTION (elems); + if (! comptypes (lhstype, TREE_TYPE (elem), 1)) + elems = OVL_CHAIN (elems); + else { - if (! comptypes (lhstype, TREE_TYPE (elem), 1)) - elem = DECL_CHAIN (elem); - else - { - mark_used (elem); - return elem; - } + mark_used (elem); + return elem; } + } - /* No exact match found, look for a compatible template. */ - { - tree save_elem = 0; - for (elem = get_first_fn (rhs); elem; elem = DECL_CHAIN (elem)) - if (TREE_CODE (elem) == TEMPLATE_DECL) + /* No exact match found, look for a compatible template. */ + { + tree save_elem = 0; + elems = rhs; + if (TREE_CODE (elems) == TREE_LIST) + elems = TREE_VALUE (rhs); + for (; elems; elems = OVL_NEXT (elems)) + if (TREE_CODE (elem = OVL_CURRENT (elems)) == TEMPLATE_DECL) + { + int n = DECL_NTPARMS (elem); + tree t = make_scratch_vec (n); + int i; + i = type_unification + (DECL_INNERMOST_TEMPLATE_PARMS (elem), t, + TYPE_ARG_TYPES (TREE_TYPE (elem)), + TYPE_ARG_TYPES (lhstype), explicit_targs, 1, 1); + if (i == 0) { - int n = DECL_NTPARMS (elem); - tree t = make_scratch_vec (n); - int i; - i = type_unification - (DECL_INNERMOST_TEMPLATE_PARMS (elem), t, - TYPE_ARG_TYPES (TREE_TYPE (elem)), - TYPE_ARG_TYPES (lhstype), explicit_targs, 1, 1); - if (i == 0) + if (save_elem) { - if (save_elem) - { - cp_error ("ambiguous template instantiation converting to `%#T'", lhstype); - return error_mark_node; - } - save_elem = instantiate_template (elem, t); - /* Check the return type. */ - if (! comptypes (TREE_TYPE (lhstype), - TREE_TYPE (TREE_TYPE (save_elem)), 1)) - save_elem = 0; + cp_error ("ambiguous template instantiation converting to `%#T'", lhstype); + return error_mark_node; } + save_elem = instantiate_template (elem, t); + /* Check the return type. */ + if (! comptypes (TREE_TYPE (lhstype), + TREE_TYPE (TREE_TYPE (save_elem)), 1)) + save_elem = 0; } - if (save_elem) - { - mark_used (save_elem); - return save_elem; - } + } + if (save_elem) + { + mark_used (save_elem); + return save_elem; } + } - /* If there are explicit_targs, only a template function - can match. */ - if (explicit_targs == NULL_TREE) + /* If there are explicit_targs, only a template function + can match. */ + if (explicit_targs == NULL_TREE) + { + /* No match found, look for a compatible function. */ + tree elems = rhs; + elems = rhs; + for (; elems; elems = OVL_NEXT (elems)) { - /* No match found, look for a compatible function. */ - elem = get_first_fn (rhs); - while (elem && comp_target_types (lhstype, - TREE_TYPE (elem), 1) <= 0) - elem = DECL_CHAIN (elem); - if (elem) + elem = OVL_CURRENT (elems); + if (comp_target_types (lhstype, TREE_TYPE (elem), 1) > 0) + break; + } + if (elems) + { + tree save_elem = elem; + for (elems = OVL_CHAIN (elems); elems; + elems = OVL_CHAIN (elems)) + { + elem = OVL_FUNCTION (elems); + if (comp_target_types (lhstype, TREE_TYPE (elem), 0) > 0) + break; + } + if (elems) { - tree save_elem = elem; - elem = DECL_CHAIN (elem); - while (elem - && comp_target_types (lhstype, - TREE_TYPE (elem), 0) <= 0) - elem = DECL_CHAIN (elem); - if (elem) + if (complain) { - if (complain) - { - cp_error - ("cannot resolve overload to target type `%#T'", - lhstype); - cp_error_at (" ambiguity between `%#D'", - save_elem); - cp_error_at (" and `%#D', at least", elem); - } - return error_mark_node; + cp_error + ("cannot resolve overload to target type `%#T'", + lhstype); + cp_error_at (" ambiguity between `%#D'", save_elem); + cp_error_at (" and `%#D', at least", elem); } - mark_used (save_elem); - return save_elem; + return error_mark_node; } + mark_used (save_elem); + return save_elem; } - if (complain) - { - cp_error ("cannot resolve overload to target type `%#T'", - lhstype); - cp_error - (" because no suitable overload of function `%D' exists", - TREE_PURPOSE (rhs)); - } - return error_mark_node; } + if (complain) + { + cp_error ("cannot resolve overload to target type `%#T'", lhstype); + cp_error + (" because no suitable overload of function `%D' exists", + DECL_NAME (OVL_FUNCTION (rhs))); + } + return error_mark_node; + } + + case TREE_LIST: + { + tree elem, baselink, name = NULL_TREE; + + if (TREE_PURPOSE (rhs) == error_mark_node) + { + /* Make sure we don't drop the non-local flag, as the old code + would rely on it. */ + int nl = TREE_NONLOCAL_FLAG (rhs); + /* We don't need the type of this node. */ + rhs = TREE_VALUE (rhs); + my_friendly_assert (TREE_NONLOCAL_FLAG (rhs) == nl, 980331); + } + /* Now we should have a baselink. */ + my_friendly_assert (TREE_CODE (TREE_PURPOSE (rhs)) == TREE_VEC, 980331); + /* First look for an exact match. Search member functions. + May have to undo what `default_conversion' might do to + lhstype. */ + + lhstype = validate_lhs (lhstype, complain); + if (lhstype == error_mark_node) + return lhstype; if (TREE_NONLOCAL_FLAG (rhs)) { + my_friendly_abort (980401); /* Got to get it as a baselink. */ rhs = lookup_fnfields (TYPE_BINFO (current_class_type), - TREE_PURPOSE (rhs), 0); + DECL_NAME (OVL_FUNCTION (rhs)), 0); } else { my_friendly_assert (TREE_CHAIN (rhs) == NULL_TREE, 181); - if (TREE_CODE (TREE_VALUE (rhs)) == TREE_LIST) - rhs = TREE_VALUE (rhs); - my_friendly_assert (TREE_CODE (TREE_VALUE (rhs)) == FUNCTION_DECL, + my_friendly_assert (TREE_CODE (TREE_VALUE (rhs)) == FUNCTION_DECL + || TREE_CODE (TREE_VALUE (rhs)) == OVERLOAD, 182); } @@ -5215,13 +5248,13 @@ instantiate_type (lhstype, rhs, complain) { elem = TREE_VALUE (baselink); while (elem) - if (comptypes (lhstype, TREE_TYPE (elem), 1)) + if (comptypes (lhstype, TREE_TYPE (OVL_CURRENT (elem)), 1)) { - mark_used (elem); - return elem; + mark_used (OVL_CURRENT (elem)); + return OVL_CURRENT (elem); } else - elem = DECL_CHAIN (elem); + elem = OVL_NEXT (elem); } /* No exact match found, look for a compatible method. */ @@ -5229,16 +5262,17 @@ instantiate_type (lhstype, rhs, complain) baselink = next_baselink (baselink)) { elem = TREE_VALUE (baselink); - while (elem && comp_target_types (lhstype, - TREE_TYPE (elem), 1) <= 0) - elem = DECL_CHAIN (elem); + for (; elem; elem = OVL_NEXT (elem)) + if (comp_target_types (lhstype, + TREE_TYPE (OVL_CURRENT (elem)), 1) > 0) + break; if (elem) { - tree save_elem = elem; - elem = DECL_CHAIN (elem); - while (elem && comp_target_types (lhstype, - TREE_TYPE (elem), 0) <= 0) - elem = DECL_CHAIN (elem); + tree save_elem = OVL_CURRENT (elem); + for (elem = OVL_NEXT (elem); elem; elem = OVL_NEXT (elem)) + if (comp_target_types (lhstype, + TREE_TYPE (OVL_CURRENT (elem)), 0) > 0) + break; if (elem) { if (complain) @@ -5248,7 +5282,10 @@ instantiate_type (lhstype, rhs, complain) mark_used (save_elem); return save_elem; } - name = DECL_NAME (TREE_VALUE (rhs)); + name = rhs; + while (TREE_CODE (name) == TREE_LIST) + name = TREE_VALUE (name); + name = DECL_NAME (OVL_CURRENT (name)); #if 0 if (TREE_CODE (lhstype) == FUNCTION_TYPE && globals < 0) { diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 2f7f938..2124a04 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -166,10 +166,15 @@ DEFTREECODE (DEFAULT_ARG, "default_arg", 'c', 2) the template will be an IDENTIFIER_NODE. */ DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", 'e', 2) -/* has two fields: scope and value */ -/* XXX: could recycle some of the common fields */ +/* An association between namespace and entity. Parameters are the + scope and the (non-type) value. + TREE_TYPE indicates the type bound to the name. */ DEFTREECODE (CPLUS_BINDING, "binding", 'x', 2) +/* A list-like node for chaining overloading candidates. TREE_TYPE is + the original name, and the parameter is the FUNCTION_DECL. */ +DEFTREECODE (OVERLOAD, "overload", 'x', 1) + /* A generic wrapper for something not tree that we want to include in tree structure. */ DEFTREECODE (WRAPPER, "wrapper", 'x', 1) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 562ce84..9c90531 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -58,13 +58,23 @@ typedef struct tree decl; } template_parm_index; -#define BINDING_SCOPE(NODE) (((struct tree_binding*)NODE)->scope) -#define BINDING_VALUE(NODE) (((struct tree_binding*)NODE)->value) -#define NAMESPACE_BINDING(ID,NS) BINDING_VALUE (binding_for_name (ID, NS)) +/* For a binding between a name and an entity, defines the scope + where the binding is declared. Currently always points to a + namespace declaration. */ +#define BINDING_SCOPE(NODE) (((struct tree_binding*)NODE)->scope) +/* This is the declaration bound to the name. Possible values: + variable, overloaded function, namespace, template, enumerator. */ +#define BINDING_VALUE(NODE) (((struct tree_binding*)NODE)->value) +/* If name is bound to a type, this is the type (struct, union, enum). */ +#define BINDING_TYPE(NODE) TREE_TYPE(NODE) #define IDENTIFIER_GLOBAL_VALUE(NODE) \ - NAMESPACE_BINDING (NODE, global_namespace) + namespace_binding (NODE, global_namespace) +#define SET_IDENTIFIER_GLOBAL_VALUE(NODE, VAL) \ + set_namespace_binding (NODE, global_namespace, VAL) #define IDENTIFIER_NAMESPACE_VALUE(NODE) \ - NAMESPACE_BINDING (NODE, current_namespace) + namespace_binding (NODE, current_namespace) +#define SET_IDENTIFIER_NAMESPACE_VALUE(NODE, VAL) \ + set_namespace_binding (NODE, current_namespace, VAL) struct tree_binding { @@ -73,6 +83,25 @@ struct tree_binding tree value; }; +/* The overloaded FUNCTION_DECL. */ +#define OVL_FUNCTION(NODE) (((struct tree_overload*)NODE)->function) +#define OVL_CHAIN(NODE) TREE_CHAIN(NODE) +/* Polymorphic access to FUNCTION and CHAIN. */ +#define OVL_CURRENT(NODE) \ + ((TREE_CODE(NODE)==OVERLOAD) ? OVL_FUNCTION(NODE) : NODE) +#define OVL_NEXT(NODE) \ + ((TREE_CODE(NODE)==OVERLOAD) ? TREE_CHAIN(NODE) : NULL_TREE) +/* If set, this was imported in a using declaration. + This is not to confuse with being used somewhere, which + is not important for this node. */ +#define OVL_USED(NODE) TREE_USED(NODE) + +struct tree_overload +{ + char common[sizeof (struct tree_common)]; + tree function; +}; + #define WRAPPER_PTR(NODE) (((struct tree_wrapper*)NODE)->u.ptr) #define WRAPPER_INT(NODE) (((struct tree_wrapper*)NODE)->u.i) @@ -100,9 +129,14 @@ struct tree_wrapper #define IDENTIFIER_TEMPLATE(NODE) \ (((struct lang_identifier *)(NODE))->class_template_info) -#define IDENTIFIER_TYPE_VALUE(NODE) (TREE_TYPE (NODE)) +/* TREE_TYPE only indicates on local and class scope the current + type. For namespace scope, the presence of a type in any namespace + is indicated with global_type_node, and the real type behind must + be found through lookup. */ +#define IDENTIFIER_TYPE_VALUE(NODE) (identifier_type_value(NODE)) +#define REAL_IDENTIFIER_TYPE_VALUE(NODE) (TREE_TYPE (NODE)) #define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = TYPE) -#define IDENTIFIER_HAS_TYPE_VALUE(NODE) (TREE_TYPE (NODE) ? 1 : 0) +#define IDENTIFIER_HAS_TYPE_VALUE(NODE) (IDENTIFIER_TYPE_VALUE (NODE) ? 1 : 0) #define LANG_ID_FIELD(NAME,NODE) \ (((struct lang_identifier *)(NODE))->x \ @@ -950,7 +984,6 @@ struct lang_decl_flags tree memfunc_pointer_to; tree template_info; struct binding_level *level; - tree in_namespace; }; struct lang_decl @@ -959,7 +992,6 @@ struct lang_decl tree main_decl_variant; struct pending_inline *pending_inline_info; - tree chain; }; /* Non-zero if NODE is a _DECL with TREE_READONLY set. */ @@ -1065,21 +1097,13 @@ struct lang_decl ((TREE_CODE (NODE) == FUNCTION_DECL && DECL_FUNCTION_MEMBER_P (NODE)) \ ? DECL_CLASS_CONTEXT (NODE) : DECL_CONTEXT (NODE)) -/* For a FUNCTION_DECL: the chain through which the next method - with the same name is found. We now use TREE_CHAIN to - walk through the methods in order of declaration. - For a NAMESPACE_DECL: the list of using namespace directives +/* For a NAMESPACE_DECL: the list of using namespace directives The PURPOSE is the used namespace, the value is the namespace - that is the common ancestor */ -#if 1 -#define DECL_CHAIN(NODE) (DECL_LANG_SPECIFIC(NODE)->chain) -#else -#define DECL_CHAIN(NODE) (TREE_CHAIN (NODE)) -#endif -#define DECL_NAMESPACE_USING(NODE) (DECL_LANG_SPECIFIC(NODE)->chain) + that is the common ancestor. */ +#define DECL_NAMESPACE_USING(NODE) DECL_VINDEX(NODE) /* In a NAMESPACE_DECL, the DECL_INITIAL is used to record all users - of a namespace, to record the transitive closure of using namespace */ + of a namespace, to record the transitive closure of using namespace. */ #define DECL_NAMESPACE_USERS(NODE) DECL_INITIAL (NODE) /* In a TREE_LIST concatenating using directives, indicate indirekt @@ -1494,12 +1518,6 @@ extern int flag_new_for_scope; #define DECL_REALLY_EXTERN(NODE) \ (DECL_EXTERNAL (NODE) && ! DECL_NOT_REALLY_EXTERN (NODE)) -/* Records the namespace we are in */ -#define DECL_NAMESPACE(NODE) \ - (DECL_LANG_SPECIFIC (NODE) ? DECL_LANG_SPECIFIC (NODE)->decl_flags.in_namespace : 0) -#define SET_DECL_NAMESPACE(NODE, val) \ - DECL_LANG_SPECIFIC (NODE)->decl_flags.in_namespace = val - /* Used to tell cp_finish_decl that it should approximate comdat linkage as best it can for this decl. */ #define DECL_COMDAT(NODE) (DECL_LANG_SPECIFIC (NODE)->decl_flags.comdat) @@ -1952,6 +1970,10 @@ extern int flag_weak; extern int flag_new_abi; +/* Nonzero to not ignore namespace std. */ + +extern int flag_honor_std; + /* Nonzero if we're done parsing and into end-of-file activities. */ extern int at_eof; @@ -2153,6 +2175,7 @@ extern void pop_namespace PROTO((void)); extern void maybe_push_to_top_level PROTO((int)); extern void push_to_top_level PROTO((void)); extern void pop_from_top_level PROTO((void)); +extern tree identifier_type_value PROTO((tree)); extern void set_identifier_type_value PROTO((tree, tree)); extern void pop_everything PROTO((void)); extern void pushtag PROTO((tree, tree, int)); @@ -2166,8 +2189,9 @@ extern tree pushdecl_class_level PROTO((tree)); #if 0 extern void pushdecl_nonclass_level PROTO((tree)); #endif +extern tree pushdecl_namespace_level PROTO((tree)); +extern tree push_using_decl PROTO((tree, tree)); extern void push_class_level_binding PROTO((tree, tree)); -extern int overloaded_globals_p PROTO((tree)); extern tree implicitly_declare PROTO((tree)); extern tree lookup_label PROTO((tree)); extern tree shadow_label PROTO((tree)); @@ -2181,13 +2205,16 @@ extern tree gettags PROTO((void)); extern void set_current_level_tags_transparency PROTO((int)); #endif extern tree binding_for_name PROTO((tree, tree)); +extern tree namespace_binding PROTO((tree, tree)); +extern void set_namespace_binding PROTO((tree, tree, tree)); extern tree lookup_namespace_name PROTO((tree, tree)); extern tree make_typename_type PROTO((tree, tree)); extern tree lookup_name_nonclass PROTO((tree)); +extern tree lookup_function_nonclass PROTO((tree, tree)); extern tree lookup_name PROTO((tree, int)); extern tree lookup_name_current_level PROTO((tree)); -extern tree lookup_using_namespace PROTO((tree,tree,tree,tree)); -extern tree qualified_lookup_using_namespace PROTO((tree,tree)); +extern int lookup_using_namespace PROTO((tree,tree,tree,tree)); +extern int qualified_lookup_using_namespace PROTO((tree,tree,tree)); extern tree auto_function PROTO((tree, tree, enum built_in_function)); extern void init_decl_processing PROTO((void)); extern int init_type_desc PROTO((void)); @@ -2234,6 +2261,7 @@ extern int in_function_p PROTO((void)); extern void replace_defarg PROTO((tree, tree)); extern void print_other_binding_stack PROTO((struct binding_level *)); extern void revert_static_member_fn PROTO((tree*, tree*, tree*)); +extern void cat_namespace_levels PROTO((void)); /* in decl2.c */ extern int flag_assume_nonnull_objects; @@ -2281,8 +2309,10 @@ extern tree build_expr_from_tree PROTO((tree)); extern tree reparse_decl_as_expr PROTO((tree, tree)); extern tree finish_decl_parsing PROTO((tree)); extern tree check_cp_case_value PROTO((tree)); -extern tree get_namespace_id PROTO((void)); -extern tree current_namespace_id PROTO((tree)); +extern void set_decl_namespace PROTO((tree, tree)); +extern tree current_decl_namespace PROTO((void)); +extern void push_decl_namespace PROTO((tree)); +extern void pop_decl_namespace PROTO((void)); extern void do_namespace_alias PROTO((tree, tree)); extern void do_toplevel_using_decl PROTO((tree)); extern tree do_class_using_decl PROTO((tree)); @@ -2290,6 +2320,7 @@ extern void do_using_directive PROTO((tree)); extern void check_default_args PROTO((tree)); extern void mark_used PROTO((tree)); extern tree handle_class_head PROTO((tree, tree, tree)); +extern tree lookup_arg_dependent PROTO((tree, tree, tree)); /* in errfn.c */ extern void cp_error (); @@ -2636,10 +2667,14 @@ extern tree get_decl_list PROTO((tree)); extern tree make_binfo PROTO((tree, tree, tree, tree, tree)); extern tree binfo_value PROTO((tree, tree)); extern tree reverse_path PROTO((tree)); -extern int decl_list_length PROTO((tree)); extern int count_functions PROTO((tree)); extern int is_overloaded_fn PROTO((tree)); extern tree get_first_fn PROTO((tree)); +extern tree binding_init PROTO((struct tree_binding*)); +extern tree ovl_cons PROTO((tree, tree)); +extern tree scratch_ovl_cons PROTO((tree, tree)); +extern int ovl_member PROTO((tree, tree)); +extern tree build_overload PROTO((tree, tree)); extern tree fnaddr_from_vtable_entry PROTO((tree)); extern tree function_arg_chain PROTO((tree)); extern int promotes_to_aggr_type PROTO((tree, enum tree_code)); @@ -2674,6 +2709,7 @@ extern void push_expression_obstack PROTO((void)); #define scratch_tree_cons expr_tree_cons #define build_scratch_list build_expr_list #define make_scratch_vec make_temp_vec +#define push_scratch_obstack push_expression_obstack /* in typeck.c */ extern tree condition_conversion PROTO((tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e3a79ae..c73bea1 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -160,9 +160,9 @@ static tree lookup_name_real PROTO((tree, int, int)); static void warn_extern_redeclared_static PROTO((tree, tree)); static void grok_reference_init PROTO((tree, tree, tree)); static tree grokfndecl PROTO((tree, tree, tree, tree, int, - enum overload_flags, - tree, tree, tree, int, int, int, int, int, int)); -static tree grokvardecl PROTO((tree, tree, RID_BIT_TYPE *, int, int)); + enum overload_flags, tree, + tree, tree, int, int, int, int, int, int, tree)); +static tree grokvardecl PROTO((tree, tree, RID_BIT_TYPE *, int, int, tree)); static tree lookup_tag PROTO((enum tree_code, tree, struct binding_level *, int)); static void set_identifier_type_value_with_scope @@ -176,7 +176,7 @@ static void bad_specifiers PROTO((tree, char *, int, int, int, int, static void indent PROTO((void)); #endif -/* a node which has tree code ERROR_MARK, and whose type is itself. +/* A node which has tree code ERROR_MARK, and whose type is itself. All erroneous expressions are replaced with this node. All functions that accept nodes as arguments should avoid generating error messages if this node is one of the arguments, since it is undesirable to get @@ -231,7 +231,7 @@ tree unsigned_intSI_type_node; tree unsigned_intDI_type_node; tree unsigned_intTI_type_node; -/* a VOID_TYPE node, and the same, packaged in a TREE_LIST. */ +/* A VOID_TYPE node, and the same, packaged in a TREE_LIST. */ tree void_type_node, void_list_node; tree void_zero_node; @@ -263,11 +263,11 @@ tree wchar_array_type_node; /* The bool data type, and constants */ tree boolean_type_node, boolean_true_node, boolean_false_node; -/* type `int ()' -- used for implicit declaration of functions. */ +/* Type `int ()' -- used for implicit declaration of functions. */ tree default_function_type; -/* function types `double (double)' and `double (double, double)', etc. */ +/* Function types `double (double)' and `double (double, double)', etc. */ static tree double_ftype_double, double_ftype_double_double; static tree int_ftype_int, long_ftype_long; @@ -301,6 +301,11 @@ tree __ptr_desc_array_type, __attr_dec_array_type, __func_desc_array_type; tree __ptmf_desc_array_type, __ptmd_desc_array_type; #endif +/* Indicates that there is a type value in some namespace, although + that is not necessarily in scope at the moment. */ + +static tree global_type_node; + tree class_star_type_node; tree class_type_node, record_type_node, union_type_node, enum_type_node; tree unknown_type_node; @@ -312,6 +317,7 @@ tree vtbl_type_node; /* namespace std */ tree std_node; +int in_std = 0; /* In a destructor, the point at which all derived class destroying has been done, just before any base class destroying will be done. */ @@ -589,6 +595,9 @@ struct binding_level component_bindings. */ tree tags; + /* A list of USING_DECL nodes. */ + tree usings; + /* For each level, a list of shadowed outer-level local definitions to be restored when this level is popped. Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and @@ -747,7 +756,7 @@ pop_binding_level () if (global_binding_level) { - /* cannot pop a level, if there are none left to pop. */ + /* Cannot pop a level, if there are none left to pop. */ if (current_binding_level == global_binding_level) my_friendly_abort (123); } @@ -791,7 +800,7 @@ suspend_binding_level () if (global_binding_level) { - /* cannot suspend a level, if there are none left to suspend. */ + /* Cannot suspend a level, if there are none left to suspend. */ if (current_binding_level == global_binding_level) my_friendly_abort (123); } @@ -823,29 +832,11 @@ static void resume_binding_level (b) struct binding_level *b; { - if (class_binding_level) - { -#if 1 - /* These are here because we cannot deal with shadows yet. */ - sorry ("cannot resume a namespace inside class"); - return; -#else - b->level_chain = class_binding_level; - class_binding_level = (struct binding_level *)0; -#endif - } - else - { -#if 1 - /* These are here because we cannot deal with shadows yet. */ - if (b->level_chain != current_binding_level) - { - sorry ("cannot resume a namespace inside a different namespace"); - return; - } -#endif - b->level_chain = current_binding_level; - } + /* Resuming binding levels is meant only for namespaces, + and those cannot nest into classes. */ + my_friendly_assert(!class_binding_level, 386); + /* Also, resuming a non-directly nested namespace is a no-no. */ + my_friendly_assert(b->level_chain == current_binding_level, 386); current_binding_level = b; #if defined(DEBUG_CP_BINDING_LEVELS) b->binding_depth = binding_depth; @@ -877,23 +868,15 @@ global_bindings_p () /* Nonzero if we are currently in a toplevel binding level. This means either the global binding level or a namespace in a toplevel - binding level. */ + binding level. + Since there are no non-toplevel namespace levels, this really + means any namespace or pseudo-global level. */ int toplevel_bindings_p () { - struct binding_level *b = current_binding_level; - - while (1) - { - if (b == global_binding_level) - return 1; - if (b->pseudo_global) - return 1; - if (! b->namespace_p) - return 0; - b=b->level_chain; - } + return current_binding_level->namespace_p + || current_binding_level->pseudo_global; } /* Nonzero if this is a namespace scope. */ @@ -1229,7 +1212,7 @@ poplevel (keep, reverse, functionbody) IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); for (link = current_binding_level->type_shadowed; link; link = TREE_CHAIN (link)) - IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); + SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link), TREE_VALUE (link)); } /* If the level being exited is the top level of a function, @@ -1333,35 +1316,6 @@ poplevel (keep, reverse, functionbody) return block; } -/* Resume a binding level for a namespace. */ - -void -resume_level (b) - struct binding_level *b; -{ - tree decls, link; - - resume_binding_level (b); - - /* Resume the variable caches. */ - decls = current_binding_level->names; - - /* Restore the meanings of the local variables of this level. */ - - for (link = decls; link; link = TREE_CHAIN (link)) - { - /* If it doesn't have a name, there is nothing left to do with it. */ - if (DECL_NAME (link) == NULL_TREE) - continue; - - IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = link; - - /* If this is a TYPE_DECL, push it into the type value slot. */ - if (TREE_CODE (link) == TYPE_DECL) - SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (link), TREE_TYPE (link)); - } -} - /* Delete the node BLOCK from the current binding level. This is used for the block inside a stmt expr ({...}) so that the block can be reinserted where appropriate. */ @@ -1486,7 +1440,7 @@ poplevel_class (force) for (shadowed = level->type_shadowed; shadowed; shadowed = TREE_CHAIN (shadowed)) - IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed); + SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (shadowed), TREE_VALUE (shadowed)); GNU_xref_end_scope ((HOST_WIDE_INT) class_binding_level, (HOST_WIDE_INT) class_binding_level->level_chain, @@ -1665,32 +1619,114 @@ print_binding_stack () print_binding_level (global_binding_level); } -/* Return the tree_binding for the name in the given scope - If there are no bindings for the name in the scope, make a new - bindings node. This bindings list of this node will be empty, though. */ +/* Namespace binding access routines: The namespace_bindings field of + the identifier is polymorphic, with three possible values: + NULL_TREE, a list of CPLUS_BINDINGS, or any other tree_node + indicating the BINDING_VALUE of global_namespace. */ -tree -binding_for_name (name, scope) +/* Check whether the a binding for the name to scope is known. + Assumes that the bindings of the name are already a list + of bindings. Returns the binding found, or NULL_TREE. */ + +static tree +find_binding (name, scope) tree name; tree scope; { - tree iter; + tree iter, prev = NULL_TREE; for (iter = IDENTIFIER_NAMESPACE_BINDINGS (name); iter; iter = TREE_CHAIN (iter)) { my_friendly_assert (TREE_CODE (iter) == CPLUS_BINDING, 374); if (BINDING_SCOPE (iter) == scope) - return iter; + { + /* Move binding found to the fron of the list, so + subsequent lookups will find it faster. */ + if (prev) + { + TREE_CHAIN (prev) = TREE_CHAIN (iter); + TREE_CHAIN (iter) = IDENTIFIER_NAMESPACE_BINDINGS (name); + IDENTIFIER_NAMESPACE_BINDINGS (name) = iter; + } + return iter; + } + prev = iter; } - /* not found, make a new permanent one */ + return NULL_TREE; +} + +/* Always returns a binding for name in scope. If the + namespace_bindings is not a list, convert it to one first. + If no binding is found, make a new one. */ + +tree +binding_for_name (name, scope) + tree name; + tree scope; +{ + tree b = IDENTIFIER_NAMESPACE_BINDINGS (name); + tree result; + if (b && TREE_CODE (b) != CPLUS_BINDING) + { + /* Get rid of optimization for global scope. */ + IDENTIFIER_NAMESPACE_BINDINGS (name) = NULL_TREE; + BINDING_VALUE (binding_for_name (name, global_namespace)) = b; + b = IDENTIFIER_NAMESPACE_BINDINGS (name); + } + if (b && (result = find_binding (name, scope))) + return result; + /* Not found, make a new permanent one. */ push_obstacks (&permanent_obstack, &permanent_obstack); - iter = make_node (CPLUS_BINDING); - TREE_CHAIN (iter) = IDENTIFIER_NAMESPACE_BINDINGS (name); - IDENTIFIER_NAMESPACE_BINDINGS (name) = iter; - BINDING_SCOPE (iter) = scope; - BINDING_VALUE (iter) = NULL_TREE; + result = make_node (CPLUS_BINDING); + TREE_CHAIN (result) = b; + IDENTIFIER_NAMESPACE_BINDINGS (name) = result; + BINDING_SCOPE (result) = scope; + BINDING_TYPE (result) = NULL_TREE; + BINDING_VALUE (result) = NULL_TREE; pop_obstacks (); - return iter; + return result; +} + +/* Return the binding value for name in scope, considering that + namespace_binding may or may not be a list of CPLUS_BINDINGS. */ + +tree +namespace_binding (name, scope) + tree name; + tree scope; +{ + tree b = IDENTIFIER_NAMESPACE_BINDINGS (name); + if (b == NULL_TREE) + return NULL_TREE; + if (TREE_CODE (b) != CPLUS_BINDING) + return (scope == global_namespace) ? b : NULL_TREE; + name = find_binding (name,scope); + if (name == NULL_TREE) + return name; + return BINDING_VALUE (name); +} + +/* Set the binding value for name in scope. If modifying the binding + of global_namespace is attempted, try to optimize it. */ + +void +set_namespace_binding (name, scope, val) + tree name; + tree scope; + tree val; +{ + tree b; + if (scope == global_namespace) + { + b = IDENTIFIER_NAMESPACE_BINDINGS (name); + if (b == NULL_TREE || TREE_CODE (b) != CPLUS_BINDING) + { + IDENTIFIER_NAMESPACE_BINDINGS (name) = val; + return; + } + } + b = binding_for_name (name, scope); + BINDING_VALUE (b) = val; } extern char * first_global_object_name; @@ -1744,25 +1780,30 @@ void push_namespace (name) tree name; { -#if 1 tree d; int need_new = 1; int implicit_use = 0; - int nodecl = 0; + int global = 0; if (!global_namespace) { - /* this must be :: */ + /* This must be ::. */ my_friendly_assert (name == get_identifier ("::"), 377); - nodecl = 1; + global = 1; } else if (!name) { name = get_unique_name (); implicit_use = 1; - } + } + else if (current_namespace == global_namespace + && name == DECL_NAME (std_node)) + { + in_std++; + return; + } else { - /* check whether this is an extended namespace definition */ + /* Check whether this is an extended namespace definition. */ d = IDENTIFIER_NAMESPACE_VALUE (name); if (d != NULL_TREE && TREE_CODE (d) == NAMESPACE_DECL) need_new = 0; @@ -1770,53 +1811,25 @@ push_namespace (name) if (need_new) { - /* make a new namespace, binding the name to it */ - d = build_lang_decl (NAMESPACE_DECL, name, void_type_node); - if (!nodecl) - d = pushdecl (d); + /* Make a new namespace, binding the name to it. */ + d = build_lang_decl (NAMESPACE_DECL, name, NULL_TREE); + /* The global namespace is not pushed, and the global binding + level is set elsewhere. */ + if (!global) + { + d = pushdecl (d); + pushlevel (0); + declare_namespace_level (); + NAMESPACE_LEVEL (d) = current_binding_level; + } } + else + resume_binding_level (NAMESPACE_LEVEL (d)); + if (implicit_use) do_using_directive (d); - /* enter the name space */ + /* Enter the name space. */ current_namespace = d; - -#else - tree old_id = get_namespace_id (); - char *buf; - tree d; - - if (! name) - { - /* Create a truly ugly name! */ - name = get_unique_name (); - } - - d = build_lang_decl (NAMESPACE_DECL, name, void_type_node); - - /* Mark them as external, so redeclaration_error_message doesn't think - they are duplicates. */ - - DECL_EXTERNAL (d) = 1; - d = pushdecl (d); - - if (NAMESPACE_LEVEL (d) == 0) - { - /* This is new for this compilation unit. */ - pushlevel (0); - declare_namespace_level (); - NAMESPACE_LEVEL (d) = current_binding_level; - } - else - resume_level (NAMESPACE_LEVEL (d)); - - /* This code is just is bit old now... */ - current_namespace = tree_cons (NULL_TREE, name, current_namespace); - buf = (char *) alloca (4 + (old_id ? IDENTIFIER_LENGTH (old_id) : 0) - + IDENTIFIER_LENGTH (name)); - sprintf (buf, "%s%s", old_id ? IDENTIFIER_POINTER (old_id) : "", - IDENTIFIER_POINTER (name)); - TREE_PURPOSE (current_namespace) = get_identifier (buf); -#endif } /* Pop from the scope of the current namespace. */ @@ -1824,52 +1837,43 @@ push_namespace (name) void pop_namespace () { -#if 1 - current_namespace = DECL_NAMESPACE (current_namespace); -#else - tree decls, link; - current_namespace = TREE_CHAIN (current_namespace); - - /* Just in case we get out of sync. */ - if (! namespace_bindings_p ()) - poplevel (0, 0, 0); + if (current_namespace == global_namespace) + { + my_friendly_assert (in_std>0, 980421); + in_std--; + return; + } + current_namespace = DECL_CONTEXT (current_namespace); + /* The binding level is not popped, as it might be re-opened later. */ + suspend_binding_level (); +} - decls = current_binding_level->names; +/* Concatenate the binding levels of all namespaces. */ - /* Clear out the meanings of the local variables of this level. */ +void +cat_namespace_levels() +{ + tree current; + tree last; + struct binding_level *b; - for (link = decls; link; link = TREE_CHAIN (link)) + last = NAMESPACE_LEVEL (global_namespace) -> names; + /* The nested namespaces appear in the names list of their ancestors. */ + for (current = last; current; current = TREE_CHAIN (current)) { - if (DECL_NAME (link) != NULL_TREE) + if (TREE_CODE (current) != NAMESPACE_DECL) + continue; + if (!DECL_LANG_SPECIFIC (current)) { - /* If the ident. was used or addressed via a local extern decl, - don't forget that fact. */ - if (DECL_EXTERNAL (link)) - { - if (TREE_USED (link)) - TREE_USED (DECL_ASSEMBLER_NAME (link)) = 1; - if (TREE_ADDRESSABLE (link)) - TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1; - } - IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = NULL_TREE; + /* Hmm. std. */ + my_friendly_assert (current == std_node, 393); + continue; } + b = NAMESPACE_LEVEL (current); + while (TREE_CHAIN (last)) + last = TREE_CHAIN (last); + TREE_CHAIN (last) = NAMESPACE_LEVEL (current) -> names; } - - /* Restore all name-meanings of the outer levels - that were shadowed by this level. */ - - for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link)) - IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); - for (link = current_binding_level->class_shadowed; - link; link = TREE_CHAIN (link)) - IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); - for (link = current_binding_level->type_shadowed; - link; link = TREE_CHAIN (link)) - IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); - - /* suspend a level. */ - suspend_binding_level (); -#endif } /* Subroutines for reverting temporarily to top-level for instantiation @@ -1880,6 +1884,7 @@ pop_namespace () struct saved_scope { struct binding_level *old_binding_level; tree old_bindings; + tree old_namespace; struct saved_scope *prev; tree class_name, class_type, function_decl; struct binding_level *class_bindings; @@ -1935,7 +1940,7 @@ store_bindings (names, old_bindings) { my_friendly_assert (TREE_CODE (id) == IDENTIFIER_NODE, 135); TREE_VEC_ELT (binding, 0) = id; - TREE_VEC_ELT (binding, 1) = IDENTIFIER_TYPE_VALUE (id); + TREE_VEC_ELT (binding, 1) = REAL_IDENTIFIER_TYPE_VALUE (id); TREE_VEC_ELT (binding, 2) = IDENTIFIER_LOCAL_VALUE (id); TREE_VEC_ELT (binding, 3) = IDENTIFIER_CLASS_VALUE (id); IDENTIFIER_LOCAL_VALUE (id) = NULL_TREE; @@ -1971,6 +1976,10 @@ maybe_push_to_top_level (pseudo) { tree t; + /* Template IDs are inserted into the global level. If they were + inserted into namespace level, finish_file wouldn't find them + when doing pending instantiations. Therefore, don't stop at + namespace level, but continue until :: . */ if (b == global_binding_level || (pseudo && b->pseudo_global)) break; @@ -1988,6 +1997,7 @@ maybe_push_to_top_level (pseudo) s->old_binding_level = current_binding_level; current_binding_level = b; + s->old_namespace = current_namespace; s->class_name = current_class_name; s->class_type = current_class_type; s->function_decl = current_function_decl; @@ -2020,6 +2030,7 @@ maybe_push_to_top_level (pseudo) processing_explicit_instantiation = 0; current_template_parms = NULL_TREE; processing_template_decl = 0; + current_namespace = global_namespace; s->prev = current_saved_scope; s->old_bindings = old_bindings; @@ -2058,7 +2069,7 @@ pop_from_top_level () tree id = TREE_VEC_ELT (t, 0); if (id) { - IDENTIFIER_TYPE_VALUE (id) = TREE_VEC_ELT (t, 1); + SET_IDENTIFIER_TYPE_VALUE (id, TREE_VEC_ELT (t, 1)); IDENTIFIER_LOCAL_VALUE (id) = TREE_VEC_ELT (t, 2); IDENTIFIER_CLASS_VALUE (id) = TREE_VEC_ELT (t, 3); } @@ -2066,6 +2077,7 @@ pop_from_top_level () TREE_CHAIN (save) = free_binding_vecs; free_binding_vecs = save; } + current_namespace = s->old_namespace; current_class_name = s->class_name; current_class_type = s->class_type; current_function_decl = s->function_decl; @@ -2113,12 +2125,21 @@ set_identifier_type_value_with_scope (id, type, b) tree type; struct binding_level *b; { - if (b != global_binding_level) + if (!b->namespace_p) { - tree old_type_value = IDENTIFIER_TYPE_VALUE (id); + /* Shadow the marker, not the real thing, so that the marker + gets restored later. */ + tree old_type_value = REAL_IDENTIFIER_TYPE_VALUE (id); b->type_shadowed = tree_cons (id, old_type_value, b->type_shadowed); } + else + { + tree binding = binding_for_name (id, current_namespace); + BINDING_TYPE (binding) = type; + /* Store marker instead of real type. */ + type = global_type_node; + } SET_IDENTIFIER_TYPE_VALUE (id, type); } @@ -2132,6 +2153,26 @@ set_identifier_type_value (id, type) set_identifier_type_value_with_scope (id, type, inner_binding_level); } +/* Return the type associated with id. */ + +tree +identifier_type_value (id) + tree id; +{ + /* There is no type with that name, anywhere. */ + if (REAL_IDENTIFIER_TYPE_VALUE (id) == NULL_TREE) + return NULL_TREE; + /* This is not the type marker, but the real thing. */ + if (REAL_IDENTIFIER_TYPE_VALUE (id) != global_type_node) + return REAL_IDENTIFIER_TYPE_VALUE (id); + /* Have to search for it. It must be on the global level, now. + Ask lookup_name not to return non-types. */ + id = lookup_name_real (id, 2, 1); + if (id) + return TREE_TYPE (id); + return NULL_TREE; +} + /* Pop off extraneous binding levels left over due to syntax errors. We don't pop past namespaces, as they might be valid. */ @@ -2198,6 +2239,9 @@ pushtag (name, type, globalize) c_decl = TREE_CODE (context) == FUNCTION_DECL ? context : TYPE_MAIN_DECL (context); + if (!context) + context = current_namespace; + /* Do C++ gratuitous typedefing. */ if (IDENTIFIER_TYPE_VALUE (name) != type) { @@ -2683,7 +2727,7 @@ duplicate_decls (newdecl, olddecl) cp_error (errmsg, newdecl); if (DECL_NAME (olddecl) != NULL_TREE) cp_error_at ((DECL_INITIAL (olddecl) - && current_binding_level == global_binding_level) + && namespace_bindings_p ()) ? "`%#D' previously defined here" : "`%#D' previously declared here", olddecl); } @@ -2783,8 +2827,6 @@ duplicate_decls (newdecl, olddecl) DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl); if (DECL_CLASS_CONTEXT (olddecl)) DECL_CLASS_CONTEXT (newdecl) = DECL_CLASS_CONTEXT (olddecl); - if (DECL_CHAIN (newdecl) == NULL_TREE) - DECL_CHAIN (newdecl) = DECL_CHAIN (olddecl); if (DECL_PENDING_INLINE_INFO (newdecl) == (struct pending_inline *)0) DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl); DECL_STATIC_CONSTRUCTOR (newdecl) |= DECL_STATIC_CONSTRUCTOR (olddecl); @@ -3048,8 +3090,6 @@ duplicate_decls (newdecl, olddecl) { DECL_TEMPLATE_SPECIALIZATIONS (newdecl) = DECL_TEMPLATE_SPECIALIZATIONS (olddecl); - if (DECL_CHAIN (newdecl) == NULL_TREE) - DECL_CHAIN (newdecl) = DECL_CHAIN (olddecl); } /* Now preserve various other info from the definition. */ @@ -3189,14 +3229,15 @@ pushdecl (x) register tree name = DECL_ASSEMBLER_NAME (x); register struct binding_level *b = current_binding_level; - if (x != current_function_decl + if (current_function_decl && x != current_function_decl + /* A local declaration for a function doesn't constitute nesting. */ + && (TREE_CODE (x) != FUNCTION_DECL || DECL_INITIAL (x)) /* Don't change DECL_CONTEXT of virtual methods. */ && (TREE_CODE (x) != FUNCTION_DECL || !DECL_VIRTUAL_P (x)) && ! DECL_CONTEXT (x)) DECL_CONTEXT (x) = current_function_decl; - /* A local declaration for a function doesn't constitute nesting. */ - if (TREE_CODE (x) == FUNCTION_DECL && DECL_INITIAL (x) == 0) - DECL_CONTEXT (x) = 0; + if (!DECL_CONTEXT (x)) + DECL_CONTEXT (x) = current_namespace; /* Type are looked up using the DECL_NAME, as that is what the rest of the compiler wants to use. */ @@ -3215,7 +3256,12 @@ pushdecl (x) if (TREE_CODE (name) == TEMPLATE_ID_EXPR) name = TREE_OPERAND (name, 0); - t = lookup_name_current_level (name); + /* Namespace-scoped variables are not found in the current level. */ + if (TREE_CODE (x) == VAR_DECL + && TREE_CODE (DECL_CONTEXT (x)) == NAMESPACE_DECL) + t = namespace_binding (name, DECL_CONTEXT (x)); + else + t = lookup_name_current_level (name); if (t == error_mark_node) { /* error_mark_node is 0 for a while during initialization! */ @@ -3243,7 +3289,7 @@ pushdecl (x) else if (((TREE_CODE (x) == FUNCTION_DECL && DECL_LANGUAGE (x) == lang_c) || DECL_FUNCTION_TEMPLATE_P (x)) && is_overloaded_fn (t)) - /* don't do anything just yet */; + /* Don't do anything just yet. */; else if (t == wchar_decl_node) { if (pedantic && ! DECL_IN_SYSTEM_HEADER (x)) @@ -3321,7 +3367,8 @@ pushdecl (x) if (t != x || DECL_LANGUAGE (x) == lang_c) return t; } - else if (DECL_FUNCTION_TEMPLATE_P (x) && DECL_CONTEXT (x) == NULL_TREE) + else if (DECL_FUNCTION_TEMPLATE_P (x) && DECL_CONTEXT (x) + && TREE_CODE (DECL_CONTEXT (x)) == NAMESPACE_DECL) return push_overloaded_decl (x, 0); /* If declaring a type as a typedef, copy the type (unless we're @@ -3380,7 +3427,7 @@ pushdecl (x) /* This name is new in its binding level. Install the new declaration and return it. */ - if (b == global_binding_level) + if (namespace_bindings_p ()) { /* Install a global value. */ tree bindings = binding_for_name (name, current_namespace); @@ -3585,15 +3632,17 @@ pushdecl_with_scope (x, level) return x; } -/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, +/* Like pushdecl, only it places X in the current namespace, if appropriate. */ tree -pushdecl_top_level (x) +pushdecl_namespace_level (x) tree x; { register struct binding_level *b = inner_binding_level; - register tree t = pushdecl_with_scope (x, global_binding_level); + register tree t; + + t = pushdecl_with_scope (x, NAMESPACE_LEVEL (current_namespace)); /* Now, the type_shadowed stack may screw us. Munge it so it does what we want. */ @@ -3629,6 +3678,20 @@ pushdecl_top_level (x) return t; } +/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, + if appropriate. */ + +tree +pushdecl_top_level (x) + tree x; +{ + tree cur_namespace = current_namespace; + current_namespace = global_namespace; + x = pushdecl_namespace_level (x); + current_namespace = cur_namespace; + return x; +} + /* Like push_overloaded_decl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate. */ @@ -3734,23 +3797,35 @@ push_class_level_binding (name, x) obstack_ptr_grow (&decl_obstack, x); } -/* Tell caller how to interpret a TREE_LIST which contains - chains of FUNCTION_DECLS. */ +/* Insert another USING_DECL into the current binding level, + returning this declaration. If this is a redeclaration, + do nothing and return NULL_TREE. */ -int -overloaded_globals_p (list) - tree list; +tree +push_using_decl (scope, name) + tree scope; + tree name; { - my_friendly_assert (TREE_CODE (list) == TREE_LIST, 142); + tree decl; + + if (!toplevel_bindings_p ()) + { + sorry ("using declaration inside function"); + return NULL_TREE; + } - /* Don't commit caller to seeing them as globals. */ - if (TREE_NONLOCAL_FLAG (list)) - return -1; - /* Do commit caller to not seeing them as globals. */ - if (TREE_CODE (TREE_VALUE (list)) == TREE_LIST) - return 0; - /* Do commit caller to seeing them as globals. */ - return 1; + my_friendly_assert (TREE_CODE (scope) == NAMESPACE_DECL, 383); + my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 384); + for (decl = current_binding_level->usings; decl; decl = TREE_CHAIN (decl)) + if (DECL_INITIAL (decl) == scope && DECL_NAME (decl) == name) + break; + if (decl) + return NULL_TREE; + decl = build_lang_decl (USING_DECL, name, void_type_node); + DECL_INITIAL (decl) = scope; + TREE_CHAIN (decl) = current_binding_level->usings; + current_binding_level->usings = decl; + return decl; } /* DECL is a FUNCTION_DECL which may have other definitions already in @@ -3773,11 +3848,11 @@ push_overloaded_decl (decl, forgettable) { tree orig_name = DECL_NAME (decl); tree old; - int doing_global = (global_bindings_p () || ! forgettable); + int doing_global = (namespace_bindings_p () || ! forgettable); if (doing_global) { - old = IDENTIFIER_NAMESPACE_VALUE (orig_name); + old = namespace_binding (orig_name, DECL_CONTEXT (decl)); if (old && TREE_CODE (old) == FUNCTION_DECL && DECL_ARTIFICIAL (old) && (DECL_BUILT_IN (old) || DECL_BUILT_IN_NONANSI (old))) @@ -3814,9 +3889,10 @@ push_overloaded_decl (decl, forgettable) { tree tmp; - for (tmp = get_first_fn (old); tmp; tmp = DECL_CHAIN (tmp)) - if (decl == tmp || duplicate_decls (decl, tmp)) - return tmp; + for (tmp = old; tmp; tmp = OVL_NEXT (tmp)) + if (decl == OVL_CURRENT (tmp) + || duplicate_decls (decl, OVL_CURRENT (tmp))) + return OVL_CURRENT (tmp); } else { @@ -3828,19 +3904,16 @@ push_overloaded_decl (decl, forgettable) if (old || TREE_CODE (decl) == TEMPLATE_DECL) { - if (old && is_overloaded_fn (old)) - DECL_CHAIN (decl) = get_first_fn (old); - else - DECL_CHAIN (decl) = NULL_TREE; - old = tree_cons (orig_name, decl, NULL_TREE); - TREE_TYPE (old) = unknown_type_node; + if (old && TREE_CODE (old) != OVERLOAD) + old = ovl_cons (old, NULL_TREE); + old = ovl_cons (decl, old); } else /* orig_name is not ambiguous. */ old = decl; if (doing_global) - IDENTIFIER_NAMESPACE_VALUE (orig_name) = old; + set_namespace_binding (orig_name, DECL_CONTEXT (decl), old); else IDENTIFIER_LOCAL_VALUE (orig_name) = old; @@ -3920,10 +3993,16 @@ redeclaration_error_message (newdecl, olddecl) if (DECL_LANG_SPECIFIC (olddecl) && DECL_ABSTRACT_VIRTUAL_P (olddecl)) return 0; + /* If both functions come from different namespaces, this is not + a redeclaration - this is a conflict with a used function. */ + if (TREE_CODE (DECL_CONTEXT (olddecl)) == NAMESPACE_DECL + && DECL_CONTEXT (olddecl) != DECL_CONTEXT (newdecl)) + return "`%D' conflicts with used function"; + /* We'll complain about linkage mismatches in warn_extern_redeclared_static. */ - /* defining the same name twice is no good. */ + /* Defining the same name twice is no good. */ if (DECL_INITIAL (olddecl) != NULL_TREE && DECL_INITIAL (newdecl) != NULL_TREE) { @@ -4320,6 +4399,27 @@ lookup_tag (form, name, binding_level, thislevel_only) if (TYPE_IDENTIFIER (TREE_VALUE (tail)) == name) return TREE_VALUE (tail); } + else if (level->namespace_p) + /* Do namespace lookup. */ + /* XXX: is this a real lookup, considering using-directives etc. ??? */ + for (tail = current_namespace; 1; tail = DECL_CONTEXT (tail)) + { + tree old = BINDING_TYPE (binding_for_name (name, tail)); + /* If it has an original type, it is a typedef, and we + should not return it. */ + if (old && DECL_ORIGINAL_TYPE (TYPE_NAME (old))) + old = NULL_TREE; + if (old && TREE_CODE (old) != form + && !(form != ENUMERAL_TYPE && TREE_CODE (old) == TEMPLATE_DECL)) + { + cp_error ("`%#D' redeclared as %C", old, form); + return NULL_TREE; + } + if (old) + return old; + if (thislevel_only || tail == global_namespace) + return NULL_TREE; + } else for (tail = level->tags; tail; tail = TREE_CHAIN (tail)) { @@ -4343,7 +4443,6 @@ lookup_tag (form, name, binding_level, thislevel_only) { if (level->pseudo_global) { - /* XXX MvL */ tree t = IDENTIFIER_NAMESPACE_VALUE (name); if (t && TREE_CODE (t) == TEMPLATE_DECL && TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL) @@ -4351,7 +4450,7 @@ lookup_tag (form, name, binding_level, thislevel_only) } return NULL_TREE; } - if (current_class_type && level->level_chain == global_binding_level) + if (current_class_type && level->level_chain->namespace_p) { /* Try looking in this class's tags before heading into global binding level. */ @@ -4495,38 +4594,20 @@ tree lookup_namespace_name (namespace, name) tree namespace, name; { -#if 1 + struct tree_binding _b; tree val; + my_friendly_assert (TREE_CODE (namespace) == NAMESPACE_DECL, 370); my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 373); - val = qualified_lookup_using_namespace (name, namespace); - if (val) - return val; + val = binding_init (&_b); + if (!qualified_lookup_using_namespace (name, namespace, val)) + return error_mark_node; + + if (BINDING_VALUE (val)) + return BINDING_VALUE (val); cp_error ("`%D' undeclared in namespace `%D'", name, namespace); return error_mark_node; -#else - struct binding_level *b = (struct binding_level *)NAMESPACE_LEVEL (namespace); - tree x = NULL_TREE; -#if 1 - /* This searches just one level. */ - if (b) - { - for (x = b->names; x; x = TREE_CHAIN (x)) - if (DECL_NAME (x) == name || DECL_ASSEMBLER_NAME (x) == name) - break; - } -#else - /* This searches all levels. */ - for (; b && !x; b = b->level_chain) - { - for (x = b->names; x; x = TREE_CHAIN (x)) - if (DECL_NAME (x) == name || DECL_ASSEMBLER_NAME (x) == name) - break; - } -#endif - return x; -#endif } tree @@ -4607,13 +4688,35 @@ make_typename_type (context, name) return t; } +/* Select the right _DECL from multiple choices. */ + +static tree +select_decl (binding, prefer_type) + tree binding; + int prefer_type; +{ + tree val; + val = BINDING_VALUE (binding); + /* If we could have a type and + we have nothing or we need a type and have none. */ + if (BINDING_TYPE (binding) + && (!val || (prefer_type && TREE_CODE (val) != TYPE_DECL))) + val = TYPE_STUB_DECL (BINDING_TYPE (binding)); + /* Don't return non-types if we really prefer types. */ + else if (val && prefer_type > 1 && TREE_CODE (val) != TYPE_DECL + && (!looking_for_template || TREE_CODE (val) != TEMPLATE_DECL)) + val = NULL_TREE; + return val; +} + /* Look up NAME in the current binding level and its superiors in the namespace of variables, functions and typedefs. Return a ..._DECL node of some kind representing its definition if there is only one such declaration, or return a TREE_LIST with all the overloaded definitions if there are many, or return 0 if it is undefined. - If PREFER_TYPE is > 0, we prefer TYPE_DECLs. + If PREFER_TYPE is > 0, we prefer TYPE_DECLs or namespaces. + If PREFER_TYPE is > 1, we reject non-type decls (e.g. namespaces). If PREFER_TYPE is -2, we're being called from yylex(). (UGLY) Otherwise we prefer non-TYPE_DECLs. @@ -4657,10 +4760,14 @@ lookup_name_real (name, prefer_type, nonclass) type = complete_type (type); if (TREE_CODE (type) == VOID_TYPE) - val = IDENTIFIER_GLOBAL_VALUE (name); - else if (TREE_CODE (type) == NAMESPACE_DECL) + type = global_namespace; + if (TREE_CODE (type) == NAMESPACE_DECL) { - val = NAMESPACE_BINDING (name, type); + struct tree_binding b; + val = binding_init (&b); + if (!qualified_lookup_using_namespace (name, type, val)) + return NULL_TREE; + val = select_decl (val, prefer_type); } else if (! IS_AGGR_TYPE (type) || TREE_CODE (type) == TEMPLATE_TYPE_PARM @@ -4704,7 +4811,7 @@ lookup_name_real (name, prefer_type, nonclass) locval = classval = NULL_TREE; - if (current_binding_level != global_binding_level + if (!current_binding_level->namespace_p && IDENTIFIER_LOCAL_VALUE (name)) locval = IDENTIFIER_LOCAL_VALUE (name); @@ -4765,20 +4872,31 @@ lookup_name_real (name, prefer_type, nonclass) val = classval; else { - /* unscoped lookup of a global, iterate over namespaces, - considering using namespace statements */ - tree binding; - tree scope = current_namespace; - do - { - binding = binding_for_name (name, scope); - val = BINDING_VALUE (binding); - val = lookup_using_namespace (name, val, current_namespace, scope); + /* Unscoped lookup of a global, iterate over namespaces, + considering using namespace statements. */ + struct tree_binding _binding; + tree b = binding_init (&_binding); + tree initial = current_decl_namespace(); + tree scope = initial; + val = NULL_TREE; + while (!val) + { + val = binding_for_name (name, scope); + /* Initialize binding for this context. */ + BINDING_VALUE (b) = BINDING_VALUE (val); + BINDING_TYPE (b) = BINDING_TYPE (val); + /* Add all _DECLs seen through using-directives. */ + if (!lookup_using_namespace (name, b, initial, scope)) + { + /* Give up because of error. */ + val = NULL_TREE; + break; + } + val = select_decl (b, prefer_type); if (scope == global_namespace) break; - scope = DECL_NAMESPACE (scope); + scope = DECL_CONTEXT (scope); } - while (!val); } done: @@ -4803,6 +4921,9 @@ lookup_name_real (name, prefer_type, nonclass) if ((TREE_CODE (val) == TEMPLATE_DECL && looking_for_template) || TREE_CODE (val) == TYPE_DECL || prefer_type <= 0) ; + /* Caller wants a class-or-namespace-name. */ + else if(prefer_type == 1 && TREE_CODE (val) == NAMESPACE_DECL) + ; else if (IDENTIFIER_HAS_TYPE_VALUE (name)) val = TYPE_MAIN_DECL (IDENTIFIER_TYPE_VALUE (name)); else if (TREE_TYPE (val) == error_mark_node) @@ -4822,6 +4943,14 @@ lookup_name_nonclass (name) } tree +lookup_function_nonclass (name, args) + tree name; + tree args; +{ + return lookup_arg_dependent (name, lookup_name_nonclass (name), args); +} + +tree lookup_name (name, prefer_type) tree name; int prefer_type; @@ -4837,7 +4966,7 @@ lookup_name_current_level (name) { register tree t = NULL_TREE; - if (current_binding_level == global_binding_level) + if (current_binding_level->namespace_p) { t = IDENTIFIER_NAMESPACE_VALUE (name); @@ -4926,15 +5055,15 @@ record_builtin_type (rid_index, name, type) tdecl = pushdecl (build_decl (TYPE_DECL, tname, type)); set_identifier_type_value (tname, NULL_TREE); if ((int) rid_index < (int) RID_MAX) - /* builtin types live in the global namespace */ - IDENTIFIER_GLOBAL_VALUE (tname) = tdecl; + /* Built-in types live in the global namespace. */ + SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl); } if (rname != NULL_TREE) { if (tname != NULL_TREE) { set_identifier_type_value (rname, NULL_TREE); - IDENTIFIER_GLOBAL_VALUE (rname) = tdecl; + SET_IDENTIFIER_GLOBAL_VALUE (rname, tdecl); } else { @@ -4997,7 +5126,7 @@ init_decl_processing () lang_name_c = get_identifier ("C"); lang_name_java = get_identifier ("Java"); - /* enter the global namespace */ + /* Enter the global namespace. */ my_friendly_assert (global_namespace == NULL_TREE, 375); my_friendly_assert (current_lang_name == NULL_TREE, 375); current_lang_name = lang_name_cplusplus; @@ -5064,6 +5193,9 @@ init_decl_processing () /* Make the binding_level structure for global names. */ pushlevel (0); global_binding_level = current_binding_level; + /* The global level is the namespace level of ::. */ + NAMESPACE_LEVEL (global_namespace) = global_binding_level; + declare_namespace_level (); this_identifier = get_identifier (THIS_NAME); in_charge_identifier = get_identifier (IN_CHARGE_NAME); @@ -5254,7 +5386,7 @@ init_decl_processing () initializations of __FUNCTION__ and __PRETTY_FUNCTION__. */ array_domain_type = build_index_type (build_int_2 (200, 0)); - /* make a type for arrays of characters. + /* Make a type for arrays of characters. With luck nothing will ever really depend on the length of this array type. */ char_array_type_node @@ -5432,7 +5564,7 @@ init_decl_processing () temp = tree_cons (NULL_TREE, build_pointer_type (build_function_type (void_type_node, NULL_TREE)), - ptr_ftype_sizetype); + tree_cons (NULL_TREE, ptr_ftype_sizetype, NULL_TREE)); builtin_function ("__builtin_apply", build_function_type (ptr_type_node, temp), BUILT_IN_APPLY, NULL_PTR); @@ -5661,19 +5793,28 @@ init_decl_processing () record_builtin_type (RID_MAX, SIGTABLE_PTR_TYPE, sigtable_entry_type); } - std_node = build_decl (NAMESPACE_DECL, get_identifier ("std"), + std_node = build_decl (NAMESPACE_DECL, + get_identifier (flag_honor_std ? "fake std":"std"), void_type_node); pushdecl (std_node); + global_type_node = make_node (LANG_TYPE); + record_builtin_type (RID_MAX, "global type", global_type_node); + /* Now, C++. */ current_lang_name = lang_name_cplusplus; { - tree bad_alloc_type_node = xref_tag + tree bad_alloc_type_node, newtype, deltype; + if (flag_honor_std) + push_namespace (get_identifier ("std")); + bad_alloc_type_node = xref_tag (class_type_node, get_identifier ("bad_alloc"), NULL_TREE, 1); - tree newtype = build_exception_variant + if (flag_honor_std) + pop_namespace (); + newtype = build_exception_variant (ptr_ftype_sizetype, build_tree_list (NULL_TREE, bad_alloc_type_node)); - tree deltype = build_exception_variant + deltype = build_exception_variant (void_ftype_ptr, build_tree_list (NULL_TREE, NULL_TREE)); auto_function (ansi_opname[(int) NEW_EXPR], newtype, NOT_BUILT_IN); auto_function (ansi_opname[(int) VEC_NEW_EXPR], newtype, NOT_BUILT_IN); @@ -5733,6 +5874,9 @@ define_function (name, type, function_code, pfn, library_name) TREE_PUBLIC (decl) = 1; DECL_ARTIFICIAL (decl) = 1; + my_friendly_assert (DECL_CONTEXT (decl) == NULL_TREE, 392); + DECL_CONTEXT (decl) = current_namespace; + /* Since `pushdecl' relies on DECL_ASSEMBLER_NAME instead of DECL_NAME, we cannot change DECL_ASSEMBLER_NAME until we have installed this function in the namespace. */ @@ -5964,6 +6108,10 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) ? DECL_CLASS_CONTEXT (decl) : DECL_CONTEXT (decl); + /* We are only interested in class contexts, later. */ + if (context && TREE_CODE (context) == NAMESPACE_DECL) + context = NULL_TREE; + if (initialized) /* Is it valid for this decl to have an initializer at all? If not, set INITIALIZED to zero, which will indirectly @@ -6083,8 +6231,11 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) comes from another scope, e.g. a static member variable. TEM may equal DECL or it may be a previous decl of the same name. */ - if ((TREE_CODE (decl) != PARM_DECL && DECL_CONTEXT (decl) != NULL_TREE) - || (TREE_CODE (decl) == TEMPLATE_DECL && !global_bindings_p ()) + if ((TREE_CODE (decl) != PARM_DECL && DECL_CONTEXT (decl) != NULL_TREE + /* Definitions of namespace members outside their namespace are + possible. */ + && TREE_CODE (DECL_CONTEXT (decl)) != NAMESPACE_DECL) + || (TREE_CODE (decl) == TEMPLATE_DECL && !namespace_bindings_p ()) || TREE_CODE (type) == LANG_TYPE /* The declaration of template specializations does not affect the functions available for overload resolution, so we do not @@ -6407,6 +6558,13 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) if (asmspec_tree) asmspec = TREE_STRING_POINTER (asmspec_tree); + if (init && TREE_CODE (init) == NAMESPACE_DECL) + { + cp_error ("Cannot initialize `%D' to namespace `%D'", + decl, init); + init = NULL_TREE; + } + /* If the type of the thing we are declaring either has a constructor, or has a virtual function table pointer, AND its initialization was accepted by `start_decl', @@ -6785,7 +6943,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) make_decl_one_only (decl); else { - /* we can't do anything useful; leave vars for explicit + /* We can't do anything useful; leave vars for explicit instantiation. */ DECL_EXTERNAL (decl) = 1; DECL_NOT_REALLY_EXTERN (decl) = 0; @@ -7329,7 +7487,7 @@ bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises) static tree grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, raises, attrlist, check, friendp, publicp, inlinep, funcdef_flag, - template_count) + template_count, in_namespace) tree ctype, type; tree declarator; tree orig_declarator; @@ -7337,6 +7495,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, enum overload_flags flags; tree quals, raises, attrlist; int check, friendp, publicp, inlinep, funcdef_flag, template_count; + tree in_namespace; { tree cname, decl; int staticp = ctype && TREE_CODE (type) == FUNCTION_TYPE; @@ -7354,10 +7513,14 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, } decl = build_lang_decl (FUNCTION_DECL, declarator, type); - /* propagate volatile out from type to decl */ + /* Propagate volatile out from type to decl. */ if (TYPE_VOLATILE (type)) TREE_THIS_VOLATILE (decl) = 1; + /* This decl is not from the current namespace. */ + if (in_namespace) + set_decl_namespace (decl, in_namespace); + /* Should probably propagate const out from type to decl I bet (mrs). */ if (staticp) { @@ -7463,18 +7626,16 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, if (check == 0 && ! current_function_decl) { - /* assembler names live in the global namespace */ + /* Assembler names live in the global namespace. */ tmp = IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl)); if (tmp == NULL_TREE) - IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl)) = decl; + SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl), decl); else if (TREE_CODE (tmp) != TREE_CODE (decl)) cp_error ("inconsistent declarations for `%D'", decl); else { duplicate_decls (decl, tmp); decl = tmp; - /* avoid creating circularities. */ - DECL_CHAIN (decl) = NULL_TREE; } make_decl_rtl (decl, NULL_PTR, 1); } @@ -7538,15 +7699,13 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, IDENTIFIER_GLOBAL_VALUE. */ tmp = lookup_name (DECL_ASSEMBLER_NAME (decl), 0); if (tmp == NULL_TREE) - IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl)) = decl; + SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl), decl); else if (TREE_CODE (tmp) != TREE_CODE (decl)) cp_error ("inconsistent declarations for `%D'", decl); else { duplicate_decls (decl, tmp); decl = tmp; - /* avoid creating circularities. */ - DECL_CHAIN (decl) = NULL_TREE; } } @@ -7567,12 +7726,13 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, } static tree -grokvardecl (type, declarator, specbits_in, initialized, constp) +grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace) tree type; tree declarator; RID_BIT_TYPE *specbits_in; int initialized; int constp; + tree in_namespace; { tree decl; RID_BIT_TYPE specbits; @@ -7592,12 +7752,16 @@ grokvardecl (type, declarator, specbits_in, initialized, constp) } else { + tree context = in_namespace ? in_namespace : current_namespace; decl = build_decl (VAR_DECL, declarator, complete_type (type)); - if (current_namespace != global_namespace) - DECL_ASSEMBLER_NAME (decl) = build_static_name (current_namespace, + if (context != global_namespace) + DECL_ASSEMBLER_NAME (decl) = build_static_name (context, declarator); } + if (in_namespace) + set_decl_namespace (decl, in_namespace); + if (RIDBIT_SETP (RID_EXTERN, specbits)) { DECL_THIS_EXTERN (decl) = 1; @@ -7659,9 +7823,9 @@ build_ptrmemfunc_type (type) t = make_lang_type (RECORD_TYPE); - /* Let the front-end know this is a pointer to member function. */ + /* Let the front-end know this is a pointer to member function... */ TYPE_PTRMEMFUNC_FLAG (t) = 1; - /* and not really an aggregate. */ + /* ... and not really an aggregate. */ IS_AGGR_TYPE (t) = 0; fields[0] = build_lang_field_decl (FIELD_DECL, delta_identifier, @@ -7788,6 +7952,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) tree quals = NULL_TREE; tree raises = NULL_TREE; int template_count = 0; + tree in_namespace = NULL_TREE; RIDBIT_RESET_ALL (specbits); if (decl_context == FUNCDEF) @@ -7814,7 +7979,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) next = &TREE_OPERAND (decl, 0); break; - case BIT_NOT_EXPR: /* for C++ destructors! */ + case BIT_NOT_EXPR: /* For C++ destructors! */ { tree name = TREE_OPERAND (decl, 0); tree rename = NULL_TREE; @@ -7857,7 +8022,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) break; case ADDR_EXPR: /* C++ reference declaration */ - /* fall through */ + /* Fall through. */ case ARRAY_REF: case INDIRECT_REF: ctype = NULL_TREE; @@ -7919,7 +8084,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) else my_friendly_abort (0); } - /* fall through */ + /* Fall through. */ case IDENTIFIER_NODE: if (TREE_CODE (decl) == IDENTIFIER_NODE) @@ -7957,6 +8122,12 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) tree cname = TREE_OPERAND (decl, 0); if (cname == NULL_TREE) ctype = NULL_TREE; + else if (TREE_CODE (cname) == NAMESPACE_DECL) + { + ctype = NULL_TREE; + in_namespace = TREE_OPERAND (decl, 0); + TREE_OPERAND (decl, 0) = NULL_TREE; + } else if (! is_aggr_type (cname, 1)) TREE_OPERAND (decl, 0) = NULL_TREE; /* Must test TREE_OPERAND (decl, 1), in case user gives @@ -8747,7 +8918,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) the function; then build_vec_delete will need this value. */ int yes = suspend_momentary (); - /* might be a cast */ + /* Might be a cast. */ if (TREE_CODE (size) == NOP_EXPR && TREE_TYPE (size) == TREE_TYPE (TREE_OPERAND (size, 0))) size = TREE_OPERAND (size, 0); @@ -8939,7 +9110,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) return void_type_node; } } - else /* it's a constructor. */ + else /* It's a constructor. */ { if (explicitp == 1) explicitp = 2; @@ -9203,7 +9374,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) /* This needs to be here, in case we are called multiple times. */ ; else if (friendp && (TREE_COMPLEXITY (declarator) < 2)) - /* don't fall out into global scope. Hides real bug? --eichin */ ; + /* Don't fall out into global scope. Hides real bug? --eichin */ ; else if (! IS_AGGR_TYPE_CODE (TREE_CODE (TREE_OPERAND (declarator, 0)))) ; @@ -9292,7 +9463,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) else if (RIDBIT_SETP (RID_TYPEDEF, specbits) || TYPE_SIZE (complete_type (ctype)) != NULL_TREE) { - /* have to move this code elsewhere in this function. + /* Have to move this code elsewhere in this function. this code is used for i.e., typedef int A::M; M *pm; It is? How? jason 10/2/94 */ @@ -9418,16 +9589,26 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL && ANON_AGGRNAME_P (TYPE_IDENTIFIER (type))) { - /* replace the anonymous name with the real name everywhere. */ + /* Replace the anonymous name with the real name everywhere. */ lookup_tag_reverse (type, declarator); TYPE_NAME (type) = decl; if (TYPE_LANG_SPECIFIC (type)) TYPE_WAS_ANONYMOUS (type) = 1; + /* XXX Temporarily set the scope. + When returning, start_decl expects it as NULL_TREE, + and will then then set it using pushdecl. */ + my_friendly_assert (DECL_CONTEXT (decl) == NULL_TREE, 980404); + if (current_class_type) + DECL_CONTEXT (decl) = current_class_type; + else + DECL_CONTEXT (decl) = current_namespace; + DECL_ASSEMBLER_NAME (decl) = DECL_NAME (decl); DECL_ASSEMBLER_NAME (decl) = get_identifier (build_overload_name (type, 1, 1)); + DECL_CONTEXT (decl) = NULL_TREE; } if (TREE_CODE (type) == OFFSET_TYPE || TREE_CODE (type) == METHOD_TYPE) @@ -9688,7 +9869,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) declarator, virtualp, flags, quals, raises, attrlist, friendp ? -1 : 0, friendp, publicp, inlinep, - funcdef_flag, template_count); + funcdef_flag, template_count, in_namespace); if (decl == NULL_TREE) return NULL_TREE; #if 0 @@ -9709,7 +9890,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) decl = grokfndecl (ctype, type, declarator, declarator, virtualp, flags, quals, raises, attrlist, friendp ? -1 : 0, friendp, 1, 0, funcdef_flag, - template_count); + template_count, in_namespace); if (decl == NULL_TREE) return NULL_TREE; } @@ -9907,19 +10088,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) virtualp, flags, quals, raises, attrlist, 1, friendp, publicp, inlinep, funcdef_flag, - template_count); + template_count, in_namespace); if (decl == NULL_TREE) return NULL_TREE; if (ctype == NULL_TREE && DECL_LANGUAGE (decl) != lang_c && (! DECL_USE_TEMPLATE (decl) || name_mangling_version < 1)) -#if 0 - /* XXX is support for the old __ns_ mangling really needed? MvL */ - DECL_ASSEMBLER_NAME (decl) = current_namespace_id (declarator); -#else DECL_ASSEMBLER_NAME (decl) = declarator; -#endif if (staticp == 1) { @@ -9977,7 +10153,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) } /* An uninitialized decl with `extern' is a reference. */ - decl = grokvardecl (type, declarator, &specbits, initialized, constp); + decl = grokvardecl (type, declarator, &specbits, + initialized, constp, in_namespace); bad_specifiers (decl, "variable", virtualp, quals != NULL_TREE, inlinep, friendp, raises != NULL_TREE); @@ -10239,14 +10416,14 @@ grokparms (first_parm, funcdef_flag) && CLASSTYPE_ABSTRACT_VIRTUALS (type)) { abstract_virtuals_error (decl, type); - any_error = 1; /* seems like a good idea */ + any_error = 1; /* Seems like a good idea. */ } else if (TREE_CODE (type) == RECORD_TYPE && TYPE_LANG_SPECIFIC (type) && IS_SIGNATURE (type)) { signature_error (decl, type); - any_error = 1; /* seems like a good idea */ + any_error = 1; /* Seems like a good idea. */ } } @@ -10591,7 +10768,7 @@ grok_op_properties (decl, virtualp, friendp) } if (name == ansi_opname[(int) CALL_EXPR]) - return; /* no restrictions on args */ + return; /* No restrictions on args. */ if (IDENTIFIER_TYPENAME_P (name) && ! DECL_TEMPLATE_INFO (decl)) { @@ -10924,13 +11101,11 @@ xref_tag (code_type_node, name, binfo, globalize) /* If it no longer looks like a nested type, make sure it's in global scope. If it is not an IDENTIFIER, this is not a declaration */ - if (b == global_binding_level && !class_binding_level + if (b->namespace_p && !class_binding_level && TREE_CODE (name) == IDENTIFIER_NODE) { - tree binding; - binding = binding_for_name (name, current_namespace); - if (BINDING_VALUE (binding) == NULL_TREE) - BINDING_VALUE (binding) = TYPE_NAME (ref); + if (IDENTIFIER_NAMESPACE_VALUE (name) == NULL_TREE) + SET_IDENTIFIER_NAMESPACE_VALUE (name, TYPE_NAME (ref)); } if (!globalize && processing_template_decl && IS_AGGR_TYPE (ref)) @@ -11265,7 +11440,7 @@ finish_enum (enumtype, values) } /* Finish debugging output for this type. */ - rest_of_type_compilation (enumtype, global_bindings_p ()); + rest_of_type_compilation (enumtype, namespace_bindings_p ()); return enumtype; } @@ -11461,6 +11636,7 @@ start_function (declspecs, declarator, attrs, pre_parsed_p) if (! DECL_ARGUMENTS (decl1) && !DECL_STATIC_FUNCTION_P (decl1) && DECL_CONTEXT (decl1) + && TREE_CODE (DECL_CONTEXT (decl1)) != NAMESPACE_DECL && TYPE_IDENTIFIER (DECL_CONTEXT (decl1)) && IDENTIFIER_TEMPLATE (TYPE_IDENTIFIER (DECL_CONTEXT (decl1)))) { @@ -11625,6 +11801,10 @@ start_function (declspecs, declarator, attrs, pre_parsed_p) || !DECL_TEMPLATE_SPECIALIZATION (decl1)) && ! DECL_FUNCTION_MEMBER_P (decl1)) decl1 = pushdecl (decl1); + else + /* We need to set the DECL_CONTEXT. */ + if (!DECL_CONTEXT (decl1) && DECL_TEMPLATE_INFO (decl1)) + DECL_CONTEXT (decl1) = DECL_CONTEXT (DECL_TI_TEMPLATE (decl1)); DECL_MAIN_VARIANT (decl1) = decl1; fntype = TREE_TYPE (decl1); } @@ -11931,7 +12111,7 @@ store_parm_decls () if (DECL_NAME (fndecl) && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 4 && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main") == 0 - && DECL_CONTEXT (fndecl) == NULL_TREE) + && DECL_CONTEXT (fndecl) == global_namespace) { expand_main_function (); } @@ -12385,7 +12565,7 @@ finish_function (lineno, call_poplevel, nested) } else if (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 4 && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main") - && DECL_CONTEXT (fndecl) == NULL_TREE) + && DECL_CONTEXT (fndecl) == global_namespace) { /* Make it so that `main' always returns 0 by default. */ #ifdef VMS @@ -12430,7 +12610,7 @@ finish_function (lineno, call_poplevel, nested) if (cleanup_label) { - /* remove the binding contour which is used + /* Remove the binding contour which is used to catch cleanup-generated temporaries. */ expand_end_bindings (0, 0, 0); poplevel (0, 0, 0); @@ -12466,7 +12646,7 @@ finish_function (lineno, call_poplevel, nested) my_friendly_abort (122); poplevel (1, 0, 1); - /* reset scope for C++: if we were in the scope of a class, + /* Reset scope for C++: if we were in the scope of a class, then when we finish this function, we are not longer so. This cannot be done until we know for sure that no more class members will ever be referenced in this function @@ -12658,7 +12838,8 @@ start_method (declspecs, declarator) { if (IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (fndecl)) != current_class_type) { - if (DECL_CONTEXT (fndecl)) + if (DECL_CONTEXT (fndecl) + && TREE_CODE( DECL_CONTEXT (fndecl)) != NAMESPACE_DECL) cp_error ("`%D' is already defined in class %s", fndecl, TYPE_NAME_STRING (DECL_CONTEXT (fndecl))); } @@ -12681,14 +12862,6 @@ start_method (declspecs, declarator) if (! DECL_FRIEND_P (fndecl)) { - if (DECL_CHAIN (fndecl) != NULL_TREE) - { - /* Need a fresh node here so that we don't get circularity - when we link these together. If FNDECL was a friend, then - `pushdecl' does the right thing, which is nothing wrt its - current value of DECL_CHAIN. */ - fndecl = copy_node (fndecl); - } if (TREE_CHAIN (fndecl)) { fndecl = copy_node (fndecl); @@ -12768,7 +12941,7 @@ finish_method (decl) IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); for (link = current_binding_level->type_shadowed; link; link = TREE_CHAIN (link)) - IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); + SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link), TREE_VALUE (link)); GNU_xref_end_scope ((HOST_WIDE_INT) current_binding_level, (HOST_WIDE_INT) current_binding_level->level_chain, diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index e945a72..3d6dc25 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -88,11 +88,15 @@ int at_eof; tree static_ctors, static_dtors; -/* The current open namespace, and :: */ +/* The current open namespace, and ::. */ tree current_namespace; tree global_namespace; +/* The stack for namespaces of current declarations. */ + +static tree decl_namespace_list; + /* C (and C++) language-specific option variables. */ @@ -410,6 +414,10 @@ int flag_weak = 1; int flag_new_abi; +/* Nonzero to not ignore namespace std. */ + +int flag_honor_std; + /* Maximum template instantiation depth. Must be at least 17 for ANSI compliance. */ @@ -460,6 +468,7 @@ static struct { char *string; int *variable; int on_value;} lang_f_options[] = {"default-inline", &flag_default_inline, 1}, {"dollars-in-identifiers", &dollars_in_ident, 1}, {"enum-int-equiv", &flag_int_enum_equivalence, 1}, + {"honor-std", &flag_honor_std, 1}, {"rtti", &flag_rtti, 1}, {"xref", &flag_gnu_xref, 1}, {"nonnull-objects", &flag_assume_nonnull_objects, 1}, @@ -572,12 +581,14 @@ lang_decode_option (p) { flag_new_abi = 1; flag_do_squangling = 1; + flag_honor_std = 1; flag_vtable_thunks = 1; } else if (!strcmp (p, "no-new-abi")) { flag_new_abi = 0; flag_do_squangling = 0; + flag_honor_std = 0; } else if (!strncmp (p, "template-depth-", 15)) { @@ -1391,7 +1402,7 @@ check_classfn (ctype, function) tree ctype, function; { tree fn_name = DECL_NAME (function); - tree fndecl; + tree fndecl, fndecls; tree method_vec = CLASSTYPE_METHOD_VEC (complete_type (ctype)); tree *methods = 0; tree *end = 0; @@ -1403,22 +1414,23 @@ check_classfn (ctype, function) end = TREE_VEC_END (method_vec); /* First suss out ctors and dtors. */ - if (*methods && fn_name == DECL_NAME (*methods) + if (*methods && fn_name == DECL_NAME (OVL_CURRENT (*methods)) && DECL_CONSTRUCTOR_P (function)) goto got_it; - if (*++methods && fn_name == DECL_NAME (*methods) + if (*++methods && fn_name == DECL_NAME (OVL_CURRENT (*methods)) && DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (function))) goto got_it; while (++methods != end) { fndecl = *methods; - if (fn_name == DECL_NAME (*methods)) + if (fn_name == DECL_NAME (OVL_CURRENT (*methods))) { got_it: - for (fndecl = *methods; fndecl != NULL_TREE; - fndecl = DECL_CHAIN (fndecl)) + for (fndecls = *methods; fndecls != NULL_TREE; + fndecls = OVL_NEXT (fndecls)) { + fndecl = OVL_CURRENT (fndecls); /* The DECL_ASSEMBLER_NAME for a TEMPLATE_DECL is not mangled, so the check below does not work correctly in that case. */ @@ -1489,10 +1501,10 @@ check_classfn (ctype, function) tree fndecl = *methods; cp_error ("prototype for `%#D' does not match any in class `%T'", function, ctype); - cp_error_at ("candidate%s: %+#D", DECL_CHAIN (fndecl) ? "s are" : " is", - fndecl); - while (fndecl = DECL_CHAIN (fndecl), fndecl) - cp_error_at (" %#D", fndecl); + cp_error_at ("candidate%s: %+#D", OVL_NEXT (fndecl) ? "s are" : " is", + OVL_CURRENT (fndecl)); + while (fndecl = OVL_NEXT (fndecl), fndecl) + cp_error_at (" %#D", OVL_CURRENT(fndecl)); } else { @@ -1745,14 +1757,6 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist) if (TREE_CODE (value) == FUNCTION_DECL) { check_default_args (value); - if (DECL_CHAIN (value) != NULL_TREE) - { - /* Need a fresh node here so that we don't get circularity - when we link these together. */ - value = copy_node (value); - /* When does this happen? */ - my_friendly_assert (init == NULL_TREE, 193); - } if (asmspec) { /* This must override the asm specifier which was placed @@ -2777,7 +2781,7 @@ get_sentry (base) tree base; { tree sname = get_id_2 ("__sn", base); - /* for struct X foo __attribute__((weak)), there is a counter + /* For struct X foo __attribute__((weak)), there is a counter __snfoo. Since base is already an assembler name, sname should be globally unique */ tree sentry = IDENTIFIER_GLOBAL_VALUE (sname); @@ -2855,6 +2859,8 @@ finish_file () instantiate_decl (fn); } + cat_namespace_levels(); + /* Push into C language context, because that's all we'll need here. */ push_lang_context (lang_name_c); @@ -2973,7 +2979,7 @@ finish_file () assemble_destructor (IDENTIFIER_POINTER (fnname)); - /* if it needed cleaning, then it will need messing up: drop through */ + /* If it needed cleaning, then it will need messing up: drop through. */ mess_up: /* Must do this while we think we are at the top level. */ @@ -3666,7 +3672,8 @@ check_cp_case_value (value) return value; } -/* return 1 if root encloses child */ +/* Return 1 if root encloses child. */ + static int is_namespace_ancestor (root, child) tree root, child; @@ -3677,19 +3684,20 @@ is_namespace_ancestor (root, child) return 1; if (child == global_namespace) return 0; - return is_namespace_ancestor (root, DECL_NAMESPACE (child)); + return is_namespace_ancestor (root, DECL_CONTEXT (child)); } -/* return the namespace that is the common ancestor - of two given namespaces */ +/* Return the namespace that is the common ancestor + of two given namespaces. */ + static tree namespace_ancestor (ns1, ns2) tree ns1, ns2; { if (is_namespace_ancestor (ns1, ns2)) return ns1; - return namespace_ancestor (DECL_NAMESPACE (ns1), ns2); + return namespace_ancestor (DECL_CONTEXT (ns1), ns2); } /* Insert used into the using list of user. Set indirect_flag if this @@ -3702,23 +3710,23 @@ add_using_namespace (user, used, indirect) int indirect; { tree iter; - /* using oneself is a no-op */ + /* Using oneself is a no-op. */ if (user == used) return; my_friendly_assert (TREE_CODE (user) == NAMESPACE_DECL, 380); my_friendly_assert (TREE_CODE (used) == NAMESPACE_DECL, 380); - /* check if we already have this */ + /* Check if we already have this. */ if (purpose_member (used, DECL_NAMESPACE_USING (user)) != NULL_TREE) return; - /* add used to the user's using list */ + /* Add used to the user's using list. */ DECL_NAMESPACE_USING (user) = perm_tree_cons (used, namespace_ancestor (user, used), DECL_NAMESPACE_USING (user)); TREE_INDIRECT_USING (DECL_NAMESPACE_USING (user)) = indirect; - /* add user to the used's users list */ + /* Add user to the used's users list. */ DECL_NAMESPACE_USERS (used) = perm_tree_cons (user, 0, DECL_NAMESPACE_USERS (used)); @@ -3727,102 +3735,130 @@ add_using_namespace (user, used, indirect) add_using_namespace (TREE_PURPOSE (iter), used, 1); } +/* Combines two sets of overloaded functions into an OVERLOAD chain. + The first list becomes the tail of the result. */ + +static tree +merge_functions (s1, s2) + tree s1; + tree s2; +{ + tree tmp, tempn; + if (TREE_CODE (s2) == OVERLOAD) + while (s2) + { + s1 = build_overload (OVL_FUNCTION (s2), s1); + s2 = OVL_CHAIN (s2); + } + else + s1 = build_overload (s2, s1); + return s1; +} + /* This should return an error not all definitions define functions. It is not an error if we find two functions with exactly the same signature, only if these are selected in overload resolution. + old is the current set of bindings, new the freshly-found binding. XXX Do we want to give *all* candidates in case of ambiguity? XXX In what way should I treat extern declarations? XXX I don't want to repeat the entire duplicate_decls here */ + static tree -ambiguous_decl (name, val1, val2) - tree name, val1, val2; +ambiguous_decl (name, old, new) + tree name; + tree old; + tree new; { - my_friendly_assert (val1 != val2, 376); - if (is_overloaded_fn (val1) && is_overloaded_fn (val1)) + my_friendly_assert (old != NULL_TREE, 393); + /* Copy the value. */ + if (!BINDING_VALUE (old)) + BINDING_VALUE (old) = BINDING_VALUE (new); + else if (BINDING_VALUE (new) + && BINDING_VALUE (new) != BINDING_VALUE (old)) + { + if (is_overloaded_fn (BINDING_VALUE (old)) + && is_overloaded_fn (BINDING_VALUE (new))) + { + BINDING_VALUE (old) = merge_functions (BINDING_VALUE (old), + BINDING_VALUE (new)); + } + else + { + /* Some declarations are functions, some are not. */ + cp_error ("ambiguous definition `%D' used", name); + cp_error_at ("first definition here", BINDING_VALUE (old)); + cp_error_at ("other definition here", BINDING_VALUE (new)); + return error_mark_node; + } + } + /* ... and copy the type. */ + if (!BINDING_TYPE (old)) + BINDING_TYPE (old) = BINDING_TYPE (new); + else if(BINDING_TYPE (new) + && BINDING_TYPE (old) != BINDING_TYPE (new)) { - /* now built a joint list of all overloaded declarations */ - /* XXX if I chain'em together, they will be always considered - as overloaded */ - sorry ("overloaded functions used from different namespaces"); + cp_error ("`%D' denotes an ambiguous type",name); + cp_error_at ("first type here", BINDING_TYPE (old)); + cp_error_at ("other type here", BINDING_TYPE (new)); } - cp_error ("ambiguous definition `%D' used", name); - cp_error_at ("first definition here", val1); - cp_error_at ("other definition here", val2); - return error_mark_node; + return old; } -/* add the bindings of name in used namespaces to val - the using list is defined by current, and the lookup goes to scope */ -tree +/* Add the bindings of name in used namespaces to val. + The using list is defined by current, and the lookup goes to scope. + Returns zero on errors. */ + +int lookup_using_namespace (name, val, current, scope) tree name, val, current, scope; { tree iter; tree val1; - /* iterate over all namespaces from current to scope */ - while (1) + /* Iterate over all namespaces from current to scope. */ + while (val != error_mark_node) { - /* iterate over all used namespaces in current, searching for - using directives of scope */ + /* Iterate over all used namespaces in current, searching for + using directives of scope. */ for (iter = DECL_NAMESPACE_USING (current); iter; iter = TREE_CHAIN (iter)) if (TREE_VALUE (iter) == scope) { - val1 = NAMESPACE_BINDING (name, TREE_PURPOSE (iter)); - /* name not found in this space */ - if (!val1) - continue; - /* first definition ever */ - if (!val) - { - val = val1; - continue; - } - /* Hmmm. Ambiguity. As long as both are overloaded functions, - this is fine */ + val1 = binding_for_name (name, TREE_PURPOSE (iter)); + /* Resolve ambiguities. */ val = ambiguous_decl (name, val, val1); - if (val == error_mark_node) - break; } if (current == scope) break; - current = DECL_NAMESPACE (current); + current = DECL_CONTEXT (current); } - return val; + return val != error_mark_node; } -/* [namespace.qual] */ -tree -qualified_lookup_using_namespace (name, scope) +/* [namespace.qual] + Excepts the name to lookup and its qualifying scope. + Returns the name/type pair found into the CPLUS_BINDING result, + or 0 on error. */ + +int +qualified_lookup_using_namespace (name, scope, result) tree name; tree scope; + tree result; { - tree val = NULL_TREE; - tree val1; - /* maintain a list of namespaces visited */ + /* Maintain a list of namespaces visited... */ tree seen = NULL_TREE; - /* and a list of namespace yet to see */ + /* ... and a list of namespace yet to see. */ tree todo = NULL_TREE; tree usings; - while (scope) + while (scope && (result != error_mark_node)) { seen = temp_tree_cons (scope, NULL_TREE, seen); - val1 = NAMESPACE_BINDING (name, scope); - if (val1) - { - if (val) - { - val = ambiguous_decl (name, val, val1); - break; - } - else - val = val1; - } - else - /* consider using directives */ + result = ambiguous_decl (name, result, binding_for_name (name, scope)); + if (!BINDING_VALUE (result) && !BINDING_TYPE (result)) + /* Consider using directives. */ for (usings = DECL_NAMESPACE_USING (scope); usings; usings = TREE_CHAIN (usings)) - /* if this was a real directive, and we have not seen it */ + /* If this was a real directive, and we have not seen it. */ if (!TREE_INDIRECT_USING (usings) && !purpose_member (seen, TREE_PURPOSE (usings))) todo = temp_tree_cons (TREE_PURPOSE (usings), NULL_TREE, todo); @@ -3832,45 +3868,360 @@ qualified_lookup_using_namespace (name, scope) todo = TREE_CHAIN (todo); } else - scope = NULL_TREE; /* if there never was a todo list */ + scope = NULL_TREE; /* If there never was a todo list. */ } - return val; + return result != error_mark_node; } -#if 0 -/* this is broken and should not be called anymore */ -/* Get the inner part of a namespace id. It doesn't have any prefix, nor - postfix. Returns 0 if in global namespace. */ +/* [namespace.memdef]/2 */ + +/* Set the context of a declaration to scope. Complain if we are not + outside scope. */ + +void +set_decl_namespace (decl, scope) + tree decl; + tree scope; +{ + tree old; + if (scope == std_node) + scope = global_namespace; + if (!is_namespace_ancestor (current_namespace, scope)) + cp_error ("declaration of `%D' not in a namespace surrounding `%D'", + decl, scope); + DECL_CONTEXT (decl) = scope; + if (scope != current_namespace) + { + /* See whether this has been declared in the namespace. */ + old = namespace_binding (DECL_NAME (decl), scope); + if (!old) + /* No old declaration at all. */ + goto complain; + if (!is_overloaded_fn (decl)) + /* Don't compare non-function decls with decls_match here, + since it can't check for the correct constness at this + point. pushdecl will find those errors later. */ + return; + /* Since decl is a function, old should contain a function decl. */ + if (!is_overloaded_fn (old)) + goto complain; + for (; old; old = OVL_NEXT (old)) + if (decls_match (decl, OVL_CURRENT (old))) + return; + } + else + return; + complain: + cp_error ("`%D' should have been declared inside `%D'", + decl, scope); +} + +/* Compute the namespace where a declaration is defined. */ tree -get_namespace_id () +decl_namespace (decl) + tree decl; { - tree x = current_namespace; - if (x) - x = TREE_PURPOSE (x); - return x; + while (DECL_CONTEXT (decl)) + { + decl = DECL_CONTEXT (decl); + if (TREE_CODE (decl) == NAMESPACE_DECL) + return decl; + if (TREE_CODE_CLASS (TREE_CODE (decl)) == 't') + decl = TYPE_STUB_DECL (decl); + my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd', 390); + } + + /* We should always find the namespace. */ + my_friendly_abort (390); + return NULL_TREE; } -/* Build up a DECL_ASSEMBLER_NAME for NAME in the current namespace. */ +/* Return the namespace where the current declaration is declared. */ tree -current_namespace_id (name) - tree name; +current_decl_namespace () { - tree old_id = get_namespace_id (); - char *buf; + tree result; + /* If we have been pushed into a different namespace, use it. */ + if (decl_namespace_list) + return TREE_PURPOSE (decl_namespace_list); + + if (current_class_type) + if (CLASSTYPE_USE_TEMPLATE (current_class_type)) + result = decl_namespace (CLASSTYPE_TI_TEMPLATE (current_class_type)); + else + result = decl_namespace (TYPE_STUB_DECL (current_class_type)); + else if (current_function_decl) + if (DECL_USE_TEMPLATE (current_function_decl)) + result = decl_namespace (DECL_TI_TEMPLATE (current_function_decl)); + else + result = decl_namespace (current_function_decl); + else + result = current_namespace; + return result; +} - /* Global names retain old encoding. */ - if (! old_id) - return name; +/* Temporarily set the namespace for the current declaration. */ - buf = (char *) alloca (8 + IDENTIFIER_LENGTH (old_id) - + IDENTIFIER_LENGTH (name)); - sprintf (buf, "__ns_%s_%s", IDENTIFIER_POINTER (old_id), - IDENTIFIER_POINTER (name)); - return get_identifier (buf); +void +push_decl_namespace (decl) + tree decl; +{ + if (TREE_CODE (decl) != NAMESPACE_DECL) + decl = decl_namespace (decl); + decl_namespace_list = tree_cons (decl, NULL_TREE, decl_namespace_list); +} + +void +pop_decl_namespace () +{ + decl_namespace_list = TREE_CHAIN (decl_namespace_list); +} + +/* [basic.lookup.koenig] */ +/* A non-zero return value in the functions below indicates an error. + All nodes allocated in the procedure are on the scratch obstack. */ + +struct arg_lookup +{ + tree name; + tree namespaces; + tree classes; + tree functions; +}; + +static int arg_assoc PROTO((struct arg_lookup*, tree)); +static int arg_assoc_args PROTO((struct arg_lookup*, tree)); + +/* Add a function to the lookup structure. */ + +static int +add_function (k, fn) + struct arg_lookup *k; + tree fn; +{ + if (ovl_member (fn, k->functions)) + return 0; + k->functions = build_overload (fn, k->functions); + return 0; +} + +/* Add functions of a namespace to the lookup structure. */ + +static int +arg_assoc_namespace (k, scope) + struct arg_lookup *k; + tree scope; +{ + tree value; + + if (purpose_member (scope, k->namespaces)) + return 0; + k->namespaces = tree_cons (scope, NULL_TREE, k->namespaces); + + value = namespace_binding (k->name, scope); + if (!value) + return 0; + + if (!is_overloaded_fn (value)) + { + cp_error_at ("`%D' is not a function", value); + cp_error ("in call to `%D'", k->name); + return 1; + } + + for (; value; value = OVL_NEXT (value)) + if (add_function (k, OVL_CURRENT (value))) + return 1; + + return 0; } -#endif + +/* Adds everything associated with class to the lookup structure. */ + +static int +arg_assoc_class (k, type) + struct arg_lookup* k; + tree type; +{ + tree list, friends, context; + int i; + + if (purpose_member (type, k->classes)) + return 0; + k->classes = tree_cons (type, NULL_TREE, k->classes); + + context = decl_namespace (TYPE_MAIN_DECL (type)); + if (arg_assoc_namespace (k, context)) + return 1; + + /* Process baseclasses. */ + for (i = 0; i < CLASSTYPE_N_BASECLASSES (type); i++) + if (arg_assoc_class (k, TYPE_BINFO_BASETYPE (type, i))) + return 1; + + /* Process friends. */ + for (list = DECL_FRIENDLIST (TYPE_MAIN_DECL (type)); list; + list = TREE_CHAIN (list)) + if (k->name == TREE_PURPOSE (list)) + for (friends = TREE_VALUE (list); friends; + friends = TREE_CHAIN (friends)) + /* Only interested in global functions with potentially hidden + (i.e. unqualified) declarations. */ + if (TREE_PURPOSE (list) == error_mark_node && TREE_VALUE (list) + && decl_namespace (TREE_VALUE (list)) == context) + if (add_function (k, TREE_VALUE (list))) + return 1; + return 0; +} + +/* Adds everything associated with a given type. */ + +static int +arg_assoc_type (k, type) + struct arg_lookup *k; + tree type; +{ + switch (TREE_CODE (type)) + { + case VOID_TYPE: + case INTEGER_TYPE: + case REAL_TYPE: + case COMPLEX_TYPE: + case CHAR_TYPE: + case BOOLEAN_TYPE: + return 0; + case RECORD_TYPE: + if (TYPE_PTRMEMFUNC_P (type)) + return arg_assoc_type (k, TYPE_PTRMEMFUNC_FN_TYPE (type)); + return arg_assoc_class (k, type); + case POINTER_TYPE: + case REFERENCE_TYPE: + case ARRAY_TYPE: + return arg_assoc_type (k, TREE_TYPE (type)); + case UNION_TYPE: + case ENUMERAL_TYPE: + return arg_assoc_namespace (k, decl_namespace (TYPE_MAIN_DECL (type))); + case METHOD_TYPE: + /* Associate the class of the method. */ + if (arg_assoc_type (k, TYPE_METHOD_BASETYPE (type))) + return 1; + /* Fall through. */ + case FUNCTION_TYPE: + /* Associate the parameter types. */ + if (arg_assoc_args (k, TYPE_ARG_TYPES (type))) + return 1; + /* Associate the return type. */ + return arg_assoc_type (k, TREE_TYPE (type)); + default: + my_friendly_abort (390); + } + return 0; +} + +/* Adds everything associated with arguments. */ + +static int +arg_assoc_args (k, args) + struct arg_lookup* k; + tree args; +{ + for (; args; args = TREE_CHAIN (args)) + if (arg_assoc (k, TREE_VALUE (args))) + return 1; + return 0; +} + +/* Adds everything associated with a given tree_node. */ + +static int +arg_assoc (k, n) + struct arg_lookup* k; + tree n; +{ + switch (TREE_CODE_CLASS (TREE_CODE (n))) + { + case 't': + return arg_assoc_type (k, n); + case 'c': + case '1': + case '2': + case '<': + case 'r': + return arg_assoc_type (k, TREE_TYPE (n)); + case 'e': + switch (TREE_CODE (n)) + { + case ADDR_EXPR: + /* special processing */ + break; + default: + return arg_assoc_type (k, TREE_TYPE (n)); + } + default: + break; + } + + while (n) + switch (TREE_CODE (n)) + { + case CONST_DECL: /* 'd' */ + case VAR_DECL: + case PARM_DECL: + case RESULT_DECL: + return arg_assoc_type (k, TREE_TYPE (n)); + case ADDR_EXPR: /* 'e' */ + /* We can't use the TREE_TYPE, as the type of an overloaded function + will be useless here. */ + n = TREE_OPERAND (n, 0); + continue; + case OVERLOAD: /* 'x' */ + if (arg_assoc (k, OVL_CURRENT (n))) + return 1; + n = OVL_NEXT (n); + continue; + case TREE_LIST: /* 'x' */ + /* XXX Overloaded member, should get an OVERLOAD directly, here. */ + n = TREE_VALUE (n); + continue; + case FUNCTION_DECL: /* 'd' */ + if (arg_assoc_args (k, FUNCTION_ARG_CHAIN (n))) + return 1; + if (DECL_FUNCTION_MEMBER_P (n)) + if (arg_assoc_type (k, DECL_CLASS_CONTEXT (n))) + return 1; + return 0; + default: + cp_error ("sorry, Koenig lookup for `%s' of type `%T' failed", + tree_code_name [(int)TREE_CODE (n)], TREE_TYPE (n)); + my_friendly_abort (391); + } + return 0; +} + +/* Performs Koenig lookup depending on arguments, where fns + are the functions found in normal lookup. */ + +tree +lookup_arg_dependent (name, fns, args) + tree name; + tree fns; + tree args; +{ + struct arg_lookup k; + k.name = name; + k.functions = fns; + k.namespaces = NULL_TREE; + k.classes = NULL_TREE; + + push_scratch_obstack (); + arg_assoc_args (&k, args); + pop_obstacks (); + return k.functions; +} + +/* Process a namespace-alias declaration. */ void do_namespace_alias (alias, namespace) @@ -3901,34 +4252,100 @@ do_namespace_alias (alias, namespace) } } +/* Process a using-declaration not appearing in class or local scope. */ + void do_toplevel_using_decl (decl) tree decl; { -#if 1 + tree scope, name, binding, decls, newval, newtype; + struct tree_binding _decls; + if (TREE_CODE (decl) == SCOPE_REF && TREE_OPERAND (decl, 0) == std_node) return; - sorry ("using-declaration"); -#else - if (decl == NULL_TREE || decl == error_mark_node) + if (TREE_CODE (decl) == SCOPE_REF) + { + scope = TREE_OPERAND (decl, 0); + name = TREE_OPERAND (decl, 1); + } + else if (TREE_CODE (decl) == IDENTIFIER_NODE) + { + scope = global_namespace; + name = decl; + } + else + my_friendly_abort (382); + if (TREE_CODE_CLASS (TREE_CODE (name)) == 'd') + name = DECL_NAME (name); + /* Make a USING_DECL. */ + decl = push_using_decl (scope, name); + if (!decl) + return; + + binding = binding_for_name (name, current_namespace); + decls = binding_init (&_decls); + if (!qualified_lookup_using_namespace (name, scope, decls)) + /* Lookup error */ return; - if (TREE_CODE (decl) == SCOPE_REF) - decl = resolve_scope_to_name (NULL_TREE, decl); + if (!BINDING_VALUE (decls) && !BINDING_TYPE (decls)) + { + cp_error ("`%D' not declared", name); + return; + } + newval = newtype = NULL_TREE; + + /* Check for using functions. */ + if (BINDING_VALUE (decls) && is_overloaded_fn (BINDING_VALUE (decls))) + { + tree oldval = BINDING_VALUE (binding); + tree tmp, tmp1; + newval = oldval; + for (tmp = BINDING_VALUE (decls); tmp; tmp = OVL_NEXT (tmp)) + { + + /* Compare each new function with each old one. + If the old function was also used, there is no conflict. */ + for (tmp1 = oldval; tmp1; tmp1 = OVL_NEXT (tmp1)) + if (OVL_CURRENT (tmp) == OVL_CURRENT (tmp1)) + break; + else if (OVL_USED (tmp1)) + continue; + else if (duplicate_decls (OVL_CURRENT (tmp), OVL_CURRENT (tmp1))) + return; - /* Is this the right way to do an id list? */ - if (TREE_CODE (decl) != TREE_LIST) + /* Duplicate use, ignore */ + if (tmp1) + continue; + + newval = build_overload (OVL_CURRENT (tmp), newval); + if (TREE_CODE (newval) != OVERLOAD) + newval = ovl_cons (newval, NULL_TREE); + OVL_USED (newval) = 1; + } + } + else { - pushdecl (decl); + tree oldval = BINDING_VALUE (binding); + newval = BINDING_VALUE (decls); + if (oldval && oldval != newval && !duplicate_decls (newval, oldval)) + newval = oldval; + } + + newtype = BINDING_TYPE (decls); + if (BINDING_TYPE (binding) && newtype && BINDING_TYPE (binding) != newtype) + { + cp_error ("using directive `%D' introduced ambiguous type `%T'", + name, BINDING_TYPE (decls)); + return; } - else - while (decl) - { - pushdecl (TREE_VALUE (decl)); - decl = TREE_CHAIN (decl); - } -#endif + /* Copy declarations found. */ + if (newval) + BINDING_VALUE (binding) = newval; + if (newtype) + BINDING_TYPE (binding) = newtype; + return; } tree @@ -3937,7 +4354,8 @@ do_class_using_decl (decl) { tree name, value; - if (TREE_CODE (decl) != SCOPE_REF) + if (TREE_CODE (decl) != SCOPE_REF + || TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (decl, 0))) != 't') { cp_error ("using-declaration for non-member at class scope"); return NULL_TREE; @@ -3954,15 +4372,33 @@ do_class_using_decl (decl) return value; } +/* Process a using-directive. */ + void do_using_directive (namespace) tree namespace; { if (namespace == std_node) return; + if (!toplevel_bindings_p ()) + { + sorry ("using directives inside functions"); + return; + } /* using A::B::C; */ if (TREE_CODE (namespace) == SCOPE_REF) namespace = TREE_OPERAND (namespace, 1); + if (TREE_CODE (namespace) == IDENTIFIER_NODE) + { + /* Lookup in lexer did not find a namespace. */ + cp_error ("namespace `%T' undeclared", namespace); + return; + } + if (TREE_CODE (namespace) != NAMESPACE_DECL) + { + cp_error ("`%T' is not a namespace", namespace); + return; + } /* direct usage */ add_using_namespace (current_namespace, namespace, 0); } diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 39f7dd9..cbb9927 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -341,7 +341,7 @@ dump_aggr_type (t, v, canonical_name) name = TYPE_NAME (canonical_name ? TYPE_MAIN_VARIANT (t) : t); - if (name && DECL_CONTEXT (name)) + if (name && DECL_CONTEXT (name) && DECL_CONTEXT (name) != global_namespace) { /* FUNCTION_DECL or RECORD_TYPE */ dump_decl (DECL_CONTEXT (name), 0); @@ -710,9 +710,9 @@ dump_decl (t, v) break; case NAMESPACE_DECL: - if (DECL_NAMESPACE (t) != global_namespace) + if (DECL_CONTEXT (t) != global_namespace) { - dump_decl (DECL_NAMESPACE (t), v); + dump_decl (DECL_CONTEXT (t), v); OB_PUTC2 (':',':'); } OB_PUTID (DECL_NAME (t)); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index d3e9c43..6a98a13 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -217,9 +217,13 @@ init_exception_processing () /* void vtype () */ tree vtype = build_function_type (void_type_node, void_list_node); + if (flag_honor_std) + push_namespace (get_identifier ("std")); Terminate = auto_function (get_identifier ("terminate"), vtype, NOT_BUILT_IN); TREE_THIS_VOLATILE (Terminate) = 1; + if (flag_honor_std) + pop_namespace (); push_lang_context (lang_name_c); diff --git a/gcc/cp/exception.cc b/gcc/cp/exception.cc index 8072e5c..d6709c5 100644 --- a/gcc/cp/exception.cc +++ b/gcc/cp/exception.cc @@ -34,10 +34,11 @@ /* Define terminate, unexpected, set_terminate, set_unexpected as well as the default terminate func and default unexpected func. */ -extern terminate_handler __terminate_func __attribute__((__noreturn__)); +extern std::terminate_handler __terminate_func __attribute__((__noreturn__)); +using std::terminate; void -terminate () +std::terminate () { __terminate_func (); } @@ -48,29 +49,29 @@ __default_unexpected () terminate (); } -static unexpected_handler __unexpected_func __attribute__((__noreturn__)) +static std::unexpected_handler __unexpected_func __attribute__((__noreturn__)) = __default_unexpected; -terminate_handler -set_terminate (terminate_handler func) +std::terminate_handler +std::set_terminate (std::terminate_handler func) { - terminate_handler old = __terminate_func; + std::terminate_handler old = __terminate_func; __terminate_func = func; return old; } -unexpected_handler -set_unexpected (unexpected_handler func) +std::unexpected_handler +std::set_unexpected (std::unexpected_handler func) { - unexpected_handler old = __unexpected_func; + std::unexpected_handler old = __unexpected_func; __unexpected_func = func; return old; } void -unexpected () +std::unexpected () { __unexpected_func (); } @@ -223,7 +224,7 @@ __check_eh_spec (int n, const void **spec) try { - unexpected (); + std::unexpected (); } catch (...) { @@ -238,11 +239,11 @@ __check_eh_spec (int n, const void **spec) } } - const type_info &bad_exc = typeid (bad_exception); + const std::type_info &bad_exc = typeid (std::bad_exception); for (int i = 0; i < n; ++i) { if (__throw_type_match_rtti (spec[i], &bad_exc, p->value)) - throw bad_exception (); + throw std::bad_exception (); } terminate (); @@ -252,25 +253,25 @@ __check_eh_spec (int n, const void **spec) extern "C" void __throw_bad_cast (void) { - throw bad_cast (); + throw std::bad_cast (); } extern "C" void __throw_bad_typeid (void) { - throw bad_typeid (); + throw std::bad_typeid (); } /* Has the current exception been caught? */ bool -uncaught_exception () +std::uncaught_exception () { cp_eh_info *p = __cp_exception_info (); return p && ! p->caught; } -const char * exception:: +const char * std::exception:: what () const { return typeid (*this).name (); diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 8538ba3..52a84a5 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -118,6 +118,10 @@ is_friend (type, supplicant) else context = NULL_TREE; + /* A namespace is not friend to anybody. */ + if (context && TREE_CODE (context) == NAMESPACE_DECL) + context = NULL_TREE; + if (context) return is_friend (type, context); diff --git a/gcc/cp/inc/exception b/gcc/cp/inc/exception index 1c4fda2..c684b7e 100644 --- a/gcc/cp/inc/exception +++ b/gcc/cp/inc/exception @@ -8,7 +8,7 @@ extern "C++" { -#if 0 +#ifdef __HONOR_STD namespace std { #endif @@ -34,7 +34,7 @@ unexpected_handler set_unexpected (unexpected_handler); void unexpected (void) __attribute__ ((__noreturn__)); bool uncaught_exception (); -#if 0 +#ifdef __HONOR_STD } // namespace std #endif diff --git a/gcc/cp/inc/new b/gcc/cp/inc/new index 23fe6eb..0f25a5c 100644 --- a/gcc/cp/inc/new +++ b/gcc/cp/inc/new @@ -10,7 +10,7 @@ extern "C++" { -#if 0 +#ifdef __HONOR_STD namespace std { #endif @@ -24,7 +24,7 @@ namespace std { typedef void (*new_handler)(); new_handler set_new_handler (new_handler); -#if 0 +#ifdef __HONOR_STD } // namespace std #endif @@ -33,10 +33,10 @@ void *operator new (size_t) throw (std::bad_alloc); void *operator new[] (size_t) throw (std::bad_alloc); void operator delete (void *) throw(); void operator delete[] (void *) throw(); -void *operator new (size_t, const nothrow_t&) throw(); -void *operator new[] (size_t, const nothrow_t&) throw(); -void operator delete (void *, const nothrow_t&) throw(); -void operator delete[] (void *, const nothrow_t&) throw(); +void *operator new (size_t, const std::nothrow_t&) throw(); +void *operator new[] (size_t, const std::nothrow_t&) throw(); +void operator delete (void *, const std::nothrow_t&) throw(); +void operator delete[] (void *, const std::nothrow_t&) throw(); // default placement versions of operator new inline void *operator new(size_t, void *place) throw() { return place; } diff --git a/gcc/cp/inc/new.h b/gcc/cp/inc/new.h index eed0910..799db7e 100644 --- a/gcc/cp/inc/new.h +++ b/gcc/cp/inc/new.h @@ -5,7 +5,7 @@ #include <new> -#if 0 +#ifdef __HONOR_STD using std::new_handler; using std::set_new_handler; #endif diff --git a/gcc/cp/inc/typeinfo b/gcc/cp/inc/typeinfo index 2652659..64b2a81 100644 --- a/gcc/cp/inc/typeinfo +++ b/gcc/cp/inc/typeinfo @@ -8,7 +8,7 @@ extern "C++" { -#if 0 +#ifdef __HONOR_STD namespace std { #endif @@ -63,7 +63,7 @@ class bad_typeid : public exception { virtual ~bad_typeid () { } }; -#if 0 +#ifdef __HONOR_STD } // namespace std #endif diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 13472c4..b92f79d 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1069,22 +1069,8 @@ expand_member_init (exp, name, init) if (fndecl) my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 209); - /* If the field is unique, we can use the parameter - types to guide possible type instantiation. */ - if (DECL_CHAIN (fndecl) == NULL_TREE) - { - /* There was a confusion here between - FIELD and FNDECL. The following code - should be correct, but abort is here - to make sure. */ - my_friendly_abort (48); - parmtypes = FUNCTION_ARG_CHAIN (fndecl); - } - else - { - parmtypes = NULL_TREE; - fndecl = NULL_TREE; - } + parmtypes = NULL_TREE; + fndecl = NULL_TREE; init = convert_arguments (parm, parmtypes, NULL_TREE, fndecl, LOOKUP_NORMAL); if (init == NULL_TREE || TREE_TYPE (init) != error_mark_node) @@ -1711,10 +1697,13 @@ build_offset_ref (type, name) /* Go from the TREE_BASELINK to the member function info. */ t = TREE_VALUE (fnfields); - if (DECL_CHAIN (t) == NULL_TREE) + if (!really_overloaded_fn (t)) { tree access; + /* Get rid of a potential OVERLOAD around it */ + t = OVL_CURRENT (t); + /* unique functions are handled easily. */ access = compute_access (basebinfo, t); if (access == access_protected_node) @@ -1742,7 +1731,7 @@ build_offset_ref (type, name) ??? The smart thing to do for the case of saving initializers is to resolve them before we're done with this scope. */ if (!TREE_PERMANENT (fnfields) - && ((flag_save_memoized_contexts && global_bindings_p ()) + && ((flag_save_memoized_contexts && toplevel_bindings_p ()) || ! allocation_temporary_p ())) fnfields = copy_list (fnfields); diff --git a/gcc/cp/lang-options.h b/gcc/cp/lang-options.h index f4f262d..ab575a4 100644 --- a/gcc/cp/lang-options.h +++ b/gcc/cp/lang-options.h @@ -56,6 +56,8 @@ Boston, MA 02111-1307, USA. */ "-fno-handle-exceptions", "-fhandle-signatures", "-fno-handle-signatures", + "-fhonor-std", + "-fno-honor-std", "-fhuge-objects", "-fno-huge-objects", "-fimplement-inlines", diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h index 55ff1fc..79b6f16 100644 --- a/gcc/cp/lang-specs.h +++ b/gcc/cp/lang-specs.h @@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. */ -undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus -D__GNUC_MINOR__=%v2\ %{ansi:-trigraphs -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\ %{!fno-exceptions:-D__EXCEPTIONS}\ + %{fhonor-std:-D__HONOR_STD} %{fnew-abi:-D__HONOR_STD}\ %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\ %i %{!M:%{!MM:%{!E:%{!pipe:%g.ii}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n", diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 97200fe..75358ae 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -332,7 +332,7 @@ get_time_identifier (name) end_temporary_allocation (); IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0); IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1); - IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times; + SET_IDENTIFIER_GLOBAL_VALUE (time_identifier, filename_times); filename_times = time_identifier; pop_obstacks (); } @@ -2740,8 +2740,8 @@ identifier_type (decl) if (looking_for_template && really_overloaded_fn (decl)) { tree t; - for (t = TREE_VALUE (decl); t != NULL_TREE; t = DECL_CHAIN (t)) - if (DECL_FUNCTION_TEMPLATE_P (t)) + for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t)) + if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t))) return PFUNCNAME; } if (TREE_CODE (decl) == NAMESPACE_DECL) @@ -2758,7 +2758,8 @@ identifier_type (decl) void see_typename () { - looking_for_typename = 1; + /* Only types expected, not even namespaces. */ + looking_for_typename = 2; if (yychar < 0) if ((yychar = yylex ()) < 0) yychar = 0; looking_for_typename = 0; @@ -2827,7 +2828,7 @@ do_identifier (token, parsing) refers to an overloaded method. Eventually this will not be necessary, since default arguments shouldn't be parsed until after the class is complete. (jason 3/12/97) */ - && TREE_CODE (id) != TREE_LIST) + && TREE_CODE (id) != OVERLOAD) pushdecl_class_level (id); if (!id || id == error_mark_node) @@ -2876,7 +2877,7 @@ do_identifier (token, parsing) } id = error_mark_node; /* Prevent repeated error messages. */ - IDENTIFIER_NAMESPACE_VALUE (token) = error_mark_node; + SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node); SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl); } } @@ -2966,7 +2967,14 @@ do_scoped_id (token, parsing) tree id; /* during parsing, this is ::name. Otherwise, it is black magic. */ if (parsing) - id = qualified_lookup_using_namespace (token, global_namespace); + { + struct tree_binding _b; + id = binding_init (&_b); + if (!qualified_lookup_using_namespace (token, global_namespace, id)) + id = NULL_TREE; + else + id = BINDING_VALUE (id); + } else id = IDENTIFIER_GLOBAL_VALUE (token); if (parsing && yychar == YYEMPTY) @@ -2988,14 +2996,14 @@ do_scoped_id (token, parsing) IDENTIFIER_POINTER (token)); id = error_mark_node; /* Prevent repeated error messages. */ - IDENTIFIER_NAMESPACE_VALUE (token) = error_mark_node; + SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node); } } else { if (TREE_CODE (id) == ADDR_EXPR) mark_used (TREE_OPERAND (id, 0)); - else if (TREE_CODE (id) != TREE_LIST) + else if (TREE_CODE (id) != OVERLOAD) mark_used (id); } if (TREE_CODE (id) == CONST_DECL && ! processing_template_decl) @@ -3232,7 +3240,7 @@ real_yylex () && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL) looking_for_typename = 0; else if (ptr->token == AGGR || ptr->token == ENUM) - looking_for_typename = 1; + looking_for_typename = 2; /* Check if this is a language-type declaration. Just glimpse the next non-white character. */ @@ -4375,8 +4383,6 @@ build_lang_decl (code, name, type) DECL_LANGUAGE (t) = lang_java; else my_friendly_abort (64); - SET_DECL_NAMESPACE (t, current_namespace); - #if 0 /* not yet, should get fixed properly later */ if (code == TYPE_DECL) { @@ -4508,7 +4514,7 @@ dump_time_statistics () for (decl = filename_times; decl; decl = next) { next = IDENTIFIER_GLOBAL_VALUE (decl); - IDENTIFIER_GLOBAL_VALUE (decl) = prev; + SET_IDENTIFIER_GLOBAL_VALUE (decl, prev); prev = decl; } diff --git a/gcc/cp/method.c b/gcc/cp/method.c index e97c626..9d8b8f0 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -187,6 +187,7 @@ static int nrepeats = 0; /* Array of types seen so far in top-level call to `build_mangled_name'. Allocated and deallocated by caller. */ static tree *typevec = NULL; +static int typevec_size; /* Number of types interned by `build_mangled_name' so far. */ static int maxtype = 0; @@ -418,6 +419,9 @@ build_overload_nested_name (decl) if (ktypelist && issue_ktype (decl)) return; + if (decl == global_namespace) + return; + if (DECL_CONTEXT (decl)) { tree context = DECL_CONTEXT (decl); @@ -438,14 +442,8 @@ build_overload_nested_name (decl) } } } - else if (decl == global_namespace) - return; - else if (DECL_NAMESPACE (decl)) - build_overload_nested_name (DECL_NAMESPACE (decl)); - else - /* XXX the above does not work for non-namespaces */ - if (current_namespace && TREE_CODE (decl) != NAMESPACE_DECL) - build_overload_nested_name (current_namespace); + else + my_friendly_abort (392); if (TREE_CODE (decl) == FUNCTION_DECL) { @@ -946,8 +944,8 @@ build_qualified_name (decl) /* if we can't find a Ktype, do it the hard way */ if (check_ktype (context, FALSE) == -1) { - /* count type scopes */ - while (DECL_CONTEXT (context)) + /* count type and namespace scopes */ + while (DECL_CONTEXT (context) && DECL_CONTEXT (context) != global_namespace) { i += 1; context = DECL_CONTEXT (context); @@ -956,25 +954,6 @@ build_qualified_name (decl) if (TREE_CODE_CLASS (TREE_CODE (context)) == 't') context = TYPE_NAME (context); } - /* now count namespace scopes */ - if (TREE_CODE (decl) == NAMESPACE_DECL) - { - i = 0; /* we have nothing done, yet: reset */ - context = decl; - } - else - /* decl must be a type, which we have to scope with the - namespace */ - { - /* XXX MvL somehow, types have no lang_decl, so no namespace */ - context = current_namespace; - } - } - - while (context != global_namespace) - { - i += 1; - context = DECL_NAMESPACE (context); } if (i > 1) @@ -1052,6 +1031,7 @@ build_mangled_name (parmtypes, begin, end) if (!nofold && typevec) { /* Every argument gets counted. */ + my_friendly_assert (maxtype < typevec_size, 387); typevec[maxtype++] = parmtype; if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2] @@ -1588,7 +1568,11 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs, { maxtype = 0; Nrepeats = 0; - typevec = (tree *)alloca (list_length (parms) * sizeof (tree)); + typevec_size = list_length (parms); + if (!for_method && current_namespace != global_namespace) + /* the namespace of a global function needs one slot */ + typevec_size++; + typevec = (tree *)alloca (typevec_size * sizeof (tree)); } nofold = 0; if (for_method) @@ -1596,6 +1580,7 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs, build_mangled_name (TREE_VALUE (parms), 0, 0); if (!flag_do_squangling) { + my_friendly_assert (maxtype < typevec_size, 387); typevec[maxtype++] = TREE_VALUE (parms); TREE_USED (TREE_VALUE (parms)) = 1; } @@ -1611,7 +1596,10 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs, will count as type */ if (current_namespace != global_namespace && !flag_do_squangling) - typevec[maxtype++] = current_namespace; + { + my_friendly_assert (maxtype < typevec_size, 387); + typevec[maxtype++] = current_namespace; + } build_mangled_name (parms, 0, 0); } @@ -1805,6 +1793,9 @@ hack_identifier (value, name) fndecl = TREE_VALUE (fields); my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 251); + /* I could not trigger this code. MvL */ + my_friendly_abort (980325); +#ifdef DEAD if (DECL_CHAIN (fndecl) == NULL_TREE) { warning ("methods cannot be converted to function pointers"); @@ -1816,6 +1807,7 @@ hack_identifier (value, name) IDENTIFIER_POINTER (name)); return error_mark_node; } +#endif } } if (flag_labels_ok && IDENTIFIER_LABEL_VALUE (name)) @@ -1856,6 +1848,9 @@ hack_identifier (value, name) } #endif } + else if (TREE_CODE (value) == OVERLOAD) + /* not really overloaded function */ + mark_used (OVL_FUNCTION (value)); else if (TREE_CODE (value) == TREE_LIST) { /* Ambiguous reference to base members, possibly other cases?. */ @@ -1866,6 +1861,9 @@ hack_identifier (value, name) t = TREE_CHAIN (t); } } + else if (TREE_CODE (value) == NAMESPACE_DECL) + /* A namespace is not really expected here; this is likely illegal code. */ + return value; else mark_used (value); @@ -1957,7 +1955,8 @@ make_thunk (function, delta) if (thunk && TREE_CODE (thunk) != THUNK_DECL) { cp_error ("implementation-reserved name `%D' used", thunk_id); - IDENTIFIER_GLOBAL_VALUE (thunk_id) = thunk = NULL_TREE; + thunk = NULL_TREE; + SET_IDENTIFIER_GLOBAL_VALUE (thunk_id, thunk); } if (thunk == NULL_TREE) { diff --git a/gcc/cp/new.cc b/gcc/cp/new.cc index 33cf190..28187a4 100644 --- a/gcc/cp/new.cc +++ b/gcc/cp/new.cc @@ -28,8 +28,9 @@ #pragma implementation "new" #include "new" -const nothrow_t nothrow = { }; +const std::nothrow_t std::nothrow = { }; +using std::new_handler; new_handler __new_handler; new_handler diff --git a/gcc/cp/new1.cc b/gcc/cp/new1.cc index 98c2a4a..5bb85c9 100644 --- a/gcc/cp/new1.cc +++ b/gcc/cp/new1.cc @@ -26,6 +26,8 @@ // the executable file might be covered by the GNU General Public License. #include "new" +using std::new_handler; +using std::bad_alloc; extern "C" void *malloc (size_t); extern new_handler __new_handler; @@ -35,7 +37,7 @@ extern new_handler __new_handler; x #ifdef L_op_newnt -WEAK (void * operator new (size_t sz, const nothrow_t&) throw()) +WEAK (void * operator new (size_t sz, const std::nothrow_t&) throw()) { void *p; diff --git a/gcc/cp/new2.cc b/gcc/cp/new2.cc index d5320f9..0be1c0d 100644 --- a/gcc/cp/new2.cc +++ b/gcc/cp/new2.cc @@ -41,7 +41,7 @@ WEAK(void * operator new[] (size_t sz) throw (std::bad_alloc)) #endif #ifdef L_op_vnewnt -WEAK(void *operator new[] (size_t sz, const nothrow_t& nothrow) throw()) +WEAK(void *operator new[] (size_t sz, const std::nothrow_t& nothrow) throw()) { return ::operator new(sz, nothrow); } diff --git a/gcc/cp/parse.c b/gcc/cp/parse.c index dd68890..6c466b4 100644 --- a/gcc/cp/parse.c +++ b/gcc/cp/parse.c @@ -624,91 +624,91 @@ static const short yyrhs[] = { -1, #if YYDEBUG != 0 static const short yyrline[] = { 0, - 328, 330, 344, 347, 348, 352, 354, 357, 362, 366, - 372, 374, 377, 380, 384, 387, 389, 391, 394, 396, - 399, 402, 404, 406, 408, 410, 412, 414, 420, 424, - 427, 429, 433, 435, 436, 438, 442, 445, 451, 454, - 456, 461, 464, 468, 471, 474, 477, 481, 486, 496, - 498, 500, 502, 504, 517, 526, 536, 538, 540, 544, - 546, 547, 554, 555, 556, 559, 562, 566, 568, 569, - 572, 574, 577, 580, 582, 586, 589, 591, 595, 597, - 599, 603, 605, 607, 611, 613, 615, 621, 625, 628, - 631, 634, 639, 642, 644, 646, 652, 662, 664, 667, - 670, 672, 675, 679, 688, 691, 693, 697, 710, 730, - 733, 735, 736, 739, 746, 752, 754, 756, 758, 760, - 763, 768, 770, 771, 772, 773, 776, 778, 779, 782, - 784, 785, 788, 793, 793, 797, 797, 800, 800, 803, - 803, 807, 807, 812, 812, 815, 815, 818, 820, 823, - 830, 837, 843, 846, 855, 857, 865, 868, 871, 874, - 878, 881, 884, 887, 889, 891, 893, 897, 900, 903, - 908, 912, 917, 921, 924, 926, 930, 949, 956, 959, - 961, 962, 963, 966, 970, 971, 975, 979, 982, 984, - 988, 991, 994, 998, 1001, 1003, 1005, 1007, 1014, 1018, - 1020, 1022, 1024, 1030, 1033, 1036, 1039, 1042, 1046, 1049, - 1052, 1056, 1058, 1062, 1066, 1068, 1072, 1075, 1082, 1085, - 1087, 1095, 1108, 1114, 1121, 1123, 1125, 1138, 1141, 1143, - 1145, 1147, 1149, 1151, 1153, 1155, 1157, 1159, 1161, 1163, - 1165, 1167, 1169, 1171, 1173, 1175, 1177, 1179, 1181, 1185, - 1187, 1189, 1206, 1209, 1210, 1211, 1212, 1213, 1216, 1219, - 1222, 1226, 1229, 1231, 1236, 1238, 1239, 1242, 1244, 1246, - 1248, 1252, 1255, 1259, 1261, 1262, 1263, 1267, 1275, 1276, - 1277, 1285, 1287, 1290, 1292, 1302, 1304, 1306, 1308, 1310, - 1312, 1315, 1317, 1361, 1362, 1366, 1370, 1374, 1378, 1380, - 1384, 1386, 1394, 1396, 1398, 1400, 1404, 1406, 1408, 1410, - 1415, 1417, 1419, 1421, 1424, 1426, 1428, 1472, 1475, 1479, - 1482, 1486, 1489, 1494, 1496, 1500, 1513, 1516, 1523, 1530, - 1535, 1537, 1542, 1544, 1551, 1553, 1557, 1561, 1567, 1571, - 1574, 1577, 1580, 1590, 1592, 1595, 1599, 1602, 1605, 1608, - 1611, 1617, 1623, 1625, 1630, 1632, 1641, 1644, 1646, 1649, - 1655, 1657, 1667, 1671, 1674, 1677, 1682, 1685, 1693, 1695, - 1697, 1699, 1702, 1705, 1720, 1739, 1742, 1744, 1747, 1749, - 1752, 1754, 1757, 1759, 1762, 1765, 1769, 1775, 1776, 1788, - 1795, 1798, 1804, 1808, 1813, 1819, 1820, 1828, 1831, 1835, - 1838, 1842, 1847, 1850, 1854, 1857, 1859, 1861, 1863, 1870, - 1872, 1873, 1874, 1878, 1881, 1885, 1888, 1894, 1896, 1899, - 1902, 1905, 1911, 1914, 1917, 1919, 1921, 1925, 1931, 1939, - 1941, 1945, 1947, 1952, 1955, 1958, 1960, 1962, 1966, 1970, - 1975, 1979, 1982, 1987, 1991, 1994, 1997, 2001, 2036, 2042, - 2051, 2071, 2073, 2076, 2078, 2083, 2085, 2087, 2089, 2091, - 2095, 2100, 2105, 2111, 2116, 2121, 2123, 2127, 2132, 2135, - 2142, 2170, 2176, 2178, 2181, 2184, 2186, 2190, 2192, 2196, - 2222, 2251, 2254, 2255, 2276, 2299, 2301, 2305, 2316, 2330, - 2419, 2426, 2429, 2437, 2448, 2457, 2461, 2476, 2479, 2484, - 2486, 2488, 2490, 2492, 2494, 2497, 2499, 2511, 2517, 2519, - 2522, 2525, 2527, 2538, 2543, 2546, 2551, 2554, 2555, 2566, - 2569, 2570, 2581, 2583, 2586, 2588, 2591, 2598, 2606, 2613, - 2619, 2625, 2633, 2637, 2642, 2646, 2649, 2658, 2660, 2664, - 2667, 2672, 2676, 2681, 2691, 2694, 2698, 2702, 2710, 2715, - 2721, 2724, 2726, 2728, 2734, 2737, 2739, 2741, 2743, 2747, - 2750, 2768, 2778, 2780, 2781, 2785, 2790, 2793, 2795, 2797, - 2799, 2803, 2809, 2812, 2814, 2816, 2818, 2822, 2825, 2828, - 2830, 2832, 2834, 2838, 2841, 2844, 2846, 2848, 2850, 2857, - 2868, 2872, 2877, 2881, 2886, 2888, 2892, 2895, 2897, 2901, - 2903, 2904, 2907, 2909, 2911, 2917, 2932, 2938, 2944, 2958, - 2960, 2964, 2978, 2980, 2982, 2986, 2992, 3005, 3007, 3011, - 3022, 3028, 3030, 3031, 3032, 3040, 3045, 3054, 3055, 3059, - 3062, 3068, 3074, 3077, 3079, 3081, 3083, 3087, 3091, 3095, - 3098, 3103, 3106, 3108, 3110, 3112, 3114, 3116, 3118, 3120, - 3124, 3128, 3132, 3136, 3137, 3139, 3141, 3143, 3145, 3147, - 3149, 3151, 3153, 3161, 3163, 3164, 3165, 3168, 3174, 3176, - 3181, 3183, 3186, 3200, 3203, 3206, 3210, 3213, 3220, 3222, - 3225, 3227, 3229, 3232, 3235, 3238, 3241, 3243, 3246, 3250, - 3252, 3258, 3260, 3261, 3263, 3268, 3270, 3272, 3274, 3276, - 3279, 3280, 3282, 3285, 3286, 3289, 3289, 3292, 3292, 3295, - 3295, 3297, 3299, 3301, 3303, 3309, 3315, 3318, 3321, 3327, - 3329, 3331, 3335, 3337, 3340, 3347, 3350, 3358, 3362, 3364, - 3367, 3369, 3372, 3376, 3378, 3381, 3383, 3386, 3403, 3409, - 3417, 3419, 3421, 3425, 3428, 3429, 3437, 3441, 3445, 3448, - 3449, 3455, 3458, 3461, 3463, 3467, 3472, 3475, 3485, 3490, - 3491, 3499, 3505, 3510, 3514, 3519, 3523, 3527, 3531, 3536, - 3547, 3561, 3565, 3568, 3570, 3574, 3578, 3581, 3584, 3586, - 3590, 3592, 3599, 3606, 3609, 3612, 3616, 3620, 3626, 3630, - 3635, 3637, 3640, 3645, 3651, 3662, 3665, 3667, 3671, 3676, - 3678, 3685, 3688, 3690, 3692, 3698, 3703, 3706, 3708, 3710, - 3712, 3714, 3716, 3718, 3720, 3722, 3724, 3726, 3728, 3730, - 3732, 3734, 3736, 3738, 3740, 3742, 3744, 3746, 3748, 3750, - 3752, 3754, 3756, 3758, 3760, 3762, 3764, 3766, 3768, 3771, - 3773 + 328, 330, 346, 349, 350, 354, 356, 359, 364, 368, + 374, 376, 379, 382, 386, 389, 391, 393, 396, 398, + 401, 404, 406, 408, 410, 412, 414, 416, 425, 429, + 432, 434, 438, 440, 441, 443, 447, 450, 456, 459, + 461, 466, 469, 473, 476, 479, 482, 486, 491, 501, + 503, 505, 507, 509, 522, 531, 541, 543, 545, 549, + 551, 552, 559, 560, 561, 564, 567, 571, 573, 574, + 577, 579, 582, 585, 587, 591, 594, 596, 600, 602, + 604, 608, 610, 612, 616, 618, 620, 626, 630, 633, + 636, 639, 644, 647, 649, 651, 657, 667, 669, 672, + 675, 677, 680, 684, 693, 696, 698, 702, 715, 735, + 738, 740, 741, 744, 751, 757, 759, 761, 763, 765, + 768, 773, 775, 776, 777, 778, 781, 783, 784, 787, + 789, 790, 793, 798, 798, 802, 802, 805, 805, 808, + 808, 812, 812, 817, 817, 820, 820, 823, 825, 828, + 835, 842, 848, 851, 860, 862, 870, 873, 876, 879, + 883, 886, 889, 892, 894, 896, 898, 902, 905, 908, + 913, 917, 922, 926, 929, 931, 935, 954, 961, 964, + 966, 967, 968, 971, 975, 976, 980, 984, 987, 989, + 993, 996, 999, 1003, 1006, 1008, 1010, 1012, 1019, 1023, + 1025, 1027, 1029, 1035, 1038, 1041, 1044, 1047, 1051, 1054, + 1057, 1061, 1063, 1067, 1071, 1073, 1077, 1080, 1087, 1090, + 1092, 1100, 1113, 1119, 1126, 1128, 1130, 1143, 1146, 1148, + 1150, 1152, 1154, 1156, 1158, 1160, 1162, 1164, 1166, 1168, + 1170, 1172, 1174, 1176, 1178, 1180, 1182, 1184, 1186, 1190, + 1192, 1194, 1211, 1214, 1215, 1216, 1217, 1218, 1221, 1224, + 1227, 1231, 1234, 1236, 1241, 1243, 1244, 1247, 1249, 1251, + 1253, 1257, 1260, 1264, 1266, 1267, 1268, 1272, 1280, 1281, + 1282, 1290, 1292, 1295, 1297, 1307, 1309, 1311, 1313, 1315, + 1317, 1320, 1322, 1366, 1367, 1371, 1375, 1379, 1383, 1385, + 1389, 1391, 1399, 1401, 1403, 1405, 1409, 1411, 1413, 1415, + 1420, 1422, 1424, 1426, 1429, 1431, 1433, 1477, 1480, 1484, + 1487, 1491, 1494, 1499, 1501, 1505, 1518, 1521, 1528, 1535, + 1540, 1542, 1547, 1549, 1556, 1558, 1562, 1566, 1572, 1576, + 1579, 1582, 1585, 1595, 1597, 1600, 1604, 1607, 1610, 1613, + 1616, 1622, 1628, 1630, 1635, 1637, 1646, 1649, 1651, 1654, + 1660, 1662, 1672, 1676, 1679, 1682, 1687, 1690, 1698, 1700, + 1702, 1704, 1707, 1710, 1725, 1744, 1747, 1749, 1752, 1754, + 1757, 1759, 1762, 1764, 1767, 1770, 1774, 1780, 1781, 1793, + 1800, 1803, 1809, 1813, 1818, 1824, 1825, 1833, 1836, 1840, + 1843, 1847, 1852, 1855, 1859, 1862, 1864, 1866, 1868, 1875, + 1877, 1878, 1879, 1883, 1886, 1890, 1893, 1899, 1901, 1904, + 1907, 1910, 1916, 1919, 1922, 1924, 1926, 1930, 1936, 1944, + 1946, 1950, 1952, 1957, 1960, 1963, 1965, 1967, 1971, 1975, + 1980, 1984, 1987, 1992, 1996, 1999, 2002, 2006, 2041, 2047, + 2056, 2076, 2078, 2081, 2083, 2088, 2090, 2092, 2094, 2096, + 2100, 2105, 2110, 2116, 2121, 2126, 2128, 2132, 2137, 2140, + 2147, 2175, 2181, 2183, 2186, 2189, 2191, 2195, 2197, 2201, + 2227, 2256, 2259, 2260, 2281, 2304, 2306, 2310, 2321, 2335, + 2425, 2432, 2435, 2443, 2454, 2463, 2467, 2482, 2485, 2490, + 2492, 2494, 2496, 2498, 2500, 2503, 2505, 2517, 2523, 2525, + 2528, 2531, 2533, 2544, 2549, 2552, 2557, 2560, 2561, 2572, + 2575, 2576, 2587, 2589, 2592, 2594, 2597, 2604, 2612, 2619, + 2625, 2631, 2639, 2643, 2648, 2652, 2655, 2664, 2666, 2670, + 2673, 2678, 2682, 2687, 2697, 2700, 2704, 2708, 2716, 2721, + 2727, 2730, 2732, 2734, 2740, 2743, 2745, 2747, 2749, 2753, + 2756, 2774, 2784, 2786, 2787, 2791, 2796, 2799, 2801, 2803, + 2805, 2809, 2815, 2818, 2820, 2822, 2824, 2828, 2831, 2834, + 2836, 2838, 2840, 2844, 2847, 2850, 2852, 2854, 2856, 2863, + 2874, 2878, 2883, 2887, 2892, 2894, 2898, 2901, 2903, 2907, + 2909, 2910, 2913, 2915, 2917, 2923, 2938, 2944, 2950, 2964, + 2966, 2970, 2984, 2986, 2988, 2992, 2998, 3011, 3013, 3017, + 3030, 3036, 3038, 3039, 3040, 3048, 3053, 3062, 3063, 3067, + 3070, 3076, 3082, 3085, 3087, 3089, 3091, 3095, 3099, 3103, + 3106, 3111, 3114, 3116, 3118, 3120, 3122, 3124, 3126, 3128, + 3132, 3136, 3140, 3144, 3145, 3147, 3149, 3151, 3153, 3155, + 3157, 3159, 3161, 3169, 3171, 3172, 3173, 3176, 3182, 3184, + 3189, 3191, 3194, 3208, 3211, 3214, 3218, 3221, 3228, 3230, + 3233, 3235, 3237, 3240, 3243, 3246, 3249, 3251, 3254, 3258, + 3260, 3266, 3268, 3269, 3271, 3276, 3278, 3280, 3282, 3284, + 3287, 3288, 3290, 3293, 3294, 3297, 3297, 3300, 3300, 3303, + 3303, 3305, 3307, 3309, 3311, 3317, 3323, 3326, 3329, 3335, + 3337, 3339, 3343, 3345, 3348, 3355, 3358, 3366, 3370, 3372, + 3375, 3377, 3380, 3384, 3386, 3389, 3391, 3394, 3411, 3417, + 3425, 3427, 3429, 3433, 3436, 3437, 3445, 3449, 3453, 3456, + 3457, 3463, 3466, 3469, 3471, 3475, 3480, 3483, 3493, 3498, + 3499, 3507, 3513, 3518, 3522, 3527, 3531, 3535, 3539, 3544, + 3555, 3569, 3573, 3576, 3578, 3582, 3586, 3589, 3592, 3594, + 3598, 3600, 3607, 3614, 3617, 3620, 3624, 3628, 3634, 3638, + 3643, 3645, 3648, 3653, 3659, 3670, 3673, 3675, 3679, 3684, + 3686, 3693, 3696, 3698, 3700, 3706, 3711, 3714, 3716, 3718, + 3720, 3722, 3724, 3726, 3728, 3730, 3732, 3734, 3736, 3738, + 3740, 3742, 3744, 3746, 3748, 3750, 3752, 3754, 3756, 3758, + 3760, 3762, 3764, 3766, 3768, 3770, 3772, 3774, 3776, 3779, + 3781 }; #endif @@ -3993,207 +3993,212 @@ case 2: { /* In case there were missing closebraces, get us back to the global binding level. */ - while (! global_bindings_p ()) + while (! toplevel_bindings_p ()) poplevel (0, 0, 0); + while (current_namespace != global_namespace) + pop_namespace (); finish_file (); ; break;} case 3: -#line 345 "parse.y" +#line 347 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 4: -#line 347 "parse.y" +#line 349 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 5: -#line 349 "parse.y" +#line 351 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 8: -#line 358 "parse.y" +#line 360 "parse.y" { have_extern_spec = 1; used_extern_spec = 0; yyval.ttype = NULL_TREE; ; break;} case 9: -#line 363 "parse.y" +#line 365 "parse.y" { have_extern_spec = 0; ; break;} case 10: -#line 368 "parse.y" +#line 370 "parse.y" { yyval.itype = pedantic; pedantic = 0; ; break;} case 13: -#line 378 "parse.y" +#line 380 "parse.y" { if (pending_lang_change) do_pending_lang_change(); ; break;} case 14: -#line 380 "parse.y" +#line 382 "parse.y" { if (! toplevel_bindings_p () && ! pseudo_global_level_p()) pop_everything (); ; break;} case 15: -#line 386 "parse.y" +#line 388 "parse.y" { if (pending_inlines) do_pending_inlines (); ; break;} case 16: -#line 388 "parse.y" +#line 390 "parse.y" { if (pending_inlines) do_pending_inlines (); ; break;} case 17: -#line 390 "parse.y" +#line 392 "parse.y" { if (pending_inlines) do_pending_inlines (); ; break;} case 18: -#line 392 "parse.y" +#line 394 "parse.y" { if (TREE_CHAIN (yyvsp[-2].ttype)) yyvsp[-2].ttype = combine_strings (yyvsp[-2].ttype); assemble_asm (yyvsp[-2].ttype); ; break;} case 19: -#line 395 "parse.y" +#line 397 "parse.y" { pop_lang_context (); ; break;} case 20: -#line 397 "parse.y" +#line 399 "parse.y" { if (pending_inlines) do_pending_inlines (); pop_lang_context (); ; break;} case 21: -#line 400 "parse.y" +#line 402 "parse.y" { if (pending_inlines) do_pending_inlines (); pop_lang_context (); ; break;} case 22: -#line 403 "parse.y" +#line 405 "parse.y" { push_namespace (yyvsp[-1].ttype); ; break;} case 23: -#line 405 "parse.y" +#line 407 "parse.y" { pop_namespace (); ; break;} case 24: -#line 407 "parse.y" +#line 409 "parse.y" { push_namespace (NULL_TREE); ; break;} case 25: -#line 409 "parse.y" +#line 411 "parse.y" { pop_namespace (); ; break;} case 26: -#line 411 "parse.y" +#line 413 "parse.y" { do_namespace_alias (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 27: -#line 413 "parse.y" +#line 415 "parse.y" { do_toplevel_using_decl (yyvsp[-1].ttype); ; break;} case 28: -#line 415 "parse.y" +#line 417 "parse.y" { - if (TREE_CODE (yyvsp[-1].ttype) == IDENTIFIER_NODE) + /* If no declaration was found, the using-directive is + invalid. Since that was not reported, we need the + identifier for the error message. */ + if (TREE_CODE (yyvsp[-1].ttype) == IDENTIFIER_NODE && lastiddecl) yyvsp[-1].ttype = lastiddecl; do_using_directive (yyvsp[-1].ttype); ; break;} case 29: -#line 421 "parse.y" +#line 426 "parse.y" { pedantic = yyvsp[-1].itype; ; break;} case 30: -#line 426 "parse.y" +#line 431 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 31: -#line 428 "parse.y" +#line 433 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 32: -#line 430 "parse.y" +#line 435 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 35: -#line 437 "parse.y" +#line 442 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 36: -#line 439 "parse.y" +#line 444 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 37: -#line 444 "parse.y" +#line 449 "parse.y" { push_lang_context (yyvsp[0].ttype); ; break;} case 38: -#line 446 "parse.y" +#line 451 "parse.y" { if (current_lang_name != yyvsp[0].ttype) cp_error ("use of linkage spec `%D' is different from previous spec `%D'", yyvsp[0].ttype, current_lang_name); pop_lang_context (); push_lang_context (yyvsp[0].ttype); ; break;} case 39: -#line 453 "parse.y" +#line 458 "parse.y" { begin_template_parm_list (); ; break;} case 40: -#line 455 "parse.y" +#line 460 "parse.y" { yyval.ttype = end_template_parm_list (yyvsp[-1].ttype); ; break;} case 41: -#line 457 "parse.y" +#line 462 "parse.y" { begin_specialization(); yyval.ttype = NULL_TREE; ; break;} case 42: -#line 463 "parse.y" +#line 468 "parse.y" { yyval.ttype = process_template_parm (NULL_TREE, yyvsp[0].ttype); ; break;} case 43: -#line 465 "parse.y" +#line 470 "parse.y" { yyval.ttype = process_template_parm (yyvsp[-2].ttype, yyvsp[0].ttype); ; break;} case 44: -#line 470 "parse.y" +#line 475 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 45: -#line 472 "parse.y" +#line 477 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 46: -#line 476 "parse.y" +#line 481 "parse.y" { yyval.ttype = finish_template_type_parm (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 47: -#line 478 "parse.y" +#line 483 "parse.y" { yyval.ttype = finish_template_type_parm (class_type_node, yyvsp[0].ttype); ; break;} case 48: -#line 483 "parse.y" +#line 488 "parse.y" { yyval.ttype = finish_template_template_parm (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 49: -#line 495 "parse.y" +#line 500 "parse.y" { yyval.ttype = build_tree_list (NULL_TREE, yyvsp[0].ttype); ; break;} case 50: -#line 497 "parse.y" +#line 502 "parse.y" { yyval.ttype = build_tree_list (groktypename (yyvsp[0].ftype.t), yyvsp[-2].ttype); ; break;} case 51: -#line 499 "parse.y" +#line 504 "parse.y" { yyval.ttype = build_tree_list (NULL_TREE, yyvsp[0].ftype.t); ; break;} case 52: -#line 501 "parse.y" +#line 506 "parse.y" { yyval.ttype = build_tree_list (yyvsp[0].ttype, yyvsp[-2].ftype.t); ; break;} case 53: -#line 503 "parse.y" +#line 508 "parse.y" { yyval.ttype = build_tree_list (NULL_TREE, yyvsp[0].ttype); ; break;} case 54: -#line 505 "parse.y" +#line 510 "parse.y" { if (TREE_CODE (yyvsp[0].ttype) != TEMPLATE_DECL && TREE_CODE (yyvsp[0].ttype) != TEMPLATE_TEMPLATE_PARM @@ -4206,7 +4211,7 @@ case 54: ; break;} case 55: -#line 520 "parse.y" +#line 525 "parse.y" { if (yyvsp[-1].ttype) end_template_decl (); @@ -4215,7 +4220,7 @@ case 55: ; break;} case 56: -#line 528 "parse.y" +#line 533 "parse.y" { if (yyvsp[-1].ttype) end_template_decl (); @@ -4224,21 +4229,21 @@ case 56: ; break;} case 58: -#line 539 "parse.y" +#line 544 "parse.y" {; break;} case 59: -#line 541 "parse.y" +#line 546 "parse.y" { note_list_got_semicolon (yyvsp[-2].ftype.t); ; break;} case 60: -#line 545 "parse.y" +#line 550 "parse.y" { pedwarn ("empty declaration"); ; break;} case 62: -#line 548 "parse.y" +#line 553 "parse.y" { tree t, attrs; split_specs_attrs (yyvsp[-1].ftype.t, &t, &attrs); @@ -4247,124 +4252,124 @@ case 62: ; break;} case 66: -#line 561 "parse.y" +#line 566 "parse.y" { yyval.itype = 0; ; break;} case 67: -#line 563 "parse.y" +#line 568 "parse.y" { yyval.itype = 1; ; break;} case 73: -#line 579 "parse.y" +#line 584 "parse.y" { finish_function (lineno, (int)yyvsp[-1].itype, 0); ; break;} case 74: -#line 581 "parse.y" +#line 586 "parse.y" { ; break;} case 75: -#line 583 "parse.y" +#line 588 "parse.y" { ; break;} case 76: -#line 588 "parse.y" +#line 593 "parse.y" { yyval.ttype = begin_constructor_declarator (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 77: -#line 590 "parse.y" +#line 595 "parse.y" { yyval.ttype = make_call_declarator (yyvsp[-4].ttype, yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 78: -#line 592 "parse.y" +#line 597 "parse.y" { yyval.ttype = begin_constructor_declarator (yyvsp[-4].ttype, yyvsp[-3].ttype); yyval.ttype = make_call_declarator (yyval.ttype, empty_parms (), yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 79: -#line 596 "parse.y" +#line 601 "parse.y" { yyval.ttype = begin_constructor_declarator (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 80: -#line 598 "parse.y" +#line 603 "parse.y" { yyval.ttype = make_call_declarator (yyvsp[-4].ttype, yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 81: -#line 600 "parse.y" +#line 605 "parse.y" { yyval.ttype = begin_constructor_declarator (yyvsp[-4].ttype, yyvsp[-3].ttype); yyval.ttype = make_call_declarator (yyval.ttype, empty_parms (), yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 82: -#line 604 "parse.y" +#line 609 "parse.y" { yyval.ttype = begin_constructor_declarator (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 83: -#line 606 "parse.y" +#line 611 "parse.y" { yyval.ttype = make_call_declarator (yyvsp[-4].ttype, yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 84: -#line 608 "parse.y" +#line 613 "parse.y" { yyval.ttype = begin_constructor_declarator (yyvsp[-4].ttype, yyvsp[-3].ttype); yyval.ttype = make_call_declarator (yyval.ttype, empty_parms (), yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 85: -#line 612 "parse.y" +#line 617 "parse.y" { yyval.ttype = begin_constructor_declarator (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 86: -#line 614 "parse.y" +#line 619 "parse.y" { yyval.ttype = make_call_declarator (yyvsp[-4].ttype, yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 87: -#line 616 "parse.y" +#line 621 "parse.y" { yyval.ttype = begin_constructor_declarator (yyvsp[-4].ttype, yyvsp[-3].ttype); yyval.ttype = make_call_declarator (yyval.ttype, empty_parms (), yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 88: -#line 623 "parse.y" +#line 628 "parse.y" { if (!begin_function_definition (yyvsp[-1].ftype.t, yyvsp[0].ttype)) YYERROR1; ; break;} case 89: -#line 626 "parse.y" +#line 631 "parse.y" { if (!begin_function_definition (yyvsp[-1].ttype, yyvsp[0].ttype)) YYERROR1; ; break;} case 90: -#line 629 "parse.y" +#line 634 "parse.y" { if (!begin_function_definition (NULL_TREE, yyvsp[0].ttype)) YYERROR1; ; break;} case 91: -#line 632 "parse.y" +#line 637 "parse.y" { if (!begin_function_definition (yyvsp[-1].ttype, yyvsp[0].ttype)) YYERROR1; ; break;} case 92: -#line 635 "parse.y" +#line 640 "parse.y" { if (!begin_function_definition (NULL_TREE, yyvsp[0].ttype)) YYERROR1; ; break;} case 93: -#line 641 "parse.y" +#line 646 "parse.y" { yyval.ttype = make_call_declarator (yyvsp[-5].ttype, yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 94: -#line 643 "parse.y" +#line 648 "parse.y" { yyval.ttype = make_call_declarator (yyvsp[-3].ttype, empty_parms (), yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 95: -#line 645 "parse.y" +#line 650 "parse.y" { yyval.ttype = make_call_declarator (yyvsp[-5].ttype, yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 96: -#line 647 "parse.y" +#line 652 "parse.y" { yyval.ttype = make_call_declarator (yyvsp[-3].ttype, empty_parms (), yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 97: -#line 654 "parse.y" +#line 659 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ttype); yyval.ttype = start_method (specs, yyvsp[0].ttype); rest_of_mdef: @@ -4375,34 +4380,34 @@ case 97: reinit_parse_for_method (yychar, yyval.ttype); ; break;} case 98: -#line 663 "parse.y" +#line 668 "parse.y" { yyval.ttype = start_method (NULL_TREE, yyvsp[0].ttype); goto rest_of_mdef; ; break;} case 99: -#line 665 "parse.y" +#line 670 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ftype.t); yyval.ttype = start_method (specs, yyvsp[0].ttype); goto rest_of_mdef; ; break;} case 100: -#line 668 "parse.y" +#line 673 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ttype); yyval.ttype = start_method (specs, yyvsp[0].ttype); goto rest_of_mdef; ; break;} case 101: -#line 671 "parse.y" +#line 676 "parse.y" { yyval.ttype = start_method (NULL_TREE, yyval.ttype); goto rest_of_mdef; ; break;} case 102: -#line 673 "parse.y" +#line 678 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ttype); yyval.ttype = start_method (specs, yyvsp[0].ttype); goto rest_of_mdef; ; break;} case 103: -#line 676 "parse.y" +#line 681 "parse.y" { yyval.ttype = start_method (NULL_TREE, yyval.ttype); goto rest_of_mdef; ; break;} case 104: -#line 681 "parse.y" +#line 686 "parse.y" { if (! current_function_parms_stored) store_parm_decls (); @@ -4410,19 +4415,19 @@ case 104: ; break;} case 105: -#line 690 "parse.y" +#line 695 "parse.y" { store_return_init (yyval.ttype, yyvsp[0].ttype); ; break;} case 106: -#line 692 "parse.y" +#line 697 "parse.y" { store_return_init (yyval.ttype, yyvsp[-1].ttype); ; break;} case 107: -#line 694 "parse.y" +#line 699 "parse.y" { store_return_init (yyval.ttype, NULL_TREE); ; break;} case 108: -#line 699 "parse.y" +#line 704 "parse.y" { if (yyvsp[0].itype == 0) error ("no base initializers given following ':'"); @@ -4434,7 +4439,7 @@ case 108: ; break;} case 109: -#line 712 "parse.y" +#line 717 "parse.y" { if (! current_function_parms_stored) store_parm_decls (); @@ -4453,15 +4458,15 @@ case 109: ; break;} case 110: -#line 732 "parse.y" +#line 737 "parse.y" { yyval.itype = 0; ; break;} case 111: -#line 734 "parse.y" +#line 739 "parse.y" { yyval.itype = 1; ; break;} case 114: -#line 741 "parse.y" +#line 746 "parse.y" { if (current_class_name) pedwarn ("anachronistic old style base class initializer"); @@ -4469,7 +4474,7 @@ case 114: ; break;} case 115: -#line 747 "parse.y" +#line 752 "parse.y" { if (current_class_name) pedwarn ("anachronistic old style base class initializer"); @@ -4477,77 +4482,77 @@ case 115: ; break;} case 116: -#line 753 "parse.y" +#line 758 "parse.y" { expand_member_init (current_class_ref, yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 117: -#line 755 "parse.y" +#line 760 "parse.y" { expand_member_init (current_class_ref, yyvsp[-1].ttype, void_type_node); ; break;} case 118: -#line 757 "parse.y" +#line 762 "parse.y" { expand_member_init (current_class_ref, yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 119: -#line 759 "parse.y" +#line 764 "parse.y" { expand_member_init (current_class_ref, yyvsp[-1].ttype, void_type_node); ; break;} case 120: -#line 761 "parse.y" +#line 766 "parse.y" { expand_member_init (current_class_ref, TYPE_MAIN_DECL (yyvsp[-3].ttype), yyvsp[-1].ttype); ; break;} case 121: -#line 764 "parse.y" +#line 769 "parse.y" { expand_member_init (current_class_ref, TYPE_MAIN_DECL (yyvsp[-1].ttype), void_type_node); ; break;} case 133: -#line 790 "parse.y" +#line 795 "parse.y" { do_type_instantiation (yyvsp[-1].ftype.t, NULL_TREE); yyungetc (';', 1); ; break;} case 135: -#line 794 "parse.y" +#line 799 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ftype.t); do_decl_instantiation (specs, yyvsp[0].ttype, NULL_TREE); ; break;} case 137: -#line 798 "parse.y" +#line 803 "parse.y" { do_decl_instantiation (NULL_TREE, yyvsp[0].ttype, NULL_TREE); ; break;} case 139: -#line 801 "parse.y" +#line 806 "parse.y" { do_decl_instantiation (NULL_TREE, yyvsp[0].ttype, NULL_TREE); ; break;} case 141: -#line 804 "parse.y" +#line 809 "parse.y" { do_type_instantiation (yyvsp[-1].ftype.t, yyvsp[-4].ttype); yyungetc (';', 1); ; break;} case 143: -#line 809 "parse.y" +#line 814 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ftype.t); do_decl_instantiation (specs, yyvsp[0].ttype, yyvsp[-4].ttype); ; break;} case 145: -#line 813 "parse.y" +#line 818 "parse.y" { do_decl_instantiation (NULL_TREE, yyvsp[0].ttype, yyvsp[-3].ttype); ; break;} case 147: -#line 816 "parse.y" +#line 821 "parse.y" { do_decl_instantiation (NULL_TREE, yyvsp[0].ttype, yyvsp[-3].ttype); ; break;} case 149: -#line 821 "parse.y" +#line 826 "parse.y" { begin_explicit_instantiation(); ; break;} case 150: -#line 824 "parse.y" +#line 829 "parse.y" { end_explicit_instantiation(); ; break;} case 151: -#line 832 "parse.y" +#line 837 "parse.y" { yyval.ttype = lookup_template_class (yyvsp[-3].ttype, yyvsp[-1].ttype, NULL_TREE, NULL_TREE); if (yyval.ttype != error_mark_node) @@ -4555,7 +4560,7 @@ case 151: ; break;} case 152: -#line 838 "parse.y" +#line 843 "parse.y" { yyval.ttype = lookup_template_class (yyvsp[-3].ttype, yyvsp[-1].ttype, NULL_TREE, NULL_TREE); if (yyval.ttype != error_mark_node) @@ -4563,7 +4568,7 @@ case 152: ; break;} case 154: -#line 848 "parse.y" +#line 853 "parse.y" { yyval.ttype = lookup_template_class (yyvsp[-3].ttype, yyvsp[-1].ttype, NULL_TREE, NULL_TREE); if (yyval.ttype != error_mark_node) @@ -4571,7 +4576,7 @@ case 154: ; break;} case 156: -#line 858 "parse.y" +#line 863 "parse.y" { /* Handle `Class<Class<Type>>' without space in the `>>' */ pedwarn ("`>>' should be `> >' in template class name"); @@ -4579,79 +4584,79 @@ case 156: ; break;} case 157: -#line 867 "parse.y" +#line 872 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 159: -#line 873 "parse.y" +#line 878 "parse.y" { yyval.ttype = build_tree_list (NULL_TREE, yyval.ttype); ; break;} case 160: -#line 875 "parse.y" +#line 880 "parse.y" { yyval.ttype = chainon (yyval.ttype, build_tree_list (NULL_TREE, yyvsp[0].ttype)); ; break;} case 161: -#line 880 "parse.y" +#line 885 "parse.y" { yyval.ttype = groktypename (yyvsp[0].ftype.t); ; break;} case 163: -#line 886 "parse.y" +#line 891 "parse.y" { yyval.code = NEGATE_EXPR; ; break;} case 164: -#line 888 "parse.y" +#line 893 "parse.y" { yyval.code = CONVERT_EXPR; ; break;} case 165: -#line 890 "parse.y" +#line 895 "parse.y" { yyval.code = PREINCREMENT_EXPR; ; break;} case 166: -#line 892 "parse.y" +#line 897 "parse.y" { yyval.code = PREDECREMENT_EXPR; ; break;} case 167: -#line 894 "parse.y" +#line 899 "parse.y" { yyval.code = TRUTH_NOT_EXPR; ; break;} case 168: -#line 899 "parse.y" +#line 904 "parse.y" { yyval.ttype = build_x_compound_expr (yyval.ttype); ; break;} case 170: -#line 905 "parse.y" +#line 910 "parse.y" { error ("ANSI C++ forbids an empty condition for `%s'", cond_stmt_keyword); yyval.ttype = integer_zero_node; ; break;} case 171: -#line 909 "parse.y" +#line 914 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 172: -#line 914 "parse.y" +#line 919 "parse.y" { error ("ANSI C++ forbids an empty condition for `%s'", cond_stmt_keyword); yyval.ttype = integer_zero_node; ; break;} case 173: -#line 918 "parse.y" +#line 923 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 174: -#line 923 "parse.y" +#line 928 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 175: -#line 925 "parse.y" +#line 930 "parse.y" { yyval.ttype = condition_conversion (yyval.ttype); ; break;} case 176: -#line 927 "parse.y" +#line 932 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 177: -#line 932 "parse.y" +#line 937 "parse.y" { { tree d; for (d = getdecls (); d; d = TREE_CHAIN (d)) @@ -4670,7 +4675,7 @@ case 177: ; break;} case 178: -#line 949 "parse.y" +#line 954 "parse.y" { cp_finish_decl (yyvsp[-1].ttype, yyvsp[0].ttype, yyvsp[-3].ttype, 1, LOOKUP_ONLYCONVERTING); resume_momentary (yyvsp[-2].itype); @@ -4680,58 +4685,58 @@ case 178: ; break;} case 184: -#line 968 "parse.y" +#line 973 "parse.y" { yyval.ttype = begin_compound_stmt (1); ; break;} case 185: -#line 970 "parse.y" +#line 975 "parse.y" { finish_compound_stmt (1, yyvsp[-1].ttype); ; break;} case 187: -#line 977 "parse.y" +#line 982 "parse.y" { yyval.ttype = expr_tree_cons (NULL_TREE, yyval.ttype, build_expr_list (NULL_TREE, yyvsp[0].ttype)); ; break;} case 188: -#line 980 "parse.y" +#line 985 "parse.y" { yyval.ttype = expr_tree_cons (NULL_TREE, yyval.ttype, build_expr_list (NULL_TREE, error_mark_node)); ; break;} case 189: -#line 983 "parse.y" +#line 988 "parse.y" { chainon (yyval.ttype, build_expr_list (NULL_TREE, yyvsp[0].ttype)); ; break;} case 190: -#line 985 "parse.y" +#line 990 "parse.y" { chainon (yyval.ttype, build_expr_list (NULL_TREE, error_mark_node)); ; break;} case 191: -#line 990 "parse.y" +#line 995 "parse.y" { yyval.ttype = build_expr_list (NULL_TREE, yyval.ttype); ; break;} case 193: -#line 996 "parse.y" +#line 1001 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 194: -#line 999 "parse.y" +#line 1004 "parse.y" { yyval.ttype = yyvsp[0].ttype; pedantic = yyvsp[-1].itype; ; break;} case 195: -#line 1002 "parse.y" +#line 1007 "parse.y" { yyval.ttype = build_x_indirect_ref (yyvsp[0].ttype, "unary *"); ; break;} case 196: -#line 1004 "parse.y" +#line 1009 "parse.y" { yyval.ttype = build_x_unary_op (ADDR_EXPR, yyvsp[0].ttype); ; break;} case 197: -#line 1006 "parse.y" +#line 1011 "parse.y" { yyval.ttype = build_x_unary_op (BIT_NOT_EXPR, yyvsp[0].ttype); ; break;} case 198: -#line 1008 "parse.y" +#line 1013 "parse.y" { yyval.ttype = build_x_unary_op (yyvsp[-1].code, yyvsp[0].ttype); if (yyvsp[-1].code == NEGATE_EXPR && TREE_CODE (yyvsp[0].ttype) == INTEGER_CST) TREE_NEGATED_INT (yyval.ttype) = 1; @@ -4739,121 +4744,121 @@ case 198: ; break;} case 199: -#line 1015 "parse.y" +#line 1020 "parse.y" { if (pedantic) pedwarn ("ANSI C++ forbids `&&'"); yyval.ttype = finish_label_address_expr (yyvsp[0].ttype); ; break;} case 200: -#line 1019 "parse.y" +#line 1024 "parse.y" { yyval.ttype = expr_sizeof (yyvsp[0].ttype); ; break;} case 201: -#line 1021 "parse.y" +#line 1026 "parse.y" { yyval.ttype = c_sizeof (groktypename (yyvsp[-1].ftype.t)); ; break;} case 202: -#line 1023 "parse.y" +#line 1028 "parse.y" { yyval.ttype = grok_alignof (yyvsp[0].ttype); ; break;} case 203: -#line 1025 "parse.y" +#line 1030 "parse.y" { yyval.ttype = c_alignof (groktypename (yyvsp[-1].ftype.t)); check_for_new_type ("alignof", yyvsp[-1].ftype); ; break;} case 204: -#line 1031 "parse.y" +#line 1036 "parse.y" { yyval.ttype = build_new (NULL_TREE, yyvsp[0].ftype.t, NULL_TREE, yyvsp[-1].itype); check_for_new_type ("new", yyvsp[0].ftype); ; break;} case 205: -#line 1034 "parse.y" +#line 1039 "parse.y" { yyval.ttype = build_new (NULL_TREE, yyvsp[-1].ftype.t, yyvsp[0].ttype, yyvsp[-2].itype); check_for_new_type ("new", yyvsp[-1].ftype); ; break;} case 206: -#line 1037 "parse.y" +#line 1042 "parse.y" { yyval.ttype = build_new (yyvsp[-1].ttype, yyvsp[0].ftype.t, NULL_TREE, yyvsp[-2].itype); check_for_new_type ("new", yyvsp[0].ftype); ; break;} case 207: -#line 1040 "parse.y" +#line 1045 "parse.y" { yyval.ttype = build_new (yyvsp[-2].ttype, yyvsp[-1].ftype.t, yyvsp[0].ttype, yyvsp[-3].itype); check_for_new_type ("new", yyvsp[-1].ftype); ; break;} case 208: -#line 1043 "parse.y" +#line 1048 "parse.y" { yyval.ttype = build_new (NULL_TREE, groktypename(yyvsp[-1].ftype.t), NULL_TREE, yyvsp[-3].itype); check_for_new_type ("new", yyvsp[-1].ftype); ; break;} case 209: -#line 1047 "parse.y" +#line 1052 "parse.y" { yyval.ttype = build_new (NULL_TREE, groktypename(yyvsp[-2].ftype.t), yyvsp[0].ttype, yyvsp[-4].itype); check_for_new_type ("new", yyvsp[-2].ftype); ; break;} case 210: -#line 1050 "parse.y" +#line 1055 "parse.y" { yyval.ttype = build_new (yyvsp[-3].ttype, groktypename(yyvsp[-1].ftype.t), NULL_TREE, yyvsp[-4].itype); check_for_new_type ("new", yyvsp[-1].ftype); ; break;} case 211: -#line 1053 "parse.y" +#line 1058 "parse.y" { yyval.ttype = build_new (yyvsp[-4].ttype, groktypename(yyvsp[-2].ftype.t), yyvsp[0].ttype, yyvsp[-5].itype); check_for_new_type ("new", yyvsp[-2].ftype); ; break;} case 212: -#line 1057 "parse.y" +#line 1062 "parse.y" { yyval.ttype = delete_sanity (yyvsp[0].ttype, NULL_TREE, 0, yyvsp[-1].itype); ; break;} case 213: -#line 1059 "parse.y" +#line 1064 "parse.y" { yyval.ttype = delete_sanity (yyvsp[0].ttype, NULL_TREE, 1, yyvsp[-3].itype); if (yychar == YYEMPTY) yychar = YYLEX; ; break;} case 214: -#line 1063 "parse.y" +#line 1068 "parse.y" { yyval.ttype = delete_sanity (yyvsp[0].ttype, yyvsp[-2].ttype, 2, yyvsp[-4].itype); if (yychar == YYEMPTY) yychar = YYLEX; ; break;} case 215: -#line 1067 "parse.y" +#line 1072 "parse.y" { yyval.ttype = build_x_unary_op (REALPART_EXPR, yyvsp[0].ttype); ; break;} case 216: -#line 1069 "parse.y" +#line 1074 "parse.y" { yyval.ttype = build_x_unary_op (IMAGPART_EXPR, yyvsp[0].ttype); ; break;} case 217: -#line 1074 "parse.y" +#line 1079 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 218: -#line 1076 "parse.y" +#line 1081 "parse.y" { yyval.ttype = yyvsp[-1].ttype; pedwarn ("old style placement syntax, use () instead"); ; break;} case 219: -#line 1084 "parse.y" +#line 1089 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 220: -#line 1086 "parse.y" +#line 1091 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 221: -#line 1088 "parse.y" +#line 1093 "parse.y" { cp_error ("`%T' is not a valid expression", yyvsp[-1].ftype.t); yyval.ttype = error_mark_node; ; break;} case 222: -#line 1096 "parse.y" +#line 1101 "parse.y" { if (pedantic) pedwarn ("ANSI C++ forbids initialization of new expression with `='"); @@ -4865,25 +4870,25 @@ case 222: ; break;} case 223: -#line 1110 "parse.y" +#line 1115 "parse.y" { yyvsp[-1].ftype.t = tree_cons (NULL_TREE, yyvsp[-1].ftype.t, void_list_node); TREE_PARMLIST (yyvsp[-1].ftype.t) = 1; yyval.ttype = make_call_declarator (NULL_TREE, yyvsp[-1].ftype.t, NULL_TREE, NULL_TREE); check_for_new_type ("cast", yyvsp[-1].ftype); ; break;} case 224: -#line 1115 "parse.y" +#line 1120 "parse.y" { yyvsp[-1].ftype.t = tree_cons (NULL_TREE, yyvsp[-1].ftype.t, void_list_node); TREE_PARMLIST (yyvsp[-1].ftype.t) = 1; yyval.ttype = make_call_declarator (yyval.ttype, yyvsp[-1].ftype.t, NULL_TREE, NULL_TREE); check_for_new_type ("cast", yyvsp[-1].ftype); ; break;} case 226: -#line 1124 "parse.y" +#line 1129 "parse.y" { yyval.ttype = reparse_absdcl_as_casts (yyval.ttype, yyvsp[0].ttype); ; break;} case 227: -#line 1126 "parse.y" +#line 1131 "parse.y" { tree init = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (yyvsp[-2].ttype)); @@ -4896,157 +4901,157 @@ case 227: ; break;} case 229: -#line 1142 "parse.y" +#line 1147 "parse.y" { yyval.ttype = build_x_binary_op (MEMBER_REF, yyval.ttype, yyvsp[0].ttype); ; break;} case 230: -#line 1144 "parse.y" +#line 1149 "parse.y" { yyval.ttype = build_m_component_ref (yyval.ttype, yyvsp[0].ttype); ; break;} case 231: -#line 1146 "parse.y" +#line 1151 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 232: -#line 1148 "parse.y" +#line 1153 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 233: -#line 1150 "parse.y" +#line 1155 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 234: -#line 1152 "parse.y" +#line 1157 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 235: -#line 1154 "parse.y" +#line 1159 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 236: -#line 1156 "parse.y" +#line 1161 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 237: -#line 1158 "parse.y" +#line 1163 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 238: -#line 1160 "parse.y" +#line 1165 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 239: -#line 1162 "parse.y" +#line 1167 "parse.y" { yyval.ttype = build_x_binary_op (LT_EXPR, yyval.ttype, yyvsp[0].ttype); ; break;} case 240: -#line 1164 "parse.y" +#line 1169 "parse.y" { yyval.ttype = build_x_binary_op (GT_EXPR, yyval.ttype, yyvsp[0].ttype); ; break;} case 241: -#line 1166 "parse.y" +#line 1171 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 242: -#line 1168 "parse.y" +#line 1173 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 243: -#line 1170 "parse.y" +#line 1175 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 244: -#line 1172 "parse.y" +#line 1177 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 245: -#line 1174 "parse.y" +#line 1179 "parse.y" { yyval.ttype = build_x_binary_op (yyvsp[-1].code, yyval.ttype, yyvsp[0].ttype); ; break;} case 246: -#line 1176 "parse.y" +#line 1181 "parse.y" { yyval.ttype = build_x_binary_op (TRUTH_ANDIF_EXPR, yyval.ttype, yyvsp[0].ttype); ; break;} case 247: -#line 1178 "parse.y" +#line 1183 "parse.y" { yyval.ttype = build_x_binary_op (TRUTH_ORIF_EXPR, yyval.ttype, yyvsp[0].ttype); ; break;} case 248: -#line 1180 "parse.y" +#line 1185 "parse.y" { yyval.ttype = build_x_conditional_expr (yyval.ttype, yyvsp[-2].ttype, yyvsp[0].ttype); ; break;} case 249: -#line 1182 "parse.y" +#line 1187 "parse.y" { yyval.ttype = build_x_modify_expr (yyval.ttype, NOP_EXPR, yyvsp[0].ttype); if (yyval.ttype != error_mark_node) C_SET_EXP_ORIGINAL_CODE (yyval.ttype, MODIFY_EXPR); ; break;} case 250: -#line 1186 "parse.y" +#line 1191 "parse.y" { yyval.ttype = build_x_modify_expr (yyval.ttype, yyvsp[-1].code, yyvsp[0].ttype); ; break;} case 251: -#line 1188 "parse.y" +#line 1193 "parse.y" { yyval.ttype = build_throw (NULL_TREE); ; break;} case 252: -#line 1190 "parse.y" +#line 1195 "parse.y" { yyval.ttype = build_throw (yyvsp[0].ttype); ; break;} case 253: -#line 1208 "parse.y" +#line 1213 "parse.y" { yyval.ttype = build_parse_node (BIT_NOT_EXPR, yyvsp[0].ttype); ; break;} case 259: -#line 1217 "parse.y" +#line 1222 "parse.y" { yyval.ttype = do_identifier (yyvsp[-1].ttype, 1); ; break;} case 260: -#line 1221 "parse.y" +#line 1226 "parse.y" { yyval.ttype = lookup_template_function (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 261: -#line 1223 "parse.y" +#line 1228 "parse.y" { yyval.ttype = lookup_template_function (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 262: -#line 1228 "parse.y" +#line 1233 "parse.y" { yyval.ttype = lookup_template_function (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 263: -#line 1230 "parse.y" +#line 1235 "parse.y" { yyval.ttype = lookup_template_function (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 264: -#line 1233 "parse.y" +#line 1238 "parse.y" { yyval.ttype = lookup_template_function (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 269: -#line 1245 "parse.y" +#line 1250 "parse.y" { yyval.ttype = build_parse_node (INDIRECT_REF, yyvsp[0].ttype); ; break;} case 270: -#line 1247 "parse.y" +#line 1252 "parse.y" { yyval.ttype = build_parse_node (ADDR_EXPR, yyvsp[0].ttype); ; break;} case 271: -#line 1249 "parse.y" +#line 1254 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 272: -#line 1254 "parse.y" +#line 1259 "parse.y" { yyval.ttype = lookup_template_function (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 273: -#line 1256 "parse.y" +#line 1261 "parse.y" { yyval.ttype = lookup_template_function (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 277: -#line 1264 "parse.y" +#line 1269 "parse.y" { yyval.ttype = finish_decl_parsing (yyvsp[-1].ttype); ; break;} case 278: -#line 1269 "parse.y" +#line 1274 "parse.y" { if (TREE_CODE (yyval.ttype) == BIT_NOT_EXPR) yyval.ttype = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND (yyval.ttype, 0)); @@ -5055,7 +5060,7 @@ case 278: ; break;} case 281: -#line 1278 "parse.y" +#line 1283 "parse.y" { if (processing_template_decl) push_obstacks (&permanent_obstack, &permanent_obstack); @@ -5065,20 +5070,20 @@ case 281: ; break;} case 282: -#line 1286 "parse.y" +#line 1291 "parse.y" { yyval.ttype = finish_parenthesized_expr (yyvsp[-1].ttype); ; break;} case 283: -#line 1288 "parse.y" +#line 1293 "parse.y" { yyvsp[-1].ttype = reparse_decl_as_expr (NULL_TREE, yyvsp[-1].ttype); yyval.ttype = finish_parenthesized_expr (yyvsp[-1].ttype); ; break;} case 284: -#line 1291 "parse.y" +#line 1296 "parse.y" { yyval.ttype = error_mark_node; ; break;} case 285: -#line 1293 "parse.y" +#line 1298 "parse.y" { if (current_function_decl == 0) { error ("braced-group within expression allowed only inside a function"); @@ -5090,35 +5095,35 @@ case 285: ; break;} case 286: -#line 1303 "parse.y" +#line 1308 "parse.y" { yyval.ttype = finish_stmt_expr (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 287: -#line 1305 "parse.y" +#line 1310 "parse.y" { yyval.ttype = finish_call_expr (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 288: -#line 1307 "parse.y" +#line 1312 "parse.y" { yyval.ttype = finish_call_expr (yyvsp[-1].ttype, NULL_TREE); ; break;} case 289: -#line 1309 "parse.y" +#line 1314 "parse.y" { yyval.ttype = grok_array_decl (yyval.ttype, yyvsp[-1].ttype); ; break;} case 290: -#line 1311 "parse.y" +#line 1316 "parse.y" { yyval.ttype = finish_increment_expr (yyvsp[-1].ttype, POSTINCREMENT_EXPR); ; break;} case 291: -#line 1313 "parse.y" +#line 1318 "parse.y" { yyval.ttype = finish_increment_expr (yyvsp[-1].ttype, POSTDECREMENT_EXPR); ; break;} case 292: -#line 1316 "parse.y" +#line 1321 "parse.y" { yyval.ttype = finish_this_expr (); ; break;} case 293: -#line 1318 "parse.y" +#line 1323 "parse.y" { tree type = NULL_TREE; tree id = yyval.ttype; @@ -5164,45 +5169,45 @@ case 293: ; break;} case 295: -#line 1363 "parse.y" +#line 1368 "parse.y" { tree type = groktypename (yyvsp[-4].ftype.t); check_for_new_type ("dynamic_cast", yyvsp[-4].ftype); yyval.ttype = build_dynamic_cast (type, yyvsp[-1].ttype); ; break;} case 296: -#line 1367 "parse.y" +#line 1372 "parse.y" { tree type = groktypename (yyvsp[-4].ftype.t); check_for_new_type ("static_cast", yyvsp[-4].ftype); yyval.ttype = build_static_cast (type, yyvsp[-1].ttype); ; break;} case 297: -#line 1371 "parse.y" +#line 1376 "parse.y" { tree type = groktypename (yyvsp[-4].ftype.t); check_for_new_type ("reinterpret_cast", yyvsp[-4].ftype); yyval.ttype = build_reinterpret_cast (type, yyvsp[-1].ttype); ; break;} case 298: -#line 1375 "parse.y" +#line 1380 "parse.y" { tree type = groktypename (yyvsp[-4].ftype.t); check_for_new_type ("const_cast", yyvsp[-4].ftype); yyval.ttype = build_const_cast (type, yyvsp[-1].ttype); ; break;} case 299: -#line 1379 "parse.y" +#line 1384 "parse.y" { yyval.ttype = build_x_typeid (yyvsp[-1].ttype); ; break;} case 300: -#line 1381 "parse.y" +#line 1386 "parse.y" { tree type = groktypename (yyvsp[-1].ftype.t); check_for_new_type ("typeid", yyvsp[-1].ftype); yyval.ttype = get_typeid (TYPE_MAIN_VARIANT (type)); ; break;} case 301: -#line 1385 "parse.y" +#line 1390 "parse.y" { yyval.ttype = do_scoped_id (yyvsp[0].ttype, 1); ; break;} case 302: -#line 1387 "parse.y" +#line 1392 "parse.y" { got_scope = NULL_TREE; if (TREE_CODE (yyvsp[0].ttype) == IDENTIFIER_NODE) @@ -5212,102 +5217,102 @@ case 302: ; break;} case 303: -#line 1395 "parse.y" +#line 1400 "parse.y" { yyval.ttype = build_offset_ref (OP0 (yyval.ttype), OP1 (yyval.ttype)); ; break;} case 304: -#line 1397 "parse.y" +#line 1402 "parse.y" { yyval.ttype = finish_globally_qualified_member_call_expr (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 305: -#line 1399 "parse.y" +#line 1404 "parse.y" { yyval.ttype = finish_globally_qualified_member_call_expr (yyvsp[-1].ttype, NULL_TREE); ; break;} case 306: -#line 1401 "parse.y" +#line 1406 "parse.y" { yyval.ttype = build_x_component_ref (yyval.ttype, yyvsp[0].ttype, NULL_TREE, 1); ; break;} case 307: -#line 1405 "parse.y" +#line 1410 "parse.y" { yyval.ttype = finish_object_call_expr (yyvsp[-3].ttype, yyvsp[-4].ttype, yyvsp[-1].ttype); ; break;} case 308: -#line 1407 "parse.y" +#line 1412 "parse.y" { yyval.ttype = finish_object_call_expr (yyvsp[-1].ttype, yyvsp[-2].ttype, NULL_TREE); ; break;} case 309: -#line 1409 "parse.y" +#line 1414 "parse.y" { yyval.ttype = build_x_component_ref (yyval.ttype, yyvsp[0].ttype, NULL_TREE, 1); ; break;} case 310: -#line 1411 "parse.y" +#line 1416 "parse.y" { if (processing_template_decl) yyval.ttype = build_min_nt (COMPONENT_REF, yyvsp[-1].ttype, copy_to_permanent (yyvsp[0].ttype)); else yyval.ttype = build_object_ref (yyval.ttype, OP0 (yyvsp[0].ttype), OP1 (yyvsp[0].ttype)); ; break;} case 311: -#line 1416 "parse.y" +#line 1421 "parse.y" { yyval.ttype = finish_object_call_expr (yyvsp[-3].ttype, yyvsp[-4].ttype, yyvsp[-1].ttype); ; break;} case 312: -#line 1418 "parse.y" +#line 1423 "parse.y" { yyval.ttype = finish_object_call_expr (yyvsp[-1].ttype, yyvsp[-2].ttype, NULL_TREE); ; break;} case 313: -#line 1420 "parse.y" +#line 1425 "parse.y" { yyval.ttype = finish_qualified_object_call_expr (yyvsp[-3].ttype, yyvsp[-4].ttype, yyvsp[-1].ttype); ; break;} case 314: -#line 1422 "parse.y" +#line 1427 "parse.y" { yyval.ttype = finish_qualified_object_call_expr (yyvsp[-1].ttype, yyvsp[-2].ttype, NULL_TREE); ; break;} case 315: -#line 1425 "parse.y" +#line 1430 "parse.y" { yyval.ttype = finish_pseudo_destructor_call_expr (yyvsp[-3].ttype, NULL_TREE, yyvsp[-1].ttype); ; break;} case 316: -#line 1427 "parse.y" +#line 1432 "parse.y" { yyval.ttype = finish_pseudo_destructor_call_expr (yyvsp[-5].ttype, yyvsp[-4].ttype, yyvsp[-1].ttype); ; break;} case 317: -#line 1429 "parse.y" +#line 1434 "parse.y" { yyval.ttype = error_mark_node; ; break;} case 318: -#line 1474 "parse.y" +#line 1479 "parse.y" { yyval.itype = 0; ; break;} case 319: -#line 1476 "parse.y" +#line 1481 "parse.y" { got_scope = NULL_TREE; yyval.itype = 1; ; break;} case 320: -#line 1481 "parse.y" +#line 1486 "parse.y" { yyval.itype = 0; ; break;} case 321: -#line 1483 "parse.y" +#line 1488 "parse.y" { got_scope = NULL_TREE; yyval.itype = 1; ; break;} case 322: -#line 1488 "parse.y" +#line 1493 "parse.y" { yyval.ttype = boolean_true_node; ; break;} case 323: -#line 1490 "parse.y" +#line 1495 "parse.y" { yyval.ttype = boolean_false_node; ; break;} case 325: -#line 1497 "parse.y" +#line 1502 "parse.y" { yyval.ttype = chainon (yyval.ttype, yyvsp[0].ttype); ; break;} case 326: -#line 1502 "parse.y" +#line 1507 "parse.y" { if (! current_function_parms_stored) store_parm_decls (); @@ -5319,18 +5324,18 @@ case 326: ; break;} case 327: -#line 1515 "parse.y" +#line 1520 "parse.y" { got_object = TREE_TYPE (yyval.ttype); ; break;} case 328: -#line 1517 "parse.y" +#line 1522 "parse.y" { yyval.ttype = build_x_arrow (yyval.ttype); got_object = TREE_TYPE (yyval.ttype); ; break;} case 329: -#line 1525 "parse.y" +#line 1530 "parse.y" { resume_momentary (yyvsp[-1].itype); if (yyvsp[-2].ftype.t && IS_AGGR_TYPE_CODE (TREE_CODE (yyvsp[-2].ftype.t))) @@ -5338,138 +5343,138 @@ case 329: ; break;} case 330: -#line 1531 "parse.y" +#line 1536 "parse.y" { resume_momentary (yyvsp[-1].itype); note_list_got_semicolon (yyvsp[-2].ftype.t); ; break;} case 331: -#line 1536 "parse.y" +#line 1541 "parse.y" { resume_momentary (yyvsp[-1].itype); ; break;} case 332: -#line 1538 "parse.y" +#line 1543 "parse.y" { shadow_tag (yyvsp[-1].ftype.t); note_list_got_semicolon (yyvsp[-1].ftype.t); ; break;} case 333: -#line 1543 "parse.y" +#line 1548 "parse.y" { warning ("empty declaration"); ; break;} case 334: -#line 1545 "parse.y" +#line 1550 "parse.y" { pedantic = yyvsp[-1].itype; ; break;} case 337: -#line 1559 "parse.y" +#line 1564 "parse.y" { yyval.ttype = make_call_declarator (NULL_TREE, empty_parms (), NULL_TREE, NULL_TREE); ; break;} case 338: -#line 1562 "parse.y" +#line 1567 "parse.y" { yyval.ttype = make_call_declarator (yyval.ttype, empty_parms (), NULL_TREE, NULL_TREE); ; break;} case 339: -#line 1569 "parse.y" +#line 1574 "parse.y" { yyval.ftype.t = build_decl_list (yyvsp[-1].ftype.t, yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 340: -#line 1572 "parse.y" +#line 1577 "parse.y" { yyval.ftype.t = build_decl_list (yyvsp[-1].ftype.t, yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 341: -#line 1575 "parse.y" +#line 1580 "parse.y" { yyval.ftype.t = build_decl_list (get_decl_list (yyvsp[-1].ftype.t), yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 342: -#line 1578 "parse.y" +#line 1583 "parse.y" { yyval.ftype.t = build_decl_list (yyvsp[0].ftype.t, NULL_TREE); yyval.ftype.new_type_flag = yyvsp[0].ftype.new_type_flag; ; break;} case 343: -#line 1581 "parse.y" +#line 1586 "parse.y" { yyval.ftype.t = build_decl_list (yyvsp[0].ftype.t, NULL_TREE); yyval.ftype.new_type_flag = yyvsp[0].ftype.new_type_flag; ; break;} case 346: -#line 1597 "parse.y" +#line 1602 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[0].ftype.t, yyvsp[-1].ttype); yyval.ftype.new_type_flag = yyvsp[0].ftype.new_type_flag; ; break;} case 347: -#line 1600 "parse.y" +#line 1605 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[-1].ftype.t, yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 348: -#line 1603 "parse.y" +#line 1608 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[-2].ftype.t, chainon (yyvsp[-1].ttype, yyvsp[0].ttype)); yyval.ftype.new_type_flag = yyvsp[-2].ftype.new_type_flag; ; break;} case 349: -#line 1606 "parse.y" +#line 1611 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[-1].ftype.t, chainon (yyvsp[0].ttype, yyvsp[-2].ttype)); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 350: -#line 1609 "parse.y" +#line 1614 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[-1].ftype.t, chainon (yyvsp[0].ttype, yyvsp[-2].ttype)); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 351: -#line 1612 "parse.y" +#line 1617 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[-2].ftype.t, chainon (yyvsp[-1].ttype, chainon (yyvsp[0].ttype, yyvsp[-3].ttype))); yyval.ftype.new_type_flag = yyvsp[-2].ftype.new_type_flag; ; break;} case 352: -#line 1619 "parse.y" +#line 1624 "parse.y" { if (extra_warnings) warning ("`%s' is not at beginning of declaration", IDENTIFIER_POINTER (yyval.ttype)); yyval.ttype = build_decl_list (NULL_TREE, yyval.ttype); ; break;} case 353: -#line 1624 "parse.y" +#line 1629 "parse.y" { yyval.ttype = decl_tree_cons (NULL_TREE, yyvsp[0].ftype.t, yyval.ttype); ; break;} case 354: -#line 1626 "parse.y" +#line 1631 "parse.y" { if (extra_warnings) warning ("`%s' is not at beginning of declaration", IDENTIFIER_POINTER (yyvsp[0].ttype)); yyval.ttype = decl_tree_cons (NULL_TREE, yyvsp[0].ttype, yyval.ttype); ; break;} case 355: -#line 1631 "parse.y" +#line 1636 "parse.y" { yyval.ttype = decl_tree_cons (yyvsp[0].ttype, NULL_TREE, yyvsp[-1].ttype); ; break;} case 356: -#line 1633 "parse.y" +#line 1638 "parse.y" { yyval.ttype = decl_tree_cons (yyvsp[0].ttype, NULL_TREE, NULL_TREE); ; break;} case 357: -#line 1643 "parse.y" +#line 1648 "parse.y" { yyval.ttype = yyvsp[0].ftype.t; TREE_STATIC (yyval.ttype) = 1; ; break;} case 358: -#line 1645 "parse.y" +#line 1650 "parse.y" { yyval.ttype = IDENTIFIER_AS_LIST (yyval.ttype); ; break;} case 359: -#line 1647 "parse.y" +#line 1652 "parse.y" { yyval.ttype = decl_tree_cons (NULL_TREE, yyvsp[0].ttype, yyval.ttype); TREE_STATIC (yyval.ttype) = 1; ; break;} case 360: -#line 1650 "parse.y" +#line 1655 "parse.y" { if (extra_warnings && TREE_STATIC (yyval.ttype)) warning ("`%s' is not at beginning of declaration", IDENTIFIER_POINTER (yyvsp[0].ttype)); @@ -5477,61 +5482,61 @@ case 360: TREE_STATIC (yyval.ttype) = TREE_STATIC (yyvsp[-1].ttype); ; break;} case 361: -#line 1656 "parse.y" +#line 1661 "parse.y" { yyval.ttype = decl_tree_cons (yyvsp[0].ttype, NULL_TREE, yyvsp[-1].ttype); ; break;} case 362: -#line 1658 "parse.y" +#line 1663 "parse.y" { yyval.ttype = decl_tree_cons (yyvsp[0].ttype, NULL_TREE, NULL_TREE); ; break;} case 363: -#line 1669 "parse.y" +#line 1674 "parse.y" { yyval.ftype.t = get_decl_list (yyvsp[0].ftype.t); yyval.ftype.new_type_flag = yyvsp[0].ftype.new_type_flag; ; break;} case 364: -#line 1672 "parse.y" +#line 1677 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[0].ftype.t, yyvsp[-1].ftype.t); yyval.ftype.new_type_flag = yyvsp[0].ftype.new_type_flag; ; break;} case 365: -#line 1675 "parse.y" +#line 1680 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[-1].ftype.t, yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 366: -#line 1678 "parse.y" +#line 1683 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[-1].ftype.t, chainon (yyvsp[0].ttype, yyvsp[-2].ftype.t)); yyval.ftype.new_type_flag = yyvsp[-2].ftype.new_type_flag; ; break;} case 367: -#line 1684 "parse.y" +#line 1689 "parse.y" { yyval.ttype = build_decl_list (NULL_TREE, yyvsp[0].ftype.t); ; break;} case 368: -#line 1686 "parse.y" +#line 1691 "parse.y" { yyval.ttype = decl_tree_cons (NULL_TREE, yyvsp[0].ftype.t, yyvsp[-1].ttype); ; break;} case 370: -#line 1696 "parse.y" +#line 1701 "parse.y" { yyval.ftype.t = yyvsp[0].ttype; yyval.ftype.new_type_flag = 0; ; break;} case 371: -#line 1698 "parse.y" +#line 1703 "parse.y" { yyval.ftype.t = yyvsp[0].ttype; yyval.ftype.new_type_flag = 0; ; break;} case 372: -#line 1700 "parse.y" +#line 1705 "parse.y" { yyval.ftype.t = TREE_TYPE (yyvsp[-1].ttype); yyval.ftype.new_type_flag = 0; ; break;} case 373: -#line 1703 "parse.y" +#line 1708 "parse.y" { yyval.ftype.t = groktypename (yyvsp[-1].ftype.t); yyval.ftype.new_type_flag = 0; ; break;} case 374: -#line 1706 "parse.y" +#line 1711 "parse.y" { tree type = TREE_TYPE (yyvsp[-1].ttype); yyval.ftype.new_type_flag = 0; @@ -5548,7 +5553,7 @@ case 374: ; break;} case 375: -#line 1721 "parse.y" +#line 1726 "parse.y" { tree type = groktypename (yyvsp[-1].ftype.t); yyval.ftype.new_type_flag = 0; @@ -5565,188 +5570,188 @@ case 375: ; break;} case 376: -#line 1741 "parse.y" +#line 1746 "parse.y" { yyval.ftype.t = yyvsp[0].ttype; yyval.ftype.new_type_flag = 0; ; break;} case 377: -#line 1743 "parse.y" +#line 1748 "parse.y" { yyval.ftype.t = yyvsp[0].ttype; yyval.ftype.new_type_flag = 0; ; break;} case 385: -#line 1764 "parse.y" +#line 1769 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 386: -#line 1766 "parse.y" +#line 1771 "parse.y" { if (TREE_CHAIN (yyvsp[-1].ttype)) yyvsp[-1].ttype = combine_strings (yyvsp[-1].ttype); yyval.ttype = yyvsp[-1].ttype; ; break;} case 387: -#line 1771 "parse.y" +#line 1776 "parse.y" { yyval.ttype = start_decl (yyvsp[-3].ttype, current_declspecs, 1, yyvsp[-1].ttype, prefix_attributes); ; break;} case 388: -#line 1775 "parse.y" +#line 1780 "parse.y" { cp_finish_decl (yyvsp[-1].ttype, yyvsp[0].ttype, yyvsp[-4].ttype, 1, LOOKUP_ONLYCONVERTING); ; break;} case 389: -#line 1777 "parse.y" +#line 1782 "parse.y" { yyval.ttype = start_decl (yyvsp[-2].ttype, current_declspecs, 0, yyvsp[0].ttype, prefix_attributes); cp_finish_decl (yyval.ttype, NULL_TREE, yyvsp[-1].ttype, 1, 0); ; break;} case 390: -#line 1790 "parse.y" +#line 1795 "parse.y" { yyvsp[0].itype = parse_decl (yyvsp[-3].ttype, yyvsp[-4].ttype, yyvsp[-1].ttype, 1, &yyval.ttype); ; break;} case 391: -#line 1795 "parse.y" +#line 1800 "parse.y" { cp_finish_decl (yyvsp[-1].ttype, yyvsp[0].ttype, yyvsp[-4].ttype, 1, LOOKUP_ONLYCONVERTING); yyval.itype = yyvsp[-2].itype; ; break;} case 392: -#line 1799 "parse.y" +#line 1804 "parse.y" { tree d; yyval.itype = parse_decl (yyvsp[-2].ttype, yyvsp[-3].ttype, yyvsp[0].ttype, 0, &d); cp_finish_decl (d, NULL_TREE, yyvsp[-1].ttype, 1, 0); ; break;} case 393: -#line 1806 "parse.y" +#line 1811 "parse.y" { yyval.itype = yyvsp[0].itype; ; break;} case 394: -#line 1810 "parse.y" +#line 1815 "parse.y" { yyval.itype = yyvsp[0].itype; ; break;} case 395: -#line 1815 "parse.y" +#line 1820 "parse.y" { /* Set things up as initdcl0_innards expects. */ yyval.ttype = yyvsp[-1].ttype; yyvsp[-1].ttype = NULL_TREE; ; break;} case 396: -#line 1819 "parse.y" +#line 1824 "parse.y" {; break;} case 397: -#line 1821 "parse.y" +#line 1826 "parse.y" { tree d; parse_decl(yyvsp[-2].ttype, NULL_TREE, yyvsp[0].ttype, 0, &d); cp_finish_decl (d, NULL_TREE, yyvsp[-1].ttype, 1, 0); ; break;} case 398: -#line 1830 "parse.y" +#line 1835 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 399: -#line 1832 "parse.y" +#line 1837 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 400: -#line 1837 "parse.y" +#line 1842 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 401: -#line 1839 "parse.y" +#line 1844 "parse.y" { yyval.ttype = chainon (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 402: -#line 1844 "parse.y" +#line 1849 "parse.y" { yyval.ttype = yyvsp[-2].ttype; ; break;} case 403: -#line 1849 "parse.y" +#line 1854 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 404: -#line 1851 "parse.y" +#line 1856 "parse.y" { yyval.ttype = chainon (yyvsp[-2].ttype, yyvsp[0].ttype); ; break;} case 405: -#line 1856 "parse.y" +#line 1861 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 406: -#line 1858 "parse.y" +#line 1863 "parse.y" { yyval.ttype = build_tree_list (yyvsp[0].ttype, NULL_TREE); ; break;} case 407: -#line 1860 "parse.y" +#line 1865 "parse.y" { yyval.ttype = build_tree_list (yyvsp[-3].ttype, build_tree_list (NULL_TREE, yyvsp[-1].ttype)); ; break;} case 408: -#line 1862 "parse.y" +#line 1867 "parse.y" { yyval.ttype = build_tree_list (yyvsp[-5].ttype, tree_cons (NULL_TREE, yyvsp[-3].ttype, yyvsp[-1].ttype)); ; break;} case 409: -#line 1864 "parse.y" +#line 1869 "parse.y" { yyval.ttype = build_tree_list (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 414: -#line 1880 "parse.y" +#line 1885 "parse.y" { yyval.ttype = build_tree_list (NULL_TREE, yyvsp[0].ttype); ; break;} case 415: -#line 1882 "parse.y" +#line 1887 "parse.y" { yyval.ttype = chainon (yyvsp[-2].ttype, build_tree_list (NULL_TREE, yyvsp[0].ttype)); ; break;} case 416: -#line 1887 "parse.y" +#line 1892 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 417: -#line 1889 "parse.y" +#line 1894 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 419: -#line 1897 "parse.y" +#line 1902 "parse.y" { yyval.ttype = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE); TREE_HAS_CONSTRUCTOR (yyval.ttype) = 1; ; break;} case 420: -#line 1900 "parse.y" +#line 1905 "parse.y" { yyval.ttype = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (yyvsp[-1].ttype)); TREE_HAS_CONSTRUCTOR (yyval.ttype) = 1; ; break;} case 421: -#line 1903 "parse.y" +#line 1908 "parse.y" { yyval.ttype = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (yyvsp[-2].ttype)); TREE_HAS_CONSTRUCTOR (yyval.ttype) = 1; ; break;} case 422: -#line 1906 "parse.y" +#line 1911 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 423: -#line 1913 "parse.y" +#line 1918 "parse.y" { yyval.ttype = build_tree_list (NULL_TREE, yyval.ttype); ; break;} case 424: -#line 1915 "parse.y" +#line 1920 "parse.y" { yyval.ttype = expr_tree_cons (NULL_TREE, yyvsp[0].ttype, yyval.ttype); ; break;} case 425: -#line 1918 "parse.y" +#line 1923 "parse.y" { yyval.ttype = build_expr_list (yyvsp[-2].ttype, yyvsp[0].ttype); ; break;} case 426: -#line 1920 "parse.y" +#line 1925 "parse.y" { yyval.ttype = build_expr_list (yyval.ttype, yyvsp[0].ttype); ; break;} case 427: -#line 1922 "parse.y" +#line 1927 "parse.y" { yyval.ttype = expr_tree_cons (yyvsp[-2].ttype, yyvsp[0].ttype, yyval.ttype); ; break;} case 428: -#line 1927 "parse.y" +#line 1932 "parse.y" { start_function (NULL_TREE, TREE_VALUE (yyvsp[0].ttype), NULL_TREE, 1); reinit_parse_for_function (); ; break;} case 429: -#line 1933 "parse.y" +#line 1938 "parse.y" { int nested = (hack_decl_function_context (current_function_decl) != NULL_TREE); @@ -5755,82 +5760,82 @@ case 429: ; break;} case 430: -#line 1940 "parse.y" +#line 1945 "parse.y" { process_next_inline (yyvsp[-2].ttype); ; break;} case 431: -#line 1942 "parse.y" +#line 1947 "parse.y" { process_next_inline (yyvsp[-2].ttype); ; break;} case 434: -#line 1954 "parse.y" +#line 1959 "parse.y" { replace_defarg (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 435: -#line 1956 "parse.y" +#line 1961 "parse.y" { replace_defarg (yyvsp[-2].ttype, error_mark_node); ; break;} case 437: -#line 1961 "parse.y" +#line 1966 "parse.y" { do_pending_defargs (); ; break;} case 438: -#line 1963 "parse.y" +#line 1968 "parse.y" { do_pending_defargs (); ; break;} case 439: -#line 1968 "parse.y" +#line 1973 "parse.y" { yyvsp[0].itype = suspend_momentary (); yyval.ttype = start_enum (yyvsp[-1].ttype); ; break;} case 440: -#line 1971 "parse.y" +#line 1976 "parse.y" { yyval.ftype.t = finish_enum (yyvsp[-3].ttype, yyvsp[-2].ttype); yyval.ftype.new_type_flag = 1; resume_momentary ((int) yyvsp[-4].itype); check_for_missing_semicolon (yyvsp[-3].ttype); ; break;} case 441: -#line 1976 "parse.y" +#line 1981 "parse.y" { yyval.ftype.t = finish_enum (start_enum (yyvsp[-2].ttype), NULL_TREE); yyval.ftype.new_type_flag = 1; check_for_missing_semicolon (yyval.ftype.t); ; break;} case 442: -#line 1980 "parse.y" +#line 1985 "parse.y" { yyvsp[0].itype = suspend_momentary (); yyval.ttype = start_enum (make_anon_name ()); ; break;} case 443: -#line 1983 "parse.y" +#line 1988 "parse.y" { yyval.ftype.t = finish_enum (yyvsp[-3].ttype, yyvsp[-2].ttype); resume_momentary ((int) yyvsp[-5].itype); check_for_missing_semicolon (yyvsp[-3].ttype); yyval.ftype.new_type_flag = 1; ; break;} case 444: -#line 1988 "parse.y" +#line 1993 "parse.y" { yyval.ftype.t = finish_enum (start_enum (make_anon_name()), NULL_TREE); yyval.ftype.new_type_flag = 1; check_for_missing_semicolon (yyval.ftype.t); ; break;} case 445: -#line 1992 "parse.y" +#line 1997 "parse.y" { yyval.ftype.t = xref_tag (enum_type_node, yyvsp[0].ttype, NULL_TREE, 1); yyval.ftype.new_type_flag = 0; ; break;} case 446: -#line 1995 "parse.y" +#line 2000 "parse.y" { yyval.ftype.t = xref_tag (enum_type_node, yyvsp[0].ttype, NULL_TREE, 1); yyval.ftype.new_type_flag = 0; ; break;} case 447: -#line 1998 "parse.y" +#line 2003 "parse.y" { yyval.ftype.t = yyvsp[0].ttype; yyval.ftype.new_type_flag = 0; ; break;} case 448: -#line 2003 "parse.y" +#line 2008 "parse.y" { int semi; @@ -5865,7 +5870,7 @@ case 448: ; break;} case 449: -#line 2036 "parse.y" +#line 2041 "parse.y" { if (pending_inlines && current_scope () == current_function_decl) @@ -5873,7 +5878,7 @@ case 449: ; break;} case 450: -#line 2042 "parse.y" +#line 2047 "parse.y" { yyval.ftype.t = yyvsp[-3].ttype; yyval.ftype.new_type_flag = 1; @@ -5885,7 +5890,7 @@ case 450: ; break;} case 451: -#line 2052 "parse.y" +#line 2057 "parse.y" { yyval.ftype.new_type_flag = 0; if (TYPE_BINFO (yyvsp[0].ttype) == NULL_TREE) @@ -5905,73 +5910,73 @@ case 451: ; break;} case 455: -#line 2079 "parse.y" +#line 2084 "parse.y" { if (pedantic && !in_system_header) pedwarn ("comma at end of enumerator list"); ; break;} case 457: -#line 2086 "parse.y" +#line 2091 "parse.y" { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER (yyvsp[0].ttype)); ; break;} case 458: -#line 2088 "parse.y" +#line 2093 "parse.y" { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER (yyvsp[0].ttype)); ; break;} case 459: -#line 2090 "parse.y" +#line 2095 "parse.y" { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER (yyvsp[0].ttype)); ; break;} case 460: -#line 2092 "parse.y" +#line 2097 "parse.y" { error ("no body nor ';' separates two class, struct or union declarations"); ; break;} case 461: -#line 2097 "parse.y" +#line 2102 "parse.y" { current_aggr = yyval.ttype; yyval.ttype = yyvsp[0].ttype; ; break;} case 462: -#line 2102 "parse.y" +#line 2107 "parse.y" { current_aggr = yyval.ttype; yyval.ttype = yyvsp[0].ttype; ; break;} case 463: -#line 2107 "parse.y" +#line 2112 "parse.y" { current_aggr = yyvsp[-2].ttype; yyval.ttype = handle_class_head (yyvsp[-2].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 464: -#line 2112 "parse.y" +#line 2117 "parse.y" { current_aggr = yyvsp[-3].ttype; yyval.ttype = handle_class_head (yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 465: -#line 2117 "parse.y" +#line 2122 "parse.y" { current_aggr = yyvsp[-2].ttype; yyval.ttype = handle_class_head (yyvsp[-2].ttype, NULL_TREE, yyvsp[0].ttype); ; break;} case 466: -#line 2122 "parse.y" +#line 2127 "parse.y" { current_aggr = yyval.ttype; yyval.ttype = yyvsp[0].ttype; ; break;} case 467: -#line 2124 "parse.y" +#line 2129 "parse.y" { current_aggr = yyval.ttype; yyval.ttype = yyvsp[0].ttype; ; break;} case 468: -#line 2129 "parse.y" +#line 2134 "parse.y" { yyval.ttype = xref_tag (current_aggr, yyvsp[0].ttype, NULL_TREE, 0); ; break;} case 469: -#line 2134 "parse.y" +#line 2139 "parse.y" { yyval.ttype = xref_tag (current_aggr, yyvsp[0].ttype, NULL_TREE, 1); ; break;} case 470: -#line 2137 "parse.y" +#line 2142 "parse.y" { yyval.ttype = yyvsp[-1].ttype; if (yyvsp[0].ttype) @@ -5979,7 +5984,7 @@ case 470: ; break;} case 471: -#line 2143 "parse.y" +#line 2148 "parse.y" { yyval.ttype = TREE_TYPE (yyvsp[-1].ttype); if (TREE_INT_CST_LOW (current_aggr) == union_type @@ -6007,28 +6012,28 @@ case 471: ; break;} case 472: -#line 2172 "parse.y" +#line 2177 "parse.y" { yyval.ttype = xref_tag (yyval.ttype, make_anon_name (), NULL_TREE, 0); yyungetc ('{', 1); ; break;} case 475: -#line 2183 "parse.y" +#line 2188 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 476: -#line 2185 "parse.y" +#line 2190 "parse.y" { yyungetc(':', 1); yyval.ttype = NULL_TREE; ; break;} case 477: -#line 2187 "parse.y" +#line 2192 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 479: -#line 2193 "parse.y" +#line 2198 "parse.y" { yyval.ttype = chainon (yyval.ttype, yyvsp[0].ttype); ; break;} case 480: -#line 2198 "parse.y" +#line 2203 "parse.y" { tree type = TREE_TYPE (yyvsp[0].ttype); if (! is_aggr_type (type, 1)) @@ -6055,7 +6060,7 @@ case 480: ; break;} case 481: -#line 2223 "parse.y" +#line 2228 "parse.y" { tree type = TREE_TYPE (yyvsp[0].ttype); if (current_aggr == signature_type_node) @@ -6084,11 +6089,11 @@ case 481: ; break;} case 482: -#line 2253 "parse.y" +#line 2258 "parse.y" { yyval.ttype = TYPE_MAIN_DECL (yyvsp[0].ttype); ; break;} case 484: -#line 2256 "parse.y" +#line 2261 "parse.y" { if (current_aggr == signature_type_node) { @@ -6111,7 +6116,7 @@ case 484: ; break;} case 485: -#line 2277 "parse.y" +#line 2282 "parse.y" { if (current_aggr == signature_type_node) { @@ -6134,13 +6139,13 @@ case 485: ; break;} case 487: -#line 2302 "parse.y" +#line 2307 "parse.y" { if (yyvsp[-1].ttype != ridpointers[(int)RID_VIRTUAL]) cp_error ("`%D' access", yyvsp[-1].ttype); yyval.ttype = access_default_virtual_node; ; break;} case 488: -#line 2306 "parse.y" +#line 2311 "parse.y" { if (yyvsp[-2].ttype != access_default_virtual_node) error ("multiple access specifiers"); @@ -6153,7 +6158,7 @@ case 488: ; break;} case 489: -#line 2317 "parse.y" +#line 2322 "parse.y" { if (yyvsp[-1].ttype != ridpointers[(int)RID_VIRTUAL]) cp_error ("`%D' access", yyvsp[-1].ttype); else if (yyval.ttype == access_public_node) @@ -6167,7 +6172,7 @@ case 489: ; break;} case 490: -#line 2332 "parse.y" +#line 2337 "parse.y" { tree t = yyvsp[-1].ttype; push_obstacks_nochange (); end_temporary_allocation (); @@ -6187,6 +6192,7 @@ case 490: yyvsp[-1].ttype = t; } if (processing_template_decl && TYPE_CONTEXT (t) + && TREE_CODE (TYPE_CONTEXT (t)) != NAMESPACE_DECL && ! current_class_type) push_template_decl (TYPE_STUB_DECL (t)); pushclass (t, 0); @@ -6255,17 +6261,17 @@ case 490: ; break;} case 491: -#line 2421 "parse.y" +#line 2427 "parse.y" { yyval.ttype = build_self_reference (); ; break;} case 492: -#line 2428 "parse.y" +#line 2434 "parse.y" { if (yyval.ttype) yyval.ttype = build_tree_list (access_public_node, yyval.ttype); ; break;} case 493: -#line 2430 "parse.y" +#line 2436 "parse.y" { if (current_aggr == signature_type_node) yyval.ttype = build_tree_list (access_public_node, yyvsp[0].ttype); @@ -6275,7 +6281,7 @@ case 493: ; break;} case 494: -#line 2438 "parse.y" +#line 2444 "parse.y" { tree visspec = yyvsp[-2].ttype; @@ -6288,19 +6294,19 @@ case 494: ; break;} case 495: -#line 2449 "parse.y" +#line 2455 "parse.y" { if (current_aggr == signature_type_node) error ("access specifier not allowed in signature"); ; break;} case 496: -#line 2459 "parse.y" +#line 2465 "parse.y" { if (yyval.ttype == void_type_node) yyval.ttype = NULL_TREE; ; break;} case 497: -#line 2462 "parse.y" +#line 2468 "parse.y" { /* In pushdecl, we created a reverse list of names in this binding level. Make sure that the chain of what we're trying to add isn't the item itself @@ -6315,45 +6321,45 @@ case 497: ; break;} case 498: -#line 2478 "parse.y" +#line 2484 "parse.y" { ; break;} case 499: -#line 2480 "parse.y" +#line 2486 "parse.y" { error ("missing ';' before right brace"); yyungetc ('}', 0); ; break;} case 500: -#line 2485 "parse.y" +#line 2491 "parse.y" { yyval.ttype = finish_method (yyval.ttype); ; break;} case 501: -#line 2487 "parse.y" +#line 2493 "parse.y" { yyval.ttype = finish_method (yyval.ttype); ; break;} case 502: -#line 2489 "parse.y" +#line 2495 "parse.y" { yyval.ttype = finish_method (yyval.ttype); ; break;} case 503: -#line 2491 "parse.y" +#line 2497 "parse.y" { yyval.ttype = finish_method (yyval.ttype); ; break;} case 504: -#line 2493 "parse.y" +#line 2499 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 505: -#line 2495 "parse.y" +#line 2501 "parse.y" { yyval.ttype = yyvsp[0].ttype; pedantic = yyvsp[-1].itype; ; break;} case 506: -#line 2498 "parse.y" +#line 2504 "parse.y" { yyval.ttype = finish_member_template_decl (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 507: -#line 2500 "parse.y" +#line 2506 "parse.y" { note_list_got_semicolon (yyvsp[-1].ftype.t); grok_x_components (yyvsp[-1].ftype.t, NULL_TREE); @@ -6365,53 +6371,53 @@ case 507: ; break;} case 508: -#line 2516 "parse.y" +#line 2522 "parse.y" { yyval.ttype = grok_x_components (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 509: -#line 2518 "parse.y" +#line 2524 "parse.y" { yyval.ttype = grok_x_components (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 510: -#line 2520 "parse.y" +#line 2526 "parse.y" { yyval.ttype = grokfield (yyval.ttype, NULL_TREE, yyvsp[0].ttype, yyvsp[-2].ttype, build_tree_list (yyvsp[-1].ttype, NULL_TREE)); ; break;} case 511: -#line 2523 "parse.y" +#line 2529 "parse.y" { yyval.ttype = grokfield (yyval.ttype, NULL_TREE, yyvsp[0].ttype, yyvsp[-2].ttype, build_tree_list (yyvsp[-1].ttype, NULL_TREE)); ; break;} case 512: -#line 2526 "parse.y" +#line 2532 "parse.y" { yyval.ttype = grokbitfield (NULL_TREE, NULL_TREE, yyvsp[0].ttype); ; break;} case 513: -#line 2528 "parse.y" +#line 2534 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 514: -#line 2539 "parse.y" +#line 2545 "parse.y" { tree specs, attrs; split_specs_attrs (yyvsp[-4].ttype, &specs, &attrs); yyval.ttype = grokfield (yyvsp[-3].ttype, specs, yyvsp[0].ttype, yyvsp[-2].ttype, build_tree_list (yyvsp[-1].ttype, attrs)); ; break;} case 515: -#line 2544 "parse.y" +#line 2550 "parse.y" { yyval.ttype = grokfield (yyval.ttype, NULL_TREE, yyvsp[0].ttype, yyvsp[-2].ttype, build_tree_list (yyvsp[-1].ttype, NULL_TREE)); ; break;} case 516: -#line 2547 "parse.y" +#line 2553 "parse.y" { yyval.ttype = do_class_using_decl (yyvsp[0].ttype); ; break;} case 517: -#line 2553 "parse.y" +#line 2559 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 519: -#line 2556 "parse.y" +#line 2562 "parse.y" { /* In this context, void_type_node encodes friends. They have been recorded elsewhere. */ @@ -6422,11 +6428,11 @@ case 519: ; break;} case 520: -#line 2568 "parse.y" +#line 2574 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 522: -#line 2571 "parse.y" +#line 2577 "parse.y" { /* In this context, void_type_node encodes friends. They have been recorded elsewhere. */ @@ -6437,7 +6443,7 @@ case 522: ; break;} case 527: -#line 2593 "parse.y" +#line 2599 "parse.y" { split_specs_attrs (yyvsp[-4].ttype, ¤t_declspecs, &prefix_attributes); yyvsp[-4].ttype = current_declspecs; @@ -6445,7 +6451,7 @@ case 527: build_tree_list (yyvsp[-1].ttype, prefix_attributes)); ; break;} case 528: -#line 2599 "parse.y" +#line 2605 "parse.y" { split_specs_attrs (yyvsp[-4].ttype, ¤t_declspecs, &prefix_attributes); yyvsp[-4].ttype = current_declspecs; @@ -6453,7 +6459,7 @@ case 528: cplus_decl_attributes (yyval.ttype, yyvsp[0].ttype, prefix_attributes); ; break;} case 529: -#line 2608 "parse.y" +#line 2614 "parse.y" { split_specs_attrs (yyvsp[-4].ttype, ¤t_declspecs, &prefix_attributes); yyvsp[-4].ttype = current_declspecs; @@ -6461,7 +6467,7 @@ case 529: build_tree_list (yyvsp[-1].ttype, prefix_attributes)); ; break;} case 530: -#line 2614 "parse.y" +#line 2620 "parse.y" { split_specs_attrs (yyvsp[-4].ttype, ¤t_declspecs, &prefix_attributes); yyvsp[-4].ttype = current_declspecs; @@ -6469,7 +6475,7 @@ case 530: build_tree_list (yyvsp[-1].ttype, prefix_attributes)); ; break;} case 531: -#line 2620 "parse.y" +#line 2626 "parse.y" { split_specs_attrs (yyvsp[-4].ttype, ¤t_declspecs, &prefix_attributes); yyvsp[-4].ttype = current_declspecs; @@ -6477,7 +6483,7 @@ case 531: cplus_decl_attributes (yyval.ttype, yyvsp[0].ttype, prefix_attributes); ; break;} case 532: -#line 2626 "parse.y" +#line 2632 "parse.y" { split_specs_attrs (yyvsp[-3].ttype, ¤t_declspecs, &prefix_attributes); yyvsp[-3].ttype = current_declspecs; @@ -6485,54 +6491,54 @@ case 532: cplus_decl_attributes (yyval.ttype, yyvsp[0].ttype, prefix_attributes); ; break;} case 533: -#line 2635 "parse.y" +#line 2641 "parse.y" { yyval.ttype = grokfield (yyval.ttype, current_declspecs, yyvsp[0].ttype, yyvsp[-2].ttype, build_tree_list (yyvsp[-1].ttype, prefix_attributes)); ; break;} case 534: -#line 2638 "parse.y" +#line 2644 "parse.y" { yyval.ttype = grokbitfield (yyval.ttype, current_declspecs, yyvsp[-1].ttype); cplus_decl_attributes (yyval.ttype, yyvsp[0].ttype, prefix_attributes); ; break;} case 535: -#line 2644 "parse.y" +#line 2650 "parse.y" { yyval.ttype = grokfield (yyval.ttype, current_declspecs, yyvsp[0].ttype, yyvsp[-2].ttype, build_tree_list (yyvsp[-1].ttype, prefix_attributes)); ; break;} case 536: -#line 2647 "parse.y" +#line 2653 "parse.y" { yyval.ttype = grokbitfield (yyval.ttype, current_declspecs, yyvsp[-1].ttype); cplus_decl_attributes (yyval.ttype, yyvsp[0].ttype, prefix_attributes); ; break;} case 537: -#line 2650 "parse.y" +#line 2656 "parse.y" { yyval.ttype = grokbitfield (NULL_TREE, current_declspecs, yyvsp[-1].ttype); cplus_decl_attributes (yyval.ttype, yyvsp[0].ttype, prefix_attributes); ; break;} case 539: -#line 2661 "parse.y" +#line 2667 "parse.y" { TREE_CHAIN (yyvsp[0].ttype) = yyval.ttype; yyval.ttype = yyvsp[0].ttype; ; break;} case 540: -#line 2666 "parse.y" +#line 2672 "parse.y" { yyval.ttype = build_enumerator (yyval.ttype, NULL_TREE); ; break;} case 541: -#line 2668 "parse.y" +#line 2674 "parse.y" { yyval.ttype = build_enumerator (yyval.ttype, yyvsp[0].ttype); ; break;} case 542: -#line 2674 "parse.y" +#line 2680 "parse.y" { yyval.ftype.t = build_decl_list (yyvsp[-1].ftype.t, yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 543: -#line 2677 "parse.y" +#line 2683 "parse.y" { yyval.ftype.t = build_decl_list (yyvsp[0].ftype.t, NULL_TREE); yyval.ftype.new_type_flag = yyvsp[0].ftype.new_type_flag; ; break;} case 544: -#line 2682 "parse.y" +#line 2688 "parse.y" { if (pedantic) pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new"); @@ -6542,71 +6548,71 @@ case 544: ; break;} case 545: -#line 2693 "parse.y" +#line 2699 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 546: -#line 2695 "parse.y" +#line 2701 "parse.y" { yyval.ttype = decl_tree_cons (NULL_TREE, yyvsp[0].ttype, yyval.ttype); ; break;} case 547: -#line 2700 "parse.y" +#line 2706 "parse.y" { yyval.ftype.t = IDENTIFIER_AS_LIST (yyvsp[0].ttype); yyval.ftype.new_type_flag = 0; ; break;} case 548: -#line 2703 "parse.y" +#line 2709 "parse.y" { yyval.ftype.t = decl_tree_cons (NULL_TREE, yyvsp[0].ttype, yyvsp[-1].ftype.t); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 549: -#line 2712 "parse.y" +#line 2718 "parse.y" { yyval.itype = suspend_momentary (); ; break;} case 550: -#line 2717 "parse.y" +#line 2723 "parse.y" { resume_momentary ((int) yyvsp[-1].itype); yyval.ttype = yyvsp[0].ttype; ; break;} case 551: -#line 2723 "parse.y" +#line 2729 "parse.y" { resume_momentary ((int) yyvsp[-3].itype); yyval.ttype = yyvsp[-1].ttype; ; break;} case 552: -#line 2725 "parse.y" +#line 2731 "parse.y" { resume_momentary ((int) yyvsp[-3].itype); yyval.ttype = yyvsp[-1].ttype; ; break;} case 553: -#line 2727 "parse.y" +#line 2733 "parse.y" { resume_momentary ((int) yyvsp[-1].itype); yyval.ttype = empty_parms (); ; break;} case 554: -#line 2729 "parse.y" +#line 2735 "parse.y" { resume_momentary ((int) yyvsp[-3].itype); yyval.ttype = NULL_TREE; ; break;} case 555: -#line 2736 "parse.y" +#line 2742 "parse.y" { yyval.ttype = make_pointer_declarator (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 556: -#line 2738 "parse.y" +#line 2744 "parse.y" { yyval.ttype = make_reference_declarator (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 557: -#line 2740 "parse.y" +#line 2746 "parse.y" { yyval.ttype = make_pointer_declarator (NULL_TREE, yyvsp[0].ttype); ; break;} case 558: -#line 2742 "parse.y" +#line 2748 "parse.y" { yyval.ttype = make_reference_declarator (NULL_TREE, yyvsp[0].ttype); ; break;} case 559: -#line 2744 "parse.y" +#line 2750 "parse.y" { tree arg = make_pointer_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-2].ttype, arg); ; break;} case 561: -#line 2752 "parse.y" +#line 2758 "parse.y" { if (TREE_CODE (yyvsp[0].ttype) == IDENTIFIER_NODE) { @@ -6625,7 +6631,7 @@ case 561: ; break;} case 562: -#line 2769 "parse.y" +#line 2775 "parse.y" { if (TREE_CODE (yyvsp[0].ttype) == IDENTIFIER_NODE) yyval.ttype = IDENTIFIER_GLOBAL_VALUE (yyvsp[0].ttype); @@ -6635,97 +6641,97 @@ case 562: ; break;} case 565: -#line 2782 "parse.y" +#line 2788 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 566: -#line 2787 "parse.y" +#line 2793 "parse.y" { yyval.ttype = get_type_decl (yyvsp[0].ttype); ; break;} case 567: -#line 2792 "parse.y" +#line 2798 "parse.y" { yyval.ttype = make_call_declarator (yyval.ttype, yyvsp[-2].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 568: -#line 2794 "parse.y" +#line 2800 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, yyval.ttype, yyvsp[-1].ttype); ; break;} case 569: -#line 2796 "parse.y" +#line 2802 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, yyval.ttype, NULL_TREE); ; break;} case 570: -#line 2798 "parse.y" +#line 2804 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 571: -#line 2800 "parse.y" +#line 2806 "parse.y" { push_nested_class (yyvsp[-1].ttype, 3); yyval.ttype = build_parse_node (SCOPE_REF, yyval.ttype, yyvsp[0].ttype); TREE_COMPLEXITY (yyval.ttype) = current_class_depth; ; break;} case 573: -#line 2811 "parse.y" +#line 2817 "parse.y" { yyval.ttype = make_pointer_declarator (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 574: -#line 2813 "parse.y" +#line 2819 "parse.y" { yyval.ttype = make_reference_declarator (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 575: -#line 2815 "parse.y" +#line 2821 "parse.y" { yyval.ttype = make_pointer_declarator (NULL_TREE, yyvsp[0].ttype); ; break;} case 576: -#line 2817 "parse.y" +#line 2823 "parse.y" { yyval.ttype = make_reference_declarator (NULL_TREE, yyvsp[0].ttype); ; break;} case 577: -#line 2819 "parse.y" +#line 2825 "parse.y" { tree arg = make_pointer_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-2].ttype, arg); ; break;} case 579: -#line 2827 "parse.y" +#line 2833 "parse.y" { yyval.ttype = make_pointer_declarator (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 580: -#line 2829 "parse.y" +#line 2835 "parse.y" { yyval.ttype = make_reference_declarator (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 581: -#line 2831 "parse.y" +#line 2837 "parse.y" { yyval.ttype = make_pointer_declarator (NULL_TREE, yyvsp[0].ttype); ; break;} case 582: -#line 2833 "parse.y" +#line 2839 "parse.y" { yyval.ttype = make_reference_declarator (NULL_TREE, yyvsp[0].ttype); ; break;} case 583: -#line 2835 "parse.y" +#line 2841 "parse.y" { tree arg = make_pointer_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-2].ttype, arg); ; break;} case 585: -#line 2843 "parse.y" +#line 2849 "parse.y" { yyval.ttype = make_call_declarator (yyval.ttype, yyvsp[-2].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 586: -#line 2845 "parse.y" +#line 2851 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 587: -#line 2847 "parse.y" +#line 2853 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, yyval.ttype, yyvsp[-1].ttype); ; break;} case 588: -#line 2849 "parse.y" +#line 2855 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, yyval.ttype, NULL_TREE); ; break;} case 589: -#line 2851 "parse.y" +#line 2857 "parse.y" { if (OP0 (yyval.ttype) != current_class_type) { push_nested_class (OP0 (yyval.ttype), 3); @@ -6734,7 +6740,7 @@ case 589: ; break;} case 590: -#line 2858 "parse.y" +#line 2864 "parse.y" { got_scope = NULL_TREE; yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-1].ttype, yyvsp[0].ttype); if (yyvsp[-1].ttype != current_class_type) @@ -6745,51 +6751,51 @@ case 590: ; break;} case 591: -#line 2870 "parse.y" +#line 2876 "parse.y" { got_scope = NULL_TREE; yyval.ttype = build_parse_node (SCOPE_REF, yyval.ttype, yyvsp[0].ttype); ; break;} case 592: -#line 2873 "parse.y" +#line 2879 "parse.y" { got_scope = NULL_TREE; yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 593: -#line 2879 "parse.y" +#line 2885 "parse.y" { got_scope = NULL_TREE; yyval.ttype = build_parse_node (SCOPE_REF, yyval.ttype, yyvsp[0].ttype); ; break;} case 594: -#line 2882 "parse.y" +#line 2888 "parse.y" { got_scope = NULL_TREE; yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 596: -#line 2889 "parse.y" +#line 2895 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 597: -#line 2894 "parse.y" +#line 2900 "parse.y" { yyval.ttype = build_functional_cast (yyvsp[-3].ftype.t, yyvsp[-1].ttype); ; break;} case 598: -#line 2896 "parse.y" +#line 2902 "parse.y" { yyval.ttype = reparse_decl_as_expr (yyvsp[-3].ftype.t, yyvsp[-1].ttype); ; break;} case 599: -#line 2898 "parse.y" +#line 2904 "parse.y" { yyval.ttype = reparse_absdcl_as_expr (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 604: -#line 2910 "parse.y" +#line 2916 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 605: -#line 2912 "parse.y" +#line 2918 "parse.y" { got_scope = yyval.ttype = make_typename_type (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 606: -#line 2919 "parse.y" +#line 2925 "parse.y" { if (TREE_CODE (yyvsp[-1].ttype) == IDENTIFIER_NODE) { @@ -6805,7 +6811,7 @@ case 606: ; break;} case 607: -#line 2933 "parse.y" +#line 2939 "parse.y" { if (TREE_CODE (yyvsp[-1].ttype) == IDENTIFIER_NODE) yyval.ttype = lastiddecl; @@ -6813,7 +6819,7 @@ case 607: ; break;} case 608: -#line 2939 "parse.y" +#line 2945 "parse.y" { if (TREE_CODE (yyval.ttype) == IDENTIFIER_NODE) yyval.ttype = lastiddecl; @@ -6821,15 +6827,15 @@ case 608: ; break;} case 609: -#line 2945 "parse.y" +#line 2951 "parse.y" { got_scope = yyval.ttype = complete_type (TREE_TYPE (yyvsp[-1].ttype)); ; break;} case 611: -#line 2961 "parse.y" +#line 2967 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 612: -#line 2966 "parse.y" +#line 2972 "parse.y" { if (TREE_CODE_CLASS (TREE_CODE (yyvsp[-1].ttype)) == 't') yyval.ttype = make_typename_type (yyvsp[-1].ttype, yyvsp[0].ttype); @@ -6844,26 +6850,26 @@ case 612: ; break;} case 613: -#line 2979 "parse.y" +#line 2985 "parse.y" { yyval.ttype = TREE_TYPE (yyvsp[0].ttype); ; break;} case 614: -#line 2981 "parse.y" +#line 2987 "parse.y" { yyval.ttype = make_typename_type (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 615: -#line 2983 "parse.y" +#line 2989 "parse.y" { yyval.ttype = make_typename_type (yyvsp[-2].ttype, yyvsp[0].ttype); ; break;} case 616: -#line 2988 "parse.y" +#line 2994 "parse.y" { if (TREE_CODE (yyvsp[0].ttype) == IDENTIFIER_NODE) cp_error ("`%T' is not a class or namespace", yyvsp[0].ttype); ; break;} case 617: -#line 2993 "parse.y" +#line 2999 "parse.y" { if (TREE_CODE_CLASS (TREE_CODE (yyvsp[-1].ttype)) == 't') yyval.ttype = make_typename_type (yyvsp[-1].ttype, yyvsp[0].ttype); @@ -6878,27 +6884,29 @@ case 617: ; break;} case 618: -#line 3006 "parse.y" +#line 3012 "parse.y" { got_scope = yyval.ttype = make_typename_type (yyvsp[-2].ttype, yyvsp[-1].ttype); ; break;} case 619: -#line 3008 "parse.y" +#line 3014 "parse.y" { got_scope = yyval.ttype = make_typename_type (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 620: -#line 3013 "parse.y" +#line 3019 "parse.y" { if (TREE_CODE (yyvsp[-1].ttype) != IDENTIFIER_NODE) yyvsp[-1].ttype = lastiddecl; - got_scope = yyval.ttype = complete_type (TREE_TYPE (yyvsp[-1].ttype)); + /* Retrieve the type for the identifier, which might involve + some computation. */ + got_scope = yyval.ttype = complete_type (IDENTIFIER_TYPE_VALUE (yyvsp[-1].ttype)); if (yyval.ttype == error_mark_node) cp_error ("`%T' is not a class or namespace", yyvsp[-1].ttype); ; break;} case 621: -#line 3023 "parse.y" +#line 3031 "parse.y" { if (TREE_CODE (yyvsp[-1].ttype) != IDENTIFIER_NODE) yyval.ttype = lastiddecl; @@ -6906,11 +6914,11 @@ case 621: ; break;} case 622: -#line 3029 "parse.y" +#line 3037 "parse.y" { got_scope = yyval.ttype = complete_type (TREE_TYPE (yyval.ttype)); ; break;} case 625: -#line 3033 "parse.y" +#line 3041 "parse.y" { if (TREE_CODE (yyval.ttype) == IDENTIFIER_NODE) yyval.ttype = lastiddecl; @@ -6918,11 +6926,11 @@ case 625: ; break;} case 626: -#line 3042 "parse.y" +#line 3050 "parse.y" { yyval.ttype = build_min_nt (TEMPLATE_ID_EXPR, yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 627: -#line 3047 "parse.y" +#line 3055 "parse.y" { if (TREE_CODE (yyvsp[0].ttype) == IDENTIFIER_NODE) yyval.ttype = IDENTIFIER_GLOBAL_VALUE (yyvsp[0].ttype); @@ -6932,148 +6940,148 @@ case 627: ; break;} case 629: -#line 3056 "parse.y" +#line 3064 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 630: -#line 3061 "parse.y" +#line 3069 "parse.y" { got_scope = NULL_TREE; ; break;} case 631: -#line 3063 "parse.y" +#line 3071 "parse.y" { yyval.ttype = yyvsp[-1].ttype; got_scope = NULL_TREE; ; break;} case 632: -#line 3070 "parse.y" +#line 3078 "parse.y" { got_scope = void_type_node; ; break;} case 633: -#line 3076 "parse.y" +#line 3084 "parse.y" { yyval.ttype = make_pointer_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 634: -#line 3078 "parse.y" +#line 3086 "parse.y" { yyval.ttype = make_pointer_declarator (yyvsp[0].ttype, NULL_TREE); ; break;} case 635: -#line 3080 "parse.y" +#line 3088 "parse.y" { yyval.ttype = make_reference_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 636: -#line 3082 "parse.y" +#line 3090 "parse.y" { yyval.ttype = make_reference_declarator (yyvsp[0].ttype, NULL_TREE); ; break;} case 637: -#line 3084 "parse.y" +#line 3092 "parse.y" { tree arg = make_pointer_declarator (yyvsp[0].ttype, NULL_TREE); yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-1].ttype, arg); ; break;} case 638: -#line 3088 "parse.y" +#line 3096 "parse.y" { tree arg = make_pointer_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-2].ttype, arg); ; break;} case 640: -#line 3097 "parse.y" +#line 3105 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, NULL_TREE, yyvsp[-1].ttype); ; break;} case 641: -#line 3099 "parse.y" +#line 3107 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, yyval.ttype, yyvsp[-1].ttype); ; break;} case 642: -#line 3105 "parse.y" +#line 3113 "parse.y" { yyval.ttype = make_pointer_declarator (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 643: -#line 3107 "parse.y" +#line 3115 "parse.y" { yyval.ttype = make_pointer_declarator (NULL_TREE, yyvsp[0].ttype); ; break;} case 644: -#line 3109 "parse.y" +#line 3117 "parse.y" { yyval.ttype = make_pointer_declarator (yyvsp[0].ftype.t, NULL_TREE); ; break;} case 645: -#line 3111 "parse.y" +#line 3119 "parse.y" { yyval.ttype = make_pointer_declarator (NULL_TREE, NULL_TREE); ; break;} case 646: -#line 3113 "parse.y" +#line 3121 "parse.y" { yyval.ttype = make_reference_declarator (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 647: -#line 3115 "parse.y" +#line 3123 "parse.y" { yyval.ttype = make_reference_declarator (NULL_TREE, yyvsp[0].ttype); ; break;} case 648: -#line 3117 "parse.y" +#line 3125 "parse.y" { yyval.ttype = make_reference_declarator (yyvsp[0].ftype.t, NULL_TREE); ; break;} case 649: -#line 3119 "parse.y" +#line 3127 "parse.y" { yyval.ttype = make_reference_declarator (NULL_TREE, NULL_TREE); ; break;} case 650: -#line 3121 "parse.y" +#line 3129 "parse.y" { tree arg = make_pointer_declarator (yyvsp[0].ttype, NULL_TREE); yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-1].ttype, arg); ; break;} case 651: -#line 3125 "parse.y" +#line 3133 "parse.y" { tree arg = make_pointer_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-2].ttype, arg); ; break;} case 653: -#line 3134 "parse.y" +#line 3142 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 655: -#line 3138 "parse.y" +#line 3146 "parse.y" { yyval.ttype = make_call_declarator (yyval.ttype, yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 656: -#line 3140 "parse.y" +#line 3148 "parse.y" { yyval.ttype = make_call_declarator (yyval.ttype, empty_parms (), yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 657: -#line 3142 "parse.y" +#line 3150 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, yyval.ttype, yyvsp[-1].ttype); ; break;} case 658: -#line 3144 "parse.y" +#line 3152 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, yyval.ttype, NULL_TREE); ; break;} case 659: -#line 3146 "parse.y" +#line 3154 "parse.y" { yyval.ttype = make_call_declarator (NULL_TREE, yyvsp[-3].ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 660: -#line 3148 "parse.y" +#line 3156 "parse.y" { set_quals_and_spec (yyval.ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 661: -#line 3150 "parse.y" +#line 3158 "parse.y" { set_quals_and_spec (yyval.ttype, yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 662: -#line 3152 "parse.y" +#line 3160 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, NULL_TREE, yyvsp[-1].ttype); ; break;} case 663: -#line 3154 "parse.y" +#line 3162 "parse.y" { yyval.ttype = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); ; break;} case 670: -#line 3177 "parse.y" +#line 3185 "parse.y" { if (pedantic) pedwarn ("ANSI C++ forbids label declarations"); ; break;} case 673: -#line 3188 "parse.y" +#line 3196 "parse.y" { tree link; for (link = yyvsp[-1].ttype; link; link = TREE_CHAIN (link)) { @@ -7084,181 +7092,181 @@ case 673: ; break;} case 674: -#line 3202 "parse.y" +#line 3210 "parse.y" {; break;} case 676: -#line 3208 "parse.y" +#line 3216 "parse.y" { yyval.ttype = begin_compound_stmt (0); ; break;} case 677: -#line 3210 "parse.y" +#line 3218 "parse.y" { yyval.ttype = finish_compound_stmt (0, yyvsp[-1].ttype); ; break;} case 678: -#line 3215 "parse.y" +#line 3223 "parse.y" { yyval.ttype = begin_if_stmt (); cond_stmt_keyword = "if"; ; break;} case 679: -#line 3220 "parse.y" +#line 3228 "parse.y" { finish_if_stmt_cond (yyvsp[0].ttype, yyvsp[-1].ttype); ; break;} case 680: -#line 3222 "parse.y" +#line 3230 "parse.y" { yyval.ttype = finish_then_clause (yyvsp[-3].ttype); ; break;} case 682: -#line 3227 "parse.y" +#line 3235 "parse.y" { yyval.ttype = begin_compound_stmt (0); ; break;} case 683: -#line 3229 "parse.y" +#line 3237 "parse.y" { yyval.ttype = finish_compound_stmt (0, yyvsp[-1].ttype); ; break;} case 684: -#line 3234 "parse.y" +#line 3242 "parse.y" {; break;} case 686: -#line 3240 "parse.y" +#line 3248 "parse.y" { finish_stmt (); ; break;} case 687: -#line 3242 "parse.y" +#line 3250 "parse.y" { finish_expr_stmt (yyvsp[-1].ttype); ; break;} case 688: -#line 3244 "parse.y" +#line 3252 "parse.y" { begin_else_clause (); ; break;} case 689: -#line 3246 "parse.y" +#line 3254 "parse.y" { finish_else_clause (yyvsp[-3].ttype); finish_if_stmt (); ; break;} case 690: -#line 3251 "parse.y" +#line 3259 "parse.y" { finish_if_stmt (); ; break;} case 691: -#line 3253 "parse.y" +#line 3261 "parse.y" { yyval.ttype = begin_while_stmt (); cond_stmt_keyword = "while"; ; break;} case 692: -#line 3258 "parse.y" +#line 3266 "parse.y" { finish_while_stmt_cond (yyvsp[0].ttype, yyvsp[-1].ttype); ; break;} case 693: -#line 3260 "parse.y" +#line 3268 "parse.y" { finish_while_stmt (yyvsp[-3].ttype); ; break;} case 694: -#line 3262 "parse.y" +#line 3270 "parse.y" { yyval.ttype = begin_do_stmt (); ; break;} case 695: -#line 3264 "parse.y" +#line 3272 "parse.y" { finish_do_body (yyvsp[-2].ttype); cond_stmt_keyword = "do"; ; break;} case 696: -#line 3269 "parse.y" +#line 3277 "parse.y" { finish_do_stmt (yyvsp[-1].ttype, yyvsp[-5].ttype); ; break;} case 697: -#line 3271 "parse.y" +#line 3279 "parse.y" { yyval.ttype = begin_for_stmt (); ; break;} case 698: -#line 3273 "parse.y" +#line 3281 "parse.y" { finish_for_init_stmt (yyvsp[-2].ttype); ; break;} case 699: -#line 3275 "parse.y" +#line 3283 "parse.y" { finish_for_cond (yyvsp[-1].ttype, yyvsp[-5].ttype); ; break;} case 700: -#line 3277 "parse.y" +#line 3285 "parse.y" { finish_for_expr (yyvsp[-1].ttype, yyvsp[-8].ttype); ; break;} case 701: -#line 3279 "parse.y" +#line 3287 "parse.y" { finish_for_stmt (yyvsp[-3].ttype, yyvsp[-10].ttype); ; break;} case 702: -#line 3281 "parse.y" +#line 3289 "parse.y" { begin_switch_stmt (); ; break;} case 703: -#line 3283 "parse.y" +#line 3291 "parse.y" { yyval.ttype = finish_switch_cond (yyvsp[-1].ttype); ; break;} case 704: -#line 3285 "parse.y" +#line 3293 "parse.y" { finish_switch_stmt (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 705: -#line 3287 "parse.y" +#line 3295 "parse.y" { finish_case_label (yyvsp[-1].ttype, NULL_TREE); ; break;} case 707: -#line 3290 "parse.y" +#line 3298 "parse.y" { finish_case_label (yyvsp[-3].ttype, yyvsp[-1].ttype); ; break;} case 709: -#line 3293 "parse.y" +#line 3301 "parse.y" { finish_case_label (NULL_TREE, NULL_TREE); ; break;} case 711: -#line 3296 "parse.y" +#line 3304 "parse.y" { finish_break_stmt (); ; break;} case 712: -#line 3298 "parse.y" +#line 3306 "parse.y" { finish_continue_stmt (); ; break;} case 713: -#line 3300 "parse.y" +#line 3308 "parse.y" { finish_return_stmt (NULL_TREE); ; break;} case 714: -#line 3302 "parse.y" +#line 3310 "parse.y" { finish_return_stmt (yyvsp[-1].ttype); ; break;} case 715: -#line 3304 "parse.y" +#line 3312 "parse.y" { finish_asm_stmt (yyvsp[-4].ttype, yyvsp[-2].ttype, NULL_TREE, NULL_TREE, NULL_TREE); ; break;} case 716: -#line 3310 "parse.y" +#line 3318 "parse.y" { finish_asm_stmt (yyvsp[-6].ttype, yyvsp[-4].ttype, yyvsp[-2].ttype, NULL_TREE, NULL_TREE); ; break;} case 717: -#line 3316 "parse.y" +#line 3324 "parse.y" { finish_asm_stmt (yyvsp[-8].ttype, yyvsp[-6].ttype, yyvsp[-4].ttype, yyvsp[-2].ttype, NULL_TREE); ; break;} case 718: -#line 3320 "parse.y" +#line 3328 "parse.y" { finish_asm_stmt (yyvsp[-10].ttype, yyvsp[-8].ttype, yyvsp[-6].ttype, yyvsp[-4].ttype, yyvsp[-2].ttype); ; break;} case 719: -#line 3322 "parse.y" +#line 3330 "parse.y" { if (pedantic) pedwarn ("ANSI C++ forbids computed gotos"); @@ -7266,25 +7274,25 @@ case 719: ; break;} case 720: -#line 3328 "parse.y" +#line 3336 "parse.y" { finish_goto_stmt (yyvsp[-1].ttype); ; break;} case 721: -#line 3330 "parse.y" +#line 3338 "parse.y" { finish_stmt (); ; break;} case 722: -#line 3332 "parse.y" +#line 3340 "parse.y" { error ("label must be followed by statement"); yyungetc ('}', 0); finish_stmt (); ; break;} case 723: -#line 3336 "parse.y" +#line 3344 "parse.y" { finish_stmt (); ; break;} case 725: -#line 3342 "parse.y" +#line 3350 "parse.y" { if (! current_function_parms_stored) store_parm_decls (); @@ -7292,11 +7300,11 @@ case 725: ; break;} case 726: -#line 3348 "parse.y" +#line 3356 "parse.y" { expand_start_all_catch (); ; break;} case 727: -#line 3350 "parse.y" +#line 3358 "parse.y" { int nested = (hack_decl_function_context (current_function_decl) != NULL_TREE); @@ -7305,41 +7313,41 @@ case 727: ; break;} case 728: -#line 3360 "parse.y" +#line 3368 "parse.y" { yyval.ttype = begin_try_block (); ; break;} case 729: -#line 3362 "parse.y" +#line 3370 "parse.y" { finish_try_block (yyvsp[-1].ttype); ; break;} case 730: -#line 3364 "parse.y" +#line 3372 "parse.y" { finish_handler_sequence (yyvsp[-3].ttype); ; break;} case 733: -#line 3374 "parse.y" +#line 3382 "parse.y" { yyval.ttype = begin_handler(); ; break;} case 734: -#line 3376 "parse.y" +#line 3384 "parse.y" { finish_handler_parms (yyvsp[-1].ttype); ; break;} case 735: -#line 3378 "parse.y" +#line 3386 "parse.y" { finish_handler (yyvsp[-3].ttype); ; break;} case 738: -#line 3388 "parse.y" +#line 3396 "parse.y" { expand_start_catch_block (NULL_TREE, NULL_TREE); ; break;} case 739: -#line 3404 "parse.y" +#line 3412 "parse.y" { check_for_new_type ("inside exception declarations", yyvsp[-1].ftype); expand_start_catch_block (TREE_PURPOSE (yyvsp[-1].ftype.t), TREE_VALUE (yyvsp[-1].ftype.t)); ; break;} case 740: -#line 3411 "parse.y" +#line 3419 "parse.y" { tree label; do_label: label = define_label (input_filename, lineno, yyvsp[-1].ttype); @@ -7348,129 +7356,129 @@ case 740: ; break;} case 741: -#line 3418 "parse.y" +#line 3426 "parse.y" { goto do_label; ; break;} case 742: -#line 3420 "parse.y" +#line 3428 "parse.y" { goto do_label; ; break;} case 743: -#line 3422 "parse.y" +#line 3430 "parse.y" { goto do_label; ; break;} case 744: -#line 3427 "parse.y" +#line 3435 "parse.y" { if (yyvsp[-1].ttype) cplus_expand_expr_stmt (yyvsp[-1].ttype); ; break;} case 746: -#line 3430 "parse.y" +#line 3438 "parse.y" { if (pedantic) pedwarn ("ANSI C++ forbids compound statements inside for initializations"); ; break;} case 747: -#line 3439 "parse.y" +#line 3447 "parse.y" { emit_line_note (input_filename, lineno); yyval.ttype = NULL_TREE; ; break;} case 748: -#line 3442 "parse.y" +#line 3450 "parse.y" { emit_line_note (input_filename, lineno); ; break;} case 749: -#line 3447 "parse.y" +#line 3455 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 751: -#line 3450 "parse.y" +#line 3458 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 752: -#line 3457 "parse.y" +#line 3465 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 755: -#line 3464 "parse.y" +#line 3472 "parse.y" { yyval.ttype = chainon (yyval.ttype, yyvsp[0].ttype); ; break;} case 756: -#line 3469 "parse.y" +#line 3477 "parse.y" { yyval.ttype = build_tree_list (yyval.ttype, yyvsp[-1].ttype); ; break;} case 757: -#line 3474 "parse.y" +#line 3482 "parse.y" { yyval.ttype = tree_cons (NULL_TREE, yyval.ttype, NULL_TREE); ; break;} case 758: -#line 3476 "parse.y" +#line 3484 "parse.y" { yyval.ttype = tree_cons (NULL_TREE, yyvsp[0].ttype, yyval.ttype); ; break;} case 759: -#line 3487 "parse.y" +#line 3495 "parse.y" { yyval.ttype = empty_parms(); ; break;} case 761: -#line 3492 "parse.y" +#line 3500 "parse.y" { yyval.ttype = tree_cons (NULL_TREE, yyvsp[0].ftype.t, void_list_node); TREE_PARMLIST (yyval.ttype) = 1; check_for_new_type ("inside parameter list", yyvsp[0].ftype); ; break;} case 762: -#line 3501 "parse.y" +#line 3509 "parse.y" { yyval.ttype = chainon (yyval.ttype, void_list_node); TREE_PARMLIST (yyval.ttype) = 1; ; break;} case 763: -#line 3506 "parse.y" +#line 3514 "parse.y" { TREE_PARMLIST (yyval.ttype) = 1; ; break;} case 764: -#line 3511 "parse.y" +#line 3519 "parse.y" { TREE_PARMLIST (yyval.ttype) = 1; ; break;} case 765: -#line 3515 "parse.y" +#line 3523 "parse.y" { yyval.ttype = build_tree_list (NULL_TREE, yyvsp[-1].ftype.t); TREE_PARMLIST (yyval.ttype) = 1; ; break;} case 766: -#line 3520 "parse.y" +#line 3528 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 767: -#line 3524 "parse.y" +#line 3532 "parse.y" { TREE_PARMLIST (yyval.ttype) = 1; ; break;} case 768: -#line 3528 "parse.y" +#line 3536 "parse.y" { TREE_PARMLIST (yyval.ttype) = 1; ; break;} case 769: -#line 3532 "parse.y" +#line 3540 "parse.y" { yyval.ttype = build_tree_list (NULL_TREE, yyvsp[-1].ftype.t); TREE_PARMLIST (yyval.ttype) = 1; ; break;} case 770: -#line 3537 "parse.y" +#line 3545 "parse.y" { /* This helps us recover from really nasty parse errors, for example, a missing right @@ -7483,7 +7491,7 @@ case 770: ; break;} case 771: -#line 3548 "parse.y" +#line 3556 "parse.y" { /* This helps us recover from really nasty parse errors, for example, a missing right @@ -7496,98 +7504,98 @@ case 771: ; break;} case 772: -#line 3563 "parse.y" +#line 3571 "parse.y" { maybe_snarf_defarg (); ; break;} case 773: -#line 3565 "parse.y" +#line 3573 "parse.y" { yyval.ttype = yyvsp[0].ttype; ; break;} case 776: -#line 3576 "parse.y" +#line 3584 "parse.y" { check_for_new_type ("in a parameter list", yyvsp[0].ftype); yyval.ttype = build_tree_list (NULL_TREE, yyvsp[0].ftype.t); ; break;} case 777: -#line 3579 "parse.y" +#line 3587 "parse.y" { check_for_new_type ("in a parameter list", yyvsp[-1].ftype); yyval.ttype = build_tree_list (yyvsp[0].ttype, yyvsp[-1].ftype.t); ; break;} case 778: -#line 3582 "parse.y" +#line 3590 "parse.y" { check_for_new_type ("in a parameter list", yyvsp[0].ftype); yyval.ttype = chainon (yyval.ttype, yyvsp[0].ftype.t); ; break;} case 779: -#line 3585 "parse.y" +#line 3593 "parse.y" { yyval.ttype = chainon (yyval.ttype, build_tree_list (NULL_TREE, yyvsp[0].ttype)); ; break;} case 780: -#line 3587 "parse.y" +#line 3595 "parse.y" { yyval.ttype = chainon (yyval.ttype, build_tree_list (yyvsp[0].ttype, yyvsp[-2].ttype)); ; break;} case 782: -#line 3593 "parse.y" +#line 3601 "parse.y" { check_for_new_type ("in a parameter list", yyvsp[-1].ftype); yyval.ttype = build_tree_list (NULL_TREE, yyvsp[-1].ftype.t); ; break;} case 783: -#line 3603 "parse.y" +#line 3611 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ftype.t); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; yyval.ftype.t = build_tree_list (specs, yyvsp[0].ttype); ; break;} case 784: -#line 3607 "parse.y" +#line 3615 "parse.y" { yyval.ftype.t = build_tree_list (yyvsp[-1].ftype.t, yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 785: -#line 3610 "parse.y" +#line 3618 "parse.y" { yyval.ftype.t = build_tree_list (get_decl_list (yyvsp[-1].ftype.t), yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 786: -#line 3613 "parse.y" +#line 3621 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ftype.t); yyval.ftype.t = build_tree_list (specs, yyvsp[0].ttype); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 787: -#line 3617 "parse.y" +#line 3625 "parse.y" { tree specs = strip_attrs (yyvsp[0].ftype.t); yyval.ftype.t = build_tree_list (specs, NULL_TREE); yyval.ftype.new_type_flag = yyvsp[0].ftype.new_type_flag; ; break;} case 788: -#line 3621 "parse.y" +#line 3629 "parse.y" { tree specs = strip_attrs (yyvsp[-1].ttype); yyval.ftype.t = build_tree_list (specs, yyvsp[0].ttype); yyval.ftype.new_type_flag = 0; ; break;} case 789: -#line 3628 "parse.y" +#line 3636 "parse.y" { yyval.ftype.t = build_tree_list (NULL_TREE, yyvsp[0].ftype.t); yyval.ftype.new_type_flag = yyvsp[0].ftype.new_type_flag; ; break;} case 790: -#line 3631 "parse.y" +#line 3639 "parse.y" { yyval.ftype.t = build_tree_list (yyvsp[0].ttype, yyvsp[-1].ftype.t); yyval.ftype.new_type_flag = yyvsp[-1].ftype.new_type_flag; ; break;} case 793: -#line 3642 "parse.y" +#line 3650 "parse.y" { see_typename (); ; break;} case 794: -#line 3647 "parse.y" +#line 3655 "parse.y" { error ("type specifier omitted for parameter"); yyval.ttype = build_tree_list (integer_type_node, NULL_TREE); ; break;} case 795: -#line 3652 "parse.y" +#line 3660 "parse.y" { error ("type specifier omitted for parameter"); if (TREE_CODE (yyval.ttype) == SCOPE_REF @@ -7598,188 +7606,188 @@ case 795: ; break;} case 796: -#line 3664 "parse.y" +#line 3672 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 797: -#line 3666 "parse.y" +#line 3674 "parse.y" { yyval.ttype = yyvsp[-1].ttype; ; break;} case 798: -#line 3668 "parse.y" +#line 3676 "parse.y" { yyval.ttype = build_decl_list (NULL_TREE, NULL_TREE); ; break;} case 799: -#line 3673 "parse.y" +#line 3681 "parse.y" { yyval.ttype = build_decl_list (NULL_TREE, groktypename(yyvsp[0].ftype.t)); ; break;} case 801: -#line 3679 "parse.y" +#line 3687 "parse.y" { TREE_CHAIN (yyvsp[0].ttype) = yyval.ttype; yyval.ttype = yyvsp[0].ttype; ; break;} case 802: -#line 3687 "parse.y" +#line 3695 "parse.y" { yyval.ttype = NULL_TREE; ; break;} case 803: -#line 3689 "parse.y" +#line 3697 "parse.y" { yyval.ttype = make_pointer_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 804: -#line 3691 "parse.y" +#line 3699 "parse.y" { yyval.ttype = make_reference_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); ; break;} case 805: -#line 3693 "parse.y" +#line 3701 "parse.y" { tree arg = make_pointer_declarator (yyvsp[-1].ttype, yyvsp[0].ttype); yyval.ttype = build_parse_node (SCOPE_REF, yyvsp[-2].ttype, arg); ; break;} case 806: -#line 3700 "parse.y" +#line 3708 "parse.y" { got_scope = NULL_TREE; ; break;} case 807: -#line 3705 "parse.y" +#line 3713 "parse.y" { yyval.ttype = ansi_opname[MULT_EXPR]; ; break;} case 808: -#line 3707 "parse.y" +#line 3715 "parse.y" { yyval.ttype = ansi_opname[TRUNC_DIV_EXPR]; ; break;} case 809: -#line 3709 "parse.y" +#line 3717 "parse.y" { yyval.ttype = ansi_opname[TRUNC_MOD_EXPR]; ; break;} case 810: -#line 3711 "parse.y" +#line 3719 "parse.y" { yyval.ttype = ansi_opname[PLUS_EXPR]; ; break;} case 811: -#line 3713 "parse.y" +#line 3721 "parse.y" { yyval.ttype = ansi_opname[MINUS_EXPR]; ; break;} case 812: -#line 3715 "parse.y" +#line 3723 "parse.y" { yyval.ttype = ansi_opname[BIT_AND_EXPR]; ; break;} case 813: -#line 3717 "parse.y" +#line 3725 "parse.y" { yyval.ttype = ansi_opname[BIT_IOR_EXPR]; ; break;} case 814: -#line 3719 "parse.y" +#line 3727 "parse.y" { yyval.ttype = ansi_opname[BIT_XOR_EXPR]; ; break;} case 815: -#line 3721 "parse.y" +#line 3729 "parse.y" { yyval.ttype = ansi_opname[BIT_NOT_EXPR]; ; break;} case 816: -#line 3723 "parse.y" +#line 3731 "parse.y" { yyval.ttype = ansi_opname[COMPOUND_EXPR]; ; break;} case 817: -#line 3725 "parse.y" +#line 3733 "parse.y" { yyval.ttype = ansi_opname[yyvsp[0].code]; ; break;} case 818: -#line 3727 "parse.y" +#line 3735 "parse.y" { yyval.ttype = ansi_opname[LT_EXPR]; ; break;} case 819: -#line 3729 "parse.y" +#line 3737 "parse.y" { yyval.ttype = ansi_opname[GT_EXPR]; ; break;} case 820: -#line 3731 "parse.y" +#line 3739 "parse.y" { yyval.ttype = ansi_opname[yyvsp[0].code]; ; break;} case 821: -#line 3733 "parse.y" +#line 3741 "parse.y" { yyval.ttype = ansi_assopname[yyvsp[0].code]; ; break;} case 822: -#line 3735 "parse.y" +#line 3743 "parse.y" { yyval.ttype = ansi_opname [MODIFY_EXPR]; ; break;} case 823: -#line 3737 "parse.y" +#line 3745 "parse.y" { yyval.ttype = ansi_opname[yyvsp[0].code]; ; break;} case 824: -#line 3739 "parse.y" +#line 3747 "parse.y" { yyval.ttype = ansi_opname[yyvsp[0].code]; ; break;} case 825: -#line 3741 "parse.y" +#line 3749 "parse.y" { yyval.ttype = ansi_opname[POSTINCREMENT_EXPR]; ; break;} case 826: -#line 3743 "parse.y" +#line 3751 "parse.y" { yyval.ttype = ansi_opname[PREDECREMENT_EXPR]; ; break;} case 827: -#line 3745 "parse.y" +#line 3753 "parse.y" { yyval.ttype = ansi_opname[TRUTH_ANDIF_EXPR]; ; break;} case 828: -#line 3747 "parse.y" +#line 3755 "parse.y" { yyval.ttype = ansi_opname[TRUTH_ORIF_EXPR]; ; break;} case 829: -#line 3749 "parse.y" +#line 3757 "parse.y" { yyval.ttype = ansi_opname[TRUTH_NOT_EXPR]; ; break;} case 830: -#line 3751 "parse.y" +#line 3759 "parse.y" { yyval.ttype = ansi_opname[COND_EXPR]; ; break;} case 831: -#line 3753 "parse.y" +#line 3761 "parse.y" { yyval.ttype = ansi_opname[yyvsp[0].code]; ; break;} case 832: -#line 3755 "parse.y" +#line 3763 "parse.y" { yyval.ttype = ansi_opname[COMPONENT_REF]; ; break;} case 833: -#line 3757 "parse.y" +#line 3765 "parse.y" { yyval.ttype = ansi_opname[MEMBER_REF]; ; break;} case 834: -#line 3759 "parse.y" +#line 3767 "parse.y" { yyval.ttype = ansi_opname[CALL_EXPR]; ; break;} case 835: -#line 3761 "parse.y" +#line 3769 "parse.y" { yyval.ttype = ansi_opname[ARRAY_REF]; ; break;} case 836: -#line 3763 "parse.y" +#line 3771 "parse.y" { yyval.ttype = ansi_opname[NEW_EXPR]; ; break;} case 837: -#line 3765 "parse.y" +#line 3773 "parse.y" { yyval.ttype = ansi_opname[DELETE_EXPR]; ; break;} case 838: -#line 3767 "parse.y" +#line 3775 "parse.y" { yyval.ttype = ansi_opname[VEC_NEW_EXPR]; ; break;} case 839: -#line 3769 "parse.y" +#line 3777 "parse.y" { yyval.ttype = ansi_opname[VEC_DELETE_EXPR]; ; break;} case 840: -#line 3772 "parse.y" +#line 3780 "parse.y" { yyval.ttype = grokoptypename (yyvsp[-1].ftype.t, yyvsp[0].ttype); ; break;} case 841: -#line 3774 "parse.y" +#line 3782 "parse.y" { yyval.ttype = ansi_opname[ERROR_MARK]; ; break;} } @@ -7980,7 +7988,7 @@ yyerrhandle: yystate = yyn; goto yynewstate; } -#line 3777 "parse.y" +#line 3785 "parse.y" #ifdef SPEW_DEBUG diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 12b59b1..074f640 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -331,8 +331,10 @@ program: { /* In case there were missing closebraces, get us back to the global binding level. */ - while (! global_bindings_p ()) + while (! toplevel_bindings_p ()) poplevel (0, 0, 0); + while (current_namespace != global_namespace) + pop_namespace (); finish_file (); } ; @@ -413,7 +415,10 @@ extdef: { do_toplevel_using_decl ($1); } | USING NAMESPACE any_id ';' { - if (TREE_CODE ($3) == IDENTIFIER_NODE) + /* If no declaration was found, the using-directive is + invalid. Since that was not reported, we need the + identifier for the error message. */ + if (TREE_CODE ($3) == IDENTIFIER_NODE && lastiddecl) $3 = lastiddecl; do_using_directive ($3); } @@ -2348,6 +2353,7 @@ left_curly: $<ttype>0 = t; } if (processing_template_decl && TYPE_CONTEXT (t) + && TREE_CODE (TYPE_CONTEXT (t)) != NAMESPACE_DECL && ! current_class_type) push_template_decl (TYPE_STUB_DECL (t)); pushclass (t, 0); @@ -3014,7 +3020,9 @@ typename_sub2: if (TREE_CODE ($1) != IDENTIFIER_NODE) $1 = lastiddecl; - got_scope = $$ = complete_type (TREE_TYPE ($1)); + /* Retrieve the type for the identifier, which might involve + some computation. */ + got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1)); if ($$ == error_mark_node) cp_error ("`%T' is not a class or namespace", $1); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 209e23e..f30164f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -171,7 +171,9 @@ template_class_depth (type) { int depth; - for (depth = 0; type && TREE_CODE (type) != FUNCTION_DECL; + for (depth = 0; + type && TREE_CODE (type) != FUNCTION_DECL + && TREE_CODE (type) != NAMESPACE_DECL; type = TYPE_CONTEXT (type)) if (CLASSTYPE_TEMPLATE_INFO (type) && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (type)) @@ -730,22 +732,19 @@ determine_specialization (template_id, decl, targs_out, tree targs_in = TREE_OPERAND (template_id, 1); tree templates = NULL_TREE; tree fn; - int overloaded; int i; *targs_out = NULL_TREE; - if (is_overloaded_fn (fns)) - fn = get_first_fn (fns); - else - fn = NULL_TREE; + /* Check for baselinks. */ + if (TREE_CODE (fns) == TREE_LIST) + fns = TREE_VALUE (fns); - overloaded = really_overloaded_fn (fns); - for (; fn != NULL_TREE; - fn = overloaded ? DECL_CHAIN (fn) : NULL_TREE) + for (; fns; fns = OVL_NEXT (fns)) { tree tmpl; + fn = OVL_CURRENT (fns); if (!need_member_template && TREE_CODE (fn) == FUNCTION_DECL && DECL_FUNCTION_MEMBER_P (fn) @@ -1576,7 +1575,8 @@ push_template_decl_real (decl, is_friend) /* For a friend, we want the context of the friend function, not the type of which it is a friend. */ ctx = DECL_CONTEXT (decl); - else if (DECL_REAL_CONTEXT (decl)) + else if (DECL_REAL_CONTEXT (decl) + && TREE_CODE (DECL_REAL_CONTEXT (decl)) != NAMESPACE_DECL) /* In the case of a virtual function, we want the class in which it is defined. */ ctx = DECL_REAL_CONTEXT (decl); @@ -1585,6 +1585,12 @@ push_template_decl_real (decl, is_friend) is assumed to be a member of the class. */ ctx = current_class_type; + if (ctx && TREE_CODE (ctx) == NAMESPACE_DECL) + ctx = NULL_TREE; + + if (!DECL_CONTEXT (decl)) + DECL_CONTEXT (decl) = current_namespace; + /* For determining whether this is a primary template or not, we're really interested in the lexical context, not the true context. */ if (is_friend) @@ -1818,7 +1824,7 @@ push_template_decl_real (decl, is_friend) /* Note that we do not try to push a global template friend declared in a template class; such a thing may well depend on the template parameters of the class. */ - tmpl = pushdecl_top_level (tmpl); + tmpl = pushdecl_namespace_level (tmpl); if (primary) DECL_PRIMARY_TEMPLATE (tmpl) = tmpl; @@ -2602,7 +2608,7 @@ mangle_class_name_for_template (name, parms, arglist, ctx) #define cat(s) obstack_grow (&scratch_obstack, (s), strlen (s)) #endif - if (ctx) + if (ctx && ctx != global_namespace) { char* s; @@ -2610,6 +2616,8 @@ mangle_class_name_for_template (name, parms, arglist, ctx) s = fndecl_as_string (ctx, 0); else if (TREE_CODE_CLASS (TREE_CODE (ctx)) == 't') s = type_as_string_real (ctx, 0, 1); + else if (TREE_CODE (ctx) == NAMESPACE_DECL) + s = decl_as_string (ctx, 0); else my_friendly_abort (0); cat (s); @@ -2635,9 +2643,18 @@ mangle_class_name_for_template (name, parms, arglist, ctx) else if (TREE_CODE (parm) == TEMPLATE_DECL) { if (TREE_CODE (arg) == TEMPLATE_DECL) - /* Already substituted with real template. Just output - the template name here */ - cat (IDENTIFIER_POINTER (DECL_NAME (arg))); + { + /* Already substituted with real template. Just output + the template name here */ + my_friendly_assert (TREE_CODE (DECL_CONTEXT (arg)) + == NAMESPACE_DECL, 980422); + if (DECL_CONTEXT (arg) != global_namespace) + { + cat(decl_as_string (DECL_CONTEXT (arg), 0)); + cat("::"); + } + cat (IDENTIFIER_POINTER (DECL_NAME (arg))); + } else /* Output the parameter declaration */ cat (type_as_string_real (arg, 0, 1)); @@ -2729,7 +2746,7 @@ tree lookup_template_function (fns, arglist) tree fns, arglist; { - tree t; + tree type; if (fns == NULL_TREE) { @@ -2740,10 +2757,11 @@ lookup_template_function (fns, arglist) if (arglist != NULL_TREE && !TREE_PERMANENT (arglist)) copy_to_permanent (arglist); - return build_min (TEMPLATE_ID_EXPR, - TREE_TYPE (fns) - ? TREE_TYPE (fns) : unknown_type_node, - fns, arglist); + type = TREE_TYPE (fns); + if (TREE_CODE (fns) == OVERLOAD || !type) + type = unknown_type_node; + + return build_min (TEMPLATE_ID_EXPR, type, fns, arglist); } /* Within the scope of a template class S<T>, the name S gets bound @@ -2786,7 +2804,7 @@ lookup_template_class (d1, arglist, in_decl, context) { tree template = NULL_TREE, parmlist; char *mangled_name; - tree id, t; + tree id, t, id_context; if (TREE_CODE (d1) == IDENTIFIER_NODE) { @@ -2795,11 +2813,15 @@ lookup_template_class (d1, arglist, in_decl, context) template = IDENTIFIER_LOCAL_VALUE (d1); else { + if (context) + push_decl_namespace (context); template = maybe_get_template_decl_from_type_decl (IDENTIFIER_CLASS_VALUE (d1)); if (template == NULL_TREE) - template = IDENTIFIER_NAMESPACE_VALUE (d1); + template = lookup_name_nonclass (d1); + if (context) + pop_decl_namespace (); } if (template) context = DECL_CONTEXT (template); @@ -2826,12 +2848,28 @@ lookup_template_class (d1, arglist, in_decl, context) else my_friendly_abort (272); + /* A namespace is used as context only for mangling. + Template IDs with namespace context are found + in the global binding level. */ + if (context != NULL_TREE && TREE_CODE (context) == NAMESPACE_DECL) + context = global_namespace; + /* With something like `template <class T> class X class X { ... };' we could end up with D1 having nothing but an IDENTIFIER_LOCAL_VALUE. We don't want to do that, but we have to deal with the situation, so let's give them some syntax errors to chew on instead of a crash. */ if (! template) return error_mark_node; + + /* We need an id_context to get the mangling right. If this is a + nested template, use the context. If it is global, retrieve the + context from the template. */ + if (context && TREE_CODE (context) != NAMESPACE_DECL) + id_context = context; + else + id_context = DECL_CONTEXT (template); + my_friendly_assert (id_context != NULL_TREE, 980410); + if (TREE_CODE (template) != TEMPLATE_DECL) { cp_error ("non-template type `%T' used as a template", d1); @@ -2903,7 +2941,7 @@ lookup_template_class (d1, arglist, in_decl, context) mangled_name = mangle_class_name_for_template (IDENTIFIER_POINTER (d1), parmlist, arglist, - context); + id_context); id = get_identifier (mangled_name); IDENTIFIER_TEMPLATE (id) = d1; @@ -3027,6 +3065,11 @@ for_each_template_parm (t, fn, data) return 1; return for_each_template_parm (TREE_CHAIN (t), fn, data); + case OVERLOAD: + if (for_each_template_parm (OVL_FUNCTION (t), fn, data)) + return 1; + return for_each_template_parm (OVL_CHAIN (t), fn, data); + /* constructed type nodes */ case POINTER_TYPE: case REFERENCE_TYPE: @@ -3118,6 +3161,7 @@ for_each_template_parm (t, fn, data) case COMPLEX_TYPE: case VOID_TYPE: case BOOLEAN_TYPE: + case NAMESPACE_DECL: return 0; case ENUMERAL_TYPE: @@ -3366,14 +3410,15 @@ tsubst_friend_function (decl, args) if (TREE_CODE (decl) == TEMPLATE_DECL) DECL_USE_TEMPLATE (DECL_TEMPLATE_RESULT (new_friend)) = 0; - if (DECL_CONTEXT (new_friend) == NULL_TREE) + if (!DECL_CONTEXT (new_friend) + || TREE_CODE (DECL_CONTEXT (new_friend)) == NAMESPACE_DECL) { if (TREE_CODE (new_friend) == TEMPLATE_DECL) /* This declaration is a `primary' template. */ TREE_TYPE (DECL_INNERMOST_TEMPLATE_PARMS (new_friend)) = new_friend; - new_friend = pushdecl_top_level (new_friend); + new_friend = pushdecl_namespace_level (new_friend); } else if (TYPE_SIZE (DECL_CONTEXT (new_friend))) { @@ -3852,10 +3897,14 @@ tsubst (t, args, in_decl) if (t == NULL_TREE || t == error_mark_node || t == integer_type_node || t == void_type_node - || t == char_type_node) + || t == char_type_node + || TREE_CODE (t) == NAMESPACE_DECL) return t; - type = TREE_TYPE (t); + if (TREE_CODE (t) == IDENTIFIER_NODE) + type = IDENTIFIER_TYPE_VALUE (t); + else + type = TREE_TYPE (t); if (type == unknown_type_node) my_friendly_abort (42); if (type && TREE_CODE (t) != FUNCTION_DECL @@ -3904,12 +3953,13 @@ tsubst (t, args, in_decl) case INTEGER_CST: case REAL_CST: case STRING_CST: + case NAMESPACE_DECL: return t; case ENUMERAL_TYPE: { tree ctx = tsubst (TYPE_CONTEXT (t), args, in_decl); - if (ctx == NULL_TREE) + if (ctx == NULL_TREE || TREE_CODE (ctx) == NAMESPACE_DECL) return t; else if (ctx == current_function_decl) return lookup_name (TYPE_IDENTIFIER (t), 1); @@ -4089,7 +4139,6 @@ tsubst (t, args, in_decl) tmpl = copy_node (t); copy_lang_decl (tmpl); my_friendly_assert (DECL_LANG_SPECIFIC (tmpl) != 0, 0); - DECL_CHAIN (tmpl) = NULL_TREE; TREE_CHAIN (tmpl) = NULL_TREE; if (is_template_template_parm) @@ -4407,7 +4456,6 @@ tsubst (t, args, in_decl) DECL_INTERFACE_KNOWN (r) = 0; DECL_DEFER_OUTPUT (r) = 0; TREE_CHAIN (r) = NULL_TREE; - DECL_CHAIN (r) = NULL_TREE; DECL_PENDING_INLINE_INFO (r) = 0; TREE_USED (r) = 0; @@ -4436,7 +4484,7 @@ tsubst (t, args, in_decl) TREE_CHAIN because it doesn't find a previous decl. Sigh. */ if (member && IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r)) == NULL_TREE) - IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r)) = r; + SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r), r); return r; } @@ -5632,15 +5680,14 @@ type_unification_real (tparms, targs, parms, args, subr, if (TREE_CODE_CLASS (TREE_CODE (arg)) != 't') { my_friendly_assert (TREE_TYPE (arg) != NULL_TREE, 293); - if (TREE_CODE (arg) == TREE_LIST - && TREE_TYPE (arg) == unknown_type_node - && TREE_CODE (TREE_VALUE (arg)) == TEMPLATE_DECL) + if (TREE_CODE (arg) == OVERLOAD + && TREE_CODE (OVL_FUNCTION (arg)) == TEMPLATE_DECL) { int ntparms; tree targs; /* Have to back unify here */ - arg = TREE_VALUE (arg); + arg = OVL_FUNCTION (arg); ntparms = DECL_NTPARMS (arg); targs = make_scratch_vec (ntparms); parm = expr_tree_cons (NULL_TREE, parm, NULL_TREE); diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c index fffcddd..1f5e3a8 100644 --- a/gcc/cp/ptree.c +++ b/gcc/cp/ptree.c @@ -147,7 +147,7 @@ print_lang_identifier (file, node, indent) tree node; int indent; { - print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4); + print_node (file, "bindings", IDENTIFIER_NAMESPACE_BINDINGS (node), indent + 4); print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4); print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4); print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4); @@ -169,6 +169,9 @@ lang_print_xnode (file, node, indent) print_node (file, "value", BINDING_VALUE (node), indent+4); print_node (file, "chain", TREE_CHAIN (node), indent+4); break; + case OVERLOAD: + print_node (file, "function", OVL_FUNCTION (node), indent+4); + print_node (file, "chain", TREE_CHAIN (node), indent+4); case TEMPLATE_PARM_INDEX: indent_to (file, indent + 3); fprintf (file, "index %d level %d orig_level %d", diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 4dc02ee..d452e03 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -57,8 +57,12 @@ tree tinfo_fn_type; void init_rtti_processing () { + if (flag_honor_std) + push_namespace (get_identifier ("std")); type_info_type_node = xref_tag (class_type_node, get_identifier ("type_info"), NULL_TREE, 1); + if (flag_honor_std) + pop_namespace (); tinfo_fn_id = get_identifier ("__tf"); tinfo_fn_type = build_function_type (build_reference_type (build_type_variant (type_info_type_node, 1, 0)), diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 9faa0ee..bbcf40c 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1152,10 +1152,10 @@ lookup_fnfields_here (type, name) fndecls = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), idx); while (fndecls) { - if (TYPE_MAIN_VARIANT (DECL_CLASS_CONTEXT (fndecls)) + if (TYPE_MAIN_VARIANT (DECL_CLASS_CONTEXT (OVL_CURRENT (fndecls))) == TYPE_MAIN_VARIANT (type)) return idx; - fndecls = TREE_CHAIN (fndecls); + fndecls = OVL_CHAIN (fndecls); } return -1; } @@ -1266,7 +1266,7 @@ lookup_field (xbasetype, name, protect, want_type) #ifdef GATHER_STATISTICS n_calls_lookup_field++; #endif /* GATHER_STATISTICS */ - if (protect && flag_memoize_lookups && ! global_bindings_p ()) + if (protect && flag_memoize_lookups && ! toplevel_bindings_p ()) entry = make_memoized_table_entry (type, name, 0); else entry = 0; @@ -1662,7 +1662,7 @@ lookup_fnfields_1 (type, name) #ifdef GATHER_STATISTICS n_outer_fields_searched++; #endif /* GATHER_STATISTICS */ - if (DECL_NAME (*methods) == name) + if (DECL_NAME (OVL_CURRENT (*methods)) == name) break; } @@ -1676,8 +1676,8 @@ lookup_fnfields_1 (type, name) while (++methods != end) { - if (TREE_CODE (*methods) == TEMPLATE_DECL - && IDENTIFIER_TYPENAME_P (DECL_NAME (*methods))) + if (TREE_CODE (OVL_CURRENT (*methods)) == TEMPLATE_DECL + && IDENTIFIER_TYPENAME_P (DECL_NAME (OVL_CURRENT (*methods)))) break; } } @@ -1815,7 +1815,7 @@ lookup_fnfields (basetype_path, name, complain) #ifdef GATHER_STATISTICS n_calls_lookup_fnfields++; #endif /* GATHER_STATISTICS */ - if (protect && flag_memoize_lookups && ! global_bindings_p ()) + if (protect && flag_memoize_lookups && ! toplevel_bindings_p ()) entry = make_memoized_table_entry (type, name, 1); else entry = 0; @@ -2101,8 +2101,8 @@ get_virtuals_named_this (binfo) { tree fndecl; - for (fndecl = TREE_VALUE (fields); fndecl; fndecl = DECL_CHAIN (fndecl)) - if (DECL_VINDEX (fndecl)) + for (fndecl = TREE_VALUE (fields); fndecl; fndecl = OVL_NEXT (fndecl)) + if (DECL_VINDEX (OVL_CURRENT (fndecl))) return fields; fields = next_baselink (fields); } @@ -2187,8 +2187,10 @@ get_matching_virtual (binfo, fndecl, dtorp) for (; baselink; baselink = next_baselink (baselink)) { - for (tmp = TREE_VALUE (baselink); tmp; tmp = DECL_CHAIN (tmp)) + tree tmps; + for (tmps = TREE_VALUE (baselink); tmps; tmps = OVL_NEXT (tmps)) { + tmp = OVL_CURRENT (tmps); if (! DECL_VINDEX (tmp)) continue; @@ -2256,7 +2258,8 @@ get_matching_virtual (binfo, fndecl, dtorp) break; } } - if (tmp) + /* If not at the end */ + if (tmps) { best = tmp; break; @@ -2680,6 +2683,7 @@ dfs_debug_mark (binfo) methods = TREE_VEC_ELT (methods, 0); else methods = TREE_VEC_ELT (methods, 2); + methods = OVL_CURRENT (methods); while (methods) { if (DECL_VINDEX (methods) @@ -2697,7 +2701,7 @@ dfs_debug_mark (binfo) /* We cannot rely on some alien method to solve our problems, so we must write out the debug info ourselves. */ TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (t)) = 0; - rest_of_type_compilation (t, global_bindings_p ()); + rest_of_type_compilation (t, toplevel_bindings_p ()); } /* Attach to the type of the virtual base class, the pointer to the @@ -3471,7 +3475,7 @@ dfs_pushdecls (binfo) { /* This will cause lookup_name to return a pointer to the tree_list of possible methods of this name. */ - tree name = DECL_NAME (*methods); + tree name = DECL_NAME (OVL_CURRENT (*methods)); tree class_value = IDENTIFIER_CLASS_VALUE (name); /* If the class value is not an envelope of the kind described in @@ -3491,7 +3495,7 @@ dfs_pushdecls (binfo) If we can't do that, keep a TREE_LIST with possibly ambiguous decls in there. */ maybe_push_cache_obstack (); - envelope_add_decl (type, *methods, &TREE_PURPOSE (class_value)); + envelope_add_decl (type, OVL_CURRENT (*methods), &TREE_PURPOSE (class_value)); pop_obstacks (); methods++; @@ -3519,7 +3523,8 @@ dfs_compress_decls (binfo) { /* This is known to be an envelope of the kind described before dfs_pushdecls. */ - tree class_value = IDENTIFIER_CLASS_VALUE (DECL_NAME (*methods)); + tree class_value = + IDENTIFIER_CLASS_VALUE (DECL_NAME (OVL_CURRENT (*methods))); tree tmp = TREE_PURPOSE (class_value); /* This was replaced in scope by somebody else. Just leave it @@ -3529,7 +3534,7 @@ dfs_compress_decls (binfo) if (TREE_CHAIN (tmp) == NULL_TREE && TREE_VALUE (tmp) - && DECL_CHAIN (TREE_VALUE (tmp)) == NULL_TREE) + && OVL_NEXT (TREE_VALUE (tmp)) == NULL_TREE) { TREE_PURPOSE (class_value) = TREE_VALUE (tmp); } @@ -3738,7 +3743,7 @@ add_conversions (binfo) for (i = 2; i < TREE_VEC_LENGTH (method_vec); ++i) { tree tmp = TREE_VEC_ELT (method_vec, i); - if (! IDENTIFIER_TYPENAME_P (DECL_NAME (tmp))) + if (! IDENTIFIER_TYPENAME_P (DECL_NAME (OVL_CURRENT (tmp)))) break; conversions = scratch_tree_cons (binfo, tmp, conversions); } diff --git a/gcc/cp/sig.c b/gcc/cp/sig.c index 01736a8..ba57173 100644 --- a/gcc/cp/sig.c +++ b/gcc/cp/sig.c @@ -96,6 +96,8 @@ build_signature_pointer_or_reference_decl (type, name) decl = build_decl (TYPE_DECL, name, type); TYPE_NAME (type) = decl; TREE_CHAIN (type) = decl; + /* But we mangle it, so it needs a scope. */ + DECL_CONTEXT (decl) = global_namespace; } /* Construct, lay out and return the type of pointers or references @@ -532,19 +534,20 @@ build_signature_table_constructor (sig_ty, rhs) else { /* Find the class method of the correct type. */ - + tree rhs_methods; basetypes = TREE_PURPOSE (baselink); if (TREE_CODE (basetypes) == TREE_LIST) basetypes = TREE_VALUE (basetypes); - rhs_method = TREE_VALUE (baselink); - for (; rhs_method; rhs_method = TREE_CHAIN (rhs_method)) - if (sig_mname == DECL_NAME (rhs_method) + rhs_methods = TREE_VALUE (baselink); + for (; rhs_methods; rhs_methods = OVL_NEXT (rhs_methods)) + if ((rhs_method = OVL_CURRENT (rhs_methods)) + && sig_mname == DECL_NAME (rhs_method) && ! DECL_STATIC_FUNCTION_P (rhs_method) && match_method_types (sig_mtype, TREE_TYPE (rhs_method))) break; - if (rhs_method == NULL_TREE + if (rhs_methods == NULL_TREE || (compute_access (basetypes, rhs_method) != access_public_node)) { @@ -754,7 +757,7 @@ build_sigtable (sig_type, rhs_type, init_from) decl = pushdecl_top_level (build_decl (VAR_DECL, name, sig_type)); current_function_decl = context; } - IDENTIFIER_GLOBAL_VALUE (name) = decl; + SET_IDENTIFIER_GLOBAL_VALUE (name, decl); store_init_value (decl, init_expr); if (IS_SIGNATURE (rhs_type)) { diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c index a13f659..0c9e4e3 100644 --- a/gcc/cp/spew.c +++ b/gcc/cp/spew.c @@ -245,6 +245,7 @@ yylex () { struct token tmp_token; tree trrr; + int old_looking_for_typename = 0; retry: #ifdef SPEW_DEBUG @@ -306,8 +307,11 @@ yylex () case IDENTIFIER: scan_tokens (1); if (nth_token (1)->yychar == SCOPE) - /* Don't interfere with the setting from an 'aggr' prefix. */ - looking_for_typename++; + { + /* Don't interfere with the setting from an 'aggr' prefix. */ + old_looking_for_typename = looking_for_typename; + looking_for_typename = 1; + } else if (nth_token (1)->yychar == '<') looking_for_template = 1; @@ -346,8 +350,9 @@ yylex () case PTYPENAME: case PTYPENAME_DEFN: consume_token (); - if (looking_for_typename > 0) - looking_for_typename--; + /* If we see a SCOPE next, restore the old value. + Otherwise, we got what we want. */ + looking_for_typename = old_looking_for_typename; looking_for_template = 0; break; @@ -368,7 +373,7 @@ yylex () /* fall through to output... */ case ENUM: /* Set this again, in case we are rescanning. */ - looking_for_typename = 1; + looking_for_typename = 2; /* fall through... */ default: consume_token (); diff --git a/gcc/cp/tinfo.cc b/gcc/cp/tinfo.cc index d82aaaf..3f32081 100644 --- a/gcc/cp/tinfo.cc +++ b/gcc/cp/tinfo.cc @@ -33,7 +33,7 @@ // that uses virtual functions and -frtti but does not actually use RTTI // functionality. -type_info:: +std::type_info:: ~type_info () { } @@ -43,7 +43,7 @@ __rtti_class (void *addr, const char *name, { new (addr) __class_type_info (name, bl, bn); } extern "C" void -__rtti_si (void *addr, const char *n, const type_info *ti) +__rtti_si (void *addr, const char *n, const std::type_info *ti) { new (addr) __si_type_info (n, static_cast <const __user_type_info &> (*ti)); diff --git a/gcc/cp/tinfo.h b/gcc/cp/tinfo.h index 3df55a5..3cfee04 100644 --- a/gcc/cp/tinfo.h +++ b/gcc/cp/tinfo.h @@ -7,7 +7,7 @@ // type_info for a class with no base classes (or an enum). -struct __user_type_info : public type_info { +struct __user_type_info : public std::type_info { __user_type_info (const char *n) : type_info (n) {} // If our type can be converted to the desired type, diff --git a/gcc/cp/tinfo2.cc b/gcc/cp/tinfo2.cc index 9496486..b797cc3 100644 --- a/gcc/cp/tinfo2.cc +++ b/gcc/cp/tinfo2.cc @@ -29,6 +29,7 @@ #include "tinfo.h" #include "new" // for placement new +using std::type_info; // service function for comparing types by name. static inline int diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9aeafd7..4b2c82d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1271,33 +1271,38 @@ debug_binfo (elem) } } -/* Return the length of a chain of nodes chained through DECL_CHAIN. - We expect a null pointer to mark the end of the chain. - This is the Lisp primitive `length'. */ +/* Initialize an CPLUS_BINDING node that does not live on an obstack. */ -int -decl_list_length (t) - tree t; +tree +binding_init (node) + struct tree_binding* node; { - register tree tail; - register int len = 0; - - my_friendly_assert (TREE_CODE (t) == FUNCTION_DECL - || TREE_CODE (t) == TEMPLATE_DECL, 300); - for (tail = t; tail; tail = DECL_CHAIN (tail)) - len++; - - return len; + static struct tree_binding* source; + if (!source) + { + extern struct obstack permanent_obstack; + push_obstacks (&permanent_obstack, &permanent_obstack); + source = (struct tree_binding*)make_node (CPLUS_BINDING); + pop_obstacks (); + } + *node = *source; + TREE_PERMANENT ((tree)node) = 0; + return (tree)node; } int count_functions (t) tree t; { + int i; if (TREE_CODE (t) == FUNCTION_DECL) return 1; - else if (TREE_CODE (t) == TREE_LIST) - return decl_list_length (TREE_VALUE (t)); + else if (TREE_CODE (t) == OVERLOAD) + { + for (i=0; t; t = OVL_CHAIN (t)) + i++; + return i; + } my_friendly_abort (359); return 0; @@ -1307,19 +1312,29 @@ int is_overloaded_fn (x) tree x; { + /* XXX A baselink is also considered an overloaded function. */ + if (TREE_CODE (x) == TREE_LIST) + { + my_friendly_assert (TREE_CODE (TREE_PURPOSE (x)) == TREE_VEC, 388); + x = TREE_VALUE (x); + } return (TREE_CODE (x) == FUNCTION_DECL || TREE_CODE (x) == TEMPLATE_ID_EXPR || DECL_FUNCTION_TEMPLATE_P (x) - || really_overloaded_fn (x)); + || TREE_CODE (x) == OVERLOAD); } int really_overloaded_fn (x) tree x; { - return (TREE_CODE (x) == TREE_LIST - && (TREE_CODE (TREE_VALUE (x)) == FUNCTION_DECL - || DECL_FUNCTION_TEMPLATE_P (TREE_VALUE (x)))); + /* A baselink is also considered an overloaded function. + This might also be an ambiguous class member. */ + while (TREE_CODE (x) == TREE_LIST) + x = TREE_VALUE (x); + return (TREE_CODE (x) == OVERLOAD + && (TREE_CHAIN (x) != NULL_TREE + || DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (x)))); } tree @@ -1327,11 +1342,72 @@ get_first_fn (from) tree from; { my_friendly_assert (is_overloaded_fn (from), 9); + /* A baselink is also considered an overloaded function. */ + if (TREE_CODE (from) == TREE_LIST) + from = TREE_VALUE (from); + return OVL_CURRENT (from); +} - if (really_overloaded_fn (from)) - return TREE_VALUE (from); - else - return from; +/* Return a new OVL node, concatenating it with the old one. */ + +tree +ovl_cons (decl, chain) + tree decl; + tree chain; +{ + tree result = make_node (OVERLOAD); + TREE_TYPE (result) = unknown_type_node; + OVL_FUNCTION (result) = decl; + TREE_CHAIN (result) = chain; + + return result; +} + +/* Same as ovl_cons, but on the scratch_obstack. */ + +tree +scratch_ovl_cons (value, chain) + tree value, chain; +{ + register tree node; + register struct obstack *ambient_obstack = current_obstack; + extern struct obstack *expression_obstack; + current_obstack = expression_obstack; + node = ovl_cons (value, chain); + current_obstack = ambient_obstack; + return node; +} + +/* Build a new overloaded function. If this is the first one, + just return it; otherwise, ovl_cons the _DECLs */ + +tree +build_overload (decl, chain) + tree decl; + tree chain; +{ + if (!chain) + return decl; + if (TREE_CODE (chain) != OVERLOAD) + chain = ovl_cons (chain, NULL_TREE); + return ovl_cons (decl, chain); +} + +/* True if fn is in ovl. */ + +int +ovl_member (fn, ovl) + tree fn; + tree ovl; +{ + if (fn == ovl) + return 1; + if (!ovl || TREE_CODE (ovl) != OVERLOAD) + return 0; + for (; ovl; ovl = OVL_CHAIN (ovl)) + if (OVL_FUNCTION (ovl) == fn) + return 1; + return 0; } int @@ -2193,8 +2269,11 @@ tree lvalue_type (arg) tree arg; { + tree type = TREE_TYPE (arg); + if (TREE_CODE (arg) == OVERLOAD) + type = unknown_type_node; return cp_build_type_variant - (TREE_TYPE (arg), TREE_READONLY (arg), TREE_THIS_VOLATILE (arg)); + (type, TREE_READONLY (arg), TREE_THIS_VOLATILE (arg)); } /* The type of ARG for printing error messages; denote lvalues with diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e74e925e..6c1a1a6 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -91,7 +91,10 @@ require_complete_type (value) if (processing_template_decl) return value; - type = TREE_TYPE (value); + if (TREE_CODE (value) == OVERLOAD) + type = unknown_type_node; + else + type = TREE_TYPE (value); /* First, detect a valid value with a complete type. */ if (TYPE_SIZE (type) != 0 @@ -161,7 +164,7 @@ int type_unknown_p (exp) tree exp; { - return (TREE_CODE (exp) == TREE_LIST + return (TREE_CODE (exp) == OVERLOAD || TREE_TYPE (exp) == unknown_type_node || (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node)); @@ -193,7 +196,8 @@ require_instantiated_type (type, exp, errval) return errval; } - if (TREE_TYPE (exp) == unknown_type_node + if (TREE_CODE (exp) == OVERLOAD + || TREE_TYPE (exp) == unknown_type_node || (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node)) { @@ -1837,8 +1841,12 @@ build_component_ref (datum, component, basetype_path, protect) /* First, see if there is a field or component with name COMPONENT. */ if (TREE_CODE (component) == TREE_LIST) { + /* I could not trigger this code. MvL */ + my_friendly_abort (980326); +#ifdef DEAD my_friendly_assert (!(TREE_CHAIN (component) == NULL_TREE && DECL_CHAIN (TREE_VALUE (component)) == NULL_TREE), 309); +#endif return build (COMPONENT_REF, TREE_TYPE (component), datum, component); } @@ -1907,7 +1915,7 @@ build_component_ref (datum, component, basetype_path, protect) if (fndecls) { if (TREE_CHAIN (fndecls) == NULL_TREE - && DECL_CHAIN (TREE_VALUE (fndecls)) == NULL_TREE) + && TREE_CODE (TREE_VALUE (fndecls)) != OVERLOAD) { tree access, fndecl; @@ -2365,7 +2373,7 @@ build_x_function_call (function, params, decl) /* A friend template. Make it look like a toplevel declaration. */ if (! is_method && TREE_CODE (function) == TEMPLATE_DECL) - function = build_scratch_list (NULL_TREE, function); + function = scratch_ovl_cons (function, NULL_TREE); /* Handle methods, friends, and overloaded functions, respectively. */ if (is_method) @@ -2453,7 +2461,7 @@ build_x_function_call (function, params, decl) } else if (really_overloaded_fn (function)) { - if (TREE_VALUE (function) == NULL_TREE) + if (OVL_FUNCTION (function) == NULL_TREE) { cp_error ("function `%D' declared overloaded, but no definitions appear with which to resolve it?!?", TREE_PURPOSE (function)); @@ -2467,6 +2475,9 @@ build_x_function_call (function, params, decl) return build_new_function_call (function, params); } } + else + /* Remove a potential OVERLOAD around it */ + function = OVL_CURRENT (function); do_x_function: if (TREE_CODE (function) == OFFSET_REF) @@ -2673,7 +2684,7 @@ build_function_call_real (function, params, require_complete, flags) && name && IDENTIFIER_LENGTH (name) == 4 && ! strcmp (IDENTIFIER_POINTER (name), "main") - && DECL_CONTEXT (function) == NULL_TREE) + && DECL_CONTEXT (function) == global_namespace) { pedwarn ("ANSI C++ forbids calling `main' from within program"); } @@ -4437,7 +4448,7 @@ build_unary_op (code, xarg, noconvert) else if (pedantic && TREE_CODE (arg) == FUNCTION_DECL && DECL_NAME (arg) - && DECL_CONTEXT (arg) == NULL_TREE + && DECL_CONTEXT (arg) == global_namespace && IDENTIFIER_LENGTH (DECL_NAME (arg)) == 4 && IDENTIFIER_POINTER (DECL_NAME (arg))[0] == 'm' && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (arg)), "main")) @@ -4488,15 +4499,16 @@ build_unary_op (code, xarg, noconvert) return build1 (ADDR_EXPR, unknown_type_node, arg); } - if (TREE_CODE (arg) == TREE_LIST) + if (TREE_CODE (arg) == OVERLOAD) + return build1 (ADDR_EXPR, unknown_type_node, arg); + else if (TREE_CODE (arg) == TREE_LIST) { - if (TREE_CODE (TREE_VALUE (arg)) == FUNCTION_DECL - && DECL_CHAIN (TREE_VALUE (arg)) == NULL_TREE) + if (TREE_CODE (TREE_VALUE (arg)) == FUNCTION_DECL) /* Unique overloaded non-member function. */ return build_unary_op (ADDR_EXPR, TREE_VALUE (arg), 0); if (TREE_CHAIN (arg) == NULL_TREE && TREE_CODE (TREE_VALUE (arg)) == TREE_LIST - && DECL_CHAIN (TREE_VALUE (TREE_VALUE (arg))) == NULL_TREE) + && TREE_CODE (TREE_VALUE (TREE_VALUE (arg))) != OVERLOAD) /* Unique overloaded member function. */ return build_unary_op (ADDR_EXPR, TREE_VALUE (TREE_VALUE (arg)), 0); @@ -6500,7 +6512,7 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) if (rhs == error_mark_node) return error_mark_node; - if (TREE_VALUE (rhs) == error_mark_node) + if (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node) return error_mark_node; if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE) |