From 2e8e74c0ad0110732111082eb48deed18b66221d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 7 Aug 2014 15:48:30 -0400 Subject: [PATCH] re PR c++/61959 (ICE: in tree_to_uhwi, at tree.h:3657 when building Mozilla code) PR c++/61959 * semantics.c (cxx_eval_bare_aggregate): Handle POINTER_PLUS_EXPR. From-SVN: r213731 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/semantics.c | 4 ++- gcc/testsuite/g++.dg/cpp0x/constexpr-empty7.C | 28 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-empty7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d218152f17b..1925891c3f3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2014-08-07 Jason Merrill + + PR c++/61959 + * semantics.c (cxx_eval_bare_aggregate): Handle POINTER_PLUS_EXPR. + 2014-08-07 Trevor Saunders * cp-tree.h, pt.c: Use hash_map instead of pointer_map. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 536ea5c3964..4cd9bee353f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8977,7 +8977,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 index 00000000000..f491994a1fe --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty7.C @@ -0,0 +1,28 @@ +// PR c++/61959 +// { dg-do compile { target c++11 } } + +template struct BasePoint +{ + Coord x, y; + constexpr BasePoint (Coord, Coord) : x (0), y (0) {} +}; +template struct BaseCoord +{ + int value; + constexpr BaseCoord (T) : value (1) {} +}; +template struct IntCoordTyped : BaseCoord, units +{ + typedef BaseCoord Super; + constexpr IntCoordTyped (int) : Super (0) {} +}; +template +struct IntPointTyped : BasePoint >, units +{ + typedef BasePoint > Super; + constexpr IntPointTyped (int, int) : Super (0, 0) {} +}; +struct A +{ +}; +IntPointTyped a (0, 0);