summaryrefslogtreecommitdiff
path: root/support/regression/tests/gcc-torture-execute-enum-2.c
blob: 12e1a3991ddada6aefe5b2278c541de09cf5c2ab (plain) (blame)
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
29
30
31
32
/*
   enum-2.c from the execute part of the gcc torture tests.
 */

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#endif

/* Copyright (C) 2000 Free Software Foundation */
/* by Alexandre Oliva  <aoliva@redhat.com> */

enum foo { FOO, BAR };

/* Even though the underlying type of an enum is unspecified, the type
   of enumeration constants is explicitly defined as int (6.4.4.3/2 in
   the C99 Standard).  Therefore, `i' must not be promoted to
   `unsigned' in the comparison below; we must exit the loop when it
   becomes negative. */

void
testTortureExecute (void)
{
  int i;
  for (i = BAR; i >= FOO; --i)
    if (i == -1)
      ASSERT (0);

  return;
}