diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-02-21 18:48:57 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-02-21 18:48:57 +0100 |
commit | 664beaf2c19148677cc26c0fd6beaf2e56d2b6f3 (patch) | |
tree | 6743da82496b663c0f92397eeada8e809092e6e7 | |
parent | 956d3e61a029d40846994b99b7b2b12986ccb047 (diff) | |
download | gcc-664beaf2c19148677cc26c0fd6beaf2e56d2b6f3.zip gcc-664beaf2c19148677cc26c0fd6beaf2e56d2b6f3.tar.gz gcc-664beaf2c19148677cc26c0fd6beaf2e56d2b6f3.tar.bz2 |
re PR c++/79639 (ICE with -O and constexpr)
PR c++/79639
* constexpr.c (cxx_eval_store_expression): If *valp is a PTRMEM_CST,
call cplus_expand_constant on it first.
* g++.dg/cpp1y/constexpr-79639.C: New test.
From-SVN: r245635
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/constexpr-79639.C | 27 |
4 files changed, 41 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 385c509..26ead8a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-02-21 Jakub Jelinek <jakub@redhat.com> + + PR c++/79639 + * constexpr.c (cxx_eval_store_expression): If *valp is a PTRMEM_CST, + call cplus_expand_constant on it first. + 2017-02-19 Jason Merrill <jason@redhat.com> PR c++/78139 - destructor needed by new-expression diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index fc7d46c..14af617 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3517,11 +3517,12 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, wants to modify it. */ if (*valp == NULL_TREE) { - *valp = new_ctx.ctor = build_constructor (type, NULL); - CONSTRUCTOR_NO_IMPLICIT_ZERO (new_ctx.ctor) = no_zero_init; + *valp = build_constructor (type, NULL); + CONSTRUCTOR_NO_IMPLICIT_ZERO (*valp) = no_zero_init; } - else - new_ctx.ctor = *valp; + else if (TREE_CODE (*valp) == PTRMEM_CST) + *valp = cplus_expand_constant (*valp); + new_ctx.ctor = *valp; new_ctx.object = target; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 02e4dec..342f23f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-02-21 Jakub Jelinek <jakub@redhat.com> + PR c++/79639 + * g++.dg/cpp1y/constexpr-79639.C: New test. + PR target/79633 * gcc.target/i386/mpx/pr79633.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-79639.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-79639.C new file mode 100644 index 0000000..03e6b84 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-79639.C @@ -0,0 +1,27 @@ +// PR c++/79639 +// { dg-do compile { target c++14 } } + +struct A +{ + void foo () {} + void bar () {} +}; +typedef void (A::*T) (); + +constexpr T +foo (T f) +{ + f = 0; + return f; +} + +constexpr T +bar (T f) +{ + f = &A::bar; + return f; +} + +constexpr T a = foo (&A::foo); +constexpr T b = foo (&A::foo); +static_assert (a == nullptr, ""); |