diff options
| -rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/cp/semantics.c | 4 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-empty7.C | 28 |
3 files changed, 35 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d6990c9cba5..297f2afd1ad 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,4 +1,7 @@ -2014-08-06 Jason Merrill <jason@redhat.com> +2014-08-07 Jason Merrill <jason@redhat.com> + + PR c++/61959 + * semantics.c (cxx_eval_bare_aggregate): Handle POINTER_PLUS_EXPR. PR c++/61994 * init.c (build_vec_init): Leave atype an ARRAY_TYPE diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d6f3a73f4cb..352fe3ce15d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8955,7 +8955,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 <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); |

