diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-19 19:28:09 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-19 19:28:09 +0000 |
commit | d5f9dab359626cfff18d69c6533b99d7e00df2d0 (patch) | |
tree | fa2e55ca24d17194496f15f5099abd3034cf20f1 | |
parent | c0735efa180c3c891dc78888a1d142c2196b6d4c (diff) | |
download | gcc-d5f9dab359626cfff18d69c6533b99d7e00df2d0.tar.gz |
PR c++/16623
* cp-tree.h (lang_type_class): Add lazy_assignment_op.
(CLASSTYPE_LAZY_ASSIGNMENT_OP): New macro.
* class.c (add_implicitly_declared_members): Use
CLASSTYPE_LAZY_ASSIGNMENT_OP.
* method.c (lazily_declare_fn): Clear
CLASSTYPE_LAZY_ASSIGNMENT_OP.
* search.c (lookup_fnfields_1): Check it.
PR c++/16623
* g++.dg/template/assign1.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84928 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/class.c | 6 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 8 | ||||
-rw-r--r-- | gcc/cp/method.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/assign1.C | 15 |
6 files changed, 45 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dfd8d26229a..40387477637 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2004-07-19 Mark Mitchell <mark@codesourcery.com> + + PR c++/16623 + * cp-tree.h (lang_type_class): Add lazy_assignment_op. + (CLASSTYPE_LAZY_ASSIGNMENT_OP): New macro. + * class.c (add_implicitly_declared_members): Use + CLASSTYPE_LAZY_ASSIGNMENT_OP. + * method.c (lazily_declare_fn): Clear + CLASSTYPE_LAZY_ASSIGNMENT_OP. + * search.c (lookup_fnfields_1): Check it. + 2004-07-19 Nathan Sidwell <nathan@codesourcery.com> * class.c (add_method): Delay adding the slot until the end. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 69f6d9e6e6f..75f7152d400 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2558,7 +2558,11 @@ add_implicitly_declared_members (tree t, of the parameter to the assignment operator will be a const or non-const reference. */ if (!TYPE_HAS_ASSIGN_REF (t) && !TYPE_FOR_JAVA (t)) - TYPE_HAS_CONST_ASSIGN_REF (t) = !cant_have_const_assignment; + { + TYPE_HAS_ASSIGN_REF (t) = 1; + TYPE_HAS_CONST_ASSIGN_REF (t) = !cant_have_const_assignment; + CLASSTYPE_LAZY_ASSIGNMENT_OP (t) = 1; + } /* Now, hook all of the new functions on to TYPE_METHODS, and add them to the CLASSTYPE_METHOD_VEC. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ca7eae30f3b..ad8e8dd2d64 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -989,6 +989,7 @@ struct lang_type_class GTY(()) unsigned lazy_default_ctor : 1; unsigned lazy_copy_ctor : 1; + unsigned lazy_assignment_op : 1; unsigned has_const_init_ref : 1; unsigned has_complex_init_ref : 1; unsigned has_complex_assign_ref : 1; @@ -1002,7 +1003,7 @@ struct lang_type_class GTY(()) /* There are some bits left to fill out a 32-bit word. Keep track of this by updating the size of this bitfield whenever you add or remove a flag. */ - unsigned dummy : 9; + unsigned dummy : 8; tree primary_base; tree vfields; @@ -1097,6 +1098,11 @@ struct lang_type GTY(()) #define CLASSTYPE_LAZY_COPY_CTOR(NODE) \ (LANG_TYPE_CLASS_CHECK (NODE)->lazy_copy_ctor) +/* Nonzero means that NODE (a class type) has an assignment operator + -- but that it has not yet been declared. */ +#define CLASSTYPE_LAZY_ASSIGNMENT_OP(NODE) \ + (LANG_TYPE_CLASS_CHECK (NODE)->lazy_assignment_op) + /* Nonzero means that this _CLASSTYPE node overloads operator=(X&). */ #define TYPE_HAS_ASSIGN_REF(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_assign_ref) diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 802d4c023fe..e3c65f8ab85 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1068,6 +1068,8 @@ lazily_declare_fn (special_function_kind sfk, tree type) /* Create appropriate clones. */ clone_function_decl (fn, /*update_method_vec=*/true); } + else if (sfk == sfk_assignment_operator) + CLASSTYPE_LAZY_ASSIGNMENT_OP (type) = 0; return fn; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 51256e5403a..b5a322c39e1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-07-18 Mark Mitchell <mark@codesourcery.com> + + PR c++/16623 + * g++.dg/template/assign1.C: New test. + 2004-07-19 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> PR c++/12170 diff --git a/gcc/testsuite/g++.dg/template/assign1.C b/gcc/testsuite/g++.dg/template/assign1.C new file mode 100644 index 00000000000..d0e134a477b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/assign1.C @@ -0,0 +1,15 @@ +// PR c++/16623 + +template <int N> +struct C +{ + C& operator= (int); +}; + +template <int N> +C<N>& C<N>::operator= (int) +{ + return *this; +} + +C<0> a; |