From 1843e1b6a0ac5c62d4a1b3073ddbbce4559147fb Mon Sep 17 00:00:00 2001 From: John Camelon Date: Fri, 6 May 2005 15:17:35 +0000 Subject: [PATCH] Added tess. --- .../tests/ast2/AST2CPPSpecFailingTest.java | 2 ++ .../core/parser/tests/ast2/AST2CPPTests.java | 8 ++++- .../cdt/core/parser/tests/ast2/AST2Tests.java | 30 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java index d59c000ab86..c14c1323c75 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java @@ -1095,4 +1095,6 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest { } catch (Exception e) { } } + + } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 6ee83f532ce..c5b5df7a350 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -3944,7 +3944,6 @@ public class AST2CPPTests extends AST2BaseTest { while( i.hasNext() ) { IASTName n = (IASTName) i.next(); - assertNotNull( n.resolveBinding()); assertFalse( n.resolveBinding() instanceof IProblemBinding ); } } @@ -3962,4 +3961,11 @@ public class AST2CPPTests extends AST2BaseTest { assertEquals( count, sum ); } + public void testBug85786() throws Exception { + IASTTranslationUnit tu = parse( "void f( int ); void foo () { void * p = &f; ( (void (*) (int)) p ) ( 1 ); }", ParserLanguage.C ); //$NON-NLS-1$ + CPPNameCollector nameResolver = new CPPNameCollector(); + tu.accept( nameResolver ); + assertNoProblemBindings( nameResolver ); + } + } 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 44d66fde7e7..89324e0764f 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 @@ -10,6 +10,8 @@ **********************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import java.util.Iterator; + import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; @@ -3082,4 +3084,32 @@ public class AST2Tests extends AST2BaseTest { assertFalse( col.getName( i ).resolveBinding() instanceof IProblemBinding ); } + + public void testBug85786() throws Exception { + IASTTranslationUnit tu = parse( "void f( int ); void foo () { void * p = &f; ( (void (*) (int)) p ) ( 1 ); }", ParserLanguage.C ); //$NON-NLS-1$ + CNameCollector nameResolver = new CNameCollector(); + tu.accept( nameResolver ); + assertNoProblemBindings( nameResolver ); + } + + protected void assertNoProblemBindings(CNameCollector col) { + Iterator i = col.nameList.iterator(); + while( i.hasNext() ) + { + IASTName n = (IASTName) i.next(); + assertFalse( n.resolveBinding() instanceof IProblemBinding ); + } + } + + protected void assertProblemBindings(CNameCollector col, int count ) { + Iterator i = col.nameList.iterator(); + int sum = 0; + while( i.hasNext() ) + { + IASTName n = (IASTName) i.next(); + if( n.getBinding() instanceof IProblemBinding ) + ++sum; + } + assertEquals( count, sum ); + } } \ No newline at end of file