"Vincent R." <foru...@smartmobili.com> writes: >> gcc will do the right thing if you put statements in an exception >> region. > > Hum how gcc can do that kind of things, is it some kind of voodoo ? > __except is not implemented yet and is more than a language construct > because it's an > OS thing. > So maybe I need to say it once again, instructions inside __except needs to > be > put inside a function by the compiler .
Can you explain why that is? I don't know how SEH works; how does the OS get involved? > Let's imagine seh were designed differently, I mean for instance let's say > instead > of putting instructions in a function it would put ins directly without any > prologue and epilogue > would you still tell me that eh region will do what I need. gcc supports C++ exceptions on all targets but does not put anything in a function and does not use a separate prologue or epilogue. > Ok so now forget my previous questions, seh and so on. > I am going to express my problem differently, let's say I want to developp > a tool based on GCC > and used to tranform code. > > I mean it would parse source code and if it detects __transform keyword > make some tranformation, > generate IL and then output the tranformed source code. > Original code is : > > int main() > { > __transform( printf("hello"); printf("world"), 10 ); > } > > and I would like to obtain > > int main() > { > } > > int func1() > { > printf("hello"); > printf("world"); > return 10 > } > > So my question is when parsing source code and when detetcing __transform > keyword you agree that > I need to generate a function and put instructions in it. > So in this case should we use start_function ? > Don't tell me to use eh region or I am getting depressed. It seems to me that you would want to treat it as a nested function. So, yes, you should use start_function. See c_parser_declaration_or_fndef when nested is true. If the code inside __transform is not permitted to refer to variables defined in main, then you might need to do some additional work to prevent that from happening. Ian