From patchwork Fri Mar 23 00:58:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 148372 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 C8770B6F98 for ; Fri, 23 Mar 2012 12:02:14 +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=1333069336; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=xnrXK5KcRp1FPhh/eg8Wq0FH1ic=; b=MuFIV/+nVvcTSA8RB7Gl+OS7DuWuybbnsggZ/Vj5ZMFTfTx9TA1iTPzxsi301E r2jdc9gBZwDDCMYgdM20zhCGzGGEdfkeCM+g+lpWMt66Qh1nisCASPhqgjBwZbq1 CGCqWBqXWrofg0xUbIUfQcwtdNr0+t3gu+W69jlwJSP1w= 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:References:In-Reply-To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=AocInZXl0DvboT1o+xmmx5TVR7lwUx56QOb+B5z34p5XFGWOP4PAHsSVOaBB7K Jtun0C1a/aXzFMOaYsl8CGVVCQZGf0Neux13ypDwM8eTHUKUFZoW9lGMsJjruMlP uYf6hkv4y3ar1FH2n4yOhIC0eMXGHLlLRYb0fCWCcOl9w=; Received: (qmail 31715 invoked by alias); 23 Mar 2012 01:02:10 -0000 Received: (qmail 31706 invoked by uid 22791); 23 Mar 2012 01:02:09 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Mar 2012 01:01:41 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q2N11c6f009515 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Mar 2012 01:01:39 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q2N11bnv018655 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 23 Mar 2012 01:01:38 GMT Received: from abhmt110.oracle.com (abhmt110.oracle.com [141.146.116.62]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q2N11bmt019489; Thu, 22 Mar 2012 20:01:37 -0500 Received: from [192.168.1.4] (/79.43.235.150) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Mar 2012 18:01:37 -0700 Message-ID: <4F6BCABF.9000502@oracle.com> Date: Fri, 23 Mar 2012 01:58:39 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120215 Thunderbird/10.0.2 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 52487 References: <4F689E3A.20805@oracle.com> <4F68D900.2000604@redhat.com> <4F68E506.3050200@oracle.com> <4F68E9F2.7070406@oracle.com> <4F6B3BF1.80806@redhat.com> <4F6B5A25.2020001@oracle.com> <4F6B6F69.8070609@redhat.com> In-Reply-To: <4F6B6F69.8070609@redhat.com> 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 On 03/22/2012 07:28 PM, Jason Merrill wrote: > On 03/22/2012 12:58 PM, Paolo Carlini wrote: >> Anyway, I also think not calling literal_type_p from check_field_decls >> if the type is incomplete is pretty ugly, but I'm not sure which is the >> best way to make progress > I guess that's OK. Just add a comment explaining that we'll get an > error later. Done: I applied the below to mainline and 4_7-branch. Thanks! Paolo. /////////////////// /cp 2012-03-22 Paolo Carlini PR c++/52487 * class.c (check_field_decls): Call literal_type_p only on complete types. /testsuite 2012-03-22 Paolo Carlini PR c++/52487 * g++.dg/cpp0x/lambda/lambda-ice7.C: New. Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C (revision 0) +++ testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C (revision 0) @@ -0,0 +1,9 @@ +// PR c++/52487 +// { dg-options "-std=c++0x" } + +struct A; // { dg-error "forward declaration" } + +void foo(A& a) +{ + [=](){a;}; // { dg-error "invalid use of incomplete type" } +} Index: cp/class.c =================================================================== --- cp/class.c (revision 185715) +++ cp/class.c (working copy) @@ -3149,8 +3149,9 @@ check_field_decls (tree t, tree *access_decls, CLASSTYPE_NON_AGGREGATE (t) = 1; /* If at least one non-static data member is non-literal, the whole - class becomes non-literal. */ - if (!literal_type_p (type)) + class becomes non-literal. Note: if the type is incomplete we + will complain later on. */ + if (COMPLETE_TYPE_P (type) && !literal_type_p (type)) CLASSTYPE_LITERAL_P (t) = false; /* A standard-layout class is a class that: