Commit b09a67ea by Marc Glisse Committed by Marc Glisse

PR c++/85746: Don't fold __builtin_constant_p prematurely

2019-10-22  Marc Glisse  <marc.glisse@inria.fr>

gcc/cp/
	* constexpr.c (cxx_eval_builtin_function_call): Only set
	force_folding_builtin_constant_p if manifestly_const_eval.

gcc/testsuite/
	* g++.dg/pr85746.C: New file.

From-SVN: r277292
parent 761a3a95
2019-10-22 Marc Glisse <marc.glisse@inria.fr>
PR c++/85746
* constexpr.c (cxx_eval_builtin_function_call): Only set
force_folding_builtin_constant_p if manifestly_const_eval.
2019-10-22 Richard Sandiford <richard.sandiford@arm.com> 2019-10-22 Richard Sandiford <richard.sandiford@arm.com>
* cp-tree.h (STF_USER_VISIBLE): New constant. * cp-tree.h (STF_USER_VISIBLE): New constant.
......
...@@ -1260,7 +1260,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun, ...@@ -1260,7 +1260,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
} }
bool save_ffbcp = force_folding_builtin_constant_p; bool save_ffbcp = force_folding_builtin_constant_p;
force_folding_builtin_constant_p = true; force_folding_builtin_constant_p |= ctx->manifestly_const_eval;
tree save_cur_fn = current_function_decl; tree save_cur_fn = current_function_decl;
/* Return name of ctx->call->fundef->decl for __builtin_FUNCTION (). */ /* Return name of ctx->call->fundef->decl for __builtin_FUNCTION (). */
if (fndecl_built_in_p (fun, BUILT_IN_FUNCTION) if (fndecl_built_in_p (fun, BUILT_IN_FUNCTION)
......
2019-10-22 Marc Glisse <marc.glisse@inria.fr>
PR c++/85746
* g++.dg/pr85746.C: New file.
2019-10-22 Richard Biener <rguenther@suse.de> 2019-10-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/92173 PR tree-optimization/92173
......
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-gimple" } */
int f(int a,int b){
// The front-end should not fold this to 0.
int c = __builtin_constant_p(a < b);
return c;
}
/* { dg-final { scan-tree-dump "__builtin_constant_p" "gimple" } } */
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