From patchwork Wed Jul 11 09:55:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 942401 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-481333-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WAjmbuxs"; 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 41QZFb0FbPz9s01 for ; Wed, 11 Jul 2018 19:55:43 +1000 (AEST) 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=UMnRVy/35AXQ40SYVIv1XKRbN9C8CxCM2els+sniC0M56c0NurWLR n4Ia9Pojd2FzJtvE744A0wm4zoOYPUrEPSGGrPKhd6Q0YyzRGGXf3Zq/RAvPdEwx 87Wen4GPa5c74mw3eqvi4iBs/OlIl/lC7uM3qlcC6nhNbPI/mQCLrM= 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:subject:message-id:mime-version:content-type; s= default; bh=uxvWHwwLIhQO5qW9wzhpbQkXl5s=; b=WAjmbuxst0frTm/5bn0c mggiEsA7PqEyyM29eslamGEZktDbHaBfYA1eq8WlADXCoXle60mgfnSMsr+ZipJW 1PcTJpGmQO5Obm3xJxD5xytdN6Bou6IjHLNcsezO0N1itgrH74nA8IQajrAk2f9z z4CZKNwHfJGQK6ONBTWvDHY= Received: (qmail 79379 invoked by alias); 11 Jul 2018 09:55: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 79364 invoked by uid 89); 11 Jul 2018 09:55:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.2 spammy=nonexistent, family X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Jul 2018 09:55:34 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 56924AEC3 for ; Wed, 11 Jul 2018 09:55:32 +0000 (UTC) Date: Wed, 11 Jul 2018 11:55:32 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][C family] Fix PR86453 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 This fixes handle_packed_attribute creating a type variant which differs in TYPE_PACKED. This cannot be generally allowed since TYPE_PACKED affects layout and layout is shared between variants. For the testcase in question the attribute itself is later ignored but TYPE_PACKED is still applied which eventually leads to an ICE in type verification (that isn't applied very reliably). Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? Thanks, Richard. 2018-07-11 Richard Biener PR c/86453 * c-attribs.c (handle_packed_attribute): Do not build a variant type with TYPE_PACKED, instead ignore the attribute if we may not apply to the original type. * g++.dg/warn/pr86453.C: New testcase. diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index f91add488bb..8cb87eb8154 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -502,8 +502,13 @@ handle_packed_attribute (tree *node, tree name, tree ARG_UNUSED (args), if (TYPE_P (*node)) { if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE)) - *node = build_variant_type_copy (*node); - TYPE_PACKED (*node) = 1; + { + warning (OPT_Wattributes, + "%qE attribute ignored for type %qT", name, *node); + *no_add_attrs = true; + } + else + TYPE_PACKED (*node) = 1; } else if (TREE_CODE (*node) == FIELD_DECL) { Index: gcc/testsuite/g++.dg/warn/pr86453.C =================================================================== --- gcc/testsuite/g++.dg/warn/pr86453.C (nonexistent) +++ gcc/testsuite/g++.dg/warn/pr86453.C (working copy) @@ -0,0 +1,5 @@ +// { dg-do compile } +// { dg-additional-options "-flto" { target lto } } +struct X { + int *__attribute__((aligned(2), packed)) a; // { dg-warning "attribute ignored" } +} b;