mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 10:25:32 +02:00
Patch for Hoda Amer
Core: Solution to bug#43679 : Exceptions in indexer Tests: -Added testBug43679_A() & testBug43679_B() to CompleteParseASTTest -Renamed FailedCompleteParseASTExpressionTest to FailedCompleteParseASTTest -Added FailedCompleteParseASTTest::testBug43503()
This commit is contained in:
parent
c50efc6fd5
commit
16c24c6cc9
6 changed files with 137 additions and 70 deletions
|
@ -3,6 +3,11 @@
|
||||||
modified resources/search/classDecl.cpp & include.h to include more operators and a constructor
|
modified resources/search/classDecl.cpp & include.h to include more operators and a constructor
|
||||||
& destructor
|
& destructor
|
||||||
|
|
||||||
|
2003-09-29 Hoda Amer
|
||||||
|
-Added testBug43679_A() & testBug43679_B() to CompleteParseASTTest
|
||||||
|
-Renamed FailedCompleteParseASTExpressionTest to FailedCompleteParseASTTest
|
||||||
|
-Added FailedCompleteParseASTTest::testBug43503()
|
||||||
|
|
||||||
2003-09-29 Andrew Niefer
|
2003-09-29 Andrew Niefer
|
||||||
added testbug43834() to ParserSymbolTableTest
|
added testbug43834() to ParserSymbolTableTest
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.tests.CompleteParseBaseTest;
|
import org.eclipse.cdt.core.parser.tests.CompleteParseBaseTest;
|
||||||
|
|
||||||
|
@ -24,19 +23,19 @@ import org.eclipse.cdt.core.parser.tests.CompleteParseBaseTest;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FailedCompleteParseASTExpressionTest extends CompleteParseBaseTest
|
public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public FailedCompleteParseASTExpressionTest()
|
public FailedCompleteParseASTTest()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public FailedCompleteParseASTExpressionTest(String name)
|
public FailedCompleteParseASTTest(String name)
|
||||||
{
|
{
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
@ -115,4 +114,20 @@ public class FailedCompleteParseASTExpressionTest extends CompleteParseBaseTest
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
|
assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug43503 () throws Exception {
|
||||||
|
Iterator i = parse("class SD_01 { f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ").getDeclarations();
|
||||||
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
Iterator j = getDeclarations(classA);
|
||||||
|
IASTMethod f = (IASTMethod)j.next();
|
||||||
|
assertFalse(j.hasNext());
|
||||||
|
IASTFunction main = (IASTFunction) i.next();
|
||||||
|
assertFalse(i.hasNext());
|
||||||
|
Iterator k = getDeclarations(main);
|
||||||
|
|
||||||
|
assertFalse(k.hasNext()); // this should be true, there is one declaration of "a"
|
||||||
|
// "a" is found to be in a multiplication expression, not a declaration
|
||||||
|
// not knowing "a" causes us to not find the reference to "f"
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
|
@ -856,4 +857,40 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
assertEquals( b.getName(), "b");
|
assertEquals( b.getName(), "b");
|
||||||
assertFalse(i.hasNext());
|
assertFalse(i.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug43679_A () throws Exception
|
||||||
|
{
|
||||||
|
try{ // this used to throw a null pointer exception
|
||||||
|
Iterator i = parse( "struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ", false ).getDeclarations();
|
||||||
|
IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
Iterator j = getDeclarations(A);
|
||||||
|
IASTMethod s = (IASTMethod) j.next();
|
||||||
|
assertFalse (j.hasNext());
|
||||||
|
IASTFunction g = (IASTFunction) i.next();
|
||||||
|
IASTFunction t = (IASTFunction) i.next();
|
||||||
|
assertFalse (i.hasNext());
|
||||||
|
Iterator ref = callback.getReferences().iterator();
|
||||||
|
assertAllReferences( 3, createTaskList( new Task(A) , new Task( s ) , new Task (g) ));
|
||||||
|
|
||||||
|
} catch(Exception e){
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void testBug43679_B () throws Exception
|
||||||
|
{
|
||||||
|
try{ // this used to throw a class cast exception
|
||||||
|
Iterator i = parse( "struct Sample{int size() const; }; struct Sample; ", false ).getDeclarations();
|
||||||
|
IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
Iterator j = getDeclarations(A);
|
||||||
|
IASTMethod s = (IASTMethod) j.next();
|
||||||
|
assertFalse (j.hasNext());
|
||||||
|
IASTAbstractTypeSpecifierDeclaration forwardDecl = (IASTAbstractTypeSpecifierDeclaration)i.next();
|
||||||
|
assertFalse (i.hasNext());
|
||||||
|
Iterator ref = callback.getReferences().iterator();
|
||||||
|
assertFalse (ref.hasNext());
|
||||||
|
|
||||||
|
} catch(Exception e){
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.model.tests.BinaryTests;
|
||||||
import org.eclipse.cdt.core.model.tests.ElementDeltaTests;
|
import org.eclipse.cdt.core.model.tests.ElementDeltaTests;
|
||||||
import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
|
import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
|
||||||
import org.eclipse.cdt.core.parser.failedTests.ASTFailedTests;
|
import org.eclipse.cdt.core.parser.failedTests.ASTFailedTests;
|
||||||
import org.eclipse.cdt.core.parser.failedTests.FailedCompleteParseASTExpressionTest;
|
import org.eclipse.cdt.core.parser.failedTests.FailedCompleteParseASTTest;
|
||||||
import org.eclipse.cdt.core.parser.failedTests.STLFailedTests;
|
import org.eclipse.cdt.core.parser.failedTests.STLFailedTests;
|
||||||
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
|
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
|
||||||
import org.eclipse.cdt.core.search.tests.SearchTestSuite;
|
import org.eclipse.cdt.core.search.tests.SearchTestSuite;
|
||||||
|
@ -97,7 +97,7 @@ public class AutomatedIntegrationSuite extends TestSuite
|
||||||
suite.addTestSuite(ASTFailedTests.class);
|
suite.addTestSuite(ASTFailedTests.class);
|
||||||
suite.addTestSuite(STLFailedTests.class);
|
suite.addTestSuite(STLFailedTests.class);
|
||||||
suite.addTestSuite(CModelElementsFailedTests.class);
|
suite.addTestSuite(CModelElementsFailedTests.class);
|
||||||
suite.addTestSuite(FailedCompleteParseASTExpressionTest.class);
|
suite.addTestSuite(FailedCompleteParseASTTest.class);
|
||||||
|
|
||||||
// Last test to trigger report generation
|
// Last test to trigger report generation
|
||||||
suite.addTest(suite.new GenerateReport("generateReport"));
|
suite.addTest(suite.new GenerateReport("generateReport"));
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2003-09-29 Hoda Amer
|
||||||
|
Solution to bug#43679 : Exceptions in indexer
|
||||||
|
|
||||||
2003-09-29 Andrew Niefer
|
2003-09-29 Andrew Niefer
|
||||||
fixed bug 43834 : Empty Parameter list and parameter list taking one void do not match
|
fixed bug 43834 : Empty Parameter list and parameter list taking one void do not match
|
||||||
|
|
||||||
|
|
|
@ -763,6 +763,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IASTTypeId typeId,
|
IASTTypeId typeId,
|
||||||
ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException
|
ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
|
try{
|
||||||
List references = new ArrayList();
|
List references = new ArrayList();
|
||||||
|
|
||||||
//look up id & add to references
|
//look up id & add to references
|
||||||
|
@ -783,11 +784,16 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
|| (kind == IASTExpression.Kind.PM_ARROWSTAR)
|
|| (kind == IASTExpression.Kind.PM_ARROWSTAR)
|
||||||
){
|
){
|
||||||
TypeInfo lhsInfo = (TypeInfo) ((ASTExpression)lhs).getResultType().iterator().next();
|
TypeInfo lhsInfo = (TypeInfo) ((ASTExpression)lhs).getResultType().iterator().next();
|
||||||
ISymbol containingScope = (ISymbol) lhsInfo.getTypeSymbol().getTypeSymbol();
|
if(lhsInfo != null){
|
||||||
|
ISymbol firstContainingScope = (ISymbol) lhsInfo.getTypeSymbol();
|
||||||
|
if(firstContainingScope != null){
|
||||||
|
ISymbol containingScope = firstContainingScope.getTypeSymbol();
|
||||||
if(containingScope != null){
|
if(containingScope != null){
|
||||||
symbol = lookupQualifiedName((IContainerSymbol)containingScope, ((ASTExpression)rhs).getIdExpressionTokenDuple(), references, false);
|
symbol = lookupQualifiedName((IContainerSymbol)containingScope, ((ASTExpression)rhs).getIdExpressionTokenDuple(), references, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// go up the scope until you hit a class
|
// go up the scope until you hit a class
|
||||||
if (kind == IASTExpression.Kind.PRIMARY_THIS){
|
if (kind == IASTExpression.Kind.PRIMARY_THIS){
|
||||||
|
@ -808,13 +814,15 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
|
|
||||||
ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
|
ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
|
||||||
typeId, idExpression, literal, newDescriptor, references);
|
typeId, idExpression, literal, newDescriptor, references);
|
||||||
try{
|
|
||||||
expression.setResultType (getExpressionResultType(expression, symbol));
|
expression.setResultType (getExpressionResultType(expression, symbol));
|
||||||
|
|
||||||
|
return expression;
|
||||||
|
|
||||||
}catch (ASTSemanticException e){
|
}catch (ASTSemanticException e){
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return expression;
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Conditional Expression conversion
|
* Conditional Expression conversion
|
||||||
|
@ -1228,6 +1236,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IParameterizedSymbol psymbol = (IParameterizedSymbol) symbol;
|
IParameterizedSymbol psymbol = (IParameterizedSymbol) symbol;
|
||||||
ISymbol returnTypeSymbol = psymbol.getReturnType();
|
ISymbol returnTypeSymbol = psymbol.getReturnType();
|
||||||
info.setType(returnTypeSymbol.getType());
|
info.setType(returnTypeSymbol.getType());
|
||||||
|
info.setTypeSymbol(returnTypeSymbol);
|
||||||
}
|
}
|
||||||
result.add(info);
|
result.add(info);
|
||||||
return result;
|
return result;
|
||||||
|
@ -2272,10 +2281,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (IASTElaboratedTypeSpecifier)checkSymbol.getASTExtension().getPrimaryDeclaration();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if( checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTClassSpecifier ||
|
if( checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTClassSpecifier ||
|
||||||
checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTEnumerationSpecifier
|
checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTEnumerationSpecifier
|
||||||
)
|
)
|
||||||
|
@ -2291,10 +2298,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
return elab;
|
return elab;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTElaboratedTypeSpecifier )
|
if( checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTElaboratedTypeSpecifier )
|
||||||
return (IASTElaboratedTypeSpecifier)checkSymbol.getASTExtension().getPrimaryDeclaration();
|
return (IASTElaboratedTypeSpecifier)checkSymbol.getASTExtension().getPrimaryDeclaration();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue