Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2013-09-13 22:02:56 -0400
committerSergey Prigogin2013-09-13 22:07:00 -0400
commit92d4b52f221bc5ef8be24854e2a3d0e517b094d5 (patch)
treecc5c69b214f95285cae613ec4e04a548e96ceda6
parenta5fafa34280bc3da6122d072fd31a67834433d8f (diff)
downloadorg.eclipse.cdt-92d4b52f221bc5ef8be24854e2a3d0e517b094d5.tar.gz
org.eclipse.cdt-92d4b52f221bc5ef8be24854e2a3d0e517b094d5.tar.xz
org.eclipse.cdt-92d4b52f221bc5ef8be24854e2a3d0e517b094d5.zip
Bug 417243 - Organize Includes inserts unnecessary include for the
header declaring a function parameter type
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/includes/BindingClassifierTest.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java3
2 files changed, 15 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/includes/BindingClassifierTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/includes/BindingClassifierTest.java
index 07a096ada9..4c63997f3d 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/includes/BindingClassifierTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/includes/BindingClassifierTest.java
@@ -258,6 +258,18 @@ public class BindingClassifierTest extends OneSourceMultipleHeadersTestCase {
assertDeclared("f");
}
+ // typedef int int32;
+ // void f(int32* p);
+
+ // void test(int i) {
+ // f(&i);
+ // }
+ public void testFunctionCallWithTypedef() throws Exception {
+ getPreferenceStore().setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, false);
+ assertDefined("f");
+ assertDeclared();
+ }
+
// struct A {
// A(void* p);
// };
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java
index ba6a8d5614..22a4a99107 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/BindingClassifier.java
@@ -534,6 +534,9 @@ public class BindingClassifier {
}
private void declareFunction(IFunction function, IASTInitializerClause[] arguments) {
+ if (!canForwardDeclare(function))
+ defineBinding(function);
+
// Handle return or expression type of the function or constructor call.
IType returnType = function.getType().getReturnType();
if (!(returnType instanceof IPointerType) && !(returnType instanceof ICPPReferenceType)) {

Back to the top