Fix IsProvablyNotDerivedFrom to always use record definitions when available.

Gets clang-on-clang passing again.

llvm-svn: 90270
This commit is contained in:
John McCall 2009-12-01 22:28:41 +00:00
parent 732351f732
commit a6d407c296
2 changed files with 20 additions and 5 deletions

View File

@ -711,10 +711,13 @@ static bool IsDependentIdExpression(Sema &SemaRef, const CXXScopeSpec &SS) {
static bool IsProvablyNotDerivedFrom(Sema &SemaRef,
CXXRecordDecl *Record,
const llvm::SmallPtrSet<CXXRecordDecl*, 4> &Bases) {
Record = Record->getCanonicalDecl();
if (Bases.count(Record))
if (Bases.count(Record->getCanonicalDecl()))
return false;
RecordDecl *RD = Record->getDefinition(SemaRef.Context);
if (!RD) return false;
Record = cast<CXXRecordDecl>(RD);
for (CXXRecordDecl::base_class_iterator I = Record->bases_begin(),
E = Record->bases_end(); I != E; ++I) {
CanQualType BaseT = SemaRef.Context.getCanonicalType((*I).getType());
@ -722,9 +725,6 @@ static bool IsProvablyNotDerivedFrom(Sema &SemaRef,
if (!BaseRT) return false;
CXXRecordDecl *BaseRecord = cast<CXXRecordDecl>(BaseRT->getDecl());
if (!BaseRecord->isDefinition())
return false;
if (!IsProvablyNotDerivedFrom(SemaRef, BaseRecord, Bases))
return false;
}

View File

@ -41,3 +41,18 @@ void test2(X *xp) {
xp->::i = 7; // expected-error{{qualified member access refers to a member in the global namespace}}
xp->C::i = 7; // expected-error{{qualified member access refers to a member in namespace 'C'}}
}
namespace test3 {
struct NamespaceDecl;
struct NamedDecl {
void *getIdentifier() const;
};
struct NamespaceDecl : NamedDecl {
bool isAnonymousNamespace() const {
return !getIdentifier();
}
};
}