From patchwork Mon Nov 26 20:54:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1003486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-490920-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gFpvUKwB"; dkim-atps=neutral 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 433fLp3vYWz9s3Z for ; Tue, 27 Nov 2018 07:55:12 +1100 (AEDT) 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:mime-version :content-type; q=dns; s=default; b=KV/4IvhFMeDrq6S0DsBEVmoZBjAbd bCB+Mx8pP+Iy3SOUN+1GoKkaBP/MnTaHwXTC1kA+4CBOr/GNU9uAYSfN37HgJ77Q Sg94yeRotSrZ56Jucpapss08yx6luRtIYFar8zLmPczVMTfv5zoQwEsi2zb7vuMf 3ichESnSlOT5pQ= 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:mime-version :content-type; s=default; bh=73Ix3McfqCJiUXOul/0mybdwhAc=; b=gFp vUKwBYy8OE1gVPCTMHcPPvJVIlyWraG2a/DEvu7ZBthZ/HJMKvyA97Gz+W8l/Yt1 Q5jh16W/i0xNpe4c/+BYYM+mnEHClK6oA61llUjOKD3ZrgF4VEOfI8LV2v1BIISy bjtiL7QBfF6wiaMbWZXD84c0hsn/fNOAUoixNCHo= Received: (qmail 105736 invoked by alias); 26 Nov 2018 20:55:05 -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 105724 invoked by uid 89); 26 Nov 2018 20:55:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=valign, forces 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; Mon, 26 Nov 2018 20:55:04 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 187513082A36 for ; Mon, 26 Nov 2018 20:55:03 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-187.ams2.redhat.com [10.36.117.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 95FC119C65; Mon, 26 Nov 2018 20:55:02 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id wAQKt0jF018175; Mon, 26 Nov 2018 21:55:00 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id wAQKsxvr018174; Mon, 26 Nov 2018 21:54:59 +0100 Date: Mon, 26 Nov 2018 21:54:59 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Propagate TYPE_PACKED to template variants (PR c++/88181) Message-ID: <20181126205459.GK12380@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! On the following patch -fpack-struct forces TYPE_PACKED on all the classes and their variants, but we then create a variant of a class instantiation (const) which doesn't have the TYPE_PACKED set and later finalize the template main variant, but don't propagate that to the already created variants. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-11-26 Jakub Jelinek PR c++/88181 * class.c (fixup_attribute_variants): Also propagate TYPE_PACKED to variants. * g++.dg/debug/pr88181.C: New test. Jakub --- gcc/cp/class.c.jj 2018-11-01 13:30:55.805803718 +0100 +++ gcc/cp/class.c 2018-11-26 15:07:59.555553144 +0100 @@ -1951,6 +1951,7 @@ fixup_attribute_variants (tree t) unsigned align = TYPE_ALIGN (t); bool user_align = TYPE_USER_ALIGN (t); bool may_alias = lookup_attribute ("may_alias", attrs); + bool packed = TYPE_PACKED (t); if (may_alias) fixup_may_alias (t); @@ -1968,6 +1969,7 @@ fixup_attribute_variants (tree t) else TYPE_USER_ALIGN (variants) = user_align; SET_TYPE_ALIGN (variants, valign); + TYPE_PACKED (variants) = packed; if (may_alias) fixup_may_alias (variants); } --- gcc/testsuite/g++.dg/debug/pr88181.C.jj 2018-11-26 15:17:56.272765972 +0100 +++ gcc/testsuite/g++.dg/debug/pr88181.C 2018-11-26 15:17:44.745955023 +0100 @@ -0,0 +1,29 @@ +// PR c++/88181 +// { dg-do compile } +// { dg-options "-fpack-struct -g -std=c++11" } + +template struct A { typedef T B; }; +template class C; +template struct D { constexpr D (e) {} }; +template struct E; +template +struct E : E<1, U...>, D { + constexpr E (T x, U... y) : E<1, U...>(y...), D(x) {} +}; +template struct E : D { + constexpr E (T x) : D(x) {} +}; +template struct C : E<0, T, U> { + constexpr C (T x, U y) : E<0, T, U>(x, y) {} + void operator= (typename A::B); +}; +struct F {}; +struct G {}; + +int +main () +{ + F f; + G g; + constexpr C c(f, g); +}