aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDecl.cpp25
-rw-r--r--test/SemaTemplate/class-template-decl.cpp1
-rw-r--r--test/SemaTemplate/member-access-ambig.cpp10
3 files changed, 28 insertions, 8 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index c7873fa068..f554cffba9 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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.
diff --git a/test/SemaTemplate/class-template-decl.cpp b/test/SemaTemplate/class-template-decl.cpp
index 2e84e93ead..38b1778abf 100644
--- a/test/SemaTemplate/class-template-decl.cpp
+++ b/test/SemaTemplate/class-template-decl.cpp
@@ -74,3 +74,4 @@ namespace PR8001 {
Foo<int>::Bar<int> y(x);
}
}
+
diff --git a/test/SemaTemplate/member-access-ambig.cpp b/test/SemaTemplate/member-access-ambig.cpp
index bf190435ec..f8a01d5fff 100644
--- a/test/SemaTemplate/member-access-ambig.cpp
+++ b/test/SemaTemplate/member-access-ambig.cpp
@@ -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;
+ };
+}
+