From patchwork Thu Feb 9 14:16:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 726139 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 3vK0WJ190gz9s3v for ; Fri, 10 Feb 2017 01:16:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="djtiPJjk"; 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:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=LqXQzSDPNhl1dEUNO 66JnEr8j7NdjVJoz452iKk22D+ZmVwcaaxRIrE/+568Ink1eCx4qt+60fQpmq2Wp Ot4rDlEgxTdwEQ4zGh8HTcRsXAkCWVbAWSEPYMyO9ieuI+nYcR1XKYiNEi7eB4p3 mkLBpLtifRvyyQi5ozcFRimplw= 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:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; s=default; bh=aFqX/1npkvFWcuiuCp46D/2 W6Tc=; b=djtiPJjkheyTI0XuWDQHW1Bu0aLGvYlFTLHXHtQBGuck+v+uWmlORM9 8o4GVMrt6yu9ojhhiP1qK7FST/MW4fRbbWwsEJu/7O2YJHR3SyVohRpBZH9lOfk7 LhV77p2gWTssoSyGQHjg6U2DXzHsOs5YLkvmzcTKYU0wHDp2gaks= Received: (qmail 127707 invoked by alias); 9 Feb 2017 14:16:35 -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 127638 invoked by uid 89); 9 Feb 2017 14:16:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=BAYES_05, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=U*jason, jasonredhatcom, sk:jasonr, jason@redhat.com 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 ESMTP; Thu, 09 Feb 2017 14:16:30 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 816857FB89 for ; Thu, 9 Feb 2017 14:16:30 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19EGSnC014284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 9 Feb 2017 09:16:30 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v19EGQrf031285; Thu, 9 Feb 2017 15:16:27 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v19EGP05031284; Thu, 9 Feb 2017 15:16:25 +0100 Date: Thu, 9 Feb 2017 15:16:25 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches List Subject: [C++ PATCH] For -std=c++1z treat class types with inherited ctors as non-aggregate (PR c++/79143, take 3) Message-ID: <20170209141625.GL1849@tucnak> Reply-To: Jakub Jelinek References: <20170207213036.GX1849@tucnak> <20170208222437.GF1849@tucnak> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes On Wed, Feb 08, 2017 at 06:47:10PM -0500, Jason Merrill wrote: > On Wed, Feb 8, 2017 at 5:24 PM, Jakub Jelinek wrote: > > On Wed, Feb 08, 2017 at 04:51:54PM -0500, Jason Merrill wrote: > >> On Tue, Feb 7, 2017 at 4:30 PM, Jakub Jelinek wrote: > >> > P0017R1 added in [dcl.init.aggr]/1 that classes with inherited constructors > >> > are not aggregate. CLASSTYPE_NON_AGGREGATE is set slightly before > >> > add_implicitly_declared_members is called and so we don't know about the > >> > inherited ctors yet. > >> > >> Hmm, why doesn't my patch for 78124 to set CLASSTYPE_NON_AGGREGATE in > >> do_class_using_decl cover this testcase? > > > > It does set CLASSTYPE_NON_AGGREGATE on a different RECORD_TYPE, > > do_class_using_decl sees the template, while what is tested and what > > check_bases_and_members is called on is the implicit instantiation thereof. > > > > The following completely untested patch also fixes it. Or is there some > > even better place where to copy over that bit from the template to the > > instantiation? > > Better I think in instantiate_class_template_1, about where we copy TYPE_PACKED. That works too, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-02-09 Jakub Jelinek Jason Merrill PR c++/79143 * pt.c (instantiate_class_template_1): Copy CLASSTYPE_NON_AGGREGATE from pattern to type. * g++.dg/cpp1z/pr79143.C: New test. Jakub --- gcc/cp/pt.c.jj 2017-02-06 21:02:40.000000000 +0100 +++ gcc/cp/pt.c 2017-02-09 00:57:58.961930210 +0100 @@ -10253,6 +10253,7 @@ instantiate_class_template_1 (tree type) TYPE_PACKED (type) = TYPE_PACKED (pattern); SET_TYPE_ALIGN (type, TYPE_ALIGN (pattern)); TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (pattern); + CLASSTYPE_NON_AGGREGATE (type) = CLASSTYPE_NON_AGGREGATE (pattern); if (ANON_AGGR_TYPE_P (pattern)) SET_ANON_AGGR_TYPE_P (type); if (CLASSTYPE_VISIBILITY_SPECIFIED (pattern)) --- gcc/testsuite/g++.dg/cpp1z/pr79143.C.jj 2017-02-07 17:55:19.091028200 +0100 +++ gcc/testsuite/g++.dg/cpp1z/pr79143.C 2017-02-07 17:54:48.000000000 +0100 @@ -0,0 +1,28 @@ +// PR c++/79143 +// { dg-do compile } +// { dg-options "-std=c++1z" } + +struct base { + base (int, int) {} +}; + +template +struct derived : base { + using base::base; +}; + +template +struct derived2 : base { + derived2 (int x, int y) : base (x, y) {} +}; + +int +main () +{ + base (13, 42); + derived (13, 42); + derived2 (13, 42); + base{13, 42}; + derived{13, 42}; // { dg-bogus "too many initializers" } + derived2{13, 42}; +}