From patchwork Thu Apr 25 06:40:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumar Selvaraj X-Patchwork-Id: 239403 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 6DBAA2C0109 for ; Thu, 25 Apr 2013 16:40:22 +1000 (EST) 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:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=uUUXS/VWBjJNJ1U1w WhxaRjcQVt531jN8s0wQOpKWMh9KB5X+8nXtfE7LPjz7K3NtjqUaa+1DILu7iBnm ttoz/ymk2kwWBqcW9Q1uCJkzr94fyhXQYLF2CS39qRtzalh+oQLdBndpSZwb4oV4 oGHyxnvv7K9RHLYZM/N49zaRiM= 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:references:mime-version :content-type:in-reply-to; s=default; bh=mBPmBoAQ0JZy4O3HK8ZraPT SJc0=; b=jxFhneWTLSs1/vINjIOBEozv8zDsO+KAevQ5HPIi4RR3xb6r/6IY+jb M1zq4PAPKvMQdVL/tk++l5sENqaZUuT/ZuL5efkc1h0hkGtZnicciJMvcPuw06xl fUyjI++zOHiOiHmkFp09BcQgT8+5aL28XFUCi8G4duaMgDBmVal4= Received: (qmail 2393 invoked by alias); 25 Apr 2013 06:40:16 -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 2380 invoked by uid 89); 25 Apr 2013 06:40:15 -0000 X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 Received: from nasmtp01.atmel.com (HELO DVREDG01.corp.atmel.com) (192.199.1.245) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 25 Apr 2013 06:40:15 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by DVREDG01.corp.atmel.com (10.42.103.30) with Microsoft SMTP Server (TLS) id 14.2.342.3; Thu, 25 Apr 2013 00:40:07 -0600 Received: from PENCHT01.corp.atmel.com (10.168.5.161) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server (TLS) id 14.2.342.3; Thu, 25 Apr 2013 14:40:17 +0800 Received: from atmel.com (10.168.5.13) by cas-ap.atmel.com (10.168.5.161) with Microsoft SMTP Server (TLS) id 14.2.342.3; Thu, 25 Apr 2013 14:40:10 +0800 Date: Thu, 25 Apr 2013 12:10:06 +0530 From: Senthil Kumar Selvaraj To: "Joseph S. Myers" CC: , Subject: Re: [Patch] Emit error for negative _Alignas alignment values Message-ID: <20130425064003.GA773@atmel.com> References: <20130403134820.GA796@atmel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) On Wed, Apr 24, 2013 at 03:18:51PM +0000, Joseph S. Myers wrote: > On Wed, 3 Apr 2013, Senthil Kumar Selvaraj wrote: > > > 2013-04-03 Senthil Kumar Selvaraj > > > > * c-common.c (check_user_alignment): Emit error for negative values > > > > * gcc.dg/c1x-align-3.c: Add test for negative power of 2 > > OK (but note there should be a "." at the end of each ChangeLog entry). > Fixed now. I also moved the test case change into its own Changelog. Could someone commit it for me please, as I don't have commit access? Regards Senthil gcc/c-family/ChangeLog 2013-04-03 Senthil Kumar Selvaraj * c-common.c (check_user_alignment): Emit error for negative values. gcc/testsuite/ChangeLog 2013-04-03 Senthil Kumar Selvaraj * gcc.dg/c1x-align-3.c: Add test for negative power of 2. diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index c7cdd0f..dfdfbb6 100644 --- gcc/c-family/c-common.c +++ gcc/c-family/c-common.c @@ -7308,9 +7308,10 @@ check_user_alignment (const_tree align, bool allow_zero) } else if (allow_zero && integer_zerop (align)) return -1; - else if ((i = tree_log2 (align)) == -1) + else if (tree_int_cst_sgn (align) == -1 + || (i = tree_log2 (align)) == -1) { - error ("requested alignment is not a power of 2"); + error ("requested alignment is not a positive power of 2"); return -1; } else if (i >= HOST_BITS_PER_INT - BITS_PER_UNIT_LOG) diff --git gcc/testsuite/gcc.dg/c1x-align-3.c gcc/testsuite/gcc.dg/c1x-align-3.c index 0b2a77f..b97351c 100644 --- gcc/testsuite/gcc.dg/c1x-align-3.c +++ gcc/testsuite/gcc.dg/c1x-align-3.c @@ -23,6 +23,7 @@ _Alignas (-(__LONG_LONG_MAX__-1)/4) char i3; /* { dg-error "too large|power of 2 _Alignas (-(__LONG_LONG_MAX__-1)/8) char i4; /* { dg-error "too large|power of 2" } */ _Alignas (-(__LONG_LONG_MAX__-1)/16) char i5; /* { dg-error "too large|power of 2" } */ _Alignas (-1) char j; /* { dg-error "power of 2" } */ +_Alignas (-2) char j; /* { dg-error "positive power of 2" } */ _Alignas (3) char k; /* { dg-error "power of 2" } */ _Alignas ((void *) 1) char k; /* { dg-error "integer constant" } */