1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00
Fixed Bug 40842 - Parser: NPE while parsing class declaration in full parse mode 
	Fixed Bug 40843 - Parser: failParse doesn't set parsePassed = false on EOF.
	Fixed Miscellaneous overrides issues involving parameters & functions. 


TESTS
	Added/moved tests as necessary for bugfix 40842 & 40843.
This commit is contained in:
John Camelon 2003-07-28 20:49:47 +00:00
parent 33fdeeac10
commit 95b11e1171
10 changed files with 74 additions and 30 deletions

View file

@ -1,3 +1,6 @@
2003-07-28 John Camelon
Added/moved tests as necessary for bugfix 40842 & 40843.
2003-07-28 Andrew Niefer
This patch creates a new failing test class : FullParseFailedTests. This
is for writing failed tests on the parser doing COMPLETE_PARSE.

View file

@ -13,8 +13,8 @@
*/
package org.eclipse.cdt.core.parser.failedTests;
import java.io.StringWriter;
import java.io.Writer;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.parser.tests.BaseASTTest;
@ -33,13 +33,9 @@ public class FullParseFailedTests extends BaseASTTest {
super(name);
}
public void testBug40842() throws Exception{
Writer code = new StringWriter();
public static Test suite() {
TestSuite suite = new TestSuite(FullParseFailedTests.class.getName());
return suite;
}
//note that if the parse fails at EOF, parse.failParse never sets
//parsePassed = false because it will throw EOF on LA(1), so get
//around this by adding more code after the error.
code.write("class A {} a;\n int x;");
assertCodeFailsFullParse(code.toString());
}
}

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.core.parser.tests;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
@ -811,5 +813,21 @@ public class CompleteParseASTTest extends TestCase
}
}
public void testBug40842() throws Exception{
Writer code = new StringWriter();
code.write("class A {} a;\n");
Iterator i = parse(code.toString()).getDeclarations();
IASTVariable instanceA = (IASTVariable)i.next();
assertFalse( i.hasNext() );
}
public void testOverride() throws Exception
{
Iterator i = parse( "void foo();\n void foo( int );\n").getDeclarations();
IASTFunction f1 = (IASTFunction)i.next();
IASTFunction f2 = (IASTFunction)i.next();
assertFalse( i.hasNext() );
}
}

View file

@ -429,7 +429,7 @@ public class QuickParseASTTests extends BaseASTTest
}
public void testBug36290() throws Exception {
parse("typedef void ( A:: * pFunction ) ( void ); ");
parse("typedef void ( A:: * pMethod ) ( void ); ");
parse("typedef void (boo) ( void ); ");
parse("typedef void boo (void); ");
}

View file

@ -98,7 +98,7 @@ public class AutomatedIntegrationSuite extends TestSuite
suite.addTestSuite(LokiFailures.class);
suite.addTestSuite(STLFailedTests.class);
suite.addTestSuite(CModelElementsFailedTests.class);
suite.addTestSuite(FullParseFailedTests.class);
suite.addTest(FullParseFailedTests.suite());
// Last test to trigger report generation
suite.addTest(suite.new GenerateReport("generateReport"));

View file

@ -1,3 +1,8 @@
2003-07-28 John Camelon
Fixed Bug 40842 - Parser: NPE while parsing class declaration in full parse mode
Fixed Bug 40843 - Parser: failParse doesn't set parsePassed = false on EOF.
Fixed Miscellaneous overrides issues involving parameters & functions.
2003-07-28 John Camelon
Fixed Bug 40730 : Parser is not searching the include path for #include"<name>"

View file

@ -19,9 +19,8 @@ import java.util.Iterator;
public interface IASTAbstractDeclaration extends IASTTypeSpecifierOwner
{
public boolean isConst();
public Iterator getPointerOperators();
public Iterator getArrayModifiers();
}

View file

@ -87,11 +87,20 @@ public class Parser implements IParser
* @throws EndOfFile
*/
protected void failParse() throws EndOfFile
{
try
{
if (firstErrorOffset == DEFAULT_OFFSET)
firstErrorOffset = LA(1).getOffset();
} catch( EndOfFile eof )
{
throw eof;
}
finally
{
parsePassed = false;
}
}
/**
* This is the standard cosntructor that we expect the Parser to be instantiated
* with.

View file

@ -713,6 +713,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
List references = new ArrayList();
setParameter( symbol, returnType, false, references );
setParameters( symbol, references, parameters.iterator() );
try
{
ownerScope.addSymbol( symbol );
@ -722,8 +726,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
throw new ASTSemanticException();
}
setParameter( symbol, returnType, false, references );
setParameters( symbol, references, parameters.iterator() );
ASTFunction function = new ASTFunction( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references );
try
@ -901,6 +903,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
setMethodTypeInfoBits( symbol, isConst, isVolatile, isVirtual, isExplicit );
List references = new ArrayList();
setParameter( symbol, returnType, false, references );
setParameters( symbol, references, parameters.iterator() );
try
{
ownerScope.addSymbol( symbol );
@ -910,8 +915,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
throw new ASTSemanticException();
}
setParameter( symbol, returnType, false, references );
setParameters( symbol, references, parameters.iterator() );
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, nameOffset, ownerTemplate, references, isConstructor, isDestructor, isPureVirtual, visibility );
try
@ -1006,19 +1010,26 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
newSymbol.getTypeInfo().setBit( isStatic, TypeInfo.isStatic );
newSymbol.getTypeInfo().setBit( abstractDeclaration.isConst(), TypeInfo.isConst );
}
protected ISymbol cloneSimpleTypeSymbol(
String name,
IASTAbstractDeclaration abstractDeclaration,
List references)
{
ISymbol newSymbol = null;
ISymbol symbolToBeCloned = null;
if( abstractDeclaration.getTypeSpecifier() instanceof ASTSimpleTypeSpecifier )
{
ISymbol symbolToBeCloned = ((ASTSimpleTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol();
newSymbol = (ISymbol)symbolToBeCloned.clone();
newSymbol.setName( name );
symbolToBeCloned = ((ASTSimpleTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol();
references.addAll( ((ASTSimpleTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getReferences() );
}
else if( abstractDeclaration.getTypeSpecifier() instanceof ASTClassSpecifier )
{
symbolToBeCloned = ((ASTClassSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol();
}
newSymbol = (ISymbol) symbolToBeCloned.clone();
newSymbol.setName( name );
return newSymbol;
}
/* (non-Javadoc)

View file

@ -2485,10 +2485,13 @@ public class ParserSymbolTable {
return false;
}
int size = getParameterList().size();
if( function.getParameterList().size() != size ){
int size = ( getParameterList() == null ) ? 0 : getParameterList().size();
int fsize = ( function.getParameterList() == null ) ? 0 : function.getParameterList().size();
if( fsize != size ){
return false;
}
if( fsize == 0 )
return true;
Iterator iter = getParameterList().iterator();
Iterator fIter = function.getParameterList().iterator();