From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25873 invoked by alias); 7 Aug 2014 19:46:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 25862 invoked by uid 89); 7 Aug 2014 19:46:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 07 Aug 2014 19:46:02 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s77Jk0rU010610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 7 Aug 2014 15:46:00 -0400 Received: from [10.10.116.19] ([10.10.116.19]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s77Jk0o5031515 for ; Thu, 7 Aug 2014 15:46:00 -0400 Message-ID: <53E3D775.2060407@redhat.com> Date: Thu, 07 Aug 2014 19:46:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/61959 (POINTER_PLUS_EXPR in CONSTRUCTOR) Content-Type: multipart/mixed; boundary="------------080209030603050300060109" X-SW-Source: 2014-08/txt/msg00845.txt.bz2 This is a multi-part message in MIME format. --------------080209030603050300060109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 155 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. --------------080209030603050300060109 Content-Type: text/x-patch; name="61959.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="61959.patch" Content-length: 1761 commit 36db761e7a61c86d1c95dd6aa65bc325b6642966 Author: Jason Merrill 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 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); --------------080209030603050300060109--