[cfe-dev] Better type-specifier representation
steve naroff
snaroff at apple.com
Fri Sep 12 16:31:09 PDT 2008
On Sep 12, 2008, at 6:13 PM, Argiris Kirtzidis wrote:
> steve naroff wrote:
>> All good points...
>>
>> Sometimes it's useful to consult the spec to help weigh various
>> design points.
>>
>> That said, C99 6.7.2.3p3 says...
>>
>> All declarations of structure, union, or enumerated types that have
>> the same scope and use the same tag declare the same type. The type
>> is incomplete109) until the closing brace of the list deļ¬ning the
>> content, and complete thereafter.
>> Since both x and y have the same type, I don't see any compelling
>> reason to alter the type system.
>>
>> struct S{} x;
>> struct S y;
>
> C99 6.7.7p7 says:
> All three of the following declarations of the signal function
> specify exactly the same type
>
> typedef void fv(int), (*pfv)(int);
> void (*signal(int, void (*)(int)))(int);
> fv *signal(int, fv *);
> pfv signal(int, pfv);
>
> And we don't actually use "exactly the same type", we use
> TypedefType to capture more syntactic information.
Typedef's are an explicit language feature for introducing user-
defined synonyms.
The only reason for representing TypedefType explicitly in the type
system is to output user-defined names in diagnostics. In fact, I wish
we didn't have to deal with them explicitly in the type system. When I
started writing Sema, I can't tell you how many bugs resulted in
accidentally operating on the non-canonical type. Nevertheless, the
pain was worth the gain (for typedefs). I'm not convinced adding more
pain for the case above is worth it. Nevertheless, I see the point you
are making a bit more clearly...
>
>
>>
>> From my perspective, we need to have a compelling reason to fold
>> this into the type system.
>>
>> If not, I think the DeclGroup solution will work fine (and appears
>> simpler).
>
> See here:
> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-September/002807.html
> about why I think folding it in the type is simpler.
>
This helps me understand the problems you are considering, however I
still don't think folding it into the type system is the right thing.
Adorning a Decl with more type-specifier info is fine though.
snaroff
> -Argiris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080912/807ce5d2/attachment.html>
More information about the cfe-dev
mailing list