| 1 |
|
| 2 |
#define func_name(outer,inner,cst) outer##inner##_##cst |
| 3 |
#define func_name_v(outer,inner,cst) outer##inner##_##cst##_v |
| 4 |
|
| 5 |
#define func_decl(outer,inner,cst) \ |
| 6 |
int outer##inner##_##cst (int) __attribute__((noipa)); \ |
| 7 |
int outer##inner##_##cst (int a) { \ |
| 8 |
return (a op_##inner cst) op_##outer a; \ |
| 9 |
} \ |
| 10 |
int outer##inner##_##cst##_v (int) __attribute__((noipa)); \ |
| 11 |
int outer##inner##_##cst##_v (volatile int a) { \ |
| 12 |
return (a op_##inner cst) op_##outer a; \ |
| 13 |
} |
| 14 |
|
| 15 |
#define functions_n(outer, inner) \ |
| 16 |
func_decl(outer,inner,0) \ |
| 17 |
func_decl(outer,inner,1) \ |
| 18 |
func_decl(outer,inner,2) |
| 19 |
|
| 20 |
#define functions() \ |
| 21 |
functions_n(eq,eq) \ |
| 22 |
functions_n(eq,ne) \ |
| 23 |
functions_n(ne,eq) \ |
| 24 |
functions_n(ne,ne) |
| 25 |
|
| 26 |
#define op_ne != |
| 27 |
#define op_eq == |
| 28 |
|
| 29 |
#define test(inner,outer,cst,arg) \ |
| 30 |
func_name_v (inner,outer,cst)(arg) != func_name(inner,outer,cst)(arg) |
| 31 |
|
| 32 |
functions() |
| 33 |
|
| 34 |
#define tests_n(inner,outer,arg) \ |
| 35 |
if (test(inner,outer,0,arg)) __builtin_abort(); \ |
| 36 |
if (test(inner,outer,1,arg)) __builtin_abort(); \ |
| 37 |
if (test(inner,outer,2,arg)) __builtin_abort(); |
| 38 |
|
| 39 |
#define tests(arg) \ |
| 40 |
tests_n(eq,eq,arg) \ |
| 41 |
tests_n(eq,ne,arg) \ |
| 42 |
tests_n(ne,eq,arg) \ |
| 43 |
tests_n(ne,ne,arg) |
| 44 |
|
| 45 |
|
| 46 |
int main() |
| 47 |
{ |
| 48 |
for(int n = -1; n <= 2; n++) { |
| 49 |
tests(n) |
| 50 |
} |
| 51 |
} |