diff options
author | Jason Merrill <jason@redhat.com> | 2018-04-03 15:13:36 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-04-03 15:13:36 -0400 |
commit | fe736ffd2f423c825da8751111da55a2ad25d059 (patch) | |
tree | c9eb7ff5e65b84e61eb5d14b187fb3688cd78191 /gcc | |
parent | 8ab30b9778a46cbf0a0853c78cd799b9afca61c5 (diff) | |
download | gcc-fe736ffd2f423c825da8751111da55a2ad25d059.zip gcc-fe736ffd2f423c825da8751111da55a2ad25d059.tar.gz gcc-fe736ffd2f423c825da8751111da55a2ad25d059.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/builtin12.C | 10 |
3 files changed, 19 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 505b225..648a71d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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> PR c++/84768 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index bebd9f5..201f27d 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 0000000..1d6bb75c --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin12.C @@ -0,0 +1,10 @@ +// PR c++/85113 +// { dg-do compile { target c++14 } } + +template<bool> struct A {}; + +constexpr int foo() +{ + A<__builtin_constant_p(0)> a{}; + return 0; +} |