aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-10-01 10:37:08 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-10-01 10:37:08 -0400
commit2968d410491161912b56a2ec7f7528d06d5ba19d (patch)
tree231dd165dc3382239b05438e1931cab7f322e2ee
parent3a303360aaa25cc639216d82b3c33b317937cb9d (diff)
downloadgcc-2968d410491161912b56a2ec7f7528d06d5ba19d.zip
gcc-2968d410491161912b56a2ec7f7528d06d5ba19d.tar.gz
gcc-2968d410491161912b56a2ec7f7528d06d5ba19d.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/decl.c24
-rw-r--r--gcc/cp/pt.c8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/defaulted13.C29
5 files changed, 69 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a25f62b..1405a5b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index cb2827d..9f5ca30 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 5f9b07c..6b98956 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 01805ae..b3551d1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted13.C b/gcc/testsuite/g++.dg/cpp0x/defaulted13.C
new file mode 100644
index 0000000..87b8100
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted13.C
@@ -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);
+}