Re: Plugin that parse tree

2011-01-27 Thread Daniel Marjamäki
I see. Good. 2011/1/27 Tom Tromey : >> "Ian" == Ian Lance Taylor writes: > > Ian> The problem with warnings for this kind of code in C/C++ is that it > Ian> often arises in macro expansions.  I think it would be necessary to > Ian> first develop a scheme which lets us determine whether code r

Re: Plugin that parse tree

2011-01-27 Thread Tom Tromey
> "Ian" == Ian Lance Taylor writes: Ian> The problem with warnings for this kind of code in C/C++ is that it Ian> often arises in macro expansions. I think it would be necessary to Ian> first develop a scheme which lets us determine whether code resulted Ian> from a macro expansion or not, w

Re: Plugin that parse tree

2011-01-25 Thread Ian Lance Taylor
Kevin André writes: > Is that ever going to be fixed? If a front end mangles its AST > representation, then it cannot be used for static analysis. > > Even if the constant folding in the front end is necessary for > checking semantics, you could still keep the original source in the > AST and sim

Re: Plugin that parse tree

2011-01-25 Thread Kevin André
On Mon, Jan 24, 2011 at 16:49, Ian Lance Taylor wrote: > Daniel Marjamäki writes: > >> Do you have any opinion about adding a warning for: >> >> int f(char c) >> { >>     return 10 * (c == 13) ? 1 : 2; >> } >> As far as I see the multiplication doesn't exist in the gimple format >> (looking at a

Re: Plugin that parse tree

2011-01-25 Thread Daniel Marjamäki
2011/1/24 Ian Lance Taylor : > Daniel Marjamäki writes: > >> 2011/1/24 Ian Lance Taylor : >> >>> The problem with warnings for this kind of code in C/C++ is that it >>> often arises in macro expansions. >> >> I see... so it won't be included in gcc. :-( > > Actually, I think it could be included i

Re: Plugin that parse tree

2011-01-24 Thread Ian Lance Taylor
Daniel Marjamäki writes: > 2011/1/24 Ian Lance Taylor : > >> The problem with warnings for this kind of code in C/C++ is that it >> often arises in macro expansions. > > I see... so it won't be included in gcc. :-( Actually, I think it could be included in gcc, provided you (or somebody) first i

Re: Plugin that parse tree

2011-01-24 Thread Daniel Marjamäki
2011/1/24 Ian Lance Taylor : > The problem with warnings for this kind of code in C/C++ is that it > often arises in macro expansions. I see... so it won't be included in gcc. :-( It was my goal to get it into GCC. But I still think it's an interesting idea that I'll look into. Regards, Daniel

Re: Plugin that parse tree

2011-01-24 Thread Ian Lance Taylor
Daniel Marjamäki writes: > Do you have any opinion about adding a warning for: > > int f(char c) > { > return 10 * (c == 13) ? 1 : 2; > } > > The multiplication has no effect. The function returns either 1 or 2. > > It would be interesting to know how a MELT script could look like for > such

Re: Plugin that parse tree

2011-01-24 Thread Daniel Marjamäki
Do you have any opinion about adding a warning for: int f(char c) { return 10 * (c == 13) ? 1 : 2; } The multiplication has no effect. The function returns either 1 or 2. It would be interesting to know how a MELT script could look like for such a case. As far as I see the multiplication do

Re: Plugin that parse tree

2011-01-24 Thread piervit
Hello! I am discovering gcc and his plugin system. I have tried MELT. I would like to say that the lispy syntax is not so difficult. It mights look unattractive to have such number of parenthesis but we quikly get used to the structure. The harder for me is to have a good view of the GCC interna

Re: Plugin that parse tree

2011-01-23 Thread Daniel Marjamäki
Hello! > Either change your test file to .cpp, or add "-x c++" to the command-line. that worked. thank you. I don't want to limit my plugin to C++. But to start with it is ok. > The major issue is to understand all the details of GCC internal > representations (i.e. Trees, Gimples). Did you u

Re: Plugin that parse tree

2011-01-23 Thread Dave Korn
On 23/01/2011 10:58, Daniel Marjamäki wrote: > I fail to use 'global_namespace': > daniel@daniel:~/gcc/build/gcc$ ./xgcc -fplugin=./myplugin2.so -c test1.c > cc1: error: cannot load plugin ./myplugin2.so You're running the C compiler (cc1) here, not the C++ one (cc1plus), because you've passed

Re: Plugin that parse tree

2011-01-23 Thread Basile Starynkevitch
On Sun, 23 Jan 2011 15:49:48 +0100 Daniel Marjamäki wrote: > GCC-MELT is an interesting project. But it seems to be very difficult > to write lisp scripts. You don't have a C interface also, do you? The few people who tried writing MELT code are founding on the contrary that coding in MELT is ea

Re: Plugin that parse tree

2011-01-23 Thread Daniel Marjamäki
GCC-MELT is an interesting project. But it seems to be very difficult to write lisp scripts. You don't have a C interface also, do you? I would like to see how I can use plain C. Regards, Daniel 2011/1/23 Basile Starynkevitch : > On Sun, 23 Jan 2011 11:58:21 +0100 > Daniel Marjamäki wrote: > >

Re: Plugin that parse tree

2011-01-23 Thread Basile Starynkevitch
On Sun, 23 Jan 2011 11:58:21 +0100 Daniel Marjamäki wrote: > Hello! > > I want to write a plugin that parse the AST. Could I get some hint > about how to do it? You could use GCC MELT for that purpose. See www.gcc-melt.org Regards -- Basile STARYNKEVITCH http://starynkevitch.net/Basi