diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/class.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/depr-copy3.C | 35 |
2 files changed, 37 insertions, 1 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 90b3438..2cf527e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5670,7 +5670,8 @@ classtype_has_depr_implicit_copy (tree t) iter; ++iter) { tree fn = *iter; - if (user_provided_p (fn) && copy_fn_p (fn)) + if (DECL_CONTEXT (fn) == t + && user_provided_p (fn) && copy_fn_p (fn)) return fn; } diff --git a/gcc/testsuite/g++.dg/cpp0x/depr-copy3.C b/gcc/testsuite/g++.dg/cpp0x/depr-copy3.C new file mode 100644 index 0000000..c303c9d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/depr-copy3.C @@ -0,0 +1,35 @@ +// PR c++/92145 +// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wdeprecated-copy" } + +struct base +{ + base() { } + base(const base&) { } + base(base&&) { } + base& operator=(const base&) { return *this; } + base& operator=(base&&) { return *this; } +}; + +struct foo : base +{ + //using base::base; + using base::operator=; +}; + +struct bar +{ + bar& operator=(foo v) + { + value = v; + return *this; + } + + foo value; +}; + +int main() +{ + foo a; + foo{a}; +} |