From: jason Date: Thu, 13 Sep 2012 15:15:06 +0000 (+0000) Subject: PR c++/53839 X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=f9454eafeaa9853181a2eb2d38937197636658c1 PR c++/53839 * semantics.c (cxx_eval_indirect_ref): If we aren't looking for an address, make sure the value is constant. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191266 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9243bf2a55a..96cdf5734ec 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2012-09-13 Jason Merrill + PR c++/53839 + * semantics.c (cxx_eval_indirect_ref): If we aren't looking for an + address, make sure the value is constant. + +2012-09-13 Jason Merrill + PR c++/54511 * pt.c (tsubst_decl) [VAR_DECL]: Handle DECL_ANON_UNION_VAR_P. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1dd1e32946b..a64c5b7f4ad 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7454,7 +7454,11 @@ cxx_eval_indirect_ref (const constexpr_call *call, tree t, } if (r == NULL_TREE) - return t; + { + if (!addr) + VERIFY_CONSTANT (t); + return t; + } return r; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e9ab7ebaba5..ba9347d7a37 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2012-09-13 Jason Merrill + PR c++/53839 + * g++.dg/cpp0x/constexpr-temp1.C: New. + +2012-09-13 Jason Merrill + PR c++/54511 * g++.dg/template/anonunion2.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-temp1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-temp1.C new file mode 100644 index 00000000000..d0654363270 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-temp1.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++11 } } + +struct A { int i; }; +constexpr A f2 (const A& a) { return a; } +constexpr int f1 (const A &a) { return f2(a).i; } +A g(const A &a) +{ + return { f1(a) }; +}