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:
parent
74962ae0c5
commit
2586ae45c5
2 changed files with 19 additions and 3 deletions
|
@ -146,12 +146,13 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertNoProblemBindings( col );
|
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$
|
IASTTranslationUnit tu = parse( code, ParserLanguage.CPP ); //$NON-NLS-1$
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
assertNoProblemBindings( col );
|
assertNoProblemBindings( col );
|
||||||
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,12 +118,13 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertNoProblemBindings( col );
|
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$
|
IASTTranslationUnit tu = parse( code, ParserLanguage.C ); //$NON-NLS-1$
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
assertNoProblemBindings( col );
|
assertNoProblemBindings( col );
|
||||||
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBasicFunction() throws Exception {
|
public void testBasicFunction() throws Exception {
|
||||||
|
@ -3294,4 +3295,18 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
buffer.append("}\n" ); //$NON-NLS-1$
|
buffer.append("}\n" ); //$NON-NLS-1$
|
||||||
parseAndCheckBindings( buffer.toString() );
|
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$
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue