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

@ -596,5 +596,16 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertFalse( i.hasNext() ); assertFalse( i.hasNext() );
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,35 +432,42 @@ 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();
IToken lastToken = name.getLastToken();
if( name.length() != 1 ) // qualified name String newSymbolName = "";
{
ITokenDuple containerSymbolName = if( name != null ){
name.getSubrange( 0, name.length() - 3 ); // -1 for index, -2 for last hop of qualified name IToken lastToken = name.getLastToken();
currentScopeSymbol = (IContainerSymbol)lookupQualifiedName( currentScopeSymbol, if( name.length() != 1 ) // qualified name
containerSymbolName, references, true); {
if( currentScopeSymbol == null ) ITokenDuple containerSymbolName =
throw new ASTSemanticException(); name.getSubrange( 0, name.length() - 3 ); // -1 for index, -2 for last hop of qualified name
currentScopeSymbol = (IContainerSymbol)lookupQualifiedName( currentScopeSymbol,
containerSymbolName, references, true);
if( currentScopeSymbol == null )
throw new ASTSemanticException();
}
newSymbolName = lastToken.getImage();
} }
ISymbol classSymbol = null; ISymbol classSymbol = null;
try if( !newSymbolName.equals("") ){
{ try
classSymbol = currentScopeSymbol.lookupMemberForDefinition(lastToken.getImage()); {
} classSymbol = currentScopeSymbol.lookupMemberForDefinition(newSymbolName);
catch (ParserSymbolTableException e) }
{ catch (ParserSymbolTableException e)
throw new ASTSemanticException(); {
} throw new ASTSemanticException();
}
if( classSymbol != null && ! classSymbol.isForwardDeclaration() )
throw new ASTSemanticException(); if( classSymbol != null && ! classSymbol.isForwardDeclaration() )
throw new ASTSemanticException();
if( classSymbol != null && classSymbol.getType() != pstType )
throw new ASTSemanticException(); if( classSymbol != null && classSymbol.getType() != pstType )
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 );