From patchwork Sat Nov 5 23:36:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 123896 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 DC775B6F7D for ; Sun, 6 Nov 2011 10:37:14 +1100 (EST) Received: (qmail 10944 invoked by alias); 5 Nov 2011 23:37:11 -0000 Received: (qmail 10913 invoked by uid 22791); 5 Nov 2011 23:37:05 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CX, TW_YP 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, 05 Nov 2011 23:36:40 +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 pA5Nado7023719 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 5 Nov 2011 19:36:39 -0400 Received: from localhost (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pA5NabGP003349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 5 Nov 2011 19:36:38 -0400 Received: by localhost (Postfix, from userid 500) id 4C14029C12B; Sun, 6 Nov 2011 00:36:35 +0100 (CET) From: Dodji Seketeli To: Jason Merrill Cc: GCC Patches , Benjamin De Kosnik Subject: Re: [C++ PATCH] PR c++/45114 - Support alias templates References: <4EA9CB03.5060708@redhat.com> X-URL: http://www.redhat.com Date: Sun, 06 Nov 2011 00:36:35 +0100 In-Reply-To: <4EA9CB03.5060708@redhat.com> (Jason Merrill's message of "Thu, 27 Oct 2011 17:20:03 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 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 Jason Merrill writes: > On 10/27/2011 03:10 PM, Dodji Seketeli wrote: > > +/* Setter for the TYPE_DECL_ALIAS_P proprety above. */ > > +#define SET_TYPE_DECL_ALIAS_P(NODE, VAL) \ > > + (DECL_LANG_FLAG_6 (TYPE_DECL_CHECK (NODE)) = (VAL)) > > This seems unnecessary. Removed. > > > +#define TYPE_DECL_NAMES_ALIAS_TEMPLATE_P(NODE) \ > > + (TYPE_DECL_ALIAS_P (NODE) \ > > + && DECL_LANG_SPECIFIC (NODE) \ > > + && DECL_TI_TEMPLATE (NODE) \ > > + && same_type_p (TREE_TYPE (NODE), TREE_TYPE (DECL_TI_TEMPLATE (NODE)))) > > I don't think same_type_p is the test you want here, as it ignores > typedefs. How about > > DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (NODE)) == (NODE) Right. Changed. > ? > > > +#define TYPE_ALIAS_P(NODE) \ > > + (TYPE_P (NODE) \ > > + && DECL_LANG_SPECIFIC (TYPE_NAME (NODE)) \ > > + && TYPE_DECL_ALIAS_P (TYPE_NAME (NODE))) > > Why check DECL_LANG_SPECIFIC? I removed the check. > > > + /*If T is a specialization of an alias template, then we don't > > + want to take this 'if' branch; we want to print it as if it > > + was a specialization of class template. */ > > I think we want to handle them specially within this if. Done. > > > - else if (same_type_p (t, TREE_TYPE (decl))) > > + else if (same_type_p (t, TREE_TYPE (decl)) > > + && /* If T is the type of an alias template then we > > + want to let dump_decl print it like an alias > > + template. */ > > + TYPE_DECL_NAMES_ALIAS_TEMPLATE_P (decl)) > > This change restricts the existing test to only apply to alias > templates. Removed. > > Also, I would think we would want to handle the uninstantiated alias > the same as instantiations. In the updated patch below, uninstantiated aliase types follow the same path as typedefs and are handled specifically by dump_decl, whereas alias instantiations are handled by the new dump_alias_template_specialization that knows how to handle class and non-class alias template instantiations. Is that bad? > > You need some tests for printing of aliases in error messages. Only > one of the current tests prints an alias: > > > /home/jason/gt/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C:5:26: error: partial specialization of alias template 'using AA0 = struct A0' > > This should have the template header. So here: > > > + if (DECL_ALIAS_TEMPLATE_P (TI_TEMPLATE (get_template_info > (type)))) > > + { > > + error ("partial specialization of alias template %qD", > > + TYPE_NAME (type)); > > + return error_mark_node; > > + } > > We should pass the template to error, rather than the > instantiation. But when I try that I see that it prints > > template struct AA0 > > instead, so more fixing is needed. Right. I tried to add more tests for that, and fixed many little things here and there to get better printing. > > > + else if (DECL_ALIAS_TEMPLATE_P (t)) > > + { > > + tree tmpl; > > + result = get_aliased_type (DECL_TEMPLATE_RESULT (t)); > > + tmpl = TI_TEMPLATE (get_template_info (result)); > > + /* If RESULT is just the naming of TMPL, return TMPL. */ > > + if (same_type_p (result, > > + TREE_TYPE (DECL_TEMPLATE_RESULT (tmpl)))) > > + result = tmpl; > > + } > > What is this trying to achieve? When we pass in a template, sometimes > it returns a type and sometimes a template? That seems odd. This is gone now, as it was for stripping aliases and I removed it now, see below. > > > + else > > + /* Strip template aliases from TEMPLATE_DECL nodes, > > + similarly to what is done by > > + canonicalize_type_argument for types above. */ > > + val = strip_alias (val); > > I don't think this is right. Alias templates are never deduced, but > that doesn't seem to mean that they can't be used as template template > arguments. Both clang and EDG accept this testcase: > > template struct same; > template struct same {}; > > template using Ptr = T*; > template