diff options
author | Jason Merrill <jason@redhat.com> | 2017-03-19 22:22:36 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-03-19 22:22:36 -0400 |
commit | c88169089283a22360c6a9eacbc9a3345c82598a (patch) | |
tree | d86f483036ee2e3262f53f1c23a346a2fe79077e /gcc | |
parent | a4c9d8017d5414aab08055bdb41b0c8c810e74a0 (diff) | |
download | gcc-c88169089283a22360c6a9eacbc9a3345c82598a.zip gcc-c88169089283a22360c6a9eacbc9a3345c82598a.tar.gz gcc-c88169089283a22360c6a9eacbc9a3345c82598a.tar.bz2 |
PR c++/80077 - error with constexpr and -fno-elide-constructors.
* constexpr.c (cxx_eval_call_expression): Set ctx->call while
expanding trivial constructor.
From-SVN: r246272
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-trivial3.C | 6 |
3 files changed, 15 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7d2a56a..a7248d9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-03-19 Jason Merrill <jason@redhat.com> + + PR c++/80077 - error with constexpr and -fno-elide-constructors. + * constexpr.c (cxx_eval_call_expression): Set ctx->call while + expanding trivial constructor. + 2017-03-17 Jason Merrill <jason@redhat.com> PR c++/78345 - ICE initializing array from lambda. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 4136b34..3ca3560 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1478,7 +1478,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, else op = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (op)), op); tree set = build2 (MODIFY_EXPR, TREE_TYPE (op), op, init); - return cxx_eval_constant_expression (ctx, set, lval, + new_ctx.call = &new_call; + return cxx_eval_constant_expression (&new_ctx, set, lval, non_constant_p, overflow_p); } } @@ -1496,7 +1497,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, } /* If in direct recursive call, optimize definition search. */ - if (ctx && ctx->call && ctx->call->fundef->decl == fun) + if (ctx && ctx->call && ctx->call->fundef && ctx->call->fundef->decl == fun) new_call.fundef = ctx->call->fundef; else { diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-trivial3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-trivial3.C new file mode 100644 index 0000000..6833cd3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-trivial3.C @@ -0,0 +1,6 @@ +// PR c++/80077 +// { dg-do compile { target c++11 } } +// { dg-options -fno-elide-constructors } + +struct X_t { X_t() = default; }; +constexpr X_t x = X_t(); |