Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/enum-2.c

raw
1 /* Copyright (C) 2000 Free Software Foundation */
2 /* by Alexandre Oliva <[email protected]> */
3
4 void abort (void);
5 void exit (int);
6
7 enum foo { FOO, BAR };
8
9 /* Even though the underlying type of an enum is unspecified, the type
10 of enumeration constants is explicitly defined as int (6.4.4.3/2 in
11 the C99 Standard). Therefore, `i' must not be promoted to
12 `unsigned' in the comparison below; we must exit the loop when it
13 becomes negative. */
14
15 int
16 main ()
17 {
18 int i;
19 for (i = BAR; i >= FOO; --i)
20 if (i == -1)
21 abort ();
22
23 exit (0);
24 }
25