1 /* test.c --- Semantic unit test for C.
3 Copyright (C) 2001-2013 Free Software Foundation, Inc.
5 Author: Eric M. Ludlam <eric@siege-engine.com>
7 This file is part of GNU Emacs.
9 GNU Emacs is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 GNU Emacs is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 /* Attempt to include as many aspects of the C language as possible.
26 /* types of include files */
27 #include "includeme1.h"
28 #include <includeme2.h>
29 #include <subdir/includeme3.h>
30 #include <includeme.notanhfile>
35 int dont_show_function()
51 } var_of_type_mystruct2
;
57 } var_of_anonymous_struct
;
59 typedef struct mystruct1 typedef_of_mystruct1
;
60 typedef struct mystruct1
*typedef_of_pointer_mystruct1
;
61 typedef struct { int slot_a
; } typedef_of_anonymous_struct
;
65 typedef struct mystruct1 td1
, td2
;
77 } var_of_type_myunion2
;
83 } var_of_anonymous_union
;
85 typedef union myunion1 typedef_of_myunion1
;
86 typedef union myunion1
*typedef_of_pointer_myunion1
;
87 typedef union { int slot_a
; } typedef_of_anonymous_union
;
89 enum myenum1
{ enum11
= 1, enum12
};
90 enum myenum2
{ enum21
, enum22
= 2 } var_of_type_myenum2
;
91 enum { enum31
, enum32
} var_of_anonymous_enum
;
93 typedef enum myenum1 typedef_of_myenum1
;
94 typedef enum myenum1
*typedef_of_pointer_myenum1
;
95 typedef enum { enum_a
= 3, enum_b
} typedef_of_anonymous_enum
;
97 typedef int typedef_of_int
;
99 /* Here are some simpler variable types */
105 struct mystruct1 var4
;
114 char *varpa1
= "moose";
115 struct mystruct2 vara2
= { 1, 'a', 0.0 };
116 enum myenum1 vara3
= enum11
;
117 int vara4
= (int)0.0;
118 int vara5
= funcall();
120 int mvar1
, mvar2
, mvar3
;
121 char *mvarp1
, *mvarp2
, *mvarp3
;
122 char *mvarpa1
= 'a', *mvarpa2
= 'b', *mvarpa3
= 'c';
123 char mvaras1
[10], mvaras2
[12][13], *mvaras3
= 'd';
125 static register const unsigned int tmvar1
;
128 #define MACRO2(foo) (1+foo)
130 /* Here are some function prototypes */
132 /* This is legal, but I decided not to support inferred integer
133 * types on functions and variables.
137 char funp2(int arg11
);
138 float funp3(char arg21
, char arg22
);
139 struct mystrct1
funp4(struct mystruct2 arg31
, union myunion2 arg32
);
140 enum myenum1
funp5(char *arg41
, union myunion1
*arg42
);
142 char funpp1
__P(char argp1
, struct mystruct2 argp2
, char *arg4p
);
146 /* Here is a function pointer */
147 int (*funcptr
)(int a
, int b
);
149 /* Function Definitions */
151 /* This is legal, but I decided not to support inferred integer
152 * types on functions and variables.
169 char fun2(int arg_11
)
174 float fun3(char arg_21
, char arg_22
)
179 struct mystrct1
fun4(struct mystruct2 arg31
, union myunion2 arg32
)
184 enum myenum1
fun5(char *arg41
, union myunion1
*arg42
)
189 /* Functions with K&R syntax. */
190 struct mystrct1
funk1(arg_31
, arg_32
)
191 struct mystruct2 arg_31
;
192 union myunion2 arg32
;
197 enum myenum1
*funk2(arg_41
, arg_42
)
199 union myunion1
*arg_42
;
207 int funk3(arg_51
, arg_53
)
214 enum myenum1 testconst
;
216 /* Function argument analysis */
217 funk3(ms1
.slot11
, arg_53
);
220 /* Slot deref on assignee */
223 /* Enum/const completion */
226 /* Bad var/slot and param */
227 blah
.notafunction(moose
);
229 /* Print something. */
235 int funk4_fixme(arg_61
, arg_62
)