OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [compare4.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* Test for a bogus warning on comparison between signed and unsigned.
2
   Origin: Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 5/13/2001.  */
3
 
4
/* { dg-do compile } */
5
/* { dg-options "-fshow-column -Wsign-compare -fstrict-overflow" } */
6
 
7
extern void bar(void);
8
 
9
int foo(int x, int y, unsigned u)
10
{
11
  /* A COMPOUND_EXPR is non-negative if the last element is known to
12
     be non-negative.  */
13
  if (u < (bar(), -1)) /*{ dg-warning "9:signed and unsigned" "COMPOUND_EXPR" }*/
14
    return x;
15
  if (u < (bar(), 10))
16
    return x;
17
  if ((bar(), 10) < u)
18
    return x;
19
  if (u < (x ? (bar(),bar(),bar(),bar(),x==y) : 10))
20
    return x;
21
  if ((x ? 10 : (bar(),bar(),bar(),bar(),x==y)) < u)
22
    return x;
23
 
24
  /* Test an ABS_EXPR, which is by definition non-negative when
25
     -fstrict-overflow is used.  */
26
  if (u < __builtin_abs(x))
27
    return x;
28
  if (__builtin_abs(x) < u)
29
    return x;
30
  if (u < (x ? __builtin_abs(x) : 10))
31
    return x;
32
  if ((x ? 10: __builtin_abs(x)) < u)
33
    return x;
34
 
35
  /* A MODIFY_EXPR is non-negative if the new value is known to be
36
     non-negative.  */
37
  if (u < (x = -1)) /* { dg-warning "9:signed and unsigned" "MODIFY_EXPR" } */
38
    return x;
39
  if (u < (x = 10))
40
    return x;
41
  if ((x = 10) < u)
42
    return x;
43
  if (u < (x = (y ? (x==y) : 10)))
44
    return x;
45
  if ((x = (y ? 10 : (x==y))) < u)
46
    return x;
47
 
48
  return 0;
49
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.