Add 2011 to FSF/AIST copyright years.
[bpt/emacs.git] / test / cedet / tests / test.c
CommitLineData
a4100ebe
CY
1/* test.c --- Semantic unit test for C.
2
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
5df4f04c 4 2010, 2011 Free Software Foundation, Inc.
a4100ebe
CY
5
6 Author: Eric M. Ludlam <eric@siege-engine.com>
7
8 This file is part of GNU Emacs.
9
10 GNU Emacs is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 GNU Emacs is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24/* Attempt to include as many aspects of the C language as possible.
74ea13c1 25 */
a4100ebe 26
74ea13c1
CY
27/* types of include files */
28#include "includeme1.h"
29#include <includeme2.h>
30#include <subdir/includeme3.h>
31#include <includeme.notanhfile>
32#include <stdlib.h>
33#include <cmath>
34
35#if 0
36int dont_show_function()
37{
38}
39#endif
40
41/* Global types */
42struct mystruct1 {
43 int slot11;
44 char slot12;
45 float slot13;
46};
47
48struct mystruct2 {
49 int slot21;
50 char slot22;
51 float slot23;
52} var_of_type_mystruct2;
53
54struct {
55 int slot31;
56 char slot32;
57 float slot33;
58} var_of_anonymous_struct;
59
60typedef struct mystruct1 typedef_of_mystruct1;
61typedef struct mystruct1 *typedef_of_pointer_mystruct1;
62typedef struct { int slot_a; } typedef_of_anonymous_struct;
63typedef struct A {
64} B;
65
66typedef struct mystruct1 td1, td2;
67
68union myunion1 {
69 int slot41;
70 char slot42;
71 float slot43;
72};
73
74union myunion2 {
75 int slot51;
76 char slot52;
77 float slot53;
78} var_of_type_myunion2;
79
80struct {
81 int slot61;
82 char slot72;
83 float slot83;
84} var_of_anonymous_union;
85
86typedef union myunion1 typedef_of_myunion1;
87typedef union myunion1 *typedef_of_pointer_myunion1;
88typedef union { int slot_a; } typedef_of_anonymous_union;
89
90enum myenum1 { enum11 = 1, enum12 };
91enum myenum2 { enum21, enum22 = 2 } var_of_type_myenum2;
92enum { enum31, enum32 } var_of_anonymous_enum;
93
94typedef enum myenum1 typedef_of_myenum1;
95typedef enum myenum1 *typedef_of_pointer_myenum1;
96typedef enum { enum_a = 3, enum_b } typedef_of_anonymous_enum;
97
98typedef int typedef_of_int;
99
100/* Here are some simpler variable types */
101int var1;
102int varbit1:1;
103char var2;
104float var3;
105mystruct1 var3;
106struct mystruct1 var4;
107union myunion1 var5;
108enum myenum1 var6;
109
110char *varp1;
111char **varp2;
112char varv1[1];
113char varv2[1][2];
114
115char *varpa1 = "moose";
116struct mystruct2 vara2 = { 1, 'a', 0.0 };
117enum myenum1 vara3 = enum11;
118int vara4 = (int)0.0;
119int vara5 = funcall();
120
121int mvar1, mvar2, mvar3;
122char *mvarp1, *mvarp2, *mvarp3;
123char *mvarpa1 = 'a', *mvarpa2 = 'b', *mvarpa3 = 'c';
124char mvaras1[10], mvaras2[12][13], *mvaras3 = 'd';
125
126static register const unsigned int tmvar1;
127
128#define MACRO1 1
129#define MACRO2(foo) (1+foo)
130
131/* Here are some function prototypes */
132
133/* This is legal, but I decided not to support inferred integer
134 * types on functions and variables.
135 */
136fun0();
137int funp1();
138char funp2(int arg11);
139float funp3(char arg21, char arg22);
140struct mystrct1 funp4(struct mystruct2 arg31, union myunion2 arg32);
141enum myenum1 funp5(char *arg41, union myunion1 *arg42);
142
143char funpp1 __P(char argp1, struct mystruct2 argp2, char *arg4p);
144
145int fun1();
146
147/* Here is a function pointer */
148int (*funcptr)(int a, int b);
149
150/* Function Definitions */
151
152/* This is legal, but I decided not to support inferred integer
153 * types on functions and variables.
154 */
155fun0()
156{
157 int sv = 0;
158}
159
160int fun1 ()
161{
162 int sv = 1;
163}
164
165int fun1p1 (void)
166{
167 int sv = 1;
168}
169
170char fun2(int arg_11)
171{
172 char sv = 2;
173}
174
175float fun3(char arg_21, char arg_22)
176{
177 char sv = 3;
178}
179
180struct mystrct1 fun4(struct mystruct2 arg31, union myunion2 arg32)
181{
182 sv = 4;
183}
184
185enum myenum1 fun5(char *arg41, union myunion1 *arg42)
186{
187 sv = 5;
188}
189
190/* Functions with K&R syntax. */
191struct mystrct1 funk1(arg_31, arg_32)
192 struct mystruct2 arg_31;
193 union myunion2 arg32;
194{
195 sv = 4;
196}
197
198enum myenum1 *funk2(arg_41, arg_42)
199 char *arg_41;
200 union myunion1 *arg_42;
201{
202 sv = 5;
203
204 if(foo) {
205 }
206}
207
208int funk3(arg_51, arg_53)
209 int arg_51;
210 char arg_53;
211{
212 char q = 'a';
213 int sv = 6;
214 td1 ms1;
215 enum myenum1 testconst;
216
217 /* Function argument analysis */
218 funk3(ms1.slot11, arg_53 );
219 sv = 7;
220
221 /* Slot deref on assignee */
222 ms1.slot11 = s;
223
224 /* Enum/const completion */
225 testconst = e;
226
227 /* Bad var/slot and param */
228 blah.notafunction(moose);
229
230 /* Print something. */
231 printf("Moose", );
232
233 tan();
234}
235
236int funk4_fixme(arg_61, arg_62)
237 int arg_61, arg_62;
238{
239
240}
241
242/* End of C tests */
3999968a
MB
243
244/* arch-tag: ac9c7740-05ad-4821-a0b4-5db4357750ae
245 (do not change this comment) */