diff options
author | Jason Merrill <jason@redhat.com> | 2017-05-09 16:37:51 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-05-09 16:37:51 -0400 |
commit | 65d7adba7ba2736bb7f11f4728c084f85f76cf86 (patch) | |
tree | 65ce1dc5ee3b54609a9f598cc0a362de33b0e8ac /gcc | |
parent | 54069e595976eb556b22c231951cb2703e523a22 (diff) | |
download | gcc-65d7adba7ba2736bb7f11f4728c084f85f76cf86.zip gcc-65d7adba7ba2736bb7f11f4728c084f85f76cf86.tar.gz gcc-65d7adba7ba2736bb7f11f4728c084f85f76cf86.tar.bz2 |
PR c++/70979 - literal class and closure types
* class.c (finalize_literal_type_property): Handle closures
specifically.
(explain_non_literal_class): Likewise.
From-SVN: r247814
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/class.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C | 4 |
3 files changed, 14 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 521b7d9..3a12217 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2017-05-09 Jason Merrill <jason@redhat.com> + PR c++/70979 - literal class and closure types + * class.c (finalize_literal_type_property): Handle closures + specifically. + (explain_non_literal_class): Likewise. + PR c++/66297, DR 1684 - literal class and constexpr member fns * constexpr.c (is_valid_constexpr_fn): Only complain about non-literal enclosing class in C++11. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 89fa822..fc71766 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5752,6 +5752,8 @@ finalize_literal_type_property (tree t) if (cxx_dialect < cxx11 || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) CLASSTYPE_LITERAL_P (t) = false; + else if (CLASSTYPE_LITERAL_P (t) && LAMBDA_TYPE_P (t)) + CLASSTYPE_LITERAL_P (t) = (cxx_dialect >= cxx1z); else if (CLASSTYPE_LITERAL_P (t) && !TYPE_HAS_TRIVIAL_DFLT (t) && CLASSTYPE_NON_AGGREGATE (t) && !TYPE_HAS_CONSTEXPR_CTOR (t)) @@ -5794,10 +5796,14 @@ explain_non_literal_class (tree t) return; inform (0, "%q+T is not literal because:", t); - if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) + if (cxx_dialect < cxx1z && LAMBDA_TYPE_P (t)) + inform (0, " %qT is a closure type, which is only literal in " + "C++1z and later", t); + else if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) inform (0, " %q+T has a non-trivial destructor", t); else if (CLASSTYPE_NON_AGGREGATE (t) && !TYPE_HAS_TRIVIAL_DFLT (t) + && !LAMBDA_TYPE_P (t) && !TYPE_HAS_CONSTEXPR_CTOR (t)) { inform (0, " %q+T is not an aggregate, does not have a trivial " diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C index 7e05481..358d4aa 100644 --- a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C @@ -1,9 +1,9 @@ // PR c++/79461 -// { dg-options -std=c++1z } +// { dg-do compile { target c++14 } } struct S { constexpr S(int i) { - auto f = [i]{}; + auto f = [i]{}; // { dg-error "literal" "" { target c++14_only } } } }; int main() {} |