Commit 8f032717 by Mark Mitchell Committed by Mark Mitchell

tinfo.h (__class_type_info): Fix illegal declaration.

1999-04-02  Mark Mitchell  <mark@codesourcery.com>
	* tinfo.h (__class_type_info): Fix illegal declaration.
	* cp-tree.def (TEMPLATE_ID_EXPR): Update comment.
	* cp-tree.h (INHERITED_VALUE_BINDING_P): New macro.
	(IDENTIFIER_CLASS_VALUE): Improve documentation.
	(is_properly_derived_from): Declare.
	(invalidate_class_lookup_cache): Likewise.
	(maybe_maybe_note_name_used_in_class): Likewise.
	(note_name_declared_in_class): Likewise.
	(push_using_decl): Remove duplicate declaration.
	(id_in_current_class): Remove declaration.
	(push_class_binding): Change prototype.
	(clear_identitifer_class_values): Declare.
	* call.c (is_properly_derived_from): Make it global.
	(build_new_function_call): Be careful about updating candidates.
	(build_new_method_call): Handle COMPONENT_REFs.  Don't crash when
	asked to make illegal calls.
	* class.c: Include splay-tree.h.
	(class_stack_node): Add names_used slot.
	(check_member_decl_is_same_in_complete_scope): Remove.
	(add_method): Fix comment.  Push the declaration into class
	scope.
	(finish_struct_1): When popping the class, pop the bindings too.
	Remove check for data member/function member conflict.
	(finish_struct): Remove calls to
	check_member_decl_is_same_in_complete_scope.  Change calls to
	popclass.
	(pushclass): Clear names_used in the class stack entry.
	Use invalidate_class_lookup_cache to remove cached entries, rather
	than magic values with popclass.  Clear IDENTIFIER_CLASS_VALUE
	before entering a new class.  Remove dead code.  Don't mess with
	current_function_decl when pushing declarations.
	(invalidate_class_lookup_cache): New function, split out from ...
	(popclass): Here.  Clean up names_used on our way out.
	(instantiate_type): Adjust.
	(build_self_reference): Don't push the declaration here.
	(maybe_note_name_used_in_class): New function.
	(note_name_declared_in_class): Likewise.
	* decl.c (add_binding): Change prototype.
	(find_class_binding_level): New function.
	(innermost_nonclass_level): Likewise.
	(current_binding_level): Update documentation.
	(inner_binding_level): Remove.  Replace with current_binding_level
	throughout.
	(push_binding_level): Remove special handling of
	class_binding_level.
	(pop_binding_level): Likewise.  Use find_class_binding_level.
	(suspend_binding_level): Likewise.
	(global_bindings_p): Use innermost_nonclass_level.
	(toplevel_bindings_p): Likewise.
	(namespace_bindings_p): Likewise.
	(pseudo_global_level_p): Likewise.
	(push_binding): Clear INHERITED_VALUE_BINDING_P.
	(add_binding): Check for illegal multiple declarations.  Return a
	value indicating whether or not the new binding was legal.
	(push_local_binding): Skip over class binding levels.  Check
	return value from add_binding.
	(push_class_binding): Set INHERITED_VALUE_BINDING_P.  Call
	note_name_declared_in_class.
	(pushlevel_class): Remove "fake out the rest of the compiler"
	code.
	(poplevel_class): Reset IDENTIFIER_CLASS_VALUEs.
	(clear_identifier_class_values): New function.
	(pop_from_top_level): Use it.
	(pop_everything): Tweak.
	(maybe_process_template_type_declaration): Don't push the
	declaration for the template here.
	(pushtag): Don't push tag declarations into class scope here.
	(pushdecl): Apply DeMorgan's law for readability.
	(pushdecl_class_level): Remove special-case code for
	TYPE_BEING_DEFINED.  Handle OVERLOADs and anonymous unions.
	(push_class_level_bindng): Deal with inherited bindings.
	(lookup_name_real): Remove special-case code for
	TYPE_BEING_DEFINED, and some implicit typename magic.
	(grokdeclarator): Handle COMPONENT_REF for a template function.
	(build_enumerator): Don't call pushdecl_class_level here.
	(id_in_current_class): Remove.
	* decl2.c (grokfield): Don't call pushdecl_class_level or
	check_template_shadow.
	* errfn.c (cp_file_of): Don't declare.
	(cp_line_of): Likewise.
	* error.c (dump_decl): Handle an OVERLOAD.
	(cp_file_of): Likewise.
	(cp_line_of): Likewise.
	* init.c (build_member_call): Handle a COMPONENT_REF.
	* lex.c (do_identifier): Call maybe_note_name_used_in_class, not
	pushdecl_class_level.
	* method.c (hack_identifier): Build COMPONENT_REFs for references
	to member templates as well as member functions.  Remove dead
	code.
	* parse.y (left_curly): Remove.
	(nonnested_type): Call maybe_note_name_used_in_class, not
	pushdecl_class_level.
	* parse.c: Regenerated.
	(nested_name_specifier_1): Likewise.
	* pt.c (check_explicit_specialization): Adjust, for robustness.
	(check_template_shadow): Handle OVERLOADs.
	(build_template_decl): Set DECL_CONSTRUCTOR_P on the
	TEMPLATE_DECL, if appropriate.
	* search.c (envelope_add_decl): Remove.
	(dfs_pushdecls): Likewise.
	(dfs_compress_decls): Likewise.
	(dfs_push_decls): New function.
	(dfs_push_type_decls): Likewise.
	(setup_class_bindings): Likewise.
	(template_self_reference_p): Likewise.
	(lookup_field_r): Use it.
	(looup_member): Remove old comment.  Deal with ambiguity.
	(push_class_decls): Use dfs_push_decls and dfs_push_type_decls,
	and remove envelope processing.
	* semantics.c (begin_class_definition): Let pushclass push
	declarations for base classes.
	(finish_member_declaration): Push declarations into class scope.
	* typeck.c (build_component_ref): Just put an OVERLOAD into the
	COMPONENT_REF, not a TREE_LIST of an OVERLOAD.
	(build_x_function_call): Deal with OVERLOAD.  Handle template-ids.
	* Makefile.in (class.o): Depend on splay-tree.h.

