OSDN Git Service

PR c++/52672
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Mar 2012 03:48:12 +0000 (03:48 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Mar 2012 03:48:12 +0000 (03:48 +0000)
* gcc/cp/semantics.c (cxx_fold_indirect_ref): Don't attempt to fold
stripped child trees that are not pointer types.

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

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-52672.C [new file with mode: 0644]

index b51935c..b8451f1 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-29  Meador Inge  <meadori@codesourcery.com>
+
+       PR c++/52672
+       * semantics.c (cxx_fold_indirect_ref): Don't attempt to fold
+       stripped child trees that are not pointer types.
+
 2012-03-29  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/52718
index 5646fa7..a562b1b 100644 (file)
@@ -7202,7 +7202,8 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base)
   sub = op0;
   STRIP_NOPS (sub);
   subtype = TREE_TYPE (sub);
-  gcc_assert (POINTER_TYPE_P (subtype));
+  if (!POINTER_TYPE_P (subtype))
+    return NULL_TREE;
 
   if (TREE_CODE (sub) == ADDR_EXPR)
     {
index 42bcde5..e9a3402 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-29  Meador Inge  <meadori@codesourcery.com>
+
+       PR c++/52672
+       * g++.dg/cpp0x/constexpr-52672.C: New testcase.
+
 2012-03-29  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/52718
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-52672.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-52672.C
new file mode 100644 (file)
index 0000000..9f87878
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/52672
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+typedef unsigned long * ul_ptr;
+constexpr unsigned long a = *((ul_ptr)0x0); // { dg-error "" }
+constexpr unsigned long b = *((ul_ptr)(*((ul_ptr)0x0))); // { dg-error "" }
+constexpr unsigned long c = *((ul_ptr)*((ul_ptr)(*((ul_ptr)0x0)))); // { dg-error "" }