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
This commit is contained in:
parent
54069e5959
commit
65d7adba7b
3 changed files with 14 additions and 3 deletions
|
@ -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.
|
||||
|
|
|
@ -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 "
|
||||
|
|
|
@ -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() {}
|
||||
|
|
Loading…
Add table
Reference in a new issue