aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog97
-rw-r--r--gcc/cp/call.c2
-rw-r--r--gcc/cp/class.c137
-rw-r--r--gcc/cp/cp-tree.h26
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/cp/decl2.c8
-rw-r--r--gcc/cp/init.c12
-rw-r--r--gcc/cp/parser.c8
-rw-r--r--gcc/cp/pt.c524
-rw-r--r--gcc/cp/search.c404
-rw-r--r--gcc/cp/semantics.c1
11 files changed, 691 insertions, 531 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 13117b89f60..80ea39131e9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,100 @@
+2004-10-08 Kazu Hirata <kazu@cs.umass.edu>
+
+ * pt.c, search.c: Fix comment typos.
+
+2004-10-08 Nathan Sidwell <nathan@codesourcery.com>
+
+ * cp-tree.h (dfs_walk, dfs_walk_real, dfs_unmark, markedp,
+ unmarkedp): Remove.
+ (dfs_skip_bases, dfs_walk_all, dfs_walk_once): New.
+ * class.c (struct find_final_overrider_data): Remove most_derived,
+ vpath_list and vpath fields. Add path field.
+ (dfs_find_final_ocerrider_1): Add DEPTH parameter. Adjust.
+ (dfs_find_final_overrider): Rename to ...
+ (dfs_find_final_overrider_pre): ... here. Adjust.
+ (dfs_find_final_overrider_post): Adjust.
+ (dfs_find_final_overrider_q): Fold into
+ dfs_find_final_overrider_pre.
+ (find_final_overrider): Adjust dfs searching.
+ (dfs_modify_vtables): Don't mark binfo here.
+ (modify_all_vtables): Use dfs_walk_once.
+ (build_vtt_inits): Likwise. Use dfs_walk_all.
+ (dfs_build_secondary_vptr_vtt_inits): Don't mark binfo here.
+ Return dfs_skip_bases as appropriate.
+ (dfs_fixup_binfo_vtbls): Return dfs_skip_bases as appropriate.
+ * init.c (dfs_initialized_vtbl_ptrs): Return dfs_skip_bases as
+ appropriate. Don't mark binfo here.
+ (initialize_vtbl_ptrs): Use dfs_walk_once.
+ * search.c (struct vbase_info): Remove unused struct.
+ (access_in_type): Use dfs_walk_once.
+ (dfs_access_in_type): Don't mark binfo here.
+ (dfs_accessible_queue_p, dfs_accessible_p) Remove.
+ Fold into ...
+ (accessible_r): ... here. New. Specialize dfs_walk_once.
+ (accessible_p): Use accessible_r.
+ (lookup_field_queue_p): Remove. Fold into ...
+ (lookup_field_r): ... here. Adjust.
+ (lookup_member): Use dfs_walk_all.
+ (dfs_walk_real, dfs_walk): Replace with ...
+ (dfs_walk_all, dfs_walk_once): ... these.
+ (dfs_walk_once_r, dfs_unmark_r): Workers for dfs_walk_once.
+ (dfs_unmark, unmarkedp, markedp): Remove.
+ (dfs_get_pure_virtuals): Don't mark binfo here.
+ (get_pure_virtuals): Use dfs_walk_once.
+ (dfs_debug_unmarked_p): Remove. Fold into ...
+ (dfs_debug_mark): ... here.
+ (note_debug_info_needed): Use dfs_walk_all.
+
+2004-10-07 Andrew Pinski <pinskia@physics.uc.edu>
+
+ * pt.c (tsubst_expr) <case ASM_EXPR>: Look passed the
+ CLEANUP_POINT_EXPR to get the asm expression.
+
+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>
+
+ * parser.c (cp_parser_asm_definition): Look passed the
+ CLEANUP_POINT_EXPR to get the asm expression.
+
+2004-10-06 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR c++/17368
+ * semantics.c (finish_asm_stmt): Asm expressions need cleanup
+ also.
+
2004-10-05 Gabriel Dos Reis <gdr@integrable-solutions.net>
Convert diagnostics to use quoting flag q 6/n
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index bd607abb9a3..7d4e9634e4c 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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
different access. */
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,
DECL_TI_TEMPLATE (fn));
else
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index c2ac0a699d2..d93ee228796 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -155,9 +155,8 @@ static void add_vcall_offset_vtbl_entries_1 (tree, vtbl_init_data *);
static void build_vcall_offset_vtbl_entries (tree, vtbl_init_data *);
static void add_vcall_offset (tree, tree, vtbl_init_data *);
static void layout_vtable_decl (tree, int);
-static tree dfs_find_final_overrider (tree, void *);
+static tree dfs_find_final_overrider_pre (tree, void *);
static tree dfs_find_final_overrider_post (tree, void *);
-static tree dfs_find_final_overrider_q (tree, int, void *);
static tree find_final_overrider (tree, tree, tree);
static int make_new_vtable (tree, tree);
static int maybe_indent_hierarchy (FILE *, int, int);
@@ -171,15 +170,14 @@ static void dump_thunk (FILE *, int, tree);
static tree build_vtable (tree, tree, tree);
static void initialize_vtable (tree, tree);
static void layout_nonempty_base_or_field (record_layout_info,
- tree, tree, splay_tree);
+ tree, tree, splay_tree);
static tree end_of_class (tree, int);
static bool layout_empty_base (tree, tree, splay_tree);
static void accumulate_vtbl_inits (tree, tree, tree, tree, tree);
static tree dfs_accumulate_vtbl_inits (tree, tree, tree, tree,
tree);
static void build_rtti_vtbl_entries (tree, vtbl_init_data *);
-static void build_vcall_and_vbase_vtbl_entries (tree,
- vtbl_init_data *);
+static void build_vcall_and_vbase_vtbl_entries (tree, vtbl_init_data *);
static void clone_constructors_and_destructors (tree);
static tree build_clone (tree, tree);
static void update_vtable_entry_for_fn (tree, tree, tree, tree *, unsigned);
@@ -192,11 +190,11 @@ static tree dfs_fixup_binfo_vtbls (tree, void *);
static int record_subobject_offset (tree, tree, splay_tree);
static int check_subobject_offset (tree, tree, splay_tree);
static int walk_subobject_offsets (tree, subobject_offset_fn,
- tree, splay_tree, tree, int);
+ tree, splay_tree, tree, int);
static void record_subobject_offsets (tree, tree, splay_tree, int);
static int layout_conflict_p (tree, tree, splay_tree, int);
static int splay_tree_compare_integer_csts (splay_tree_key k1,
- splay_tree_key k2);
+ splay_tree_key k2);
static void warn_about_ambiguous_bases (tree);
static bool type_requires_array_cookie (tree);
static bool contains_empty_class_p (tree);
@@ -1657,17 +1655,7 @@ resort_type_method_vec (void* obj,
}
}
-/* Warn about duplicate methods in fn_fields. Also compact method
- 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.
+/* Warn about duplicate methods in fn_fields.
Sort methods that are not special (i.e., constructors, destructors,
and type conversion operators) so that we can find them faster in
@@ -1686,11 +1674,9 @@ finish_struct_methods (tree t)
len = VEC_length (tree, method_vec);
- /* First fill in entry 0 with the constructors, entry 1 with destructors,
- and the next few with type conversion operators (if any). */
+ /* Clear DECL_IN_AGGR_P for all functions. */
for (fn_fields = TYPE_METHODS (t); fn_fields;
fn_fields = TREE_CHAIN (fn_fields))
- /* Clear out this flag. */
DECL_IN_AGGR_P (fn_fields) = 0;
if (TYPE_HAS_DESTRUCTOR (t) && !CLASSTYPE_DESTRUCTORS (t))
@@ -1800,15 +1786,10 @@ typedef struct find_final_overrider_data_s {
tree fn;
/* The base class in which the function was declared. */
tree declaring_base;
- /* The most derived class in the hierarchy. */
- tree most_derived_type;
/* The candidate overriders. */
tree candidates;
- /* Each entry in this array is the next-most-derived class for a
- virtual base class along the current path. */
- tree *vpath_list;
- /* A pointer one past the top of the VPATH_LIST. */
- tree *vpath;
+ /* Path to most derived. */
+ VEC (tree) *path;
} find_final_overrider_data;
/* Add the overrider along the current path to FFOD->CANDIDATES.
@@ -1816,22 +1797,18 @@ typedef struct find_final_overrider_data_s {
static bool
dfs_find_final_overrider_1 (tree binfo,
- tree *vpath,
- find_final_overrider_data *ffod)
+ find_final_overrider_data *ffod,
+ unsigned depth)
{
tree method;
/* If BINFO is not the most derived type, try a more derived class.
A definition there will overrider a definition here. */
- if (!same_type_p (BINFO_TYPE (binfo), ffod->most_derived_type))
+ if (depth)
{
- tree derived;
-
- if (BINFO_VIRTUAL_P (binfo))
- derived = *--vpath;
- else
- derived = BINFO_INHERITANCE_CHAIN (binfo);
- if (dfs_find_final_overrider_1 (derived, vpath, ffod))
+ depth--;
+ if (dfs_find_final_overrider_1
+ (VEC_index (tree, ffod->path, depth), ffod, depth))
return true;
}
@@ -1865,36 +1842,23 @@ dfs_find_final_overrider_1 (tree binfo,
/* Called from find_final_overrider via dfs_walk. */
static tree
-dfs_find_final_overrider (tree binfo, void* data)
+dfs_find_final_overrider_pre (tree binfo, void *data)
{
find_final_overrider_data *ffod = (find_final_overrider_data *) data;
if (binfo == ffod->declaring_base)
- dfs_find_final_overrider_1 (binfo, ffod->vpath, ffod);
+ dfs_find_final_overrider_1 (binfo, ffod, VEC_length (tree, ffod->path));
+ VEC_safe_push (tree, ffod->path, binfo);
return NULL_TREE;
}
static tree
-dfs_find_final_overrider_q (tree derived, int ix, void *data)
-{
- tree binfo = BINFO_BASE_BINFO (derived, ix);
- find_final_overrider_data *ffod = (find_final_overrider_data *) data;
-
- if (BINFO_VIRTUAL_P (binfo))
- *ffod->vpath++ = derived;
-
- return binfo;
-}
-
-static tree
-dfs_find_final_overrider_post (tree binfo, void *data)
+dfs_find_final_overrider_post (tree binfo ATTRIBUTE_UNUSED, void *data)
{
find_final_overrider_data *ffod = (find_final_overrider_data *) data;
+ VEC_pop (tree, ffod->path);
- if (BINFO_VIRTUAL_P (binfo))
- ffod->vpath--;
-
return NULL_TREE;
}
@@ -1932,23 +1896,14 @@ find_final_overrider (tree derived, tree binfo, tree fn)
/* Determine the depth of the hierarchy. */
ffod.fn = fn;
ffod.declaring_base = binfo;
- ffod.most_derived_type = BINFO_TYPE (derived);
ffod.candidates = NULL_TREE;
- /* The virtual depth cannot be greater than the number of virtual
- bases. */
- ffod.vpath_list = (tree *) xcalloc
- (VEC_length (tree, CLASSTYPE_VBASECLASSES (BINFO_TYPE (derived))),
- sizeof (tree));
- ffod.vpath = ffod.vpath_list;
+ ffod.path = VEC_alloc (tree, 30);
- dfs_walk_real (derived,
- dfs_find_final_overrider,
- dfs_find_final_overrider_post,
- dfs_find_final_overrider_q,
- &ffod);
-
- free (ffod.vpath_list);
+ dfs_walk_all (derived, dfs_find_final_overrider_pre,
+ dfs_find_final_overrider_post, &ffod);
+ VEC_free (tree, ffod.path);
+
/* If there was no winner, issue an error message. */
if (!ffod.candidates || TREE_CHAIN (ffod.candidates))
{
@@ -2220,8 +2175,6 @@ dfs_modify_vtables (tree binfo, void* data)
&virtuals, ix);
}
- BINFO_MARKED (binfo) = 1;
-
return NULL_TREE;
}
@@ -2241,8 +2194,7 @@ modify_all_vtables (tree t, tree virtuals)
tree *fnsp;
/* Update all of the vtables. */
- dfs_walk (binfo, dfs_modify_vtables, unmarkedp, t);
- dfs_walk (binfo, dfs_unmark, markedp, t);
+ dfs_walk_once (binfo, NULL, dfs_modify_vtables, t);
/* Add virtual functions not already in our primary vtable. These
will be both those introduced by this class, and those overridden
@@ -6775,7 +6727,7 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index)
/* Recursively add the secondary VTTs for non-virtual bases. */
for (i = 0; BINFO_BASE_ITERATE (binfo, i, b); ++i)
if (!BINFO_VIRTUAL_P (b))
- inits = build_vtt_inits (BINFO_BASE_BINFO (binfo, i), t, inits, index);
+ inits = build_vtt_inits (b, t, inits, index);
/* Add secondary virtual pointers for all subobjects of BINFO with
either virtual bases or reachable along a virtual path, except
@@ -6785,9 +6737,7 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index)
data.inits = NULL;
data.type_being_constructed = BINFO_TYPE (binfo);
- dfs_walk_real (binfo, dfs_build_secondary_vptr_vtt_inits,
- NULL, unmarkedp, &data);
- dfs_walk (binfo, dfs_unmark, markedp, 0);
+ dfs_walk_once (binfo, dfs_build_secondary_vptr_vtt_inits, NULL, &data);
*index = data.index;
@@ -6814,7 +6764,7 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index)
}
else
/* Remove the ctor vtables we created. */
- dfs_walk (binfo, dfs_fixup_binfo_vtbls, 0, binfo);
+ dfs_walk_all (binfo, dfs_fixup_binfo_vtbls, NULL, binfo);
return inits;
}
@@ -6827,27 +6777,25 @@ dfs_build_secondary_vptr_vtt_inits (tree binfo, void *data_)
{
secondary_vptr_vtt_init_data *data = (secondary_vptr_vtt_init_data *)data_;
- BINFO_MARKED (binfo) = 1;
-
/* We don't care about bases that don't have vtables. */
if (!TYPE_VFIELD (BINFO_TYPE (binfo)))
- return NULL_TREE;
+ return dfs_skip_bases;
/* We're only interested in proper subobjects of the type being
constructed. */
if (same_type_p (BINFO_TYPE (binfo), data->type_being_constructed))
return NULL_TREE;
- /* We're not interested in non-virtual primary bases. */
- if (!BINFO_VIRTUAL_P (binfo) && BINFO_PRIMARY_P (binfo))
- return NULL_TREE;
-
/* We're only interested in bases with virtual bases or reachable
via a virtual path from the type being constructed. */
- if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo))
- && !binfo_via_virtual (binfo, data->type_being_constructed))
+ if (!(CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo))
+ || binfo_via_virtual (binfo, data->type_being_constructed)))
+ return dfs_skip_bases;
+
+ /* We're not interested in non-virtual primary bases. */
+ if (!BINFO_VIRTUAL_P (binfo) && BINFO_PRIMARY_P (binfo))
return NULL_TREE;
-
+
/* Record the index where this secondary vptr can be found. */
if (data->top_level_p)
{
@@ -6885,9 +6833,18 @@ dfs_fixup_binfo_vtbls (tree binfo, void* data)
{
tree vtable = BINFO_VTABLE (binfo);
+ if (!TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)))
+ /* If this class has no vtable, none of its bases do. */
+ return dfs_skip_bases;
+
+ if (!vtable)
+ /* This might be a primary base, so have no vtable in this
+ hierarchy. */
+ return NULL_TREE;
+
/* If we scribbled the construction vtable vptr into BINFO, clear it
out now. */
- if (vtable && TREE_CODE (vtable) == TREE_LIST
+ if (TREE_CODE (vtable) == TREE_LIST
&& (TREE_PURPOSE (vtable) == (tree) data))
BINFO_VTABLE (binfo) = TREE_CHAIN (vtable);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 5ff38b72575..826bd51cf29 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -39,7 +39,6 @@ struct diagnostic_context;
DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR).
TREE_INDIRECT_USING (in NAMESPACE_DECL).
- ICS_USER_FLAG (in _CONV)
CLEANUP_P (in TRY_BLOCK)
AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR)
PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF)
@@ -90,6 +89,7 @@ struct diagnostic_context;
DECL_MUTABLE_P (in FIELD_DECL)
1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_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).
DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL)
3: DECL_IN_AGGR_P.
@@ -2177,6 +2177,11 @@ struct lang_decl GTY(())
#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
member template, whose inline definition is being processed after
the class definition is complete. */
@@ -3930,7 +3935,6 @@ extern tree instantiate_decl (tree, int, int);
extern int push_tinst_level (tree);
extern void pop_tinst_level (void);
extern int more_specialized_class (tree, tree, tree);
-extern int is_member_template (tree);
extern int comp_template_parms (tree, tree);
extern int template_class_depth (tree);
extern int is_specialization_of (tree, tree);
@@ -3990,6 +3994,7 @@ extern int accessible_p (tree, tree);
extern tree lookup_field_1 (tree, tree, bool);
extern tree lookup_field (tree, tree, int, bool);
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_member (tree, tree, int, bool);
extern int look_for_overrides (tree, tree);
@@ -4009,18 +4014,11 @@ extern tree binfo_from_vbase (tree);
extern tree binfo_for_vbase (tree, tree);
extern tree look_for_overrides_here (tree, tree);
extern int check_final_overrider (tree, tree);
-extern tree dfs_walk (tree,
- tree (*) (tree, void *),
- tree (*) (tree, int, void *),
- void *);
-extern tree dfs_walk_real (tree,
- tree (*) (tree, void *),
- tree (*) (tree, void *),
- tree (*) (tree, int, void *),
- void *);
-extern tree dfs_unmark (tree, void *);
-extern tree markedp (tree, int, void *);
-extern tree unmarkedp (tree, int, void *);
+#define dfs_skip_bases ((tree)1)
+extern tree dfs_walk_all (tree, tree (*) (tree, void *),
+ tree (*) (tree, void *), void *);
+extern tree dfs_walk_once (tree, tree (*) (tree, void *),
+ tree (*) (tree, void *), void *);
extern tree binfo_via_virtual (tree, tree);
extern tree build_baselink (tree, tree, tree, tree);
extern tree adjust_result_of_qualified_name_lookup
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 078e2f9326d..919b619cc83 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8477,7 +8477,8 @@ copy_fn_p (tree 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
functions. Note that member functions of templated classes are
represented as template functions internally, and we must
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 3c1f9b4ed9a..896fdfc1834 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -596,7 +596,7 @@ check_classfn (tree ctype, tree function, tree template_parms)
if (DECL_USE_TEMPLATE (function)
&& !(TREE_CODE (function) == TEMPLATE_DECL
&& 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,
we're not going to find the declaration in the class.
For example, in:
@@ -622,11 +622,7 @@ check_classfn (tree ctype, tree function, tree template_parms)
/* OK, is this a definition of a member template? */
is_template = (template_parms != NULL_TREE);
- ix = lookup_fnfields_1 (complete_type (ctype),
- DECL_CONSTRUCTOR_P (function) ? ctor_identifier :
- DECL_DESTRUCTOR_P (function) ? dtor_identifier :
- DECL_NAME (function));
-
+ ix = class_method_index_for_fn (complete_type (ctype), function);
if (ix >= 0)
{
VEC(tree) *methods = CLASSTYPE_METHOD_VEC (ctype);
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 12886836d1b..ceb6d690a6a 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -101,8 +101,10 @@ finish_init_stmts (bool is_global, tree stmt_expr, tree compound_stmt)
static tree
dfs_initialize_vtbl_ptrs (tree binfo, void *data)
{
- if ((!BINFO_PRIMARY_P (binfo) || BINFO_VIRTUAL_P (binfo))
- && TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)))
+ if (!TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)))
+ return dfs_skip_bases;
+
+ if (!BINFO_PRIMARY_P (binfo) || BINFO_VIRTUAL_P (binfo))
{
tree base_ptr = TREE_VALUE ((tree) data);
@@ -111,8 +113,6 @@ dfs_initialize_vtbl_ptrs (tree binfo, void *data)
expand_virtual_init (binfo, base_ptr);
}
- BINFO_MARKED (binfo) = 1;
-
return NULL_TREE;
}
@@ -132,9 +132,7 @@ initialize_vtbl_ptrs (tree addr)
class. We do these in pre-order because we can't find the virtual
bases for a class until we've initialized the vtbl for that
class. */
- dfs_walk_real (TYPE_BINFO (type), dfs_initialize_vtbl_ptrs,
- NULL, unmarkedp, list);
- dfs_walk (TYPE_BINFO (type), dfs_unmark, markedp, type);
+ dfs_walk_once (TYPE_BINFO (type), dfs_initialize_vtbl_ptrs, NULL, list);
}
/* Return an expression for the zero-initialization of an object with
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 79342dbf576..9bd3f1805b6 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10389,7 +10389,13 @@ cp_parser_asm_definition (cp_parser* parser)
inputs, clobbers);
/* If the extended syntax was not used, mark the ASM_EXPR. */
if (!extended_p)
- ASM_INPUT_P (asm_stmt) = 1;
+ {
+ tree temp = asm_stmt;
+ if (TREE_CODE (temp) == CLEANUP_POINT_EXPR)
+ temp = TREE_OPERAND (temp, 0);
+
+ ASM_INPUT_P (temp) = 1;
+ }
}
else
assemble_asm (string);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 3813c38ed41..9a869eaecd2 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -117,12 +117,9 @@ static int for_each_template_parm (tree, tree_fn_t, void*, htab_t);
static tree build_template_parm_index (int, int, int, tree, tree);
static int inline_needs_template_parms (tree);
static void push_inline_template_parms_recursive (tree, int);
-static tree retrieve_specialization (tree, tree);
static tree retrieve_local_specialization (tree);
-static tree register_specialization (tree, tree, tree);
static void register_local_specialization (tree, tree);
static tree reduce_template_parm_level (tree, tree, int);
-static tree build_template_decl (tree, tree);
static int mark_template_parm (tree, void *);
static int template_parm_this_level_p (tree, void *);
static tree tsubst_friend_function (tree, tree);
@@ -441,67 +438,6 @@ maybe_end_member_template_processing (void)
}
}
-/* Returns nonzero iff T is a member template function. We must be
- careful as in
-
- template <class T> class C { void f(); }
-
- Here, f is a template function, and a member, but not a member
- template. This function does not concern itself with the origin of
- T, only its present state. So if we have
-
- template <class T> class C { template <class U> void f(U); }
-
- then neither C<int>::f<char> nor C<T>::f<double> is considered
- to be a member template. But, `template <class U> void
- C<int>::f(U)' is considered a member template. */
-
-int
-is_member_template (tree t)
-{
- if (!DECL_FUNCTION_TEMPLATE_P (t))
- /* Anything that isn't a function or a template function is
- certainly not a member template. */
- return 0;
-
- /* A local class can't have member templates. */
- if (decl_function_context (t))
- return 0;
-
- return (DECL_FUNCTION_MEMBER_P (DECL_TEMPLATE_RESULT (t))
- /* If there are more levels of template parameters than
- there are template classes surrounding the declaration,
- then we have a member template. */
- && (TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (t)) >
- template_class_depth (DECL_CONTEXT (t))));
-}
-
-#if 0 /* UNUSED */
-/* Returns nonzero iff T is a member template class. See
- is_member_template for a description of what precisely constitutes
- a member template. */
-
-int
-is_member_template_class (tree t)
-{
- if (!DECL_CLASS_TEMPLATE_P (t))
- /* Anything that isn't a class template, is certainly not a member
- template. */
- return 0;
-
- if (!DECL_CLASS_SCOPE_P (t))
- /* Anything whose context isn't a class type is surely not a
- member template. */
- return 0;
-
- /* If there are more levels of template parameters than there are
- template classes surrounding the declaration, then we have a
- member template. */
- return (TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (t)) >
- template_class_depth (DECL_CONTEXT (t)));
-}
-#endif
-
/* Return a new template argument vector which contains all of ARGS,
but has as its innermost set of arguments the EXTRA_ARGS. */
@@ -826,30 +762,122 @@ maybe_process_partial_specialization (tree type)
error ("explicit specialization of non-template %qT", type);
}
+/* Returns nonzero if we can optimize the retrieval of specializations
+ for TMPL, a TEMPLATE_DECL. In particular, for such a template, we
+ do not use DECL_TEMPLATE_SPECIALIZATIONS at all. */
+
+static inline bool
+optimize_specialization_lookup_p (tree tmpl)
+{
+ return (DECL_FUNCTION_TEMPLATE_P (tmpl)
+ && DECL_CLASS_SCOPE_P (tmpl)
+ /* DECL_CLASS_SCOPE_P holds of T::f even if T is a template
+ parameter. */
+ && CLASS_TYPE_P (DECL_CONTEXT (tmpl))
+ && !DECL_MEMBER_TEMPLATE_P (tmpl)
+ && !DECL_CONV_FN_P (tmpl)
+ /* It is possible to have a template that is not a member
+ template and is not a member of a template class:
+
+ template <typename T>
+ struct S { friend A::f(); };
+
+ Here, the friend function is a template, but the context does
+ not have template information. The optimized lookup relies
+ on having ARGS be the template arguments for both the class
+ and the function template. */
+ && !DECL_FRIEND_P (DECL_TEMPLATE_RESULT (tmpl)));
+}
+
/* Retrieve the specialization (in the sense of [temp.spec] - a
specialization is either an instantiation or an explicit
specialization) of TMPL for the given template ARGS. If there is
no such specialization, return NULL_TREE. The ARGS are a vector of
arguments, or a vector of vectors of arguments, in the case of
- templates with more than one level of parameters. */
+ templates with more than one level of parameters.
+
+ If TMPL is a type template and CLASS_SPECIALIZATIONS_P is true,
+ then we search for a partial specialization matching ARGS. This
+ parameter is ignored if TMPL is not a class template. */
static tree
-retrieve_specialization (tree tmpl, tree args)
+retrieve_specialization (tree tmpl, tree args,
+ bool class_specializations_p)
{
- tree s;
-
gcc_assert (TREE_CODE (tmpl) == TEMPLATE_DECL);
/* There should be as many levels of arguments as there are
levels of parameters. */
gcc_assert (TMPL_ARGS_DEPTH (args)
== TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl)));
-
- for (s = DECL_TEMPLATE_SPECIALIZATIONS (tmpl);
- s != NULL_TREE;
- s = TREE_CHAIN (s))
- if (comp_template_args (TREE_PURPOSE (s), args))
- return TREE_VALUE (s);
+
+ if (optimize_specialization_lookup_p (tmpl))
+ {
+ tree class_template;
+ tree class_specialization;
+ VEC(tree) *methods;
+ tree fns;
+ int idx;
+
+ /* The template arguments actually apply to the containing
+ class. Find the class specialization with those
+ arguments. */
+ class_template = CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (tmpl));
+ class_specialization
+ = retrieve_specialization (class_template, args,
+ /*class_specializations_p=*/false);
+ if (!class_specialization)
+ return NULL_TREE;
+ /* Now, find the appropriate entry in the CLASSTYPE_METHOD_VEC
+ for the specialization. */
+ idx = class_method_index_for_fn (class_specialization, tmpl);
+ if (idx == -1)
+ return NULL_TREE;
+ /* Iterate through the methods with the indicated name, looking
+ for the one that has an instance of TMPL. */
+ methods = CLASSTYPE_METHOD_VEC (class_specialization);
+ for (fns = VEC_index (tree, methods, idx); fns; fns = OVL_NEXT (fns))
+ {
+ tree fn = OVL_CURRENT (fns);
+ if (DECL_TEMPLATE_INFO (fn) && DECL_TI_TEMPLATE (fn) == tmpl)
+ return fn;
+ }
+ return NULL_TREE;
+ }
+ else
+ {
+ tree *sp;
+ tree *head;
+
+ /* Class templates store their instantiations on the
+ DECL_TEMPLATE_INSTANTIATIONS list; other templates use the
+ DECL_TEMPLATE_SPECIALIZATIONS list. */
+ if (!class_specializations_p
+ && TREE_CODE (DECL_TEMPLATE_RESULT (tmpl)) == TYPE_DECL)
+ sp = &DECL_TEMPLATE_INSTANTIATIONS (tmpl);
+ else
+ sp = &DECL_TEMPLATE_SPECIALIZATIONS (tmpl);
+ head = sp;
+ /* Iterate through the list until we find a matching template. */
+ while (*sp != NULL_TREE)
+ {
+ tree spec = *sp;
+
+ if (comp_template_args (TREE_PURPOSE (spec), args))
+ {
+ /* Use the move-to-front heuristic to speed up future
+ searches. */
+ if (spec != *head)
+ {
+ *sp = TREE_CHAIN (*sp);
+ TREE_CHAIN (spec) = *head;
+ *head = spec;
+ }
+ return TREE_VALUE (spec);
+ }
+ sp = &TREE_CHAIN (spec);
+ }
+ }
return NULL_TREE;
}
@@ -1035,7 +1063,7 @@ is_specialization_of_friend (tree decl, tree friend)
static tree
register_specialization (tree spec, tree tmpl, tree args)
{
- tree s;
+ tree fn;
gcc_assert (TREE_CODE (tmpl) == TEMPLATE_DECL);
@@ -1059,73 +1087,67 @@ register_specialization (tree spec, tree tmpl, tree args)
gcc_assert (TMPL_ARGS_DEPTH (args)
== TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl)));
- for (s = DECL_TEMPLATE_SPECIALIZATIONS (tmpl);
- s != NULL_TREE;
- s = TREE_CHAIN (s))
+ fn = retrieve_specialization (tmpl, args,
+ /*class_specializations_p=*/false);
+ /* We can sometimes try to re-register a specialization that we've
+ already got. In particular, regenerate_decl_from_template calls
+ duplicate_decls which will update the specialization list. But,
+ we'll still get called again here anyhow. It's more convenient
+ to simply allow this than to try to prevent it. */
+ if (fn == spec)
+ return spec;
+ else if (fn && DECL_TEMPLATE_SPECIALIZATION (spec))
{
- tree fn = TREE_VALUE (s);
-
- /* We can sometimes try to re-register a specialization that we've
- already got. In particular, regenerate_decl_from_template
- calls duplicate_decls which will update the specialization
- list. But, we'll still get called again here anyhow. It's
- more convenient to simply allow this than to try to prevent it. */
- if (fn == spec)
- return spec;
- else if (DECL_TEMPLATE_SPECIALIZATION (spec)
- && comp_template_args (TREE_PURPOSE (s), args))
+ if (DECL_TEMPLATE_INSTANTIATION (fn))
{
- if (DECL_TEMPLATE_INSTANTIATION (fn))
+ if (TREE_USED (fn)
+ || DECL_EXPLICIT_INSTANTIATION (fn))
{
- if (TREE_USED (fn)
- || DECL_EXPLICIT_INSTANTIATION (fn))
- {
- error ("specialization of %qD after instantiation", fn);
- return spec;
- }
- else
- {
- /* This situation should occur only if the first
- specialization is an implicit instantiation, the
- second is an explicit specialization, and the
- implicit instantiation has not yet been used.
- That situation can occur if we have implicitly
- instantiated a member function and then
- specialized it later.
-
- We can also wind up here if a friend declaration
- that looked like an instantiation turns out to be
- a specialization:
-
- template <class T> void foo(T);
- class S { friend void foo<>(int) };
- template <> void foo(int);
-
- We transform the existing DECL in place so that
- any pointers to it become pointers to the updated
- declaration.
-
- If there was a definition for the template, but
- not for the specialization, we want this to look
- as if there were no definition, and vice
- versa. */
- DECL_INITIAL (fn) = NULL_TREE;
- duplicate_decls (spec, fn);
-
- return fn;
- }
+ error ("specialization of %qD after instantiation",
+ fn);
+ return spec;
}
- else if (DECL_TEMPLATE_SPECIALIZATION (fn))
+ else
{
- if (!duplicate_decls (spec, fn) && DECL_INITIAL (spec))
- /* Dup decl failed, but this is a new definition. Set
- the line number so any errors match this new
- definition. */
- DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (spec);
+ /* This situation should occur only if the first
+ specialization is an implicit instantiation, the
+ second is an explicit specialization, and the
+ implicit instantiation has not yet been used. That
+ situation can occur if we have implicitly
+ instantiated a member function and then specialized
+ it later.
+
+ We can also wind up here if a friend declaration that
+ looked like an instantiation turns out to be a
+ specialization:
+
+ template <class T> void foo(T);
+ class S { friend void foo<>(int) };
+ template <> void foo(int);
+
+ We transform the existing DECL in place so that any
+ pointers to it become pointers to the updated
+ declaration.
+
+ If there was a definition for the template, but not
+ for the specialization, we want this to look as if
+ there were no definition, and vice versa. */
+ DECL_INITIAL (fn) = NULL_TREE;
+ duplicate_decls (spec, fn);
return fn;
}
}
+ else if (DECL_TEMPLATE_SPECIALIZATION (fn))
+ {
+ if (!duplicate_decls (spec, fn) && DECL_INITIAL (spec))
+ /* Dup decl failed, but this is a new definition. Set the
+ line number so any errors match this new
+ definition. */
+ DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (spec);
+
+ return fn;
+ }
}
/* A specialization must be declared in the same namespace as the
@@ -1134,8 +1156,9 @@ register_specialization (tree spec, tree tmpl, tree args)
&& !check_specialization_namespace (tmpl))
DECL_CONTEXT (spec) = decl_namespace_context (tmpl);
- DECL_TEMPLATE_SPECIALIZATIONS (tmpl)
- = tree_cons (args, spec, DECL_TEMPLATE_SPECIALIZATIONS (tmpl));
+ if (!optimize_specialization_lookup_p (tmpl))
+ DECL_TEMPLATE_SPECIALIZATIONS (tmpl)
+ = tree_cons (args, spec, DECL_TEMPLATE_SPECIALIZATIONS (tmpl));
return spec;
}
@@ -2393,14 +2416,16 @@ current_template_args (void)
}
/* Return a TEMPLATE_DECL corresponding to DECL, using the indicated
- template PARMS. Used by push_template_decl below. */
+ template PARMS. If MEMBER_TEMPLATE_P is true, the new template is
+ a member template. Used by push_template_decl below. */
static tree
-build_template_decl (tree decl, tree parms)
+build_template_decl (tree decl, tree parms, bool member_template_p)
{
tree tmpl = build_lang_decl (TEMPLATE_DECL, DECL_NAME (decl), NULL_TREE);
DECL_TEMPLATE_PARMS (tmpl) = parms;
DECL_CONTEXT (tmpl) = DECL_CONTEXT (decl);
+ DECL_MEMBER_TEMPLATE_P (tmpl) = member_template_p;
if (DECL_LANG_SPECIFIC (decl))
{
DECL_STATIC_FUNCTION_P (tmpl) = DECL_STATIC_FUNCTION_P (decl);
@@ -2636,7 +2661,8 @@ process_partial_specialization (tree decl)
}
}
- if (retrieve_specialization (maintmpl, specargs))
+ if (retrieve_specialization (maintmpl, specargs,
+ /*class_specializations_p=*/true))
/* We've already got this specialization. */
return decl;
@@ -2826,6 +2852,9 @@ push_template_decl_real (tree decl, int is_friend)
int primary;
int is_partial;
int new_template_p = 0;
+ /* True if the template is a member template, in the sense of
+ [temp.mem]. */
+ bool member_template_p = false;
if (decl == error_mark_node)
return decl;
@@ -2862,6 +2891,8 @@ push_template_decl_real (tree decl, int is_friend)
if (primary)
{
+ if (DECL_CLASS_SCOPE_P (decl))
+ member_template_p = true;
if (current_lang_name == lang_name_c)
error ("template with C linkage");
else if (TREE_CODE (decl) == TYPE_DECL
@@ -2941,7 +2972,8 @@ push_template_decl_real (tree decl, int is_friend)
}
else
{
- tmpl = build_template_decl (decl, current_template_parms);
+ tmpl = build_template_decl (decl, current_template_parms,
+ member_template_p);
new_template_p = 1;
if (DECL_LANG_SPECIFIC (decl)
@@ -2984,7 +3016,7 @@ push_template_decl_real (tree decl, int is_friend)
if (DECL_FUNCTION_TEMPLATE_P (tmpl)
&& DECL_TEMPLATE_INFO (decl) && DECL_TI_ARGS (decl)
&& DECL_TEMPLATE_SPECIALIZATION (decl)
- && is_member_template (tmpl))
+ && DECL_MEMBER_TEMPLATE_P (tmpl))
{
tree new_tmpl;
@@ -2996,7 +3028,8 @@ push_template_decl_real (tree decl, int is_friend)
args = DECL_TI_ARGS (decl);
new_tmpl
- = build_template_decl (decl, current_template_parms);
+ = build_template_decl (decl, current_template_parms,
+ member_template_p);
DECL_TEMPLATE_RESULT (new_tmpl) = decl;
TREE_TYPE (new_tmpl) = TREE_TYPE (decl);
DECL_TI_TEMPLATE (decl) = new_tmpl;
@@ -4342,7 +4375,6 @@ lookup_template_class (tree d1,
tree gen_tmpl;
tree type_decl;
tree found = NULL_TREE;
- tree *tp;
int arg_depth;
int parm_depth;
int is_partial_instantiation;
@@ -4466,22 +4498,11 @@ lookup_template_class (tree d1,
if (found)
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, found);
- for (tp = &DECL_TEMPLATE_INSTANTIATIONS (template);
- *tp;
- tp = &TREE_CHAIN (*tp))
- if (comp_template_args (TREE_PURPOSE (*tp), arglist))
- {
- found = *tp;
-
- /* Use the move-to-front heuristic to speed up future
- searches. */
- *tp = TREE_CHAIN (*tp);
- TREE_CHAIN (found)
- = DECL_TEMPLATE_INSTANTIATIONS (template);
- DECL_TEMPLATE_INSTANTIATIONS (template) = found;
-
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, TREE_VALUE (found));
- }
+ /* If we already have this specialization, return it. */
+ found = retrieve_specialization (template, arglist,
+ /*class_specializations_p=*/false);
+ if (found)
+ POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, found);
/* This type is a "partial instantiation" if any of the template
arguments still involve template parameters. Note that we set
@@ -6069,7 +6090,8 @@ tsubst_decl (tree t, tree args, tree type, tsubst_flags_t complain)
changed. */
gcc_assert (full_args != tmpl_args);
- spec = retrieve_specialization (t, full_args);
+ spec = retrieve_specialization (t, full_args,
+ /*class_specializations_p=*/true);
if (spec != NULL_TREE)
{
r = spec;
@@ -6181,7 +6203,8 @@ tsubst_decl (tree t, tree args, tree type, tsubst_flags_t complain)
args, complain, in_decl);
/* Check to see if we already have this specialization. */
- spec = retrieve_specialization (gen_tmpl, argvec);
+ spec = retrieve_specialization (gen_tmpl, argvec,
+ /*class_specializations_p=*/false);
if (spec)
{
@@ -6467,7 +6490,8 @@ tsubst_decl (tree t, tree args, tree type, tsubst_flags_t complain)
tmpl = DECL_TI_TEMPLATE (t);
gen_tmpl = most_general_template (tmpl);
argvec = tsubst (DECL_TI_ARGS (t), args, complain, in_decl);
- spec = retrieve_specialization (gen_tmpl, argvec);
+ spec = retrieve_specialization (gen_tmpl, argvec,
+ /*class_specializations_p=*/false);
}
else
spec = retrieve_local_specialization (t);
@@ -6657,6 +6681,39 @@ tsubst_function_type (tree t,
return fntype;
}
+/* FNTYPE is a FUNCTION_TYPE or METHOD_TYPE. Substitute the template
+ ARGS into that specification, and return the substituted
+ specification. If there is no specification, return NULL_TREE. */
+
+static tree
+tsubst_exception_specification (tree fntype,
+ tree args,
+ tsubst_flags_t complain,
+ tree in_decl)
+{
+ tree specs;
+ tree new_specs;
+
+ specs = TYPE_RAISES_EXCEPTIONS (fntype);
+ new_specs = NULL_TREE;
+ if (specs)
+ {
+ if (! TREE_VALUE (specs))
+ new_specs = specs;
+ else
+ while (specs)
+ {
+ tree spec;
+ spec = tsubst (TREE_VALUE (specs), args, complain, in_decl);
+ if (spec == error_mark_node)
+ return spec;
+ new_specs = add_exception_specifier (new_specs, spec, complain);
+ specs = TREE_CHAIN (specs);
+ }
+ }
+ return new_specs;
+}
+
/* Substitute into the PARMS of a call-declarator. */
static tree
@@ -7089,32 +7146,16 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
case METHOD_TYPE:
{
tree fntype;
- tree raises;
-
+ tree specs;
fntype = tsubst_function_type (t, args, complain, in_decl);
if (fntype == error_mark_node)
return error_mark_node;
/* Substitute the exception specification. */
- raises = TYPE_RAISES_EXCEPTIONS (t);
- if (raises)
- {
- tree list = NULL_TREE;
-
- if (! TREE_VALUE (raises))
- list = raises;
- else
- for (; raises != NULL_TREE; raises = TREE_CHAIN (raises))
- {
- tree spec = TREE_VALUE (raises);
-
- spec = tsubst (spec, args, complain, in_decl);
- if (spec == error_mark_node)
- return spec;
- list = add_exception_specifier (list, spec, complain);
- }
- fntype = build_exception_variant (fntype, list);
- }
+ specs = tsubst_exception_specification (t, args, complain,
+ in_decl);
+ if (specs)
+ fntype = build_exception_variant (fntype, specs);
return fntype;
}
case ARRAY_TYPE:
@@ -7537,7 +7578,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (DECL_TEMPLATE_TEMPLATE_PARM_P (t))
return tsubst (TREE_TYPE (DECL_TEMPLATE_RESULT (t)),
args, complain, in_decl);
- else if (is_member_template (t))
+ else if (DECL_FUNCTION_TEMPLATE_P (t) && DECL_MEMBER_TEMPLATE_P (t))
return tsubst (t, args, complain, in_decl);
else if (DECL_CLASS_SCOPE_P (t)
&& uses_template_parms (DECL_CONTEXT (t)))
@@ -8017,7 +8058,12 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
tsubst_expr (ASM_OUTPUTS (t), args, complain, in_decl),
tsubst_expr (ASM_INPUTS (t), args, complain, in_decl),
tsubst_expr (ASM_CLOBBERS (t), args, complain, in_decl));
- ASM_INPUT_P (tmp) = ASM_INPUT_P (t);
+ {
+ tree asm_expr = tmp;
+ if (TREE_CODE (asm_expr) == CLEANUP_POINT_EXPR)
+ asm_expr = TREE_OPERAND (asm_expr, 0);
+ ASM_INPUT_P (asm_expr) = ASM_INPUT_P (t);
+ }
break;
case TRY_BLOCK:
@@ -8736,7 +8782,8 @@ instantiate_template (tree tmpl, tree targ_ptr, tsubst_flags_t complain)
}
/* Check to see if we already have this specialization. */
- spec = retrieve_specialization (tmpl, targ_ptr);
+ spec = retrieve_specialization (tmpl, targ_ptr,
+ /*class_specializations_p=*/false);
if (spec != NULL_TREE)
return spec;
@@ -8750,7 +8797,8 @@ instantiate_template (tree tmpl, tree targ_ptr, tsubst_flags_t complain)
targ_ptr);
/* Check to see if we already have this specialization. */
- spec = retrieve_specialization (gen_tmpl, targ_ptr);
+ spec = retrieve_specialization (gen_tmpl, targ_ptr,
+ /*class_specializations_p=*/false);
if (spec != NULL_TREE)
return spec;
}
@@ -10808,75 +10856,76 @@ do_type_instantiation (tree t, tree storage, tsubst_flags_t complain)
static void
regenerate_decl_from_template (tree decl, tree tmpl)
{
- /* The most general version of TMPL. */
- tree gen_tmpl;
/* The arguments used to instantiate DECL, from the most general
template. */
tree args;
tree code_pattern;
- tree new_decl;
- bool unregistered;
args = DECL_TI_ARGS (decl);
code_pattern = DECL_TEMPLATE_RESULT (tmpl);
- /* Unregister the specialization so that when we tsubst we will not
- just return DECL. We don't have to unregister DECL from TMPL
- because if would only be registered there if it were a partial
- instantiation of a specialization, which it isn't: it's a full
- instantiation. */
- gen_tmpl = most_general_template (tmpl);
- unregistered = reregister_specialization (decl, gen_tmpl,
- /*new_spec=*/NULL_TREE);
-
- /* If the DECL was not unregistered then something peculiar is
- happening: we created a specialization but did not call
- register_specialization for it. */
- gcc_assert (unregistered);
-
/* Make sure that we can see identifiers, and compute access
correctly. */
push_access_scope (decl);
- /* Do the substitution to get the new declaration. */
- new_decl = tsubst (code_pattern, args, tf_error, NULL_TREE);
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ tree decl_parm;
+ tree pattern_parm;
+ tree specs;
+ int args_depth;
+ int parms_depth;
+
+ args_depth = TMPL_ARGS_DEPTH (args);
+ parms_depth = TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl));
+ if (args_depth > parms_depth)
+ args = get_innermost_template_args (args, parms_depth);
+
+ specs = tsubst_exception_specification (TREE_TYPE (code_pattern),
+ args, tf_error, NULL_TREE);
+ if (specs)
+ TREE_TYPE (decl) = build_exception_variant (TREE_TYPE (decl),
+ specs);
+
+ /* Merge parameter declarations. */
+ decl_parm = skip_artificial_parms_for (decl,
+ DECL_ARGUMENTS (decl));
+ pattern_parm
+ = skip_artificial_parms_for (code_pattern,
+ DECL_ARGUMENTS (code_pattern));
+ while (decl_parm)
+ {
+ tree parm_type;
+
+ if (DECL_NAME (decl_parm) != DECL_NAME (pattern_parm))
+ DECL_NAME (decl_parm) = DECL_NAME (pattern_parm);
+ parm_type = tsubst (TREE_TYPE (pattern_parm), args, tf_error,
+ NULL_TREE);
+ if (!same_type_p (TREE_TYPE (decl_parm), parm_type))
+ TREE_TYPE (decl_parm) = parm_type;
+ decl_parm = TREE_CHAIN (decl_parm);
+ pattern_parm = TREE_CHAIN (pattern_parm);
+ }
- if (TREE_CODE (decl) == VAR_DECL)
+ /* Merge additional specifiers from the CODE_PATTERN. */
+ if (DECL_DECLARED_INLINE_P (code_pattern)
+ && !DECL_DECLARED_INLINE_P (decl))
+ DECL_DECLARED_INLINE_P (decl) = 1;
+ if (DECL_INLINE (code_pattern) && !DECL_INLINE (decl))
+ DECL_INLINE (decl) = 1;
+ }
+ else if (TREE_CODE (decl) == VAR_DECL)
{
- /* Set up DECL_INITIAL, since tsubst doesn't. */
- if (!DECL_INITIALIZED_IN_CLASS_P (decl))
- DECL_INITIAL (new_decl) =
+ if (!DECL_INITIALIZED_IN_CLASS_P (decl)
+ && DECL_INITIAL (code_pattern))
+ DECL_INITIAL (decl) =
tsubst_expr (DECL_INITIAL (code_pattern), args,
tf_error, DECL_TI_TEMPLATE (decl));
}
- else if (TREE_CODE (decl) == FUNCTION_DECL)
- {
- /* Convince duplicate_decls to use the DECL_ARGUMENTS from the
- new decl. */
- DECL_INITIAL (new_decl) = error_mark_node;
- /* And don't complain about a duplicate definition. */
- DECL_INITIAL (decl) = NULL_TREE;
- }
+ else
+ gcc_unreachable ();
pop_access_scope (decl);
-
- /* The immediate parent of the new template is still whatever it was
- before, even though tsubst sets DECL_TI_TEMPLATE up as the most
- general template. We also reset the DECL_ASSEMBLER_NAME since
- tsubst always calculates the name as if the function in question
- were really a template instance, and sometimes, with friend
- functions, this is not so. See tsubst_friend_function for
- details. */
- DECL_TI_TEMPLATE (new_decl) = DECL_TI_TEMPLATE (decl);
- COPY_DECL_ASSEMBLER_NAME (decl, new_decl);
- COPY_DECL_RTL (decl, new_decl);
- DECL_USE_TEMPLATE (new_decl) = DECL_USE_TEMPLATE (decl);
-
- /* Call duplicate decls to merge the old and new declarations. */
- duplicate_decls (new_decl, decl);
-
- /* Now, re-register the specialization. */
- register_specialization (decl, gen_tmpl, args);
}
/* Return the TEMPLATE_DECL into which DECL_TI_ARGS(DECL) should be
@@ -10994,7 +11043,8 @@ instantiate_decl (tree d, int defer_ok, int undefined_ok)
DECL_TEMPLATE_SPECIALIZATION. */
gen_tmpl = most_general_template (tmpl);
gen_args = DECL_TI_ARGS (d);
- spec = retrieve_specialization (gen_tmpl, gen_args);
+ spec = retrieve_specialization (gen_tmpl, gen_args,
+ /*class_specializations_p=*/false);
if (spec != NULL_TREE && DECL_TEMPLATE_SPECIALIZATION (spec))
return spec;
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 47d08f34c74..cd6e9b2dc65 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -36,29 +36,20 @@ Boston, MA 02111-1307, USA. */
#include "toplev.h"
#include "stack.h"
-struct vbase_info
-{
- /* The class dominating the hierarchy. */
- tree type;
- /* A pointer to a complete object of the indicated TYPE. */
- tree decl_ptr;
- tree inits;
-};
-
static int is_subobject_of_p (tree, tree);
static base_kind lookup_base_r (tree, tree, base_access, bool, tree *);
static int dynamic_cast_base_recurse (tree, tree, bool, tree *);
-static tree dfs_debug_unmarkedp (tree, int, void *);
static tree dfs_debug_mark (tree, void *);
+static tree dfs_walk_once_r (tree, tree (*pre_fn) (tree, void *),
+ tree (*post_fn) (tree, void *), void *data);
+static void dfs_unmark_r (tree);
static int check_hidden_convs (tree, int, int, tree, tree, tree);
static tree split_conversions (tree, tree, tree, tree);
static int lookup_conversions_r (tree, int, int,
tree, tree, tree, tree, tree *, tree *);
static int look_for_overrides_r (tree, tree);
-static tree lookup_field_queue_p (tree, int, void *);
static tree lookup_field_r (tree, void *);
-static tree dfs_accessible_queue_p (tree, int, void *);
-static tree dfs_accessible_p (tree, void *);
+static tree accessible_r (tree, bool);
static tree dfs_access_in_type (tree, void *);
static access_kind access_in_type (tree, tree);
static int protected_accessible_p (tree, tree, tree);
@@ -663,10 +654,6 @@ dfs_access_in_type (tree binfo, void *data)
/* Note the access to DECL in TYPE. */
SET_BINFO_ACCESS (binfo, access);
- /* Mark TYPE as visited so that if we reach it again we do not
- duplicate our efforts here. */
- BINFO_MARKED (binfo) = 1;
-
return NULL_TREE;
}
@@ -688,47 +675,11 @@ access_in_type (tree type, tree decl)
The algorithm we use is to make a post-order depth-first traversal
of the base-class hierarchy. As we come up the tree, we annotate
each node with the most lenient access. */
- dfs_walk_real (binfo, 0, dfs_access_in_type, unmarkedp, decl);
- dfs_walk (binfo, dfs_unmark, markedp, 0);
+ dfs_walk_once (binfo, NULL, dfs_access_in_type, decl);
return BINFO_ACCESS (binfo);
}
-/* Called from accessible_p via dfs_walk. */
-
-static tree
-dfs_accessible_queue_p (tree derived, int ix, void *data ATTRIBUTE_UNUSED)
-{
- tree binfo = BINFO_BASE_BINFO (derived, ix);
-
- if (BINFO_MARKED (binfo))
- return NULL_TREE;
-
- /* If this class is inherited via private or protected inheritance,
- then we can't see it, unless we are a friend of the derived class. */
- if (BINFO_BASE_ACCESS (derived, ix) != access_public_node
- && !is_friend (BINFO_TYPE (derived), current_scope ()))
- return NULL_TREE;
-
- return binfo;
-}
-
-/* Called from accessible_p via dfs_walk. */
-
-static tree
-dfs_accessible_p (tree binfo, void *data ATTRIBUTE_UNUSED)
-{
- access_kind access;
-
- BINFO_MARKED (binfo) = 1;
- access = BINFO_ACCESS (binfo);
- if (access != ak_none
- && is_friend (BINFO_TYPE (binfo), current_scope ()))
- return binfo;
-
- return NULL_TREE;
-}
-
/* Returns nonzero if it is OK to access DECL through an object
indicated by BINFO in the context of DERIVED. */
@@ -855,6 +806,43 @@ friend_accessible_p (tree scope, tree decl, tree binfo)
return 0;
}
+static tree
+accessible_r (tree binfo, bool once)
+{
+ tree rval = NULL_TREE;
+ unsigned ix;
+ tree base_binfo;
+
+ /* Find the next child binfo to walk. */
+ for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
+ {
+ bool mark = once && BINFO_VIRTUAL_P (base_binfo);
+
+ if (mark && BINFO_MARKED (base_binfo))
+ continue;
+
+ /* If the base is inherited via private or protected
+ inheritance, then we can't see it, unless we are a friend of
+ the current binfo. */
+ if (BINFO_BASE_ACCESS (binfo, ix) != access_public_node
+ && !is_friend (BINFO_TYPE (binfo), current_scope ()))
+ continue;
+
+ if (mark)
+ BINFO_MARKED (base_binfo) = 1;
+
+ rval = accessible_r (base_binfo, once);
+ if (rval)
+ return rval;
+ }
+
+ if (BINFO_ACCESS (binfo) != ak_none
+ && is_friend (BINFO_TYPE (binfo), current_scope ()))
+ rval = binfo;
+
+ return rval;
+}
+
/* DECL is a declaration from a base class of TYPE, which was the
class used to name DECL. Return nonzero if, in the current
context, DECL is accessible. If TYPE is actually a BINFO node,
@@ -941,12 +929,28 @@ accessible_p (tree type, tree decl)
{
/* Walk the hierarchy again, looking for a base class that allows
access. */
- t = dfs_walk (binfo, dfs_accessible_p, dfs_accessible_queue_p, 0);
- /* Clear any mark bits. Note that we have to walk the whole tree
- here, since we have aborted the previous walk from some point
- deep in the tree. */
- dfs_walk (binfo, dfs_unmark, 0, 0);
+ t = accessible_r
+ (binfo, CLASSTYPE_DIAMOND_SHAPED_P (BINFO_TYPE (binfo)));
+ if (!CLASSTYPE_DIAMOND_SHAPED_P (BINFO_TYPE (binfo)))
+ ;/* We are not diamond shaped, and therefore cannot
+ encounter the same binfo twice. */
+ else if (!BINFO_INHERITANCE_CHAIN (binfo))
+ {
+ /* We are at the top of the hierarchy, and can use the
+ CLASSTYPE_VBASECLASSES list for unmarking the virtual
+ bases. */
+ VEC (tree) *vbases;
+ unsigned ix;
+ tree base_binfo;
+
+ for (vbases = CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)), ix = 0;
+ VEC_iterate (tree, vbases, ix, base_binfo); ix++)
+ BINFO_MARKED (base_binfo) = 0;
+ }
+ else
+ dfs_unmark_r (binfo);
+
return t != NULL_TREE;
}
}
@@ -969,33 +973,6 @@ struct lookup_field_info {
const char *errstr;
};
-/* Returns nonzero if BINFO is not hidden by the value found by the
- lookup so far. If BINFO is hidden, then there's no need to look in
- it. DATA is really a struct lookup_field_info. Called from
- lookup_field via breadth_first_search. */
-
-static tree
-lookup_field_queue_p (tree derived, int ix, void *data)
-{
- tree binfo = BINFO_BASE_BINFO (derived, ix);
- struct lookup_field_info *lfi = (struct lookup_field_info *) data;
-
- /* Don't look for constructors or destructors in base classes. */
- if (IDENTIFIER_CTOR_OR_DTOR_P (lfi->name))
- return NULL_TREE;
-
- /* If this base class is hidden by the best-known value so far, we
- don't need to look. */
- if (lfi->rval_binfo && derived == lfi->rval_binfo)
- return NULL_TREE;
-
- /* If this is a dependent base, don't look in it. */
- if (BINFO_DEPENDENT_BASE_P (binfo))
- return NULL_TREE;
-
- return binfo;
-}
-
/* Within the scope of a template class, you can refer to the to the
current specialization with the name of the template itself. For
example:
@@ -1075,6 +1052,16 @@ lookup_field_r (tree binfo, void *data)
tree type = BINFO_TYPE (binfo);
tree nval = NULL_TREE;
+ /* If this is a dependent base, don't look in it. */
+ if (BINFO_DEPENDENT_BASE_P (binfo))
+ return NULL_TREE;
+
+ /* If this base class is hidden by the best-known value so far, we
+ don't need to look. */
+ if (lfi->rval_binfo && BINFO_INHERITANCE_CHAIN (binfo) == lfi->rval_binfo
+ && !BINFO_VIRTUAL_P (binfo))
+ return dfs_skip_bases;
+
/* First, look for a function. There can't be a function and a data
member with the same name, and if there's a function and a type
with the same name, the type is hidden by the function. */
@@ -1092,7 +1079,7 @@ lookup_field_r (tree binfo, void *data)
/* If there is no declaration with the indicated name in this type,
then there's nothing to do. */
if (!nval)
- return NULL_TREE;
+ goto done;
/* If we're looking up a type (as with an elaborated type specifier)
we ignore all non-types we find. */
@@ -1119,14 +1106,14 @@ lookup_field_r (tree binfo, void *data)
if (e != NULL)
nval = TYPE_MAIN_DECL (e->type);
else
- return NULL_TREE;
+ goto done;
}
}
/* You must name a template base class with a template-id. */
if (!same_type_p (type, lfi->type)
&& template_self_reference_p (type, nval))
- return NULL_TREE;
+ goto done;
/* If the lookup already found a match, and the new value doesn't
hide the old one, we might have an ambiguity. */
@@ -1165,6 +1152,10 @@ lookup_field_r (tree binfo, void *data)
lfi->rval_binfo = binfo;
}
+ done:
+ /* Don't look for constructors or destructors in base classes. */
+ if (IDENTIFIER_CTOR_OR_DTOR_P (lfi->name))
+ return dfs_skip_bases;
return NULL_TREE;
}
@@ -1251,8 +1242,7 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type)
lfi.type = type;
lfi.name = name;
lfi.want_type = want_type;
- dfs_walk_real (basetype_path, &lookup_field_r, 0,
- &lookup_field_queue_p, &lfi);
+ dfs_walk_all (basetype_path, &lookup_field_r, NULL, &lfi);
rval = lfi.rval;
rval_binfo = lfi.rval_binfo;
if (rval_binfo)
@@ -1464,6 +1454,22 @@ lookup_fnfields_1 (tree type, tree name)
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
the class or namespace used to qualify the name. CONTEXT_CLASS is
the class corresponding to the object in which DECL will be used.
@@ -1510,66 +1516,158 @@ adjust_result_of_qualified_name_lookup (tree decl,
/* Walk the class hierarchy within BINFO, in a depth-first traversal.
- PREFN is called in preorder, while POSTFN is called in postorder.
- If they ever returns a non-NULL value, that value is immediately
- returned and the walk is terminated. Both PREFN and POSTFN can be
- NULL. At each node, PREFN and POSTFN are passed the binfo to
- examine. Before each base-binfo of BINFO is walked, QFN is called.
- If the value returned is nonzero, the base-binfo is walked;
- otherwise it is not. If QFN is NULL, it is treated as a function
- which always returns 1. All callbacks are passed DATA whenever
- they are called. */
+ PRE_FN is called in preorder, while POST_FN is called in postorder.
+ If PRE_FN returns DFS_SKIP_BASES, child binfos will not be
+ walked. If PRE_FN or POST_FN returns a different non-NULL value,
+ that value is immediately returned and the walk is terminated. One
+ of PRE_FN and POST_FN can be NULL. At each node, PRE_FN and
+ POST_FN are passed the binfo to examine and the caller's DATA
+ value. All paths are walked, thus virtual and morally virtual
+ binfos can be multiply walked. */
tree
-dfs_walk_real (tree binfo,
- tree (*prefn) (tree, void *),
- tree (*postfn) (tree, void *),
- tree (*qfn) (tree, int, void *),
- void *data)
+dfs_walk_all (tree binfo, tree (*pre_fn) (tree, void *),
+ tree (*post_fn) (tree, void *), void *data)
{
- int i;
+ tree rval;
+ unsigned ix;
tree base_binfo;
- tree rval = NULL_TREE;
-
+
/* Call the pre-order walking function. */
- if (prefn)
+ if (pre_fn)
{
- rval = (*prefn) (binfo, data);
+ rval = pre_fn (binfo, data);
+ if (rval)
+ {
+ if (rval == dfs_skip_bases)
+ goto skip_bases;
+ return rval;
+ }
+ }
+
+ /* Find the next child binfo to walk. */
+ for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
+ {
+ rval = dfs_walk_all (base_binfo, pre_fn, post_fn, data);
if (rval)
return rval;
}
- /* Process the basetypes. */
- for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ skip_bases:
+ /* Call the post-order walking function. */
+ if (post_fn)
+ return post_fn (binfo, data);
+ return NULL_TREE;
+}
+
+/* Worker for dfs_walk_once. This behaves as dfs_walk_all, except
+ that binfos are walked at most once. */
+
+static tree
+dfs_walk_once_r (tree binfo, tree (*pre_fn) (tree, void *),
+ tree (*post_fn) (tree, void *), void *data)
+{
+ tree rval;
+ unsigned ix;
+ tree base_binfo;
+
+ /* Call the pre-order walking function. */
+ if (pre_fn)
{
- if (qfn)
+ rval = pre_fn (binfo, data);
+ if (rval)
{
- base_binfo = (*qfn) (binfo, i, data);
- if (!base_binfo)
+ if (rval == dfs_skip_bases)
+ goto skip_bases;
+
+ return rval;
+ }
+ }
+
+ /* Find the next child binfo to walk. */
+ for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
+ {
+ if (BINFO_VIRTUAL_P (base_binfo))
+ {
+ if (BINFO_MARKED (base_binfo))
continue;
+ BINFO_MARKED (base_binfo) = 1;
}
- rval = dfs_walk_real (base_binfo, prefn, postfn, qfn, data);
+
+ rval = dfs_walk_once_r (base_binfo, pre_fn, post_fn, data);
if (rval)
return rval;
}
-
+
+ skip_bases:
/* Call the post-order walking function. */
- if (postfn)
- rval = (*postfn) (binfo, data);
+ if (post_fn)
+ return post_fn (binfo, data);
- return rval;
+ return NULL_TREE;
+}
+
+/* Worker for dfs_walk_once. Recursively unmark the virtual base binfos of
+ BINFO. */
+
+static void
+dfs_unmark_r (tree binfo)
+{
+ unsigned ix;
+ tree base_binfo;
+
+ /* Process the basetypes. */
+ for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
+ {
+ if (BINFO_VIRTUAL_P (base_binfo))
+ {
+ if (!BINFO_MARKED (base_binfo))
+ continue;
+ BINFO_MARKED (base_binfo) = 0;
+ }
+ /* Only walk, if it can contain more virtual bases. */
+ if (CLASSTYPE_VBASECLASSES (BINFO_TYPE (base_binfo)))
+ dfs_unmark_r (base_binfo);
+ }
}
-/* Exactly like dfs_walk_real, except that there is no pre-order
- function call and FN is called in post-order. */
+/* Like dfs_walk_all, except that binfos are not multiply walked. For
+ non-diamond shaped hierarchies this is the same as dfs_walk_all.
+ For diamond shaped hierarchies we must mark the virtual bases, to
+ avoid multiple walks. */
tree
-dfs_walk (tree binfo,
- tree (*fn) (tree, void *),
- tree (*qfn) (tree, int, void *),
- void *data)
+dfs_walk_once (tree binfo, tree (*pre_fn) (tree, void *),
+ tree (*post_fn) (tree, void *), void *data)
{
- return dfs_walk_real (binfo, 0, fn, qfn, data);
+ tree rval;
+
+ gcc_assert (pre_fn || post_fn);
+
+ if (!CLASSTYPE_DIAMOND_SHAPED_P (BINFO_TYPE (binfo)))
+ /* We are not diamond shaped, and therefore cannot encounter the
+ same binfo twice. */
+ rval = dfs_walk_all (binfo, pre_fn, post_fn, data);
+ else
+ {
+ rval = dfs_walk_once_r (binfo, pre_fn, post_fn, data);
+ if (!BINFO_INHERITANCE_CHAIN (binfo))
+ {
+ /* We are at the top of the hierarchy, and can use the
+ CLASSTYPE_VBASECLASSES list for unmarking the virtual
+ bases. */
+ VEC (tree) *vbases;
+ unsigned ix;
+ tree base_binfo;
+
+ for (vbases = CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)), ix = 0;
+ VEC_iterate (tree, vbases, ix, base_binfo); ix++)
+ BINFO_MARKED (base_binfo) = 0;
+ }
+ else
+ dfs_unmark_r (binfo);
+ }
+ return rval;
}
/* Check that virtual overrider OVERRIDER is acceptable for base function
@@ -1789,8 +1887,6 @@ dfs_get_pure_virtuals (tree binfo, void *data)
VEC_safe_push (tree, CLASSTYPE_PURE_VIRTUALS (type),
BV_FN (virtuals));
}
-
- BINFO_MARKED (binfo) = 1;
return NULL_TREE;
}
@@ -1809,40 +1905,9 @@ get_pure_virtuals (tree type)
(A primary base is not interesting because the derived class of
which it is a primary base will contain vtable entries for the
pure virtuals in the base class. */
- dfs_walk (TYPE_BINFO (type), dfs_get_pure_virtuals, unmarkedp, type);
- dfs_walk (TYPE_BINFO (type), dfs_unmark, markedp, type);
+ dfs_walk_once (TYPE_BINFO (type), NULL, dfs_get_pure_virtuals, type);
}
-/* DEPTH-FIRST SEARCH ROUTINES. */
-
-tree
-markedp (tree derived, int ix, void *data ATTRIBUTE_UNUSED)
-{
- tree binfo = BINFO_BASE_BINFO (derived, ix);
-
- return BINFO_MARKED (binfo) ? binfo : NULL_TREE;
-}
-
-tree
-unmarkedp (tree derived, int ix, void *data ATTRIBUTE_UNUSED)
-{
- tree binfo = BINFO_BASE_BINFO (derived, ix);
-
- return !BINFO_MARKED (binfo) ? binfo : NULL_TREE;
-}
-
-/* The worker functions for `dfs_walk'. These do not need to
- test anything (vis a vis marking) if they are paired with
- a predicate function (above). */
-
-tree
-dfs_unmark (tree binfo, void *data ATTRIBUTE_UNUSED)
-{
- BINFO_MARKED (binfo) = 0;
- return NULL_TREE;
-}
-
-
/* Debug info for C++ classes can get very large; try to avoid
emitting it everywhere.
@@ -1889,23 +1954,14 @@ dfs_debug_mark (tree binfo, void *data ATTRIBUTE_UNUSED)
{
tree t = BINFO_TYPE (binfo);
+ if (CLASSTYPE_DEBUG_REQUESTED (t))
+ return dfs_skip_bases;
+
CLASSTYPE_DEBUG_REQUESTED (t) = 1;
return NULL_TREE;
}
-/* Returns BINFO if we haven't already noted that we want debugging
- info for this base class. */
-
-static tree
-dfs_debug_unmarkedp (tree derived, int ix, void *data ATTRIBUTE_UNUSED)
-{
- tree binfo = BINFO_BASE_BINFO (derived, ix);
-
- return (!CLASSTYPE_DEBUG_REQUESTED (BINFO_TYPE (binfo))
- ? binfo : NULL_TREE);
-}
-
/* Write out the debugging information for TYPE, whose vtable is being
emitted. Also walk through our bases and note that we want to
write out information for them. This avoids the problem of not
@@ -1922,7 +1978,7 @@ note_debug_info_needed (tree type)
rest_of_type_compilation (type, toplevel_bindings_p ());
}
- dfs_walk (TYPE_BINFO (type), dfs_debug_mark, dfs_debug_unmarkedp, 0);
+ dfs_walk_all (TYPE_BINFO (type), dfs_debug_mark, NULL, 0);
}
void
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 5bb6f3b4d59..78d2683f6ef 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1178,6 +1178,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands,
output_operands, input_operands,
clobbers);
ASM_VOLATILE_P (r) = volatile_p;
+ r = maybe_cleanup_point_expr (r);
return add_stmt (r);
}