gdb
[external/binutils.git] / gdb / testsuite / gdb.base / macscp1.c
1 #include <stdio.h>
2
3 #define SPLICE(a, b) INNER_SPLICE(a, b)
4 #define INNER_SPLICE(a, b) a ## b
5 #define STRINGIFY(a) INNER_STRINGIFY(a)
6 #define INNER_STRINGIFY(a) #a
7
8 #define FIFTY_SEVEN 57
9
10 #define FORTY_EIGHT 48
11 #undef  FORTY_EIGHT
12
13 /* A macro named UNTIL_<func> is #defined until just before the
14    definition of the function <func>.
15
16    A macro named BEFORE_<func> is not #defined until just before the
17    definition of <func>.
18
19    The macro WHERE is redefined before each function <func> to the
20    token list ``before <func>''.
21
22    The macscp IN_MACSCP2_H and IN_MACSCP3_H are defined while
23    processing those header files; macscp4.h uses them to choose
24    appropriate function names, output strings, and macro definitions.  */
25
26 #define UNTIL_MACSCP1_1
27 #define UNTIL_MACSCP2_1
28 #define UNTIL_MACSCP4_1_FROM_MACSCP2
29 #define UNTIL_MACSCP4_2_FROM_MACSCP2
30 #define UNTIL_MACSCP2_2
31 #define UNTIL_MACSCP1_2
32 #define UNTIL_MACSCP3_1
33 #define UNTIL_MACSCP4_1_FROM_MACSCP3
34 #define UNTIL_MACSCP4_2_FROM_MACSCP3
35 #define UNTIL_MACSCP3_2
36 #define UNTIL_MACSCP1_3
37
38 #define WHERE before macscp1_1
39 #define BEFORE_MACSCP1_1
40 #undef UNTIL_MACSCP1_1
41 void
42 macscp1_1 ()
43 {
44   puts ("macscp1_1");
45 }
46
47 #include "macscp2.h"
48
49 #undef WHERE
50 #define WHERE before macscp1_2
51 #define BEFORE_MACSCP1_2
52 #undef UNTIL_MACSCP1_2
53 void
54 macscp1_2 ()
55 {
56   puts ("macscp1_2");
57 }
58
59 #include "macscp3.h"
60
61 #undef WHERE
62 #define WHERE before macscp1_3
63 #define BEFORE_MACSCP1_3
64 #undef UNTIL_MACSCP1_3
65 void
66 macscp1_3 ()
67 {
68   puts ("macscp1_3");
69 }
70
71 void
72 macscp_expr (void)
73 {
74   int foo = -1;
75
76   foo = 0;  /* set breakpoint here */
77 #define MACRO_TO_EXPAND foo
78   foo = 1;
79 #undef MACRO_TO_EXPAND
80   foo = 2;
81 }
82
83 #define TWENTY_THREE 23
84
85 int
86 main (int argc, char **argv)
87 {
88   macscp1_1 ();
89   macscp2_1 ();
90   macscp4_1_from_macscp2 ();
91   macscp4_2_from_macscp2 ();
92   macscp2_2 ();
93   macscp1_2 ();
94   macscp3_1 ();
95   macscp4_1_from_macscp3 ();
96   macscp4_2_from_macscp3 ();
97   macscp3_2 ();
98   macscp1_3 ();
99   macscp_expr ();
100 }