mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/51526 ([C++11][constexpr] constexpr delegating constructor should be accepted)
PR c++/51526 * semantics.c (build_data_member_initialization): Handle delegating constructor. (build_constexpr_constructor_member_initializers): Likewise. From-SVN: r182499
This commit is contained in:
parent
8f1ad6b6bf
commit
176fcc5d18
|
@ -1,5 +1,10 @@
|
|||
2011-12-19 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/51526
|
||||
* semantics.c (build_data_member_initialization): Handle
|
||||
delegating constructor.
|
||||
(build_constexpr_constructor_member_initializers): Likewise.
|
||||
|
||||
PR c++/51553
|
||||
* cp-tree.h (LOOKUP_LIST_INIT_CTOR): Rename from
|
||||
LOOKUP_NO_COPY_CTOR_CONVERSION.
|
||||
|
|
|
@ -5801,6 +5801,12 @@ build_data_member_initialization (tree t, VEC(constructor_elt,gc) **vec)
|
|||
the const_cast. */
|
||||
member = op;
|
||||
}
|
||||
else if (op == current_class_ptr
|
||||
&& (same_type_ignoring_top_level_qualifiers_p
|
||||
(TREE_TYPE (TREE_TYPE (member)),
|
||||
current_class_type)))
|
||||
/* Delegating constructor. */
|
||||
member = op;
|
||||
else
|
||||
{
|
||||
/* We don't put out anything for an empty base. */
|
||||
|
@ -5907,7 +5913,20 @@ build_constexpr_constructor_member_initializers (tree type, tree body)
|
|||
else
|
||||
gcc_assert (errorcount > 0);
|
||||
if (ok)
|
||||
return build_constructor (type, vec);
|
||||
{
|
||||
if (VEC_length (constructor_elt, vec) > 0)
|
||||
{
|
||||
/* In a delegating constructor, return the target. */
|
||||
constructor_elt *ce = VEC_index (constructor_elt, vec, 0);
|
||||
if (ce->index == current_class_ptr)
|
||||
{
|
||||
body = ce->value;
|
||||
VEC_free (constructor_elt, gc, vec);
|
||||
return body;
|
||||
}
|
||||
}
|
||||
return build_constructor (type, vec);
|
||||
}
|
||||
else
|
||||
return error_mark_node;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2011-12-19 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/51526
|
||||
* g++.dg/cpp0x/constexpr-delegating.C: New.
|
||||
|
||||
2011-12-19 Sandra Loosemore <sandra@codesourcery.com>
|
||||
Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// PR c++/51526
|
||||
// { dg-options -std=c++0x }
|
||||
|
||||
const int j = 42;
|
||||
|
||||
struct S {
|
||||
int i;
|
||||
constexpr S(int i) : i(i) {}
|
||||
constexpr S() : S(j) {}
|
||||
};
|
||||
|
||||
constexpr S s{};
|
||||
|
||||
#define SA(X) static_assert((X),#X)
|
||||
SA(s.i == 42);
|
Loading…
Reference in New Issue