Blame cpp-test/test-t/unspcs.c

Packit b40e2e
/*
Packit b40e2e
 *  unspcs.c:
Packit b40e2e
 *  1998/08             kmatsui
Packit b40e2e
 *
Packit b40e2e
 *   These texts are unportable ones, because the order of the evaluation is
Packit b40e2e
 * unspecified.  Good preprocessor will warn at these texts even if the
Packit b40e2e
 * results are valid.  Good preprocessor will also document the order of
Packit b40e2e
 * evaluation and the behavior on invalid results.
Packit b40e2e
 *   Note: Order of evaluation of sub-expressions (other than operands of &&,
Packit b40e2e
 * ||, ? :) of #if expression is also unspecified.  The order, however, never
Packit b40e2e
 * affects the result, because #if expression never cause side effect, so no
Packit b40e2e
 * warning is necessary.  Precedence and grouping rules of operators are other
Packit b40e2e
 * things than order of evaluation, and shall be obeyed by preprocessor.
Packit b40e2e
 *
Packit b40e2e
 *  2003/03 Rewritten for testsuite.        kmatsui
Packit b40e2e
 */
Packit b40e2e
Packit b40e2e
/* { dg-do preprocess } */
Packit b40e2e
/* { dg-options "-ansi -pedantic -Wall" }   */
Packit b40e2e
Packit b40e2e
#define str( a)     # a
Packit b40e2e
#define xstr( a)    str( a)
Packit b40e2e
Packit b40e2e
/* s.1.1:   Order of evaluation of #, ## operators. */
Packit b40e2e
#define MAKWIDESTR( s)  L ## # s    /* { dg-warning "Macro with mixing of ## and # operators isn't portable" } */
Packit b40e2e
/*  Either of L"name"; or L# name; ("L#" is not a valid pp-token).  */
Packit b40e2e
    MAKWIDESTR( name);
Packit b40e2e
Packit b40e2e
/* s.1.2:   Order of evaluation of ## operators.    */
Packit b40e2e
#define glue3( a, b, c)     a ## b ## c     /* { dg-warning "Macro with multiple ## operators isn't portable" } */
Packit b40e2e
/*  "1.a" or undefined, since .a is not a valid pp-token, while 1. and 1.a are
Packit b40e2e
        valid pp-tokens.    */
Packit b40e2e
    xstr( glue3( 1, ., a));
Packit b40e2e