OSDN Git Service

PR c++/57551
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Jul 2013 17:50:24 +0000 (17:50 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Jul 2013 17:50:24 +0000 (17:50 +0000)
* semantics.c (cxx_eval_indirect_ref): Don't try to look through
a POINTER_PLUS_EXPR for type punning diagnostic.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@200830 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/expr/const1.C [new file with mode: 0644]

index bfb3da8..f11ad34 100644 (file)
@@ -1,5 +1,9 @@
 2013-07-09  Jason Merrill  <jason@redhat.com>
 
+       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.
 
index e0c1c1f..1d95e3e 100644 (file)
@@ -7459,11 +7459,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 (file)
index 0000000..8c1271d
--- /dev/null
@@ -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;
+}