mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Corrects handling of backtrack exceptions.
This commit is contained in:
parent
588b7c399d
commit
a1d528d6c7
2 changed files with 27 additions and 34 deletions
|
@ -1564,10 +1564,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
decl= declaration(option);
|
||||
break;
|
||||
} catch (BacktrackException bt2) {
|
||||
n= bt.getNodeBeforeProblem();
|
||||
n= bt2.getNodeBeforeProblem();
|
||||
if (n instanceof IASTDeclaration) {
|
||||
decl= (IASTDeclaration) n;
|
||||
trailingProblem= buildProblemDeclaration(bt.getProblem());
|
||||
trailingProblem= buildProblemDeclaration(bt2.getProblem());
|
||||
break;
|
||||
}
|
||||
} catch (EndOfFileException e) {
|
||||
|
@ -1727,7 +1727,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
ds = nodeFactory.newDeclarationStatement(d);
|
||||
((ASTNode) ds).setOffsetAndLength(((ASTNode) d).getOffset(), ((ASTNode) d).getLength());
|
||||
} catch (BacktrackException b) {
|
||||
backup(mark);
|
||||
if (expressionStatement == null) {
|
||||
throw b;
|
||||
}
|
||||
|
|
|
@ -497,12 +497,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
} else {
|
||||
// not a type-id - try as expression
|
||||
backup(argStart);
|
||||
try {
|
||||
IASTExpression expression = assignmentExpression();
|
||||
list.add(expression);
|
||||
} catch (BacktrackException e) {
|
||||
backup(argStart);
|
||||
}
|
||||
}
|
||||
|
||||
if (LT(1) == IToken.tCOMMA) {
|
||||
|
@ -671,6 +667,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
try {
|
||||
throwExpression = expression();
|
||||
} catch (BacktrackException bte) {
|
||||
backup(throwToken);
|
||||
consume();
|
||||
}
|
||||
int o = throwExpression != null ? calculateEndOffset(throwExpression)
|
||||
: throwToken.getEndOffset();
|
||||
|
@ -1368,7 +1366,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
* request for a backtrack
|
||||
*/
|
||||
protected IASTDeclaration templateDeclaration(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||
IToken mark = mark();
|
||||
IToken firstToken = null;
|
||||
boolean exported = false;
|
||||
boolean encounteredExtraMod = false;
|
||||
|
@ -1429,7 +1426,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return templateSpecialization;
|
||||
}
|
||||
|
||||
try {
|
||||
final boolean wasOnTop= onTopInTemplateArgs;
|
||||
onTopInTemplateArgs= true;
|
||||
List<ICPPASTTemplateParameter> parms;
|
||||
|
@ -1448,10 +1444,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
templateDecl.addTemplateParamter(parm);
|
||||
}
|
||||
return templateDecl;
|
||||
} catch (BacktrackException bt) {
|
||||
backup(mark);
|
||||
throw bt;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1607,11 +1599,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
} catch (BacktrackException e) {
|
||||
if (option != DeclarationOptions.CPP_MEMBER || declarationMark == null)
|
||||
throw e;
|
||||
BacktrackException orig= new BacktrackException(e); // copy the exception
|
||||
IToken mark= mark();
|
||||
backup(declarationMark);
|
||||
try {
|
||||
return usingDeclaration(declarationMark.getOffset());
|
||||
} catch (BacktrackException e2) {
|
||||
throw e; // throw original exception;
|
||||
backup(mark);
|
||||
throw orig; // throw original exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2670,8 +2665,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (!canBeTypeSpecifier()) {
|
||||
return null;
|
||||
}
|
||||
IToken mark = mark();
|
||||
int startingOffset = mark.getOffset();
|
||||
int startingOffset = mark().getOffset();
|
||||
IASTDeclSpecifier declSpecifier = null;
|
||||
IASTDeclarator declarator = null;
|
||||
rejectLogicalOperatorInTemplateID++;
|
||||
|
|
Loading…
Add table
Reference in a new issue