<div dir="ltr"><div style>Hi All,</div><div style><br></div><div style>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 .</div>
















<div style><br></div><div style>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:</div>
<div><br></div><div>  test/SemaTemplate/ms-function-specialization-class-scope.cpp:55:4: error:</div><div>      unknown type name 'T'</div><div>          T a = 3;</div><div>          ^</div><div><br></div><div style>
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?</div>
<div style><br></div><div style>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.</div>
<div style><br></div><div style>- Will.</div><div style><br></div>
</div>