diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index c30f1317447..98fa2ea91e0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -5764,4 +5764,35 @@ public class AST2CPPTests extends AST2BaseTest { IASTProblemDeclaration pdecl= getDeclaration(ls, 1); 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); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index d5c0ea77faf..46ce31dbf4a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -2055,7 +2055,7 @@ public class AST2TemplateTests extends AST2BaseTest { // func(c, &C::m1); // func(d, &C::m2); // } - public void _testBug233889() throws Exception { + public void testBug233889() throws Exception { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); ICPPFunction fn1= bh.assertNonProblem("func(c", 4, ICPPFunction.class); ICPPFunction fn2= bh.assertNonProblem("func(d", 4, ICPPFunction.class); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index 9338023e7cc..d4526456ba4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -1563,7 +1563,14 @@ public class CPPVisitor { } 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) { try { IType classType = ((IPointerType) thisType).getType(); @@ -1574,7 +1581,6 @@ public class CPPVisitor { thisType = null; } IType type = new CPPFunctionType(returnType, pTypes, (IPointerType) thisType); - IASTDeclarator nested = fnDtor.getNestedDeclarator(); if (nested != null) { return createType(type, nested); }