mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 19:25:38 +02:00
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=60142 and updated CModel tests appropriately.
This commit is contained in:
parent
7a2c6de5fb
commit
31cfba78a4
3 changed files with 14 additions and 63 deletions
|
@ -312,14 +312,14 @@ public class CModelElementsTests extends TestCase {
|
|||
IVariable var2 = (IVariable) nsVars.get(1);
|
||||
assertEquals(var2.getElementName(), new String("vuLong"));
|
||||
checkElementOffset((CElement)var2);
|
||||
assertEquals(var2.getTypeName(), new String("unsigned long int"));
|
||||
assertEquals(var2.getTypeName(), new String("unsigned long"));
|
||||
checkLineNumbers((CElement)var2, 73, 73);
|
||||
|
||||
// MyPackage ---> unsigned short vuShort
|
||||
IVariable var3 = (IVariable) nsVars.get(2);
|
||||
assertEquals(var3.getElementName(), new String("vuShort"));
|
||||
checkElementOffset((CElement)var3);
|
||||
assertEquals(var3.getTypeName(), new String("unsigned short int"));
|
||||
assertEquals(var3.getTypeName(), new String("unsigned short"));
|
||||
checkLineNumbers((CElement)var3, 75, 75);
|
||||
|
||||
// MyPackage ---> function pointer: orig_malloc_hook
|
||||
|
|
|
@ -2230,4 +2230,15 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
parse( "int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };", true, true, ParserLanguage.C );
|
||||
}
|
||||
|
||||
public void testBug60142() throws Exception
|
||||
{
|
||||
IASTVariable var = (IASTVariable) assertSoleDeclaration( "unsigned long var;");
|
||||
assertEquals( var.getName(), "var");
|
||||
IASTSimpleTypeSpecifier specifier = ((IASTSimpleTypeSpecifier)var.getAbstractDeclaration().getTypeSpecifier());
|
||||
assertEquals( specifier.getTypename(), "unsigned long" );
|
||||
assertTrue( specifier.isLong() );
|
||||
assertTrue( specifier.isUnsigned() );
|
||||
assertEquals( specifier.getType(), IASTSimpleTypeSpecifier.Type.INT );
|
||||
}
|
||||
|
||||
}
|
|
@ -59,67 +59,7 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
|||
this.complex = isComplex;
|
||||
this.imaginary = isImaginary;
|
||||
|
||||
StringBuffer type = new StringBuffer();
|
||||
if( this.kind == IASTSimpleTypeSpecifier.Type.CHAR || this.kind == IASTSimpleTypeSpecifier.Type.WCHAR_T )
|
||||
{
|
||||
if (isUnsigned())
|
||||
type.append("unsigned "); //$NON-NLS-1$
|
||||
else if( isSigned() )
|
||||
type.append("signed "); //$NON-NLS-1$
|
||||
type.append( (String)nameMap.get( this.kind ));
|
||||
}
|
||||
else if( this.kind == Type.BOOL || this.kind == Type.VOID || this.kind == Type._BOOL )
|
||||
{
|
||||
type.append( (String) nameMap.get( this.kind ));
|
||||
}
|
||||
else if( this.kind == Type.INT )
|
||||
{
|
||||
if (isUnsigned())
|
||||
type.append("unsigned "); //$NON-NLS-1$
|
||||
if (isShort())
|
||||
type.append("short "); //$NON-NLS-1$
|
||||
if (isLong())
|
||||
type.append("long "); //$NON-NLS-1$
|
||||
type.append( (String)nameMap.get( this.kind ));
|
||||
}
|
||||
else if( this.kind == Type.FLOAT )
|
||||
{
|
||||
type.append( (String)nameMap.get( this.kind ));
|
||||
if( isComplex() )
|
||||
type.append( "_Complex" ); //$NON-NLS-1$
|
||||
else if( isImaginary() )
|
||||
type.append( "_Imaginary" ); //$NON-NLS-1$
|
||||
}
|
||||
else if( this.kind == Type.DOUBLE )
|
||||
{
|
||||
if (isLong())
|
||||
type.append("long "); //$NON-NLS-1$
|
||||
type.append( (String)nameMap.get( this.kind ));
|
||||
if( isComplex() )
|
||||
type.append( "_Complex" ); //$NON-NLS-1$
|
||||
else if( isImaginary() )
|
||||
type.append( "_Imaginary" ); //$NON-NLS-1$
|
||||
}
|
||||
else if( this.kind == Type.CLASS_OR_TYPENAME || this.kind == Type.TEMPLATE )
|
||||
{
|
||||
if (isTypename() )
|
||||
type.append("typename "); //$NON-NLS-1$
|
||||
type.append(typeName.toString());
|
||||
}
|
||||
else if( this.kind == Type.UNSPECIFIED )
|
||||
{
|
||||
if (isUnsigned())
|
||||
type.append("unsigned "); //$NON-NLS-1$
|
||||
if (isShort())
|
||||
type.append("short "); //$NON-NLS-1$
|
||||
if (isLong())
|
||||
type.append("long "); //$NON-NLS-1$
|
||||
if (isSigned())
|
||||
type.append("signed "); //$NON-NLS-1$
|
||||
}
|
||||
else
|
||||
type.append( typeName.toString() );
|
||||
this.typeName = type.toString().trim();
|
||||
this.typeName = typeName.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue