When performing name lookup for the previous declaration of a field,

be sure to consider all of the possible lookup results. We were
assert()'ing (but behaving correctly) for unresolved values. Fixes
PR11134 / <rdar://problem/10290422>.

llvm-svn: 142652
This commit is contained in:
Douglas Gregor 2011-10-21 15:47:52 +00:00
parent 99eddc3d92
commit fbf8752597
3 changed files with 28 additions and 8 deletions

View File

@ -8421,16 +8421,25 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
<< 2;
// Check to see if this name was declared as a member previously
NamedDecl *PrevDecl = 0;
LookupResult Previous(*this, II, Loc, LookupMemberName, ForRedeclaration);
LookupName(Previous, S);
assert((Previous.empty() || Previous.isOverloadedResult() ||
Previous.isSingleResult())
&& "Lookup of member name should be either overloaded, single or null");
// If the name is overloaded then get any declaration else get the single
// result
NamedDecl *PrevDecl = Previous.isOverloadedResult() ?
Previous.getRepresentativeDecl() : Previous.getAsSingle<NamedDecl>();
switch (Previous.getResultKind()) {
case LookupResult::Found:
case LookupResult::FoundUnresolvedValue:
PrevDecl = Previous.getAsSingle<NamedDecl>();
break;
case LookupResult::FoundOverloaded:
PrevDecl = Previous.getRepresentativeDecl();
break;
case LookupResult::NotFound:
case LookupResult::NotFoundInCurrentInstantiation:
case LookupResult::Ambiguous:
break;
}
Previous.suppressDiagnostics();
if (PrevDecl && PrevDecl->isTemplateParameter()) {
// Maybe we will complain about the shadowed template parameter.

View File

@ -74,3 +74,4 @@ namespace PR8001 {
Foo<int>::Bar<int> y(x);
}
}

View File

@ -33,3 +33,13 @@ void X::g()
// expected-error{{expected '(' for function-style cast}} \
// expected-error{{expected expression}}
}
namespace PR11134 {
template<typename Derived> class A;
template<typename Derived> class B : A<Derived> {
typedef A<Derived> Base;
using Base::member;
int member;
};
}