From patchwork Thu Feb 17 19:50:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yufeng Zhang X-Patchwork-Id: 83477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 82AE0B70DA for ; Fri, 18 Feb 2011 06:50:42 +1100 (EST) Received: (qmail 5080 invoked by alias); 17 Feb 2011 19:50:40 -0000 Received: (qmail 5070 invoked by uid 22791); 17 Feb 2011 19:50:39 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, MSGID_MULTIPLE_AT, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (94.185.240.25) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Thu, 17 Feb 2011 19:50:32 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 17 Feb 2011 19:50:28 +0000 Received: from e102530 ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Thu, 17 Feb 2011 19:50:25 +0000 From: "Yufeng Zhang" To: Subject: [PING] [PR46003, C++] Fix the assertion failure in build_target_expr Date: Thu, 17 Feb 2011 19:50:21 -0000 Message-ID: <000201cbcedb$e9ac8b70$bd05a250$@Zhang@arm.com> MIME-Version: 1.0 x-cr-hashedpuzzle: 2hU= 360= AhuV AwoA A828 CFo2 Cca3 D9Ep E+9G FYIB Fa6J FxvD G31W G5BQ JO/6 KX25; 1; ZwBjAGMALQBwAGEAdABjAGgAZQBzAEAAZwBjAGMALgBnAG4AdQAuAG8AcgBnAA==; Sosha1_v1; 7; {072C77ED-EB92-4ABE-ABC7-A396EBD07308}; eQB1AGYAZQBuAGcALgB6AGgAYQBuAGcAQABhAHIAbQAuAGMAbwBtAA==; Thu, 17 Feb 2011 19:50:18 GMT; WwBQAEkATgBHAF0AIABbAFAAUgA0ADYAMAAwADMALAAgAEMAKwArAF0AIABGAGkAeAAgAHQAaABlACAAYQBzAHMAZQByAHQAaQBvAG4AIABmAGEAaQBsAHUAcgBlACAAaQBuACAAYgB1AGkAbABkAF8AdABhAHIAZwBlAHQAXwBlAHgAcAByAA== x-cr-puzzleid: {072C77ED-EB92-4ABE-ABC7-A396EBD07308} X-MC-Unique: 111021719502800501 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello, This patch fixes g++.dg/template/cond5.C failure with arm-eabi; the fix is done in the C++ frontend. http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00689.html Any comment will be appreciated. Thanks, Yufeng -----Original Message----- The test ./g++.dg/template/cond5.C fails for testing with arm-eabi with an assertion failure, which occurs in cp/tree.c:build_target_expr(). (Please see the bugzilla page for more information on the analysis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46003) Note that the assertion does not fail in x86-targeted (or any of many other targets targeted) compiler, because of the difference in the ARM C ++ ABI on constructor return values. The ARM C++ ABI requires C1 and C2 constructors to return this (instead of being void functions). The patch tries to patch cp/tree.c:build_aggr_init_expr(). build_aggr_init_expr() wraps a ctor-calling CALL_EXPR tree node with an AGGR_INIT_EXPR tree node, whose expression type is always VOID_TYPE. When it determines whether the routine being called is a ctor or not, it only looks into simple cases, but not the case of overloaded ctors in a tree of COMPONENT_REF (INDIRECT_REF (something, BASELINK (OVERLOAD))). This patch expands the is_ctor determining logic. The test with arm-eabi before and after the patch shows that the previously failing test (cond5.C) now passes, and all the other tests are unaffected. There is no change in the x86 test result. OK for the trunk? Thanks, Yufeng 2011-02-10 Yufeng Zhang PR c++/46003 * tree.c (build_aggr_init_expr): Also consider overloaded ctors when determining is_ctor. Index: gcc/cp/tree.c =================================================================== --- gcc/cp/tree.c (revision 169974) +++ gcc/cp/tree.c (working copy) @@ -391,9 +391,11 @@ else return convert (type, init); - is_ctor = (TREE_CODE (fn) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL - && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0))); + is_ctor = ((TREE_CODE (fn) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL + && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0))) + || ((is_overloaded_fn (fn)) + && DECL_CONSTRUCTOR_P (get_first_fn (fn)))); /* We split the CALL_EXPR into its function and its arguments here. Then, in expand_expr, we put them back together. The reason for