From patchwork Tue Jul 3 03:28:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 168679 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 6AEBE2C008D for ; Tue, 3 Jul 2012 13:29:16 +1000 (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=1341890956; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=kVmHwKr 3sBjnxy3g/0HpsTfO7Zk=; b=mxj55tu0WpjzMKejBzfCgDre6VuiyEL+0fda6c0 x+RmR4SBPp48Bar9h239TpKC1fD2VXiVImAHGROvpcYIZUDHlG73omHMonQPUtd3 MM6O1cJqu6GlhtU6eThoTGl6gDUs6GX7nknjIXtA90b9D9f3AYog0dYg97dAMtvy uKK4= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=t28zI1SOq1AuRjr/eG8unJ1UbQ9V1kvlqbxwLxj6Dj+xxP2egjft0K/El32vvz FxLucwGPbgdiW0/SuB9a/0fA7hEUlFwO3ZIcnDqPXg3aLSrZYjI68Ffu50AgIcr9 E7RpKA2GMNAyT32yEdzXMdccvwXTaXXHJd/C1yeggTNIo=; Received: (qmail 27352 invoked by alias); 3 Jul 2012 03:29:13 -0000 Received: (qmail 27343 invoked by uid 22791); 3 Jul 2012 03:29:12 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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; Tue, 03 Jul 2012 03:28:59 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q633T0fc030205 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 2 Jul 2012 23:29:00 -0400 Received: from [10.3.113.9] ([10.3.113.9]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q633SxoV027718 for ; Mon, 2 Jul 2012 23:29:00 -0400 Message-ID: <4FF266FA.2000507@redhat.com> Date: Mon, 02 Jul 2012 23:28:58 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/53788 (accepts-invalid with call to method in decltype) 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 The diagnostic for calling a non-static member function without an associated object depends on the form of the dummy object built by build_dummy_object. If we wrap it in a NON_DEPENDENT_EXPR, then is_dummy_object doesn't recognize it any more. So don't wrap it. Tested x86_64-pc-linux-gnu, applying to trunk. commit 66f75d714661171ff026b8ccf3d99ce9a4d536e2 Author: Jason Merrill Date: Mon Jul 2 17:06:33 2012 -0400 PR c++/53788 * pt.c (build_non_dependent_expr): Don't wrap a dummy object. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f8f416a..563a1ad 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -20215,6 +20215,10 @@ build_non_dependent_expr (tree expr) if (BRACE_ENCLOSED_INITIALIZER_P (expr)) return expr; + /* Don't wrap a dummy object, we need to be able to test for it. */ + if (is_dummy_object (expr)) + return expr; + if (TREE_CODE (expr) == COND_EXPR) return build3 (COND_EXPR, TREE_TYPE (expr), diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype39.C b/gcc/testsuite/g++.dg/cpp0x/decltype39.C new file mode 100644 index 0000000..4676d2d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype39.C @@ -0,0 +1,19 @@ +// PR c++/53788 +// { dg-do compile { target c++11 } } + +struct t { static const bool value = true; }; +struct f { static const bool value = false; }; + +template +struct has_static { + template + static t check(X*, decltype(T::fun())* = 0); // { dg-error "without object" } + static f check(...); + + typedef decltype(check((T*)(0))) ret; + static const bool value = ret::value; +}; + +struct test { int fun() { return 0; } }; + +bool b = has_static::value; diff --git a/gcc/testsuite/g++.dg/diagnostic/method1.C b/gcc/testsuite/g++.dg/diagnostic/method1.C index 4a78104..0e7c580 100644 --- a/gcc/testsuite/g++.dg/diagnostic/method1.C +++ b/gcc/testsuite/g++.dg/diagnostic/method1.C @@ -10,7 +10,7 @@ template void bar () { - A::foo ().anything; // { dg-error "request for member" } + A::foo ().anything; // { dg-error "without object" } } void @@ -18,5 +18,3 @@ baz () { bar (); } - -// { dg-prune-output "without object" }