diff options
author | Jason Merrill <jason@redhat.com> | 2010-06-29 20:50:45 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-06-29 20:50:45 -0400 |
commit | 4640884658bae7ba9ff09068efcbe4b7e94baf8d (patch) | |
tree | 85c05d67287f91a060fe0e69e71f48258e217270 /gcc/cp | |
parent | 066ec0a4a0c12148352889d7d26a2975960d5571 (diff) | |
download | gcc-4640884658bae7ba9ff09068efcbe4b7e94baf8d.zip gcc-4640884658bae7ba9ff09068efcbe4b7e94baf8d.tar.gz gcc-4640884658bae7ba9ff09068efcbe4b7e94baf8d.tar.bz2 |
class.c (type_has_virtual_destructor): New.
* class.c (type_has_virtual_destructor): New.
* cp-tree.h: Declare it.
* semantics.c (trait_expr_value): Use it.
* call.c (build_over_call): Only give warnings with tf_warning.
* name-lookup.c (pop_scope): Handle NULL_TREE.
From-SVN: r161578
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/call.c | 2 | ||||
-rw-r--r-- | gcc/cp/class.c | 19 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/decl.c | 1 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 2 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 3 | ||||
-rw-r--r-- | gcc/cp/tree.c | 23 |
8 files changed, 52 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7eaca7f..bc02bd0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 2010-06-29 Jason Merrill <jason@redhat.com> + * class.c (type_has_virtual_destructor): New. + * cp-tree.h: Declare it. + * semantics.c (trait_expr_value): Use it. + + * call.c (build_over_call): Only give warnings with tf_warning. + + * name-lookup.c (pop_scope): Handle NULL_TREE. + * cp-tree.h (TYPE_HAS_ASSIGN_REF): Rename to TYPE_HAS_COPY_ASSIGN. (TYPE_HAS_CONST_ASSIGN_REF): Rename to TYPE_HAS_CONST_COPY_ASSIGN. (TYPE_HAS_INIT_REF): Rename to TYPE_HAS_COPY_CTOR. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c05e5a1..852c7ea 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5600,7 +5600,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) } /* Give any warnings we noticed during overload resolution. */ - if (cand->warnings) + if (cand->warnings && (complain & tf_warning)) { struct candidate_warning *w; for (w = cand->warnings; w; w = w->next) diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 3a87555..bfd3113 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3838,7 +3838,9 @@ check_methods (tree t) if (DECL_PURE_VIRTUAL_P (x)) VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); } - /* All user-provided destructors are non-trivial. */ + /* All user-provided destructors are non-trivial. + Constructors and assignment ops are handled in + grok_special_member_properties. */ if (DECL_DESTRUCTOR_P (x) && user_provided_p (x)) TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = 1; } @@ -4260,6 +4262,21 @@ type_has_user_provided_default_constructor (tree t) return false; } +/* Returns true iff class TYPE has a virtual destructor. */ + +bool +type_has_virtual_destructor (tree type) +{ + tree dtor; + + if (!CLASS_TYPE_P (type)) + return false; + + gcc_assert (COMPLETE_TYPE_P (type)); + dtor = CLASSTYPE_DESTRUCTORS (type); + return (dtor && DECL_VIRTUAL_P (dtor)); +} + /* Remove all zero-width bit-fields from T. */ static void diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1b3c2f0..bfdf036 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4655,6 +4655,7 @@ extern tree in_class_defaulted_default_constructor (tree); extern bool user_provided_p (tree); extern bool type_has_user_provided_constructor (tree); extern bool type_has_user_provided_default_constructor (tree); +extern bool type_has_virtual_destructor (tree); extern void defaulted_late_check (tree); extern bool defaultable_fn_check (tree); extern void fixup_type_variants (tree); @@ -5280,6 +5281,7 @@ extern bool pod_type_p (const_tree); extern bool layout_pod_type_p (const_tree); extern bool std_layout_type_p (const_tree); extern bool trivial_type_p (const_tree); +extern bool trivially_copyable_p (const_tree); extern bool type_has_nontrivial_default_init (const_tree); extern bool type_has_nontrivial_copy_init (const_tree); extern bool class_tmpl_impl_spec_p (const_tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1011243..0c2f7e5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10295,6 +10295,7 @@ grok_special_member_properties (tree decl) TYPE_HAS_CONST_COPY_ASSIGN (class_type) = 1; } } + /* Destructors are handled in check_methods. */ } /* Check a constructor DECL has the correct form. Complains diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 4e40e3b..6713119 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -2480,6 +2480,8 @@ push_scope (tree t) void pop_scope (tree t) { + if (t == NULL_TREE) + return; if (TREE_CODE (t) == NAMESPACE_DECL) pop_decl_namespace (); else if CLASS_TYPE_P (t) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9dae90b..adc5e7f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5104,8 +5104,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) && TYPE_HAS_TRIVIAL_DESTRUCTOR (type1))); case CPTK_HAS_VIRTUAL_DESTRUCTOR: - return (CLASS_TYPE_P (type1) - && (t = locate_dtor (type1, NULL)) && DECL_VIRTUAL_P (t)); + return type_has_virtual_destructor (type1); case CPTK_IS_ABSTRACT: return (CLASS_TYPE_P (type1) && CLASSTYPE_PURE_VIRTUALS (type1)); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index f7ce655..7236924 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2381,22 +2381,37 @@ type_has_nontrivial_copy_init (const_tree t) return 0; } -/* Returns 1 iff type T is a trivial type, as defined in [basic.types]. */ +/* Returns 1 iff type T is a trivially copyable type, as defined in + [basic.types] and [class]. */ bool -trivial_type_p (const_tree t) +trivially_copyable_p (const_tree t) { t = strip_array_types (CONST_CAST_TREE (t)); if (CLASS_TYPE_P (t)) - return (TYPE_HAS_TRIVIAL_DFLT (t) - && TYPE_HAS_TRIVIAL_COPY_CTOR (t) + return (TYPE_HAS_TRIVIAL_COPY_CTOR (t) && TYPE_HAS_TRIVIAL_COPY_ASSIGN (t) && TYPE_HAS_TRIVIAL_DESTRUCTOR (t)); else return scalarish_type_p (t); } +/* Returns 1 iff type T is a trivial type, as defined in [basic.types] and + [class]. */ + +bool +trivial_type_p (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return (TYPE_HAS_TRIVIAL_DFLT (t) + && trivially_copyable_p (t)); + else + return scalarish_type_p (t); +} + /* Returns 1 iff type T is a POD type, as defined in [basic.types]. */ bool |