diff options
author | Jason Merrill <jason@redhat.com> | 2011-05-23 23:49:03 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-05-23 23:49:03 -0400 |
commit | 874aeeede55641e963f98fa663653aafa2a16d87 (patch) | |
tree | ab58bc86946cf6084204861e09cb6a81cd300862 /gcc | |
parent | a345e45d144c0e83aed85b6d29f64af3d21b4453 (diff) | |
download | gcc-874aeeede55641e963f98fa663653aafa2a16d87.zip gcc-874aeeede55641e963f98fa663653aafa2a16d87.tar.gz gcc-874aeeede55641e963f98fa663653aafa2a16d87.tar.bz2 |
re PR c++/49102 ([C++0x] Use of deleted copy constructor not diagnosed)
PR c++/49102
* call.c (convert_arg_to_ellipsis): Call force_rvalue.
From-SVN: r174101
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/call.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/defaulted28.C | 15 |
4 files changed, 29 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 032c8e2..c00e064 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-05-23 Jason Merrill <jason@redhat.com> + PR c++/49102 + * call.c (convert_arg_to_ellipsis): Call force_rvalue. + PR c++/49105 * typeck.c (cp_build_c_cast): Don't strip cv-quals when converting to reference. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 8503f5e..ff3dc06 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5905,10 +5905,13 @@ convert_arg_to_ellipsis (tree arg) /* In a template (or ill-formed code), we can have an incomplete type even after require_complete_type, in which case we don't know whether it has trivial copy or not. */ - && COMPLETE_TYPE_P (arg_type) - && (type_has_nontrivial_copy_init (arg_type) - || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (arg_type))) + && COMPLETE_TYPE_P (arg_type)) { + /* Build up a real lvalue-to-rvalue conversion in case the + copy constructor is trivial but not callable. */ + if (CLASS_TYPE_P (arg_type)) + force_rvalue (arg, tf_warning_or_error); + /* [expr.call] 5.2.2/7: Passing a potentially-evaluated argument of class type (Clause 9) with a non-trivial copy constructor or a non-trivial destructor @@ -5920,7 +5923,9 @@ convert_arg_to_ellipsis (tree arg) If the call appears in the context of a sizeof expression, it is not potentially-evaluated. */ - if (cp_unevaluated_operand == 0) + if (cp_unevaluated_operand == 0 + && (type_has_nontrivial_copy_init (arg_type) + || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (arg_type))) error ("cannot pass objects of non-trivially-copyable " "type %q#T through %<...%>", arg_type); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f58dea3..4b447ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-05-23 Jason Merrill <jason@redhat.com> + * g++.dg/cpp0x/defaulted28.C: New. + * g++.dg/cpp0x/sfinae25.C: New. * g++.dg/cpp0x/rv-cast2.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted28.C b/gcc/testsuite/g++.dg/cpp0x/defaulted28.C new file mode 100644 index 0000000..15caef6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted28.C @@ -0,0 +1,15 @@ +// PR c++/49102 +// { dg-options -std=c++0x } + +struct A { + A() = default; + +private: + A(A const&) = default; // { dg-error "private" } +}; + +void f(...) { } +int main() { + A a; + f(a); // { dg-error "this context" } +} |