+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
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])
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;
+ }
}
}
/* 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)
{
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;
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))
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;
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;
--- /dev/null
+// { 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);
+}