From 01628e543b8867e4c4ca5724d4982caae7f0bc1a Mon Sep 17 00:00:00 2001 From: Jason Merrill <jason@redhat.com> Date: Mon, 7 Jun 2010 16:42:37 -0400 Subject: [PATCH] cp-tree.h (COMPLETE_OR_OPEN_TYPE_P): New macro. * cp-tree.h (COMPLETE_OR_OPEN_TYPE_P): New macro. * init.c (build_offset_ref): Use it. * pt.c (maybe_process_partial_specialization): Use it. (instantiate_class_template): Use it. * search.c (lookup_base): Use it. From-SVN: r160398 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-tree.h | 5 +++++ gcc/cp/init.c | 3 +-- gcc/cp/pt.c | 8 +++----- gcc/cp/search.c | 3 +-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7119dddff5b6..322023008968 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2010-06-07 Jason Merrill <jason@redhat.com> + * cp-tree.h (COMPLETE_OR_OPEN_TYPE_P): New macro. + * init.c (build_offset_ref): Use it. + * pt.c (maybe_process_partial_specialization): Use it. + (instantiate_class_template): Use it. + * search.c (lookup_base): Use it. + * pt.c (lookup_template_class): Don't mess with DECL_TEMPLATE_INSTANTIATIONS except for partial instantiations. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5efe2798d321..f507a21a78da 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1433,6 +1433,11 @@ struct GTY(()) lang_type { starting the definition of this type has been seen. */ #define TYPE_BEING_DEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->being_defined) +/* Nonzero means that this type is either complete or being defined, so we + can do lookup in it. */ +#define COMPLETE_OR_OPEN_TYPE_P(NODE) \ + (COMPLETE_TYPE_P (NODE) || (CLASS_TYPE_P (NODE) && TYPE_BEING_DEFINED (NODE))) + /* Mark bits for repeated base checks. */ #define TYPE_MARKED_P(NODE) TREE_LANG_FLAG_6 (TYPE_CHECK (NODE)) diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 1f3e8035382a..66451b1e356d 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1520,8 +1520,7 @@ build_offset_ref (tree type, tree member, bool address_p) /* Callers should call mark_used before this point. */ gcc_assert (!DECL_P (member) || TREE_USED (member)); - if (!COMPLETE_TYPE_P (complete_type (type)) - && !TYPE_BEING_DEFINED (type)) + if (!COMPLETE_OR_OPEN_TYPE_P (complete_type (type))) { error ("incomplete type %qT does not have member %qD", type, member); return error_mark_node; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fd93b1b3dc15..b62a9bc695f4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -891,7 +891,7 @@ maybe_process_partial_specialization (tree type) *slot = GGC_NEW (spec_entry); **slot = elt; } - else if (COMPLETE_TYPE_P (inst) || TYPE_BEING_DEFINED (inst)) + else if (COMPLETE_OR_OPEN_TYPE_P (inst)) /* But if we've had an implicit instantiation, that's a problem ([temp.expl.spec]/6). */ error ("specialization %qT after instantiation %qT", @@ -7700,8 +7700,7 @@ instantiate_class_template (tree type) if (type == error_mark_node) return error_mark_node; - if (TYPE_BEING_DEFINED (type) - || COMPLETE_TYPE_P (type) + if (COMPLETE_OR_OPEN_TYPE_P (type) || uses_template_parms (type)) return type; @@ -7796,8 +7795,7 @@ instantiate_class_template (tree type) instantiate it, and that lookup should instantiate the enclosing class. */ gcc_assert (!DECL_CLASS_SCOPE_P (TYPE_MAIN_DECL (pattern)) - || COMPLETE_TYPE_P (TYPE_CONTEXT (type)) - || TYPE_BEING_DEFINED (TYPE_CONTEXT (type))); + || COMPLETE_OR_OPEN_TYPE_P (TYPE_CONTEXT (type))); base_list = NULL_TREE; if (BINFO_N_BASE_BINFOS (pbinfo)) diff --git a/gcc/cp/search.c b/gcc/cp/search.c index e30882116bb2..d69d415cd60a 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -216,8 +216,7 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr) /* If BASE is incomplete, it can't be a base of T--and instantiating it might cause an error. */ - if (t_binfo && CLASS_TYPE_P (base) - && (COMPLETE_TYPE_P (base) || TYPE_BEING_DEFINED (base))) + if (t_binfo && CLASS_TYPE_P (base) && COMPLETE_OR_OPEN_TYPE_P (base)) { struct lookup_base_data_s data; -- GitLab