From patchwork Tue Sep 27 02:04:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 116530 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 610C3B6F7C for ; Tue, 27 Sep 2011 12:04:46 +1000 (EST) Received: (qmail 9865 invoked by alias); 27 Sep 2011 02:04:41 -0000 Received: (qmail 9694 invoked by uid 22791); 27 Sep 2011 02:04:31 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, 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; Tue, 27 Sep 2011 02:04:14 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8R24E4J027386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 26 Sep 2011 22:04:14 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8R24DA6024638 for ; Mon, 26 Sep 2011 22:04:14 -0400 Received: from [0.0.0.0] ([10.3.113.3]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p8R24CDT028498 for ; Mon, 26 Sep 2011 22:04:13 -0400 Message-ID: <4E812F1C.3080300@redhat.com> Date: Mon, 26 Sep 2011 22:04:12 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20110906 Thunderbird/6.0.2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCHes for c++/46105, c++/45102 (bogus partial specialization ambiguities) 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 When Paolo asked earlier, I thought these two were the same bug, but on investigation they turned out to be unrelated. In 46105 we were treating (const T)::element_type as different from T::element_type, and in 45102 we were pulling out the constant value of RUNTIME and then deciding it was different from RUNTIME itself. Tested x86_64-pc-linux-gnu, applying to trunk. commit 1ef4191889beeb8537cd7adc0f4456b4732435f2 Author: Jason Merrill Date: Mon Sep 26 18:53:20 2011 -0400 PR c++/45102 * pt.c (tsubst_copy_and_build) [CONST_DECL]: Don't pull out constant value if we're still in a template. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cac45f9..4d57f94 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13916,7 +13916,7 @@ tsubst_copy_and_build (tree t, t = tsubst_copy (t, args, complain, in_decl); /* As in finish_id_expression, we resolve enumeration constants to their underlying values. */ - if (TREE_CODE (t) == CONST_DECL) + if (TREE_CODE (t) == CONST_DECL && !processing_template_decl) { used_types_insert (TREE_TYPE (t)); return DECL_INITIAL (t); diff --git a/gcc/testsuite/g++.dg/template/partial13.C b/gcc/testsuite/g++.dg/template/partial13.C new file mode 100644 index 0000000..bfbe2e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial13.C @@ -0,0 +1,25 @@ +// PR c++/45012 + +template struct enable_if; + +template +struct enable_if +{ + typedef T type; +}; + +enum { RUNTIME = 0 }; +// it compiles with the previous line commented out and the next commented in +// static const int RUNTIME=0; + +template struct foo; + +template class V, int M> +struct foo,V, typename enable_if::type> {}; + +template class V1, template class V2, int M> +struct foo,V2, typename enable_if::type> {}; + +template struct bar {}; + +foo,bar<2> > x;