From 7eb48705c0b12d73651de15cd9a9a415c7229039 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 9 Jul 2013 13:55:43 -0400 Subject: [PATCH] re PR regression/57551 (g++.dg/ext/visibility/anon6.C scan-assembler 1BIiE1cE) PR c++/57551 * semantics.c (cxx_eval_indirect_ref): Don't try to look through a POINTER_PLUS_EXPR for type punning diagnostic. From-SVN: r200840 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/semantics.c | 5 ----- gcc/testsuite/g++.dg/expr/const1.C | 9 +++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/expr/const1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index aa6bdb1f339..87892aaf127 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-07-09 Jason Merrill + PR c++/57551 + * semantics.c (cxx_eval_indirect_ref): Don't try to look through + a POINTER_PLUS_EXPR for type punning diagnostic. + PR c++/57831 * pt.c (tsubst_copy): Handle USING_DECL. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c9a292e8249..e06ac61bb80 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7715,11 +7715,6 @@ cxx_eval_indirect_ref (const constexpr_call *call, tree t, { tree sub = op0; STRIP_NOPS (sub); - if (TREE_CODE (sub) == POINTER_PLUS_EXPR) - { - sub = TREE_OPERAND (sub, 0); - STRIP_NOPS (sub); - } if (TREE_CODE (sub) == ADDR_EXPR) { /* We couldn't fold to a constant value. Make sure it's not diff --git a/gcc/testsuite/g++.dg/expr/const1.C b/gcc/testsuite/g++.dg/expr/const1.C new file mode 100644 index 00000000000..9371b27b28f --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/const1.C @@ -0,0 +1,9 @@ +// PR c++/57551 + +extern unsigned long ADDR; + +unsigned long f(){ + const unsigned long* const var=&ADDR; + const unsigned long retval=var[1]; + return retval; +} -- 2.30.2