[cfe-commits] [PATCH][MS][Review request] - Microsoft function specialization at scope scope

Francois Pichet pichet2000 at gmail.com
Thu Jun 16 19:42:03 PDT 2011

On Thu, Jun 16, 2011 at 9:52 PM, John McCall <rjmccall at apple.com> wrote:
> On Jun 16, 2011, at 6:26 PM, Francois Pichet wrote:
>> I struggled getting this patch right and I am not confident enough to
>> submit it directly without review so here it is:
>> Template function specialization at class scope for -fms-extensions
>> Example:
>> template <class T>
>> class B {
>> public:
>>   template <class U>
>>   void f(U p) {   }
>>   template <>
>>    void f(int p) {    }  // <= not standard C++, Microsoft extension
>> };
>> As Doug suggested to me on the IRC chat, I created a new Decl node:
>> ClassScopeFunctionSpecializationDecl
>> This node hold a temporary CXXMethodDecl and it will use it to create
>> an explicit specialization during class instantiation.
> Can you explain the need to do this rather than simply making this
> a FunctionTemplateSpecializationDecl, like it would be at global
> scope?  There's already code in SemaTemplateInstantiateDecl for
> instantiating such things;  I'm sure it would need to be changed,
> but...
> John.

What is a FunctionTemplateSpecializationDecl? I can't find it.
I suppose you mean a FunctionDecl whose TemplateOrSpecialization
member is a FunctionTemplateSpecializationInfo?

The problem is that you cannot call
CheckFunctionTemplateSpecialization inside a dependent context
otherwise you'll assert somewhere inside DeduceTemplateArguments.

As such, the idea is to postpone CheckFunctionTemplateSpecialization
until you are no longer inside a dependent context. I tried many
approaches that failed until dgregor suggested to me to create that
ClassScopeFunctionSpecializationDecl node and to spawn the
specialization during class instantiation.

does that answer your question?

More information about the cfe-commits mailing list