re PR c++/50234 (internal compiler error: in cxx_eval_component_reference, at cp/semantics.c:6527)

PR c++/50234
	* semantics.c (cxx_eval_component_reference): Handle
	value-initialization for omitted initializers.

From-SVN: r178325
This commit is contained in:
Jason Merrill 2011-08-30 11:28:30 -04:00 committed by Jason Merrill
parent 5de3524042
commit d05da2b9d5
4 changed files with 29 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2011-08-30 Jason Merrill <jason@redhat.com>
PR c++/50234
* semantics.c (cxx_eval_component_reference): Handle
value-initialization for omitted initializers.
2011-08-29 Jason Merrill <jason@redhat.com>
PR c++/50224

View File

@ -6518,7 +6518,8 @@ cxx_eval_component_reference (const constexpr_call *call, tree t,
if (field == part)
return value;
}
if (TREE_CODE (TREE_TYPE (whole)) == UNION_TYPE)
if (TREE_CODE (TREE_TYPE (whole)) == UNION_TYPE
&& CONSTRUCTOR_NELTS (whole) > 0)
{
/* DR 1188 says we don't have to deal with this. */
if (!allow_non_constant)
@ -6527,8 +6528,12 @@ cxx_eval_component_reference (const constexpr_call *call, tree t,
*non_constant_p = true;
return t;
}
gcc_unreachable();
return error_mark_node;
/* If there's no explicit init for this field, it's value-initialized. */
value = build_value_init (TREE_TYPE (t), tf_warning_or_error);
return cxx_eval_constant_expression (call, value,
allow_non_constant, addr,
non_constant_p);
}
/* Subroutine of cxx_eval_constant_expression.

View File

@ -1,3 +1,8 @@
2011-08-30 Jason Merrill <jason@redhat.com>
PR c++/50234
* g++.dg/cpp0x/constexpr-value3.C: New.
2011-08-30 Richard Guenther <rguenther@suse.de>
PR middle-end/48571

View File

@ -0,0 +1,10 @@
// PR c++/50234
// { dg-options -std=c++0x }
#define SA(X) static_assert((X),#X)
struct A { int i; };
constexpr int f(A a) { return a.i; }
SA(f({}) == 0);