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:
parent
f013413676
commit
ec3395e78d
2 changed files with 26 additions and 4 deletions
|
@ -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 */
|
||||
/* ##################################################################### */
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
|
|||
|
||||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue