From: Jason Merrill Date: Thu, 7 Aug 2014 19:50:11 +0000 (-0400) Subject: re PR c++/61959 (ICE: in tree_to_uhwi, at tree.h:3657 when building Mozilla code) X-Git-Tag: releases/gcc-4.8.4~306 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67bf4ba6c32dfcdb258f6c97bc7a74f4d362d681;p=thirdparty%2Fgcc.git 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: r213735 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b0e1efd19732..82e61f5f6b7e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2014-08-07 Jason Merrill + 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. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d5013c446f9f..9825dbe6aa40 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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 index 000000000000..f491994a1fed --- /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);