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:
parent
631ee3a6fb
commit
9c04b1bcf7
2 changed files with 25 additions and 1 deletions
|
@ -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.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
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.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.ICPPASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
@ -127,9 +128,15 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
||||||
if (!actualConstructorFields.isEmpty()) {
|
if (!actualConstructorFields.isEmpty()) {
|
||||||
IASTFunctionCallExpression fCall = (IASTFunctionCallExpression) expression;
|
IASTFunctionCallExpression fCall = (IASTFunctionCallExpression) expression;
|
||||||
IASTExpression fNameExp = fCall.getFunctionNameExpression();
|
IASTExpression fNameExp = fCall.getFunctionNameExpression();
|
||||||
|
IBinding fBinding = null;
|
||||||
if (fNameExp instanceof IASTIdExpression) {
|
if (fNameExp instanceof IASTIdExpression) {
|
||||||
IASTIdExpression fName = (IASTIdExpression) fNameExp;
|
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) {
|
if (fBinding instanceof ICPPMethod) {
|
||||||
ICPPMethod method = (ICPPMethod) fBinding;
|
ICPPMethod method = (ICPPMethod) fBinding;
|
||||||
ICompositeType constructorOwner = actualConstructorFields.iterator().next().getCompositeTypeOwner();
|
ICompositeType constructorOwner = actualConstructorFields.iterator().next().getCompositeTypeOwner();
|
||||||
|
|
|
@ -647,4 +647,21 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
|
||||||
loadCodeAndRun(getAboveComment());
|
loadCodeAndRun(getAboveComment());
|
||||||
checkNoErrors();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue