Commit c7222c02 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (ICS_USER_FLAG): Remove comment about obsolete flag.

	* cp-tree.h (ICS_USER_FLAG): Remove comment about obsolete flag.
	(DECL_MEMBER_TEMPLATE_P): New macro.
	(is_member_template): Remove.
	(class_method_index_for_fn): New function.
	* pt.c (build_over_call): Use DECL_MEMBER_TEMPLATE_P.
	* class.c (finish_struct_methods): Remove out-of-date comment.
	* decl.c (copy_fn_p): Use DECL_MBMER_TEMPLATE_P.
	* decl2.c (check_classfn): Use DECL_MEMBER_TEMPLATE_P and
	class_method_index_for_fn.
	* pt.c (is_member_template): Remove.
	(is_member_template_class): Likewise.
	(optimize_specialization_lookup_p): New function.
	(retrieve_specialization): Optimize lookups for members that are
	not member templates.
	(register_specialization): Adjust accordingly.
	(build_template_decl): Add member_template_p parameter.  Set
	DECL_MEMBER_TEMPLATE_P.
	(process_partial_specialization): Adjust call to
	retrieve_specialization.
	(push_template_decl_real): Determine whether the template is a
	member template.
	(lookup_template_class): Use retrieve_specialization.
	(tsubst_decl): Adjust call to retrieve_specialization.
	(tsubst_exception_specification): New function.
	(tsubst): Use it.
	(tsubst_copy): Use DECL_MEMBER_TEMPLATE_P.
	(instantiate_template): Adjust call to retrieve_specialization.
	(regenerate_decl_from_template): Do not actually generate a new
	DECL.
	(instantiate_decl): Adjust call to retrieve_specialization.
	(class_method_index_for_fn): New method.

