mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 04:15:35 +02:00
233889: pointer-to-member declarations in parameter contexts are not typed correctly
This commit is contained in:
parent
cba281ab15
commit
e50931293e
3 changed files with 40 additions and 3 deletions
|
@ -5764,4 +5764,35 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
IASTProblemDeclaration pdecl= getDeclaration(ls, 1);
|
IASTProblemDeclaration pdecl= getDeclaration(ls, 1);
|
||||||
assertEquals("+error", pdecl.getRawSignature());
|
assertEquals("+error", pdecl.getRawSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// class C;
|
||||||
|
// void func(void (C::*m)(int) const);
|
||||||
|
public void test233889_a() throws Exception {
|
||||||
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
|
ICPPFunction func= bh.assertNonProblem("func(", 4, ICPPFunction.class);
|
||||||
|
assertEquals(1,func.getParameters().length);
|
||||||
|
IType type= func.getParameters()[0].getType();
|
||||||
|
ICPPPointerToMemberType ptm= assertInstance(type, ICPPPointerToMemberType.class);
|
||||||
|
ICPPFunctionType t= ((ICPPFunctionType)ptm.getType());
|
||||||
|
assertTrue(t.isConst());
|
||||||
|
}
|
||||||
|
|
||||||
|
// struct C {
|
||||||
|
// int m1(int a);
|
||||||
|
// int m2(int a) const;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// C* func(int (C::*m)(int) const);
|
||||||
|
// C* func(int (C::*m)(int));
|
||||||
|
//
|
||||||
|
// void ref() {
|
||||||
|
// func(&C::m1);
|
||||||
|
// func(&C::m2);
|
||||||
|
// }
|
||||||
|
public void testBug233889_b() throws Exception {
|
||||||
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
|
ICPPFunction fn1= bh.assertNonProblem("func(&C::m1", 4, ICPPFunction.class);
|
||||||
|
ICPPFunction fn2= bh.assertNonProblem("func(&C::m2", 4, ICPPFunction.class);
|
||||||
|
assertNotSame(fn1, fn2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2055,7 +2055,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// func(c, &C::m1);
|
// func(c, &C::m1);
|
||||||
// func(d, &C::m2);
|
// func(d, &C::m2);
|
||||||
// }
|
// }
|
||||||
public void _testBug233889() throws Exception {
|
public void testBug233889() throws Exception {
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
ICPPFunction fn1= bh.assertNonProblem("func(c", 4, ICPPFunction.class);
|
ICPPFunction fn1= bh.assertNonProblem("func(c", 4, ICPPFunction.class);
|
||||||
ICPPFunction fn2= bh.assertNonProblem("func(d", 4, ICPPFunction.class);
|
ICPPFunction fn2= bh.assertNonProblem("func(d", 4, ICPPFunction.class);
|
||||||
|
|
|
@ -1564,6 +1564,13 @@ public class CPPVisitor {
|
||||||
|
|
||||||
IScope scope = fnDtor.getFunctionScope();
|
IScope scope = fnDtor.getFunctionScope();
|
||||||
IType thisType= getThisType(scope);
|
IType thisType= getThisType(scope);
|
||||||
|
IASTDeclarator nested = fnDtor.getNestedDeclarator();
|
||||||
|
if(thisType == null && nested != null) {
|
||||||
|
IType pts= getPointerTypes(new CPPBasicType(-1,-1), nested);
|
||||||
|
if(pts instanceof ICPPPointerToMemberType) {
|
||||||
|
thisType= new CPPPointerType(((ICPPPointerToMemberType)pts).getMemberOfClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (thisType instanceof IPointerType) {
|
if (thisType instanceof IPointerType) {
|
||||||
try {
|
try {
|
||||||
IType classType = ((IPointerType) thisType).getType();
|
IType classType = ((IPointerType) thisType).getType();
|
||||||
|
@ -1574,7 +1581,6 @@ public class CPPVisitor {
|
||||||
thisType = null;
|
thisType = null;
|
||||||
}
|
}
|
||||||
IType type = new CPPFunctionType(returnType, pTypes, (IPointerType) thisType);
|
IType type = new CPPFunctionType(returnType, pTypes, (IPointerType) thisType);
|
||||||
IASTDeclarator nested = fnDtor.getNestedDeclarator();
|
|
||||||
if (nested != null) {
|
if (nested != null) {
|
||||||
return createType(type, nested);
|
return createType(type, nested);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue