diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseProblemTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseProblemTest.java index 0d34cb19864..a53f240a79d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseProblemTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseProblemTest.java @@ -10,8 +10,12 @@ ***********************************************************************/ package org.eclipse.cdt.core.parser.tests; +import java.util.Iterator; + import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ParserFactoryError; +import org.eclipse.cdt.core.parser.ast.IASTFunction; +import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.internal.core.parser.ParserException; /** @@ -91,4 +95,24 @@ public class CompleteParseProblemTest extends CompleteParseBaseTest { assertEquals( p.getSourceEnd(), end ); assertEquals( p.getID(), IProblem.SEMANTIC_NAME_NOT_FOUND ); } + + public void testBug69744() throws Exception + { + String code = "int f() { try { } catch( foo bar ) {} catch ( ... ) {} } int i;"; //$NON-NLS-1$ + + Iterator i = parse( code, false ).getDeclarations(); + + int start = code.indexOf( "foo" ); //$NON-NLS-1$ + int end = start + 3; + + assertEquals( callback.problems.size(), 1 ); + IProblem p = (IProblem) callback.problems.get( 0 ); + + assertEquals( p.getSourceStart(), start ); + assertEquals( p.getSourceEnd(), end ); + assertEquals( p.getID(), IProblem.SEMANTIC_NAME_NOT_FOUND ); + + IASTFunction f = (IASTFunction) i.next(); + IASTVariable varI = (IASTVariable) i.next(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index 50a8cbd009c..bafd3eb810e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -3150,15 +3150,21 @@ public abstract class Parser extends ExpressionParser implements IParser while (LT(1) == IToken.t_catch) { consume(IToken.t_catch); consume(IToken.tLPAREN); - if (LT(1) == IToken.tELLIPSIS) - consume(IToken.tELLIPSIS); - else - simpleDeclaration(SimpleDeclarationStrategy.TRY_VARIABLE, - scope, null, CompletionKind.EXCEPTION_REFERENCE, true, - KeywordSetKey.DECL_SPECIFIER_SEQUENCE); - consume(IToken.tRPAREN); - catchBlockCompoundStatement(scope); + try { + if (LT(1) == IToken.tELLIPSIS) + consume(IToken.tELLIPSIS); + else + simpleDeclaration(SimpleDeclarationStrategy.TRY_VARIABLE, + scope, null, CompletionKind.EXCEPTION_REFERENCE, true, + KeywordSetKey.DECL_SPECIFIER_SEQUENCE); + consume(IToken.tRPAREN); + + catchBlockCompoundStatement(scope); + } catch (BacktrackException b) { + failParse(b); + failParseWithErrorHandling(); + } } }