Blame test-c/u_1_24.c

Packit Service 8bf002
/* u_1_24.c:    Undefined behaviors on empty argument of macro call.    */
Packit Service 8bf002
Packit Service 8bf002
/* u.1.24:  Empty argument of macro call.   */
Packit Service 8bf002
/*
Packit Service 8bf002
 *   Note: Since no argument and one empty argument cannot be distinguished
Packit Service 8bf002
 * syntactically, additional dummy argument may be necessary for an
Packit Service 8bf002
 * intermediate macro to process one empty argument (if possible).
Packit Service 8bf002
 */
Packit Service 8bf002
Packit Service 8bf002
#include    <stdio.h>
Packit Service 8bf002
Packit Service 8bf002
#define ARG( a, dummy)      # a
Packit Service 8bf002
#define EMPTY
Packit Service 8bf002
#define SHOWN( n)       printf( "%s : %d\n", # n, n)
Packit Service 8bf002
#define SHOWS( s)       printf( "%s : %s\n", # s, ARG( s, dummy))
Packit Service 8bf002
#define add( a, b)      (a + b)
Packit Service 8bf002
#define sub( a, b)      (a - b)
Packit Service 8bf002
#define math( op, a, b)     op( a, b)
Packit Service 8bf002
#define APPEND( a, b)       a ## b
Packit Service 8bf002
Packit Service 8bf002
main( void)
Packit Service 8bf002
{
Packit Service 8bf002
    int     x = 1;
Packit Service 8bf002
    int     y = 2;
Packit Service 8bf002
Packit Service 8bf002
/*  printf( "%s : %d\n", "math( sub, , y)", ( - y));
Packit Service 8bf002
        or other undefined behavior.    */
Packit Service 8bf002
    SHOWN( math( sub, , y));
Packit Service 8bf002
Packit Service 8bf002
/*  printf( "%s : %s\n", "EMPTY", "");
Packit Service 8bf002
        or other undefined behavior.    */
Packit Service 8bf002
    SHOWS( EMPTY);
Packit Service 8bf002
Packit Service 8bf002
/*  printf( "%s : %s\n", "APPEND( CON, 1)", "CON1");    */
Packit Service 8bf002
    SHOWS( APPEND( CON, 1));
Packit Service 8bf002
Packit Service 8bf002
/*  printf( "%s : %s\n", "APPEND( CON, )", "CON");
Packit Service 8bf002
        or other undefined behavior.    */
Packit Service 8bf002
    SHOWS( APPEND( CON, ));
Packit Service 8bf002
Packit Service 8bf002
/*  printf( "%s : %s\n", "APPEND( , )", "");
Packit Service 8bf002
        or other undefined behavior.    */
Packit Service 8bf002
    SHOWS( APPEND( , ));
Packit Service 8bf002
Packit Service 8bf002
    return  0;
Packit Service 8bf002
}
Packit Service 8bf002