]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/61959 (ICE: in tree_to_uhwi, at tree.h:3657 when building Mozilla code)
authorJason Merrill <jason@redhat.com>
Thu, 7 Aug 2014 19:50:11 +0000 (15:50 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 7 Aug 2014 19:50:11 +0000 (15:50 -0400)
PR c++/61959
* semantics.c (cxx_eval_bare_aggregate): Handle POINTER_PLUS_EXPR.

From-SVN: r213735

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

index b0e1efd197322367d7a53b782b128a7655b74ebe..82e61f5f6b7e13a396cc6d9594c48d73e8eed895 100644 (file)
@@ -1,5 +1,8 @@
 2014-08-07  Jason Merrill  <jason@redhat.com>
 
+       PR c++/61959
+       * semantics.c (cxx_eval_bare_aggregate): Handle POINTER_PLUS_EXPR.
+
        PR c++/58714
        * tree.c (stabilize_expr): A stabilized prvalue is an xvalue.
 
index d5013c446f9fb3bb4749cd995ecca05218683264..9825dbe6aa4003b788726aee40a3a70a34d6f87c 100644 (file)
@@ -7296,7 +7296,9 @@ cxx_eval_bare_aggregate (const constexpr_call *call, tree t,
          constructor_elt *inner = base_field_constructor_elt (n, ce->index);
          inner->value = elt;
        }
-      else if (ce->index && TREE_CODE (ce->index) == NOP_EXPR)
+      else if (ce->index
+              && (TREE_CODE (ce->index) == NOP_EXPR
+                  || TREE_CODE (ce->index) == POINTER_PLUS_EXPR))
        {
          /* This is an initializer for an empty base; now that we've
             checked that it's constant, we can ignore it.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty7.C
new file mode 100644 (file)
index 0000000..f491994
--- /dev/null
@@ -0,0 +1,28 @@
+// PR c++/61959
+// { dg-do compile { target c++11 } }
+
+template <class Coord> struct BasePoint
+{
+  Coord x, y;
+  constexpr BasePoint (Coord, Coord) : x (0), y (0) {}
+};
+template <class T> struct BaseCoord
+{
+  int value;
+  constexpr BaseCoord (T) : value (1) {}
+};
+template <class units> struct IntCoordTyped : BaseCoord<int>, units
+{
+  typedef BaseCoord Super;
+  constexpr IntCoordTyped (int) : Super (0) {}
+};
+template <class units>
+struct IntPointTyped : BasePoint<IntCoordTyped<units> >, units
+{
+  typedef BasePoint<IntCoordTyped<units> > Super;
+  constexpr IntPointTyped (int, int) : Super (0, 0) {}
+};
+struct A
+{
+};
+IntPointTyped<A> a (0, 0);