From patchwork Thu Apr 9 15:19:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 459763 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 C77451401AD for ; Fri, 10 Apr 2015 01:19:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=WSh2nML0; dkim-adsp=none (unprotected policy); 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=ZBLXrnZypXB9etSVZ Ek3zna1izbwSdcNKv/c6cQ21dz6RgL6AnJaCm6dHqHfkLkPp5VjWVbM50dTrl80k vVipTQkQBM4bx8QU0WwvIvevH3aW5baUtzOQCxHRKNFyOjK2c2CPqm8TwKdBHj4C qqe9HsLsK8CSni0M8xQZcAoDR8= 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=TofRRSIV5jgr0qHi8xOEtu/ 083k=; b=WSh2nML0cUxp+/S1mozPQhBnydcqCmFIi39w1Z7W5NYdd7r1WCuKOYE COpkAq2pSU8Zx07Oma9P9/CMpiAMpMlGUls4NlOwB2S6dsKufB7KG1RFIvW5q0YS 2IiOtp3hecIJKSqztzyxubM47nImJPFLEsErnrdZQKVd7CmwZuD0= Received: (qmail 34967 invoked by alias); 9 Apr 2015 15:19:29 -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 34937 invoked by uid 89); 9 Apr 2015 15:19:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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, 09 Apr 2015 15:19:28 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t39FJQrw014571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 9 Apr 2015 11:19:26 -0400 Received: from tucnak.zalov.cz (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t39FJPYV006444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 9 Apr 2015 11:19:26 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id t39FJNad000458; Thu, 9 Apr 2015 17:19:23 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id t39FJM0k000457; Thu, 9 Apr 2015 17:19:22 +0200 Date: Thu, 9 Apr 2015 17:19:22 +0200 From: Jakub Jelinek To: Jason Merrill Cc: Jan Hubicka , gcc-patches@gcc.gnu.org Subject: Re: [C++ PATCH] Fix alignment handling in build_cplus_array_type/cp_build_qualified_type_real (PR c++/65690) Message-ID: <20150409151922.GK19273@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20150408100239.GO19273@tucnak.redhat.com> <55253F73.1000902@redhat.com> <20150408150759.GS19273@tucnak.redhat.com> <5526913D.4040603@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5526913D.4040603@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Thu, Apr 09, 2015 at 10:48:29AM -0400, Jason Merrill wrote: > So the first hunk of the first patch is OK. Ok, I've committed this to fix the regression. 2015-04-09 Jakub Jelinek PR c++/65690 * tree.c (build_cplus_array_type): Layout type before variants are set, but copy over TYPE_SIZE and TYPE_SIZE_UNIT from the main variant. * c-c++-common/attr-aligned-1.c: New test. Jakub --- gcc/cp/tree.c.jj 2015-04-01 15:29:33.000000000 +0200 +++ gcc/cp/tree.c 2015-04-08 09:09:45.326939354 +0200 @@ -880,12 +880,19 @@ build_cplus_array_type (tree elt_type, t { t = build_min_array_type (elt_type, index_type); set_array_type_canon (t, elt_type, index_type); + if (!dependent) + { + layout_type (t); + /* Make sure sizes are shared with the main variant. + layout_type can't be called after setting TYPE_NEXT_VARIANT, + as it will overwrite alignment etc. of all variants. */ + TYPE_SIZE (t) = TYPE_SIZE (m); + TYPE_SIZE_UNIT (t) = TYPE_SIZE_UNIT (m); + } TYPE_MAIN_VARIANT (t) = m; TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m); TYPE_NEXT_VARIANT (m) = t; - if (!dependent) - layout_type (t); } } --- gcc/testsuite/c-c++-common/attr-aligned-1.c.jj 2015-04-08 09:22:46.181427189 +0200 +++ gcc/testsuite/c-c++-common/attr-aligned-1.c 2015-04-08 09:26:41.315627195 +0200 @@ -0,0 +1,22 @@ +/* PR c++/65690 */ +/* { dg-do run } */ + +typedef double T[4][4] __attribute__((aligned (2 * __alignof__ (double)))); +void foo (const T); +struct S { T s; }; + +int +main () +{ + if (__alignof__ (struct S) != 2 * __alignof__ (double) + || __alignof__ (T) != 2 * __alignof__ (double) + || __alignof__ (const struct S) != 2 * __alignof__ (double)) + __builtin_abort (); + return 0; +} + +#if defined(__cplusplus) && __cplusplus >= 201103L +static_assert (alignof (S) == 2 * alignof (double), "alignment of S"); +static_assert (alignof (T) == 2 * alignof (double), "alignment of T"); +static_assert (alignof (const S) == 2 * alignof (double), "alignment of const S"); +#endif