Blame test-c/n_26.c

Packit Service 8bf002
/* n_26.c:  The name once replaced is not furthur replaced. */
Packit Service 8bf002
Packit Service 8bf002
#include    "defs.h"
Packit Service 8bf002
Packit Service 8bf002
int     f( a)
Packit Service 8bf002
    int     a;
Packit Service 8bf002
{
Packit Service 8bf002
    return  a;
Packit Service 8bf002
}
Packit Service 8bf002
Packit Service 8bf002
int     g( a)
Packit Service 8bf002
    int     a;
Packit Service 8bf002
{
Packit Service 8bf002
    return  a * 2;
Packit Service 8bf002
}
Packit Service 8bf002
Packit Service 8bf002
main( void)
Packit Service 8bf002
{
Packit Service 8bf002
    int     x = 1;
Packit Service 8bf002
    int     AB = 1;
Packit Service 8bf002
    int     Z[1];
Packit Service 8bf002
Packit Service 8bf002
    fputs( "started\n", stderr);
Packit Service 8bf002
Packit Service 8bf002
    Z[0] = 1;
Packit Service 8bf002
Packit Service 8bf002
/* 26.1:    Directly recursive object-like macro definition.    */
Packit Service 8bf002
/*  Z[0];   */
Packit Service 8bf002
#define Z   Z[0]
Packit Service 8bf002
    assert( Z == 1);
Packit Service 8bf002
Packit Service 8bf002
/* 26.2:    Intermediately recursive object-like macro definition.  */
Packit Service 8bf002
/*  AB; */
Packit Service 8bf002
#define AB  BA
Packit Service 8bf002
#define BA  AB
Packit Service 8bf002
    assert( AB == 1);
Packit Service 8bf002
Packit Service 8bf002
/* 26.3:    Directly recursive function-like macro definition.  */
Packit Service 8bf002
/*  x + f(x);   */
Packit Service 8bf002
#define f(a)    a + f(a)
Packit Service 8bf002
    assert( f( x) == 2);
Packit Service 8bf002
Packit Service 8bf002
/* 26.4:    Intermediately recursive function-like macro definition.    */
Packit Service 8bf002
/*  x + x + g( x);  */
Packit Service 8bf002
#define g(a)    a + h( a)
Packit Service 8bf002
#define h(a)    a + g( a)
Packit Service 8bf002
    assert( g( x) == 4);
Packit Service 8bf002
Packit Service 8bf002
/* 26.5:    Rescanning encounters the non-replaced macro name.  */
Packit Service 8bf002
/*  Z[0] + f( Z[0]);    */
Packit Service 8bf002
    assert( f( Z) == 2);
Packit Service 8bf002
Packit Service 8bf002
    fputs( "success\n", stderr);
Packit Service 8bf002
    return  0;
Packit Service 8bf002
}
Packit Service 8bf002