From-SVN: r88697
parent d0e75c71
2004-10-07 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (ICS_USER_FLAG): Remove comment about obsolete flag.
(DECL_MEMBER_TEMPLATE_P): New macro.
(is_member_template): Remove.
(class_method_index_for_fn): New function.
* pt.c (build_over_call): Use DECL_MEMBER_TEMPLATE_P.
* class.c (finish_struct_methods): Remove out-of-date comment.
* decl.c (copy_fn_p): Use DECL_MBMER_TEMPLATE_P.
* decl2.c (check_classfn): Use DECL_MEMBER_TEMPLATE_P and
class_method_index_for_fn.
* pt.c (is_member_template): Remove.
(is_member_template_class): Likewise.
(optimize_specialization_lookup_p): New function.
(retrieve_specialization): Optimize lookups for members that are
not member templates.
(register_specialization): Adjust accordingly.
(build_template_decl): Add member_template_p parameter. Set
DECL_MEMBER_TEMPLATE_P.
(process_partial_specialization): Adjust call to
retrieve_specialization.
(push_template_decl_real): Determine whether the template is a
member template.
(lookup_template_class): Use retrieve_specialization.
(tsubst_decl): Adjust call to retrieve_specialization.
(tsubst_exception_specification): New function.
(tsubst): Use it.
(tsubst_copy): Use DECL_MEMBER_TEMPLATE_P.
(instantiate_template): Adjust call to retrieve_specialization.
(regenerate_decl_from_template): Do not actually generate a new
DECL.
(instantiate_decl): Adjust call to retrieve_specialization.
(class_method_index_for_fn): New method.
2004-10-07 Andrew Pinski <pinskia@physics.uc.edu> 2004-10-07 Andrew Pinski <pinskia@physics.uc.edu>
* parser.c (cp_parser_asm_definition): Look passed the * parser.c (cp_parser_asm_definition): Look passed the
......
...@@ -4614,7 +4614,7 @@ build_over_call (struct z_candidate *cand, int flags) ...@@ -4614,7 +4614,7 @@ build_over_call (struct z_candidate *cand, int flags)
primary template because `B<T>::g' and `B<int>::g' may have primary template because `B<T>::g' and `B<int>::g' may have
different access. */ different access. */
if (DECL_TEMPLATE_INFO (fn) if (DECL_TEMPLATE_INFO (fn)
&& is_member_template (DECL_TI_TEMPLATE (fn))) && DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (fn)))
perform_or_defer_access_check (cand->access_path, perform_or_defer_access_check (cand->access_path,
DECL_TI_TEMPLATE (fn)); DECL_TI_TEMPLATE (fn));
else else
......
...@@ -1657,17 +1657,7 @@ resort_type_method_vec (void* obj, ...@@ -1657,17 +1657,7 @@ resort_type_method_vec (void* obj,
} }
} }
/* Warn about duplicate methods in fn_fields. Also compact method /* Warn about duplicate methods in fn_fields.
lists so that lookup can be made faster.
Data Structure: List of method lists. The outer list is a
TREE_LIST, whose TREE_PURPOSE field is the field name and the
TREE_VALUE is the DECL_CHAIN of the FUNCTION_DECLs. TREE_CHAIN
links the entire list of methods for TYPE_METHODS. Friends are
chained in the same way as member functions (? TREE_CHAIN or
DECL_CHAIN), but they live in the TREE_TYPE field of the outer
list. That allows them to be quickly deleted, and requires no
extra storage.
Sort methods that are not special (i.e., constructors, destructors, Sort methods that are not special (i.e., constructors, destructors,
and type conversion operators) so that we can find them faster in and type conversion operators) so that we can find them faster in
...@@ -1686,11 +1676,9 @@ finish_struct_methods (tree t) ...@@ -1686,11 +1676,9 @@ finish_struct_methods (tree t)
len = VEC_length (tree, method_vec); len = VEC_length (tree, method_vec);
/* First fill in entry 0 with the constructors, entry 1 with destructors, /* Clear DECL_IN_AGGR_P for all functions. */
and the next few with type conversion operators (if any). */
for (fn_fields = TYPE_METHODS (t); fn_fields; for (fn_fields = TYPE_METHODS (t); fn_fields;
fn_fields = TREE_CHAIN (fn_fields)) fn_fields = TREE_CHAIN (fn_fields))
/* Clear out this flag. */
DECL_IN_AGGR_P (fn_fields) = 0; DECL_IN_AGGR_P (fn_fields) = 0;
if (TYPE_HAS_DESTRUCTOR (t) && !CLASSTYPE_DESTRUCTORS (t)) if (TYPE_HAS_DESTRUCTOR (t) && !CLASSTYPE_DESTRUCTORS (t))
......
...@@ -39,7 +39,6 @@ struct diagnostic_context; ...@@ -39,7 +39,6 @@ struct diagnostic_context;
DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR). DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR). COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR).
TREE_INDIRECT_USING (in NAMESPACE_DECL). TREE_INDIRECT_USING (in NAMESPACE_DECL).
ICS_USER_FLAG (in _CONV)
CLEANUP_P (in TRY_BLOCK) CLEANUP_P (in TRY_BLOCK)
AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR) AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR)
PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF) PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF)
...@@ -90,6 +89,7 @@ struct diagnostic_context; ...@@ -90,6 +89,7 @@ struct diagnostic_context;
DECL_MUTABLE_P (in FIELD_DECL) DECL_MUTABLE_P (in FIELD_DECL)
1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_DECL). 1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_DECL).
DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL) DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL)
DECL_MEMBER_TEMPLATE_P (in TEMPLATE_DECL)
2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL). 2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL).
DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL) DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL)
3: DECL_IN_AGGR_P. 3: DECL_IN_AGGR_P.
...@@ -2177,6 +2177,11 @@ struct lang_decl GTY(()) ...@@ -2177,6 +2177,11 @@ struct lang_decl GTY(())
#define INNERMOST_TEMPLATE_PARMS(NODE) TREE_VALUE (NODE) #define INNERMOST_TEMPLATE_PARMS(NODE) TREE_VALUE (NODE)
/* Nonzero if NODE (a TEMPLATE_DECL) is a member template, in the
sense of [temp.mem]. */
#define DECL_MEMBER_TEMPLATE_P(NODE) \
(DECL_LANG_FLAG_1 (TEMPLATE_DECL_CHECK (NODE)))
/* Nonzero if the NODE corresponds to the template parameters for a /* Nonzero if the NODE corresponds to the template parameters for a
member template, whose inline definition is being processed after member template, whose inline definition is being processed after
the class definition is complete. */ the class definition is complete. */
...@@ -3930,7 +3935,6 @@ extern tree instantiate_decl (tree, int, int); ...@@ -3930,7 +3935,6 @@ extern tree instantiate_decl (tree, int, int);
extern int push_tinst_level (tree); extern int push_tinst_level (tree);
extern void pop_tinst_level (void); extern void pop_tinst_level (void);
extern int more_specialized_class (tree, tree, tree); extern int more_specialized_class (tree, tree, tree);
extern int is_member_template (tree);
extern int comp_template_parms (tree, tree); extern int comp_template_parms (tree, tree);
extern int template_class_depth (tree); extern int template_class_depth (tree);
extern int is_specialization_of (tree, tree); extern int is_specialization_of (tree, tree);
...@@ -3990,6 +3994,7 @@ extern int accessible_p (tree, tree); ...@@ -3990,6 +3994,7 @@ extern int accessible_p (tree, tree);
extern tree lookup_field_1 (tree, tree, bool); extern tree lookup_field_1 (tree, tree, bool);
extern tree lookup_field (tree, tree, int, bool); extern tree lookup_field (tree, tree, int, bool);
extern int lookup_fnfields_1 (tree, tree); extern int lookup_fnfields_1 (tree, tree);
extern int class_method_index_for_fn (tree, tree);
extern tree lookup_fnfields (tree, tree, int); extern tree lookup_fnfields (tree, tree, int);
extern tree lookup_member (tree, tree, int, bool); extern tree lookup_member (tree, tree, int, bool);
extern int look_for_overrides (tree, tree); extern int look_for_overrides (tree, tree);
......
...@@ -8477,7 +8477,8 @@ copy_fn_p (tree d) ...@@ -8477,7 +8477,8 @@ copy_fn_p (tree d)
gcc_assert (DECL_FUNCTION_MEMBER_P (d)); gcc_assert (DECL_FUNCTION_MEMBER_P (d));
if (DECL_TEMPLATE_INFO (d) && is_member_template (DECL_TI_TEMPLATE (d))) if (DECL_TEMPLATE_INFO (d)
&& DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (d)))
/* Instantiations of template member functions are never copy /* Instantiations of template member functions are never copy
functions. Note that member functions of templated classes are functions. Note that member functions of templated classes are
represented as template functions internally, and we must represented as template functions internally, and we must
......
...@@ -596,7 +596,7 @@ check_classfn (tree ctype, tree function, tree template_parms) ...@@ -596,7 +596,7 @@ check_classfn (tree ctype, tree function, tree template_parms)
if (DECL_USE_TEMPLATE (function) if (DECL_USE_TEMPLATE (function)
&& !(TREE_CODE (function) == TEMPLATE_DECL && !(TREE_CODE (function) == TEMPLATE_DECL
&& DECL_TEMPLATE_SPECIALIZATION (function)) && DECL_TEMPLATE_SPECIALIZATION (function))
&& is_member_template (DECL_TI_TEMPLATE (function))) && DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (function)))
/* Since this is a specialization of a member template, /* Since this is a specialization of a member template,
we're not going to find the declaration in the class. we're not going to find the declaration in the class.
For example, in: For example, in:
...@@ -622,11 +622,7 @@ check_classfn (tree ctype, tree function, tree template_parms) ...@@ -622,11 +622,7 @@ check_classfn (tree ctype, tree function, tree template_parms)
/* OK, is this a definition of a member template? */ /* OK, is this a definition of a member template? */
is_template = (template_parms != NULL_TREE); is_template = (template_parms != NULL_TREE);
ix = lookup_fnfields_1 (complete_type (ctype), ix = class_method_index_for_fn (complete_type (ctype), function);
DECL_CONSTRUCTOR_P (function) ? ctor_identifier :
DECL_DESTRUCTOR_P (function) ? dtor_identifier :
DECL_NAME (function));
if (ix >= 0) if (ix >= 0)
{ {
VEC(tree) *methods = CLASSTYPE_METHOD_VEC (ctype); VEC(tree) *methods = CLASSTYPE_METHOD_VEC (ctype);
......
...@@ -1464,6 +1464,22 @@ lookup_fnfields_1 (tree type, tree name) ...@@ -1464,6 +1464,22 @@ lookup_fnfields_1 (tree type, tree name)
return -1; return -1;
} }
/* Like lookup_fnfields_1, except that the name is extracted from
FUNCTION, which is a FUNCTION_DECL or a TEMPLATE_DECL. */
int
class_method_index_for_fn (tree class_type, tree function)
{
gcc_assert (TREE_CODE (function) == FUNCTION_DECL
|| DECL_FUNCTION_TEMPLATE_P (function));
return lookup_fnfields_1 (class_type,
DECL_CONSTRUCTOR_P (function) ? ctor_identifier :
DECL_DESTRUCTOR_P (function) ? dtor_identifier :
DECL_NAME (function));
}
/* DECL is the result of a qualified name lookup. QUALIFYING_SCOPE is /* DECL is the result of a qualified name lookup. QUALIFYING_SCOPE is
the class or namespace used to qualify the name. CONTEXT_CLASS is the class or namespace used to qualify the name. CONTEXT_CLASS is
the class corresponding to the object in which DECL will be used. the class corresponding to the object in which DECL will be used.
......
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