Commit 9299bde0 by Paolo Carlini Committed by Paolo Carlini

re PR c++/60254 ([c++11] ICE with non-const expression in static_assert)

/cp
2014-03-13  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60254
	* semantics.c (finish_static_assert): Call cxx_constant_value only
	if require_potential_rvalue_constant_expression returns true.

/testsuite
2014-03-13  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60254
	* g++.dg/cpp0x/static_assert10.C: New.
	* g++.dg/cpp0x/static_assert11.C: Likewise.
	* g++.dg/cpp0x/static_assert3.C: Adjust.

From-SVN: r208538
parent eba14fca
2014-03-13 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60254
* semantics.c (finish_static_assert): Call cxx_constant_value only
if require_potential_rvalue_constant_expression returns true.
2014-03-11 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60389
......
......@@ -6860,7 +6860,8 @@ finish_static_assert (tree condition, tree message, location_t location,
else if (condition && condition != error_mark_node)
{
error ("non-constant condition for static assertion");
cxx_constant_value (condition);
if (require_potential_rvalue_constant_expression (condition))
cxx_constant_value (condition);
}
input_location = saved_loc;
}
......
2014-03-13 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60254
* g++.dg/cpp0x/static_assert10.C: New.
* g++.dg/cpp0x/static_assert11.C: Likewise.
* g++.dg/cpp0x/static_assert3.C: Adjust.
2014-03-13 Richard Biener <rguenther@suse.de>
* lib/lto.exp (lto-execute): Fix error catching for dg-final.
......
// PR c++/60254
// { dg-do compile { target c++11 } }
template<typename T> bool foo(T)
{
int i;
static_assert(foo(i), "Error"); // { dg-error "non-constant condition|not usable" }
}
// PR c++/60254
// { dg-do compile { target c++11 } }
struct A
{
template<typename T> bool foo(T)
{
static_assert(foo(0), "Error"); // { dg-error "non-constant condition|constant expression" }
}
};
// { dg-do compile { target c++11 } }
static_assert(7 / 0, "X"); // { dg-error "non-constant condition" "non-constant" }
// { dg-warning "division by zero" "zero" { target *-*-* } 2 }
// { dg-error "7 / 0.. is not a constant expression" "not a constant" { target *-*-* } 2 }
// { dg-error "division by zero is not a constant-expression" "not a constant" { target *-*-* } 2 }
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