[cfe-commits] [PATCH] Implement C++11 alias templates

Richard Smith richard at metafoo.co.uk
Thu May 5 15:29:39 PDT 2011


On Thu, May 5, 2011 21:06, Sebastian Redl wrote:
> On 03.05.2011, at 23:00, Richard Smith wrote:
>> On Thu, April 28, 2011 22:02, Richard Smith wrote:
>>> The attached patch implements C++11 alias templates.
>>>
>>>
>>> I've added a new Decl node for alias templates:
>>> TypeAliasTemplateDecl.
>>> Alias template specialization types also need to track the
>>> non-canonicalized aliased type, so I've extended
>>> TemplateSpecializationType
>>> to store a non-canonical QualType in the case where it refers to an
>>> alias template.
>> [...]
>>
>>
>> I noticed that AST serialization support was missing from the previous
>> patch. Attached is a diff to apply on top of the previous patch to
>> implement such support, and a complete patch rebased to ToT.
>>
>> Review comments appreciated!
>
> Awesome! Very thorough test cases.
>
>
> One tiny little question, but this is ready to commit either way.

Great, I've checked it in as r130953.

>> Index: test/CXX/temp/temp.decls/p3.cpp
>> ===================================================================
>> --- test/CXX/temp/temp.decls/p3.cpp	(revision 0)
>> +++ test/CXX/temp/temp.decls/p3.cpp	(revision 0)
>> @@ -0,0 +1,8 @@
>> +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
>> +
>> +template<typename T> using A = int;
>> +template<typename T> using A<T*> = char; // expected-error {{partial
>> specialization of alias templates is not permitted}} +template<> using
>> A<char> = char; // expected-error {{explicit specialization of alias
>> templates is not permitted}} +template using A<char> = char; //
>> expected-error {{explicit instantiation of alias templates is not
>> permitted}} +// Best guess as to what the user was trying to do: missing
>> template<>. +using A<char> = char; // expected-error {{partial
>> specialization of alias templates is not permitted}}
>
> If the user is missing template<>, wouldn't that be a full specialization
> and thus should say "explicit specialization" in the error message?

Yes, either that or "explicit instantiation" if we think just 'template'
is missing. But 'partial specialization' is certainly not ideal wording.
I'll switch this to "name defined in alias declaration must be an
identifier" wording in a follow-up commit.

Thanks,
Richard





More information about the cfe-commits mailing list