Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / test / cedet / tests / testsppreplace.c
blob6bdea6e78291b7ac6945d672c9de9709e752998a
1 /* testsppreplace.c --- unit test for CPP/SPP Replacement
2 Copyright (C) 2007-2014 Free Software Foundation, Inc.
4 Author: Eric M. Ludlam <eric@siege-engine.com>
6 This file is part of GNU Emacs.
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 /* TEST: The EMU keyword doesn't screw up the function defn. */
23 #define EMU
24 #define EMU2 /*comment*/
25 char EMU parse_around_emu EMU2 (EMU)
29 /* TEST: A simple word can be replaced in a definition. */
30 #define SUBFLOAT /* Some Float */ float
31 SUBFLOAT returnanfloat()
35 /* TEST: Punctuation an be replaced in a definition. */
36 #define COLON :
37 int foo COLON COLON bar ()
41 /* TEST: Multiple lexical characters in a definition */
42 #define SUPER mysuper::
43 int SUPER baz ()
47 /* TEST: Macro replacement. */
48 #define INT_FCN(name) int name (int in)
50 INT_FCN(increment) {
51 return in+1;
54 /* TEST: Macro replacement with complex args */
55 #define P_(proto) ()
57 int myFcn1 P_((a,b));
59 #define P__(proto) proto
61 int myFcn2 P__((int a, int b));
62 int myFcn3 (int a, int b);
64 /* TEST: Multiple args to a macro. */
65 #define MULTI_ARGS(name, field1, field2, field3) struct name { int field1; int field2; int field3; }
67 MULTI_ARGS(ma_struct, moose, penguin, emu);
69 /* TEST: Macro w/ args, but no body. */
70 #define NO_BODY(name)
72 NO_BODY(Moose);
74 /* TEST: Not a macro with args, but close. */
75 #define NOT_WITH_ARGS (moose)
77 int not_with_args_fcn NOT_WITH_ARGS
81 /* TEST: macro w/ continuation. */
82 #define WITH_CONT \
83 continuation_symbol
85 int WITH_CONT () { };
87 /* TEST: macros in a macro - tail processing */
88 #define tail_with_args_and_long_name(a) (int a)
89 #define int_arg tail_with_args_and_long_name
91 int tail int_arg(q) {}
93 /* TEST: macros used improperly. */
94 #define tail_fail tail_with_args_and_long_name(q)
96 int tail_fcn tail_fail(q);
98 /* TEST: feature of CPP from LSD <lsdsgster@...> */
99 #define __gthrw_(name) __gthrw_ ## name
101 int __gthrw_(foo) (int arg1) { }
103 /* TEST: macros using macros */
104 #define macro_foo foo
105 #define mf_declare int macro_foo
107 mf_declare;
109 /* TEST: macros with args using macros */
110 #define Amacro(A) (int A)
111 #define mf_Amacro(B) int B Amacro(B)
113 mf_Amacro(noodle);
115 /* TEST: Double macro using the argument stack. */
116 #define MACRO0(name) int that_ ## name(int i);
117 #define MACRO1(name) int this_ ## name(int i);
118 #define MACRO2(name) MACRO0(name) MACRO1(name)
120 MACRO2(foo)
122 /* TEST: The G++ namespace macro hack. Not really part of SPP. */
123 _GLIBCXX_BEGIN_NAMESPACE(baz)
125 int bazfnc(int b) { }
127 _GLIBCXX_END_NAMESPACE;
129 _GLIBCXX_BEGIN_NESTED_NAMESPACE(foo,bar)
131 int foo_bar_func(int a) { }
133 _GLIBCXX_END_NESTED_NAMESPACE;
136 /* TEST: The VC++ macro hack. */
137 _STD_BEGIN
139 int inside_std_namespace(int a) { }
141 _STD_END
143 /* TEST: Recursion prevention. CPP doesn't allow even 1 level of recursion. */
144 #define STARTMACRO MACROA
145 #define MACROA MACROB
146 #define MACROB MACROA
148 int STARTMACRO () {
153 /* END */