diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 52d823202e6..8502e818671 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -2941,4 +2941,15 @@ public class AST2Tests extends AST2BaseTest { ICPPASTCastExpression.op_dynamic_cast); } + + public void testBug86766() throws Exception { + IASTTranslationUnit tu = parse("char foo; void foo(){}", ParserLanguage.C); //$NON-NLS-1$ + CNameCollector col = new CNameCollector(); + tu.getVisitor().visitTranslationUnit( col); + + IVariable foo = (IVariable) col.getName(0).resolveBinding(); + IProblemBinding prob = (IProblemBinding) col.getName(1).resolveBinding(); + assertEquals( prob.getID(), IProblemBinding.SEMANTIC_INVALID_OVERLOAD ); + assertNotNull( foo ); + } } \ No newline at end of file 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 f2c2faeabb3..37696689bb6 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 @@ -640,7 +640,10 @@ public class CVisitor implements ICASTVisitor { if( declarator instanceof IASTStandardFunctionDeclarator ){ binding = resolveBinding( parent, CURRENT_SCOPE ); if( binding != null ) { - ((CFunction)binding).addDeclarator( (IASTStandardFunctionDeclarator) declarator ); + if( binding instanceof IFunction ) + ((CFunction)binding).addDeclarator( (IASTStandardFunctionDeclarator) declarator ); + else + binding = new ProblemBinding( IProblemBinding.SEMANTIC_INVALID_OVERLOAD, name.toCharArray() ); } else { binding = createBinding(declarator); } @@ -648,7 +651,10 @@ public class CVisitor implements ICASTVisitor { if ( CharArrayUtils.equals(declarator.getName().toCharArray(), name.toCharArray()) ){ binding = resolveBinding( parent, CURRENT_SCOPE ); if( binding != null ) { - ((CFunction)binding).addDeclarator( (ICASTKnRFunctionDeclarator) declarator ); + if( binding instanceof IFunction ) + ((CFunction)binding).addDeclarator( (ICASTKnRFunctionDeclarator) declarator ); + else + binding = new ProblemBinding( IProblemBinding.SEMANTIC_INVALID_OVERLOAD, name.toCharArray() ); } else { binding = createBinding(declarator); }