Commit d8cff23f by Marek Polacek Committed by Marek Polacek

re PR c++/84596 (internal compiler error: unexpected expression '(bool)c' of…

re PR c++/84596 (internal compiler error: unexpected expression '(bool)c' of kind implicit_conv_expr (cxx_eval_constant_expression))

	PR c++/84596
	* constexpr.c (require_rvalue_constant_expression): New function.
	* cp-tree.h: Declare it.
	* semantics.c (finish_static_assert): Use it instead of
	require_potential_rvalue_constant_expression.

	* g++.dg/cpp0x/static_assert14.C: New test.

From-SVN: r258107
parent 26a0cc94
2018-03-01 Marek Polacek <polacek@redhat.com>
PR c++/84596
* constexpr.c (require_rvalue_constant_expression): New function.
* cp-tree.h: Declare it.
* semantics.c (finish_static_assert): Use it instead of
require_potential_rvalue_constant_expression.
2018-03-01 Jason Merrill <jason@redhat.com>
Alexandre Oliva <aoliva@redhat.com>
......
......@@ -6047,7 +6047,8 @@ potential_rvalue_constant_expression (tree t)
bool
require_potential_constant_expression (tree t)
{
return potential_constant_expression_1 (t, false, true, false, tf_warning_or_error);
return potential_constant_expression_1 (t, false, true, false,
tf_warning_or_error);
}
/* Cross product of the above. */
......@@ -6055,7 +6056,17 @@ require_potential_constant_expression (tree t)
bool
require_potential_rvalue_constant_expression (tree t)
{
return potential_constant_expression_1 (t, true, true, false, tf_warning_or_error);
return potential_constant_expression_1 (t, true, true, false,
tf_warning_or_error);
}
/* Like above, but don't consider PARM_DECL a potential_constant_expression. */
bool
require_rvalue_constant_expression (tree t)
{
return potential_constant_expression_1 (t, true, true, true,
tf_warning_or_error);
}
/* Like potential_constant_expression, but don't consider possible constexpr
......
......@@ -7409,6 +7409,7 @@ extern bool is_static_init_expression (tree);
extern bool potential_rvalue_constant_expression (tree);
extern bool require_potential_constant_expression (tree);
extern bool require_constant_expression (tree);
extern bool require_rvalue_constant_expression (tree);
extern bool require_potential_rvalue_constant_expression (tree);
extern tree cxx_constant_value (tree, tree = NULL_TREE);
extern tree cxx_constant_init (tree, tree = NULL_TREE);
......
......@@ -8671,7 +8671,7 @@ finish_static_assert (tree condition, tree message, location_t location,
else if (condition && condition != error_mark_node)
{
error ("non-constant condition for static assertion");
if (require_potential_rvalue_constant_expression (condition))
if (require_rvalue_constant_expression (condition))
cxx_constant_value (condition);
}
input_location = saved_loc;
......
2018-03-01 Marek Polacek <polacek@redhat.com>
PR c++/84596
* g++.dg/cpp0x/static_assert14.C: New test.
2018-03-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/79410
......
// PR c++/84596
// { dg-do compile { target c++11 } }
template<int x>
void b(int c) {
static_assert (c, "c"); // { dg-error "non-constant|not a constant" }
}
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