From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3203 invoked by alias); 26 Jun 2015 21:02:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 59933 invoked by uid 89); 26 Jun 2015 20:30:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 26 Jun 2015 20:30:28 +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 (Postfix) with ESMTPS id 53B05362085 for ; Fri, 26 Jun 2015 20:30:26 +0000 (UTC) Received: from [10.10.116.35] ([10.10.116.35]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5QKUPfc025174 for ; Fri, 26 Jun 2015 16:30:26 -0400 Message-ID: <558DB65E.405@redhat.com> Date: Fri, 26 Jun 2015 21:05:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/66255 (ICE with non-type template parameter of typedef type) Content-Type: multipart/mixed; boundary="------------080503060705030306080705" X-SW-Source: 2015-06/txt/msg01989.txt.bz2 This is a multi-part message in MIME format. --------------080503060705030306080705 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 223 My checking code to make sure that we've stripped all appropriate typedefs wasn't considering that the parameter might have a typedef type, requiring the argument to match. Tested x86_64-pc-linux-gnu, applying to trunk. --------------080503060705030306080705 Content-Type: text/x-patch; name="66255.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="66255.patch" Content-length: 2490 commit 63f562788d442b1139d1158a26129b781c16b07a Author: Jason Merrill Date: Thu Jun 25 12:13:16 2015 -0400 PR c++/66255 * pt.c (check_unstripped_args): Split out from... (retrieve_specialization): ...here. Allow typedefs in the type of a non-type argument. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fe5fc14..082e04c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1019,6 +1019,35 @@ optimize_specialization_lookup_p (tree tmpl) && !DECL_FRIEND_P (DECL_TEMPLATE_RESULT (tmpl))); } +/* Make sure ARGS doesn't use any inappropriate typedefs; we should have + gone through coerce_template_parms by now. */ + +static void +check_unstripped_args (tree args) +{ +#ifdef ENABLE_CHECKING + ++processing_template_decl; + if (!any_dependent_template_arguments_p (args)) + { + tree inner = INNERMOST_TEMPLATE_ARGS (args); + for (int i = 0; i < TREE_VEC_LENGTH (inner); ++i) + { + tree arg = TREE_VEC_ELT (inner, i); + if (TREE_CODE (arg) == TEMPLATE_DECL) + /* OK */; + else if (TYPE_P (arg)) + gcc_assert (strip_typedefs (arg, NULL) == arg); + else if (strip_typedefs (TREE_TYPE (arg), NULL) != TREE_TYPE (arg)) + /* Allow typedefs on the type of a non-type argument, since a + parameter can have them. */; + else + gcc_assert (strip_typedefs_expr (arg, NULL) == arg); + } + } + --processing_template_decl; +#endif +} + /* Retrieve the specialization (in the sense of [temp.spec] - a specialization is either an instantiation or an explicit specialization) of TMPL for the given template ARGS. If there is @@ -1052,13 +1081,7 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash) ? TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl)) : template_class_depth (DECL_CONTEXT (tmpl)))); -#ifdef ENABLE_CHECKING - /* We should have gone through coerce_template_parms by now. */ - ++processing_template_decl; - if (!any_dependent_template_arguments_p (args)) - gcc_assert (strip_typedefs_expr (args, NULL) == args); - --processing_template_decl; -#endif + check_unstripped_args (args); if (optimize_specialization_lookup_p (tmpl)) { diff --git a/gcc/testsuite/g++.dg/template/nontype27.C b/gcc/testsuite/g++.dg/template/nontype27.C new file mode 100644 index 0000000..956e5e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/nontype27.C @@ -0,0 +1,9 @@ +// PR c++/66255 + +typedef int int_t; + +template +struct S { }; + +int_t a; +S b; --------------080503060705030306080705--