From patchwork Wed Nov 17 01:33:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 71501 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 E2D23B7103 for ; Wed, 17 Nov 2010 12:33:40 +1100 (EST) Received: (qmail 28545 invoked by alias); 17 Nov 2010 01:33:38 -0000 Received: (qmail 28536 invoked by uid 22791); 17 Nov 2010 01:33:37 -0000 X-SWARE-Spam-Status: No, hits=-6.1 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; Wed, 17 Nov 2010 01:33:32 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAH1XVVf023768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Nov 2010 20:33:31 -0500 Received: from [127.0.0.1] (ovpn-113-96.phx2.redhat.com [10.3.113.96]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAH1XUq4024596 for ; Tue, 16 Nov 2010 20:33:30 -0500 Message-ID: <4CE330E9.3010208@redhat.com> Date: Tue, 16 Nov 2010 20:33:29 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101114 Lightning/1.0b1 Shredder/3.0.11pre MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for DR 1004 (use of injected type name as template) 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 While I was doing the standardese drafting for core language issue 1004, I noticed that when I implemented these semantics before I missed a case. Fixed thus. Tested x86_64-pc-linux-gnu, applied to trunk. commit 086ac7e09768d54b4fea6f936593d9e16f1f38ca Author: Jason Merrill Date: Wed Nov 10 23:59:55 2010 -0600 DR 1004 * decl.c (make_unbound_class_template): Handle using injected-type-name as template. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 714516e..55e0d6a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3227,6 +3227,9 @@ make_unbound_class_template (tree context, tree name, tree parm_list, if (MAYBE_CLASS_TYPE_P (context)) tmpl = lookup_field (context, name, 0, false); + if (tmpl && TREE_CODE (tmpl) == TYPE_DECL) + tmpl = maybe_get_template_decl_from_type_decl (tmpl); + if (!tmpl || !DECL_CLASS_TEMPLATE_P (tmpl)) { if (complain & tf_error) diff --git a/gcc/testsuite/g++.dg/template/injected2.C b/gcc/testsuite/g++.dg/template/injected2.C new file mode 100644 index 0000000..bd09ccc --- /dev/null +++ b/gcc/testsuite/g++.dg/template/injected2.C @@ -0,0 +1,9 @@ +// DR 1004 + +template class U = T::template B> struct A { }; + +template struct B { + template friend struct B; +}; + +A > a;