1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed Bug 84759 Return type of functions which returns enum instance is incorrect

Committed test case.
This commit is contained in:
John Camelon 2005-07-12 20:02:53 +00:00
parent 74962ae0c5
commit 2586ae45c5
2 changed files with 19 additions and 3 deletions

View file

@ -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;
}

View file

@ -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 );
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$
}
}