2016-04-14 Jason Merrill <jason@redhat.com>
+ PR c++/70528
+ * class.c (type_has_constexpr_default_constructor): Return true
+ for an implicitly declared constructor.
+
PR c++/70622
* parser.c (cp_parser_init_declarator): Add auto_result parm.
(cp_parser_simple_declaration): Pass it.
CLASSTYPE_LAZY_DEFAULT_CTOR (t) = 1;
if (cxx_dialect >= cxx11)
TYPE_HAS_CONSTEXPR_CTOR (t)
- /* This might force the declaration. */
= type_has_constexpr_default_constructor (t);
}
{
if (!TYPE_HAS_COMPLEX_DFLT (t))
return trivial_default_constructor_is_constexpr (t);
- /* Non-trivial, we need to check subobject constructors. */
- lazily_declare_fn (sfk_constructor, t);
+ /* Assume it's constexpr to avoid unnecessary instantiation; if the
+ definition would have made the class non-literal, it will still be
+ non-literal because of the base or member in question, and that
+ gives a better diagnostic. */
+ return true;
}
fns = locate_ctor (t);
return (fns && DECL_DECLARED_CONSTEXPR_P (fns));
struct B: A { };
constexpr int f(B b) { return b.i; }
-struct C { C(); }; // { dg-message "calls non-constexpr" }
-struct D: C { }; // { dg-message "no constexpr constructor" }
+struct C { C(); }; // { dg-message "" }
+struct D: C { }; // { dg-message "" }
constexpr int g(D d) { return 42; } // { dg-error "invalid type" }