diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-01-12 17:06:20 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-01-12 17:06:20 +0000 |
commit | 2e9338824f896790ca0766f7505259ce129eb51a (patch) | |
tree | 631d3e6e39c2356009ef928816dddf64931b5b54 | |
parent | 148299f5eb05828937b883e4eba622c3363b4725 (diff) |
When determining whether a given name is a template in a dependent
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
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 5 | ||||
-rw-r--r-- | test/SemaTemplate/typo-dependent-name.cpp | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index c4da5a7f09..d11bf3c064 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -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 index 0000000000..96554e9dcf --- /dev/null +++ b/test/SemaTemplate/typo-dependent-name.cpp @@ -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; + } +}; |