1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 16:55:38 +02:00

Bug 415914 - Organize Includes doesn't add include for a constructor

call
This commit is contained in:
Sergey Prigogin 2013-08-26 13:15:02 -07:00
parent ecdbe69720
commit 50c5677fcf
2 changed files with 42 additions and 8 deletions

View file

@ -258,6 +258,37 @@ public class BindingClassifierTest extends OneSourceMultipleHeadersTestCase {
assertDeclared("f");
}
// struct A {
// A(void* p);
// };
// void test() {
// A(nullptr);
// }
public void testConstructorCall() throws Exception {
getPreferenceStore().setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
// A header declaring the function is not responsible for defining the parameter type since
// the implicit conversion from B to A is provided externally to parameter type.
assertDefined("A");
assertDeclared();
}
// struct A {
// A(void* p);
// };
// typedef A B;
// void test() {
// B(nullptr);
// }
public void testConstructorCallWithTypedef() throws Exception {
getPreferenceStore().setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
// A header declaring the function is not responsible for defining the parameter type since
// the implicit conversion from B to A is provided externally to parameter type.
assertDefined("B");
assertDeclared();
}
// struct A {
// A(const B& b);
// };

View file

@ -1030,7 +1030,9 @@ public class BindingClassifier {
IBinding binding = ((IASTIdExpression) functionNameExpression).getName().resolveBinding();
if (binding instanceof IFunction) {
declareFunction((IFunction) binding, functionCallExpression);
} else if (functionCallExpression instanceof IASTImplicitNameOwner) {
} else if (binding instanceof IType) {
defineBinding(binding);
if (functionCallExpression instanceof IASTImplicitNameOwner) {
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) functionCallExpression).getImplicitNames();
for (IASTName name : implicitNames) {
binding = name.resolveBinding();
@ -1040,6 +1042,7 @@ public class BindingClassifier {
}
}
}
}
} else if (expression instanceof IASTFieldReference) {
/*
* The type of the expression part of a field reference always requires a definition.