From patchwork Fri Jul 1 20:23:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 102968 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 6E04EB6F59 for ; Sat, 2 Jul 2011 06:24:16 +1000 (EST) Received: (qmail 13385 invoked by alias); 1 Jul 2011 20:24:14 -0000 Received: (qmail 13232 invoked by uid 22791); 1 Jul 2011 20:24:13 -0000 X-SWARE-Spam-Status: No, hits=-6.4 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; Fri, 01 Jul 2011 20:23:57 +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 p61KNvTn025228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Jul 2011 16:23:57 -0400 Received: from [127.0.0.1] (ovpn-113-148.phx2.redhat.com [10.3.113.148]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p61KNuno008744 for ; Fri, 1 Jul 2011 16:23:57 -0400 Message-ID: <4E0E2CDC.5000201@redhat.com> Date: Fri, 01 Jul 2011 16:23:56 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48261 (ICE with non-template used 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 Replacing assert with error. Tested x86_64-pc-linux-gnu, applying to trunk. commit e42789795f05e88b0b55c5da0670aa827ad046b2 Author: Jason Merrill Date: Fri Jul 1 14:06:46 2011 -0400 PR c++/48261 * pt.c (lookup_template_function): Handle non-function. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5743159..7236e7e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6622,8 +6622,12 @@ lookup_template_function (tree fns, tree arglist) return error_mark_node; gcc_assert (!arglist || TREE_CODE (arglist) == TREE_VEC); - gcc_assert (fns && (is_overloaded_fn (fns) - || TREE_CODE (fns) == IDENTIFIER_NODE)); + + if (!is_overloaded_fn (fns) && TREE_CODE (fns) != IDENTIFIER_NODE) + { + error ("%q#D is not a function template", fns); + return error_mark_node; + } if (BASELINK_P (fns)) { diff --git a/gcc/testsuite/g++.dg/template/template-id-3.C b/gcc/testsuite/g++.dg/template/template-id-3.C new file mode 100644 index 0000000..e0753ab --- /dev/null +++ b/gcc/testsuite/g++.dg/template/template-id-3.C @@ -0,0 +1,22 @@ +// PR c++/48261 + +typedef double (*gaddType)(double,double); +struct Foo2 +{ + static gaddType add; +}; + +template +struct Something +{ + void work() + { + double x=T::template add(5.0,6.0); // { dg-error "add" } + } +}; + +int main() +{ + Something s2; + s2.work(); +}