From: Jason Merrill Date: Tue, 3 Apr 2018 19:13:36 +0000 (-0400) Subject: PR c++/85113 - ICE with constexpr and __builtin_constant_p. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe736ffd2f423c825da8751111da55a2ad25d059;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 505b2257be2..648a71d4897 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-03 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. + 2018-04-03 Paolo Carlini PR c++/84768 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index bebd9f5b5d0..201f27d8e66 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -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. */ 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 + && ctx->quiet && current_function_decl && DECL_DECLARED_CONSTEXPR_P (current_function_decl)) { diff --git a/gcc/testsuite/g++.dg/ext/builtin12.C b/gcc/testsuite/g++.dg/ext/builtin12.C new file mode 100644 index 00000000000..1d6bb75cd77 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin12.C @@ -0,0 +1,10 @@ +// PR c++/85113 +// { dg-do compile { target c++14 } } + +template struct A {}; + +constexpr int foo() +{ + A<__builtin_constant_p(0)> a{}; + return 0; +}