From patchwork Sat Mar 16 19:38:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 228247 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 926102C00B6 for ; Sun, 17 Mar 2013 06:38:26 +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=1364067507; 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=5atTRly b9eMcp8qL3flCT4nAMBk=; b=Nmfk+3hpFkeXVnb2thaV20i6T6HqBG/TWQJKs0+ jV5go9fP13HXdoDIb/LPDWDM63WMt42P7At21QAbkww4PJ5EwL6z7xO/NHENoDSm dcqBuA/L+nWfTRst5/VMFztxC25BBGuM65EzFl14ctc4uFGYh0DwaNb/7+coBnTL PVSY= 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=k1A2jSLC1FLryttVjxgiDV2sO33bVMDUpvvHaxWr6w0SvoN5/ijAjxUO0xI9IQ R8QUbLumth8NfwtZUH/J34FZHRlrC6ydcelotrX+9S8fEEJPjrDlNRD2V/9JhTsk 32Pdx/vTBnRo/EfWqD25gxyY1jJ1/UgFWDwTRe+ksnJb4=; Received: (qmail 1188 invoked by alias); 16 Mar 2013 19:38:18 -0000 Received: (qmail 966 invoked by uid 22791); 16 Mar 2013 19:38:16 -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:38:09 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2GJc9M6015633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 16 Mar 2013 15:38:09 -0400 Received: from [10.3.113.8] ([10.3.113.8]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2GJc8Wj009310 for ; Sat, 16 Mar 2013 15:38:08 -0400 Message-ID: <5144CA1F.8060605@redhat.com> Date: Sat, 16 Mar 2013 15:38:07 -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 c++/17232 (abstract class, array 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 In SFINAE context, we need to instantiate a class so that we can tell whether or not is abstract. Doing this in non-SFINAE context caused problems, so I've made it conditional. Tested x86_64-pc-linux-gnu, applying to trunk. commit 02d2b645f935749d9f860cba2fab05656edbbce7 Author: Jason Merrill Date: Wed Feb 27 12:35:12 2013 -0500 DR 337 PR c++/17232 * pt.c (tsubst) [ARRAY_TYPE]: Use abstract_virtuals_error_sfinae. * typeck2.c (abstract_virtuals_error_sfinae): Call complete_type. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cad1c60..ce07fa4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11653,13 +11653,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) error ("creating array of %qT", type); return error_mark_node; } - if (ABSTRACT_CLASS_TYPE_P (type)) - { - if (complain & tf_error) - error ("creating array of %qT, which is an abstract class type", - type); - return error_mark_node; - } + + if (abstract_virtuals_error_sfinae (NULL_TREE, type, complain)) + return error_mark_node; r = build_cplus_array_type (type, domain); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 0e8c921..37c42e2 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -258,6 +258,10 @@ abstract_virtuals_error_sfinae (tree decl, tree type, tsubst_flags_t complain) return 0; type = TYPE_MAIN_VARIANT (type); + /* In SFINAE context, force instantiation. */ + if (!(complain & tf_error)) + complete_type (type); + /* If the type is incomplete, we register it within a hash table, so that we can check again once it is completed. This makes sense only for objects for which we have a declaration or at least a diff --git a/gcc/testsuite/g++.dg/template/abstract-dr337.C b/gcc/testsuite/g++.dg/template/abstract-dr337.C new file mode 100644 index 0000000..de84f90 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/abstract-dr337.C @@ -0,0 +1,13 @@ +// PR c++/17232 (DR 337) + +template +class A { + virtual void f() = 0; +}; + +template +void g(T (*a)[1]) {} // { dg-error "abstract" } + +int main() { + g >(0); // { dg-error "no matching function" } +}