public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/61959 (POINTER_PLUS_EXPR in CONSTRUCTOR)
@ 2014-08-07 19:46 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2014-08-07 19:46 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 155 bytes --]

It seems that an empty base initializer can show up with an index of 
POINTER_PLUS_EXPR as well.

Tested x86_64-pc-linux-gnu, applying to trunk, 4.8, 4.9.

[-- Attachment #2: 61959.patch --]
[-- Type: text/x-patch, Size: 1761 bytes --]

commit 36db761e7a61c86d1c95dd6aa65bc325b6642966
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Aug 7 15:10:08 2014 -0400

    	PR c++/61959
    	* semantics.c (cxx_eval_bare_aggregate): Handle POINTER_PLUS_EXPR.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 536ea5c..4cd9bee 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 0000000..f491994
--- /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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-07 19:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-07 19:46 C++ PATCH for c++/61959 (POINTER_PLUS_EXPR in CONSTRUCTOR) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).