1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 15:45:25 +02:00
Fixed Bug 43503 : Search:f_SD_01 cannot be found in ManyClasses20 Project 
	Fixed Bug 43680 : Fix Parser Error Handling 

TESTS
	Updated CompleteParseASTTest::testBug42872()
	Moved FailedCompleteParseASTTest::testBug43503() to CompleteParseASTTest::testBug43503A().
This commit is contained in:
John Camelon 2003-09-30 20:42:24 +00:00
parent 148f6add3c
commit 007714a394
9 changed files with 755 additions and 349 deletions
core
org.eclipse.cdt.core.tests
ChangeLog
failures/org/eclipse/cdt/core/parser/failedTests
parser/org/eclipse/cdt/core/parser/tests
org.eclipse.cdt.core/parser

View file

@ -1,3 +1,7 @@
2003-09-30 John Camelon
Updated CompleteParseASTTest::testBug42872()
Moved FailedCompleteParseASTTest::testBug43503() to CompleteParseASTTest::testBug43503A().
2003-09-30 Andrew Niefer 2003-09-30 Andrew Niefer
added testBug43503_AmbiguousUsing() and testBug43503_UnableToResolveFunction() to added testBug43503_AmbiguousUsing() and testBug43503_UnableToResolveFunction() to
ParserSymbolTableTest ParserSymbolTableTest

View file

@ -114,20 +114,4 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
assertFalse( i.hasNext() ); assertFalse( i.hasNext() );
assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2))); assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
} }
public void testBug43503 () throws Exception {
Iterator i = parse("class SD_01 { f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ").getDeclarations();
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
Iterator j = getDeclarations(classA);
IASTMethod f = (IASTMethod)j.next();
assertFalse(j.hasNext());
IASTFunction main = (IASTFunction) i.next();
assertFalse(i.hasNext());
Iterator k = getDeclarations(main);
assertFalse(k.hasNext()); // this should be true, there is one declaration of "a"
// "a" is found to be in a multiplication expression, not a declaration
// not knowing "a" causes us to not find the reference to "f"
}
} }

View file

