2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / trad / defined.c
blob5fa1d93b8aa49257dc633bed6756958ff925cd2b
1 /* Copyright (C) 2000 Free Software Foundation, Inc. */
3 /* { dg-do preprocess } */
5 /* Tests tradcpp0 with defined. The defined operator in traditional C
6 works just the same as the defined operator in Standard C. */
8 /* Source: Zack Weinberg, glibc, Neil Booth 11 Dec 2000. */
10 #if defined REGPARMS
11 #error REGPARMS should not be defined
12 #endif
14 #define REGPARMS 1
15 #if !defined REGPARMS
16 #error REGPARMS should be defined
17 #endif
19 #define defined /* { dg-error "defined" } */
21 /* No diagnostics, though you could argue there should be. */
22 #if defined defined
23 #error defined is defined!
24 #endif
26 #define is_Z_defined defined Z
28 #if defined Z
29 #error Z is not defined
30 #endif
32 /* The behavior of "defined" when it comes from a macro expansion is
33 now documented. */
34 #if is_Z_defined
35 #error Macro expanding into defined operator test 1
36 #endif
38 #define Z
40 #if !defined Z
41 #error Z is defined
42 #endif
44 #if !is_Z_defined
45 #error Macro expanding into defined operator test 2
46 #endif
48 #undef is_Z_defined
49 #undef Z
51 /* Do all the tests over again with the () form of defined. */
53 /* No diagnostics, though you could argue there should be. */
54 #if defined(defined)
55 #error defined is defined!
56 #endif
58 #define is_Z_defined defined ( Z )
60 #if defined(Z)
61 #error Z is not defined
62 #endif
64 /* The behavior of "defined" when it comes from a macro expansion is
65 now documented. */
66 #if is_Z_defined
67 #error Macro expanding into defined operator test 1
68 #endif
70 #define Z
72 #if !defined(Z)
73 #error Z is defined
74 #endif
76 #if !is_Z_defined
77 #error Macro expanding into defined operator test 2
78 #endif