Bug 270275 - The IBasicType for an int should default to being signed.
Summary: The IBasicType for an int should default to being signed.
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 6.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 6.0   Edit
Assignee: Markus Schorn CLA
QA Contact: Mike Kucera CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2009-03-27 10:58 EDT by Richard Miskin CLA
Modified: 2009-04-15 04:17 EDT (History)
0 users

See Also:


Attachments
Patch to CBasicType and tests. (4.78 KB, patch)
2009-03-27 11:01 EDT, Richard Miskin CLA
no flags Details | Diff
New patch (3.66 KB, patch)
2009-04-01 14:01 EDT, Richard Miskin CLA
mschorn.eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Miskin CLA 2009-03-27 10:58:07 EDT
Build ID: I20090313-0100

Looking at section 6.2.5 of the rationale for the C99 standard a 'signed int' is a designation for 'int'. Looking at 6.7.2 of the standard it shows int, signed and signed int as being equivalent.

I think that this means that the IType for the variable in the following declarations should be the same:
int a;
signed int b;
signed c;

I've modified CBasicType to model this and updated AST2Tests.testBasicTypes to test this.

More information:
Currently testBasicType only checks the IType - should it also be checking the IASTSimpleDeclSpecifier?
Comment 1 Richard Miskin CLA 2009-03-27 11:01:56 EDT
Created attachment 130107 [details]
Patch to CBasicType and tests.
Comment 2 Markus Schorn CLA 2009-03-30 09:29:07 EDT
Hmm, with the patch we loose the information whether a type has explicitly been specified as signed. This would affect the display of proposals in content assist.
However the method isSameType() should be fixed. See CPPBasicType. 
Comment 3 Richard Miskin CLA 2009-03-30 10:10:12 EDT
(In reply to comment #2)
> Hmm, with the patch we loose the information whether a type has explicitly been
> specified as signed. This would affect the display of proposals in content
> assist.
> However the method isSameType() should be fixed. See CPPBasicType. 
> 


I agree information has been lost from the IType, but it should still be there on the IASTSimpleDeclSpecifier.

Should IType objects include syntax related information? I'd thought that IType objects were for semantic information. And given an "int" and a "signed int" are the same thing does it matter if the content assist doesn't distinguish between the two?

If the signed information should definitely be retained I'll create a new patch with suitable tests.
Comment 4 Markus Schorn CLA 2009-03-31 13:38:32 EDT
(In reply to comment #3)
> I agree information has been lost from the IType, but it should still be there
> on the IASTSimpleDeclSpecifier.
Types are also stored in the index, when working with those you would not have access to the ast.

> Should IType objects include syntax related information? I'd thought that IType
> objects were for semantic information. And given an "int" and a "signed int"
> are the same thing does it matter if the content assist doesn't distinguish
> between the two?
I don't have a particular reason why the information should be part of IBasicType other than that it has been this way for years. I am just guessing that the information will influence the display of types (ugly 'unsigned int' instead of 'int' in potentially many places, for example potentially in the proposals of content assist).
Comment 5 Richard Miskin CLA 2009-04-01 14:01:03 EDT
Created attachment 130594 [details]
New patch

Leaving things the way they've always been seems like a good enough reason to me  and I'd not really thought about the potential changes in the UI.

In the new patch I've modified CBasicType.isSameType() so it treats signed int and int as equivalent and added a test.
Comment 6 Markus Schorn CLA 2009-04-15 04:16:43 EDT
Thanks, I have committed your patch.
Fixed in 6.0 > 20090415.