Commit ac9ec198 by Marek Polacek Committed by Marek Polacek

re PR c++/84927 (ICE with NSDMI and reference)

	PR c++/84927
	* constexpr.c (cxx_eval_bare_aggregate): Update constructor's flags
	as we evaluate the elements.
	(cxx_eval_constant_expression): Verify constructor's flags
	unconditionally.

	* g++.dg/cpp1y/nsdmi-aggr9.C: New test.

From-SVN: r258661
parent e5cc0d54
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
PR c++/84925 PR c++/84925
* pt.c (enclosing_instantiation_of): Check if fn is null. * pt.c (enclosing_instantiation_of): Check if fn is null.
PR c++/84927
* constexpr.c (cxx_eval_bare_aggregate): Update constructor's flags
as we evaluate the elements.
(cxx_eval_constant_expression): Verify constructor's flags
unconditionally.
2018-03-16 Jason Merrill <jason@redhat.com> 2018-03-16 Jason Merrill <jason@redhat.com>
PR c++/71834 - template-id with too few arguments. PR c++/71834 - template-id with too few arguments.
......
...@@ -2880,7 +2880,12 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t, ...@@ -2880,7 +2880,12 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
(*p)->last().value = elt; (*p)->last().value = elt;
} }
else else
CONSTRUCTOR_APPEND_ELT (*p, index, elt); {
CONSTRUCTOR_APPEND_ELT (*p, index, elt);
/* Adding an element might change the ctor's flags. */
TREE_CONSTANT (ctx->ctor) = constant_p;
TREE_SIDE_EFFECTS (ctx->ctor) = side_effects_p;
}
} }
if (*non_constant_p || !changed) if (*non_constant_p || !changed)
return t; return t;
...@@ -4530,11 +4535,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -4530,11 +4535,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
{ {
/* Don't re-process a constant CONSTRUCTOR, but do fold it to /* Don't re-process a constant CONSTRUCTOR, but do fold it to
VECTOR_CST if applicable. */ VECTOR_CST if applicable. */
/* FIXME after GCC 6 branches, make the verify unconditional. */ verify_constructor_flags (t);
if (CHECKING_P)
verify_constructor_flags (t);
else
recompute_constructor_flags (t);
if (TREE_CONSTANT (t)) if (TREE_CONSTANT (t))
return fold (t); return fold (t);
} }
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
PR c++/84925 PR c++/84925
* g++.dg/cpp1z/lambda-__func__.C: New test. * g++.dg/cpp1z/lambda-__func__.C: New test.
PR c++/84927
* g++.dg/cpp1y/nsdmi-aggr9.C: New test.
2018-03-19 Maxim Ostapenko <m.ostapenko@samsung.com> 2018-03-19 Maxim Ostapenko <m.ostapenko@samsung.com>
PR sanitizer/78651 PR sanitizer/78651
......
// PR c++/84927 - ICE with NSDMI and reference
// { dg-do compile { target c++14 } }
struct A
{
int& r;
int i = r;
};
void foo()
{
int j;
A a = A{j};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment