From patchwork Tue Mar 20 15:11:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 147809 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 B48CAB6EEF for ; Wed, 21 Mar 2012 02:15:24 +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=1332861325; 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=T2L+chxXmLewUPRNc09cDjtS5J4=; b=ldwrBRm8GSkGtUe O+69MFPfIXYe7tXuapXlVmk0JoUB+q/SHUJgqe0mdkMT0ssPeQlV7UBTahlI+J2m p5AlZLzxyEUdBIVUZ5QkvYEIXMsJrRANFHdthuBcMiP+ubkfgLChFsLP0UxG8f60 ZBlM2kDZY6pHwTfY0EROzwjolVHI= 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=DXqWTH46MHWems/9wP2rjWCJ6IacSTTvMIzC05OJVgvpVYIHdgcxBzd7PE0ffe CINa6L4IbuxngRqS9/TkEJvxcihYTdZP2Eki+JjB2+3qpU1r/wgQCN5fxtCodl+O 9VJx5tNZHalhcpfLWIphid7Qwl5KQ/zVX4le3aqaLpCvM=; Received: (qmail 22562 invoked by alias); 20 Mar 2012 15:15:17 -0000 Received: (qmail 22531 invoked by uid 22791); 20 Mar 2012 15:15:13 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Tue, 20 Mar 2012 15:14:50 +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 q2KFEmqw018610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 20 Mar 2012 15:14:49 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q2KFElsl011559 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 20 Mar 2012 15:14:48 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q2KFElKd026199; Tue, 20 Mar 2012 10:14:47 -0500 Received: from [192.168.1.4] (/79.25.197.176) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Mar 2012 08:14:47 -0700 Message-ID: <4F689E3A.20805@oracle.com> Date: Tue, 20 Mar 2012 16:11:54 +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: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 52487 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, this regression is about literal_type_p ICEing for types which cannot be completed. Indeed, for the testcase, complete_type cannot complete the type but doesn't error out either, just returns the type as-is, and the gcc_assert triggers. We could imagine handling such types in the caller - check_field_decls - but in my opinion makes more sense to just allow such types and return false. I also considered changing literal_type_p to use complete_type_or_else but then it's easy to produce duplicate diagnostics, for example. What do you think? Tested x86_64-linux. Thanks, Paolo. PS: eventually I guess we want to fix this in mainline and 4.7.1. /////////////////////////// /cp 2012-03-20 Paolo Carlini PR c++/52487 * semantics.c (literal_type_p): Simply return false for types which cannot be completed. /testsuite 2012-03-20 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/semantics.c =================================================================== --- cp/semantics.c (revision 185571) +++ cp/semantics.c (working copy) @@ -5610,8 +5610,7 @@ literal_type_p (tree t) if (CLASS_TYPE_P (t)) { t = complete_type (t); - gcc_assert (COMPLETE_TYPE_P (t) || errorcount); - return CLASSTYPE_LITERAL_P (t); + return COMPLETE_TYPE_P (t) && CLASSTYPE_LITERAL_P (t); } if (TREE_CODE (t) == ARRAY_TYPE) return literal_type_p (strip_array_types (t));