1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 519473 Fixed member function calling with references

Change-Id: I86d1dfacb6f842be688bfdaf2a6a0faf0ffade09
Signed-off-by: Bassem Girgis <brgirgis@gmail.com>
This commit is contained in:
Bassem Girgis 2018-10-08 02:29:07 -05:00 committed by Nathan Ridge
parent 631ee3a6fb
commit 9c04b1bcf7
2 changed files with 25 additions and 1 deletions

View file

@ -41,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
@ -127,9 +128,15 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
if (!actualConstructorFields.isEmpty()) {
IASTFunctionCallExpression fCall = (IASTFunctionCallExpression) expression;
IASTExpression fNameExp = fCall.getFunctionNameExpression();
IBinding fBinding = null;
if (fNameExp instanceof IASTIdExpression) {
IASTIdExpression fName = (IASTIdExpression) fNameExp;
IBinding fBinding = fName.getName().resolveBinding();
fBinding = fName.getName().resolveBinding();
} else if (fNameExp instanceof ICPPASTFieldReference) {
ICPPASTFieldReference fName = (ICPPASTFieldReference) fNameExp;
fBinding = fName.getFieldName().resolveBinding();
}
if (fBinding != null) {
if (fBinding instanceof ICPPMethod) {
ICPPMethod method = (ICPPMethod) fBinding;
ICompositeType constructorOwner = actualConstructorFields.iterator().next().getCompositeTypeOwner();

View file

@ -647,4 +647,21 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
// class ClassWithWarning {
// public:
// ClassWithWarning(char* n) {
// this->initClass(n);
// }
//
// private:
// char *name;
// void initClass(char *name) {
// this->name = name;
// }
// };
public void testMemberFunctionCalling_519473() throws Exception {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
}