[cfe-commits] r158185 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/typename-specifier.cpp
Kaelyn Uhrain
rikka at google.com
Thu Jun 7 18:07:27 PDT 2012
Author: rikka
Date: Thu Jun 7 20:07:26 2012
New Revision: 158185
URL: http://llvm.org/viewvc/llvm-project?rev=158185&view=rev
Log:
Fix up the 'typename' suggestion logic introduced in r157085, based on
feedback from Doug Gregor.
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/typename-specifier.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=158185&r1=158184&r2=158185&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jun 7 20:07:26 2012
@@ -2453,22 +2453,20 @@
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);
Modified: cfe/trunk/test/SemaTemplate/typename-specifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/typename-specifier.cpp?rev=158185&r1=158184&r2=158185&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/typename-specifier.cpp (original)
+++ cfe/trunk/test/SemaTemplate/typename-specifier.cpp Thu Jun 7 20:07:26 2012
@@ -118,7 +118,7 @@
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 @@
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'?}}
More information about the cfe-commits
mailing list