@ -745,9 +745,22 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
IASTClassSpecifier structB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTClassSpecifier structB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTClassSpecifier structD = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTClassSpecifier structD = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTFunction foo = (IASTFunction)i.next(); IASTFunction foo = (IASTFunction)i.next();
IASTVariable bp = (IASTVariable)getDeclarations(foo).next();
assertFalse( i.hasNext() ); assertFalse( i.hasNext() );
} }
public void testBug43503A() throws Exception {
Iterator i = parse("class SD_01 { f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ").getDeclarations();
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
Iterator j = getDeclarations(classA);
IASTMethod f = (IASTMethod)j.next();
assertFalse(j.hasNext());
IASTFunction main = (IASTFunction) i.next();
assertFalse(i.hasNext());
Iterator k = getDeclarations(main);
assertTrue(k.hasNext());
}
public void testBug42979() throws Exception public void testBug42979() throws Exception
{ {

View file

@ -1,3 +1,7 @@
2003-09-30 John Camelon
Fixed Bug 43503 : Search:f_SD_01 cannot be found in ManyClasses20 Project
Fixed Bug 43680 : Fix Parser Error Handling
2003-09-30 Hoda Amer 2003-09-30 Hoda Amer
-Solution to [Bug 43053] require reference cleanup for expressions -Solution to [Bug 43053] require reference cleanup for expressions
Added purgeReferences() at the end of ASTExpression::acceptElement() Added purgeReferences() at the end of ASTExpression::acceptElement()

View file

@ -24,32 +24,32 @@ public interface IASTFactory
String name, String name,
int startingOffset, int startingOffset,
int nameOffset, int nameOffset,
int nameEndOffset, int endingOffset); int nameEndOffset, int endingOffset) throws Exception;
public IASTInclusion createInclusion( public IASTInclusion createInclusion(
String name, String name,
String fileName, String fileName,
boolean local, boolean local,
int startingOffset, int startingOffset,
int nameOffset, int nameOffset,
int nameEndOffset, int endingOffset); int nameEndOffset, int endingOffset) throws Exception;
public IASTUsingDirective createUsingDirective( public IASTUsingDirective createUsingDirective(
IASTScope scope, IASTScope scope,
ITokenDuple duple, int startingOffset, int endingOffset) ITokenDuple duple, int startingOffset, int endingOffset)
throws ASTSemanticException; throws ASTSemanticException, Exception;
public IASTUsingDeclaration createUsingDeclaration( public IASTUsingDeclaration createUsingDeclaration(
IASTScope scope, IASTScope scope,
boolean isTypeName, boolean isTypeName,
ITokenDuple name, int startingOffset, int endingOffset) throws ASTSemanticException; ITokenDuple name, int startingOffset, int endingOffset) throws ASTSemanticException, Exception;
public IASTASMDefinition createASMDefinition( public IASTASMDefinition createASMDefinition(
IASTScope scope, IASTScope scope,
String assembly, String assembly,
int first, int first,
int last); int last)throws Exception;
public IASTNamespaceDefinition createNamespaceDefinition( public IASTNamespaceDefinition createNamespaceDefinition(
IASTScope scope, IASTScope scope,
String identifier, String identifier,
int startingOffset, int startingOffset,
int nameOffset, int nameEndOffset) throws ASTSemanticException; int nameOffset, int nameEndOffset) throws ASTSemanticException, Exception;
public IASTNamespaceAlias createNamespaceAlias( public IASTNamespaceAlias createNamespaceAlias(
IASTScope scope, IASTScope scope,
@ -57,12 +57,12 @@ public interface IASTFactory
ITokenDuple alias, ITokenDuple alias,
int startingOffset, int startingOffset,
int nameOffset, int nameOffset,
int nameEndOffset, int endOffset ) throws ASTSemanticException; int nameEndOffset, int endOffset ) throws ASTSemanticException, Exception;
public IASTCompilationUnit createCompilationUnit(); public IASTCompilationUnit createCompilationUnit() throws Exception;
public IASTLinkageSpecification createLinkageSpecification( public IASTLinkageSpecification createLinkageSpecification(
IASTScope scope, IASTScope scope,
String spec, int startingOffset); String spec, int startingOffset) throws Exception;
public IASTClassSpecifier createClassSpecifier( public IASTClassSpecifier createClassSpecifier(
IASTScope scope, IASTScope scope,
ITokenDuple name, ITokenDuple name,
@ -70,7 +70,7 @@ public interface IASTFactory
ClassNameType type, ClassNameType type,
ASTAccessVisibility access, ASTAccessVisibility access,
int startingOffset, int startingOffset,
int nameOffset, int nameEndOffset) throws ASTSemanticException; int nameOffset, int nameEndOffset) throws ASTSemanticException, Exception;
/** /**
* @param astClassSpec * @param astClassSpec
* @param isVirtual * @param isVirtual
@ -81,21 +81,21 @@ public interface IASTFactory
IASTClassSpecifier astClassSpec, IASTClassSpecifier astClassSpec,
boolean isVirtual, boolean isVirtual,
ASTAccessVisibility visibility, ASTAccessVisibility visibility,
ITokenDuple parentClassName) throws ASTSemanticException; ITokenDuple parentClassName) throws ASTSemanticException, Exception;
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier( public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(
IASTScope scope, IASTScope scope,
ASTClassKind elaboratedClassKind, ASTClassKind elaboratedClassKind,
ITokenDuple typeName, ITokenDuple typeName,
int startingOffset, int endOffset, boolean isForewardDecl) throws ASTSemanticException; int startingOffset, int endOffset, boolean isForewardDecl) throws ASTSemanticException, Exception;
public IASTEnumerationSpecifier createEnumerationSpecifier( public IASTEnumerationSpecifier createEnumerationSpecifier(
IASTScope scope, IASTScope scope,
String name, String name,
int startingOffset, int nameOffset, int nameEndOffset) throws ASTSemanticException; int startingOffset, int nameOffset, int nameEndOffset) throws ASTSemanticException, Exception;
public void addEnumerator( public void addEnumerator(
IASTEnumerationSpecifier enumeration, IASTEnumerationSpecifier enumeration,
String string, String string,
int startingOffset, int startingOffset,
int nameOffset, int nameEndOffset, int endingOffset, IASTExpression initialValue)throws ASTSemanticException; int nameOffset, int nameEndOffset, int endingOffset, IASTExpression initialValue)throws ASTSemanticException, Exception;
public IASTExpression createExpression( public IASTExpression createExpression(
IASTScope scope, IASTScope scope,
IASTExpression.Kind kind, IASTExpression.Kind kind,
@ -103,17 +103,17 @@ public interface IASTFactory
IASTExpression rhs, IASTExpression rhs,
IASTExpression thirdExpression, IASTExpression thirdExpression,
IASTTypeId typeId, IASTTypeId typeId,
ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException; ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException, Exception;
public IASTExpression.IASTNewExpressionDescriptor createNewDescriptor(List newPlacementExpressions,List newTypeIdExpressions,List newInitializerExpressions); public IASTExpression.IASTNewExpressionDescriptor createNewDescriptor(List newPlacementExpressions,List newTypeIdExpressions,List newInitializerExpressions)throws Exception;
public IASTInitializerClause createInitializerClause( public IASTInitializerClause createInitializerClause(
IASTInitializerClause.Kind kind, IASTInitializerClause.Kind kind,
IASTExpression assignmentExpression, IASTExpression assignmentExpression,
List initializerClauses); List initializerClauses) throws Exception;
public IASTExceptionSpecification createExceptionSpecification(IASTScope scope, List typeIds) throws ASTSemanticException; public IASTExceptionSpecification createExceptionSpecification(IASTScope scope, List typeIds) throws ASTSemanticException, Exception;
/** /**
* @param exp * @param exp
*/ */
public IASTArrayModifier createArrayModifier(IASTExpression exp); public IASTArrayModifier createArrayModifier(IASTExpression exp) throws Exception;
/** /**
* @param duple * @param duple
* @param expressionList * @param expressionList
@ -121,7 +121,7 @@ public interface IASTFactory
*/ */
public IASTConstructorMemberInitializer createConstructorMemberInitializer( public IASTConstructorMemberInitializer createConstructorMemberInitializer(
IASTScope scope, IASTScope scope,
ITokenDuple duple, IASTExpression expressionList) throws ASTSemanticException; ITokenDuple duple, IASTExpression expressionList) throws ASTSemanticException, Exception;
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier( public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(
IASTScope scope, IASTScope scope,
IASTSimpleTypeSpecifier.Type kind, IASTSimpleTypeSpecifier.Type kind,
@ -129,7 +129,7 @@ public interface IASTFactory
boolean isShort, boolean isShort,
boolean isLong, boolean isLong,
boolean isSigned, boolean isSigned,
boolean isUnsigned, boolean isTypename) throws ASTSemanticException; boolean isUnsigned, boolean isTypename) throws ASTSemanticException, Exception;
public IASTFunction createFunction( public IASTFunction createFunction(
IASTScope scope, IASTScope scope,
String name, String name,
@ -147,12 +147,12 @@ public interface IASTFactory
boolean isVolatile, boolean isVolatile,
boolean isVirtual, boolean isVirtual,
boolean isExplicit, boolean isExplicit,
boolean isPureVirtual, List constructorChain, boolean isDefinition ) throws ASTSemanticException; boolean isPureVirtual, List constructorChain, boolean isDefinition ) throws ASTSemanticException, Exception;
public IASTAbstractDeclaration createAbstractDeclaration( public IASTAbstractDeclaration createAbstractDeclaration(
boolean isConst, boolean isConst,
boolean isVolatile, boolean isVolatile,
IASTTypeSpecifier typeSpecifier, IASTTypeSpecifier typeSpecifier,
List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOperator); List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOperator)throws Exception;
public IASTMethod createMethod( public IASTMethod createMethod(
IASTScope scope, IASTScope scope,
String name, String name,
@ -170,28 +170,28 @@ public interface IASTFactory
boolean isVolatile, boolean isVolatile,
boolean isVirtual, boolean isVirtual,
boolean isExplicit, boolean isExplicit,
boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition) throws ASTSemanticException; boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition) throws ASTSemanticException, Exception;
public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression,
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, int nameEndOffset, IASTExpression constructorExpression ) throws ASTSemanticException; IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, int nameEndOffset, IASTExpression constructorExpression ) throws ASTSemanticException, Exception;
public IASTField createField( IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, int nameEndOffset, IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException; public IASTField createField( IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, int nameEndOffset, IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException, Exception;
public IASTParameterDeclaration createParameterDeclaration( boolean isConst, boolean isVolatile, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int nameOffset, int nameEndOffset, int endingOffset ); public IASTParameterDeclaration createParameterDeclaration( boolean isConst, boolean isVolatile, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int nameOffset, int nameEndOffset, int endingOffset ) throws Exception;
public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset ); public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset ) throws Exception;
public IASTTemplateParameter createTemplateParameter( IASTTemplateParameter.ParamKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms ); public IASTTemplateParameter createTemplateParameter( IASTTemplateParameter.ParamKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms ) throws Exception;
public IASTTemplateInstantiation createTemplateInstantiation(IASTScope scope, int startingOffset); public IASTTemplateInstantiation createTemplateInstantiation(IASTScope scope, int startingOffset)throws Exception;
public IASTTemplateSpecialization createTemplateSpecialization(IASTScope scope, int startingOffset); public IASTTemplateSpecialization createTemplateSpecialization(IASTScope scope, int startingOffset)throws Exception;
public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset, int nameEndOffset ) throws ASTSemanticException; public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset, int nameEndOffset ) throws ASTSemanticException, Exception;
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset); public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset)throws Exception;
public boolean queryIsTypeName( IASTScope scope, ITokenDuple nameInQuestion ); public boolean queryIsTypeName( IASTScope scope, ITokenDuple nameInQuestion ) throws Exception;
static final String DOUBLE_COLON = "::"; static final String DOUBLE_COLON = "::";
static final String TELTA = "~"; static final String TELTA = "~";
@ -199,14 +199,14 @@ public interface IASTFactory
* @param scope * @param scope
* @return * @return
*/ */
public IASTCodeScope createNewCodeBlock(IASTScope scope); public IASTCodeScope createNewCodeBlock(IASTScope scope)throws Exception;
public IASTTypeId createTypeId( IASTScope scope, IASTSimpleTypeSpecifier.Type kind, boolean isConst, boolean isVolatile, boolean isShort, public IASTTypeId createTypeId( IASTScope scope, IASTSimpleTypeSpecifier.Type kind, boolean isConst, boolean isVolatile, boolean isShort,
boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, ITokenDuple name, List pointerOps, List arrayMods ) throws ASTSemanticException; boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, ITokenDuple name, List pointerOps, List arrayMods ) throws ASTSemanticException, Exception;
/** /**
* @param astClassSpecifier * @param astClassSpecifier
*/ */
public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier); public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier) throws Exception;
} }

