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
This commit is contained in:
Jason Merrill 2014-08-07 15:48:30 -04:00 committed by Jason Merrill
parent 34c1359ee1
commit 2e8e74c0ad
3 changed files with 36 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2014-08-07 Jason Merrill <jason@redhat.com>
PR c++/61959
* semantics.c (cxx_eval_bare_aggregate): Handle POINTER_PLUS_EXPR.
2014-08-07 Trevor Saunders <tsaunders@mozilla.com>
* cp-tree.h, pt.c: Use hash_map instead of pointer_map.

View File

@ -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. */

View File

@ -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);