blob: 9a60bdd5d10620a3f903850af5af2cc033acda20 (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/* Copyright (C) 2000 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
/* Tests behavior of the defined operator. */
/* Source: Neil Booth, 29 Oct 2000, Zack Weinberg 11 Dec 2000. */
#define defined /* { dg-error "defined" } */
/* No diagnostics, though you could argue there should be. */
#if defined defined
#error defined is defined!
#endif
#define is_Z_defined defined Z
#if defined Z
#error Z is not defined
#endif
/* The behavior of "defined" when it comes from a macro expansion is
now documented. */
#if is_Z_defined
#error Macro expanding into defined operator test 1
#endif
#define Z
#if !defined Z
#error Z is defined
#endif
#if !is_Z_defined
#error Macro expanding into defined operator test 2
#endif
#undef is_Z_defined
#undef Z
/* Do all the tests over again with the () form of defined. */
/* No diagnostics, though you could argue there should be. */
#if defined(defined)
#error defined is defined!
#endif
#define is_Z_defined defined ( Z )
#if defined(Z)
#error Z is not defined
#endif
/* The behavior of "defined" when it comes from a macro expansion is
now documented. */
#if is_Z_defined
#error Macro expanding into defined operator test 1
#endif
#define Z
#if !defined(Z)
#error Z is defined
#endif
#if !is_Z_defined
#error Macro expanding into defined operator test 2
#endif
/* Use of defined in different contexts. */
#define bad1 defined
#if !bad1 Z /* { dg-warning "may not be portable" } */
#error Z is defined
#endif
#if !bad1 (Z) /* { dg-warning "may not be portable" } */
#error Z is defined
#endif
#define bad2 defined (Z
#if !bad2) /* { dg-warning "may not be portable" } */
#error Z is defined
#endif
|