From-SVN: r26133
parent ae7f7270
1999-04-02 Mark Mitchell <mark@codesourcery.com>
* tinfo.h (__class_type_info): Fix illegal declaration.
* cp-tree.def (TEMPLATE_ID_EXPR): Update comment.
* cp-tree.h (INHERITED_VALUE_BINDING_P): New macro.
(IDENTIFIER_CLASS_VALUE): Improve documentation.
(is_properly_derived_from): Declare.
(invalidate_class_lookup_cache): Likewise.
(maybe_maybe_note_name_used_in_class): Likewise.
(note_name_declared_in_class): Likewise.
(push_using_decl): Remove duplicate declaration.
(id_in_current_class): Remove declaration.
(push_class_binding): Change prototype.
(clear_identitifer_class_values): Declare.
* call.c (is_properly_derived_from): Make it global.
(build_new_function_call): Be careful about updating candidates.
(build_new_method_call): Handle COMPONENT_REFs. Don't crash when
asked to make illegal calls.
* class.c: Include splay-tree.h.
(class_stack_node): Add names_used slot.
(check_member_decl_is_same_in_complete_scope): Remove.
(add_method): Fix comment. Push the declaration into class
scope.
(finish_struct_1): When popping the class, pop the bindings too.
Remove check for data member/function member conflict.
(finish_struct): Remove calls to
check_member_decl_is_same_in_complete_scope. Change calls to
popclass.
(pushclass): Clear names_used in the class stack entry.
Use invalidate_class_lookup_cache to remove cached entries, rather
than magic values with popclass. Clear IDENTIFIER_CLASS_VALUE
before entering a new class. Remove dead code. Don't mess with
current_function_decl when pushing declarations.
(invalidate_class_lookup_cache): New function, split out from ...
(popclass): Here. Clean up names_used on our way out.
(instantiate_type): Adjust.
(build_self_reference): Don't push the declaration here.
(maybe_note_name_used_in_class): New function.
(note_name_declared_in_class): Likewise.
* decl.c (add_binding): Change prototype.
(find_class_binding_level): New function.
(innermost_nonclass_level): Likewise.
(current_binding_level): Update documentation.
(inner_binding_level): Remove. Replace with current_binding_level
throughout.
(push_binding_level): Remove special handling of
class_binding_level.
(pop_binding_level): Likewise. Use find_class_binding_level.
(suspend_binding_level): Likewise.
(global_bindings_p): Use innermost_nonclass_level.
(toplevel_bindings_p): Likewise.
(namespace_bindings_p): Likewise.
(pseudo_global_level_p): Likewise.
(push_binding): Clear INHERITED_VALUE_BINDING_P.
(add_binding): Check for illegal multiple declarations. Return a
value indicating whether or not the new binding was legal.
(push_local_binding): Skip over class binding levels. Check
return value from add_binding.
(push_class_binding): Set INHERITED_VALUE_BINDING_P. Call
note_name_declared_in_class.
(pushlevel_class): Remove "fake out the rest of the compiler"
code.
(poplevel_class): Reset IDENTIFIER_CLASS_VALUEs.
(clear_identifier_class_values): New function.
(pop_from_top_level): Use it.
(pop_everything): Tweak.
(maybe_process_template_type_declaration): Don't push the
declaration for the template here.
(pushtag): Don't push tag declarations into class scope here.
(pushdecl): Apply DeMorgan's law for readability.
(pushdecl_class_level): Remove special-case code for
TYPE_BEING_DEFINED. Handle OVERLOADs and anonymous unions.
(push_class_level_bindng): Deal with inherited bindings.
(lookup_name_real): Remove special-case code for
TYPE_BEING_DEFINED, and some implicit typename magic.
(grokdeclarator): Handle COMPONENT_REF for a template function.
(build_enumerator): Don't call pushdecl_class_level here.
(id_in_current_class): Remove.
* decl2.c (grokfield): Don't call pushdecl_class_level or
check_template_shadow.
* errfn.c (cp_file_of): Don't declare.
(cp_line_of): Likewise.
* error.c (dump_decl): Handle an OVERLOAD.
(cp_file_of): Likewise.
(cp_line_of): Likewise.
* init.c (build_member_call): Handle a COMPONENT_REF.
* lex.c (do_identifier): Call maybe_note_name_used_in_class, not
pushdecl_class_level.
* method.c (hack_identifier): Build COMPONENT_REFs for references
to member templates as well as member functions. Remove dead
code.
* parse.y (left_curly): Remove.
(nonnested_type): Call maybe_note_name_used_in_class, not
pushdecl_class_level.
* parse.c: Regenerated.
(nested_name_specifier_1): Likewise.
* pt.c (check_explicit_specialization): Adjust, for robustness.
(check_template_shadow): Handle OVERLOADs.
(build_template_decl): Set DECL_CONSTRUCTOR_P on the
TEMPLATE_DECL, if appropriate.
* search.c (envelope_add_decl): Remove.
(dfs_pushdecls): Likewise.
(dfs_compress_decls): Likewise.
(dfs_push_decls): New function.
(dfs_push_type_decls): Likewise.
(setup_class_bindings): Likewise.
(template_self_reference_p): Likewise.
(lookup_field_r): Use it.
(looup_member): Remove old comment. Deal with ambiguity.
(push_class_decls): Use dfs_push_decls and dfs_push_type_decls,
and remove envelope processing.
* semantics.c (begin_class_definition): Let pushclass push
declarations for base classes.
(finish_member_declaration): Push declarations into class scope.
* typeck.c (build_component_ref): Just put an OVERLOAD into the
COMPONENT_REF, not a TREE_LIST of an OVERLOAD.
(build_x_function_call): Deal with OVERLOAD. Handle template-ids.
* Makefile.in (class.o): Depend on splay-tree.h.
Wed Mar 31 11:30:43 BST 1999 Nathan Sidwell <nathan@acm.org>
* cvt.c (convert_pointer_to_real): Use same_type_p.
......
......@@ -267,7 +267,8 @@ typeck2.o : typeck2.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
typeck.o : typeck.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H) \
$(EXPR_H) $(srcdir)/../system.h $(srcdir)/../toplev.h
class.o : class.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
$(srcdir)/../system.h $(srcdir)/../toplev.h
$(srcdir)/../system.h $(srcdir)/../toplev.h \
$(srcdir)/../../include/splay-tree.h
call.o : call.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
$(srcdir)/../system.h $(srcdir)/../toplev.h
friend.o : friend.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H) \
......
......@@ -87,7 +87,6 @@ static tree strip_top_quals PROTO((tree));
static tree non_reference PROTO((tree));
static tree build_conv PROTO((enum tree_code, tree, tree));
static int is_subseq PROTO((tree, tree));
static int is_properly_derived_from PROTO((tree, tree));
static int maybe_handle_ref_bind PROTO((tree*, tree*));
static void maybe_handle_implicit_object PROTO((tree*));
static struct z_candidate * add_candidate PROTO((struct z_candidate *,
......@@ -2312,6 +2311,8 @@ build_new_function_call (fn, args)
for (t1 = fn; t1; t1 = OVL_CHAIN (t1))
{
tree t = OVL_FUNCTION (t1);
struct z_candidate *old_candidates = candidates;
if (TREE_CODE (t) == TEMPLATE_DECL)
{
templates = scratch_tree_cons (NULL_TREE, t, templates);
......@@ -2322,6 +2323,9 @@ build_new_function_call (fn, args)
else if (! template_only)
candidates = add_function_candidate
(candidates, t, args, LOOKUP_NORMAL);
if (candidates != old_candidates)
candidates->basetype_path = DECL_REAL_CONTEXT (t);
}
if (! any_viable (candidates))
......@@ -3524,8 +3528,16 @@ build_new_method_call (instance, name, args, basetype_path, flags)
{
explicit_targs = TREE_OPERAND (name, 1);
name = TREE_OPERAND (name, 0);
if (TREE_CODE (name) == TEMPLATE_DECL)
if (TREE_CODE_CLASS (TREE_CODE (name)) == 'd')
name = DECL_NAME (name);
else
{
if (TREE_CODE (name) == COMPONENT_REF)
name = TREE_OPERAND (name, 1);
if (TREE_CODE (name) == OVERLOAD)
name = DECL_NAME (OVL_CURRENT (name));
}
template_only = 1;
}
......@@ -3675,7 +3687,10 @@ build_new_method_call (instance, name, args, basetype_path, flags)
cp_error ("abstract virtual `%#D' called from constructor", cand->fn);
if (TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE
&& is_dummy_object (instance_ptr))
cp_error ("cannot call member function `%D' without object", cand->fn);
{
cp_error ("cannot call member function `%D' without object", cand->fn);
return error_mark_node;
}
if (DECL_VINDEX (cand->fn) && ! (flags & LOOKUP_NONVIRTUAL)
&& ((instance == current_class_ref && (dtor_label || ctor_label))
......@@ -3738,7 +3753,7 @@ is_subseq (ics1, ics2)
/* Returns non-zero iff DERIVED is derived from BASE. The inputs may
be any _TYPE nodes. */
static int
int
is_properly_derived_from (derived, base)
tree derived;
tree base;
......
......@@ -170,12 +170,11 @@ DEFTREECODE (USING_DECL, "using_decl", 'd', 0)
/* An un-parsed default argument. Looks like an IDENTIFIER_NODE. */
DEFTREECODE (DEFAULT_ARG, "default_arg", 'c', 2)
/* A template-id, like foo<int>. The first operand is the template.
The second is the list of explicitly specified arguments. The
template will be a FUNCTION_DECL, TEMPLATE_DECL, or a list of
overloaded functions and templates if the template-id refers to
a global template. If the template-id refers to a member template,
the template may be an IDENTIFIER_NODE. */
/* A template-id, like foo<int>. The first operand is the template.
The second is the list of explicitly specified arguments. The
template will be a FUNCTION_DECL, TEMPLATE_DECL, or an OVERLOAD.
If the template-id refers to a member template, the template may be
an IDENTIFIER_NODE. */
DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", 'e', 2)
/* An association between name and entity. Parameters are the scope
......
......@@ -40,6 +40,7 @@ Boston, MA 02111-1307, USA. */
(TREE_CALLS_NEW) (in _EXPR or _REF) (commented-out).
TYPE_USES_COMPLEX_INHERITANCE (in _TYPE).
C_DECLARED_LABEL_FLAG.
INHERITED_VALUE_BINDING_P (in CPLUS_BINDING)
2: IDENTIFIER_OPNAME_P.
BINFO_VBASE_MARKED.
BINFO_FIELDS_MARKED.
......@@ -134,6 +135,10 @@ typedef struct ptrmem_cst
or namespace scope. */
#define LOCAL_BINDING_P(NODE) TREE_LANG_FLAG_0(NODE)
/* Nonzero if BINDING_VALUE is from a base class of the class which is
currently being defined. */
#define INHERITED_VALUE_BINDING_P(NODE) TREE_LANG_FLAG_1(NODE)
/* For a binding between a name and an entity at a non-local scope,
defines the scope where the binding is declared. (Either a class
_TYPE node, or a NAMESPACE_DECL.) This macro should be used only
......@@ -235,10 +240,10 @@ struct tree_srcloc
? BINDING_VALUE (IDENTIFIER_BINDING (NODE)) \
: NULL_TREE)
/* If we are currently in class scope, then IDENTIFIER_CLASS_VALUE
indicates the class-scoped binding of NODE. This is just a pointer
to the BINDING_VALUE of one of the bindings in the
IDENTIFIER_BINDINGs list, so any time that this is set so is
/* If IDENTIFIER_CLASS_VALUE is set, then NODE is bound in the current
class, and IDENTIFIER_CLASS_VALUE is the value binding. This is
just a pointer to the BINDING_VALUE of one of the bindings in the
IDENTIFIER_BINDINGs list, so any time that this is non-NULL so is
IDENTIFIER_BINDING. */
#define IDENTIFIER_CLASS_VALUE(NODE) \
(((struct lang_identifier *) (NODE))->class_value)
......@@ -2684,6 +2689,7 @@ extern int can_convert_arg PROTO((tree, tree, tree));
extern int enforce_access PROTO((tree, tree));
extern tree convert_default_arg PROTO((tree, tree, tree));
extern tree convert_arg_to_ellipsis PROTO((tree));
extern int is_properly_derived_from PROTO((tree, tree));
/* in class.c */
extern tree build_vbase_path PROTO((enum tree_code, tree, tree, tree, int));
......@@ -2713,6 +2719,9 @@ extern void warn_hidden PROTO((tree));
extern tree get_enclosing_class PROTO((tree));
int is_base_of_enclosing_class PROTO((tree, tree));
extern void unreverse_member_declarations PROTO((tree));
extern void invalidate_class_lookup_cache PROTO((void));
extern void maybe_note_name_used_in_class PROTO((tree, tree));
extern void note_name_declared_in_class PROTO((tree, tree));
/* in cvt.c */
extern tree convert_to_reference PROTO((tree, tree, int, int, tree));
......@@ -2776,7 +2785,6 @@ extern tree pushdecl_namespace_level PROTO((tree));
extern tree push_using_decl PROTO((tree, tree));
extern tree push_using_directive PROTO((tree));
extern void push_class_level_binding PROTO((tree, tree));
extern tree push_using_decl PROTO((tree, tree));
extern tree implicitly_declare PROTO((tree));
extern tree lookup_label PROTO((tree));
extern tree shadow_label PROTO((tree));
......@@ -2845,7 +2853,6 @@ extern tree maybe_build_cleanup_and_delete PROTO((tree));
extern tree maybe_build_cleanup PROTO((tree));
extern void cplus_expand_expr_stmt PROTO((tree));
extern void finish_stmt PROTO((void));
extern int id_in_current_class PROTO((tree));
extern void push_cp_function_context PROTO((tree));
extern void pop_cp_function_context PROTO((tree));
extern int in_function_p PROTO((void));
......@@ -2856,9 +2863,10 @@ extern void cat_namespace_levels PROTO((void));
extern void fixup_anonymous_union PROTO((tree));
extern int check_static_variable_definition PROTO((tree, tree));
extern void push_local_binding PROTO((tree, tree, int));
extern void push_class_binding PROTO((tree, tree));
extern int push_class_binding PROTO((tree, tree));
extern tree check_default_argument PROTO((tree, tree));
extern tree push_overloaded_decl PROTO((tree, int));
extern void clear_identifier_class_values PROTO((void));
/* in decl2.c */
extern int check_java_method PROTO((tree));
......
......@@ -1525,7 +1525,6 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
DECL_ASSEMBLER_NAME (value) =
get_identifier (build_overload_name (TREE_TYPE (value), 1, 1));
pushdecl_class_level (value);
return value;
}
......@@ -1611,8 +1610,6 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
&& (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == FUNCTION_DECL))
value = push_template_decl (value);
check_template_shadow (value);
if (attrlist)
cplus_decl_attributes (value, TREE_PURPOSE (attrlist),
TREE_VALUE (attrlist));
......@@ -1656,7 +1653,6 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
DECL_CLASS_CONTEXT (value) = current_class_type;
cp_finish_decl (value, init, asmspec_tree, 1, flags);
pushdecl_class_level (value);
return value;
}
if (TREE_CODE (value) == FIELD_DECL)
......
......@@ -41,8 +41,6 @@ int cp_silent = 0;
typedef void errorfn (); /* deliberately vague */
static void cp_thing PROTO ((errorfn *, int, const char *, va_list));
extern char* cp_file_of PROTO((tree));
extern int cp_line_of PROTO((tree));
#define STRDUP(f) (ap = (char *) alloca (strlen (f) +1), strcpy (ap, (f)), ap)
......
......@@ -806,6 +806,10 @@ dump_decl (t, v)
}
break;
case OVERLOAD:
t = OVL_CURRENT (t);
/* Fall through. */
case FUNCTION_DECL:
if (GLOBAL_IORD_P (DECL_ASSEMBLER_NAME (t)))
dump_global_iord (DECL_ASSEMBLER_NAME (t));
......@@ -1928,6 +1932,8 @@ cp_file_of (t)
return DECL_SOURCE_FILE (DECL_CONTEXT (t));
else if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t));
else if (TREE_CODE (t) == OVERLOAD)
return DECL_SOURCE_FILE (OVL_FUNCTION (t));
else
return DECL_SOURCE_FILE (t);
}
......@@ -1945,6 +1951,8 @@ cp_line_of (t)
if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
line = DECL_SOURCE_LINE (TYPE_MAIN_DECL (t));
else if (TREE_CODE (t) == OVERLOAD)
line = DECL_SOURCE_LINE (OVL_FUNCTION (t));
else
line = DECL_SOURCE_LINE (t);
......
......@@ -1377,14 +1377,17 @@ build_member_call (type, name, parmlist)
return build_x_function_call (lookup_namespace_name (type, name),
parmlist, current_class_ref);
if (TREE_CODE (name) != TEMPLATE_ID_EXPR)
method_name = name;
else
if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
{
method_name = TREE_OPERAND (name, 0);
if (TREE_CODE (method_name) == COMPONENT_REF)
method_name = TREE_OPERAND (method_name, 1);
if (is_overloaded_fn (method_name))
method_name = DECL_NAME (OVL_CURRENT (method_name));
TREE_OPERAND (name, 0) = method_name;
}
else
method_name = name;
if (TREE_CODE (method_name) == BIT_NOT_EXPR)
{
......
......@@ -2878,15 +2878,13 @@ do_identifier (token, parsing, args)
/* Remember that this name has been used in the class definition, as per
[class.scope0] */
if (id && current_class_type && parsing
&& TYPE_BEING_DEFINED (current_class_type)
&& ! IDENTIFIER_CLASS_VALUE (token)
if (id && parsing
/* Avoid breaking if we get called for a default argument that
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) != OVERLOAD)
pushdecl_class_level (id);
maybe_note_name_used_in_class (token, id);
if (id == error_mark_node)
{
......
......@@ -1916,11 +1916,16 @@ hack_identifier (value, name)
TREE_USED (value) = 1;
value = build_component_ref (current_class_ref, name, NULL_TREE, 1);
}
else if (TREE_CODE (value) == FUNCTION_DECL
&& DECL_FUNCTION_MEMBER_P (value))
else if ((TREE_CODE (value) == FUNCTION_DECL
&& DECL_FUNCTION_MEMBER_P (value))
|| (TREE_CODE (value) == OVERLOAD
&& DECL_FUNCTION_MEMBER_P (OVL_CURRENT (value))))
{
tree decl;
if (TREE_CODE (value) == OVERLOAD)
value = OVL_CURRENT (value);
if (IS_SIGNATURE (DECL_CLASS_CONTEXT (value)))
return value;
......@@ -1928,19 +1933,7 @@ hack_identifier (value, name)
value = build_component_ref (decl, name, NULL_TREE, 1);
}
else if (really_overloaded_fn (value))
{
#if 0
tree t = get_first_fn (value);
for (; t; t = DECL_CHAIN (t))
{
if (TREE_CODE (t) == TEMPLATE_DECL)
continue;
assemble_external (t);
TREE_USED (t) = 1;
}
#endif
}
;
else if (TREE_CODE (value) == OVERLOAD)
/* not really overloaded function */
mark_used (OVL_FUNCTION (value));
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2138,7 +2138,8 @@ structsp:
if (!processing_template_decl)
cp_pedwarn ("using `typename' outside of template"); }
/* C++ extensions, merged with C to avoid shift/reduce conflicts */
| class_head left_curly
| class_head '{'
{ $<ttype>1 = begin_class_definition ($<ttype>1); }
opt.component_decl_list '}' maybe_attribute
{
int semi;
......@@ -2147,7 +2148,7 @@ structsp:
yychar = YYLEX;
semi = yychar == ';';
$<ttype>$ = finish_class_definition ($1, $5, semi);
$<ttype>$ = finish_class_definition ($1, $6, semi);
}
pending_defargs
{
......@@ -2156,7 +2157,7 @@ structsp:
pending_inlines
{
finish_inline_definitions ();
$$.t = $<ttype>6;
$$.t = $<ttype>7;
$$.new_type_flag = 1;
}
| class_head %prec EMPTY
......@@ -2404,11 +2405,6 @@ base_class_access_list:
}
;
left_curly:
'{'
{ $<ttype>0 = begin_class_definition ($<ttype>0); }
;
opt.component_decl_list:
| component_decl_list
| opt.component_decl_list access_specifier component_decl_list
......@@ -2758,14 +2754,7 @@ nonnested_type:
if (TREE_CODE ($1) == IDENTIFIER_NODE)
{
$$ = lookup_name ($1, 1);
if (current_class_type
&& TYPE_BEING_DEFINED (current_class_type)
&& ! IDENTIFIER_CLASS_VALUE ($1))
{
/* Remember that this name has been used in the class
definition, as per [class.scope0] */
pushdecl_class_level ($$);
}
maybe_note_name_used_in_class ($1, $$);
}
else
$$ = $1;
......@@ -2925,12 +2914,7 @@ nested_name_specifier_1:
if (TREE_CODE ($1) == IDENTIFIER_NODE)
{
$$ = lastiddecl;
/* Remember that this name has been used in the class
definition, as per [class.scope0] */
if (current_class_type
&& TYPE_BEING_DEFINED (current_class_type)
&& ! IDENTIFIER_CLASS_VALUE ($1))
pushdecl_class_level ($$);
maybe_note_name_used_in_class ($1, $$);
}
got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
}
......
......@@ -1304,16 +1304,6 @@ check_explicit_specialization (declarator, decl, template_count, flags)
if (declarator == error_mark_node)
return error_mark_node;
if (TREE_CODE (TREE_OPERAND (declarator, 0)) == LOOKUP_EXPR)
{
/* A friend declaration. We can't do much, because we don't
know what this resolves to, yet. */
my_friendly_assert (is_friend != 0, 0);
my_friendly_assert (!explicit_instantiation, 0);
SET_DECL_IMPLICIT_INSTANTIATION (decl);
return decl;
}
if (ctype != NULL_TREE && TYPE_BEING_DEFINED (ctype))
{
if (!explicit_instantiation)
......@@ -1340,6 +1330,15 @@ check_explicit_specialization (declarator, decl, template_count, flags)
return decl;
}
else if (TREE_CODE (TREE_OPERAND (declarator, 0)) == LOOKUP_EXPR)
{
/* A friend declaration. We can't do much, because we don't
know what this resolves to, yet. */
my_friendly_assert (is_friend != 0, 0);
my_friendly_assert (!explicit_instantiation, 0);
SET_DECL_IMPLICIT_INSTANTIATION (decl);
return decl;
}
else if (ctype != NULL_TREE
&& (TREE_CODE (TREE_OPERAND (declarator, 0)) ==
IDENTIFIER_NODE))
......@@ -1598,7 +1597,11 @@ void
check_template_shadow (decl)
tree decl;
{
tree olddecl = IDENTIFIER_VALUE (DECL_NAME (decl));
tree olddecl;
if (TREE_CODE (decl) == OVERLOAD)
decl = OVL_CURRENT (decl);
olddecl = IDENTIFIER_VALUE (DECL_NAME (decl));
if (current_template_parms && olddecl)
{
......@@ -1888,8 +1891,8 @@ build_template_decl (decl, parms)
if (DECL_LANG_SPECIFIC (decl))
{
DECL_CLASS_CONTEXT (tmpl) = DECL_CLASS_CONTEXT (decl);
DECL_STATIC_FUNCTION_P (tmpl) =
DECL_STATIC_FUNCTION_P (decl);
DECL_STATIC_FUNCTION_P (tmpl) = DECL_STATIC_FUNCTION_P (decl);
DECL_CONSTRUCTOR_P (tmpl) = DECL_CONSTRUCTOR_P (decl);
}
return tmpl;
......
......@@ -1295,7 +1295,7 @@ begin_class_definition (t)
&& TYPE_CONTEXT (t) && TYPE_P (TYPE_CONTEXT (t))
&& ! current_class_type)
push_template_decl (TYPE_STUB_DECL (t));
pushclass (t, 0);
pushclass (t, 1);
TYPE_BEING_DEFINED (t) = 1;
/* Reset the interface data, at the earliest possible
moment, as it might have been set via a class foo;
......@@ -1419,6 +1419,10 @@ finish_member_declaration (decl)
TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
TYPE_FIELDS (current_class_type) = decl;
}
/* Enter the DECL into the scope of the class. */
if (TREE_CODE (decl) != USING_DECL)
pushdecl_class_level (decl);
}
}
......
......@@ -40,7 +40,7 @@ struct __class_type_info : public __user_type_info {
const __user_type_info *base;
USItype offset: 29;
bool is_virtual: 1;
access access: 2;
enum access access: 2;
};
const base_info *base_list;
......
......@@ -2191,7 +2191,7 @@ build_component_ref (datum, component, basetype_path, protect)
}
ref = build (COMPONENT_REF, unknown_type_node,
datum, fndecls);
datum, TREE_VALUE (fndecls));
return ref;
}
......@@ -2616,6 +2616,8 @@ build_x_function_call (function, params, decl)
&& current_class_type != NULL_TREE
&& (IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (function))
== function))
|| (TREE_CODE (function) == OVERLOAD
&& DECL_FUNCTION_MEMBER_P (OVL_CURRENT (function)))
|| TREE_CODE (function) == IDENTIFIER_NODE
|| TREE_CODE (type) == METHOD_TYPE
|| TYPE_PTRMEMFUNC_P (type));
......@@ -2629,6 +2631,9 @@ build_x_function_call (function, params, decl)
{
tree basetype = NULL_TREE;
if (TREE_CODE (function) == OVERLOAD)
function = OVL_CURRENT (function);
if (TREE_CODE (function) == FUNCTION_DECL
|| DECL_FUNCTION_TEMPLATE_P (function))
{
......@@ -2700,7 +2705,14 @@ build_x_function_call (function, params, decl)
/* Undo what we did in build_component_ref. */
decl = TREE_OPERAND (function, 0);
function = TREE_OPERAND (function, 1);
function = DECL_NAME (OVL_CURRENT (TREE_VALUE (function)));
function = DECL_NAME (OVL_CURRENT (function));
if (template_id)
{
TREE_OPERAND (template_id, 0) = function;
function = template_id;
}
return build_method_call (decl, function, params,
NULL_TREE, LOOKUP_NORMAL);
}
......
......@@ -123,7 +123,7 @@ public:
template <class U>
friend bool fooy(U u);
template <class T161> // ERROR - .*
template <class T161>
friend bool foo(T161 u)
{
Xseven<T161, 5, int> obj;
......
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
struct B {
struct X {};
};
struct D : public B {
void X();
struct X x;
void f();
};
void D::f()
{
struct X y;
}
......@@ -3,8 +3,6 @@
// Based on bug report by Klaus-Georg Adams
// <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
// crash test - XFAIL *-*-*
struct bar {
typedef bar t;
};
......
// Build don't link:
// Origin: Jason Merrill <jason@cygnus.com>
struct A { typedef int B; };
template <int B> struct C : public A {
B b;
void f();
};
template <int B>
void C<B>::f() {
B b;
}
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T>
class X{};
class Y : public X<int>
{
void f();
};
void Y::f()
{
X x; // ERROR - X is not a type.
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment