1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 358282 - Name resolution problem with mismatched 'class' and

'struct'.
This commit is contained in:
Sergey Prigogin 2011-09-20 11:56:07 -07:00
parent f013413676
commit ec3395e78d
2 changed files with 26 additions and 4 deletions

View file

@ -1597,6 +1597,23 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
assertEquals("ns", ref.getOwner().getName());
}
// class A {};
// void f(A a) {}
// struct B {};
// void g(B b) {}
// struct A;
// class B;
//
// void test(A a, B b) {
// f(a);
// g(b);
// }
public void testStructClassMismatch_358282() throws Exception {
getBindingFromASTName("f(a)", 1, ICPPFunction.class);
getBindingFromASTName("g(b)", 1, ICPPFunction.class);
}
/* CPP assertion helpers */
/* ##################################################################### */

View file

@ -226,22 +226,22 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
return false;
}
}
public boolean isSameType(IType type) {
if (type instanceof ITypedef) {
return type.isSameType(this);
}
if (type instanceof PDOMNode) {
PDOMNode node= (PDOMNode) type;
if (node.getPDOM() == getPDOM()) {
return node.getRecord() == getRecord();
}
}
if (type instanceof ICPPClassType && !(type instanceof ProblemBinding)) {
ICPPClassType ctype= (ICPPClassType) type;
if (ctype.getKey() != getKey())
if (getEquivalentKind(ctype) != getEquivalentKind(this))
return false;
char[] nchars = ctype.getNameCharArray();
if (nchars.length == 0) {
@ -255,6 +255,11 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
return false;
}
private static int getEquivalentKind(ICPPClassType classType) {
int key = classType.getKey();
return key == k_class ? k_struct : key;
}
public ICPPBase[] getBases() {
Long key= record + PDOMCPPLinkage.CACHE_BASES;
ICPPBase[] bases= (ICPPBase[]) getPDOM().getCachedResult(key);