[PATCH] -fdelayed-template-parsing: handle cases where a late-parsed function is not a direct member of a template, but rather nested inside a class that's a member of a template (PR19613)
Hans Wennborg
hans at chromium.org
Tue Apr 29 18:05:26 PDT 2014
Hi rnk, majnemer,
This patch seems to fix the problem. Please take a look.
http://reviews.llvm.org/D3555
Files:
lib/Parse/ParseTemplate.cpp
test/Parser/DelayedTemplateParsing.cpp
Index: lib/Parse/ParseTemplate.cpp
===================================================================
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -1255,15 +1255,23 @@
new ParseScope(this, Scope::TemplateParamScope));
Actions.ActOnReenterTemplateScope(getCurScope(), MD);
++CurTemplateDepthTracker;
- } else if (CXXRecordDecl *MD = dyn_cast_or_null<CXXRecordDecl>(*II)) {
- bool IsClassTemplate = MD->getDescribedClassTemplate() != 0;
+ } else if (CXXRecordDecl *RD = dyn_cast_or_null<CXXRecordDecl>(*II)) {
+ ClassTemplateDecl *CTD = RD->getDescribedClassTemplate();
+
+ if (!CTD) {
+ if (CXXRecordDecl *Parent = dyn_cast<CXXRecordDecl>(RD->getParent()))
+ CTD = Parent->getDescribedClassTemplate();
+ }
+
+ bool IsClassTemplate = CTD != 0;
TemplateParamScopeStack.push_back(
new ParseScope(this, Scope::TemplateParamScope,
- /*ManageScope*/IsClassTemplate));
- Actions.ActOnReenterTemplateScope(getCurScope(),
- MD->getDescribedClassTemplate());
- if (IsClassTemplate)
+ /*EnteredScope*/IsClassTemplate));
+
+ if (IsClassTemplate) {
+ Actions.ActOnReenterTemplateScope(getCurScope(), CTD);
++CurTemplateDepthTracker;
+ }
}
TemplateParamScopeStack.push_back(new ParseScope(this, Scope::DeclScope));
Actions.PushDeclContext(Actions.getCurScope(), *II);
Index: test/Parser/DelayedTemplateParsing.cpp
===================================================================
--- test/Parser/DelayedTemplateParsing.cpp
+++ test/Parser/DelayedTemplateParsing.cpp
@@ -123,3 +123,31 @@
template <typename T>
auto invalidTrailingRetType() -> Bogus {} // expected-error {{unknown type name 'Bogus'}}
+
+namespace PR19613 {
+
+struct HeapTypeConfig {
+ static void from_bitset();
+};
+
+template <class Config>
+struct TypeImpl {
+ struct BitsetType;
+
+ static void Any() {
+ BitsetType::New();
+ }
+};
+
+template<class Config>
+struct TypeImpl<Config>::BitsetType {
+ static void New() {
+ Config::from_bitset();
+ }
+};
+
+static void f() {
+ TypeImpl<HeapTypeConfig>::Any();
+}
+
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3555.8948.patch
Type: text/x-patch
Size: 2242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140430/a82144b6/attachment.bin>
More information about the cfe-commits
mailing list