summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/20040121-1.c
blob: 6225bcdc8a34b7a11b9495f0046237cf85a111fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28


/* Test that (p!=0) + (q!=0) is computed as int,
    not boolean */
/* { dg-options "-O3" } */
/* { dg-do run } */
extern void abort (void);
char *foo(char *p, char *q) {
    int x = (p !=0) + (q != 0);
    if (x==2)  return "a"; else return 0;
}
extern char *bar(char*, char*) __attribute__((noinline));
char *bar(char *first, char *last)
{
   int y;
   if (!first)  return last;
   if (!last)   return first;
   if (*first == 'a')
     return foo(first, last);
   return 0;
}
main() {
   char *p = "a", *q = "b";
   if (p)
     if (bar(p,q))
       return 0;
   abort();
}