File: n_11.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 (37 lines) | stat: -rw-r--r-- 1,004 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
31
32
33
34
35
36
37
/* n_11.c:  Operator "defined" in #if or #elif directive.   */

#define MACRO_abc   abc
#define MACRO_xyz   xyz
#define MACRO_0     0
#define ZERO_TOKEN

/* 11.1:    */
/*  abc;    */
/*  xyz;    */
#if     defined a
    a;
#else
    MACRO_abc;
#endif
#if     defined (MACRO_xyz)
    MACRO_xyz;
#else
    0;
#endif

/* 11.2:    "defined" is an unary operator whose result is 1 or 0.  */
#if     defined MACRO_0 * 3 != 3
#error  Bad handling of "defined" operator.
#endif
#if     (!defined ZERO_TOKEN != 0) || (-defined ZERO_TOKEN != -1)
#error  Bad grouping of "defined", !, - operator.
#endif

/* { dg-do preprocess }
   { dg-final { if ![file exist n_11.i] { return }                      } }
   { dg-final { if \{ [grep n_11.i "abc"] != ""                 \} \{   } }
   { dg-final { if \{ [grep n_11.i "xyz"] != ""                 \} \{   } }
   { dg-final { return \} \}                                            } }
   { dg-final { fail "n_11.c: 'defined' operator"                       } }
 */