From 6fe83e54b813fd448f3b69676821a090b2918420 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 4 Dec 2014 20:37:24 +0000 Subject: [PATCH] PR c++/64080 * constexpr.c (cxx_eval_store_expression): Handle non-decl store targets. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218401 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/constexpr.c | 9 ++++++--- gcc/testsuite/g++.dg/cpp1y/constexpr-ref1.C | 9 +++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-ref1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0e2548fbdb8..2db8bd7c581 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-12-03 Jason Merrill + + PR c++/64080 + * constexpr.c (cxx_eval_store_expression): Handle non-decl store + targets. + 2014-12-03 Paolo Carlini PR c++/63558 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index d18025f457c..9426d8558e2 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -2583,19 +2583,22 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, default: object = probe; - gcc_assert (DECL_P (object)); } } /* And then find/build up our initializer for the path to the subobject we're initializing. */ - tree *valp = ctx->values->get (object); + tree *valp; + if (DECL_P (object)) + valp = ctx->values->get (object); + else + valp = NULL; if (!valp) { /* A constant-expression cannot modify objects from outside the constant-expression. */ if (!ctx->quiet) - error ("modification of %qD is not a constant-expression", object); + error ("modification of %qE is not a constant-expression", object); *non_constant_p = true; return t; } diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-ref1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-ref1.C new file mode 100644 index 00000000000..6f88f82c0b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-ref1.C @@ -0,0 +1,9 @@ +// PR c++/64080 +// { dg-do compile { target c++14 } } + +constexpr void foo (int&& i) { i = 0; } + +void bar(int&& i) +{ + bool b = noexcept(foo(static_cast(i))); +} -- 2.11.4.GIT