1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Andrew Niefer

Fixed NPE in CompleParseASTFactory.createClassSpecifier caused by a null 
name.
This commit is contained in:
John Camelon 2003-09-05 13:45:16 +00:00
parent 9eb63f2fdb
commit ae96e590ff
4 changed files with 49 additions and 25 deletions

View file

@ -2,6 +2,9 @@
Updated ASTFailedTests::testBug39702() to fail more accurately. Updated ASTFailedTests::testBug39702() to fail more accurately.
Added testSimpleFunctionBody(), testSimpleForLoop() to CompleteParseASTTest.java. Added testSimpleFunctionBody(), testSimpleForLoop() to CompleteParseASTTest.java.
2003-09-04 Andrew Niefer
Added testBug42541 to CompleParseASTTests.java
2003-09-04 Hoda Amer 2003-09-04 Hoda Amer
Call to ASTExpression getTypeId() changed to getTypeIdString(). Call to ASTExpression getTypeId() changed to getTypeIdString().

View file

@ -597,4 +597,15 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertEquals( callback.getReferences().size(), 5 ); assertEquals( callback.getReferences().size(), 5 );
} }
public void testBug42541() throws Exception
{
Iterator i = parse( "union{ int v; char a; } id;" ).getDeclarations();
IASTVariable id = (IASTVariable)i.next();
IASTClassSpecifier union = (IASTClassSpecifier) id.getAbstractDeclaration().getTypeSpecifier();
Iterator sub = getDeclarations( union );
IASTField intV = (IASTField)sub.next();
IASTField charA = (IASTField)sub.next();
}
} }

View file

@ -3,6 +3,9 @@
Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope
constructs, clients should keep this in mind and update their implementations. constructs, clients should keep this in mind and update their implementations.
2003-09-04 Andrew Niefer
Fix bug42541 - Anonymous structures cause NPE in full parse
2003-09-03 Andrew Niefer 2003-09-03 Andrew Niefer
fix bug in PST that prevents > 2 constructors fix bug in PST that prevents > 2 constructors

View file

@ -432,6 +432,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
IContainerSymbol currentScopeSymbol = scopeToSymbol(scope); IContainerSymbol currentScopeSymbol = scopeToSymbol(scope);
TypeInfo.eType pstType = classKindToTypeInfo(kind); TypeInfo.eType pstType = classKindToTypeInfo(kind);
List references = new ArrayList(); List references = new ArrayList();
String newSymbolName = "";
if( name != null ){
IToken lastToken = name.getLastToken(); IToken lastToken = name.getLastToken();
if( name.length() != 1 ) // qualified name if( name.length() != 1 ) // qualified name
{ {
@ -442,11 +446,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( currentScopeSymbol == null ) if( currentScopeSymbol == null )
throw new ASTSemanticException(); throw new ASTSemanticException();
} }
newSymbolName = lastToken.getImage();
}
ISymbol classSymbol = null; ISymbol classSymbol = null;
if( !newSymbolName.equals("") ){
try try
{ {
classSymbol = currentScopeSymbol.lookupMemberForDefinition(lastToken.getImage()); classSymbol = currentScopeSymbol.lookupMemberForDefinition(newSymbolName);
} }
catch (ParserSymbolTableException e) catch (ParserSymbolTableException e)
{ {
@ -458,9 +465,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( classSymbol != null && classSymbol.getType() != pstType ) if( classSymbol != null && classSymbol.getType() != pstType )
throw new ASTSemanticException(); throw new ASTSemanticException();
}
IDerivableContainerSymbol newSymbol = pst.newDerivableContainerSymbol( newSymbolName, pstType );
IDerivableContainerSymbol newSymbol = pst.newDerivableContainerSymbol( lastToken.getImage(), pstType );
if( classSymbol != null ) if( classSymbol != null )
classSymbol.setTypeSymbol( newSymbol ); classSymbol.setTypeSymbol( newSymbol );