Fix a crash with qualified member access into a non-type, from Sean Hunt!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84370 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2009-10-17 22:37:54 +00:00
Родитель 31fec98c2a
Коммит 8d1c9ae5d2
3 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -383,6 +383,8 @@ def note_ambig_member_ref_object_type : Note<
"lookup in the object type %0 refers here">;
def note_ambig_member_ref_scope : Note<
"lookup from the current scope refers here">;
def err_qualified_member_nonclass : Error<
"qualified member access refers to a member in %0">;
// C++ class members
def err_storageclass_invalid_for_member : Error<

Просмотреть файл

@ -2185,6 +2185,12 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
// nested-name-specifier.
DC = computeDeclContext(*SS, false);
if (!isa<TypeDecl>(DC)) {
Diag(MemberLoc, diag::err_qualified_member_nonclass)
<< DC << SS->getRange();
return ExprError();
}
// FIXME: If DC is not computable, we should build a
// CXXUnresolvedMemberExpr.
assert(DC && "Cannot handle non-computable dependent contexts in lookup");

Просмотреть файл

@ -31,3 +31,14 @@ int f0(B *b) {
return b->f0->f0; // expected-error{{member reference base type 'struct A *()' is not a structure or union}} \
// expected-note{{perhaps you meant to call this function}}
}
int i;
namespace C {
int i;
}
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'}}
}