Commit fe736ffd by Jason Merrill Committed by Jason Merrill

PR c++/85113 - ICE with constexpr and __builtin_constant_p.

	* constexpr.c (cxx_eval_builtin_function_call): Only defer
	__builtin_constant_p if ctx->quiet.

From-SVN: r259051
parent 8ab30b97
2018-04-03 Jason Merrill <jason@redhat.com>
PR c++/85113 - ICE with constexpr and __builtin_constant_p.
* constexpr.c (cxx_eval_builtin_function_call): Only defer
__builtin_constant_p if ctx->quiet.
2018-04-03 Paolo Carlini <paolo.carlini@oracle.com> 2018-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84768 PR c++/84768
......
...@@ -1171,7 +1171,10 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun, ...@@ -1171,7 +1171,10 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
/* Don't fold __builtin_constant_p within a constexpr function. */ /* Don't fold __builtin_constant_p within a constexpr function. */
bool bi_const_p = (DECL_FUNCTION_CODE (fun) == BUILT_IN_CONSTANT_P); bool bi_const_p = (DECL_FUNCTION_CODE (fun) == BUILT_IN_CONSTANT_P);
/* If we aren't requiring a constant expression, defer __builtin_constant_p
in a constexpr function until we have values for the parameters. */
if (bi_const_p if (bi_const_p
&& ctx->quiet
&& current_function_decl && current_function_decl
&& DECL_DECLARED_CONSTEXPR_P (current_function_decl)) && DECL_DECLARED_CONSTEXPR_P (current_function_decl))
{ {
......
// PR c++/85113
// { dg-do compile { target c++14 } }
template<bool> struct A {};
constexpr int foo()
{
A<__builtin_constant_p(0)> a{};
return 0;
}
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