From patchwork Tue Aug 27 13:12:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 270121 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 "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 593152C00C8 for ; Tue, 27 Aug 2013 23:12:49 +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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=G/IBTZIf6umPOlgY6U16QgTwNcPae0O3dUkXj3QIQla 7v+Tv3mZesAefspZKHQIAzJpZeiDcbqYLmyV/o7MgHWVIS/Xb+ZB54/fAfQ+PEIl BkkoLKYTEfAMeTCv1EGNeED2/9P2aQCHQYKArzfrL+EV2ButwI4IuYIjbI7iSl8I = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=xzYx/4dqH6N4jSLYv3MdLUPBPFo=; b=w/ZWnP2qrDNER/tx1 oAbBEeA+v1ZtWnbdyhoV9tIvs4Uue+Ei/52hmNK39M4YGQxfaOGXs/ZRZWCHyxe9 VU1H4+ddeVhFLd7iYRQ4Sjdb6nm+bNDS4rVN7np+xQSBh+w0bbxWWHZgMH4i3Uz/ qCM8AiWmlyopln6ss1k5HB23Gc= Received: (qmail 20403 invoked by alias); 27 Aug 2013 13:12:42 -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 20394 invoked by uid 89); 27 Aug 2013 13:12:42 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 27 Aug 2013 13:12:42 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-7.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r7RDCdIJ008266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Aug 2013 13:12:40 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7RDCcd2008329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Aug 2013 13:12:39 GMT Received: from abhmt102.oracle.com (abhmt102.oracle.com [141.146.116.54]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7RDCc4H007107; Tue, 27 Aug 2013 13:12:38 GMT Received: from poldo4.casa (/79.43.213.94) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 27 Aug 2013 06:12:38 -0700 Message-ID: <521CA5C4.9060102@oracle.com> Date: Tue, 27 Aug 2013 15:12:36 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 13981 Hi, in this very old issue submitter requested some sort of hint in the diagnostic that the specific problem with the testcase has to do with class type B being incomplete. I think an inform can do. I feared that we would provide too many "false positives", in the sense that the inform would often not be that useful, depending on the target type, but in fact I tried and it *never* (X) triggers in our whole testsuite, thus I'm not that worried anymore ;) Tested x86_64-linux. Thanks, Paolo. (X) Without the class type check it would trigger 2 times in g++.old-deja for arrays of unknown bound. I think we don't want those. //////////////////////// /cp 2013-08-27 Paolo Carlini PR c++/13981 * typeck.c (convert_for_assignment): Provide an inform for pointers to incomplete class types. /testsuite 2013-08-27 Paolo Carlini PR c++/13981 * g++.dg/diagnostic/pr13981.C: New. Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 202020) +++ cp/typeck.c (working copy) @@ -7983,6 +7983,11 @@ convert_for_assignment (tree type, tree rhs, default: gcc_unreachable(); } + if (TYPE_PTR_P (rhstype) + && CLASS_TYPE_P (TREE_TYPE (rhstype)) + && !COMPLETE_TYPE_P (TREE_TYPE (rhstype))) + inform (input_location, "class type %qT is incomplete", + TREE_TYPE (rhstype)); } return error_mark_node; } Index: testsuite/g++.dg/diagnostic/pr13981.C =================================================================== --- testsuite/g++.dg/diagnostic/pr13981.C (revision 0) +++ testsuite/g++.dg/diagnostic/pr13981.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/13981 + +struct A {}; +struct B; + +void func( A *a ); + +int main() +{ + B *b = 0; + func(b); // { dg-error "cannot convert" } +} // { dg-message "is incomplete" "is incomplete" { target *-*-* } 11 }