From 1193d6341ad48e3769da6dc137e9f19230f23eef Mon Sep 17 00:00:00 2001 From: John Camelon Date: Thu, 3 Jun 2004 00:38:37 +0000 Subject: [PATCH] Fixed bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=47752
Fixed bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=64321 --- .../parser/tests/CompleteParseASTTest.java | 21 ++++++++++++++++++- .../cdt/internal/core/parser/Parser.java | 7 ++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java index 69ce4029013..b83ad9cf772 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java @@ -1889,6 +1889,25 @@ public class CompleteParseASTTest extends CompleteParseBaseTest writer.write( "blah3\n"); //$NON-NLS-1$ writer.write( "};\n"); //$NON-NLS-1$ writer.write( "e mye = blah;\n"); //$NON-NLS-1$ - parse( writer.toString().toString() ); + parse( writer.toString() ); + } + + public void testBug47752() throws Exception + { + Writer writer = new StringWriter(); + writer.write( "class BBC\n"); //$NON-NLS-1$ + writer.write( "{\n"); //$NON-NLS-1$ + writer.write( "int x;\n"); //$NON-NLS-1$ + writer.write( "};\n"); //$NON-NLS-1$ + writer.write( "void func( BBC bar )\n"); //$NON-NLS-1$ + writer.write( "try\n"); //$NON-NLS-1$ + writer.write( "{\n"); //$NON-NLS-1$ + writer.write( "}\n"); //$NON-NLS-1$ + writer.write( "catch ( BBC error )\n"); //$NON-NLS-1$ + writer.write( "{\n"); //$NON-NLS-1$ + writer.write( " //... error handling code ...\n"); //$NON-NLS-1$ + writer.write( "}\n"); //$NON-NLS-1$ + parse( writer.toString() ); + assertEquals( callback.getReferences().size(), 2 ); } } 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 510841e956c..a0ed5f8f097 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 @@ -1093,10 +1093,7 @@ public abstract class Parser extends ExpressionParser implements IParser declarator.setHasFunctionBody(true); hasFunctionBody = true; } - - if( fromCatchHandler ) - return null; - + if( hasFunctionTryBlock && ! hasFunctionBody ) throw backtrack; } @@ -1122,7 +1119,7 @@ public abstract class Parser extends ExpressionParser implements IParser } if (i.hasNext()) // no need to do this unless we have a declarator { - if (!hasFunctionBody) + if (!hasFunctionBody || fromCatchHandler) { IASTDeclaration declaration = null; while (i.hasNext())