Hello Romain,

Sorry for my late reply to this thread.

Romain Geissler <romain.geiss...@st.com> a écrit:

>> Just to be sure I understand, do you need to be notified about *uses* of
>> types and decls as well?  If so, maybe a new kind of event should
>> probably be defined, because PLUGIN_FINISH_DECL and PLUGIN_FINISH_TYPE
>> seem to have more to do with declaring/defining decls and types than
>> using them.
>>
>
> Personally i don't need to catch all struct uses, but i need to catch struct 
> declarations.
> I want to apply some __attributes__ to a given struct type, for
> example let's say i need to mark *struct my_struct* as deprecated
> thanks to a plugin. I know how to apply some attributes to a type or a
> decl. See the plugin (test_plugin.c) and the test files attached.
>
> With test_pass.c, my_struct is declared first, then defined after,
> applying the deprecated attribute works.
> With test_fail.c, my_struct is declared and defined at the same time,
> applying the deprecated attribute doesn't work with the current trunk
> (and also with my patch).
> I got:
> test_fail.c:4:1: warning: type attributes ignored after type is already 
> defined [-Wattributes]

Right, you cannot use (cplus_)decl_attributes on type that is fully
created.  The function warns in that case.

> So i may need a PLUGIN_FINISH_TYPE_DECLARATION triggered when the type
> is declared but before it is finally defined.

Hmmh.  For this specific case, maybe just setting the TREE_DEPRECATED
flag on the tree node of type could do what you want?

-- 
                Dodji

Reply via email to