diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java index 2cdc9c49bfb..633d4e6b032 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java @@ -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 diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java index c65d0e4a44e..52be35e709b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java @@ -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 ); + } + } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTSimpleTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTSimpleTypeSpecifier.java index 86de2c234ab..562c373c780 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTSimpleTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTSimpleTypeSpecifier.java @@ -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)