]> granicus.if.org Git - clang/commitdiff
When determining whether a given name is a template in a dependent
authorDouglas Gregor <dgregor@apple.com>
Tue, 12 Jan 2010 17:06:20 +0000 (17:06 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 12 Jan 2010 17:06:20 +0000 (17:06 +0000)
context, do not attempt typo correction. This harms performance (as
Abramo noted) and can cause some amusing errors, as in this new
testcase.

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

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/typo-dependent-name.cpp [new file with mode: 0644]

index c4da5a7f09ebc0c2dbad8305688ff330ba55f9a8..d11bf3c0645851f89fffec0ddf03e6c08c02b33a 100644 (file)
@@ -194,7 +194,8 @@ void Sema::LookupTemplateName(LookupResult &Found,
       ObjectTypeSearchedInScope = true;
     }
   } else if (isDependent) {
-    // We cannot look into a dependent object type or
+    // We cannot look into a dependent object type or nested nme
+    // specifier.
     return;
   } else {
     // Perform unqualified name lookup in the current scope.
@@ -205,7 +206,7 @@ void Sema::LookupTemplateName(LookupResult &Found,
   assert(!Found.isAmbiguous() &&
          "Cannot handle template name-lookup ambiguities");
 
-  if (Found.empty()) {
+  if (Found.empty() && !isDependent) {
     // If we did not find any names, attempt to correct any typos.
     DeclarationName Name = Found.getLookupName();
     if (CorrectTypo(Found, S, &SS, LookupCtx)) {
diff --git a/test/SemaTemplate/typo-dependent-name.cpp b/test/SemaTemplate/typo-dependent-name.cpp
new file mode 100644 (file)
index 0000000..96554e9
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct Base {
+  T inner;
+};
+
+template<typename T>
+struct X {
+  template<typename U>
+  struct Inner {
+  };
+
+  bool f(T other) {
+    return this->inner < other;
+  }
+};