From patchwork Thu Dec 29 00:07:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 133467 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]) by ozlabs.org (Postfix) with SMTP id 66008B6FBB for ; Thu, 29 Dec 2011 11:09:13 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1325722155; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=0mH2xDKab0QzCNC8yTRdvVWQArE=; b=agCl8IsAA1oAkeb A5UYhpBGbugMbH+ewu1TNYLH4awJWx0BLXDA68o4C/jwZfhsDOTGPkwjQNo3dBeE OPU1UvTx8iWUjdLvp39awy6CglMZLGGVFwG8tbxwZv4C4bOu2Ki/Ng9NzMugtR0Y /TQMX0Xv9CiTz2tC82SiNBWGDOzc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=RRVgVYVLUQGOALrOdGa096MIUvDYxbLd6J9EBzHIIRz4iRvJ0J/RCiJ/YzRiJE cLLKOt8xxwk7lDWevJ21NHQvdPT7HEAok5Gl//IeD15mGAF3AAwKBEbnKP3wokSf dO8DRD2Jjwl1Brch8YU4qJB3BTFfy6SIspGRWWlbcMnE8=; Received: (qmail 8353 invoked by alias); 29 Dec 2011 00:09:06 -0000 Received: (qmail 8343 invoked by uid 22791); 29 Dec 2011 00:09:02 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_CX X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Dec 2011 00:08:49 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pBT08mJ8016237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Dec 2011 00:08:48 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pBT08lw2017241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 29 Dec 2011 00:08:47 GMT Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id pBT08k9n023453; Wed, 28 Dec 2011 18:08:46 -0600 Received: from [192.168.1.4] (/79.52.212.124) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Dec 2011 16:08:46 -0800 Message-ID: <4EFBAF5B.8050700@oracle.com> Date: Thu, 29 Dec 2011 01:07:55 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111219 Thunderbird/9.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 51316 X-IsSubscribed: yes 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 Hi, I think the resolution of core/930 and C++11 itself are pretty clear: alignof of an array of unknown bound is fine, provided the element type is complete of course. Tested x86_64-linux. Thanks, Paolo. ////////////////////// /c-family 2011-12-29 Paolo Carlini PR c++/51316 * c-common.c (c_sizeof_or_alignof_type): In C++ allow for alignof of array types with an unknown bound. /testsuite 2011-12-29 Paolo Carlini PR c++/51316 * g++.dg/cpp0x/alignof4.C: New. Index: testsuite/g++.dg/cpp0x/alignof4.C =================================================================== --- testsuite/g++.dg/cpp0x/alignof4.C (revision 0) +++ testsuite/g++.dg/cpp0x/alignof4.C (revision 0) @@ -0,0 +1,7 @@ +// PR c++/51316 +// { dg-options "-std=c++0x" } + +int main() +{ + alignof(int []); +} Index: c-family/c-common.c =================================================================== --- c-family/c-common.c (revision 182710) +++ c-family/c-common.c (working copy) @@ -4382,13 +4382,22 @@ c_sizeof_or_alignof_type (location_t loc, return error_mark_node; value = size_one_node; } - else if (!COMPLETE_TYPE_P (type)) + else if (!COMPLETE_TYPE_P (type) + && (!c_dialect_cxx () || is_sizeof || type_code != ARRAY_TYPE)) { if (complain) - error_at (loc, "invalid application of %qs to incomplete type %qT ", + error_at (loc, "invalid application of %qs to incomplete type %qT", op_name, type); return error_mark_node; } + else if (c_dialect_cxx () && type_code == ARRAY_TYPE + && !COMPLETE_TYPE_P (TREE_TYPE (type))) + { + if (complain) + error_at (loc, "invalid application of %qs to array type %qT of " + "incomplete element type", op_name, type); + return error_mark_node; + } else { if (is_sizeof)