Allow returning something of type void in a function that returns void
[delight/core.git] / d-lang.h
blob1888205f7cbe4f16db92649d09cd88db79859fa9
1 /* GDC -- D front-end for GCC
2 Copyright (C) 2004 David Friedman
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef GCC_DCMPLR_DC_LANG_H
20 #define GCC_DCMPLR_DC_LANG_H
22 /* Nothing is added to tree_identifier; */
23 struct lang_identifier GTY(())
25 struct tree_identifier ignore;
28 /* This is required to be defined, but we do not use it. */
29 struct language_function GTY(())
31 int unused;
34 /* The DMD front end types have not been integrated into the GCC garbage
35 collection system. Handle this by using the "skip" attribute. */
36 struct Declaration;
37 typedef struct Declaration *DeclarationGTYP;
38 struct lang_decl GTY(())
40 DeclarationGTYP GTY ((skip(""))) d_decl;
43 /* The lang_type field is not set for every GCC type. */
44 struct Type;
45 typedef struct Type *TypeGTYP;
46 struct lang_type GTY(())
48 TypeGTYP GTY((skip(""))) d_type;
51 /* Another required, but unused declaration. This could be simplified, since
52 there is no special lang_identifier */
53 union lang_tree_node
54 GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
55 chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
57 union tree_node GTY ((tag ("0"),
58 desc ("tree_node_structure (&%h)")))
59 generic;
60 struct lang_identifier GTY ((tag ("1"))) identifier;
63 // These special tree codes are not needed for 4.x
64 #if D_GCC_VER < 40
65 #undef DEFTREECODE
66 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
68 enum d_tree_code {
69 D_DUMMY_TREE_CODE = LAST_AND_UNUSED_TREE_CODE,
70 #include "d-tree.def"
71 LAST_D_TREE_CODE
73 #endif
75 /* True if the Tdelegate typed expression is not really a variable,
76 but a literal function / method reference */
77 #define D_IS_METHOD_CALL_EXPR(NODE) (TREE_LANG_FLAG_0(NODE))
79 /* True if the symbol should be made "link one only". This is used to
80 defer calling make_decl_one_only() before the decl has been prepared. */
81 #define D_DECL_ONE_ONLY(NODE) (DECL_LANG_FLAG_0(NODE))
83 /* True if the symbol is a template member. Need to distinguish
84 between templates and other shared static data so that the latter
85 is not affected by -femit-templates. */
86 #define D_DECL_IS_TEMPLATE(NODE) (DECL_LANG_FLAG_1(NODE))
88 /* True if the function has been marked "naked". */
89 #define D_DECL_NO_FRAME_POINTER(NODE) (DECL_LANG_FLAG_2(NODE))
91 /* The D front-end does not use the 'binding level' system for a symbol table,
92 It is only needed to get debugging information for local variables and
93 otherwise support the backend. */
94 struct binding_level GTY(())
96 /* A chain of declarations. These are in the reverse of the order supplied. */
97 tree names;
99 /* A pointer to the end of the names chain. Only needed to facilitate
100 a quick test if a decl is in the list by checking if its TREE_CHAIN
101 is not NULL or it is names_end (in pushdecl_nocheck()). */
102 tree names_end;
104 /* For each level (except the global one), a chain of BLOCK nodes for
105 all the levels that were entered and exited one level down. */
106 tree blocks;
108 /* The BLOCK node for this level, if one has been preallocated.
109 If NULL_TREE, the BLOCK is allocated (if needed) when the level is popped. */
110 tree this_block;
112 /* The binding level this one is contained in. */
113 struct binding_level *level_chain;
117 extern GTY(()) struct binding_level * current_binding_level;
118 extern GTY(()) struct binding_level * global_binding_level;
120 extern GTY(()) tree intmax_type_node;
121 extern GTY(()) tree uintmax_type_node;
122 extern GTY(()) tree signed_size_type_node;
123 extern GTY(()) tree string_type_node;
124 extern GTY(()) tree const_string_type_node;
126 extern GTY(()) tree d_null_pointer;
127 extern GTY(()) tree d_void_zero_node;
128 extern GTY(()) tree d_vtbl_ptr_type_node;
130 #if D_GCC_VER >= 41
131 /* not GTY'd because gtype does not actually understand #if */
132 extern tree null_node;
133 #endif
135 #ifdef __cplusplus
136 /* In d-lang.cc. These are called through function pointers
137 and do not need to be "extern C". */
138 extern bool d_mark_addressable PARAMS ((tree));
139 extern tree d_truthvalue_conversion PARAMS ((tree));
140 extern tree d_convert_basic PARAMS ((tree, tree));
142 extern void init_global_binding_level(void);
143 extern void set_decl_binding_chain(tree decl_chain);
145 extern void d_add_global_function PARAMS(( tree ));
147 extern tree d_unsigned_type(tree);
148 extern tree d_signed_type(tree);
150 extern tree d_type_promotes_to(tree);
152 extern rtx d_expand_expr(tree, rtx, enum machine_mode, int, rtx *);
154 extern void gcc_d_backend_init();
155 extern void gcc_d_backend_term();
157 struct Module;
158 extern Module * d_gcc_get_output_module();
160 extern struct lang_type * build_d_type_lang_specific(Type * t);
162 /* In asmstmt.cc */
163 struct IRState;
164 extern bool d_have_inline_asm();
165 extern void d_expand_priv_asm_label(IRState * irs, unsigned n);
166 extern tree d_build_asm_stmt(tree t1, tree t2, tree t3, tree t4);
168 #endif
170 #ifdef __cplusplus
171 extern "C" {
172 #endif
173 /* In d-lang.cc */
174 tree pushdecl PARAMS ((tree));
175 void pushlevel PARAMS ((int));
176 tree poplevel PARAMS ((int, int, int));
177 tree d_type_for_size(unsigned bits, int unsignedp);
178 tree d_type_for_mode(enum machine_mode mode, int unsignedp);
179 void dkeep(tree t);
181 /* In d-builtins.c */
182 extern void d_init_builtins PARAMS ((void));
183 extern const struct attribute_spec d_common_attribute_table[];
184 extern const struct attribute_spec d_common_format_attribute_table[];
185 extern tree builtin_function PARAMS ((const char *, tree, int, enum built_in_class, const char *, tree));
187 /* In d-misc.c */
188 extern int d_using_sjlj_exceptions PARAMS ((void));
189 extern char * d_asm_format_private_name PARAMS ((const char *,int));
191 /* In d-builtins2.cc */
192 extern void d_bi_init(int nt, int nb);
193 extern void d_bi_builtin_func(tree decl);
195 #ifdef __cplusplus
197 #endif
199 /* protect from garbage collection */
200 extern GTY(()) tree d_keep_list;
202 #include "d-dmd-gcc.h"
204 #if D_GCC_VER >= 40
205 #define TREE_UNSIGNED TYPE_UNSIGNED
206 #define build_type_copy build_variant_type_copy
207 #endif
209 typedef HOST_WIDE_INT hwint;
210 typedef unsigned HOST_WIDE_INT uhwint;
212 #if D_GCC_VER < 40
213 static inline tree build2(enum tree_code c, tree t, tree a, tree b) { return build(c, t, a, b); }
214 #define gcc_assert(x) (assert(x))
215 #define gcc_unreachable(x) (assert(0))
216 #endif
218 #if D_GCC_VER < 41
219 //#define d_warning(option, xformat, ...) warning(format, __VA_ARGS__)
220 #define d_warning(option, ...) warning(__VA_ARGS__)
221 #else
222 //#define d_warning(option, format, ...) warning(option, format, __VA_ARGS__)
223 #define d_warning(option, ...) warning(option, __VA_ARGS__)
224 #endif
226 #endif