From patchwork Fri May 22 18:46:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 475749 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6C366140B0E for ; Sat, 23 May 2015 04:46:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=mWI7TyUr; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=cqFurMwWKRuviKrYpze9B4ebYXjM8dR6ufd+G2HR/8P gC35sf2G5DbPCQ0QJSGIwW3RdOws9WtOuo8Pv/0xcvBgz+NbSaTtZm6aktD7rg0r kQgwRVIzwDlNRgxys9NmnbHrO5bclVksB33Pm/WSglbN3/dFcXDQDHgF2mtLuXoc = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=YIfe69eed4AZiSWAvrMQ2gG19dw=; b=mWI7TyUrSxEP2mPR6 KN8CZmupBQEB1SCoEk5+sFwDeAXIMjASht4gJ7xVouSoe1ckJhwIQmwcpxMQWJ2/ GAw2ayTEhuO0NOHgxO+p4PMROkY7k+Xn1wgMzjUrf9RHdVKOLoNwi4UyjKcxD7+Z mnHyi2gbHfhaK6QyLQvizm4ed0= Received: (qmail 94238 invoked by alias); 22 May 2015 18:46:23 -0000 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 Received: (qmail 94226 invoked by uid 89); 22 May 2015 18:46:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 22 May 2015 18:46:22 +0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t4MIkJtZ016005 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 May 2015 18:46:20 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t4MIkJN9018252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 22 May 2015 18:46:19 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t4MIkJTw025914; Fri, 22 May 2015 18:46:19 GMT Received: from [192.168.1.4] (/79.33.215.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 May 2015 11:46:18 -0700 Message-ID: <555F7971.4060704@oracle.com> Date: Fri, 22 May 2015 20:46:09 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 65815 X-IsSubscribed: yes Hi, surprisingly, for NSDMIs we don't use reshape_init and we end-up rejecting simple testcases like the below. It seems clear to me that we should - consistently with the comment preceding digest_init too - but I'm not 100% sure that digest_nsdmi_init is the best place for that. Anyway, the below passes testing on x86_64-linux. Thanks! Paolo. ///////////////////////// /cp 2015-05-22 Paolo Carlini PR c++/65815 * typeck2.c (digest_nsdmi_init): On aggregates use reshape_init; take a type, not a decl, as first argument. * parser.c (cp_parser_late_parse_one_default_arg): Adjust call. * init.c (get_nsdmi): Likewise. /testsuite 2015-05-22 Paolo Carlini PR c++/65815 * g++.dg/cpp0x/nsdmi-aggr1.C: New. Index: cp/init.c =================================================================== --- cp/init.c (revision 223580) +++ cp/init.c (working copy) @@ -564,7 +564,7 @@ get_nsdmi (tree member, bool in_ctor) tf_warning_or_error, member, /*function_p=*/false, /*integral_constant_expression_p=*/false)); - init = digest_nsdmi_init (member, init); + init = digest_nsdmi_init (TREE_TYPE (member), init); } else { Index: cp/parser.c =================================================================== --- cp/parser.c (revision 223580) +++ cp/parser.c (working copy) @@ -24278,7 +24283,7 @@ cp_parser_late_parse_one_default_arg (cp_parser *p parsed_arg = check_default_argument (parmtype, parsed_arg, tf_warning_or_error); else - parsed_arg = digest_nsdmi_init (decl, parsed_arg); + parsed_arg = digest_nsdmi_init (TREE_TYPE (decl), parsed_arg); } /* If the token stream has not been completely used up, then Index: cp/typeck2.c =================================================================== --- cp/typeck2.c (revision 223580) +++ cp/typeck2.c (working copy) @@ -1159,16 +1159,18 @@ digest_init_flags (tree type, tree init, int flags return digest_init_r (type, init, false, flags, tf_warning_or_error); } -/* Process the initializer INIT for an NSDMI DECL (a FIELD_DECL). */ +/* Process the initializer INIT for an NSDMI decl of type TYPE. */ + tree -digest_nsdmi_init (tree decl, tree init) +digest_nsdmi_init (tree type, tree init) { - gcc_assert (TREE_CODE (decl) == FIELD_DECL); - int flags = LOOKUP_IMPLICIT; if (DIRECT_LIST_INIT_P (init)) flags = LOOKUP_NORMAL; - init = digest_init_flags (TREE_TYPE (decl), init, flags); + if (BRACE_ENCLOSED_INITIALIZER_P (init) + && CP_AGGREGATE_TYPE_P (type)) + init = reshape_init (type, init, tf_warning_or_error); + init = digest_init_flags (type, init, flags); if (TREE_CODE (init) == TARGET_EXPR) /* This represents the whole initialization. */ TARGET_EXPR_DIRECT_INIT_P (init) = true; Index: testsuite/g++.dg/cpp0x/nsdmi-aggr1.C =================================================================== --- testsuite/g++.dg/cpp0x/nsdmi-aggr1.C (revision 0) +++ testsuite/g++.dg/cpp0x/nsdmi-aggr1.C (working copy) @@ -0,0 +1,10 @@ +// PR c++/65815 +// { dg-do compile { target c++11 } } + +struct array { + int data [2]; +}; + +struct X { + array a = { 1, 2 }; +};