From patchwork Thu Jan 7 21:43:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 564467 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 018F71402F0 for ; Fri, 8 Jan 2016 08:43:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=dY2L9mrT; 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:mime-version :content-type; q=dns; s=default; b=kSHCZLIy4nfGTfNjg3NsOjgDoISgX K9v5ePbx0aCYsXr/Eh1umoPhCOHPWWjtDpAIjbWq58NMmfru+ttIgYsGgTNk7Sqe VO++XxriPDr4o0SbpTfOpoUYJpSMI4QH1sqM4KrFyVo5IWeIGYS5dy2HHFEHWp1u Fr4ggU7bKCsdzA= 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=5UG5i+5mVnMKhpHznahJO7jwo5I=; b=dY2 L9mrTLJJLnDUFziCgwLxxIDoBMDQMrJwFStc+NQ6IkVrNIsCDx3WF8w2bCUzHM4s Ms+N7DtDmpzkSU/X4EdaU5H7A1rL5HERbxGdTw7JjLEQZS9MXwVyhe4b9gujNRRW Nxt3txmjWtOHocsWPgXmgBH+PPU4zXj1WN+lFm8A= Received: (qmail 113350 invoked by alias); 7 Jan 2016 21:43:36 -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 113337 invoked by uid 89); 7 Jan 2016 21:43:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=bitfields 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 Jan 2016 21:43:35 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B530C65655 for ; Thu, 7 Jan 2016 21:43:33 +0000 (UTC) Received: from tucnak.zalov.cz ([10.3.113.3]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u07LhWPF006564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 7 Jan 2016 16:43:33 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u07LhUn0025652; Thu, 7 Jan 2016 22:43:31 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u07LhTsx025651; Thu, 7 Jan 2016 22:43:29 +0100 Date: Thu, 7 Jan 2016 22:43:29 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix ICE with bitfields (PR c++/69164) Message-ID: <20160107214329.GP18720@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi! We ICE on the following testcase during SRA, because it sees a field with DECL_SIZE of 1 which is not DECL_BIT_FIELD. The problem is that layout_class_type in some cases copies fields, including DECL_SIZE, but does not copy over DECL_BIT_FIELD flag. The following patch copies even that and also DECL_SIZE_UNIT and DEC_BIT_FIELD_TYPE that weren't copied either. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-01-07 Jakub Jelinek PR c++/69164 * class.c (layout_class_type): Also copy DEC_SIZE_UNIT, DECL_BIT_FIELD and DEC_BIT_FIELD_TYPE. * g++.dg/opt/pr69164.C: New test. Jakub --- gcc/cp/class.c.jj 2016-01-04 14:55:57.000000000 +0100 +++ gcc/cp/class.c 2016-01-07 13:59:13.895677297 +0100 @@ -6493,7 +6493,10 @@ layout_class_type (tree t, tree *virtual DECL_FIELD_BIT_OFFSET (*next_field) = DECL_FIELD_BIT_OFFSET (field); DECL_SIZE (*next_field) = DECL_SIZE (field); + DECL_SIZE_UNIT (*next_field) = DECL_SIZE_UNIT (field); DECL_MODE (*next_field) = DECL_MODE (field); + DECL_BIT_FIELD (*next_field) = DECL_BIT_FIELD (field); + DECL_BIT_FIELD_TYPE (*next_field) = DECL_BIT_FIELD_TYPE (field); next_field = &DECL_CHAIN (*next_field); } --- gcc/testsuite/g++.dg/opt/pr69164.C.jj 2016-01-07 13:56:33.013915214 +0100 +++ gcc/testsuite/g++.dg/opt/pr69164.C 2016-01-07 13:55:57.000000000 +0100 @@ -0,0 +1,30 @@ +// PR c++/69164 +// { dg-do compile { target c++11 } } +// { dg-options "-O2" } + +struct A { + struct B { + B () {} + bool : 1; + }; + B foo () { B r; return r; } +}; + +struct C { + struct D { + D (C *x) : d (x->c.foo ()) {} + A::B d; + }; + A c; +}; + +struct F : C { + D f = this; + F (int, int) {} +}; + +void +bar (int a, int b) +{ + F (b, a); +}