]> granicus.if.org Git - clang/commitdiff
Parse dependent template-ids in base clauses and member
authorDouglas Gregor <dgregor@apple.com>
Tue, 12 Jan 2010 17:52:59 +0000 (17:52 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 12 Jan 2010 17:52:59 +0000 (17:52 +0000)
initializers. This isn't actually in the C++ grammar (in any version),
but that's clearly an oversight: both GCC and EDG support this syntax,
and it's used within Boost code. I'll file a core issue proposing
precisely the change made here. Fixes PR6008.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93243 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDeclCXX.cpp
test/SemaTemplate/dependent-base-classes.cpp [new file with mode: 0644]

index 265d0f3e849fe13079d82f41effccd903491eb66..61a494193c79fc2a264df45674c6d4ffd362e253 100644 (file)
@@ -468,7 +468,8 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
   if (Tok.is(tok::annot_template_id)) {
     TemplateIdAnnotation *TemplateId
       = static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
-    if (TemplateId->Kind == TNK_Type_template) {
+    if (TemplateId->Kind == TNK_Type_template ||
+        TemplateId->Kind == TNK_Dependent_template_name) {
       AnnotateTemplateIdTokenAsType(SS);
 
       assert(Tok.is(tok::annot_typename) && "template-id -> type failed");
@@ -1527,12 +1528,12 @@ Parser::MemInitResult Parser::ParseMemInitializer(DeclPtrTy ConstructorDecl) {
   if (Tok.is(tok::annot_template_id)) {
     TemplateIdAnnotation *TemplateId
       = static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
-    if (TemplateId->Kind == TNK_Type_template) {
+    if (TemplateId->Kind == TNK_Type_template ||
+        TemplateId->Kind == TNK_Dependent_template_name) {
       AnnotateTemplateIdTokenAsType(&SS);
       assert(Tok.is(tok::annot_typename) && "template-id -> type failed");
       TemplateTypeTy = Tok.getAnnotationValue();
     }
-    // FIXME. May need to check for TNK_Dependent_template as well.
   }
   if (!TemplateTypeTy && Tok.isNot(tok::identifier)) {
     Diag(Tok, diag::err_expected_member_or_base_name);
diff --git a/test/SemaTemplate/dependent-base-classes.cpp b/test/SemaTemplate/dependent-base-classes.cpp
new file mode 100644 (file)
index 0000000..5697920
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, typename U>
+struct X0 : T::template apply<U> { 
+  X0(U u) : T::template apply<U>(u) { }
+};