Commit 46408846 by Jason Merrill Committed by Jason Merrill

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
parent 066ec0a4
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.
......
......@@ -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)
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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)
......
......@@ -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));
......
......@@ -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
......
2010-06-29 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/defaulted19.C: New.
* g++.dg/expr/string-1.C: Fix for -std=c++0x.
* g++.dg/template/error23.C: Fix for -std=c++0x.
2010-06-29 Janus Weil <janus@gcc.gnu.org>
PR fortran/44718
......
// We allocate a cookie to help us run the destructor even if it's deleted.
// { dg-options -std=c++0x }
// { dg-do run }
struct A
{
~A() = delete;
};
void *p = 0;
void *operator new[](__SIZE_TYPE__ t)
{
p = ::operator new (t);
return p;
}
int main()
{
A* ap = new A[5];
return ap == p;
}
// { dg-do compile }
// This testcase used to seg fault (PR c++/38648)
// { dg-prune-output "initializer lists" }
char a[1];
int foo( // { dg-error "extended initializer lists only available" }
int foo(
{
a = ""; // { dg-error "" }
return 0; // { dg-error "" }
......
......@@ -8,10 +8,10 @@ struct nullptr_type {
operator T* ( void ) const {
return ( 0 );
}
} const nullptr;
} const nullptr_ob;
int main ( void ) {
0 == nullptr; // { dg-error "match" }
0 == nullptr_ob; // { dg-error "match" }
}
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