[gcc libcc1] build_qualified_type for self-referencing/incomplete types

Jeff Law law@redhat.com
Fri Apr 24 05:31:00 GMT 2015


On 04/18/2015 04:19 AM, Jan Kratochvil wrote:
> On Fri, 17 Apr 2015 17:22:13 +0200, Jan Kratochvil wrote:
>> How to get 'volatile struct sv' GCC 'tree' type for:
>> 	volatile struct sv { volatile struct sv *p; };
>
> I have found out how it can work, even with no change on the GCC side:
>
> Instead of current:
> 	plugin_build_record_type:
> 		record_type = make_node (RECORD_TYPE)
> 	plugin_build_add_field:
> 		add fields to record_type... But there is no qualified_record_type here!
> 	plugin_finish_record_or_union:
> 		TYPE_SIZE (record_type) etc. ... to finish the type
> 	plugin_build_qualified_type:
> 		qualified_record_type = build_qualified_type (record_type, ...)
> one can do instead:
> 	plugin_build_record_type:
> 		record_type = make_node (RECORD_TYPE)
> 	plugin_build_qualified_type:
> 		qualified_record_type = build_qualified_type (record_type, ...)
> 	plugin_build_add_field:
> 		add fields to qualified_record_type
> 	plugin_finish_record_or_union:
> 		TYPE_SIZE (qualified_record_type) etc. ... to finish the type
> And one forgets about the unfinished record_type.
>
> For a different cv-quals of the same record type one builds a new cv-qualified
> record from scratch.
I'm a bit surprised the former didn't work, but if the latter is working 
consistently, then I'd stick with it.

jeff



More information about the Gcc mailing list