From patchwork Fri Jun 13 18:57:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 359595 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6878C14007B for ; Sat, 14 Jun 2014 05:00:50 +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:subject:references :in-reply-to:content-type; q=dns; s=default; b=nBI957/8L+vprX48j Hk8xGCXoa/sIqLTgB7o0b6LJjnGo9C4xOBRj1q1UDHiPjyvEcsv8SnVyor3r55ab qfzUa9P5wyKDA1vIj0SxACani0vCyzYcLDotC8NWYgbd9rGz3v6N5Vh0bvpzKzaj mwqe9Cl+aTk5VEVM50T23vxyj4= 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:subject:references :in-reply-to:content-type; s=default; bh=NORpFQMys3gHvv0/SS5D9dY 0QKo=; b=S0VxLYLHOEGc2dz5Ayxr7bpDTaEYYWSmqvyXf35Nv0fdG8N9X/+8RL6 uO/fmmFInhXJ46vPL7iE0NwuAbvFI62QIB4tq/d6pKHnle6AfB8lOGwbyH+l3DF8 f8BhGXqYxjUQaDeU/pmeRb6XvbOADcX8HWUC7BS/0MDoWbC713MM= Received: (qmail 21906 invoked by alias); 13 Jun 2014 19:00:43 -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 21890 invoked by uid 89); 13 Jun 2014 19:00:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com 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; Fri, 13 Jun 2014 19:00:42 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s5DJ0doh003664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 Jun 2014 19:00:40 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s5DJ0cpM013260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 13 Jun 2014 19:00:39 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s5DJ0bVJ026408; Fri, 13 Jun 2014 19:00:38 GMT Received: from [192.168.1.4] (/79.52.198.93) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 13 Jun 2014 12:00:37 -0700 Message-ID: <539B4998.6040004@oracle.com> Date: Fri, 13 Jun 2014 20:57:28 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 33101 References: <5399D163.7070700@oracle.com> <5399FC15.3010101@oracle.com> <539A19B3.6000108@redhat.com> <539AC874.6050908@oracle.com> <539AD067.2050309@oracle.com> <539AD969.6010509@oracle.com> <539B2255.9080808@redhat.com> <539B2A06.1090001@oracle.com> <539B2B9E.8090509@redhat.com> <539B2DFE.7070300@oracle.com> <539B2EA0.9000508@oracle.com> <539B3747.9030100@redhat.com> <539B389D.1000102@oracle.com> <539B3EC9.603@redhat.com> In-Reply-To: <539B3EC9.603@redhat.com> X-IsSubscribed: yes Hi, On 06/13/2014 08:11 PM, Jason Merrill wrote: > On 06/13/2014 01:45 PM, Paolo Carlini wrote: >> But it doesn't work here, doesn't do anything fancy, it exactly prints >> 'v' and nothing else. > > That seems to be a bug in type_to_string, which sees that "void" > starts with "v" and concludes that they are the same. Oops. This pair old bug, new testcase is really diabolic ;) Fixing type_to_string seems easy. I'm finishing testing the below. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 211609) +++ cp/decl.c (working copy) @@ -11137,12 +11137,24 @@ grokparms (tree parmlist, tree *parms) type = TREE_TYPE (decl); if (VOID_TYPE_P (type)) { - if (same_type_p (type, void_type_node) - && DECL_SELF_REFERENCE_P (type) - && !DECL_NAME (decl) && !result && TREE_CHAIN (parm) == void_list_node) + if (type == void_type_node + && !init + && !DECL_NAME (decl) && !result + && TREE_CHAIN (parm) == void_list_node) /* this is a parmlist of `(void)', which is ok. */ break; - cxx_incomplete_type_error (decl, type); + else if (typedef_variant_p (type)) + error_at (DECL_SOURCE_LOCATION (decl), + "invalid use of typedef-name %qT in " + "parameter declaration", type); + else if (cv_qualified_p (type)) + error_at (DECL_SOURCE_LOCATION (decl), + "invalid use of cv-qualified type %qT in " + "parameter declaration", type); + else + error_at (DECL_SOURCE_LOCATION (decl), + "invalid use of type % in parameter " + "declaration"); /* It's not a good idea to actually create parameters of type `void'; other parts of the compiler assume that a void type terminates the parameter list. */ Index: cp/error.c =================================================================== --- cp/error.c (revision 211609) +++ cp/error.c (working copy) @@ -2922,7 +2922,7 @@ type_to_string (tree typ, int verbose) if (typ && TYPE_P (typ) && typ != TYPE_CANONICAL (typ) && !uses_template_parms (typ)) { - int aka_start; char *p; + int aka_start, aka_len; char *p; struct obstack *ob = pp_buffer (cxx_pp)->obstack; /* Remember the end of the initial dump. */ int len = obstack_object_size (ob); @@ -2932,10 +2932,11 @@ type_to_string (tree typ, int verbose) /* And remember the start of the aka dump. */ aka_start = obstack_object_size (ob); dump_type (cxx_pp, aka, flags); + aka_len = obstack_object_size (ob) - aka_start; pp_right_brace (cxx_pp); p = (char*)obstack_base (ob); /* If they are identical, cut off the aka with a NUL. */ - if (memcmp (p, p+aka_start, len) == 0) + if (len == aka_len && memcmp (p, p+aka_start, len) == 0) p[len] = '\0'; } return pp_ggc_formatted_text (cxx_pp); Index: testsuite/g++.dg/conversion/err-recover1.C =================================================================== --- testsuite/g++.dg/conversion/err-recover1.C (revision 211609) +++ testsuite/g++.dg/conversion/err-recover1.C (working copy) @@ -1,6 +1,6 @@ // PR c++/42219 -void foo(const void); // { dg-error "incomplete|const" } +void foo(const void); // { dg-error "invalid use of cv-qualified" } void bar() { Index: testsuite/g++.dg/other/void3.C =================================================================== --- testsuite/g++.dg/other/void3.C (revision 0) +++ testsuite/g++.dg/other/void3.C (working copy) @@ -0,0 +1,4 @@ +// PR c++/33101 + +typedef void v; +typedef v (*pf)(v); // { dg-error "invalid use of typedef-name" }