]> granicus.if.org Git - clang/commitdiff
When checking a set of template parameter lists against a
authorDouglas Gregor <dgregor@apple.com>
Sun, 15 May 2011 17:27:27 +0000 (17:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 15 May 2011 17:27:27 +0000 (17:27 +0000)
nested-name-specifier, re-evaluate the nested-name-specifier as if we
were entering that context (which we did!), so that we'll resolve a
template-id to a particular class template partial
specialization. Fixes PR9913.

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

lib/Sema/SemaCXXScopeSpec.cpp
lib/Sema/SemaTemplate.cpp
test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp

index ff3890023e52e1b078b7bab8496dc7ea5e108316..61d9e93f2ff596ae67f048ee1b0fde702c45055a 100644 (file)
@@ -423,7 +423,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
       //   class-name or namespace-name. [...]
       //
       // Qualified name lookup into a class will not find a namespace-name,
-      // so we do not need to diagnoste that case specifically. However,
+      // so we do not need to diagnose that case specifically. However,
       // this qualified name lookup may find nothing. In that case, perform
       // unqualified name lookup in the given scope (if available) or
       // reconstruct the result from when name lookup was performed at template
index c31ed017377ccd43dcf4c66f826c73ea389ac220..aaadac2e5f443e79c87d9fb41e57d42706490214 100644 (file)
@@ -1513,8 +1513,13 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
   // by the nested-name-specifier and walking out until we run out of types.
   llvm::SmallVector<QualType, 4> NestedTypes;
   QualType T;
-  if (SS.getScopeRep())
-    T = QualType(SS.getScopeRep()->getAsType(), 0);
+  if (SS.getScopeRep()) {
+    if (CXXRecordDecl *Record 
+              = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS, true)))
+      T = Context.getTypeDeclType(Record);
+    else
+      T = QualType(SS.getScopeRep()->getAsType(), 0);
+  }
   
   // If we found an explicit specialization that prevents us from needing
   // 'template<>' headers, this will be set to the location of that
index a34eccd3f2f6cbf8328b4061216f2c55856f1107..f141e929a9c2c36225ea3ebe2601e43ff4ead6d3 100644 (file)
@@ -166,3 +166,13 @@ namespace PR9877 {
   template<> const int X<1>::Y::Z; // expected-error{{extraneous 'template<>' in declaration of variable 'Z'}}
 }
 
+namespace PR9913 {
+  template<class,class=int>struct S;
+  template<class X>struct S<X> {
+    template<class T> class F;
+  };
+
+  template<class A>
+  template<class B>
+  class S<A>::F{};
+}