This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Custom __attribute__ like functionality


Hi all,

I am interested in being able to "mark-up" C++ code with special meta-information. This is kind of like the existing __attribute__ for GCC but the semantics are quite different (I.e. Not just function/type level but statement level meta-data). I wish to ask if anyone knows of anything existing that may be able to achieve what i desire and if nothing exists what others think the difficulty would be of modifying existing __attribute__ semantics or creating something new. Note: This is for a non-mainstream patch and I will not be requesting it be added to mainstream GCC unless people could see a reason to do so.

Basically I would like to mark-up arbitrary segments of C++ code "like":

#define EDOC_NOTHROW(Code) __attribute__ ((nothrow)) { Code }
#define EDOC_THROW(Code, Types) __attribute__ ((throw(Types))) { Code }

for (Type i = begin(); EDOC_NOTHROW( i < end() ); i++)
{
}

or:

EDOC_NOTHROW(vec.push_back(blah));

I would probably want meta information for things, like: nothrow, throws (With additional type arguments), and a doc one that can be used for assigning documentation meta-information to a "throw x;" statement.

The idea is that a patched GCC (I already have a patched GCC for gathering other exception based data: http://edoc.sourceforge.net/ )  would then be able to query tree nodes for some sort of "attached" meta-data that includes this information. I could then use this with the EDoc++ program in order to allow users to provide indications of code segments that require different types of exception guarantees, which is then enforced at a later time. 

Any thoughts or ideas are welcome.
Thanks,
Brendon.








Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]