View file

@ -373,17 +373,49 @@ public class DeclarationWrapper implements IDeclaratorOwner
} }
List convertedParms = createParameterList( declarator.getParameters() ); List convertedParms = createParameterList( declarator.getParameters() );
IASTAbstractDeclaration abs = astFactory.createAbstractDeclaration( IASTAbstractDeclaration abs = null;
constt, volatil, getTypeSpecifier(), declarator.getPointerOperators(), declarator.getArrayModifiers(), try
convertedParms, (ASTPointerOperator)i.next() ); {
abs =
astFactory.createAbstractDeclaration(
constt,
volatil,
getTypeSpecifier(),
declarator.getPointerOperators(),
declarator.getArrayModifiers(),
convertedParms,
(ASTPointerOperator)i.next());
}
catch (Exception e)
{
throw new ASTSemanticException();
}
String name = ( d.getPointerOperatorNameDuple() != null ) ? d.getPointerOperatorNameDuple().toString() + d.getName() : d.getName(); String name = ( d.getPointerOperatorNameDuple() != null ) ? d.getPointerOperatorNameDuple().toString() + d.getName() : d.getName();
if( typedef ) if( typedef )
return astFactory.createTypedef( try
scope, {
name, return astFactory.createTypedef(
abs, getStartingOffset(), d.getNameStartOffset(), d.getNameEndOffset() ); scope,
name,
abs, getStartingOffset(), d.getNameStartOffset(), d.getNameEndOffset() );
}
catch (ASTSemanticException e1)
{
throw e1;
}
catch (Exception e1)
{
throw new ASTSemanticException();
}
else else
return astFactory.createVariable( scope, name, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), d.getNameStartOffset(), d.getNameEndOffset(), d.getConstructorExpression() ); try
{
return astFactory.createVariable( scope, name, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), d.getNameStartOffset(), d.getNameEndOffset(), d.getConstructorExpression() );
}
catch (Exception e2)
{
throw new ASTSemanticException();
}
} }
else else
@ -399,14 +431,25 @@ public class DeclarationWrapper implements IDeclaratorOwner
*/ */
private IASTTypedefDeclaration createTypedef(Declarator declarator, boolean nested ) throws ASTSemanticException private IASTTypedefDeclaration createTypedef(Declarator declarator, boolean nested ) throws ASTSemanticException
{ {
return astFactory.createTypedef( try
scope, {
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(), return astFactory.createTypedef(
astFactory.createAbstractDeclaration( scope,
constt, nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
volatil, astFactory.createAbstractDeclaration(
getTypeSpecifier(), constt,
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null), startingOffset, declarator.getNameStartOffset(), declarator.getNameEndOffset()); volatil,
getTypeSpecifier(),
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null), startingOffset, declarator.getNameStartOffset(), declarator.getNameEndOffset());
}
catch (ASTSemanticException e)
{
throw e;
}
catch (Exception e)
{
throw new ASTSemanticException();
}
} }
/** /**
* @param declarator * @param declarator
@ -414,14 +457,57 @@ public class DeclarationWrapper implements IDeclaratorOwner
*/ */
private IASTMethod createMethodASTNode(Declarator declarator, boolean nested) throws ASTSemanticException private IASTMethod createMethodASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{ {
return astFactory try
.createMethod( {
return astFactory
.createMethod(
scope,
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration(
constt,
volatil,
getTypeSpecifier(),
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
declarator.getExceptionSpecification(),
inline,
friend,
staticc,
startingOffset,
declarator.getNameStartOffset(),
declarator.getNameEndOffset(),
templateDeclaration,
declarator.isConst(),
declarator.isVolatile(),
virtual,
explicit,
declarator.isPureVirtual(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode(),
declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody());
}
catch (ASTSemanticException e)
{
throw e;
}
catch (Exception e)
{
throw new ASTSemanticException();
}
}
/**
* @param declarator
* @return
*/
private IASTFunction createFunctionASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{
try
{
return astFactory.createFunction(
scope, scope,
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
createParameterList(declarator.getParameters()), createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration( astFactory.createAbstractDeclaration(
constt, constt,
volatil, volatil,
getTypeSpecifier(), getTypeSpecifier(),
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null), declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
declarator.getExceptionSpecification(), declarator.getExceptionSpecification(),
@ -431,43 +517,22 @@ public class DeclarationWrapper implements IDeclaratorOwner
startingOffset, startingOffset,
declarator.getNameStartOffset(), declarator.getNameStartOffset(),
declarator.getNameEndOffset(), declarator.getNameEndOffset(),
templateDeclaration, templateDeclaration,
declarator.isConst(), declarator.isConst(),
declarator.isVolatile(), declarator.isVolatile(),
virtual, virtual,
explicit, explicit,
declarator.isPureVirtual(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.isPureVirtual(),
declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody()); declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody() );
} }
/** catch (ASTSemanticException e)
* @param declarator {
* @return throw e;
*/ }
private IASTFunction createFunctionASTNode(Declarator declarator, boolean nested) throws ASTSemanticException catch (Exception e)
{ {
return astFactory.createFunction( throw new ASTSemanticException();
scope, }
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration(
constt,
volatil,
getTypeSpecifier(),
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
declarator.getExceptionSpecification(),
inline,
friend,
staticc,
startingOffset,
declarator.getNameStartOffset(),
declarator.getNameEndOffset(),
templateDeclaration,
declarator.isConst(),
declarator.isVolatile(),
virtual,
explicit,
declarator.isPureVirtual(),
declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody() );
} }
/** /**
* @param declarator * @param declarator
@ -475,26 +540,37 @@ public class DeclarationWrapper implements IDeclaratorOwner
*/ */
private IASTField createFieldASTNode(Declarator declarator, boolean nested) throws ASTSemanticException private IASTField createFieldASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{ {
return astFactory.createField( try
scope, {
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(), return astFactory.createField(
auto, scope,
declarator.getInitializerClause(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
declarator.getBitFieldExpression(), auto,
astFactory.createAbstractDeclaration( declarator.getInitializerClause(),
constt, declarator.getBitFieldExpression(),
volatil, astFactory.createAbstractDeclaration(
getTypeSpecifier(), constt,
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null), volatil,
mutable, getTypeSpecifier(),
extern, declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
register, mutable,
staticc, extern,
startingOffset, register,
declarator.getNameStartOffset(), staticc,
declarator.getNameEndOffset(), declarator.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode()); startingOffset,
declarator.getNameStartOffset(),
declarator.getNameEndOffset(), declarator.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode());
}
catch (ASTSemanticException e)
{
throw e;
}
catch (Exception e)
{
throw new ASTSemanticException();
}
} }
private List createParameterList(List currentParameters) private List createParameterList(List currentParameters) throws ASTSemanticException
{ {
List result = new ArrayList(); List result = new ArrayList();
Iterator i = currentParameters.iterator(); Iterator i = currentParameters.iterator();
@ -505,16 +581,23 @@ public class DeclarationWrapper implements IDeclaratorOwner
while (j.hasNext()) while (j.hasNext())
{ {
Declarator declarator = (Declarator)j.next(); Declarator declarator = (Declarator)j.next();
result.add( try
astFactory.createParameterDeclaration( {
wrapper.isConst(), result.add(
wrapper.isVolatile(), astFactory.createParameterDeclaration(
wrapper.getTypeSpecifier(), wrapper.isConst(),
declarator.getPointerOperators(), wrapper.isVolatile(),
declarator.getArrayModifiers(), wrapper.getTypeSpecifier(),
null, null, declarator.getName() == null declarator.getPointerOperators(),
? "" declarator.getArrayModifiers(),
: declarator.getName(), declarator.getInitializerClause(), wrapper.getStartingOffset(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), wrapper.getEndOffset())); null, null, declarator.getName() == null
? ""
: declarator.getName(), declarator.getInitializerClause(), wrapper.getStartingOffset(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), wrapper.getEndOffset()));
}
catch (Exception e)
{
throw new ASTSemanticException();
}
} }
} }
return result; return result;
@ -525,23 +608,34 @@ public class DeclarationWrapper implements IDeclaratorOwner
*/ */
private IASTVariable createVariableASTNode(Declarator declarator, boolean nested ) throws ASTSemanticException private IASTVariable createVariableASTNode(Declarator declarator, boolean nested ) throws ASTSemanticException
{ {
return astFactory.createVariable( try
scope, {
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(), return astFactory.createVariable(
isAuto(), scope,
declarator.getInitializerClause(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
declarator.getBitFieldExpression(), isAuto(),
astFactory.createAbstractDeclaration( declarator.getInitializerClause(),
constt, declarator.getBitFieldExpression(),
volatil, astFactory.createAbstractDeclaration(
getTypeSpecifier(), constt,
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null), volatil,
mutable, getTypeSpecifier(),
extern, declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
register, mutable,
staticc, extern,
getStartingOffset(), register,
declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getConstructorExpression()); staticc,
getStartingOffset(),
declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getConstructorExpression());
}
catch (ASTSemanticException e)
{
throw e;
}
catch (Exception e)
{
throw new ASTSemanticException();
}
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -344,7 +344,23 @@ public class Scanner implements IScanner {
} }
} }
if (inclusionReader != null) { if (inclusionReader != null) {
IASTInclusion inclusion = astFactory.createInclusion( fileName, newPath, !useIncludePaths, beginOffset, nameOffset, nameOffset + fileName.length(), endOffset ); IASTInclusion inclusion = null;
try
{
inclusion =
astFactory.createInclusion(
fileName,
newPath,
!useIncludePaths,
beginOffset,
nameOffset,
nameOffset + fileName.length(),
endOffset);
}
catch (Exception e)
{
/* do nothing */
}
contextStack.updateContext(inclusionReader, newPath, ScannerContext.INCLUSION, inclusion, requestor ); contextStack.updateContext(inclusionReader, newPath, ScannerContext.INCLUSION, inclusion, requestor );
} }
} }
@ -2010,10 +2026,28 @@ public class Scanner implements IScanner {
{ {
if( requestor != null ) if( requestor != null )
{ {
IASTInclusion i = astFactory.createInclusion( f, "", !useIncludePath, beginningOffset, IASTInclusion i = null;
startOffset, startOffset + f.length(), endOffset ); try
i.enterScope( requestor ); {
i.exitScope( requestor ); i =
astFactory.createInclusion(
f,
"",
!useIncludePath,
beginningOffset,
startOffset,
startOffset + f.length(),
endOffset);
}
catch (Exception e)
{
/* do nothing */
}
if( i != null )
{
i.enterScope( requestor );
i.exitScope( requestor );
}
} }
} }
else else
@ -2168,7 +2202,14 @@ public class Scanner implements IScanner {
throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() ); throw new ScannerException( ScannerException.ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE, getCurrentFile(), getCurrentOffset() );
} }
astFactory.createMacro( key, beginning, offset, offset + key.length(), contextStack.getCurrentContext().getOffset() ).acceptElement( requestor ); try
{
astFactory.createMacro( key, beginning, offset, offset + key.length(), contextStack.getCurrentContext().getOffset() ).acceptElement( requestor );
}
catch (Exception e)
{
/* do nothing */
}
} }
protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException { protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException {

View file

@ -154,7 +154,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
result = startingScope.qualifiedLookup(name, type); result = startingScope.qualifiedLookup(name, type);
} }
} catch (ParserSymbolTableException e) { } catch (ParserSymbolTableException e) {
throw e; if( e.reason != ParserSymbolTableException.r_UnableToResolveFunction )
throw e;
} }
return result; return result;
} }
@ -215,14 +216,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
try try
{ {
result = lookupElement(startingScope, firstSymbol.getImage(), type, parameters); result = lookupElement(startingScope, firstSymbol.getImage(), type, parameters);
/* if(type == TypeInfo.t_function) if( result != null )
if (validParameterList(parameters))
result = startingScope.unqualifiedFunctionLookup( firstSymbol.getImage(), new LinkedList(parameters));
else
result = null;
else
result = startingScope.lookup( firstSymbol.getImage());
*/ if( result != null )
addReference( references, createReference( result, firstSymbol.getImage(), firstSymbol.getOffset() )); addReference( references, createReference( result, firstSymbol.getImage(), firstSymbol.getOffset() ));
else else
throw new ASTSemanticException(); throw new ASTSemanticException();
@ -248,14 +242,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{ {
if( t == name.getLastToken() ) if( t == name.getLastToken() )
result = lookupElement((IContainerSymbol)result, t.getImage(), type, parameters); result = lookupElement((IContainerSymbol)result, t.getImage(), type, parameters);
/* if((type == TypeInfo.t_function) || (type == TypeInfo.t_constructor)) else
if (validParameterList(parameters))
result = ((IContainerSymbol)result).qualifiedFunctionLookup( t.getImage(), new LinkedList(parameters) );
else
result = null;
else
result = ((IContainerSymbol)result).qualifiedLookup( t.getImage() );
*/ else
result = ((IContainerSymbol)result).lookupNestedNameSpecifier( t.getImage() ); result = ((IContainerSymbol)result).lookupNestedNameSpecifier( t.getImage() );
addReference( references, createReference( result, t.getImage(), t.getOffset() )); addReference( references, createReference( result, t.getImage(), t.getOffset() ));
} }
@ -857,7 +844,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
* Apply the usual arithmetic conversions to find out the result of an expression * Apply the usual arithmetic conversions to find out the result of an expression
* that has a lhs and a rhs as indicated in the specs (section 5.Expressions, page 64) * that has a lhs and a rhs as indicated in the specs (section 5.Expressions, page 64)
*/ */
protected TypeInfo usualArithmeticConversions(TypeInfo lhs, TypeInfo rhs){ protected TypeInfo usualArithmeticConversions(TypeInfo lhs, TypeInfo rhs) throws ASTSemanticException{
// if you have a variable of type basic type, then we need to go to the basic type first // if you have a variable of type basic type, then we need to go to the basic type first
while( (lhs.getType() == TypeInfo.t_type) && (lhs.getTypeSymbol() != null)){ while( (lhs.getType() == TypeInfo.t_type) && (lhs.getTypeSymbol() != null)){
@ -867,6 +854,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
rhs = rhs.getTypeSymbol().getTypeInfo(); rhs = rhs.getTypeSymbol().getTypeInfo();
} }
if( lhs.isType(TypeInfo.t_class, TypeInfo.t_enumeration ) ||
rhs.isType(TypeInfo.t_class, TypeInfo.t_enumeration ) )
{
throw new ASTSemanticException();
}
TypeInfo info = new TypeInfo(); TypeInfo info = new TypeInfo();
if( if(
( lhs.checkBit(TypeInfo.isLong) && lhs.getType() == TypeInfo.t_double) ( lhs.checkBit(TypeInfo.isLong) && lhs.getType() == TypeInfo.t_double)
@ -929,6 +922,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
} }
} }
protected List getExpressionResultType(IASTExpression expression, ISymbol symbol)throws ASTSemanticException{ protected List getExpressionResultType(IASTExpression expression, ISymbol symbol)throws ASTSemanticException{
List result = new ArrayList(); List result = new ArrayList();
TypeInfo info = new TypeInfo(); TypeInfo info = new TypeInfo();
try { try {
@ -1165,6 +1160,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next(); TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next();
info = usualArithmeticConversions(leftType, rightType); info = usualArithmeticConversions(leftType, rightType);
} }
else
throw new ASTSemanticException();
result.add(info); result.add(info);
return result; return result;
} }