From patchwork Thu Mar 17 16:00:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 87392 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 31B57B6FDC for ; Fri, 18 Mar 2011 03:01:10 +1100 (EST) Received: (qmail 9811 invoked by alias); 17 Mar 2011 16:01:06 -0000 Received: (qmail 9802 invoked by uid 22791); 17 Mar 2011 16:01:05 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Mar 2011 16:01:01 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2HG0xws013698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Mar 2011 12:01:00 -0400 Received: from [127.0.0.1] (ovpn-113-145.phx2.redhat.com [10.3.113.145]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2HG0wts002581 for ; Thu, 17 Mar 2011 12:00:59 -0400 Message-ID: <4D82303A.6010301@redhat.com> Date: Thu, 17 Mar 2011 12:00:58 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48166 (ICE with invalid function-cv-quals) 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 I missed one case where we needed to change cp_type_quals to type_memfn_quals. After that fix we gave the correct error, but still ICEd, so to avoid that I go ahead and strip the offending cv-quals. Tested x86_64-pc-linux-gnu, applying to trunk, will apply to 4.6.1 after 4.6.0 release. commit 3ac9d1e0b60a71e6ff154d4c8996ebedb7ba9652 Author: Jason Merrill Date: Thu Mar 17 10:24:48 2011 -0400 PR c++/48166 * decl.c (revert_static_member_fn): Strip function-cv-quals. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a7da574..0985749 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13344,10 +13344,14 @@ static_fn_type (tree memfntype) void revert_static_member_fn (tree decl) { - TREE_TYPE (decl) = static_fn_type (decl); + tree stype = static_fn_type (decl); - if (cp_type_quals (TREE_TYPE (decl)) != TYPE_UNQUALIFIED) - error ("static member function %q#D declared with type qualifiers", decl); + if (type_memfn_quals (stype) != TYPE_UNQUALIFIED) + { + error ("static member function %q#D declared with type qualifiers", decl); + stype = apply_memfn_quals (stype, TYPE_UNQUALIFIED); + } + TREE_TYPE (decl) = stype; if (DECL_ARGUMENTS (decl)) DECL_ARGUMENTS (decl) = DECL_CHAIN (DECL_ARGUMENTS (decl)); diff --git a/gcc/testsuite/g++.dg/parse/memfnquals1.C b/gcc/testsuite/g++.dg/parse/memfnquals1.C new file mode 100644 index 0000000..ce8af7b --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/memfnquals1.C @@ -0,0 +1,6 @@ +// PR c++/48166 + +struct foo { + static void func (); +}; +void foo::func () const {} // { dg-error "type qualifiers" }