pt.c (register_specialization): Push DECL_SOURCE_LOCATION to the clones.

* pt.c (register_specialization): Push DECL_SOURCE_LOCATION to the
	clones.

	* decl.c (grok_special_member_properties): Only adjust
	TYPE_HAS_COMPLEX_* if the function is defaulted in the class body.
	(cp_finish_decl): Push DECL_DELETED_FN/DECL_DEFAULTED_FN to the
	clones.

From-SVN: r152373
This commit is contained in:
Jason Merrill 2009-10-01 10:37:08 -04:00 committed by Jason Merrill
parent 3a303360aa
commit 2968d41049
5 changed files with 69 additions and 6 deletions

View file

@ -1,3 +1,13 @@
2009-10-01 Jason Merrill <jason@redhat.com>
* pt.c (register_specialization): Push DECL_SOURCE_LOCATION to the
clones.
* decl.c (grok_special_member_properties): Only adjust
TYPE_HAS_COMPLEX_* if the function is defaulted in the class body.
(cp_finish_decl): Push DECL_DELETED_FN/DECL_DEFAULTED_FN to the
clones.
2009-09-30 Gabriel Dos Reis <gdr@cs.tamu.edu>
* decl.c (check_for_uninitialized_const_var): Check constexpr

View file

@ -5586,12 +5586,19 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
if (init && TREE_CODE (decl) == FUNCTION_DECL)
{
tree clone;
if (init == ridpointers[(int)RID_DELETE])
{
/* FIXME check this is 1st decl. */
DECL_DELETED_FN (decl) = 1;
DECL_DECLARED_INLINE_P (decl) = 1;
DECL_INITIAL (decl) = error_mark_node;
FOR_EACH_CLONE (clone, decl)
{
DECL_DELETED_FN (clone) = 1;
DECL_DECLARED_INLINE_P (clone) = 1;
DECL_INITIAL (clone) = error_mark_node;
}
init = NULL_TREE;
}
else if (init == ridpointers[(int)RID_DEFAULT])
@ -5602,7 +5609,11 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
DECL_INITIAL (decl) = NULL_TREE;
}
else
DECL_DEFAULTED_FN (decl) = 1;
{
DECL_DEFAULTED_FN (decl) = 1;
FOR_EACH_CLONE (clone, decl)
DECL_DEFAULTED_FN (clone) = 1;
}
}
}
@ -9966,6 +9977,10 @@ move_fn_p (const_tree d)
/* Remember any special properties of member function DECL. */
#define DECL_DEFAULTED_IN_CLASS_P(DECL) \
(DECL_DEFAULTED_FN (DECL) \
&& (DECL_ARTIFICIAL (DECL) || DECL_INITIALIZED_IN_CLASS_P (DECL)))
void
grok_special_member_properties (tree decl)
{
@ -9992,7 +10007,7 @@ grok_special_member_properties (tree decl)
are no other parameters or else all other parameters have
default arguments. */
TYPE_HAS_INIT_REF (class_type) = 1;
if (!DECL_DEFAULTED_FN (decl))
if (!DECL_DEFAULTED_IN_CLASS_P (decl))
TYPE_HAS_COMPLEX_INIT_REF (class_type) = 1;
if (ctor > 1)
TYPE_HAS_CONST_INIT_REF (class_type) = 1;
@ -10000,7 +10015,8 @@ grok_special_member_properties (tree decl)
else if (sufficient_parms_p (FUNCTION_FIRST_USER_PARMTYPE (decl)))
{
TYPE_HAS_DEFAULT_CONSTRUCTOR (class_type) = 1;
if (TREE_CODE (decl) == TEMPLATE_DECL || !DECL_DEFAULTED_FN (decl))
if (TREE_CODE (decl) == TEMPLATE_DECL
|| !DECL_DEFAULTED_IN_CLASS_P (decl))
TYPE_HAS_COMPLEX_DFLT (class_type) = 1;
}
else if (is_list_ctor (decl))
@ -10019,7 +10035,7 @@ grok_special_member_properties (tree decl)
if (assop)
{
TYPE_HAS_ASSIGN_REF (class_type) = 1;
if (!DECL_DEFAULTED_FN (decl))
if (!DECL_DEFAULTED_IN_CLASS_P (decl))
TYPE_HAS_COMPLEX_ASSIGN_REF (class_type) = 1;
if (assop != 1)
TYPE_HAS_CONST_ASSIGN_REF (class_type) = 1;

View file

@ -1348,8 +1348,12 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend,
to the primary function; now copy the inline bits to
the various clones. */
FOR_EACH_CLONE (clone, fn)
DECL_DECLARED_INLINE_P (clone)
= DECL_DECLARED_INLINE_P (fn);
{
DECL_DECLARED_INLINE_P (clone)
= DECL_DECLARED_INLINE_P (fn);
DECL_SOURCE_LOCATION (clone)
= DECL_SOURCE_LOCATION (fn);
}
check_specialization_namespace (fn);
return fn;

View file

@ -1,3 +1,7 @@
2009-10-01 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/defaulted13.C: New.
2009-09-30 Dennis Wassel <dennis.wassel@gmail.com>
* gcc/testsuite/gfortran.dg/bounds_check_7.f90: Adapted error message.

View file

@ -0,0 +1,29 @@
// { dg-options -std=c++0x }
template<typename T>
struct NonCopyable {
NonCopyable() = default;
NonCopyable(NonCopyable const&);
};
template<>
NonCopyable<int>::NonCopyable(NonCopyable<int> const&) = delete; // { dg-error "deleted" }
template<typename T>
NonCopyable<T>::NonCopyable(NonCopyable<T> const&) = default;
template<>
NonCopyable<double>::NonCopyable(NonCopyable<double> const&) = delete; // { dg-error "deleted" }
int main()
{
NonCopyable<double> nc_dbl;
NonCopyable<double> nc_dbl_cpy(nc_dbl); // { dg-error "used here" }
NonCopyable<int> nc_int;
NonCopyable<int> nc_int_cpy(nc_int); // { dg-error "used here" }
NonCopyable<char> nc_char;
NonCopyable<char> nc_char_cpy(nc_char);
}