зеркало из https://github.com/microsoft/clang-1.git
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:
Родитель
31fec98c2a
Коммит
8d1c9ae5d2
|
@ -383,6 +383,8 @@ def note_ambig_member_ref_object_type : Note<
|
||||||
"lookup in the object type %0 refers here">;
|
"lookup in the object type %0 refers here">;
|
||||||
def note_ambig_member_ref_scope : Note<
|
def note_ambig_member_ref_scope : Note<
|
||||||
"lookup from the current scope refers here">;
|
"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
|
// C++ class members
|
||||||
def err_storageclass_invalid_for_member : Error<
|
def err_storageclass_invalid_for_member : Error<
|
||||||
|
|
|
@ -2184,6 +2184,12 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
|
||||||
// If the member name was a qualified-id, look into the
|
// If the member name was a qualified-id, look into the
|
||||||
// nested-name-specifier.
|
// nested-name-specifier.
|
||||||
DC = computeDeclContext(*SS, false);
|
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
|
// FIXME: If DC is not computable, we should build a
|
||||||
// CXXUnresolvedMemberExpr.
|
// CXXUnresolvedMemberExpr.
|
||||||
|
|
|
@ -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}} \
|
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}}
|
// 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'}}
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче