File: n_24.c

package info (click to toggle)
mcpp 2.7.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,024 kB
  • ctags: 29,151
  • sloc: ansic: 35,191; sh: 9,231; makefile: 176; cpp: 84; exp: 18
file content (30 lines) | stat: -rw-r--r-- 987 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* n_24.c:  # operator in macro definition / 1. */

#define str( a)     # a

/* 24.1:    */
/*  "a+b";  */
    str( a+b);

/* 24.2:    White spaces between tokens of operand are converted to one space.
 */
/*  "ab + cd";  */
    str(    ab  /* comment */   +
        cd  );

/* 24.5:    Token separator inserted by macro expansion should be removed.
        (Meanwhile, tokens should not be merged.  See 21.2.)    */
#define xstr( a)    str( a)
#define f(a)        a
/*  "x-y";  */
    xstr( x-f(y));

/* { dg-do preprocess }
   { dg-final { if ![file exist n_24.i] { return }                      } }
   { dg-final { if \{ [grep n_24.i "\"a\\+b\""] != ""           \} \{   } }
   { dg-final { if \{ [grep n_24.i "\"ab \\+ cd\""] != ""       \} \{   } }
   { dg-final { if \{ [grep n_24.i "\"x-y\""] != ""             \} \{   } }
   { dg-final { return \} \} \}                                         } }
   { dg-final { fail "n_24.c: #operator"                                } }
 */