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

Will Wilson will at indefiant.com
Fri Apr 19 12:18:43 PDT 2013


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130419/fcffd3ef/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: latetemplatefunc.patch
Type: application/octet-stream
Size: 4652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130419/fcffd3ef/attachment.obj>


More information about the cfe-commits mailing list