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:
parent
9eb63f2fdb
commit
ae96e590ff
4 changed files with 49 additions and 25 deletions
|
@ -2,6 +2,9 @@
|
|||
Updated ASTFailedTests::testBug39702() to fail more accurately.
|
||||
Added testSimpleFunctionBody(), testSimpleForLoop() to CompleteParseASTTest.java.
|
||||
|
||||
2003-09-04 Andrew Niefer
|
||||
Added testBug42541 to CompleParseASTTests.java
|
||||
|
||||
2003-09-04 Hoda Amer
|
||||
Call to ASTExpression getTypeId() changed to getTypeIdString().
|
||||
|
||||
|
|
|
@ -597,4 +597,15 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope
|
||||
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
|
||||
fix bug in PST that prevents > 2 constructors
|
||||
|
||||
|
|
|
@ -432,35 +432,42 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
IContainerSymbol currentScopeSymbol = scopeToSymbol(scope);
|
||||
TypeInfo.eType pstType = classKindToTypeInfo(kind);
|
||||
List references = new ArrayList();
|
||||
IToken lastToken = name.getLastToken();
|
||||
if( name.length() != 1 ) // qualified name
|
||||
{
|
||||
ITokenDuple containerSymbolName =
|
||||
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();
|
||||
|
||||
String newSymbolName = "";
|
||||
|
||||
if( name != null ){
|
||||
IToken lastToken = name.getLastToken();
|
||||
if( name.length() != 1 ) // qualified name
|
||||
{
|
||||
ITokenDuple containerSymbolName =
|
||||
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;
|
||||
try
|
||||
{
|
||||
classSymbol = currentScopeSymbol.lookupMemberForDefinition(lastToken.getImage());
|
||||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
throw new ASTSemanticException();
|
||||
}
|
||||
if( !newSymbolName.equals("") ){
|
||||
try
|
||||
{
|
||||
classSymbol = currentScopeSymbol.lookupMemberForDefinition(newSymbolName);
|
||||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
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( lastToken.getImage(), pstType );
|
||||
IDerivableContainerSymbol newSymbol = pst.newDerivableContainerSymbol( newSymbolName, pstType );
|
||||
|
||||
if( classSymbol != null )
|
||||
classSymbol.setTypeSymbol( newSymbol );
|
||||
|
|
Loading…
Add table
Reference in a new issue