Constant qualifier on typeof

Benedikt Huber benedikt.huber at gmail.com
Thu Feb 4 08:44:11 EST 2010


On 03.02.2010, at 02:54, Aaron Tomb wrote:

> Hi Benedikt,
>>>
>>> The question is, how do we fix this? TypeDefType contains just a  
>>> TypeDefRef, which is defined as:
>>>
>>> TypeDefRef Ident (Maybe Type) NodeInfo
>>>
>>> and presumably we could recursively call mergeTypeAttributes on  
>>> the enclosed Type, if present. I'm not sure that's really the  
>>> correct behavior, though. I would think that the enclosed Type  
>>> should just be an exact copy of the type in the typedef declaration.
>>>
>>> Perhaps TypeDefType should have a TypeQuals field? (Maybe even an  
>>> Attributes field? I'm not sure that can come up...). That doesn't  
>>> seem like quite the right solution, either, though.
>> Hmm, why ? This seems like a viable solution, altough it  
>> complicates the semrep a little bit.
>
> Perhaps it is a good solution. I had assumed that there was a good  
> reason no to include those fields. If you think it makes sense to  
> add them, I'm happy with that solution, as well.
If I remember correctly, i wanted to keep SemRep as simple as  
possible, and thought that type-qualifiers for typedefs are not  
strictly neccessary.
I guess I simply forgot to consider attributes for direct types,  
that's clearly a mistake
[..]
>> What I can see is that
>> a) type qualifiers are dropped for typedefs (tDirectType)
>> b) type qualifiers are not allowed for typedefs (mergeTypeAttributes)
[..]
>>  c) attributes are dropped for direct types altogether
>>
>>> Does anyone else have a clear understanding of how this gets  
>>> processed? Would it be straightforward to refactor the code so  
>>> that both the typeof version and direct version of the code above  
>>> would result in the same internal type structure?
>> I know roughly what to do (modify SemRep/Type, adjust affected  
>> function like derefTypeDef, fix the two function mentioned above).
>> Do you think this is the best solution ? (plus all fixes needed  
>> elsewhere)
>>
>> 335c335
>> <        DirectType TypeName TypeQuals
>> ---
>>>       DirectType TypeName TypeQuals Attributes
>> 341c341
>> <      | FunctionType FunType
>> ---
>>>     | FunctionType FunType Attributes
>> 343c343
>> <      | TypeDefType TypeDefRef
>> ---
>>>     | TypeDefType TypeDefRef TypeQuals
>
> I'm happy with this solution if you are. I'd be happy to make the  
> change myself, or I can leave it to you if you prefer.
Ok, than I'll tackle this one. I'm started using language-c for a  
couple of small tasks again recently, so this fits well.

cheers, benedikt




More information about the Language-c mailing list