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 4e1eaafe4a6..ab4ab50e37b 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 @@ -97,6 +97,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification; @@ -10701,4 +10702,23 @@ public class AST2CPPTests extends AST2TestBase { IVariable waldo = helper.assertNonProblem("waldo"); assertEquals(42, waldo.getInitialValue().numericalValue().longValue()); } + + // struct S1 { S1(int); }; + // struct S2 { void operator()(int); }; + // S2 s2; + // int main() { + // S1(42); + // s2(43); + // } + public void testICPPASTFunctionCallExpression_getOverload_441701() throws Exception { + BindingAssertionHelper helper = getAssertionHelper(); + + ICPPASTFunctionCallExpression call1 = helper.assertNode("S1(42)"); + ICPPFunction constructor = helper.assertNonProblem("S1(int)", "S1"); + assertEquals(constructor, call1.getOverload()); + + ICPPASTFunctionCallExpression call2 = helper.assertNode("s2(43)"); + ICPPFunction operator = helper.assertNonProblem("operator()"); + assertEquals(operator, call2.getOverload()); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java index ea0636b2e8d..dad3526b7b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java @@ -29,4 +29,11 @@ public interface ICPPASTFunctionCallExpression */ @Override ICPPASTFunctionCallExpression copy(CopyStyle style); + + /** + * Returns the function binding for the overloaded operator() invoked by + * the function call, or null if the operator() is not overloaded. + * @since 5.8 + */ + public ICPPFunction getOverload(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java index c95dc72e566..67144bd24a1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java @@ -259,6 +259,7 @@ public class CPPASTFunctionCallExpression extends ASTNode } } + @Override public ICPPFunction getOverload() { ICPPEvaluation eval = getEvaluation(); if (eval instanceof EvalFunctionCall)