From 2586ae45c5d90dd14c6197b5c2c6ea1692442937 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Tue, 12 Jul 2005 20:02:53 +0000 Subject: [PATCH] Fixed Bug 84759 Return type of functions which returns enum instance is incorrect Committed test case. --- .../core/parser/tests/ast2/AST2CPPTests.java | 3 ++- .../cdt/core/parser/tests/ast2/AST2Tests.java | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 783b45a9a81..0a483ef35a3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -146,12 +146,13 @@ public class AST2CPPTests extends AST2BaseTest { assertNoProblemBindings( col ); } - protected void parseAndCheckBindings( String code ) throws Exception + protected IASTTranslationUnit parseAndCheckBindings( String code ) throws Exception { IASTTranslationUnit tu = parse( code, ParserLanguage.CPP ); //$NON-NLS-1$ CPPNameCollector col = new CPPNameCollector(); tu.accept(col); assertNoProblemBindings( col ); + return tu; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index f3d904d8483..2fbd2aada35 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -118,12 +118,13 @@ public class AST2Tests extends AST2BaseTest { assertNoProblemBindings( col ); } - protected void parseAndCheckBindings( String code ) throws Exception + protected IASTTranslationUnit parseAndCheckBindings( String code ) throws Exception { IASTTranslationUnit tu = parse( code, ParserLanguage.C ); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); - assertNoProblemBindings( col ); + assertNoProblemBindings( col ); + return tu; } public void testBasicFunction() throws Exception { @@ -3294,4 +3295,18 @@ public class AST2Tests extends AST2BaseTest { buffer.append("}\n" ); //$NON-NLS-1$ parseAndCheckBindings( buffer.toString() ); } + + public void testBug84759() throws Exception { + StringBuffer buffer = new StringBuffer("enum COLOR {\n" ); //$NON-NLS-1$ + buffer.append( "RED=1\n" ); //$NON-NLS-1$ + buffer.append( "};\n" ); //$NON-NLS-1$ + buffer.append( "enum COLOR getColor() {\n" ); //$NON-NLS-1$ + buffer.append( "enum COLOR ret;\n" ); //$NON-NLS-1$ + buffer.append( "return ret;\n" ); //$NON-NLS-1$ + buffer.append( "}\n" ); //$NON-NLS-1$ + IASTTranslationUnit tu = parseAndCheckBindings( buffer.toString() ); + IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1]; + assertEquals( fd.getDeclSpecifier().getRawSignature(), "enum COLOR"); //$NON-NLS-1$ + + } } \ No newline at end of file