1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-30 20:29:25 +00:00

Improved test case for PR #1220.

This commit is contained in:
acqn 2020-08-31 20:41:36 +08:00 committed by Oliver Schmidt
parent fb6bc275bc
commit 2a3d996077

View File

@ -10,14 +10,14 @@
/* test AND/OR in ternary context */ /* test AND/OR in ternary context */
#define CONTEXT_B(x) do {\ #define CONTEXT_B(x) do {\
s = 0, flags = 0,\ s = 0, flags = 0, t = (x ? 42 : -42),\
(x ? printf("%3d %2X: 1\n", s, flags) : printf("%3d %2X: 0\n", s, flags));\ printf("%3d %2X: %d\n", s, flags, t);\
} while (0) } while (0)
int s, t; int s, t;
unsigned flags; unsigned flags;
int f(x) int f(int x)
/* The call to this function should be and only be skipped strictly according to /* The call to this function should be and only be skipped strictly according to
** the short-circuit evaluation rule. ** the short-circuit evaluation rule.
*/ */
@ -31,8 +31,8 @@ int f(x)
#define _B f(b) #define _B f(b)
#define _C f(c) #define _C f(c)
#define _D f(d) #define _D f(d)
#define _T (f(0), -1) #define _T (f(0), 256)
#define _F (f(-1), 0) #define _F (f(256), 0)
void f0() void f0()
/* constant short-circuit */ /* constant short-circuit */
@ -176,7 +176,7 @@ void f5(int a, int b, int c, int d)
void f0_B() void f0_B()
/* constant short-circuit */ /* constant short-circuit */
{ {
printf("f0()\n"); printf("f0_B()\n");
CONTEXT_B(_T && _T && _T); CONTEXT_B(_T && _T && _T);
CONTEXT_B(_F && _F && _F); CONTEXT_B(_F && _F && _F);
@ -205,7 +205,7 @@ void f0_B()
void f1_B(int a, int b, int c) void f1_B(int a, int b, int c)
/* AND */ /* AND */
{ {
printf("f1(%d, %d, %d)\n", a, b, c); printf("f1_B(%d, %d, %d)\n", a, b, c);
CONTEXT_B(_A && _B && _C); CONTEXT_B(_A && _B && _C);
@ -227,7 +227,7 @@ void f1_B(int a, int b, int c)
void f2_B(int a, int b, int c) void f2_B(int a, int b, int c)
/* OR */ /* OR */
{ {
printf("f2(%d, %d, %d)\n", a, b, c); printf("f2_B(%d, %d, %d)\n", a, b, c);
CONTEXT_B(_A || _B || _C); CONTEXT_B(_A || _B || _C);
@ -249,7 +249,7 @@ void f2_B(int a, int b, int c)
void f3_B(int a, int b, int c, int d) void f3_B(int a, int b, int c, int d)
/* AND and OR */ /* AND and OR */
{ {
printf("f3(%d, %d, %d, %d)\n", a, b, c, d); printf("f3_B(%d, %d, %d, %d)\n", a, b, c, d);
CONTEXT_B(_A && _B || _C && _D); CONTEXT_B(_A && _B || _C && _D);
CONTEXT_B(_T && _T || _C && _D); CONTEXT_B(_T && _T || _C && _D);
@ -271,7 +271,7 @@ void f3_B(int a, int b, int c, int d)
void f4_B(int a, int b, int c, int d) void f4_B(int a, int b, int c, int d)
/* AND as top-level expression inside OR context */ /* AND as top-level expression inside OR context */
{ {
printf("f4(%d, %d, %d, %d)\n", a, b, c, d); printf("f4_B(%d, %d, %d, %d)\n", a, b, c, d);
CONTEXT_B((_A && _B) || (_C && _D)); CONTEXT_B((_A && _B) || (_C && _D));
CONTEXT_B((_T && _T) || (_C && _D)); CONTEXT_B((_T && _T) || (_C && _D));
@ -293,7 +293,7 @@ void f4_B(int a, int b, int c, int d)
void f5_B(int a, int b, int c, int d) void f5_B(int a, int b, int c, int d)
/* OR as top-level expression inside AND context */ /* OR as top-level expression inside AND context */
{ {
printf("f5(%d, %d, %d, %d)\n", a, b, c, d); printf("f5_B(%d, %d, %d, %d)\n", a, b, c, d);
CONTEXT_B((_A || _B) && (_C || _D)); CONTEXT_B((_A || _B) && (_C || _D));
CONTEXT_B((_F || _F) && (_C || _D)); CONTEXT_B((_F || _F) && (_C || _D));