This is the mail archive of the gcc-patches@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]

Re: -ftree-check for review


On Wednesday 09 May 2007 22:29, Andrew Pinski wrote:
> On 5/9/07, Nic Volanschi <nic.volanschi@free.fr> wrote:
> > gcc --tree-check="%_ = fopen(%_, "rw")" *.c
>
> Except this won't match:
> fopen(XXXX, &"rw"[0])
> Or:
> fopen(XXXX, &"11\0rw"[3])
>
> While the first is more likely (I think the C++ front-end produces
> that), the second can happen if people are smart (or doing something
> crazy).
>
> Thanks,
> Andrew Pinski

Hi Andrew,

Nice example! But it perfectly works, in both cases, and even others. Let's 
consider the file:

#include <stdio.h>

#define N 10

void kix_o_main() {
  int a[N], i, j, k, *p;
  FILE *f;

  f = fopen("in", "rw");
  f = fopen("in", &"rw"[0]);
  f = fopen("in", &"11\0rw"[3]);
  f = fopen("in", "11\0rw"+3);

  if(p == NULL)
    a[i] = a[i] * k + j;
  
  return;
}

So, let's try:

[nic@paco C]$ ~/Gcc/graphite/inst/bin/gcc -c --tree-check="%X=fopen(%_,%Y)" 
--tree-checks-verbose --dump-tree-gimple c.c
c.c: In function âkix_o_mainâ:
c.c:9: warning: user-defined warning %X=fopen(%_,%Y): .
c.c:9: instance = {X <- f, Y <- &"rw"[0]},
c.c:9: reached: f = f.0.
c.c:10: warning: user-defined warning %X=fopen(%_,%Y): .
c.c:10: instance = {X <- f, Y <- &"rw"[0]},
c.c:10: reached: f = f.1.
c.c:11: warning: user-defined warning %X=fopen(%_,%Y): .
c.c:11: instance = {X <- f, Y <- D.2121},
c.c:11: reached: f = f.2.
c.c:12: warning: user-defined warning %X=fopen(%_,%Y): .
c.c:12: instance = {X <- f, Y <- D.2123},
c.c:12: reached: f = f.3.

Everything is there!
Nic.


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