Nuke arch-tags.
[emacs.git] / test / cedet / tests / test.c
blobf33e970e6fc49e75e2c6d3a286a3876837613bb8
1 /* test.c --- Semantic unit test for C.
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4 2010, 2011 Free Software Foundation, Inc.
6 Author: Eric M. Ludlam <eric@siege-engine.com>
8 This file is part of GNU Emacs.
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.
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.
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/>.
24 /* Attempt to include as many aspects of the C language as possible.
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>
35 #if 0
36 int dont_show_function()
39 #endif
41 /* Global types */
42 struct mystruct1 {
43 int slot11;
44 char slot12;
45 float slot13;
48 struct mystruct2 {
49 int slot21;
50 char slot22;
51 float slot23;
52 } var_of_type_mystruct2;
54 struct {
55 int slot31;
56 char slot32;
57 float slot33;
58 } var_of_anonymous_struct;
60 typedef struct mystruct1 typedef_of_mystruct1;
61 typedef struct mystruct1 *typedef_of_pointer_mystruct1;
62 typedef struct { int slot_a; } typedef_of_anonymous_struct;
63 typedef struct A {
64 } B;
66 typedef struct mystruct1 td1, td2;
68 union myunion1 {
69 int slot41;
70 char slot42;
71 float slot43;
74 union myunion2 {
75 int slot51;
76 char slot52;
77 float slot53;
78 } var_of_type_myunion2;
80 struct {
81 int slot61;
82 char slot72;
83 float slot83;
84 } var_of_anonymous_union;
86 typedef union myunion1 typedef_of_myunion1;
87 typedef union myunion1 *typedef_of_pointer_myunion1;
88 typedef union { int slot_a; } typedef_of_anonymous_union;
90 enum myenum1 { enum11 = 1, enum12 };
91 enum myenum2 { enum21, enum22 = 2 } var_of_type_myenum2;
92 enum { enum31, enum32 } var_of_anonymous_enum;
94 typedef enum myenum1 typedef_of_myenum1;
95 typedef enum myenum1 *typedef_of_pointer_myenum1;
96 typedef enum { enum_a = 3, enum_b } typedef_of_anonymous_enum;
98 typedef int typedef_of_int;
100 /* Here are some simpler variable types */
101 int var1;
102 int varbit1:1;
103 char var2;
104 float var3;
105 mystruct1 var3;
106 struct mystruct1 var4;
107 union myunion1 var5;
108 enum myenum1 var6;
110 char *varp1;
111 char **varp2;
112 char varv1[1];
113 char varv2[1][2];
115 char *varpa1 = "moose";
116 struct mystruct2 vara2 = { 1, 'a', 0.0 };
117 enum myenum1 vara3 = enum11;
118 int vara4 = (int)0.0;
119 int vara5 = funcall();
121 int mvar1, mvar2, mvar3;
122 char *mvarp1, *mvarp2, *mvarp3;
123 char *mvarpa1 = 'a', *mvarpa2 = 'b', *mvarpa3 = 'c';
124 char mvaras1[10], mvaras2[12][13], *mvaras3 = 'd';
126 static register const unsigned int tmvar1;
128 #define MACRO1 1
129 #define MACRO2(foo) (1+foo)
131 /* Here are some function prototypes */
133 /* This is legal, but I decided not to support inferred integer
134 * types on functions and variables.
136 fun0();
137 int funp1();
138 char funp2(int arg11);
139 float funp3(char arg21, char arg22);
140 struct mystrct1 funp4(struct mystruct2 arg31, union myunion2 arg32);
141 enum myenum1 funp5(char *arg41, union myunion1 *arg42);
143 char funpp1 __P(char argp1, struct mystruct2 argp2, char *arg4p);
145 int fun1();
147 /* Here is a function pointer */
148 int (*funcptr)(int a, int b);
150 /* Function Definitions */
152 /* This is legal, but I decided not to support inferred integer
153 * types on functions and variables.
155 fun0()
157 int sv = 0;
160 int fun1 ()
162 int sv = 1;
165 int fun1p1 (void)
167 int sv = 1;
170 char fun2(int arg_11)
172 char sv = 2;
175 float fun3(char arg_21, char arg_22)
177 char sv = 3;
180 struct mystrct1 fun4(struct mystruct2 arg31, union myunion2 arg32)
182 sv = 4;
185 enum myenum1 fun5(char *arg41, union myunion1 *arg42)
187 sv = 5;
190 /* Functions with K&R syntax. */
191 struct mystrct1 funk1(arg_31, arg_32)
192 struct mystruct2 arg_31;
193 union myunion2 arg32;
195 sv = 4;
198 enum myenum1 *funk2(arg_41, arg_42)
199 char *arg_41;
200 union myunion1 *arg_42;
202 sv = 5;
204 if(foo) {
208 int funk3(arg_51, arg_53)
209 int arg_51;
210 char arg_53;
212 char q = 'a';
213 int sv = 6;
214 td1 ms1;
215 enum myenum1 testconst;
217 /* Function argument analysis */
218 funk3(ms1.slot11, arg_53 );
219 sv = 7;
221 /* Slot deref on assignee */
222 ms1.slot11 = s;
224 /* Enum/const completion */
225 testconst = e;
227 /* Bad var/slot and param */
228 blah.notafunction(moose);
230 /* Print something. */
231 printf("Moose", );
233 tan();
236 int funk4_fixme(arg_61, arg_62)
237 int arg_61, arg_62;
242 /* End of C tests */