104494
|
1 /* Test CPP/SPP Replacement
|
|
2 */
|
|
3
|
|
4 /* TEST: The EMU keyword doesn't screw up the function defn. */
|
|
5 #define EMU
|
|
6 #define EMU2 /*comment*/
|
|
7 char EMU parse_around_emu EMU2 (EMU)
|
|
8 {
|
|
9 }
|
|
10
|
|
11 /* TEST: A simple word can be replaced in a definition. */
|
|
12 #define SUBFLOAT /* Some Float */ float
|
|
13 SUBFLOAT returnanfloat()
|
|
14 {
|
|
15 }
|
|
16
|
|
17 /* TEST: Punctuation an be replaced in a definition. */
|
|
18 #define COLON :
|
|
19 int foo COLON COLON bar ()
|
|
20 {
|
|
21 }
|
|
22
|
|
23 /* TEST: Multiple lexical characters in a definition */
|
|
24 #define SUPER mysuper::
|
|
25 int SUPER baz ()
|
|
26 {
|
|
27 }
|
|
28
|
|
29 /* TEST: Macro replacement. */
|
|
30 #define INT_FCN(name) int name (int in)
|
|
31
|
|
32 INT_FCN(increment) {
|
|
33 return in+1;
|
|
34 }
|
|
35
|
|
36 /* TEST: Macro replacement with complex args */
|
|
37 #define P_(proto) ()
|
|
38
|
|
39 int myFcn1 P_((a,b));
|
|
40
|
|
41 #define P__(proto) proto
|
|
42
|
|
43 int myFcn2 P__((int a, int b));
|
|
44 int myFcn3 (int a, int b);
|
|
45
|
|
46 /* TEST: Multiple args to a macro. */
|
|
47 #define MULTI_ARGS(name, field1, field2, field3) struct name { int field1; int field2; int field3; }
|
|
48
|
|
49 MULTI_ARGS(ma_struct, moose, penguin, emu);
|
|
50
|
|
51 /* TEST: Macro w/ args, but no body. */
|
|
52 #define NO_BODY(name)
|
|
53
|
|
54 NO_BODY(Moose);
|
|
55
|
|
56 /* TEST: Not a macro with args, but close. */
|
|
57 #define NOT_WITH_ARGS (moose)
|
|
58
|
|
59 int not_with_args_fcn NOT_WITH_ARGS
|
|
60 {
|
|
61 }
|
|
62
|
|
63 /* TEST: macro w/ continuation. */
|
|
64 #define WITH_CONT \
|
|
65 continuation_symbol
|
|
66
|
|
67 int WITH_CONT () { };
|
|
68
|
|
69 /* TEST: macros in a macro - tail processing */
|
|
70 #define tail_with_args_and_long_name(a) (int a)
|
|
71 #define int_arg tail_with_args_and_long_name
|
|
72
|
|
73 int tail int_arg(q) {}
|
|
74
|
|
75 /* TEST: macros used improperly. */
|
|
76 #define tail_fail tail_with_args_and_long_name(q)
|
|
77
|
|
78 int tail_fcn tail_fail(q);
|
|
79
|
|
80 /* TEST: feature of CPP from LSD <lsdsgster@...> */
|
|
81 #define __gthrw_(name) __gthrw_ ## name
|
|
82
|
|
83 int __gthrw_(foo) (int arg1) { }
|
|
84
|
|
85 /* TEST: macros using macros */
|
|
86 #define macro_foo foo
|
|
87 #define mf_declare int macro_foo
|
|
88
|
|
89 mf_declare;
|
|
90
|
|
91 /* TEST: macros with args using macros */
|
|
92 #define Amacro(A) (int A)
|
|
93 #define mf_Amacro(B) int B Amacro(B)
|
|
94
|
|
95 mf_Amacro(noodle);
|
|
96
|
|
97 /* TEST: Double macro using the argument stack. */
|
|
98 #define MACRO0(name) int that_ ## name(int i);
|
|
99 #define MACRO1(name) int this_ ## name(int i);
|
|
100 #define MACRO2(name) MACRO0(name) MACRO1(name)
|
|
101
|
|
102 MACRO2(foo)
|
|
103
|
|
104 /* TEST: The G++ namespace macro hack. Not really part of SPP. */
|
|
105 _GLIBCXX_BEGIN_NAMESPACE(baz)
|
|
106
|
|
107 int bazfnc(int b) { }
|
|
108
|
|
109 _GLIBCXX_END_NAMESPACE;
|
|
110
|
|
111 _GLIBCXX_BEGIN_NESTED_NAMESPACE(foo,bar)
|
|
112
|
|
113 int foo_bar_func(int a) { }
|
|
114
|
|
115 _GLIBCXX_END_NESTED_NAMESPACE;
|
|
116
|
|
117
|
|
118 /* TEST: The VC++ macro hack. */
|
|
119 _STD_BEGIN
|
|
120
|
|
121 int inside_std_namespace(int a) { }
|
|
122
|
|
123 _STD_END
|
|
124
|
|
125 /* TEST: Recursion prevention. CPP doesn't allow even 1 level of recursion. */
|
|
126 #define STARTMACRO MACROA
|
|
127 #define MACROA MACROB
|
|
128 #define MACROB MACROA
|
|
129
|
|
130 int STARTMACRO () {
|
|
131
|
|
132 }
|
|
133
|
|
134
|
|
135 /* END */
|
105377
|
136
|
|
137 /* arch-tag: ee9bd650-35f4-468f-82d7-a5f3606c0132
|
|
138 (do not change this comment) */
|