1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Patch for John Camelon:

CORE
		 Fixed Bug36532  -   Hang on partial template definition.
		 Fixed Bug36432  -   Trying to open attached source code hangs
Eclipse. 
		 Fixed Bug36594  -   Parser Stack Overflow on unaryExpression
		 Fixed Bug36600  -   Elaborated Enumerated Types Parse Incorrectly. 

TESTS
		 Added DOMTests::testBug36532().
		 Added DOMTests::testBug36432(). 
		 Added DOMTests::testBug36594().
		 Added DOMTests::testBug36600(). 
		 Added DOMTests::testArrayOfPointerToFunctions().
This commit is contained in:
Doug Schaefer 2003-04-17 13:41:45 +00:00
parent 020e55826f
commit 861d5cdfcc
7 changed files with 96 additions and 13 deletions

View file

@ -632,7 +632,7 @@ public class DOMBuilder implements IParserCallback
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
public Object enumSpecifierBegin(Object container, Token enumKey) {
SimpleDeclaration decl = (SimpleDeclaration)container;
TypeSpecifier.IOwner decl = (TypeSpecifier.IOwner)container;
EnumerationSpecifier es = new EnumerationSpecifier( decl );
es.setStartToken(enumKey);
decl.setTypeSpecifier(es);

View file

@ -24,7 +24,7 @@ import org.eclipse.cdt.internal.core.parser.Token;
*/
public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable {
public EnumerationSpecifier(SimpleDeclaration declaration) {
public EnumerationSpecifier(IOwner declaration) {
super(declaration);
}

View file

@ -1,3 +1,9 @@
2003-04-16 John Camelon
Fixed Bug36532 - Hang on partial template definition.
Fixed Bug36432 - Trying to open attached source code hangs Eclipse.
Fixed Bug36594 - Parser Stack Overflow on unaryExpression
Fixed Bug36600 - Elaborated Enumerated Types Parse Incorrectly.
2003-04-15 John Camelon
Fixed bug36434 - Broken outline in winbase.h
Partial Fix for bug36379 - The parser to set Line informations when scanning.

View file

@ -38,6 +38,7 @@ import org.eclipse.cdt.internal.core.dom.IOffsetable;
import org.eclipse.cdt.internal.core.dom.ITemplateParameterListOwner;
import org.eclipse.cdt.internal.core.dom.Inclusion;
import org.eclipse.cdt.internal.core.dom.Macro;
import org.eclipse.cdt.internal.core.dom.Name;
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
import org.eclipse.cdt.internal.core.dom.ParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.ParameterDeclarationClause;
@ -80,8 +81,16 @@ public class CModelBuilder {
System.out.println( "Parse Exception in Outline View" );
e.printStackTrace();
}
long startTime = System.currentTimeMillis();
generateModelElements(domBuilder.getTranslationUnit());
long startTime = System.currentTimeMillis();
try
{
generateModelElements(domBuilder.getTranslationUnit());
}
catch( NullPointerException npe )
{
System.out.println( "NullPointer exception generating CModel");
npe.printStackTrace();
}
System.out.println("CModel build: "+ ( System.currentTimeMillis() - startTime ) + "ms" );
return this.newElements;
}
@ -343,7 +352,10 @@ public class CModelBuilder {
protected TypeDef createTypeDef(Parent parent, Declarator declarator, SimpleDeclaration simpleDeclaration){
// create the element
String declaratorName = declarator.getName().toString();
Name domName = ( declarator.getDeclarator() != null ) ? declarator.getDeclarator().getName() :
declarator.getName();
String declaratorName = domName.toString();
TypeDef element = new TypeDef( parent, declaratorName );
String type = getType(simpleDeclaration, declarator);
element.setTypeName(type);
@ -352,21 +364,21 @@ public class CModelBuilder {
parent.addChild((CElement)element);
// set positions
element.setIdPos(declarator.getName().getStartOffset(), declarator.getName().length());
element.setIdPos(domName.getStartOffset(), domName.length());
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
this.newElements.put(element, element.getElementInfo());
return element;
}
protected VariableDeclaration createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
String declaratorName = declarator.getName().toString();
protected VariableDeclaration createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
String variableName = declarator.getName().toString();
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
VariableDeclaration element = null;
if(parent instanceof IStructure){
// field
Field newElement = new Field( parent, declaratorName );
Field newElement = new Field( parent, variableName);
newElement.setMutable(declSpecifier.isMutable());
newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
element = newElement;
@ -374,12 +386,12 @@ public class CModelBuilder {
else {
if(declSpecifier.isExtern()){
// variableDeclaration
VariableDeclaration newElement = new VariableDeclaration( parent, declaratorName );
VariableDeclaration newElement = new VariableDeclaration( parent, variableName );
element = newElement;
}
else {
// variable
Variable newElement = new Variable( parent, declaratorName );
Variable newElement = new Variable( parent, variableName );
element = newElement;
}
}

View file

@ -130,6 +130,7 @@ c, quick);
while (LT(1) != Token.tSEMI) {
consume();
}
consume();
}
/**
@ -340,6 +341,7 @@ c, quick);
} catch( Backtrack bt )
{
try { callback.templateDeclarationAbort( templateDeclaration ); } catch( Exception e ) {}
throw bt;
}
}
@ -639,6 +641,7 @@ c, quick);
protected void parameterDeclaration( Object containerObject ) throws Backtrack
{
Token current = LA(1);
Object parameterDecl = null;
try{ parameterDecl = callback.parameterDeclarationBegin( containerObject );} catch( Exception e ) {}
declSpecifierSeq( parameterDecl, true );
@ -647,10 +650,13 @@ c, quick);
try {
Object declarator = initDeclarator(parameterDecl);
} catch (Backtrack b) {
// allowed to be empty
}
if( current == LA(1) )
throw backtrack;
try{ callback.parameterDeclarationEnd( parameterDecl );} catch( Exception e ) {}
}
@ -944,6 +950,7 @@ c, quick);
*/
protected Object initDeclarator( Object owner ) throws Backtrack {
Object declarator = declarator( owner );
// handle = initializerClause
if (LT(1) == Token.tASSIGN) {
@ -1347,6 +1354,7 @@ c, quick);
protected void enumSpecifier( Object owner ) throws Backtrack
{
Object enumSpecifier = null;
Token mark = mark();
try{ enumSpecifier = callback.enumSpecifierBegin( owner, consume( Token.t_enum ) );} catch( Exception e ) {}
if( LT(1) == Token.tIDENTIFIER )
@ -1402,6 +1410,7 @@ c, quick);
else
{
// enumSpecifierAbort
backup(mark);
throw backtrack;
}
@ -2008,8 +2017,9 @@ c, quick);
try{ callback.expressionOperator(expression, t);} catch( Exception e ) {}
return;
case Token.t_sizeof:
consume(Token.t_sizeof);
if (LT(1) == Token.tLPAREN) {
consume();
consume( Token.tLPAREN );
typeId();
consume(Token.tRPAREN);
} else {

View file

@ -1,3 +1,10 @@
2003-04-16 John Camelon
Added DOMTests::testBug36532().
Added DOMTests::testBug36432().
Added DOMTests::testBug36594().
Added DOMTests::testBug36600().
Added DOMTests::testArrayOfPointerToFunctions().
2003-04-15 John Camelon
Added ScannerTestCase::testBug36434().
Added ScannerTestCase::testMultipleLines().

View file

@ -1264,6 +1264,54 @@ public class DOMTests extends TestCase {
assertEquals( clause.getDeclarations().size(), 3 );
}
public void testBug36532() throws Exception
{
try
{
TranslationUnit tu = parse( "template<int f() {\n" );
fail( "We should not make it this far");
}
catch( ParserException pe )
{
}
catch( Exception e )
{
fail( "We should have gotten a ParserException rather than" + e);
}
}
public void testBug36432() throws Exception
{
Writer code = new StringWriter();
code.write( "#define CMD_GET \"g\"\n" );
code.write( "#define CMD_ACTION \"a\"\n" );
code.write( "#define CMD_QUIT \"q\"\n" );
code.write( "static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n");
code.write( "memevent_get,\n");
code.write( "memevent_action,\n");
code.write( "memevent_quit,\n");
code.write( "};\n");
TranslationUnit tu = parse( code.toString() );
assertEquals( tu.getDeclarations().size(), 1 );
}
public void testBug36594() throws Exception
{
TranslationUnit tu = parse( "const int n = sizeof(A) / sizeof(B);");
assertEquals( tu.getDeclarations().size(), 1 );
}
public void testArrayOfPointerToFunctions() throws Exception
{
TranslationUnit tu = parse( "unsigned char (*main_data)[MAD_BUFFER_MDLEN];");
}
public void testBug36600() throws Exception
{
TranslationUnit tu = parse( "enum mad_flow (*input_func)(void *, struct mad_stream *);");
}
public void testBug36247() throws Exception
{
Writer code = new StringWriter();