OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [opt/] [range-test-2.C] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Test fold-const.c (fold_range_test) optimizations.
2
// { dg-do run } */
3
// { dg-options "-O2" } */
4
 
5
#include 
6
#include 
7
#include 
8
 
9
#if (INT_MAX == 2147483647) && (INT_MIN == -2147483648) \
10
    && (SCHAR_MIN == -128) && (SCHAR_MAX == 127) \
11
    && (UCHAR_MIN == 0) && (UCHAR_MAX == 255)
12
 
13
#ifndef T
14
 
15
enum enum3
16
{
17
  enum3_zero,
18
  enum3_one,
19
  enum3_two,
20
  enum3_three,
21
  enum3_four,
22
  enum3_five,
23
  enum3_six,
24
  enum3_seven
25
};
26
 
27
int var;
28
void
29
check ()
30
{
31
  ++var;
32
}
33
 
34
#define T(IDX, TYPE, TEST, YESARR, NOARR)                               \
35
void __attribute__((noinline))                                          \
36
test##IDX (TYPE x)                                                      \
37
{                                                                       \
38
  if (TEST)                                                             \
39
    check ();                                                           \
40
}
41
#include "range-test-2.C"
42
#undef T
43
 
44
int
45
main ()
46
{
47
  int i, fails = 0;
48
 
49
#define C ,
50
#define T(IDX, TYPE, TEST, YESARR, NOARR)                               \
51
  {                                                                     \
52
    static TYPE yesarr##IDX [] = YESARR;                                \
53
    static TYPE noarr##IDX [] = NOARR;                                  \
54
    for (i = 0; i < (int) (sizeof (yesarr##IDX) / sizeof (TYPE)); ++i)  \
55
      {                                                                 \
56
        var = 0;                                                        \
57
        test##IDX (yesarr##IDX [i]);                                    \
58
        if (var != 1)                                                   \
59
          printf ("test" #IDX " failed for yesarr [%u]\n", i), ++fails; \
60
      }                                                                 \
61
    var = 0;                                                            \
62
    for (i = 0; i < (int) (sizeof (noarr##IDX) / sizeof (TYPE)); ++i)   \
63
      {                                                                 \
64
        test##IDX (noarr##IDX [i]);                                     \
65
        if (var != 0)                                                   \
66
          printf ("test" #IDX " failed for noarr [%u]\n", i), ++fails;  \
67
      }                                                                 \
68
  }
69
#include "range-test-2.C"
70
#undef T
71
 
72
  if (fails)
73
    abort ();
74
 
75
  exit (0);
76
}
77
 
78
#else
79
 
80
/* Use `C' instead of `,' below to separate array entries.  */
81
 
82
T(26, enum3, x == enum3_one || x == enum3_two || x == enum3_three,
83
  { enum3_one C enum3_two C enum3_three }, { enum3_zero C enum3_four
84
    C enum3_five C enum3_six C enum3_seven })
85
 
86
#endif
87
 
88
#else
89
 
90
int
91
main (void)
92
{
93
  return 0;
94
}
95
 
96
#endif

powered by: WebSVN 2.1.0

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