mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed infinite loop in BinaryTests
This commit is contained in:
parent
369547850f
commit
653c8bb11e
5 changed files with 130 additions and 48 deletions
|
@ -11,6 +11,8 @@
|
||||||
package org.eclipse.cdt.core.parser.tests;
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.NullLogService;
|
import org.eclipse.cdt.core.parser.NullLogService;
|
||||||
|
@ -19,7 +21,9 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
@ -124,5 +128,37 @@ public class SelectionParseTest extends CompleteParseBaseTest {
|
||||||
assertEquals( ((IASTParameterDeclaration)node).getName(), "argc" );
|
assertEquals( ((IASTParameterDeclaration)node).getName(), "argc" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug57898() throws Exception
|
||||||
|
{
|
||||||
|
Writer writer = new StringWriter();
|
||||||
|
writer.write( "class Gonzo { public: void playHorn(); };\n" );
|
||||||
|
writer.write( "void Gonzo::playHorn() { return; }\n" );
|
||||||
|
writer.write( "int main(int argc, char **argv) { Gonzo gonzo; gonzo.playHorn(); }\n" );
|
||||||
|
String code = writer.toString();
|
||||||
|
for( int i = 0; i < 3; ++i )
|
||||||
|
{
|
||||||
|
int start = -1, stop = -1;
|
||||||
|
switch( i )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
start = code.indexOf( "void playHorn") + 5;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
start = code.indexOf( "::playHorn") + 2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
start = code.indexOf( ".playHorn") + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
stop = start + 8;
|
||||||
|
IASTNode node = parse( code, start, stop );
|
||||||
|
assertNotNull( node );
|
||||||
|
assertTrue( node instanceof IASTMethod );
|
||||||
|
IASTMethod method = (IASTMethod) node;
|
||||||
|
assertEquals( method.getName(), "playHorn");
|
||||||
|
IASTClassSpecifier gonzo = method.getOwnerClassSpecifier();
|
||||||
|
assertEquals( gonzo.getName(), "Gonzo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceAlias;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
|
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
|
||||||
|
@ -226,9 +227,10 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
* using namespace ::? nested-name-specifier? namespace-name ;
|
* using namespace ::? nested-name-specifier? namespace-name ;
|
||||||
*
|
*
|
||||||
* @param container Callback object representing the scope these definitions fall into.
|
* @param container Callback object representing the scope these definitions fall into.
|
||||||
|
* @return TODO
|
||||||
* @throws BacktrackException request for a backtrack
|
* @throws BacktrackException request for a backtrack
|
||||||
*/
|
*/
|
||||||
protected void usingClause(IASTScope scope)
|
protected IASTDeclaration usingClause(IASTScope scope)
|
||||||
throws EndOfFileException, BacktrackException
|
throws EndOfFileException, BacktrackException
|
||||||
{
|
{
|
||||||
IToken firstToken = consume(IToken.t_using);
|
IToken firstToken = consume(IToken.t_using);
|
||||||
|
@ -261,7 +263,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
astUD.acceptElement(requestor);
|
astUD.acceptElement(requestor);
|
||||||
return;
|
return astUD;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -312,6 +314,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
declaration.acceptElement( requestor );
|
declaration.acceptElement( requestor );
|
||||||
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), Key.DECLARATION );
|
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), Key.DECLARATION );
|
||||||
|
return declaration;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -327,9 +330,10 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
* | extern "string literal" { declaration-seq }
|
* | extern "string literal" { declaration-seq }
|
||||||
*
|
*
|
||||||
* @param container Callback object representing the scope these definitions fall into.
|
* @param container Callback object representing the scope these definitions fall into.
|
||||||
|
* @return TODO
|
||||||
* @throws BacktrackException request for a backtrack
|
* @throws BacktrackException request for a backtrack
|
||||||
*/
|
*/
|
||||||
protected void linkageSpecification(IASTScope scope)
|
protected IASTDeclaration linkageSpecification(IASTScope scope)
|
||||||
throws EndOfFileException, BacktrackException
|
throws EndOfFileException, BacktrackException
|
||||||
{
|
{
|
||||||
IToken firstToken = consume(IToken.t_extern);
|
IToken firstToken = consume(IToken.t_extern);
|
||||||
|
@ -383,6 +387,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
IToken lastTokenConsumed = consume();
|
IToken lastTokenConsumed = consume();
|
||||||
linkage.setEndingOffsetAndLineNumber(lastTokenConsumed.getEndOffset(), lastTokenConsumed.getLineNumber());
|
linkage.setEndingOffsetAndLineNumber(lastTokenConsumed.getEndOffset(), lastTokenConsumed.getLineNumber());
|
||||||
linkage.exitScope( requestor );
|
linkage.exitScope( requestor );
|
||||||
|
return linkage;
|
||||||
}
|
}
|
||||||
else // single declaration
|
else // single declaration
|
||||||
{
|
{
|
||||||
|
@ -403,6 +408,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
linkage.enterScope( requestor );
|
linkage.enterScope( requestor );
|
||||||
declaration(linkage, null, null);
|
declaration(linkage, null, null);
|
||||||
linkage.exitScope( requestor );
|
linkage.exitScope( requestor );
|
||||||
|
return linkage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -415,9 +421,10 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
* explicit-specialization: template <> declaration
|
* explicit-specialization: template <> declaration
|
||||||
*
|
*
|
||||||
* @param container Callback object representing the scope these definitions fall into.
|
* @param container Callback object representing the scope these definitions fall into.
|
||||||
|
* @return TODO
|
||||||
* @throws BacktrackException request for a backtrack
|
* @throws BacktrackException request for a backtrack
|
||||||
*/
|
*/
|
||||||
protected void templateDeclaration(IASTScope scope)
|
protected IASTDeclaration templateDeclaration(IASTScope scope)
|
||||||
throws EndOfFileException, BacktrackException
|
throws EndOfFileException, BacktrackException
|
||||||
{
|
{
|
||||||
IToken firstToken = null;
|
IToken firstToken = null;
|
||||||
|
@ -451,7 +458,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
templateInstantiation.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber());
|
templateInstantiation.setEndingOffsetAndLineNumber(lastToken.getEndOffset(), lastToken.getLineNumber());
|
||||||
templateInstantiation.exitScope( requestor );
|
templateInstantiation.exitScope( requestor );
|
||||||
|
|
||||||
return;
|
return templateInstantiation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -479,7 +486,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
templateSpecialization.setEndingOffsetAndLineNumber(
|
templateSpecialization.setEndingOffsetAndLineNumber(
|
||||||
lastToken.getEndOffset(), lastToken.getLineNumber());
|
lastToken.getEndOffset(), lastToken.getLineNumber());
|
||||||
templateSpecialization.exitScope(requestor);
|
templateSpecialization.exitScope(requestor);
|
||||||
return;
|
return templateSpecialization;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,6 +519,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
|
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||||
templateDecl.exitScope( requestor );
|
templateDecl.exitScope( requestor );
|
||||||
|
return templateDecl;
|
||||||
}
|
}
|
||||||
catch (BacktrackException bt)
|
catch (BacktrackException bt)
|
||||||
{
|
{
|
||||||
|
@ -713,7 +721,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, overideKind);
|
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, overideKind);
|
||||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||||
|
IASTDeclaration resultDeclaration = null;
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
{
|
{
|
||||||
case IToken.t_asm :
|
case IToken.t_asm :
|
||||||
|
@ -724,10 +732,9 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
IToken last = consume(IToken.tSEMI);
|
IToken last = consume(IToken.tSEMI);
|
||||||
|
|
||||||
IASTASMDefinition asmDefinition;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
asmDefinition =
|
resultDeclaration =
|
||||||
astFactory.createASMDefinition(
|
astFactory.createASMDefinition(
|
||||||
scope,
|
scope,
|
||||||
assembly,
|
assembly,
|
||||||
|
@ -741,29 +748,30 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
// if we made it this far, then we have all we need
|
// if we made it this far, then we have all we need
|
||||||
// do the callback
|
// do the callback
|
||||||
asmDefinition.acceptElement(requestor);
|
resultDeclaration.acceptElement(requestor);
|
||||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||||
return;
|
break;
|
||||||
case IToken.t_namespace :
|
case IToken.t_namespace :
|
||||||
namespaceDefinition(scope);
|
resultDeclaration = namespaceDefinition(scope);
|
||||||
return;
|
break;
|
||||||
case IToken.t_using :
|
case IToken.t_using :
|
||||||
usingClause(scope);
|
resultDeclaration = usingClause(scope);
|
||||||
return;
|
break;
|
||||||
case IToken.t_export :
|
case IToken.t_export :
|
||||||
case IToken.t_template :
|
case IToken.t_template :
|
||||||
templateDeclaration(scope);
|
resultDeclaration = templateDeclaration(scope);
|
||||||
return;
|
break;
|
||||||
case IToken.t_extern :
|
case IToken.t_extern :
|
||||||
if (LT(2) == IToken.tSTRING)
|
if (LT(2) == IToken.tSTRING)
|
||||||
{
|
{
|
||||||
linkageSpecification(scope);
|
resultDeclaration = linkageSpecification(scope);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
simpleDeclarationStrategyUnion(scope, ownerTemplate, overideKind, Key.DECLARATION );
|
resultDeclaration = simpleDeclarationStrategyUnion(scope, ownerTemplate, overideKind, Key.DECLARATION );
|
||||||
}
|
}
|
||||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||||
|
endDeclaration( resultDeclaration );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -774,7 +782,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void simpleDeclarationStrategyUnion(
|
protected IASTDeclaration simpleDeclarationStrategyUnion(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
IASTTemplate ownerTemplate, CompletionKind overrideKind, Key overrideKey)
|
IASTTemplate ownerTemplate, CompletionKind overrideKind, Key overrideKey)
|
||||||
throws EndOfFileException, BacktrackException
|
throws EndOfFileException, BacktrackException
|
||||||
|
@ -783,7 +791,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
simpleDeclaration(
|
return simpleDeclaration(
|
||||||
SimpleDeclarationStrategy.TRY_CONSTRUCTOR,
|
SimpleDeclarationStrategy.TRY_CONSTRUCTOR,
|
||||||
scope,
|
scope,
|
||||||
ownerTemplate, overrideKind, false, overrideKey);
|
ownerTemplate, overrideKind, false, overrideKey);
|
||||||
|
@ -796,7 +804,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
simpleDeclaration(
|
return simpleDeclaration(
|
||||||
SimpleDeclarationStrategy.TRY_FUNCTION,
|
SimpleDeclarationStrategy.TRY_FUNCTION,
|
||||||
scope,
|
scope,
|
||||||
ownerTemplate, overrideKind, false, overrideKey);
|
ownerTemplate, overrideKind, false, overrideKey);
|
||||||
|
@ -807,7 +815,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
simpleDeclaration(
|
return simpleDeclaration(
|
||||||
SimpleDeclarationStrategy.TRY_VARIABLE,
|
SimpleDeclarationStrategy.TRY_VARIABLE,
|
||||||
scope,
|
scope,
|
||||||
ownerTemplate, overrideKind, false, overrideKey);
|
ownerTemplate, overrideKind, false, overrideKey);
|
||||||
|
@ -828,10 +836,11 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
* namespace-body:
|
* namespace-body:
|
||||||
* declaration-seq?
|
* declaration-seq?
|
||||||
* @param container IParserCallback object which serves as the owner scope for this declaration.
|
* @param container IParserCallback object which serves as the owner scope for this declaration.
|
||||||
|
* @return TODO
|
||||||
* @throws BacktrackException request a backtrack
|
* @throws BacktrackException request a backtrack
|
||||||
|
|
||||||
*/
|
*/
|
||||||
protected void namespaceDefinition(IASTScope scope)
|
protected IASTDeclaration namespaceDefinition(IASTScope scope)
|
||||||
throws BacktrackException, EndOfFileException
|
throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
IToken first = consume(IToken.t_namespace);
|
IToken first = consume(IToken.t_namespace);
|
||||||
|
@ -898,6 +907,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
last.getOffset() + last.getLength(), last.getLineNumber());
|
last.getOffset() + last.getLength(), last.getLineNumber());
|
||||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||||
namespaceDefinition.exitScope( requestor );
|
namespaceDefinition.exitScope( requestor );
|
||||||
|
return namespaceDefinition;
|
||||||
}
|
}
|
||||||
else if( LT(1) == IToken.tASSIGN )
|
else if( LT(1) == IToken.tASSIGN )
|
||||||
{
|
{
|
||||||
|
@ -910,9 +920,10 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY);
|
ITokenDuple duple = name(scope, CompletionKind.NAMESPACE_REFERENCE, Key.EMPTY);
|
||||||
consume( IToken.tSEMI );
|
consume( IToken.tSEMI );
|
||||||
setCompletionValues(scope, kind, Key.DECLARATION );
|
setCompletionValues(scope, kind, Key.DECLARATION );
|
||||||
|
IASTNamespaceAlias alias = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
astFactory.createNamespaceAlias(
|
alias = astFactory.createNamespaceAlias(
|
||||||
scope, identifier.getImage(), duple, first.getOffset(),
|
scope, identifier.getImage(), duple, first.getOffset(),
|
||||||
first.getLineNumber(), identifier.getOffset(), identifier.getEndOffset(), identifier.getLineNumber(), duple.getLastToken().getEndOffset(), duple.getLastToken().getLineNumber() );
|
first.getLineNumber(), identifier.getOffset(), identifier.getEndOffset(), identifier.getLineNumber(), duple.getLastToken().getEndOffset(), duple.getLastToken().getLineNumber() );
|
||||||
}
|
}
|
||||||
|
@ -921,6 +932,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
logException( "namespaceDefinition:createNamespaceAlias", e1 ); //$NON-NLS-1$
|
logException( "namespaceDefinition:createNamespaceAlias", e1 ); //$NON-NLS-1$
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
return alias;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -942,9 +954,10 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
*
|
*
|
||||||
* @param container IParserCallback object which serves as the owner scope for this declaration.
|
* @param container IParserCallback object which serves as the owner scope for this declaration.
|
||||||
* @param tryConstructor true == take strategy1 (constructor ) : false == take strategy 2 ( pointer to function)
|
* @param tryConstructor true == take strategy1 (constructor ) : false == take strategy 2 ( pointer to function)
|
||||||
|
* @return TODO
|
||||||
* @throws BacktrackException request a backtrack
|
* @throws BacktrackException request a backtrack
|
||||||
*/
|
*/
|
||||||
protected void simpleDeclaration(
|
protected IASTDeclaration simpleDeclaration(
|
||||||
SimpleDeclarationStrategy strategy,
|
SimpleDeclarationStrategy strategy,
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler, Key overrideKey)
|
IASTTemplate ownerTemplate, CompletionKind overideKind, boolean fromCatchHandler, Key overrideKey)
|
||||||
|
@ -1034,7 +1047,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fromCatchHandler )
|
if( fromCatchHandler )
|
||||||
return;
|
return null;
|
||||||
|
|
||||||
if( hasFunctionTryBlock && ! hasFunctionBody )
|
if( hasFunctionTryBlock && ! hasFunctionBody )
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
@ -1058,13 +1071,15 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
{
|
{
|
||||||
if (!hasFunctionBody)
|
if (!hasFunctionBody)
|
||||||
{
|
{
|
||||||
|
IASTDeclaration declaration = null;
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
{
|
{
|
||||||
IASTDeclaration declaration = (IASTDeclaration)i.next();
|
declaration = (IASTDeclaration)i.next();
|
||||||
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber(
|
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber(
|
||||||
lastToken.getEndOffset(), lastToken.getLineNumber());
|
lastToken.getEndOffset(), lastToken.getLineNumber());
|
||||||
declaration.acceptElement( requestor );
|
declaration.acceptElement( requestor );
|
||||||
}
|
}
|
||||||
|
return declaration;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1083,6 +1098,8 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
if( hasFunctionTryBlock )
|
if( hasFunctionTryBlock )
|
||||||
catchHandlerSequence( scope );
|
catchHandlerSequence( scope );
|
||||||
|
|
||||||
|
return declaration;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1092,14 +1109,15 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
{
|
{
|
||||||
if( sdw.getTypeSpecifier() != null )
|
if( sdw.getTypeSpecifier() != null )
|
||||||
{
|
{
|
||||||
astFactory.createTypeSpecDeclaration(
|
IASTAbstractTypeSpecifierDeclaration declaration = astFactory.createTypeSpecDeclaration(
|
||||||
sdw.getScope(),
|
sdw.getScope(),
|
||||||
sdw.getTypeSpecifier(),
|
sdw.getTypeSpecifier(),
|
||||||
ownerTemplate,
|
ownerTemplate,
|
||||||
sdw.getStartingOffset(),
|
sdw.getStartingOffset(),
|
||||||
sdw.getStartingLine(), lastToken.getEndOffset(), lastToken.getLineNumber(),
|
sdw.getStartingLine(), lastToken.getEndOffset(), lastToken.getLineNumber(),
|
||||||
sdw.isFriend())
|
sdw.isFriend());
|
||||||
.acceptElement(requestor);
|
declaration.acceptElement(requestor);
|
||||||
|
return declaration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
|
@ -1108,7 +1126,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2741,14 +2759,17 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
constant_expression.acceptElement(requestor);
|
constant_expression.acceptElement(requestor);
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
statement(scope);
|
statement(scope);
|
||||||
|
cleanupLastToken();
|
||||||
return;
|
return;
|
||||||
case IToken.t_default :
|
case IToken.t_default :
|
||||||
consume(IToken.t_default);
|
consume(IToken.t_default);
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
statement(scope);
|
statement(scope);
|
||||||
|
cleanupLastToken();
|
||||||
return;
|
return;
|
||||||
case IToken.tLBRACE :
|
case IToken.tLBRACE :
|
||||||
compoundStatement(scope, true);
|
compoundStatement(scope, true);
|
||||||
|
cleanupLastToken();
|
||||||
return;
|
return;
|
||||||
case IToken.t_if :
|
case IToken.t_if :
|
||||||
consume( IToken.t_if );
|
consume( IToken.t_if );
|
||||||
|
@ -2767,6 +2788,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
else
|
else
|
||||||
statement( scope );
|
statement( scope );
|
||||||
}
|
}
|
||||||
|
cleanupLastToken();
|
||||||
return;
|
return;
|
||||||
case IToken.t_switch :
|
case IToken.t_switch :
|
||||||
consume();
|
consume();
|
||||||
|
@ -2774,6 +2796,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
condition(scope);
|
condition(scope);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
statement(scope);
|
statement(scope);
|
||||||
|
cleanupLastToken();
|
||||||
return;
|
return;
|
||||||
case IToken.t_while :
|
case IToken.t_while :
|
||||||
consume(IToken.t_while);
|
consume(IToken.t_while);
|
||||||
|
@ -2784,6 +2807,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
singleStatementScope(scope);
|
singleStatementScope(scope);
|
||||||
else
|
else
|
||||||
statement(scope);
|
statement(scope);
|
||||||
|
cleanupLastToken();
|
||||||
return;
|
return;
|
||||||
case IToken.t_do :
|
case IToken.t_do :
|
||||||
consume(IToken.t_do);
|
consume(IToken.t_do);
|
||||||
|
@ -2795,6 +2819,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
condition(scope);
|
condition(scope);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
cleanupLastToken();
|
||||||
return;
|
return;
|
||||||
case IToken.t_for :
|
case IToken.t_for :
|
||||||
consume();
|
consume();
|
||||||
|
@ -2810,6 +2835,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
statement(scope);
|
statement(scope);
|
||||||
|
cleanupLastToken();
|
||||||
return;
|
return;
|
||||||
case IToken.t_break :
|
case IToken.t_break :
|
||||||
consume();
|
consume();
|
||||||
|
@ -3073,4 +3099,23 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
protected IASTNode getCompliationUnit() {
|
protected IASTNode getCompliationUnit() {
|
||||||
return compilationUnit;
|
return compilationUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void endDeclaration( IASTDeclaration declaration ) throws EndOfFileException
|
||||||
|
{
|
||||||
|
cleanupLastToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void cleanupLastToken() {
|
||||||
|
if( lastToken != null )
|
||||||
|
lastToken.setNext( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void endExpressionStatement( IASTExpression expression ) throws EndOfFileException
|
||||||
|
{
|
||||||
|
cleanupLastToken();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,7 +289,7 @@ public final class TemplateEngine {
|
||||||
List pPtrs = p.getPtrOperators();
|
List pPtrs = p.getPtrOperators();
|
||||||
if( pPtrs.size() > 0 ){
|
if( pPtrs.size() > 0 ){
|
||||||
PtrOp pOp = (PtrOp) pPtrs.get( 0 );
|
PtrOp pOp = (PtrOp) pPtrs.get( 0 );
|
||||||
if( pOp.getType() == PtrOp.t_reference || pOp.getType() == PtrOp.t_undef ){
|
if( pOp.getType() == PtrOp.t_reference || pOp.getType() == PtrOp.t_undef_ptr ){
|
||||||
pPtrs.remove( 0 );
|
pPtrs.remove( 0 );
|
||||||
} else {
|
} else {
|
||||||
PtrOp newOp = new PtrOp( pOp.getType(), false, false );
|
PtrOp newOp = new PtrOp( pOp.getType(), false, false );
|
||||||
|
|
|
@ -166,13 +166,13 @@ public class TypeInfo {
|
||||||
}
|
}
|
||||||
public PtrOp( TypeInfo.eType type, boolean isConst, boolean isVolatile ){
|
public PtrOp( TypeInfo.eType type, boolean isConst, boolean isVolatile ){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.isConst = isConst;
|
this.isConstPtr = isConst;
|
||||||
this.isVolatile = isVolatile;
|
this.isVolatilePtr = isVolatile;
|
||||||
}
|
}
|
||||||
public PtrOp( ISymbol memberOf, boolean isConst, boolean isVolatile ){
|
public PtrOp( ISymbol memberOf, boolean isConst, boolean isVolatile ){
|
||||||
this.type = PtrOp.t_memberPointer;
|
this.type = PtrOp.t_memberPointer;
|
||||||
this.isConst = isConst;
|
this.isConstPtr = isConst;
|
||||||
this.isVolatile = isVolatile;
|
this.isVolatilePtr = isVolatile;
|
||||||
this.memberOf = memberOf;
|
this.memberOf = memberOf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ public class TypeInfo {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final TypeInfo.eType t_undef = new TypeInfo.eType( 0 );
|
public static final TypeInfo.eType t_undef_ptr = new TypeInfo.eType( 0 );
|
||||||
public static final TypeInfo.eType t_pointer = new TypeInfo.eType( 1 );
|
public static final TypeInfo.eType t_pointer = new TypeInfo.eType( 1 );
|
||||||
public static final TypeInfo.eType t_reference = new TypeInfo.eType( 2 );
|
public static final TypeInfo.eType t_reference = new TypeInfo.eType( 2 );
|
||||||
public static final TypeInfo.eType t_array = new TypeInfo.eType( 3 );
|
public static final TypeInfo.eType t_array = new TypeInfo.eType( 3 );
|
||||||
|
@ -189,10 +189,10 @@ public class TypeInfo {
|
||||||
public TypeInfo.eType getType() { return type; }
|
public TypeInfo.eType getType() { return type; }
|
||||||
public void setType( TypeInfo.eType type ) { this.type = type; }
|
public void setType( TypeInfo.eType type ) { this.type = type; }
|
||||||
|
|
||||||
public boolean isConst() { return isConst; }
|
public boolean isConst() { return isConstPtr; }
|
||||||
public boolean isVolatile() { return isVolatile; }
|
public boolean isVolatile() { return isVolatilePtr; }
|
||||||
public void setConst( boolean isConst ) { this.isConst = isConst; }
|
public void setConst( boolean isConst ) { this.isConstPtr = isConst; }
|
||||||
public void setVolatile(boolean isVolatile) { this.isVolatile = isVolatile; }
|
public void setVolatile(boolean isVolatile) { this.isVolatilePtr = isVolatile; }
|
||||||
|
|
||||||
public ISymbol getMemberOf() { return memberOf; }
|
public ISymbol getMemberOf() { return memberOf; }
|
||||||
public void setMemberOf( ISymbol member ) { this.memberOf = member; }
|
public void setMemberOf( ISymbol member ) { this.memberOf = member; }
|
||||||
|
@ -214,9 +214,9 @@ public class TypeInfo {
|
||||||
getType() == op.getType() );
|
getType() == op.getType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeInfo.eType type = PtrOp.t_undef;
|
private TypeInfo.eType type = PtrOp.t_undef_ptr;
|
||||||
private boolean isConst = false;
|
private boolean isConstPtr = false;
|
||||||
private boolean isVolatile = false;
|
private boolean isVolatilePtr = false;
|
||||||
private ISymbol memberOf = null;
|
private ISymbol memberOf = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,6 +326,7 @@ public class CDescriptorManager implements ICDescriptorManager, IResourceChangeL
|
||||||
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
|
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
|
||||||
CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$
|
CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$
|
||||||
CCorePlugin.log(status);
|
CCorePlugin.log(status);
|
||||||
|
iterator.next(); // increment the iterator remove infinite loop
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
|
|
Loading…
Add table
Reference in a new issue