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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-final { scan-assembler-not "cmp" } } */
extern void abort (void);
int c;
#define PLUSCC1(T, t, C) \
T pluscc##t##C (T a, T b) \
{ \
T sum = a + b; \
if (sum < C) \
abort (); \
return sum; \
}
#define PLUSCC(T, t) PLUSCC1(T, t, a) PLUSCC1(T, t, b)
#define INCCC1(T, t, C) \
T inccc##t##C (T a, T b) \
{ \
T sum = a + b; \
if (sum < C) \
c ++; \
return sum; \
}
#define INCCC(T, t) INCCC1(T, t, a) INCCC1(T, t, b)
#define PLUSCCONLY1(T, t, C) \
void pluscconly##t##C (T a, T b) \
{ \
T sum = a + b; \
if (sum < C) \
abort (); \
}
#define PLUSCCONLY(T, t) PLUSCCONLY1(T, t, a) PLUSCCONLY1(T, t, b)
#define TEST(T, t) \
PLUSCC(T, t) \
PLUSCCONLY(T, t) \
INCCC(T, t)
TEST (unsigned long, l)
TEST (unsigned int, i)
TEST (unsigned short, s)
TEST (unsigned char, c)
#define PLUSCCZEXT(C) \
unsigned long pluscczext##C (unsigned int a, unsigned int b) \
{ \
unsigned int sum = a + b; \
if (sum < C) \
abort (); \
return sum; \
}
PLUSCCZEXT(a)
PLUSCCZEXT(b)
|