[PATCH] ClassScopeFunctionSpecializationDecl issue with -fdelayed-template-parsing

Richard Smith richard at metafoo.co.uk
Fri Apr 26 08:23:21 PDT 2013


Change LGTM, thanks.

+    if (ClassTemplatePartialSpecializationDecl* MD =
+
 dyn_cast_or_null<ClassTemplatePartialSpecializationDecl>(*II)) {
+      TemplateParamScopeStack.push_back(new ParseScope(this,
+
Scope::TemplateParamScope));
+      Actions.ActOnReenterTemplateScope(getCurScope(), MD);
+    } else if (CXXRecordDecl* MD = dyn_cast_or_null<CXXRecordDecl>(*II)) {
+      TemplateParamScopeStack.push_back(new ParseScope(this,
+
 Scope::TemplateParamScope,
+                                     MD->getDescribedClassTemplate() != 0
));

Can you fix the formatting of this code too? :) There's some strange
indentation here (probably due to 80-column limits) and an extra space
after the 0. Also a typo "outmost" should be "outermost".


On Wed, Apr 24, 2013 at 3:42 AM, Will Wilson <will at indefiant.com> wrote:

> *ping* Anyone available for a quick review of this patch?
>
> Cheers,
> Will.
>
>
> On 19 April 2013 21:18, Will Wilson <will at indefiant.com> wrote:
>
>> Hi All,
>>
>> This patch attempts to resolve an issue seen when a CXXMethodDecl
>> (produced via a ClassScopeFunctionSpecializationDecl) is encountered
>> with -fdelayed-template-parsing enabled. This is needed to successfully
>> compile the VS2012 xlocnum header (see: class numpunct) which is used by a
>> number of other core MS STL headers .
>>
>> The existing logic in Parser::ParseLateTemplatedFuncDef() uses a special
>> case if the FunctionDecl was a Declarator with template parameter lists, in
>> which case most of the parent scope was ignored. Unfortunately this is the
>> code path used by CXXMethodDecl's generated from
>> ClassScopeFunctionSpecializationDecl's. This would break name lookup for
>> parameter's named in the parent context:
>>
>>   test/SemaTemplate/ms-function-specialization-class-scope.cpp:55:4:
>> error:
>>       unknown type name 'T'
>>           T a = 3;
>>           ^
>>
>> The approach I've taken may be missing a lower-level issue, as it simply
>> attempts to ensure the parent lookup scope is always restored. Oddly, there
>> seems to be a number of checks for ClassTemplatePartialSpecializationDecl
>> in the delayed template parsing code that never get called - is
>> this evidence that the design changed at some time?
>>
>> Either way, this patch seems to resolve the issue and passes all existing
>> tests. I've also added an additional test run to
>> ms-function-specialization-class-scope.cpp with -fdelayed-template-parsing
>> enabled in order to reproduce the original issue.
>>
>> - Will.
>>
>>
>
>
> --
> *Indefiant Ltd.*
> *
> *
> Firsby Lodge, New Main Road, Scamblesby, Louth, Lincs LN11 9XH UK
> *Tel: +44 20 8123 7663 England Registered No. 07936820 VAT No. **128556202
> *
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130426/034a0073/attachment.html>


More information about the cfe-commits mailing list