aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2012-06-08 01:07:26 +0000
committerKaelyn Uhrain <rikka@google.com>2012-06-08 01:07:26 +0000
commit8c14de83188640bab9cae658e92a655e6d4fd484 (patch)
treefaa48ed1c270145601b580dea42933036785e9fa
parentc0838d2acb498b0491908d3693514dfec5befe6f (diff)
Fix up the 'typename' suggestion logic introduced in r157085, based on
feedback from Doug Gregor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158185 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaTemplate.cpp20
-rw-r--r--test/SemaTemplate/typename-specifier.cpp5
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index dccb4b6a61..9cfd9c31e5 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -2453,22 +2453,20 @@ bool Sema::CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
NameInfo = ArgExpr->getNameInfo();
} else if (CXXDependentScopeMemberExpr *ArgExpr =
dyn_cast<CXXDependentScopeMemberExpr>(Arg.getAsExpr())) {
- SS.Adopt(ArgExpr->getQualifierLoc());
- NameInfo = ArgExpr->getMemberNameInfo();
+ if (ArgExpr->isImplicitAccess()) {
+ SS.Adopt(ArgExpr->getQualifierLoc());
+ NameInfo = ArgExpr->getMemberNameInfo();
+ }
}
- if (NameInfo.getName()) {
+ if (NameInfo.getName().isIdentifier()) {
LookupResult Result(*this, NameInfo, LookupOrdinaryName);
LookupParsedName(Result, CurScope, &SS);
- bool CouldBeType = Result.getResultKind() ==
- LookupResult::NotFoundInCurrentInstantiation;
-
- for (LookupResult::iterator I = Result.begin(), IEnd = Result.end();
- !CouldBeType && I != IEnd; ++I) {
- CouldBeType = isa<TypeDecl>(*I);
- }
- if (CouldBeType) {
+ if (Result.getAsSingle<TypeDecl>() ||
+ Result.getResultKind() ==
+ LookupResult::NotFoundInCurrentInstantiation) {
+ // FIXME: Add a FixIt and fix up the template argument for recovery.
SourceLocation Loc = AL.getSourceRange().getBegin();
Diag(Loc, diag::err_template_arg_must_be_type_suggest);
Diag(Param->getLocation(), diag::note_template_param_here);
diff --git a/test/SemaTemplate/typename-specifier.cpp b/test/SemaTemplate/typename-specifier.cpp
index 1d38926c0e..15c13e3bef 100644
--- a/test/SemaTemplate/typename-specifier.cpp
+++ b/test/SemaTemplate/typename-specifier.cpp
@@ -118,7 +118,7 @@ namespace PR10925 {
namespace missing_typename {
-template <class T1, class T2> struct pair {}; // expected-note 5 {{template parameter is declared here}}
+template <class T1, class T2> struct pair {}; // expected-note 7 {{template parameter is declared here}}
template <class T1, class T2>
struct map {
@@ -132,10 +132,13 @@ class ExampleClass1 {
struct ExampleItemSet {
typedef ExampleItem* iterator;
+ ExampleItem* operator[](unsigned);
};
void foo() {
pair<ExampleItemSet::iterator, int> i; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}}
+ pair<this->ExampleItemSet::iterator, int> i; // expected-error-re {{template argument for template type parameter must be a type$}}
+ pair<ExampleItemSet::operator[], int> i; // expected-error-re {{template argument for template type parameter must be a type$}}
}
pair<ExampleItemSet::iterator, int> elt; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}}