Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-03-06 04:59:30 -0500
committerMarkus Schorn2008-03-06 04:59:30 -0500
commit853bc59800b002cff35b522fc350573699669ab0 (patch)
treee95e7b3941ddeadd638debc334af99ff9c0ab2e3
parentf0dc504bd516c9c4d2fdc963cc2824d43cf67cb0 (diff)
downloadorg.eclipse.cdt-853bc59800b002cff35b522fc350573699669ab0.tar.gz
org.eclipse.cdt-853bc59800b002cff35b522fc350573699669ab0.tar.xz
org.eclipse.cdt-853bc59800b002cff35b522fc350573699669ab0.zip
Index based name-resolution for K&R-style functions, bug 221635.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java2
2 files changed, 22 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java
index ee67cc641ee..bb1e930e5f1 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java
@@ -327,4 +327,25 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
assertTrue(tAST.isSameType(tIndex));
assertTrue(tIndex.isSameType(tAST));
}
+
+ // int myFunc();
+
+ // int myFunc(var)
+ // int var;
+ // {
+ // return var;
+ // }
+ // int main(void) {
+ // return myFunc(0);
+ // }
+ public void testKRStyleFunction_Bug216791() throws DOMException {
+ // struct
+ IBinding b = getBindingFromASTName("myFunc(", 6);
+ assertTrue(b instanceof IFunction);
+ IFunction f= (IFunction) b;
+ IParameter[] params= f.getParameters();
+ assertEquals(1, params.length);
+ assertTrue(params[0].getType() instanceof IBasicType);
+ assertEquals(IBasicType.t_int, ((IBasicType)params[0].getType()).getType());
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
index 705598926bd..42802a4c236 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
@@ -797,7 +797,7 @@ public class CVisitor {
IASTNode parent = declarator.getParent();
if ( CharArrayUtils.equals(declarator.getName().toCharArray(), name.toCharArray()) ){
binding = resolveBinding( parent, CURRENT_SCOPE );
- if( binding != null ) {
+ if( binding != null && binding instanceof IIndexBinding == false) {
if( binding instanceof ICInternalFunction )
((ICInternalFunction)binding).addDeclarator( (ICASTKnRFunctionDeclarator) declarator );
else

Back to the top