From patchwork Sat Mar 16 19:35:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 228246 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 195882C00B8 for ; Sun, 17 Mar 2013 06:36:01 +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=1364067362; 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=NXEhWKo VLPgauH5f+XHTbWaduOQ=; b=jzHf1Et938RPZWJOK2vfp0+KtMv2icnjhNZfjPt KwERhtr47P2yZIMlzXYY34URzDyQ1J/Z/5pM7YoTXssRlVDrxbgoZEv3MmhsQ7uR uTFpJVD5kQ9J2v0i/zvA4GNo1vhMmQTdDOWYFGEAaECqgp6YAbKvrMWT/kiArza5 Pt9c= 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=VpH4vSWUkbiiE6HvN3F9PdTIdcVytkYHDV4+c9kzq0E7jfgE7DPd15Hm75qXuu JxjhhynohSlECoZeoaXWd4pW9Eu3mzAaZmXnT757MBcDaoBdwG0/yvXxgzHpgnQH 7Nty+z+BYSDynZVTkiG1vKd1wVwZuptI8EQL0OU8oDda4=; Received: (qmail 16015 invoked by alias); 16 Mar 2013 19:35:52 -0000 Received: (qmail 15545 invoked by uid 22791); 16 Mar 2013 19:35:49 -0000 X-SWARE-Spam-Status: No, hits=-7.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Sat, 16 Mar 2013 19:35:45 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2GJZjI6030959 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 16 Mar 2013 15:35:45 -0400 Received: from [10.3.113.8] ([10.3.113.8]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2GJZivb025241 for ; Sat, 16 Mar 2013 15:35:44 -0400 Message-ID: <5144C98F.7050704@redhat.com> Date: Sat, 16 Mar 2013 15:35:43 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Thunderbird/21.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for DR 657 (abstract classes and sfinae) 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 Trying to use an abstract class as a return or parameter type causes a deduction failure. Tested x86_64-pc-linux-gnu, applying to trunk. commit 0e6294b17c0e992131701bdc0b71cf6903e09c64 Author: Jason Merrill Date: Wed Feb 27 10:54:55 2013 -0500 DR 657 * pt.c (tsubst_function_type): Call abstract_virtuals_error_sfinae. (tsubst_arg_types): Likewise. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c07ed32..cad1c60 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10850,6 +10850,9 @@ tsubst_arg_types (tree arg_types, } return error_mark_node; } + /* DR 657. */ + if (abstract_virtuals_error_sfinae (NULL_TREE, type, complain)) + return error_mark_node; /* Do array-to-pointer, function-to-pointer conversion, and ignore top-level qualifiers as required. */ @@ -10912,10 +10915,8 @@ tsubst_function_type (tree t, return_type = tsubst (TREE_TYPE (t), args, complain, in_decl); if (return_type == error_mark_node) return error_mark_node; - /* The standard does not presently indicate that creation of a - function type with an invalid return type is a deduction failure. - However, that is clearly analogous to creating an array of "void" - or a reference to a reference. This is core issue #486. */ + /* DR 486 clarifies that creation of a function type with an + invalid return type is a deduction failure. */ if (TREE_CODE (return_type) == ARRAY_TYPE || TREE_CODE (return_type) == FUNCTION_TYPE) { @@ -10928,6 +10929,9 @@ tsubst_function_type (tree t, } return error_mark_node; } + /* And DR 657. */ + if (abstract_virtuals_error_sfinae (NULL_TREE, return_type, complain)) + return error_mark_node; /* Substitute the argument types. */ arg_types = tsubst_arg_types (TYPE_ARG_TYPES (t), args, NULL_TREE, diff --git a/gcc/testsuite/g++.dg/template/sfinae-dr657.C b/gcc/testsuite/g++.dg/template/sfinae-dr657.C new file mode 100644 index 0000000..b78b5a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sfinae-dr657.C @@ -0,0 +1,22 @@ +// DR 657 +// Test that a return or parameter type with abstract class type causes a +// deduction failure. + +struct A +{ + A(); + A(int); + virtual void f() = 0; +}; + +template T declval(); +template int declval(...); + +template void arg(T); +template int arg(...); + +int main() +{ + int i = declval(); + i = arg(1); +}