From c6250f73ff88d48a49b377cfd0f4c4fe1779ea2d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 10 Oct 2014 16:27:07 -0400 Subject: [PATCH] method.c (implicitly_declare_fn): Handle deleted lambda default ctor and copy assop here. * method.c (implicitly_declare_fn): Handle deleted lambda default ctor and copy assop here. * class.c (check_bases_and_members): Not here. (add_implicitly_declared_members): And don't set CLASSTYPE_LAZY_MOVE_ASSIGN. From-SVN: r216105 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/class.c | 9 +-------- gcc/cp/method.c | 6 ++++++ .../g++.dg/ext/is_trivially_constructible4.C | 12 ++++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/is_trivially_constructible4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1414f2be2f9..3e2ab6ece42 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2014-10-10 Jason Merrill + * method.c (implicitly_declare_fn): Handle deleted lambda default + ctor and copy assop here. + * class.c (check_bases_and_members): Not here. + (add_implicitly_declared_members): And don't set + CLASSTYPE_LAZY_MOVE_ASSIGN. + * semantics.c (finish_id_expression): Check for error_mark_node. 2014-10-09 Jason Merrill diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 12ac30a84a8..b6611870a23 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3158,7 +3158,7 @@ add_implicitly_declared_members (tree t, tree* access_decls, TYPE_HAS_COPY_ASSIGN (t) = 1; TYPE_HAS_CONST_COPY_ASSIGN (t) = !cant_have_const_assignment; CLASSTYPE_LAZY_COPY_ASSIGN (t) = 1; - if (move_ok) + if (move_ok && !LAMBDA_TYPE_P (t)) CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1; } @@ -5624,13 +5624,6 @@ check_bases_and_members (tree t) if (LAMBDA_TYPE_P (t)) { - /* "The closure type associated with a lambda-expression has a deleted - default constructor and a deleted copy assignment operator." */ - TYPE_NEEDS_CONSTRUCTING (t) = 1; - TYPE_HAS_COMPLEX_DFLT (t) = 1; - TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1; - CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 0; - /* "This class type is not an aggregate." */ CLASSTYPE_NON_AGGREGATE (t) = 1; } diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 882898658dd..dce2d2b2caf 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1911,6 +1911,12 @@ implicitly_declare_fn (special_function_kind kind, tree type, DECL_DEFAULTED_FN (fn) = 1; if (cxx_dialect >= cxx11) { + /* "The closure type associated with a lambda-expression has a deleted + default constructor and a deleted copy assignment operator." */ + if ((kind == sfk_constructor + || kind == sfk_copy_assignment) + && LAMBDA_TYPE_P (type)) + deleted_p = true; DECL_DELETED_FN (fn) = deleted_p; DECL_DECLARED_CONSTEXPR_P (fn) = constexpr_p; } diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible4.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible4.C new file mode 100644 index 00000000000..c6d17586e85 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible4.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +void f() +{ + int x; + auto l = [=]{ return x; }; + typedef decltype(l) C; + SA(__is_trivially_copyable(C)); + SA(__is_trivially_constructible(C,C)); +} -- 2.30.2