From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/61959 (POINTER_PLUS_EXPR in CONSTRUCTOR)
Date: Thu, 07 Aug 2014 19:46:00 -0000 [thread overview]
Message-ID: <53E3D775.2060407@redhat.com> (raw)
[-- 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);
reply other threads:[~2014-08-07 19:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53E3D775.2060407@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).