diff options
author | Doug Schaefer | 2003-04-17 13:41:45 +0000 |
---|---|---|
committer | Doug Schaefer | 2003-04-17 13:41:45 +0000 |
commit | 861d5cdfcc5b543ba2d43bb4e7ee908a5e5d1d62 (patch) | |
tree | c0e1346adebe9cba7948f4059a475d4deb8a9ef3 /core | |
parent | 020e55826fd01cbd41321f2d2158ee369a695a34 (diff) | |
download | org.eclipse.cdt-861d5cdfcc5b543ba2d43bb4e7ee908a5e5d1d62.tar.gz org.eclipse.cdt-861d5cdfcc5b543ba2d43bb4e7ee908a5e5d1d62.tar.xz org.eclipse.cdt-861d5cdfcc5b543ba2d43bb4e7ee908a5e5d1d62.zip |
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().
Diffstat (limited to 'core')
7 files changed, 96 insertions, 13 deletions
diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java index ae7157f5297..ca8d7973c7f 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java @@ -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); diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java index 0b16aa0f2de..52109962a09 100644 --- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java @@ -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); } diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index bf7079bdee4..f89e43a04ca 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -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. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java index 2dfcc7ba839..75df14ef9dc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java @@ -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; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index 7d743013be3..270bf790ca1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -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 { diff --git a/core/org.eclipse.cdt.ui.tests/ChangeLog b/core/org.eclipse.cdt.ui.tests/ChangeLog index 50cd9f2658a..8a15c1fba1f 100644 --- a/core/org.eclipse.cdt.ui.tests/ChangeLog +++ b/core/org.eclipse.cdt.ui.tests/ChangeLog @@ -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(). diff --git a/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java b/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java index 51e9e7d4606..77f500b4444 100644 --- a/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java +++ b/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java @@ -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(); |