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>
36 int dont_show_function()
52 } var_of_type_mystruct2
;
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
;
66 typedef struct mystruct1 td1
, td2
;
78 } var_of_type_myunion2
;
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 */
106 struct mystruct1 var4
;
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
;
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.
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
);
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.
170 char fun2(int arg_11
)
175 float fun3(char arg_21
, char arg_22
)
180 struct mystrct1
fun4(struct mystruct2 arg31
, union myunion2 arg32
)
185 enum myenum1
fun5(char *arg41
, union myunion1
*arg42
)
190 /* Functions with K&R syntax. */
191 struct mystrct1
funk1(arg_31
, arg_32
)
192 struct mystruct2 arg_31
;
193 union myunion2 arg32
;
198 enum myenum1
*funk2(arg_41
, arg_42
)
200 union myunion1
*arg_42
;
208 int funk3(arg_51
, arg_53
)
215 enum myenum1 testconst
;
217 /* Function argument analysis */
218 funk3(ms1
.slot11
, arg_53
);
221 /* Slot deref on assignee */
224 /* Enum/const completion */
227 /* Bad var/slot and param */
228 blah
.notafunction(moose
);
230 /* Print something. */
236 int funk4_fixme(arg_61
, arg_62
)
244 /* arch-tag: ac9c7740-05ad-4821-a0b4-5db4357750ae
245 (do not change this comment) */