1 /* Process declarations and variables for GNU CHILL compiler.
2 Copyright (C) 1992, 1993, 1994, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* Process declarations and symbol lookup for CHILL front end.
24 Also constructs types; the standard scalar types at initialization,
25 and structure, union, array and enum types when they are declared. */
27 /* NOTES on Chill name resolution
29 Chill allows one to refer to an identifier that is declared later in
30 the same Group. Hence, a single pass over the code (as in C) is
33 This implementation uses two complete passes over the source code,
34 plus some extra passes over internal data structures.
36 Loosely, during pass 1, a 'scope' object is created for each Chill
37 reach. Each scope object contains a list of 'decl' objects,
38 one for each 'defining occurrence' in the reach. (This list
39 is in the 'remembered_decls' field of each scope.)
40 The scopes and their decls are replayed in pass 2: As each reach
41 is entered, the decls saved from pass 1 are made visible.
43 There are some exceptions. Declarations that cannot be referenced
44 before their declaration (i.e. whose defining occurrence precede
45 their reach), can be deferred to pass 2. These include formal
46 parameter declarations, and names defined in a DO action.
48 During pass 2, as each scope is entered, we must make visible all
49 the declarations defined in the scope, before we generate any code.
50 We must also simplify the declarations from pass 1: For example
51 a VAR_DECL may have a array type whose bounds are expressions;
52 these need to be folded. But of course the expressions may contain
53 identifiers that may be defined later in the scope - or even in
56 The "satisfy" process has two main phases:
58 1: Binding. Each identifier *referenced* in a declaration (i.e. in
59 a mode or the RHS of a synonum declaration) must be bound to its
60 defining occurrence. This may need to be linking via
61 grants and/or seizes (which are represented by ALIAS_DECLs).
62 A further complication is handling implied name strings.
64 2: Layout. Each CONST_DECL or TYPE_DECL *referenced* in a declaration
65 must than be replaced by its value (or type). Constants must be
66 folded. Types and declarstions must be laid out. DECL_RTL must be set.
67 While doing this, we must watch out for circular dependencies.
69 If a scope contains nested modulions, then the Binding phase must be
70 done for each nested module (recursively) before the Layout phase
71 can start for that scope. As an example of why this is needed, consider:
74 DCL a ARRAY [1:y] int; -- This should have 7 elements.
84 Here, the 'x' in "x + 5" must be Bound to the 'x' in module M2.
85 This must be done before we can Layout a.
86 The reason this is an issue is that we do *not* have a lookup
87 (or hash) table per scope (or module). Instead we have a single
88 global table we keep adding and removing bindings from.
89 (This is both for speed, and because of gcc history.)
91 Note that a SEIZE generates a declaration in the current scope,
92 linked to something in the surrounding scope. Determining (binding)
93 the link must be done in pass 2. On the other hand, a GRANT
94 generates a declaration in the surrounding scope, linked to
95 something in the current scope. This linkage is Bound in pass 1.
97 The sequence for the above example is:
98 - Enter the declarations of M1 (i.e. {a, x, y}) into the hash table.
99 - For each of {a, x, y}, examine dependent expression (the
100 rhs of x, the bounds of a), and Bind any identifiers to
101 the current declarations (as found in the hash table). Specifically,
102 the 'y' in the array bounds of 'a' is bound to the 'y' declared by
103 the SEIZE declaration. Also, 'y' is Bound to the implicit
104 declaration in the global scope (generated from the GRANT in M2).
105 - Remove the bindings for M1 (i.e. {a, x, y}) from the hash table.
106 - Enter the declarations of M2 (i.e. {x, y}) into the hash table.
107 - For each of {x, y} examine the dependent expressions (the rhs of
108 x and y), and Bind any identifiers to their current declarartions
109 (in this case the 'x' in "x + 5" is bound to the 'x' that is 2.
110 - Remove the bindings for M2 (i.e. {x, y}) from the hash table.
111 - Perform Layout for M1: This requires the size of a, which
112 requires the value of y. The 'y' is Bound to the implicit
113 declaration in the global scope, which is Bound to the declaration
114 of y in M2. We now require the value of this 'y', which is "x + 5"
115 where x is bound to the x in M2 (thanks to our previous Binding
116 phase). So we get that the value of y is 7.
117 - Perform layout of M2. This implies calculating (constant folding)
118 the value of y - but we already did that, so we're done.
120 An example illustating the problem with implied names:
124 use(e); -- e is implied by y.
136 This implies that determining the implied name e in M1
137 must be done after Binding of y to x in M2.
142 DCL a ARRAY(v:v) int;
154 This one implies that determining the implied name e in M2,
155 must be done before Layout of a in M1.
157 These two examples togother indicate the determining implieed
158 names requries yet another phase.
159 - Bind strong names in M1.
160 - Bind strong names in M2.
161 - Bind strong names in M3.
162 - Determine weak names implied by SEIZEs in M1.
163 - Bind the weak names in M1.
164 - Determine weak names implied by SEIZEs in M2.
165 - Bind the weak names in M2.
166 - Determine weak names implied by SEIZEs in M3.
167 - Bind the weak names in M3.
172 We must bind the strong names in every module before we can determine
173 weak names in any module (because of seized/granted synmode/newmodes).
174 We must bind the weak names in every module before we can do Layout
181 /* ??? not all decl nodes are given the most useful possible
182 line numbers. For example, the CONST_DECLs for enum values. */
194 #include "diagnostic.h"
196 #define IS_UNKNOWN_TYPE(type) (TYPE_SIZE(type)==0)
197 #define BUILTIN_NESTING_LEVEL (-1)
199 /* For backward compatibility, we define Chill INT to be the same
200 as SHORT (i.e. 16 bits), at least if C INT is the same as LONG.
202 #define CHILL_INT_IS_SHORT (INT_TYPE_SIZE==LONG_TYPE_SIZE)
204 extern int ignore_case
;
205 extern tree process_type
;
206 extern struct obstack
*saveable_obstack
;
207 extern tree signal_code
;
208 extern int special_UC
;
210 static tree get_next_decl
PARAMS ((void));
211 static tree lookup_name_for_seizing
PARAMS ((tree
));
213 static tree lookup_name_current_level
PARAMS ((tree
));
215 static void save_decl
PARAMS ((tree
));
217 extern struct obstack permanent_obstack
;
218 extern int in_pseudo_module
;
220 struct module
*current_module
= NULL
;
221 struct module
*first_module
= NULL
;
222 struct module
**next_module
= &first_module
;
224 extern int in_pseudo_module
;
226 int module_number
= 0;
228 /* This is only used internally (by signed_type). */
230 tree signed_boolean_type_node
;
232 tree global_function_decl
= NULL_TREE
;
234 /* This is a temportary used by RESULT to store its value.
235 Note we cannot directly use DECL_RESULT for two reasons:
236 a) If DECL_RESULT is a register, it may get clobbered by a
237 subsequent function call; and
238 b) if the function returns a struct, we might (visibly) modify the
239 destination before we're supposed to. */
240 tree chill_result_decl
;
242 int result_never_set
;
244 /* forward declarations */
245 static void pushdecllist
PARAMS ((tree
, int));
246 static int init_nonvalue_struct
PARAMS ((tree
));
247 static int init_nonvalue_array
PARAMS ((tree
));
248 static void set_nesting_level
PARAMS ((tree
, int));
249 static tree make_chill_variants
PARAMS ((tree
, tree
, tree
));
250 static tree fix_identifier
PARAMS ((tree
));
251 static void proclaim_decl
PARAMS ((tree
, int));
252 static tree maybe_acons
PARAMS ((tree
, tree
));
253 static void push_scope_decls
PARAMS ((int));
254 static void pop_scope_decls
PARAMS ((tree
, tree
));
255 static tree build_implied_names
PARAMS ((tree
));
256 static void bind_sub_modules
PARAMS ((int));
257 static void layout_array_type
PARAMS ((tree
));
258 static void do_based_decl
PARAMS ((tree
, tree
, tree
));
259 static void handle_one_level
PARAMS ((tree
, tree
));
261 int current_nesting_level
= BUILTIN_NESTING_LEVEL
;
262 int current_module_nesting_level
= 0;
264 /* Lots of declarations copied from c-decl.c. */
265 /* ??? not all decl nodes are given the most useful possible
266 line numbers. For example, the CONST_DECLs for enum values. */
269 /* We let tm.h override the types used here, to handle trivial differences
270 such as the choice of unsigned int or long unsigned int for size_t.
271 When machines start needing nontrivial differences in the size type,
272 it would be best to do something here to figure out automatically
273 from other information what type to use. */
276 #define PTRDIFF_TYPE "long int"
280 #define WCHAR_TYPE "int"
283 tree wchar_type_node
;
284 tree signed_wchar_type_node
;
285 tree unsigned_wchar_type_node
;
289 /* type of initializer structure, which points to
290 a module's module-level code, and to the next
292 tree initializer_type
;
294 /* type of a CHILL predefined value builtin routine */
295 tree chill_predefined_function_type
;
297 /* type `int ()' -- used for implicit declaration of functions. */
299 tree default_function_type
;
301 const char **boolean_code_name
;
303 /* Nodes for boolean constants TRUE and FALSE. */
304 tree boolean_true_node
, boolean_false_node
;
306 tree string_one_type_node
; /* The type of CHARS(1). */
307 tree bitstring_one_type_node
; /* The type of BOOLS(1). */
308 tree bit_zero_node
; /* B'0' */
309 tree bit_one_node
; /* B'1' */
311 /* Nonzero if we have seen an invalid cross reference
312 to a struct, union, or enum, but not yet printed the message. */
314 tree pending_invalid_xref
;
315 /* File and line to appear in the eventual error message. */
316 char *pending_invalid_xref_file
;
317 int pending_invalid_xref_line
;
319 /* After parsing the declarator that starts a function definition,
320 `start_function' puts here the list of parameter names or chain of decls.
321 `store_parm_decls' finds it here. */
323 static tree current_function_parms
;
325 /* Nonzero when store_parm_decls is called indicates a varargs function.
326 Value not meaningful after store_parm_decls. */
328 static int c_function_varargs
;
330 /* These are irrelevant for Chill, but are referenced from from c-typeck.c. */
332 int warn_traditional
;
333 int warn_bad_function_cast
;
335 /* Identifiers that hold VAR_LENGTH and VAR_DATA. */
336 tree var_length_id
, var_data_id
;
340 /* For each binding contour we allocate a scope structure
341 * which records the names defined in that contour.
344 * 1) one for each function definition,
345 * where internal declarations of the parameters appear.
346 * 2) one for each compound statement,
347 * to record its declarations.
349 * The current meaning of a name can be found by searching the levels from
350 * the current one out to the global one.
353 /* To communicate between pass 1 and 2, we maintain a list of "scopes".
354 Each scope corrresponds to a nested source scope/block that contain
355 that can contain declarations. The TREE_VALUE of the scope points
356 to the list of declarations declared in that scope.
357 The TREE_PURPOSE of the scope points to the surrounding scope.
358 (We may need to handle nested modules later. FIXME)
359 The TREE_CHAIN field contains a list of scope as they are seen
360 in chronological order. (Reverse order during first pass,
361 but it is reverse before pass 2.) */
365 /* The enclosing scope. */
366 struct scope
*enclosing
;
368 /* The next scope, in chronlogical order. */
371 /* A chain of DECLs constructed using save_decl during pass 1. */
372 tree remembered_decls
;
374 /* A chain of _DECL nodes for all variables, constants, functions,
375 and typedef types belong to this scope. */
378 /* List of declarations that have been granted into this scope. */
381 /* List of implied (weak) names. */
384 /* For each level, a list of shadowed outer-level local definitions
385 to be restored when this level is popped.
386 Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
387 whose TREE_VALUE is its old definition (a kind of ..._DECL node). */
390 /* For each level (except not the global one),
391 a chain of BLOCK nodes for all the levels
392 that were entered and exited one level down. */
395 /* The BLOCK node for this level, if one has been preallocated.
396 If 0, the BLOCK is allocated (if needed) when the level is popped. */
399 /* The binding level which this one is contained in (inherits from). */
400 struct scope
*level_chain
;
402 /* Nonzero for a level that corresponds to a module. */
405 /* Zero means called from backend code. */
408 /* The modules that are directly enclosed by this scope
409 are chained together. */
410 struct scope
* first_child_module
;
411 struct scope
** tail_child_module
;
412 struct scope
* next_sibling_module
;
415 /* The outermost binding level, for pre-defined (builtin) names. */
417 static struct scope builtin_scope
= {
418 NULL
, NULL
, NULL_TREE
, NULL_TREE
, NULL_TREE
, NULL_TREE
, NULL_TREE
,
419 NULL_TREE
, NULL_TREE
, NULL
, 0, 0, NULL
, NULL
, NULL
};
421 struct scope
*global_scope
;
423 /* The binding level currently in effect. */
425 static struct scope
*current_scope
= &builtin_scope
;
427 /* The most recently seen scope. */
428 struct scope
*last_scope
= &builtin_scope
;
430 /* Binding level structures are initialized by copying this one. */
432 static struct scope clear_scope
= {
433 NULL
, NULL
, NULL_TREE
, NULL_TREE
, NULL_TREE
, NULL_TREE
, NULL_TREE
,
434 NULL_TREE
, NULL_TREE
, NULL
, 0, 0, NULL
, NULL
, NULL
};
436 /* Chain of decls accessible through IDENTIFIER_OUTER_VALUE.
437 Decls with the same DECL_NAME are adjacent in the chain. */
439 static tree outer_decls
= NULL_TREE
;
441 /* C-specific option variables. */
443 /* Nonzero means allow type mismatches in conditional expressions;
444 just make their values `void'. */
446 int flag_cond_mismatch
;
448 /* Nonzero means give `double' the same size as `float'. */
450 int flag_short_double
;
452 /* Nonzero means don't recognize the keyword `asm'. */
456 /* Nonzero means don't recognize any builtin functions. */
460 /* Nonzero means don't recognize the non-ANSI builtin functions.
463 int flag_no_nonansi_builtin
;
465 /* Nonzero means do some things the same way PCC does. */
467 int flag_traditional
;
469 /* Nonzero means to allow single precision math even if we're generally
470 being traditional. */
471 int flag_allow_single_precision
= 0;
473 /* Nonzero means to treat bitfields as signed unless they say `unsigned'. */
475 int flag_signed_bitfields
= 1;
476 int explicit_flag_signed_bitfields
= 0;
478 /* Nonzero means warn about implicit declarations. */
482 /* Nonzero means give string constants the type `const char *'
483 to get extra warnings from them. These warnings will be too numerous
484 to be useful, except in thoroughly ANSIfied programs. */
486 int warn_write_strings
;
488 /* Nonzero means warn about pointer casts that can drop a type qualifier
489 from the pointer target type. */
493 /* Nonzero means warn about sizeof(function) or addition/subtraction
494 of function pointers. */
496 int warn_pointer_arith
;
498 /* Nonzero means warn for non-prototype function decls
499 or non-prototyped defs without previous prototype. */
501 int warn_strict_prototypes
;
503 /* Nonzero means warn for any global function def
504 without separate previous prototype decl. */
506 int warn_missing_prototypes
;
508 /* Nonzero means warn about multiple (redundant) decls for the same single
509 variable or function. */
511 int warn_redundant_decls
= 0;
513 /* Nonzero means warn about extern declarations of objects not at
514 file-scope level and about *all* declarations of functions (whether
515 extern or static) not at file-scope level. Note that we exclude
516 implicit function declarations. To get warnings about those, use
519 int warn_nested_externs
= 0;
521 /* Warn about a subscript that has type char. */
523 int warn_char_subscripts
= 0;
525 /* Warn if a type conversion is done that might have confusing results. */
529 /* Warn if adding () is suggested. */
531 int warn_parentheses
;
533 /* Warn if initializer is not completely bracketed. */
535 int warn_missing_braces
;
537 /* Define the special tree codes that we use. */
539 /* Table indexed by tree code giving a string containing a character
540 classifying the tree code. Possibilities are
541 t, d, s, c, r, <, 1 and 2. See ch-tree.def for details. */
543 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
545 const char chill_tree_code_type
[] = {
547 #include "ch-tree.def"
551 /* Table indexed by tree code giving number of expression
552 operands beyond the fixed part of the node structure.
553 Not used for types or decls. */
555 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
557 int chill_tree_code_length
[] = {
559 #include "ch-tree.def"
564 /* Names of tree components.
565 Used for printing out the tree and error messages. */
566 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
568 const char *chill_tree_code_name
[] = {
570 #include "ch-tree.def"
574 /* Nonzero means `$' can be in an identifier. */
575 #ifndef DOLLARS_IN_IDENTIFIERS
576 #define DOLLARS_IN_IDENTIFIERS 0
578 int dollars_in_ident
= DOLLARS_IN_IDENTIFIERS
> 1;
580 /* An identifier that is used internally to indicate
581 an "ALL" prefix for granting or seizing.
582 We use "*" rather than the external name "ALL", partly for convenience,
583 and partly to avoid case senstivity problems. */
588 allocate_lang_decl (t
)
589 tree t ATTRIBUTE_UNUSED
;
595 copy_lang_decl (node
)
596 tree node ATTRIBUTE_UNUSED
;
602 build_lang_decl (code
, name
, type
)
603 enum chill_tree_code code
;
607 return build_decl (code
, name
, type
);
610 /* Decode the string P as a language-specific option for C.
611 Return the number of strings consumed for a valid option.
612 Return 0 for an invalid option. */
615 c_decode_option (argc
, argv
)
616 int argc ATTRIBUTE_UNUSED
;
620 if (!strcmp (p
, "-ftraditional") || !strcmp (p
, "-traditional"))
622 flag_traditional
= 1;
623 flag_writable_strings
= 1;
624 #if DOLLARS_IN_IDENTIFIERS > 0
625 dollars_in_ident
= 1;
628 else if (!strcmp (p
, "-fnotraditional") || !strcmp (p
, "-fno-traditional"))
630 flag_traditional
= 0;
631 flag_writable_strings
= 0;
632 dollars_in_ident
= DOLLARS_IN_IDENTIFIERS
> 1;
634 else if (!strcmp (p
, "-fsigned-char"))
635 flag_signed_char
= 1;
636 else if (!strcmp (p
, "-funsigned-char"))
637 flag_signed_char
= 0;
638 else if (!strcmp (p
, "-fno-signed-char"))
639 flag_signed_char
= 0;
640 else if (!strcmp (p
, "-fno-unsigned-char"))
641 flag_signed_char
= 1;
642 else if (!strcmp (p
, "-fsigned-bitfields")
643 || !strcmp (p
, "-fno-unsigned-bitfields"))
645 flag_signed_bitfields
= 1;
646 explicit_flag_signed_bitfields
= 1;
648 else if (!strcmp (p
, "-funsigned-bitfields")
649 || !strcmp (p
, "-fno-signed-bitfields"))
651 flag_signed_bitfields
= 0;
652 explicit_flag_signed_bitfields
= 1;
654 else if (!strcmp (p
, "-fshort-enums"))
655 flag_short_enums
= 1;
656 else if (!strcmp (p
, "-fno-short-enums"))
657 flag_short_enums
= 0;
658 else if (!strcmp (p
, "-fcond-mismatch"))
659 flag_cond_mismatch
= 1;
660 else if (!strcmp (p
, "-fno-cond-mismatch"))
661 flag_cond_mismatch
= 0;
662 else if (!strcmp (p
, "-fshort-double"))
663 flag_short_double
= 1;
664 else if (!strcmp (p
, "-fno-short-double"))
665 flag_short_double
= 0;
666 else if (!strcmp (p
, "-fasm"))
668 else if (!strcmp (p
, "-fno-asm"))
670 else if (!strcmp (p
, "-fbuiltin"))
672 else if (!strcmp (p
, "-fno-builtin"))
674 else if (!strcmp (p
, "-ansi"))
675 flag_no_asm
= 1, flag_no_nonansi_builtin
= 1, dollars_in_ident
= 0;
676 else if (!strcmp (p
, "-Wimplicit"))
678 else if (!strcmp (p
, "-Wno-implicit"))
680 else if (!strcmp (p
, "-Wwrite-strings"))
681 warn_write_strings
= 1;
682 else if (!strcmp (p
, "-Wno-write-strings"))
683 warn_write_strings
= 0;
684 else if (!strcmp (p
, "-Wcast-qual"))
686 else if (!strcmp (p
, "-Wno-cast-qual"))
688 else if (!strcmp (p
, "-Wpointer-arith"))
689 warn_pointer_arith
= 1;
690 else if (!strcmp (p
, "-Wno-pointer-arith"))
691 warn_pointer_arith
= 0;
692 else if (!strcmp (p
, "-Wstrict-prototypes"))
693 warn_strict_prototypes
= 1;
694 else if (!strcmp (p
, "-Wno-strict-prototypes"))
695 warn_strict_prototypes
= 0;
696 else if (!strcmp (p
, "-Wmissing-prototypes"))
697 warn_missing_prototypes
= 1;
698 else if (!strcmp (p
, "-Wno-missing-prototypes"))
699 warn_missing_prototypes
= 0;
700 else if (!strcmp (p
, "-Wredundant-decls"))
701 warn_redundant_decls
= 1;
702 else if (!strcmp (p
, "-Wno-redundant-decls"))
703 warn_redundant_decls
= 0;
704 else if (!strcmp (p
, "-Wnested-externs"))
705 warn_nested_externs
= 1;
706 else if (!strcmp (p
, "-Wno-nested-externs"))
707 warn_nested_externs
= 0;
708 else if (!strcmp (p
, "-Wchar-subscripts"))
709 warn_char_subscripts
= 1;
710 else if (!strcmp (p
, "-Wno-char-subscripts"))
711 warn_char_subscripts
= 0;
712 else if (!strcmp (p
, "-Wconversion"))
714 else if (!strcmp (p
, "-Wno-conversion"))
716 else if (!strcmp (p
, "-Wparentheses"))
717 warn_parentheses
= 1;
718 else if (!strcmp (p
, "-Wno-parentheses"))
719 warn_parentheses
= 0;
720 else if (!strcmp (p
, "-Wreturn-type"))
721 warn_return_type
= 1;
722 else if (!strcmp (p
, "-Wno-return-type"))
723 warn_return_type
= 0;
724 else if (!strcmp (p
, "-Wcomment"))
725 ; /* cpp handles this one. */
726 else if (!strcmp (p
, "-Wno-comment"))
727 ; /* cpp handles this one. */
728 else if (!strcmp (p
, "-Wcomments"))
729 ; /* cpp handles this one. */
730 else if (!strcmp (p
, "-Wno-comments"))
731 ; /* cpp handles this one. */
732 else if (!strcmp (p
, "-Wtrigraphs"))
733 ; /* cpp handles this one. */
734 else if (!strcmp (p
, "-Wno-trigraphs"))
735 ; /* cpp handles this one. */
736 else if (!strcmp (p
, "-Wimport"))
737 ; /* cpp handles this one. */
738 else if (!strcmp (p
, "-Wno-import"))
739 ; /* cpp handles this one. */
740 else if (!strcmp (p
, "-Wmissing-braces"))
741 warn_missing_braces
= 1;
742 else if (!strcmp (p
, "-Wno-missing-braces"))
743 warn_missing_braces
= 0;
744 else if (!strcmp (p
, "-Wall"))
747 /* We save the value of warn_uninitialized, since if they put
748 -Wuninitialized on the command line, we need to generate a
749 warning about not using it without also specifying -O. */
750 if (warn_uninitialized
!= 1)
751 warn_uninitialized
= 2;
753 warn_return_type
= 1;
755 warn_char_subscripts
= 1;
756 warn_parentheses
= 1;
757 warn_missing_braces
= 1;
765 /* Hooks for print_node. */
768 print_lang_decl (file
, node
, indent
)
773 indent_to (file
, indent
+ 3);
774 fputs ("nesting_level ", file
);
775 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, DECL_NESTING_LEVEL (node
));
777 if (DECL_WEAK_NAME (node
))
778 fprintf (file
, "weak_name ");
779 if (CH_DECL_SIGNAL (node
))
780 fprintf (file
, "decl_signal ");
781 print_node (file
, "tasking_code",
782 (tree
)DECL_TASKING_CODE_DECL (node
), indent
+ 4);
787 print_lang_type (file
, node
, indent
)
794 indent_to (file
, indent
+ 3);
795 if (CH_IS_BUFFER_MODE (node
))
796 fprintf (file
, "buffer_mode ");
797 if (CH_IS_EVENT_MODE (node
))
798 fprintf (file
, "event_mode ");
800 if (CH_IS_EVENT_MODE (node
) || CH_IS_BUFFER_MODE (node
))
802 temp
= max_queue_size (node
);
804 print_node_brief (file
, "qsize", temp
, indent
+ 4);
809 print_lang_identifier (file
, node
, indent
)
814 print_node (file
, "local", IDENTIFIER_LOCAL_VALUE (node
), indent
+ 4);
815 print_node (file
, "outer", IDENTIFIER_OUTER_VALUE (node
), indent
+ 4);
816 print_node (file
, "implicit", IDENTIFIER_IMPLICIT_DECL (node
), indent
+ 4);
817 print_node (file
, "error locus", IDENTIFIER_ERROR_LOCUS (node
), indent
+ 4);
818 print_node (file
, "signal_dest", IDENTIFIER_SIGNAL_DEST (node
), indent
+ 4);
819 indent_to (file
, indent
+ 3);
820 if (IDENTIFIER_SIGNAL_DATA(node
))
821 fprintf (file
, "signal_data ");
824 /* initialise non-value struct */
827 init_nonvalue_struct (expr
)
830 tree type
= TREE_TYPE (expr
);
834 if (CH_IS_BUFFER_MODE (type
))
837 build_chill_modify_expr (
838 build_component_ref (expr
, get_identifier ("__buffer_data")),
842 else if (CH_IS_EVENT_MODE (type
))
845 build_chill_modify_expr (
846 build_component_ref (expr
, get_identifier ("__event_data")),
850 else if (CH_IS_ASSOCIATION_MODE (type
))
853 build_chill_modify_expr (expr
,
854 chill_convert_for_assignment (type
, association_init_value
,
858 else if (CH_IS_ACCESS_MODE (type
))
860 init_access_location (expr
, type
);
863 else if (CH_IS_TEXT_MODE (type
))
865 init_text_location (expr
, type
);
869 for (field
= TYPE_FIELDS (type
); field
!= NULL_TREE
; field
= TREE_CHAIN (field
))
871 type
= TREE_TYPE (field
);
872 if (CH_TYPE_NONVALUE_P (type
))
874 tree exp
= build_component_ref (expr
, DECL_NAME (field
));
875 if (TREE_CODE (type
) == RECORD_TYPE
)
876 res
|= init_nonvalue_struct (exp
);
877 else if (TREE_CODE (type
) == ARRAY_TYPE
)
878 res
|= init_nonvalue_array (exp
);
884 /* initialize non-value array */
885 /* do it with DO FOR unique-id IN expr; ... OD; */
887 init_nonvalue_array (expr
)
890 tree tmpvar
= get_unique_identifier ("NONVALINIT");
895 build_loop_iterator (tmpvar
, expr
, NULL_TREE
, NULL_TREE
, 0, 1, 0);
896 nonvalue_begin_loop_scope ();
897 build_loop_start (NULL_TREE
);
898 tmpvar
= lookup_name (tmpvar
);
899 type
= TREE_TYPE (tmpvar
);
900 if (CH_TYPE_NONVALUE_P (type
))
902 if (TREE_CODE (type
) == RECORD_TYPE
)
903 res
|= init_nonvalue_struct (tmpvar
);
904 else if (TREE_CODE (type
) == ARRAY_TYPE
)
905 res
|= init_nonvalue_array (tmpvar
);
908 nonvalue_end_loop_scope ();
913 /* This excessive piece of code sets DECL_NESTING_LEVEL (DECL) to LEVEL. */
916 set_nesting_level (decl
, level
)
920 static tree
*small_ints
= NULL
;
921 static int max_small_ints
= 0;
924 decl
->decl
.vindex
= NULL_TREE
;
927 if (level
>= max_small_ints
)
929 int new_max
= level
+ 20;
930 if (small_ints
== NULL
)
931 small_ints
= (tree
*)xmalloc (new_max
* sizeof(tree
));
933 small_ints
= (tree
*)xrealloc (small_ints
, new_max
* sizeof(tree
));
934 while (max_small_ints
< new_max
)
935 small_ints
[max_small_ints
++] = NULL_TREE
;
937 if (small_ints
[level
] == NULL_TREE
)
939 push_obstacks (&permanent_obstack
, &permanent_obstack
);
940 small_ints
[level
] = build_int_2 (level
, 0);
943 /* set DECL_NESTING_LEVEL */
944 decl
->decl
.vindex
= small_ints
[level
];
948 /* OPT_EXTERNAL is non-zero when the declaration is at module level.
949 * OPT_EXTERNAL == 2 means implicitly grant it.
952 do_decls (names
, type
, opt_static
, lifetime_bound
, opt_init
, opt_external
)
960 if (names
== NULL_TREE
|| TREE_CODE (names
) == TREE_LIST
)
962 for (; names
!= NULL_TREE
; names
= TREE_CHAIN (names
))
963 do_decl (TREE_VALUE (names
), type
, opt_static
, lifetime_bound
,
964 opt_init
, opt_external
);
966 else if (TREE_CODE (names
) != ERROR_MARK
)
967 do_decl (names
, type
, opt_static
, lifetime_bound
, opt_init
, opt_external
);
971 do_decl (name
, type
, is_static
, lifetime_bound
, opt_init
, opt_external
)
980 if (current_function_decl
== global_function_decl
981 && ! lifetime_bound
/*&& opt_init != NULL_TREE*/)
986 push_obstacks (&permanent_obstack
, &permanent_obstack
);
987 decl
= make_node (VAR_DECL
);
988 DECL_NAME (decl
) = name
;
989 TREE_TYPE (decl
) = type
;
990 DECL_ASSEMBLER_NAME (decl
) = name
;
992 /* Try to put things in common when possible.
993 Tasking variables must go into common. */
994 DECL_COMMON (decl
) = 1;
995 DECL_EXTERNAL (decl
) = opt_external
> 0;
996 TREE_PUBLIC (decl
) = opt_external
> 0;
997 TREE_STATIC (decl
) = is_static
;
1001 /* We have to set this here, since we build the decl w/o
1002 calling `build_decl'. */
1003 DECL_INITIAL (decl
) = opt_init
;
1012 DECL_INITIAL (decl
) = opt_init
;
1013 if (opt_external
> 1 || in_pseudo_module
)
1014 push_granted (DECL_NAME (decl
), decl
);
1016 else /* pass == 2 */
1018 tree temp
= NULL_TREE
;
1021 decl
= get_next_decl ();
1023 if (name
!= DECL_NAME (decl
))
1026 type
= TREE_TYPE (decl
);
1028 push_obstacks_nochange ();
1029 if (TYPE_READONLY_PROPERTY (type
))
1031 if (CH_TYPE_NONVALUE_P (type
))
1033 error_with_decl (decl
, "`%s' must not be declared readonly");
1034 opt_init
= NULL_TREE
; /* prevent subsequent errors */
1036 else if (opt_init
== NULL_TREE
&& !opt_external
)
1037 error("declaration of readonly variable without initialization");
1039 TREE_READONLY (decl
) = TYPE_READONLY (type
);
1041 if (!opt_init
&& chill_varying_type_p (type
))
1043 tree fixed_part_type
= TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (type
)));
1044 if (fixed_part_type
!= NULL_TREE
&& TREE_CODE (fixed_part_type
) != ERROR_MARK
)
1046 if (CH_CHARS_TYPE_P (fixed_part_type
))
1047 opt_init
= build_chill_string (0, "");
1049 opt_init
= build_nt (CONSTRUCTOR
, NULL_TREE
, NULL_TREE
);
1056 if (CH_TYPE_NONVALUE_P (type
))
1058 error_with_decl (decl
,
1059 "no initialization allowed for `%s'");
1062 else if (TREE_CODE (type
) == REFERENCE_TYPE
)
1063 { /* A loc-identity declaration */
1064 if (! CH_LOCATION_P (opt_init
))
1066 error_with_decl (decl
,
1067 "value for loc-identity `%s' is not a location");
1070 else if (! CH_READ_COMPATIBLE (TREE_TYPE (type
),
1071 TREE_TYPE (opt_init
)))
1073 error_with_decl (decl
,
1074 "location for `%s' not read-compatible");
1078 temp
= convert (type
, opt_init
);
1081 { /* Normal location declaration */
1083 sprintf (place
, "`%.60s' initializer",
1084 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1085 temp
= chill_convert_for_assignment (type
, opt_init
, place
);
1088 else if (CH_TYPE_NONVALUE_P (type
))
1093 DECL_INITIAL (decl
) = NULL_TREE
;
1095 if (temp
!= NULL_TREE
&& TREE_CODE (temp
) != ERROR_MARK
)
1097 /* The same for stack variables (assuming no nested modules). */
1098 if (lifetime_bound
|| !is_static
)
1100 if (is_static
&& ! TREE_CONSTANT (temp
))
1101 error_with_decl (decl
, "nonconstant initializer for `%s'");
1103 DECL_INITIAL (decl
) = temp
;
1107 /* Initialize the variable unless initialized statically. */
1108 if ((!is_static
|| ! lifetime_bound
) &&
1109 temp
!= NULL_TREE
&& TREE_CODE (temp
) != ERROR_MARK
)
1111 int was_used
= TREE_USED (decl
);
1112 emit_line_note (input_filename
, lineno
);
1113 expand_expr_stmt (build_chill_modify_expr (decl
, temp
));
1114 /* Don't let the initialization count as "using" the variable. */
1115 TREE_USED (decl
) = was_used
;
1116 if (current_function_decl
== global_function_decl
)
1117 build_constructor
= 1;
1119 else if (init_it
&& TREE_CODE (type
) != ERROR_MARK
)
1121 /* Initialize variables with non-value type */
1122 int was_used
= TREE_USED (decl
);
1123 int something_initialised
= 0;
1125 emit_line_note (input_filename
, lineno
);
1126 if (TREE_CODE (type
) == RECORD_TYPE
)
1127 something_initialised
= init_nonvalue_struct (decl
);
1128 else if (TREE_CODE (type
) == ARRAY_TYPE
)
1129 something_initialised
= init_nonvalue_array (decl
);
1130 if (! something_initialised
)
1132 error ("do_decl: internal error: don't know what to initialize");
1135 /* Don't let the initialization count as "using" the variable. */
1136 TREE_USED (decl
) = was_used
;
1137 if (current_function_decl
== global_function_decl
)
1138 build_constructor
= 1;
1145 * ARGTYPES is a tree_list of formal argument types. TREE_VALUE
1146 * is the type tree for each argument, while the attribute is in
1150 build_chill_function_type (return_type
, argtypes
, exceptions
, recurse_p
)
1151 tree return_type
, argtypes
, exceptions
, recurse_p
;
1155 if (exceptions
!= NULL_TREE
)
1157 /* if we have exceptions we add 2 arguments, callers filename
1158 and linenumber. These arguments will be added automatically
1159 when calling a function which may raise exceptions. */
1160 argtypes
= chainon (argtypes
,
1161 build_tree_list (NULL_TREE
, ridpointers
[(int) RID_PTR
]));
1162 argtypes
= chainon (argtypes
,
1163 build_tree_list (NULL_TREE
, ridpointers
[(int) RID_LONG
]));
1166 /* Indicate the argument list is complete. */
1167 argtypes
= chainon (argtypes
,
1168 build_tree_list (NULL_TREE
, void_type_node
));
1170 /* INOUT and OUT parameters must be a REFERENCE_TYPE since
1171 we'll be passing a temporary's address at call time. */
1172 for (arg
= argtypes
; arg
; arg
= TREE_CHAIN (arg
))
1173 if (TREE_PURPOSE (arg
) == ridpointers
[(int) RID_LOC
]
1174 || TREE_PURPOSE (arg
) == ridpointers
[(int) RID_OUT
]
1175 || TREE_PURPOSE (arg
) == ridpointers
[(int) RID_INOUT
]
1178 build_chill_reference_type (TREE_VALUE (arg
));
1180 /* Cannot use build_function_type, because if does hash-canonlicalization. */
1181 ftype
= make_node (FUNCTION_TYPE
);
1182 TREE_TYPE (ftype
) = return_type
? return_type
: void_type_node
;
1183 TYPE_ARG_TYPES (ftype
) = argtypes
;
1186 ftype
= build_exception_variant (ftype
, exceptions
);
1189 sorry ("RECURSIVE PROCs");
1195 * ARGTYPES is a tree_list of formal argument types.
1198 push_extern_function (name
, typespec
, argtypes
, exceptions
, granting
)
1199 tree name
, typespec
, argtypes
, exceptions
;
1200 int granting ATTRIBUTE_UNUSED
;/*If 0 do pushdecl(); if 1 do push_granted()*/
1204 push_obstacks_nochange ();
1205 end_temporary_allocation ();
1209 ftype
= build_chill_function_type (typespec
, argtypes
,
1210 exceptions
, NULL_TREE
);
1212 fndecl
= build_decl (FUNCTION_DECL
, name
, ftype
);
1214 DECL_EXTERNAL(fndecl
) = 1;
1215 TREE_STATIC (fndecl
) = 1;
1216 TREE_PUBLIC (fndecl
) = 1;
1220 finish_decl (fndecl
);
1227 make_function_rtl (fndecl
);
1231 fndecl
= get_next_decl ();
1232 finish_decl (fndecl
);
1237 push_granted (name
, decl
);
1247 push_extern_process (name
, argtypes
, exceptions
, granting
)
1248 tree name
, argtypes
, exceptions
;
1251 tree decl
, func
, arglist
;
1253 push_obstacks_nochange ();
1254 end_temporary_allocation ();
1258 tree proc_struct
= make_process_struct (name
, argtypes
);
1259 arglist
= (argtypes
== NULL_TREE
) ? NULL_TREE
:
1260 tree_cons (NULL_TREE
,
1261 build_chill_pointer_type (proc_struct
), NULL_TREE
);
1264 arglist
= NULL_TREE
;
1266 func
= push_extern_function (name
, NULL_TREE
, arglist
,
1267 exceptions
, granting
);
1269 /* declare the code variable */
1270 decl
= generate_tasking_code_variable (name
, &process_type
, 1);
1271 CH_DECL_PROCESS (func
) = 1;
1272 /* remember the code variable in the function decl */
1273 DECL_TASKING_CODE_DECL (func
) = (struct lang_decl
*)decl
;
1275 add_taskstuff_to_list (decl
, "_TT_Process", NULL_TREE
, func
, NULL_TREE
);
1279 push_extern_signal (signame
, sigmodelist
, optsigdest
)
1280 tree signame
, sigmodelist
, optsigdest
;
1284 push_obstacks_nochange ();
1285 end_temporary_allocation ();
1288 build_signal_struct_type (signame
, sigmodelist
, optsigdest
);
1290 /* declare the code variable outside the process */
1291 decl
= generate_tasking_code_variable (signame
, &signal_code
, 1);
1292 add_taskstuff_to_list (decl
, "_TT_Signal", NULL_TREE
, sigtype
, NULL_TREE
);
1299 while (mode
!= NULL_TREE
)
1301 switch (TREE_CODE (mode
))
1305 mode
= TREE_TYPE (mode
);
1309 printf (" %s ", IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (mode
))));
1314 tree itype
= TYPE_DOMAIN (mode
);
1315 if (CH_STRING_TYPE_P (mode
))
1317 fputs (" STRING (", stdout
);
1318 printf (HOST_WIDE_INT_PRINT_DEC
,
1319 TREE_INT_CST_LOW (TYPE_MAX_VALUE (itype
)));
1320 fputs (") OF ", stdout
);
1324 fputs (" ARRAY (", stdout
);
1325 printf (HOST_WIDE_INT_PRINT_DEC
,
1326 TREE_INT_CST_LOW (TYPE_MIN_VALUE (itype
)));
1327 fputs (":", stdout
);
1328 printf (HOST_WIDE_INT_PRINT_DEC
,
1329 TREE_INT_CST_LOW (TYPE_MAX_VALUE (itype
)));
1330 fputs (") OF ", stdout
);
1332 mode
= TREE_TYPE (mode
);
1337 tree fields
= TYPE_FIELDS (mode
);
1338 printf (" RECORD (");
1339 while (fields
!= NULL_TREE
)
1341 printf (" %s:", IDENTIFIER_POINTER (DECL_NAME (fields
)));
1342 print_mode (TREE_TYPE (fields
));
1343 if (TREE_CHAIN (fields
))
1345 fields
= TREE_CHAIN (fields
);
1358 chill_munge_params (nodes
, type
, attr
)
1359 tree nodes
, type
, attr
;
1364 /* Convert the list of identifiers to a list of types. */
1365 for (node
= nodes
; node
!= NULL_TREE
; node
= TREE_CHAIN (node
))
1367 TREE_VALUE (node
) = type
; /* this was the identifier node */
1368 TREE_PURPOSE (node
) = attr
;
1374 /* Push the declarations described by SYN_DEFS into the current scope. */
1376 push_syndecl (name
, mode
, value
)
1377 tree name
, mode
, value
;
1381 tree decl
= make_node (CONST_DECL
);
1382 DECL_NAME (decl
) = name
;
1383 DECL_ASSEMBLER_NAME (decl
) = name
;
1384 TREE_TYPE (decl
) = mode
;
1385 DECL_INITIAL (decl
) = value
;
1386 TREE_READONLY (decl
) = 1;
1388 if (in_pseudo_module
)
1389 push_granted (DECL_NAME (decl
), decl
);
1391 else /* pass == 2 */
1397 /* Push the declarations described by (MODENAME,MODE) into the current scope.
1398 MAKE_NEWMODE is 1 for NEWMODE, 0 for SYNMODE, and
1399 -1 for internal use (in which case the mode does not need to be copied). */
1402 push_modedef (modename
, mode
, make_newmode
)
1404 tree mode
; /* ignored if pass==2. */
1407 tree newdecl
, newmode
;
1411 /* FIXME: need to check here for SYNMODE fred fred; */
1412 push_obstacks (&permanent_obstack
, &permanent_obstack
);
1414 newdecl
= build_lang_decl (TYPE_DECL
, modename
, mode
);
1416 if (make_newmode
>= 0)
1418 newmode
= make_node (LANG_TYPE
);
1419 TREE_TYPE (newmode
) = mode
;
1420 TREE_TYPE (newdecl
) = newmode
;
1421 TYPE_NAME (newmode
) = newdecl
;
1422 if (make_newmode
> 0)
1423 CH_NOVELTY (newmode
) = newdecl
;
1426 save_decl (newdecl
);
1430 else /* pass == 2 */
1432 /* FIXME: need to check here for SYNMODE fred fred; */
1433 newdecl
= get_next_decl ();
1434 if (DECL_NAME (newdecl
) != modename
)
1436 if (TREE_CODE (TREE_TYPE (newdecl
)) != ERROR_MARK
)
1438 /* ASSOCIATION, ACCESS, TEXT, BUFFER, and EVENT must not be READOnly */
1439 if (TREE_READONLY (TREE_TYPE (newdecl
)) &&
1440 (CH_IS_ASSOCIATION_MODE (TREE_TYPE (newdecl
)) ||
1441 CH_IS_ACCESS_MODE (TREE_TYPE (newdecl
)) ||
1442 CH_IS_TEXT_MODE (TREE_TYPE (newdecl
)) ||
1443 CH_IS_BUFFER_MODE (TREE_TYPE (newdecl
)) ||
1444 CH_IS_EVENT_MODE (TREE_TYPE (newdecl
))))
1445 error_with_decl (newdecl
, "`%s' must not be READonly");
1446 rest_of_decl_compilation (newdecl
, NULL_PTR
,
1447 global_bindings_p (), 0);
1453 /* Return a chain of FIELD_DECLs for the names in NAMELIST. All of
1454 of type TYPE. When NAMELIST is passed in from the parser, it is
1456 LAYOUT is (NULL_TREE, integer_one_node, integer_zero_node, tree_list),
1457 meaning (default, pack, nopack, POS (...) ). */
1460 grok_chill_fixedfields (namelist
, type
, layout
)
1461 tree namelist
, type
;
1464 tree decls
= NULL_TREE
;
1466 if (layout
!= NULL_TREE
&& TREE_CHAIN (namelist
) != NULL_TREE
)
1468 if (layout
!= integer_one_node
&& layout
!= integer_zero_node
)
1471 error ("POS may not be specified for a list of field declarations");
1475 /* we build the chain of FIELD_DECLs backwards, effectively
1476 unreversing the reversed names in NAMELIST. */
1477 for (; namelist
; namelist
= TREE_CHAIN (namelist
))
1479 tree decl
= build_decl (FIELD_DECL
,
1480 TREE_VALUE (namelist
), type
);
1481 DECL_INITIAL (decl
) = layout
;
1482 TREE_CHAIN (decl
) = decls
;
1495 static int label_value_cmp
PARAMS ((struct tree_pair
*,
1496 struct tree_pair
*));
1498 /* Function to help qsort sort variant labels by value order. */
1500 label_value_cmp (x
, y
)
1501 struct tree_pair
*x
, *y
;
1503 return TREE_INT_CST_LOW (x
->value
) - TREE_INT_CST_LOW (y
->value
);
1507 make_chill_variants (tagfields
, body
, variantelse
)
1513 tree first
= NULL_TREE
;
1514 for (; body
; body
= TREE_CHAIN (body
))
1516 tree decls
= TREE_VALUE (body
);
1517 tree labellist
= TREE_PURPOSE (body
);
1519 if (labellist
!= NULL_TREE
1520 && TREE_CODE (TREE_VALUE (labellist
)) == TREE_LIST
1521 && TREE_VALUE (TREE_VALUE (labellist
)) == case_else_node
1522 && TREE_CHAIN (labellist
) == NULL_TREE
)
1525 error ("(ELSE) case label as well as ELSE variant");
1526 variantelse
= decls
;
1530 tree rtype
= start_struct (RECORD_TYPE
, NULL_TREE
);
1531 rtype
= finish_struct (rtype
, decls
);
1533 first
= chainon (first
, build_decl (FIELD_DECL
, NULL_TREE
, rtype
));
1535 TYPE_TAG_VALUES (rtype
) = labellist
;
1539 if (variantelse
!= NULL_TREE
)
1541 tree rtype
= start_struct (RECORD_TYPE
, NULL_TREE
);
1542 rtype
= finish_struct (rtype
, variantelse
);
1543 first
= chainon (first
,
1544 build_decl (FIELD_DECL
,
1545 ELSE_VARIANT_NAME
, rtype
));
1548 utype
= start_struct (UNION_TYPE
, NULL_TREE
);
1549 utype
= finish_struct (utype
, first
);
1550 TYPE_TAGFIELDS (utype
) = tagfields
;
1555 layout_chill_variants (utype
)
1558 tree first
= TYPE_FIELDS (utype
);
1559 int nlabels
, label_index
= 0;
1560 struct tree_pair
*label_value_array
;
1562 extern int errorcount
;
1564 if (TYPE_SIZE (utype
))
1567 for (decl
= first
; decl
; decl
= TREE_CHAIN (decl
))
1569 tree tagfields
= TYPE_TAGFIELDS (utype
);
1570 tree t
= TREE_TYPE (decl
);
1571 tree taglist
= TYPE_TAG_VALUES (t
);
1572 if (DECL_NAME (decl
) == ELSE_VARIANT_NAME
)
1574 if (tagfields
== NULL_TREE
)
1576 for ( ; tagfields
!= NULL_TREE
&& taglist
!= NULL_TREE
;
1577 tagfields
= TREE_CHAIN (tagfields
), taglist
= TREE_CHAIN (taglist
))
1579 tree labellist
= TREE_VALUE (taglist
);
1580 for (; labellist
; labellist
= TREE_CHAIN (labellist
))
1582 int compat_error
= 0;
1583 tree label_value
= TREE_VALUE (labellist
);
1584 if (TREE_CODE (label_value
) == RANGE_EXPR
)
1586 if (TREE_OPERAND (label_value
, 0) != NULL_TREE
)
1588 if (!CH_COMPATIBLE (TREE_OPERAND (label_value
, 0),
1589 TREE_TYPE (TREE_VALUE (tagfields
)))
1590 || !CH_COMPATIBLE (TREE_OPERAND (label_value
, 1),
1591 TREE_TYPE (TREE_VALUE (tagfields
))))
1595 else if (TREE_CODE (label_value
) == TYPE_DECL
)
1597 if (!CH_COMPATIBLE (label_value
,
1598 TREE_TYPE (TREE_VALUE (tagfields
))))
1601 else if (TREE_CODE (label_value
) == INTEGER_CST
)
1603 if (!CH_COMPATIBLE (label_value
,
1604 TREE_TYPE (TREE_VALUE (tagfields
))))
1609 if (TYPE_FIELDS (t
) == NULL_TREE
)
1610 error ("inconsistent modes between labels and tag field");
1612 error_with_decl (TYPE_FIELDS (t
),
1613 "inconsistent modes between labels and tag field");
1617 if (tagfields
!= NULL_TREE
)
1618 error ("too few tag labels");
1619 if (taglist
!= NULL_TREE
)
1620 error ("too many tag labels");
1623 /* Compute the number of labels to be checked for duplicates. */
1625 for (decl
= first
; decl
; decl
= TREE_CHAIN (decl
))
1627 tree t
= TREE_TYPE (decl
);
1628 /* Only one tag (first case_label_list) supported, for now. */
1629 tree labellist
= TYPE_TAG_VALUES (t
);
1631 labellist
= TREE_VALUE (labellist
);
1633 for (; labellist
!= NULL_TREE
; labellist
= TREE_CHAIN (labellist
))
1634 if (TREE_CODE (TREE_VALUE (labellist
)) == INTEGER_CST
)
1638 /* Check for duplicate label values. */
1639 label_value_array
= (struct tree_pair
*)alloca (nlabels
* sizeof (struct tree_pair
));
1640 for (decl
= first
; decl
; decl
= TREE_CHAIN (decl
))
1642 tree t
= TREE_TYPE (decl
);
1643 /* Only one tag (first case_label_list) supported, for now. */
1644 tree labellist
= TYPE_TAG_VALUES (t
);
1646 labellist
= TREE_VALUE (labellist
);
1648 for (; labellist
!= NULL_TREE
; labellist
= TREE_CHAIN (labellist
))
1652 tree x
= TREE_VALUE (labellist
);
1653 if (TREE_CODE (x
) == RANGE_EXPR
)
1655 if (TREE_OPERAND (x
, 0) != NULL_TREE
)
1657 if (TREE_CODE (TREE_OPERAND (x
, 0)) != INTEGER_CST
)
1658 error ("case label lower limit is not a discrete constant expression");
1659 if (TREE_CODE (TREE_OPERAND (x
, 1)) != INTEGER_CST
)
1660 error ("case label upper limit is not a discrete constant expression");
1664 else if (TREE_CODE (x
) == TYPE_DECL
)
1666 else if (TREE_CODE (x
) == ERROR_MARK
)
1668 else if (TREE_CODE (x
) != INTEGER_CST
) /* <-- FIXME: what about CONST_DECLs? */
1670 error ("case label must be a discrete constant expression");
1674 if (TREE_CODE (x
) == CONST_DECL
)
1675 x
= DECL_INITIAL (x
);
1676 if (TREE_CODE (x
) != INTEGER_CST
) abort ();
1679 if (p
.decl
== NULL_TREE
)
1680 p
.decl
= TREE_VALUE (labellist
);
1681 label_value_array
[label_index
++] = p
;
1684 if (errorcount
== 0)
1687 qsort (label_value_array
,
1688 label_index
, sizeof (struct tree_pair
),
1689 (int (*) PARAMS ((const void *, const void *))) label_value_cmp
);
1690 limit
= label_index
- 1;
1691 for (label_index
= 0; label_index
< limit
; label_index
++)
1693 if (tree_int_cst_equal (label_value_array
[label_index
].value
,
1694 label_value_array
[label_index
+1].value
))
1696 error_with_decl (label_value_array
[label_index
].decl
,
1697 "variant label declared here...");
1698 error_with_decl (label_value_array
[label_index
+1].decl
,
1699 "...is duplicated here");
1703 layout_type (utype
);
1707 /* Convert a TREE_LIST of tag field names into a list of
1708 field decls, found from FIXED_FIELDS, re-using the input list. */
1711 lookup_tag_fields (tag_field_names
, fixed_fields
)
1712 tree tag_field_names
;
1716 for (list
= tag_field_names
; list
!= NULL_TREE
; list
= TREE_CHAIN (list
))
1718 tree decl
= fixed_fields
;
1719 for ( ; decl
!= NULL_TREE
; decl
= TREE_CHAIN (decl
))
1721 if (DECL_NAME (decl
) == TREE_VALUE (list
))
1723 TREE_VALUE (list
) = decl
;
1727 if (decl
== NULL_TREE
)
1729 error ("no field (yet) for tag %s",
1730 IDENTIFIER_POINTER (TREE_VALUE (list
)));
1731 TREE_VALUE (list
) = error_mark_node
;
1734 return tag_field_names
;
1737 /* If non-NULL, TAGFIELDS is the tag fields for this variant record.
1738 BODY is a TREE_LIST of (optlabels, fixed fields).
1739 If non-null, VARIANTELSE is a fixed field for the else part of the
1743 grok_chill_variantdefs (tagfields
, body
, variantelse
)
1744 tree tagfields
, body
, variantelse
;
1748 t
= make_chill_variants (tagfields
, body
, variantelse
);
1750 t
= layout_chill_variants (t
);
1751 return build_decl (FIELD_DECL
, NULL_TREE
, t
);
1755 In pass 1, PARMS is a list of types (with attributes).
1756 In pass 2, PARMS is a chain of PARM_DECLs.
1760 start_chill_function (label
, rtype
, parms
, exceptlist
, attrs
)
1761 tree label
, rtype
, parms
, exceptlist
, attrs
;
1763 tree decl
, fndecl
, type
, result_type
, func_type
;
1764 int nested
= current_function_decl
!= 0;
1768 = build_chill_function_type (rtype
, parms
, exceptlist
, 0);
1769 fndecl
= build_decl (FUNCTION_DECL
, label
, func_type
);
1773 /* Make the init_value nonzero so pushdecl knows this is not tentative.
1774 error_mark_node is replaced below (in poplevel) with the BLOCK. */
1775 DECL_INITIAL (fndecl
) = error_mark_node
;
1777 DECL_EXTERNAL (fndecl
) = 0;
1779 /* This function exists in static storage.
1780 (This does not mean `static' in the C sense!) */
1781 TREE_STATIC (fndecl
) = 1;
1783 for (; attrs
!= NULL_TREE
; attrs
= TREE_CHAIN (attrs
))
1785 if (TREE_VALUE (attrs
) == ridpointers
[RID_GENERAL
])
1786 CH_DECL_GENERAL (fndecl
) = 1;
1787 else if (TREE_VALUE (attrs
) == ridpointers
[RID_SIMPLE
])
1788 CH_DECL_SIMPLE (fndecl
) = 1;
1789 else if (TREE_VALUE (attrs
) == ridpointers
[RID_RECURSIVE
])
1790 CH_DECL_RECURSIVE (fndecl
) = 1;
1791 else if (TREE_VALUE (attrs
) == ridpointers
[RID_INLINE
])
1792 DECL_INLINE (fndecl
) = 1;
1797 else /* pass == 2 */
1799 fndecl
= get_next_decl ();
1800 if (DECL_NAME (fndecl
) != label
)
1801 abort (); /* outta sync - got wrong decl */
1802 func_type
= TREE_TYPE (fndecl
);
1803 if (TYPE_RAISES_EXCEPTIONS (func_type
) != NULL_TREE
)
1805 /* In this case we have to add 2 parameters.
1806 See build_chill_function_type (pass == 1). */
1809 arg
= make_node (PARM_DECL
);
1810 DECL_ASSEMBLER_NAME (arg
) = DECL_NAME (arg
) = get_identifier (CALLER_FILE
);
1811 DECL_IGNORED_P (arg
) = 1;
1812 parms
= chainon (parms
, arg
);
1814 arg
= make_node (PARM_DECL
);
1815 DECL_ASSEMBLER_NAME (arg
) = DECL_NAME (arg
) = get_identifier (CALLER_LINE
);
1816 DECL_IGNORED_P (arg
) = 1;
1817 parms
= chainon (parms
, arg
);
1821 current_function_decl
= fndecl
;
1822 result_type
= TREE_TYPE (func_type
);
1823 if (CH_TYPE_NONVALUE_P (result_type
))
1824 error ("non-value mode may only returned by LOC");
1826 pushlevel (1); /* Push parameters. */
1830 DECL_ARGUMENTS (fndecl
) = parms
;
1831 for (decl
= DECL_ARGUMENTS (fndecl
), type
= TYPE_ARG_TYPES (func_type
);
1833 decl
= TREE_CHAIN (decl
), type
= TREE_CHAIN (type
))
1835 /* check here that modes with the non-value property (like
1836 BUFFER's, EVENT's, ASSOCIATION's, ACCESS's, or TEXT's) only
1837 gets passed by LOC */
1838 tree argtype
= TREE_VALUE (type
);
1839 tree argattr
= TREE_PURPOSE (type
);
1841 if (TREE_CODE (argtype
) == REFERENCE_TYPE
)
1842 argtype
= TREE_TYPE (argtype
);
1844 if (TREE_CODE (argtype
) != ERROR_MARK
&&
1845 TREE_CODE_CLASS (TREE_CODE (argtype
)) != 't')
1847 error_with_decl (decl
, "mode of `%s' is not a mode");
1848 TREE_VALUE (type
) = error_mark_node
;
1851 if (CH_TYPE_NONVALUE_P (argtype
) &&
1852 argattr
!= ridpointers
[(int) RID_LOC
])
1853 error_with_decl (decl
, "`%s' may only be passed by LOC");
1854 TREE_TYPE (decl
) = TREE_VALUE (type
);
1855 DECL_ARG_TYPE (decl
) = TREE_TYPE (decl
);
1856 DECL_CONTEXT (decl
) = fndecl
;
1857 TREE_READONLY (decl
) = TYPE_READONLY (argtype
);
1858 layout_decl (decl
, 0);
1861 pushdecllist (DECL_ARGUMENTS (fndecl
), 0);
1863 DECL_RESULT (current_function_decl
)
1864 = build_decl (RESULT_DECL
, NULL_TREE
, result_type
);
1867 /* Write a record describing this function definition to the prototypes
1868 file (if requested). */
1869 gen_aux_info_record (fndecl
, 1, 0, prototype
);
1872 if (fndecl
!= global_function_decl
|| seen_action
)
1874 /* Initialize the RTL code for the function. */
1875 init_function_start (fndecl
, input_filename
, lineno
);
1877 /* Set up parameters and prepare for return, for the function. */
1878 expand_function_start (fndecl
, 0);
1882 /* Allocate further tree nodes temporarily during compilation
1883 of this function only. */
1884 temporary_allocation ();
1886 /* If this fcn was already referenced via a block-scope `extern' decl (or
1887 an implicit decl), propagate certain information about the usage. */
1888 if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (current_function_decl
)))
1889 TREE_ADDRESSABLE (current_function_decl
) = 1;
1892 /* Z.200 requires that formal parameter names be defined in
1893 the same block as the procedure body.
1894 We could do this by keeping boths sets of DECLs in the same
1895 scope, but we would have to be careful to not merge the
1896 two chains (e.g. DECL_ARGUEMENTS musr not contains locals).
1897 Instead, we just make sure they have the same nesting_level. */
1898 current_nesting_level
--;
1899 pushlevel (1); /* Push local variables. */
1901 if (pass
== 2 && (fndecl
!= global_function_decl
|| seen_action
))
1903 /* generate label for possible 'exit' */
1904 expand_start_bindings (1);
1906 result_never_set
= 1;
1909 if (TREE_CODE (result_type
) == VOID_TYPE
)
1910 chill_result_decl
= NULL_TREE
;
1913 /* We use the same name as the keyword.
1914 This makes it easy to print and change the RESULT from gdb. */
1915 const char *result_str
=
1916 (ignore_case
|| ! special_UC
) ? "result" : "RESULT";
1917 if (pass
== 2 && TREE_CODE (result_type
) == ERROR_MARK
)
1918 TREE_TYPE (current_scope
->remembered_decls
) = result_type
;
1919 chill_result_decl
= do_decl (get_identifier (result_str
),
1920 result_type
, 0, 0, 0, 0);
1921 DECL_CONTEXT (chill_result_decl
) = fndecl
;
1927 /* For checking purpose added pname as new argument
1928 MW Wed Oct 14 14:22:10 1992 */
1930 finish_chill_function ()
1932 register tree fndecl
= current_function_decl
;
1933 tree outer_function
= decl_function_context (fndecl
);
1935 if (outer_function
== NULL_TREE
&& fndecl
!= global_function_decl
)
1936 outer_function
= global_function_decl
;
1937 nested
= current_function_decl
!= global_function_decl
;
1938 if (pass
== 2 && (fndecl
!= global_function_decl
|| seen_action
))
1939 expand_end_bindings (getdecls (), 1, 0);
1941 /* pop out of function */
1943 current_nesting_level
++;
1944 /* pop out of its parameters */
1949 /* TREE_READONLY (fndecl) = 1;
1950 This caused &foo to be of type ptr-to-const-function which
1951 then got a warning when stored in a ptr-to-function variable. */
1953 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl
)) = fndecl
;
1955 /* Must mark the RESULT_DECL as being in this function. */
1957 DECL_CONTEXT (DECL_RESULT (fndecl
)) = fndecl
;
1959 if (fndecl
!= global_function_decl
|| seen_action
)
1961 /* Generate rtl for function exit. */
1962 expand_function_end (input_filename
, lineno
, 0);
1964 /* Run the optimizers and output assembler code for this function. */
1965 rest_of_compilation (fndecl
);
1968 if (DECL_SAVED_INSNS (fndecl
) == 0 && ! nested
)
1970 /* Stop pointing to the local nodes about to be freed. */
1971 /* But DECL_INITIAL must remain nonzero so we know this
1972 was an actual function definition. */
1973 /* For a nested function, this is done in pop_chill_function_context. */
1974 DECL_INITIAL (fndecl
) = error_mark_node
;
1975 DECL_ARGUMENTS (fndecl
) = 0;
1978 current_function_decl
= outer_function
;
1983 /* Points to the head of the _DECLs read from seize files. */
1985 static tree seized_decls
;
1987 static tree processed_seize_files
= 0;
1991 chill_seize (old_prefix
, new_prefix
, postfix
)
1992 tree old_prefix
, new_prefix
, postfix
;
1996 tree decl
= build_alias_decl (old_prefix
, new_prefix
, postfix
);
1997 DECL_SEIZEFILE(decl
) = use_seizefile_name
;
2000 else /* pass == 2 */
2002 /* Do nothing - get_next_decl automatically ignores ALIAS_DECLs */
2008 * output a debug dump of a scope structure
2014 if (sp
== (struct scope
*)NULL
)
2016 fprintf (stderr
, "null scope ptr\n");
2019 fprintf (stderr
, "enclosing 0x%x ", sp
->enclosing
);
2020 fprintf (stderr
, "next 0x%x ", sp
->next
);
2021 fprintf (stderr
, "remembered_decls 0x%x ", sp
->remembered_decls
);
2022 fprintf (stderr
, "decls 0x%x\n", sp
->decls
);
2023 fprintf (stderr
, "shadowed 0x%x ", sp
->shadowed
);
2024 fprintf (stderr
, "blocks 0x%x ", sp
->blocks
);
2025 fprintf (stderr
, "this_block 0x%x ", sp
->this_block
);
2026 fprintf (stderr
, "level_chain 0x%x\n", sp
->level_chain
);
2027 fprintf (stderr
, "module_flag %c ", sp
->module_flag
? 'T' : 'F');
2028 fprintf (stderr
, "first_child_module 0x%x ", sp
->first_child_module
);
2029 fprintf (stderr
, "next_sibling_module 0x%x\n", sp
->next_sibling_module
);
2030 if (sp
->remembered_decls
!= NULL_TREE
)
2033 fprintf (stderr
, "remembered_decl chain:\n");
2034 for (temp
= sp
->remembered_decls
; temp
; temp
= TREE_CHAIN (temp
))
2044 if (current_function_decl
!= global_function_decl
)
2045 DECL_CONTEXT (decl
) = current_function_decl
;
2047 TREE_CHAIN (decl
) = current_scope
->remembered_decls
;
2048 current_scope
->remembered_decls
= decl
;
2050 fprintf (stderr
, "\n\nsave_decl 0x%x\n", decl
);
2051 debug_scope (current_scope
); /* ************* */
2053 set_nesting_level (decl
, current_nesting_level
);
2062 decl
= current_scope
->remembered_decls
;
2063 current_scope
->remembered_decls
= TREE_CHAIN (decl
);
2064 /* We ignore ALIAS_DECLs, because push_scope_decls
2065 can convert a single ALIAS_DECL representing 'SEIZE ALL'
2066 into one ALIAS_DECL for each seizeable name.
2067 This means we lose the nice one-to-one mapping
2068 between pass 1 decls and pass 2 decls.
2069 (Perhaps ALIAS_DECLs should not be on the remembered_decls list.) */
2070 } while (decl
&& TREE_CODE (decl
) == ALIAS_DECL
);
2074 /* At the end of pass 1, we reverse the chronological chain of scopes. */
2080 extern int errorcount
, sorrycount
;
2082 if (current_scope
!= &builtin_scope
)
2084 last_scope
= &builtin_scope
;
2085 builtin_scope
.remembered_decls
= nreverse (builtin_scope
.remembered_decls
);
2086 write_grant_file ();
2089 if (errorcount
|| sorrycount
)
2090 exit (FATAL_EXIT_CODE
);
2093 if (grant_only_flag
)
2094 exit (SUCCESS_EXIT_CODE
);
2098 next_module
= &first_module
;
2102 * Called during pass 2, when we're processing actions, to
2103 * generate a temporary variable. These don't need satisfying
2104 * because they're compiler-generated and always declared
2105 * before they're used.
2108 decl_temp1 (name
, type
, opt_static
, opt_init
,
2109 opt_external
, opt_public
)
2113 int opt_external
, opt_public
;
2115 int orig_pass
= pass
; /* be cautious */
2119 mydecl
= do_decl (name
, type
, opt_static
, opt_static
,
2120 opt_init
, opt_external
);
2123 TREE_PUBLIC (mydecl
) = 1;
2125 do_decl (name
, type
, opt_static
, opt_static
, opt_init
, opt_external
);
2131 /* True if we're reading a seizefile, but we haven't seen a SPEC MODULE yet.
2132 For backwards compatibility, we treat declarations in such a context
2133 as implicity granted. */
2136 set_module_name (name
)
2140 if (name
== NULL_TREE
)
2142 /* NOTE: build_prefix_clause assumes a generated
2143 module starts with a '_'. */
2145 sprintf (buf
, "_MODULE_%d", module_number
);
2146 name
= get_identifier (buf
);
2152 push_module (name
, is_spec_module
)
2156 struct module
*new_module
;
2159 new_module
= (struct module
*) permalloc (sizeof (struct module
));
2160 new_module
->prev_module
= current_module
;
2162 *next_module
= new_module
;
2166 new_module
= *next_module
;
2168 next_module
= &new_module
->next_module
;
2170 new_module
->procedure_seen
= 0;
2171 new_module
->is_spec_module
= is_spec_module
;
2172 new_module
->name
= name
;
2174 new_module
->prefix_name
2175 = get_identifier3 (IDENTIFIER_POINTER (current_module
->prefix_name
),
2176 "__", IDENTIFIER_POINTER (name
));
2178 new_module
->prefix_name
= name
;
2180 new_module
->granted_decls
= NULL_TREE
;
2181 new_module
->nesting_level
= current_nesting_level
+ 1;
2183 current_module
= new_module
;
2184 current_module_nesting_level
= new_module
->nesting_level
;
2185 in_pseudo_module
= name
? 0 : 1;
2189 current_scope
->module_flag
= 1;
2191 *current_scope
->enclosing
->tail_child_module
= current_scope
;
2192 current_scope
->enclosing
->tail_child_module
2193 = ¤t_scope
->next_sibling_module
;
2195 /* Rename the global function to have the same name as
2196 the first named non-spec module. */
2198 && IDENTIFIER_POINTER (name
)[0] != '_'
2199 && IDENTIFIER_POINTER (DECL_NAME (global_function_decl
))[0] == '_')
2201 tree fname
= get_identifier3 ("", IDENTIFIER_POINTER (name
), "_");
2202 DECL_NAME (global_function_decl
) = fname
;
2203 DECL_ASSEMBLER_NAME (global_function_decl
) = fname
;
2206 return name
; /* may have generated a name */
2208 /* Make a copy of the identifier NAME, replacing each '!' by '__'. */
2210 fix_identifier (name
)
2213 char *buf
= (char*)alloca (2 * IDENTIFIER_LENGTH (name
) + 1);
2215 register char *dptr
= buf
;
2216 register const char *sptr
= IDENTIFIER_POINTER (name
);
2217 for (; *sptr
; sptr
++)
2229 return fixed
? get_identifier (buf
) : name
;
2233 find_granted_decls ()
2237 /* Match each granted name to a granted decl. */
2239 tree alias
= current_module
->granted_decls
;
2240 tree next_alias
, decl
;
2241 /* This is an O(M*N) algorithm. FIXME! */
2242 for (; alias
; alias
= next_alias
)
2245 next_alias
= TREE_CHAIN (alias
);
2246 for (decl
= current_scope
->remembered_decls
;
2247 decl
; decl
= TREE_CHAIN (decl
))
2249 tree new_name
= (! DECL_NAME (decl
)) ? NULL_TREE
:
2250 decl_check_rename (alias
,
2255 /* A Seized declaration is not grantable. */
2256 if (TREE_CODE (decl
) == ALIAS_DECL
&& !CH_DECL_GRANTED (decl
))
2259 if (global_bindings_p ())
2260 TREE_PUBLIC (decl
) = 1;
2261 if (DECL_ASSEMBLER_NAME (decl
) == NULL_TREE
)
2262 DECL_ASSEMBLER_NAME (decl
) = fix_identifier (new_name
);
2263 if (DECL_POSTFIX_ALL (alias
))
2266 = build_alias_decl (NULL_TREE
, NULL_TREE
, new_name
);
2267 TREE_CHAIN (new_alias
) = TREE_CHAIN (alias
);
2268 TREE_CHAIN (alias
) = new_alias
;
2269 DECL_ABSTRACT_ORIGIN (new_alias
) = decl
;
2270 DECL_SOURCE_LINE (new_alias
) = 0;
2271 DECL_SEIZEFILE (new_alias
) = DECL_SEIZEFILE (alias
);
2275 DECL_ABSTRACT_ORIGIN (alias
) = decl
;
2281 error_with_decl (alias
, "nothing named `%s' to grant");
2282 DECL_ABSTRACT_ORIGIN (alias
) = error_mark_node
;
2292 struct scope
*module_scope
= current_scope
;
2298 /* Write out the grant file. */
2299 if (!current_module
->is_spec_module
)
2301 /* After reversal, TREE_CHAIN (last_old_decl) is the oldest
2302 decl of the current module. */
2303 write_spec_module (module_scope
->remembered_decls
,
2304 current_module
->granted_decls
);
2307 /* Move the granted decls into the enclosing scope. */
2308 if (current_scope
== global_scope
)
2311 for (decl
= current_module
->granted_decls
; decl
; decl
= next_decl
)
2313 tree name
= DECL_NAME (decl
);
2314 next_decl
= TREE_CHAIN (decl
);
2315 if (name
!= NULL_TREE
)
2317 tree old_decl
= IDENTIFIER_OUTER_VALUE (name
);
2318 set_nesting_level (decl
, current_nesting_level
);
2319 if (old_decl
!= NULL_TREE
)
2321 pedwarn_with_decl (decl
, "duplicate grant for `%s'");
2322 pedwarn_with_decl (old_decl
, "previous grant for `%s'");
2323 TREE_CHAIN (decl
) = TREE_CHAIN (old_decl
);
2324 TREE_CHAIN (old_decl
) = decl
;
2328 TREE_CHAIN (decl
) = outer_decls
;
2330 IDENTIFIER_OUTER_VALUE (name
) = decl
;
2336 current_scope
->granted_decls
= chainon (current_module
->granted_decls
,
2337 current_scope
->granted_decls
);
2340 chill_check_no_handlers (); /* Sanity test */
2341 current_module
= current_module
->prev_module
;
2342 current_module_nesting_level
= current_module
?
2343 current_module
->nesting_level
: 0;
2344 in_pseudo_module
= 0;
2347 /* Nonzero if we are currently in the global binding level. */
2350 global_bindings_p ()
2352 /* We return -1 here for the sake of variable_size() in ../stor-layout.c. */
2353 return (current_function_decl
== NULL_TREE
2354 || current_function_decl
== global_function_decl
) ? -1 : 0;
2357 /* Nonzero if the current level needs to have a BLOCK made. */
2362 return current_scope
->decls
!= 0;
2365 /* Make DECL visible.
2366 Save any existing definition.
2367 Check redefinitions at the same level.
2368 Suppress error messages if QUIET is true. */
2371 proclaim_decl (decl
, quiet
)
2375 tree name
= DECL_NAME (decl
);
2378 tree old_decl
= IDENTIFIER_LOCAL_VALUE (name
);
2379 if (old_decl
== NULL
) ; /* No duplication */
2380 else if (DECL_NESTING_LEVEL (old_decl
) != current_nesting_level
)
2382 /* Record for restoration when this binding level ends. */
2383 current_scope
->shadowed
2384 = tree_cons (name
, old_decl
, current_scope
->shadowed
);
2386 else if (DECL_WEAK_NAME (decl
))
2388 else if (!DECL_WEAK_NAME (old_decl
))
2390 tree base_decl
= decl
, base_old_decl
= old_decl
;
2391 while (TREE_CODE (base_decl
) == ALIAS_DECL
)
2392 base_decl
= DECL_ABSTRACT_ORIGIN (base_decl
);
2393 while (TREE_CODE (base_old_decl
) == ALIAS_DECL
)
2394 base_old_decl
= DECL_ABSTRACT_ORIGIN (base_old_decl
);
2395 /* Note that duplicate definitions are allowed for set elements
2396 of similar set modes. See Z200 (1988) 12.2.2.
2397 However, if the types are identical, we are defining the
2398 same name multiple times in the same SET, which is naughty. */
2399 if (!quiet
&& base_decl
!= base_old_decl
)
2401 if (TREE_CODE (base_decl
) != CONST_DECL
2402 || TREE_CODE (base_old_decl
) != CONST_DECL
2403 || !CH_DECL_ENUM (base_decl
)
2404 || !CH_DECL_ENUM (base_old_decl
)
2405 || TREE_TYPE (base_decl
) == TREE_TYPE (base_old_decl
)
2406 || !CH_SIMILAR (TREE_TYPE (base_decl
),
2407 TREE_TYPE(base_old_decl
)))
2409 error_with_decl (decl
, "duplicate definition `%s'");
2410 error_with_decl (old_decl
, "previous definition of `%s'");
2414 IDENTIFIER_LOCAL_VALUE (name
) = decl
;
2416 /* Should be redundant most of the time ... */
2417 set_nesting_level (decl
, current_nesting_level
);
2420 /* Return tree_cons (NULL_TREE, ELEMENT, LIST) unless ELEMENT
2421 is already in LIST, in which case return LIST. */
2424 maybe_acons (element
, list
)
2428 for (pair
= list
; pair
; pair
= TREE_CHAIN (pair
))
2429 if (element
== TREE_VALUE (pair
))
2431 return tree_cons (NULL_TREE
, element
, list
);
2440 static tree find_implied_types
PARAMS ((tree
, struct path
*, tree
));
2442 /* Look for implied types (enumeral types) implied by TYPE (a decl or type).
2444 Use old_path to guard against cycles. */
2447 find_implied_types (type
, old_path
, list
)
2449 struct path
*old_path
;
2452 struct path path
[1], *link
;
2453 if (type
== NULL_TREE
)
2455 path
[0].prev
= old_path
;
2456 path
[0].node
= type
;
2458 /* Check for a cycle. Something more clever might be appropriate. FIXME? */
2459 for (link
= old_path
; link
; link
= link
->prev
)
2460 if (link
->node
== type
)
2463 switch (TREE_CODE (type
))
2466 return maybe_acons (type
, list
);
2469 case REFERENCE_TYPE
:
2471 return find_implied_types (TREE_TYPE (type
), path
, list
);
2473 return find_implied_types (TYPE_DOMAIN (type
), path
, list
);
2479 list
= find_implied_types (TREE_TYPE (type
), path
, list
);
2480 for (t
= TYPE_ARG_TYPES (type
); t
!= NULL_TREE
; t
= TREE_CHAIN (t
))
2481 list
= find_implied_types (TREE_VALUE (t
), path
, list
);
2485 list
= find_implied_types (TYPE_DOMAIN (type
), path
, list
);
2486 return find_implied_types (TREE_TYPE (type
), path
, list
);
2490 for (fields
= TYPE_FIELDS (type
); fields
!= NULL_TREE
;
2491 fields
= TREE_CHAIN (fields
))
2492 list
= find_implied_types (TREE_TYPE (fields
), path
, list
);
2496 case IDENTIFIER_NODE
:
2497 return find_implied_types (lookup_name (type
), path
, list
);
2500 return find_implied_types (DECL_ABSTRACT_ORIGIN (type
), path
, list
);
2504 return find_implied_types (TREE_TYPE (type
), path
, list
);
2510 /* Make declarations in current scope visible.
2511 Also, expand SEIZEs, and make correspondong ALIAS_DECLs visible. */
2514 push_scope_decls (quiet
)
2515 int quiet
; /* If 1, we're pre-scanning, so suppress errors. */
2519 /* First make everything except 'SEIZE ALL' names visible, before
2520 handling 'SEIZE ALL'. (This makes it easier to check 'seizable'). */
2521 for (decl
= current_scope
->remembered_decls
; decl
; decl
= TREE_CHAIN (decl
))
2523 if (TREE_CODE (decl
) == ALIAS_DECL
)
2525 if (DECL_POSTFIX_ALL (decl
))
2527 if (DECL_ABSTRACT_ORIGIN (decl
) == NULL_TREE
)
2529 tree val
= lookup_name_for_seizing (decl
);
2530 if (val
== NULL_TREE
)
2532 error_with_file_and_line
2533 (DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
),
2534 "cannot SEIZE `%s'",
2535 IDENTIFIER_POINTER (DECL_OLD_NAME (decl
)));
2536 val
= error_mark_node
;
2538 DECL_ABSTRACT_ORIGIN (decl
) = val
;
2541 proclaim_decl (decl
, quiet
);
2544 pushdecllist (current_scope
->granted_decls
, quiet
);
2546 /* Now handle SEIZE ALLs. */
2547 for (decl
= current_scope
->remembered_decls
; decl
; )
2549 tree next_decl
= TREE_CHAIN (decl
);
2550 if (TREE_CODE (decl
) == ALIAS_DECL
2551 && DECL_ABSTRACT_ORIGIN (decl
) == NULL_TREE
2552 && DECL_POSTFIX_ALL (decl
))
2554 /* We saw a "SEIZE ALL". Replace it be a SEIZE for each
2555 declaration visible in the surrounding scope.
2556 Note that this complicates get_next_decl(). */
2558 tree last_new_alias
= decl
;
2559 DECL_ABSTRACT_ORIGIN (decl
) = error_mark_node
;
2560 if (current_scope
->enclosing
== global_scope
)
2561 candidate
= outer_decls
;
2563 candidate
= current_scope
->enclosing
->decls
;
2564 for ( ; candidate
; candidate
= TREE_CHAIN (candidate
))
2566 tree seizename
= DECL_NAME (candidate
);
2571 new_name
= decl_check_rename (decl
, seizename
);
2575 /* Check if candidate is seizable. */
2576 if (lookup_name (new_name
) != NULL_TREE
)
2579 new_alias
= build_alias_decl (NULL_TREE
,NULL_TREE
, new_name
);
2580 TREE_CHAIN (new_alias
) = TREE_CHAIN (last_new_alias
);
2581 TREE_CHAIN (last_new_alias
) = new_alias
;
2582 last_new_alias
= new_alias
;
2583 DECL_ABSTRACT_ORIGIN (new_alias
) = candidate
;
2584 DECL_SOURCE_LINE (new_alias
) = 0;
2586 proclaim_decl (new_alias
, quiet
);
2592 /* Link current_scope->remembered_decls at the head of the
2593 current_scope->decls list (just like pushdecllist, but
2594 without calling proclaim_decl, since we've already done that). */
2595 if ((decl
= current_scope
->remembered_decls
) != NULL_TREE
)
2597 while (TREE_CHAIN (decl
) != NULL_TREE
)
2598 decl
= TREE_CHAIN (decl
);
2599 TREE_CHAIN (decl
) = current_scope
->decls
;
2600 current_scope
->decls
= current_scope
->remembered_decls
;
2605 pop_scope_decls (decls_limit
, shadowed_limit
)
2606 tree decls_limit
, shadowed_limit
;
2608 /* Remove the temporary bindings we made. */
2609 tree link
= current_scope
->shadowed
;
2610 tree decl
= current_scope
->decls
;
2611 if (decl
!= decls_limit
)
2613 while (decl
!= decls_limit
)
2615 tree next
= TREE_CHAIN (decl
);
2616 if (DECL_NAME (decl
))
2618 /* If the ident. was used or addressed via a local extern decl,
2619 don't forget that fact. */
2620 if (DECL_EXTERNAL (decl
))
2622 if (TREE_USED (decl
))
2623 TREE_USED (DECL_NAME (decl
)) = 1;
2624 if (TREE_ADDRESSABLE (decl
))
2625 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl
)) = 1;
2627 IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl
)) = 0;
2629 if (next
== decls_limit
)
2631 TREE_CHAIN (decl
) = NULL_TREE
;
2636 current_scope
->decls
= decls_limit
;
2639 /* Restore all name-meanings of the outer levels
2640 that were shadowed by this level. */
2641 for ( ; link
!= shadowed_limit
; link
= TREE_CHAIN (link
))
2642 IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link
)) = TREE_VALUE (link
);
2643 current_scope
->shadowed
= shadowed_limit
;
2646 /* Return list of weak names (as ALIAS_DECLs) implied by IMPLIED_TYPES. */
2649 build_implied_names (implied_types
)
2652 tree aliases
= NULL_TREE
;
2654 for ( ; implied_types
; implied_types
= TREE_CHAIN (implied_types
))
2656 tree enum_type
= TREE_VALUE (implied_types
);
2657 tree link
= TYPE_VALUES (enum_type
);
2658 if (TREE_CODE (enum_type
) != ENUMERAL_TYPE
)
2661 for ( ; link
; link
= TREE_CHAIN (link
))
2663 /* We don't handle renaming/prefixes (Blue Book p 163) FIXME */
2664 /* Note that before enum_type is laid out, TREE_VALUE (link)
2665 is a CONST_DECL, while after it is laid out,
2666 TREE_VALUE (link) is an INTEGER_CST. Either works. */
2668 = build_alias_decl (NULL_TREE
, NULL_TREE
, TREE_PURPOSE (link
));
2669 DECL_ABSTRACT_ORIGIN (alias
) = TREE_VALUE (link
);
2670 DECL_WEAK_NAME (alias
) = 1;
2671 TREE_CHAIN (alias
) = aliases
;
2673 /* Strictlt speaking, we should have a pointer from the alias
2674 to the decl, so we can make sure that the alias is only
2675 visible when the decl is. FIXME */
2682 bind_sub_modules (do_weak
)
2686 int save_module_nesting_level
= current_module_nesting_level
;
2687 struct scope
*saved_scope
= current_scope
;
2688 struct scope
*nested_module
= current_scope
->first_child_module
;
2690 while (nested_module
!= NULL
)
2692 tree saved_shadowed
= nested_module
->shadowed
;
2693 tree saved_decls
= nested_module
->decls
;
2694 current_nesting_level
++;
2695 current_scope
= nested_module
;
2696 current_module_nesting_level
= current_nesting_level
;
2698 push_scope_decls (1);
2701 tree implied_types
= NULL_TREE
;
2702 /* Push weak names implied by decls in current_scope. */
2703 for (decl
= current_scope
->remembered_decls
;
2704 decl
; decl
= TREE_CHAIN (decl
))
2705 if (TREE_CODE (decl
) == ALIAS_DECL
)
2706 implied_types
= find_implied_types (decl
, NULL
, implied_types
);
2707 for (decl
= current_scope
->granted_decls
;
2708 decl
; decl
= TREE_CHAIN (decl
))
2709 implied_types
= find_implied_types (decl
, NULL
, implied_types
);
2710 current_scope
->weak_decls
= build_implied_names (implied_types
);
2711 pushdecllist (current_scope
->weak_decls
, 1);
2714 bind_sub_modules (do_weak
);
2715 for (decl
= current_scope
->remembered_decls
;
2716 decl
; decl
= TREE_CHAIN (decl
))
2717 satisfy_decl (decl
, 1);
2718 pop_scope_decls (saved_decls
, saved_shadowed
);
2719 current_nesting_level
--;
2720 nested_module
= nested_module
->next_sibling_module
;
2723 current_scope
= saved_scope
;
2724 current_module_nesting_level
= save_module_nesting_level
;
2727 /* Enter a new binding level.
2728 If two_pass==0, assume we are called from non-Chill-specific parts
2729 of the compiler. These parts assume a single pass.
2730 If two_pass==1, we're called from Chill parts of the compiler.
2734 pushlevel (two_pass
)
2737 register struct scope
*newlevel
;
2739 current_nesting_level
++;
2742 newlevel
= (struct scope
*)xmalloc (sizeof(struct scope
));
2743 *newlevel
= clear_scope
;
2744 newlevel
->enclosing
= current_scope
;
2745 current_scope
= newlevel
;
2749 newlevel
= (struct scope
*)permalloc (sizeof(struct scope
));
2750 *newlevel
= clear_scope
;
2751 newlevel
->tail_child_module
= &newlevel
->first_child_module
;
2752 newlevel
->enclosing
= current_scope
;
2753 current_scope
= newlevel
;
2754 last_scope
->next
= newlevel
;
2755 last_scope
= newlevel
;
2757 else /* pass == 2 */
2760 newlevel
= current_scope
= last_scope
= last_scope
->next
;
2762 push_scope_decls (0);
2763 pushdecllist (current_scope
->weak_decls
, 0);
2765 /* If this is not a module scope, scan ahead for locally nested
2766 modules. (If this is a module, that's already done.) */
2767 if (!current_scope
->module_flag
)
2769 bind_sub_modules (0);
2770 bind_sub_modules (1);
2773 for (decl
= current_scope
->remembered_decls
;
2774 decl
; decl
= TREE_CHAIN (decl
))
2775 satisfy_decl (decl
, 0);
2778 /* Add this level to the front of the chain (stack) of levels that
2781 newlevel
->level_chain
= current_scope
;
2782 current_scope
= newlevel
;
2784 newlevel
->two_pass
= two_pass
;
2787 /* Exit a binding level.
2788 Pop the level off, and restore the state of the identifier-decl mappings
2789 that were in effect when this level was entered.
2791 If KEEP is nonzero, this level had explicit declarations, so
2792 and create a "block" (a BLOCK node) for the level
2793 to record its declarations and subblocks for symbol table output.
2795 If FUNCTIONBODY is nonzero, this level is the body of a function,
2796 so create a block as if KEEP were set and also clear out all
2799 If REVERSE is nonzero, reverse the order of decls before putting
2800 them into the BLOCK. */
2803 poplevel (keep
, reverse
, functionbody
)
2809 /* The chain of decls was accumulated in reverse order.
2810 Put it into forward order, just for cleanliness. */
2815 int block_previously_created
= 0;
2817 if (current_scope
== NULL
)
2818 return error_mark_node
;
2820 subblocks
= current_scope
->blocks
;
2822 /* Get the decls in the order they were written.
2823 Usually current_scope->decls is in reverse order.
2824 But parameter decls were previously put in forward order. */
2827 current_scope
->decls
2828 = decls
= nreverse (current_scope
->decls
);
2830 decls
= current_scope
->decls
;
2834 /* Output any nested inline functions within this block
2835 if they weren't already output. */
2837 for (decl
= decls
; decl
; decl
= TREE_CHAIN (decl
))
2838 if (TREE_CODE (decl
) == FUNCTION_DECL
2839 && ! TREE_ASM_WRITTEN (decl
)
2840 && DECL_INITIAL (decl
) != 0
2841 && TREE_ADDRESSABLE (decl
))
2843 /* If this decl was copied from a file-scope decl
2844 on account of a block-scope extern decl,
2845 propagate TREE_ADDRESSABLE to the file-scope decl. */
2846 if (DECL_ABSTRACT_ORIGIN (decl
) != 0)
2847 TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl
)) = 1;
2850 push_function_context ();
2851 output_inline_function (decl
);
2852 pop_function_context ();
2856 /* Clear out the meanings of the local variables of this level. */
2857 pop_scope_decls (NULL_TREE
, NULL_TREE
);
2859 /* If there were any declarations or structure tags in that level,
2860 or if this level is a function body,
2861 create a BLOCK to record them for the life of this function. */
2864 block_previously_created
= (current_scope
->this_block
!= 0);
2865 if (block_previously_created
)
2866 block
= current_scope
->this_block
;
2867 else if (keep
|| functionbody
)
2868 block
= make_node (BLOCK
);
2872 BLOCK_VARS (block
) = decls
;
2874 /* Splice out ALIAS_DECL and LABEL_DECLs,
2875 since instantiate_decls can't handle them. */
2876 for (ptr
= &BLOCK_VARS (block
); *ptr
; )
2879 if (TREE_CODE (decl
) == ALIAS_DECL
2880 || TREE_CODE (decl
) == LABEL_DECL
)
2881 *ptr
= TREE_CHAIN (decl
);
2883 ptr
= &TREE_CHAIN(*ptr
);
2886 BLOCK_SUBBLOCKS (block
) = subblocks
;
2889 /* In each subblock, record that this is its superior. */
2891 for (link
= subblocks
; link
; link
= TREE_CHAIN (link
))
2892 BLOCK_SUPERCONTEXT (link
) = block
;
2896 /* If the level being exited is the top level of a function,
2897 check over all the labels, and clear out the current
2898 (function local) meanings of their names. */
2900 if (pass
== 2 && functionbody
)
2902 /* If this is the top level block of a function,
2903 the vars are the function's parameters.
2904 Don't leave them in the BLOCK because they are
2905 found in the FUNCTION_DECL instead. */
2907 BLOCK_VARS (block
) = 0;
2910 /* Clear out the definitions of all label names,
2911 since their scopes end here,
2912 and add them to BLOCK_VARS. */
2914 for (link
= named_labels
; link
; link
= TREE_CHAIN (link
))
2916 register tree label
= TREE_VALUE (link
);
2918 if (DECL_INITIAL (label
) == 0)
2920 error_with_decl (label
, "label `%s' used but not defined");
2921 /* Avoid crashing later. */
2922 define_label (input_filename
, lineno
,
2925 else if (warn_unused_label
&& !TREE_USED (label
))
2926 warning_with_decl (label
, "label `%s' defined but not used");
2927 IDENTIFIER_LABEL_VALUE (DECL_NAME (label
)) = 0;
2929 /* Put the labels into the "variables" of the
2930 top-level block, so debugger can see them. */
2931 TREE_CHAIN (label
) = BLOCK_VARS (block
);
2932 BLOCK_VARS (block
) = label
;
2939 current_scope
->remembered_decls
2940 = nreverse (current_scope
->remembered_decls
);
2941 current_scope
->granted_decls
= nreverse (current_scope
->granted_decls
);
2944 current_scope
= current_scope
->enclosing
;
2945 current_nesting_level
--;
2952 /* Dispose of the block that we just made inside some higher level. */
2954 DECL_INITIAL (current_function_decl
) = block
;
2957 if (!block_previously_created
)
2958 current_scope
->blocks
2959 = chainon (current_scope
->blocks
, block
);
2961 /* If we did not make a block for the level just exited,
2962 any blocks made for inner levels
2963 (since they cannot be recorded as subblocks in that level)
2964 must be carried forward so they will later become subblocks
2965 of something else. */
2967 current_scope
->blocks
2968 = chainon (current_scope
->blocks
, subblocks
);
2971 TREE_USED (block
) = 1;
2975 /* Delete the node BLOCK from the current binding level.
2976 This is used for the block inside a stmt expr ({...})
2977 so that the block can be reinserted where appropriate. */
2980 delete_block (block
)
2984 if (current_scope
->blocks
== block
)
2985 current_scope
->blocks
= TREE_CHAIN (block
);
2986 for (t
= current_scope
->blocks
; t
;)
2988 if (TREE_CHAIN (t
) == block
)
2989 TREE_CHAIN (t
) = TREE_CHAIN (block
);
2993 TREE_CHAIN (block
) = NULL
;
2994 /* Clear TREE_USED which is always set by poplevel.
2995 The flag is set again if insert_block is called. */
2996 TREE_USED (block
) = 0;
2999 /* Insert BLOCK at the end of the list of subblocks of the
3000 current binding level. This is used when a BIND_EXPR is expanded,
3001 to handle the BLOCK node inside teh BIND_EXPR. */
3004 insert_block (block
)
3007 TREE_USED (block
) = 1;
3008 current_scope
->blocks
3009 = chainon (current_scope
->blocks
, block
);
3012 /* Set the BLOCK node for the innermost scope
3013 (the one we are currently in). */
3017 register tree block
;
3019 current_scope
->this_block
= block
;
3020 current_scope
->decls
= chainon (current_scope
->decls
, BLOCK_VARS (block
));
3021 current_scope
->blocks
= chainon (current_scope
->blocks
,
3022 BLOCK_SUBBLOCKS (block
));
3025 /* Record a decl-node X as belonging to the current lexical scope.
3026 Check for errors (such as an incompatible declaration for the same
3027 name already seen in the same scope).
3029 Returns either X or an old decl for the same name.
3030 If an old decl is returned, it may have been smashed
3031 to agree with what X says. */
3037 register tree name
= DECL_NAME (x
);
3038 register struct scope
*b
= current_scope
;
3040 DECL_CONTEXT (x
) = current_function_decl
;
3041 /* A local extern declaration for a function doesn't constitute nesting.
3042 A local auto declaration does, since it's a forward decl
3043 for a nested function coming later. */
3044 if (TREE_CODE (x
) == FUNCTION_DECL
&& DECL_INITIAL (x
) == 0
3045 && DECL_EXTERNAL (x
))
3046 DECL_CONTEXT (x
) = 0;
3049 proclaim_decl (x
, 0);
3051 if (TREE_CODE (x
) == TYPE_DECL
&& DECL_SOURCE_LINE (x
) == 0
3052 && TYPE_NAME (TREE_TYPE (x
)) == 0)
3053 TYPE_NAME (TREE_TYPE (x
)) = x
;
3055 /* Put decls on list in reverse order.
3056 We will reverse them later if necessary. */
3057 TREE_CHAIN (x
) = b
->decls
;
3063 /* Make DECLS (a chain of decls) visible in the current_scope. */
3066 pushdecllist (decls
, quiet
)
3070 tree last
= NULL_TREE
, decl
;
3072 for (decl
= decls
; decl
!= NULL_TREE
;
3073 last
= decl
, decl
= TREE_CHAIN (decl
))
3075 proclaim_decl (decl
, quiet
);
3080 TREE_CHAIN (last
) = current_scope
->decls
;
3081 current_scope
->decls
= decls
;
3085 /* Like pushdecl, only it places X in GLOBAL_SCOPE, if appropriate. */
3088 pushdecl_top_level (x
)
3092 register struct scope
*b
= current_scope
;
3094 current_scope
= global_scope
;
3100 /* Define a label, specifying the location in the source file.
3101 Return the LABEL_DECL node for the label, if the definition is valid.
3102 Otherwise return 0. */
3105 define_label (filename
, line
, name
)
3106 const char *filename
;
3114 decl
= build_decl (LABEL_DECL
, name
, void_type_node
);
3116 /* A label not explicitly declared must be local to where it's ref'd. */
3117 DECL_CONTEXT (decl
) = current_function_decl
;
3119 DECL_MODE (decl
) = VOIDmode
;
3121 /* Say where one reference is to the label,
3122 for the sake of the error if it is not defined. */
3123 DECL_SOURCE_LINE (decl
) = line
;
3124 DECL_SOURCE_FILE (decl
) = filename
;
3126 /* Mark label as having been defined. */
3127 DECL_INITIAL (decl
) = error_mark_node
;
3129 DECL_ACTION_NESTING_LEVEL (decl
) = action_nesting_level
;
3135 decl
= get_next_decl ();
3136 /* Make sure every label has an rtx. */
3139 expand_label (decl
);
3144 /* Return the list of declarations of the current level.
3145 Note that this list is in reverse order unless/until
3146 you nreverse it; and when you do nreverse it, you must
3147 store the result back using `storedecls' or you will lose. */
3152 /* This is a kludge, so that dbxout_init can get the predefined types,
3153 which are in the builtin_scope, though when it is called,
3154 the current_scope is the global_scope.. */
3155 if (current_scope
== global_scope
)
3156 return builtin_scope
.decls
;
3157 return current_scope
->decls
;
3161 /* Store the list of declarations of the current level.
3162 This is done for the parameter declarations of a function being defined,
3163 after they are modified in the light of any missing parameters. */
3169 current_scope
->decls
= decls
;
3173 /* Look up NAME in the current binding level and its superiors
3174 in the namespace of variables, functions and typedefs.
3175 Return a ..._DECL node of some kind representing its definition,
3176 or return 0 if it is undefined. */
3182 register tree val
= IDENTIFIER_LOCAL_VALUE (name
);
3184 if (val
== NULL_TREE
)
3186 if (TREE_CODE_CLASS (TREE_CODE (val
)) == 'c')
3188 if (DECL_NESTING_LEVEL (val
) > BUILTIN_NESTING_LEVEL
3189 && DECL_NESTING_LEVEL (val
) < current_module_nesting_level
)
3193 while (TREE_CODE (val
) == ALIAS_DECL
)
3195 val
= DECL_ABSTRACT_ORIGIN (val
);
3196 if (TREE_CODE (val
) == ERROR_MARK
)
3199 if (TREE_CODE (val
) == BASED_DECL
)
3201 return build_chill_indirect_ref (DECL_ABSTRACT_ORIGIN (val
),
3202 TREE_TYPE (val
), 1);
3204 if (TREE_CODE (val
) == WITH_DECL
)
3205 return build_component_ref (DECL_ABSTRACT_ORIGIN (val
), DECL_NAME (val
));
3210 /* Similar to `lookup_name' but look only at current binding level. */
3213 lookup_name_current_level (name
)
3216 register tree val
= IDENTIFIER_LOCAL_VALUE (name
);
3217 if (val
&& DECL_NESTING_LEVEL (val
) == current_nesting_level
)
3224 lookup_name_for_seizing (seize_decl
)
3227 tree name
= DECL_OLD_NAME (seize_decl
);
3229 val
= IDENTIFIER_LOCAL_VALUE (name
);
3230 if (val
== NULL_TREE
|| DECL_NESTING_LEVEL (val
) == BUILTIN_NESTING_LEVEL
)
3232 val
= IDENTIFIER_OUTER_VALUE (name
);
3233 if (val
== NULL_TREE
)
3235 if (TREE_CHAIN (val
) && DECL_NAME (TREE_CHAIN (val
)) == name
)
3236 { /* More than one decl with the same name has been granted
3237 into the same global scope. Pick the one (we hope) that
3238 came from a seizefile the matches the most recent
3239 seizefile (as given by DECL_SEIZEFILE (seize_decl).) */
3240 tree d
, best
= NULL_TREE
;
3241 for (d
= val
; d
!= NULL_TREE
&& DECL_NAME (d
) == name
;
3243 if (DECL_SEIZEFILE (d
) == DECL_SEIZEFILE (seize_decl
))
3247 error_with_decl (seize_decl
,
3248 "ambiguous choice for seize `%s' -");
3249 error_with_decl (best
, " - can seize this `%s' -");
3250 error_with_decl (d
, " - or this granted decl `%s'");
3255 if (best
== NULL_TREE
)
3257 error_with_decl (seize_decl
,
3258 "ambiguous choice for seize `%s' -");
3259 error_with_decl (val
, " - can seize this `%s' -");
3260 error_with_decl (TREE_CHAIN (val
),
3261 " - or this granted decl `%s'");
3268 /* We don't need to handle this, as long as we
3269 resolve the seize targets before pushing them. */
3270 if (DECL_NESTING_LEVEL (val
) >= current_module_nesting_level
)
3272 /* VAL was declared inside current module. We need something
3273 from the scope *enclosing* the current module, so search
3274 through the shadowed declarations. */
3278 if (current_module
&& current_module
->prev_module
3279 && DECL_NESTING_LEVEL (val
)
3280 < current_module
->prev_module
->nesting_level
)
3283 /* It's declared in a scope enclosing the module enclosing
3284 the current module. Hence it's not visible. */
3287 while (TREE_CODE (val
) == ALIAS_DECL
)
3289 val
= DECL_ABSTRACT_ORIGIN (val
);
3290 if (TREE_CODE (val
) == ERROR_MARK
)
3296 /* Create the predefined scalar types of C,
3297 and some nodes representing standard constants (0, 1, (void *)0).
3298 Initialize the global binding level.
3299 Make definitions for built-in primitive functions. */
3302 init_decl_processing ()
3304 int wchar_type_size
;
3305 tree bool_ftype_int_ptr_int
;
3306 tree bool_ftype_int_ptr_int_int
;
3307 tree bool_ftype_luns_ptr_luns_long
;
3308 tree bool_ftype_luns_ptr_luns_long_ptr_int
;
3309 tree bool_ftype_ptr_int_ptr_int
;
3310 tree bool_ftype_ptr_int_ptr_int_int
;
3311 tree find_bit_ftype
;
3312 tree bool_ftype_ptr_ptr_int
;
3313 tree bool_ftype_ptr_ptr_luns
;
3314 tree bool_ftype_ptr_ptr_ptr_luns
;
3317 tree int_ftype_int_int
;
3318 tree int_ftype_int_ptr_int
;
3320 tree int_ftype_ptr_int
;
3321 tree int_ftype_ptr_int_int_ptr_int
;
3322 tree int_ftype_ptr_luns_long_ptr_int
;
3323 tree int_ftype_ptr_ptr_int
;
3324 tree int_ftype_ptr_ptr_luns
;
3325 tree long_ftype_ptr_luns
;
3328 tree ptr_ftype_ptr_int_int
;
3329 tree ptr_ftype_ptr_ptr_int
;
3330 tree ptr_ftype_ptr_ptr_int_ptr_int
;
3331 tree real_ftype_real
;
3333 tree void_ftype_cptr_cptr_int
;
3334 tree void_ftype_long_int_ptr_int_ptr_int
;
3335 tree void_ftype_ptr
;
3336 tree void_ftype_ptr_int_int_int_int
;
3337 tree void_ftype_ptr_int_ptr_int_int_int
;
3338 tree void_ftype_ptr_int_ptr_int_ptr_int
;
3339 tree void_ftype_ptr_luns_long_long_bool_ptr_int
;
3340 tree void_ftype_ptr_luns_ptr_luns_luns_luns
;
3341 tree void_ftype_ptr_ptr_ptr_int
;
3342 tree void_ftype_ptr_ptr_ptr_luns
;
3343 tree void_ftype_refptr_int_ptr_int
;
3344 tree void_ftype_void
;
3345 tree void_ftype_ptr_ptr_int
;
3346 tree void_ftype_ptr_luns_luns_cptr_luns_luns_luns
;
3347 tree ptr_ftype_luns_ptr_int
;
3348 tree double_ftype_double
;
3350 /* allow 0-255 enums to occupy only a byte */
3351 flag_short_enums
= 1;
3353 current_function_decl
= NULL
;
3355 set_alignment
= BITS_PER_UNIT
;
3357 ALL_POSTFIX
= get_identifier ("*");
3358 string_index_type_dummy
= get_identifier("%string-index%");
3360 var_length_id
= get_identifier (VAR_LENGTH
);
3361 var_data_id
= get_identifier (VAR_DATA
);
3363 build_common_tree_nodes (1);
3365 if (CHILL_INT_IS_SHORT
)
3366 long_integer_type_node
= integer_type_node
;
3368 long_integer_type_node
= make_signed_type (LONG_TYPE_SIZE
);
3370 /* `unsigned long' is the standard type for sizeof.
3371 Note that stddef.h uses `unsigned long',
3372 and this must agree, even of long and int are the same size. */
3374 set_sizetype (long_unsigned_type_node
);
3377 const char *size_type_c_name
= SIZE_TYPE
;
3378 if (strncmp (size_type_c_name
, "long long ", 10) == 0)
3379 set_sizetype (long_long_unsigned_type_node
);
3380 else if (strncmp (size_type_c_name
, "long ", 5) == 0)
3381 set_sizetype (long_unsigned_type_node
);
3383 set_sizetype (unsigned_type_node
);
3387 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int) RID_FLOAT
],
3389 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int) RID_DOUBLE
],
3392 build_common_tree_nodes_2 (flag_short_double
);
3394 pushdecl (build_decl (TYPE_DECL
,
3395 ridpointers
[(int) RID_VOID
], void_type_node
));
3396 /* We are not going to have real types in C with less than byte alignment,
3397 so we might as well not have any types that claim to have it. */
3398 TYPE_ALIGN (void_type_node
) = BITS_PER_UNIT
;
3399 TYPE_USER_ALIGN (void_type_node
) = 0;
3401 /* This is for wide string constants. */
3402 wchar_type_node
= short_unsigned_type_node
;
3403 wchar_type_size
= TYPE_PRECISION (wchar_type_node
);
3404 signed_wchar_type_node
= type_for_size (wchar_type_size
, 0);
3405 unsigned_wchar_type_node
= type_for_size (wchar_type_size
, 1);
3407 default_function_type
3408 = build_function_type (integer_type_node
, NULL_TREE
);
3410 ptr_type_node
= build_pointer_type (void_type_node
);
3412 = build_pointer_type (build_type_variant (void_type_node
, 1, 0));
3414 void_list_node
= build_tree_list (NULL_TREE
, void_type_node
);
3416 boolean_type_node
= make_node (BOOLEAN_TYPE
);
3417 TYPE_PRECISION (boolean_type_node
) = 1;
3418 fixup_unsigned_type (boolean_type_node
);
3419 boolean_false_node
= TYPE_MIN_VALUE (boolean_type_node
);
3420 boolean_true_node
= TYPE_MAX_VALUE (boolean_type_node
);
3421 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_BOOL
],
3422 boolean_type_node
));
3424 /* TRUE and FALSE have the BOOL derived class */
3425 CH_DERIVED_FLAG (boolean_true_node
) = 1;
3426 CH_DERIVED_FLAG (boolean_false_node
) = 1;
3428 signed_boolean_type_node
= make_node (BOOLEAN_TYPE
);
3429 temp
= build_int_2 (-1, -1);
3430 TREE_TYPE (temp
) = signed_boolean_type_node
;
3431 TYPE_MIN_VALUE (signed_boolean_type_node
) = temp
;
3432 temp
= build_int_2 (0, 0);
3433 TREE_TYPE (temp
) = signed_boolean_type_node
;
3434 TYPE_MAX_VALUE (signed_boolean_type_node
) = temp
;
3435 layout_type (signed_boolean_type_node
);
3438 bitstring_one_type_node
= build_bitstring_type (integer_one_node
);
3439 bit_zero_node
= build (CONSTRUCTOR
, bitstring_one_type_node
, NULL_TREE
,
3441 bit_one_node
= build (CONSTRUCTOR
, bitstring_one_type_node
, NULL_TREE
,
3442 build_tree_list (NULL_TREE
, integer_zero_node
));
3444 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_CHAR
],
3447 if (CHILL_INT_IS_SHORT
)
3449 chill_integer_type_node
= short_integer_type_node
;
3450 chill_unsigned_type_node
= short_unsigned_type_node
;
3454 chill_integer_type_node
= integer_type_node
;
3455 chill_unsigned_type_node
= unsigned_type_node
;
3458 string_one_type_node
= build_string_type (char_type_node
, integer_one_node
);
3460 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_BYTE
],
3461 signed_char_type_node
));
3462 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_UBYTE
],
3463 unsigned_char_type_node
));
3465 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_INT
],
3466 chill_integer_type_node
));
3468 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_UINT
],
3469 chill_unsigned_type_node
));
3471 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_LONG
],
3472 long_integer_type_node
));
3474 set_sizetype (long_integer_type_node
);
3477 = TREE_TYPE (IDENTIFIER_LOCAL_VALUE (get_identifier (PTRDIFF_TYPE
)));
3479 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_ULONG
],
3480 long_unsigned_type_node
));
3481 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_REAL
],
3483 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_LONG_REAL
],
3485 pushdecl (build_decl (TYPE_DECL
, ridpointers
[(int)RID_PTR
],
3488 IDENTIFIER_LOCAL_VALUE (ridpointers
[(int)RID_TRUE
]) =
3490 IDENTIFIER_LOCAL_VALUE (ridpointers
[(int)RID_FALSE
]) =
3492 IDENTIFIER_LOCAL_VALUE (ridpointers
[(int)RID_NULL
]) =
3495 /* The second operand is set to non-NULL to distinguish
3496 (ELSE) from (*). Used when writing grant files. */
3497 case_else_node
= build (RANGE_EXPR
,
3498 NULL_TREE
, NULL_TREE
, boolean_false_node
);
3500 pushdecl (temp
= build_decl (TYPE_DECL
,
3501 get_identifier ("__tmp_initializer"),
3502 build_init_struct ()));
3503 DECL_SOURCE_LINE (temp
) = 0;
3504 initializer_type
= TREE_TYPE (temp
);
3506 memcpy (tree_code_type
+ (int) LAST_AND_UNUSED_TREE_CODE
,
3507 chill_tree_code_type
,
3508 (((int) LAST_CHILL_TREE_CODE
- (int) LAST_AND_UNUSED_TREE_CODE
)
3510 memcpy (tree_code_length
+ (int) LAST_AND_UNUSED_TREE_CODE
,
3511 chill_tree_code_length
,
3512 (((int) LAST_CHILL_TREE_CODE
- (int) LAST_AND_UNUSED_TREE_CODE
)
3514 memcpy (tree_code_name
+ (int) LAST_AND_UNUSED_TREE_CODE
,
3515 chill_tree_code_name
,
3516 (((int) LAST_CHILL_TREE_CODE
- (int) LAST_AND_UNUSED_TREE_CODE
)
3517 * sizeof (char *)));
3518 boolean_code_name
= (const char **) xcalloc (sizeof (char *),
3519 (int) LAST_CHILL_TREE_CODE
);
3521 boolean_code_name
[EQ_EXPR
] = "=";
3522 boolean_code_name
[NE_EXPR
] = "/=";
3523 boolean_code_name
[LT_EXPR
] = "<";
3524 boolean_code_name
[GT_EXPR
] = ">";
3525 boolean_code_name
[LE_EXPR
] = "<=";
3526 boolean_code_name
[GE_EXPR
] = ">=";
3527 boolean_code_name
[SET_IN_EXPR
] = "in";
3528 boolean_code_name
[TRUTH_ANDIF_EXPR
] = "andif";
3529 boolean_code_name
[TRUTH_ORIF_EXPR
] = "orif";
3530 boolean_code_name
[TRUTH_AND_EXPR
] = "and";
3531 boolean_code_name
[TRUTH_OR_EXPR
] = "or";
3532 boolean_code_name
[BIT_AND_EXPR
] = "and";
3533 boolean_code_name
[BIT_IOR_EXPR
] = "or";
3534 boolean_code_name
[BIT_XOR_EXPR
] = "xor";
3536 endlink
= void_list_node
;
3538 chill_predefined_function_type
3539 = build_function_type (integer_type_node
,
3540 tree_cons (NULL_TREE
, integer_type_node
,
3543 bool_ftype_int_ptr_int
3544 = build_function_type (boolean_type_node
,
3545 tree_cons (NULL_TREE
, integer_type_node
,
3546 tree_cons (NULL_TREE
, ptr_type_node
,
3547 tree_cons (NULL_TREE
, integer_type_node
,
3549 bool_ftype_int_ptr_int
3550 = build_function_type (boolean_type_node
,
3551 tree_cons (NULL_TREE
, integer_type_node
,
3552 tree_cons (NULL_TREE
, ptr_type_node
,
3553 tree_cons (NULL_TREE
, integer_type_node
,
3554 tree_cons (NULL_TREE
, integer_type_node
,
3556 bool_ftype_int_ptr_int_int
3557 = build_function_type (boolean_type_node
,
3558 tree_cons (NULL_TREE
, integer_type_node
,
3559 tree_cons (NULL_TREE
, ptr_type_node
,
3560 tree_cons (NULL_TREE
, integer_type_node
,
3561 tree_cons (NULL_TREE
, integer_type_node
,
3563 bool_ftype_luns_ptr_luns_long
3564 = build_function_type (boolean_type_node
,
3565 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3566 tree_cons (NULL_TREE
, ptr_type_node
,
3567 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3568 tree_cons (NULL_TREE
, long_integer_type_node
,
3570 bool_ftype_luns_ptr_luns_long_ptr_int
3571 = build_function_type (boolean_type_node
,
3572 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3573 tree_cons (NULL_TREE
, ptr_type_node
,
3574 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3575 tree_cons (NULL_TREE
, long_integer_type_node
,
3576 tree_cons (NULL_TREE
, ptr_type_node
,
3577 tree_cons (NULL_TREE
, integer_type_node
,
3579 bool_ftype_ptr_ptr_int
3580 = build_function_type (boolean_type_node
,
3581 tree_cons (NULL_TREE
, ptr_type_node
,
3582 tree_cons (NULL_TREE
, ptr_type_node
,
3583 tree_cons (NULL_TREE
, integer_type_node
,
3585 bool_ftype_ptr_ptr_luns
3586 = build_function_type (boolean_type_node
,
3587 tree_cons (NULL_TREE
, ptr_type_node
,
3588 tree_cons (NULL_TREE
, ptr_type_node
,
3589 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3591 bool_ftype_ptr_ptr_ptr_luns
3592 = build_function_type (boolean_type_node
,
3593 tree_cons (NULL_TREE
, ptr_type_node
,
3594 tree_cons (NULL_TREE
, ptr_type_node
,
3595 tree_cons (NULL_TREE
, ptr_type_node
,
3596 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3598 bool_ftype_ptr_int_ptr_int
3599 = build_function_type (boolean_type_node
,
3600 tree_cons (NULL_TREE
, ptr_type_node
,
3601 tree_cons (NULL_TREE
, integer_type_node
,
3602 tree_cons (NULL_TREE
, ptr_type_node
,
3603 tree_cons (NULL_TREE
, integer_type_node
,
3605 bool_ftype_ptr_int_ptr_int_int
3606 = build_function_type (boolean_type_node
,
3607 tree_cons (NULL_TREE
, ptr_type_node
,
3608 tree_cons (NULL_TREE
, integer_type_node
,
3609 tree_cons (NULL_TREE
, ptr_type_node
,
3610 tree_cons (NULL_TREE
, integer_type_node
,
3611 tree_cons (NULL_TREE
, integer_type_node
,
3614 = build_function_type (integer_type_node
,
3615 tree_cons (NULL_TREE
, ptr_type_node
,
3616 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3617 tree_cons (NULL_TREE
, integer_type_node
,
3620 = build_function_type (integer_type_node
,
3621 tree_cons (NULL_TREE
, integer_type_node
,
3624 = build_function_type (integer_type_node
,
3625 tree_cons (NULL_TREE
, integer_type_node
,
3626 tree_cons (NULL_TREE
, integer_type_node
,
3628 int_ftype_int_ptr_int
3629 = build_function_type (integer_type_node
,
3630 tree_cons (NULL_TREE
, integer_type_node
,
3631 tree_cons (NULL_TREE
, ptr_type_node
,
3632 tree_cons (NULL_TREE
, integer_type_node
,
3635 = build_function_type (integer_type_node
,
3636 tree_cons (NULL_TREE
, ptr_type_node
,
3639 = build_function_type (integer_type_node
,
3640 tree_cons (NULL_TREE
, ptr_type_node
,
3641 tree_cons (NULL_TREE
, integer_type_node
,
3645 = build_function_type (long_integer_type_node
,
3646 tree_cons (NULL_TREE
, ptr_type_node
,
3647 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3650 int_ftype_ptr_int_int_ptr_int
3651 = build_function_type (integer_type_node
,
3652 tree_cons (NULL_TREE
, ptr_type_node
,
3653 tree_cons (NULL_TREE
, integer_type_node
,
3654 tree_cons (NULL_TREE
, integer_type_node
,
3655 tree_cons (NULL_TREE
, ptr_type_node
,
3656 tree_cons (NULL_TREE
, integer_type_node
,
3659 int_ftype_ptr_luns_long_ptr_int
3660 = build_function_type (integer_type_node
,
3661 tree_cons (NULL_TREE
, ptr_type_node
,
3662 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3663 tree_cons (NULL_TREE
, long_integer_type_node
,
3664 tree_cons (NULL_TREE
, ptr_type_node
,
3665 tree_cons (NULL_TREE
, integer_type_node
,
3668 int_ftype_ptr_ptr_int
3669 = build_function_type (integer_type_node
,
3670 tree_cons (NULL_TREE
, ptr_type_node
,
3671 tree_cons (NULL_TREE
, ptr_type_node
,
3672 tree_cons (NULL_TREE
, integer_type_node
,
3674 int_ftype_ptr_ptr_luns
3675 = build_function_type (integer_type_node
,
3676 tree_cons (NULL_TREE
, ptr_type_node
,
3677 tree_cons (NULL_TREE
, ptr_type_node
,
3678 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3680 memcpy_ftype
/* memcpy/memmove prototype */
3681 = build_function_type (ptr_type_node
,
3682 tree_cons (NULL_TREE
, ptr_type_node
,
3683 tree_cons (NULL_TREE
, const_ptr_type_node
,
3684 tree_cons (NULL_TREE
, sizetype
,
3686 memcmp_ftype
/* memcmp prototype */
3687 = build_function_type (integer_type_node
,
3688 tree_cons (NULL_TREE
, ptr_type_node
,
3689 tree_cons (NULL_TREE
, ptr_type_node
,
3690 tree_cons (NULL_TREE
, sizetype
,
3693 ptr_ftype_ptr_int_int
3694 = build_function_type (ptr_type_node
,
3695 tree_cons (NULL_TREE
, ptr_type_node
,
3696 tree_cons (NULL_TREE
, integer_type_node
,
3697 tree_cons (NULL_TREE
, integer_type_node
,
3699 ptr_ftype_ptr_ptr_int
3700 = build_function_type (ptr_type_node
,
3701 tree_cons (NULL_TREE
, ptr_type_node
,
3702 tree_cons (NULL_TREE
, ptr_type_node
,
3703 tree_cons (NULL_TREE
, integer_type_node
,
3705 ptr_ftype_ptr_ptr_int_ptr_int
3706 = build_function_type (void_type_node
,
3707 tree_cons (NULL_TREE
, ptr_type_node
,
3708 tree_cons (NULL_TREE
, ptr_type_node
,
3709 tree_cons (NULL_TREE
, integer_type_node
,
3710 tree_cons (NULL_TREE
, ptr_type_node
,
3711 tree_cons (NULL_TREE
, integer_type_node
,
3714 = build_function_type (float_type_node
,
3715 tree_cons (NULL_TREE
, float_type_node
,
3719 = build_function_type (void_type_node
,
3720 tree_cons (NULL_TREE
, ptr_type_node
, endlink
));
3722 void_ftype_cptr_cptr_int
3723 = build_function_type (void_type_node
,
3724 tree_cons (NULL_TREE
, const_ptr_type_node
,
3725 tree_cons (NULL_TREE
, const_ptr_type_node
,
3726 tree_cons (NULL_TREE
, integer_type_node
,
3729 void_ftype_refptr_int_ptr_int
3730 = build_function_type (void_type_node
,
3731 tree_cons (NULL_TREE
, build_reference_type(ptr_type_node
),
3732 tree_cons (NULL_TREE
, integer_type_node
,
3733 tree_cons (NULL_TREE
, ptr_type_node
,
3734 tree_cons (NULL_TREE
, integer_type_node
,
3737 void_ftype_ptr_ptr_ptr_int
3738 = build_function_type (void_type_node
,
3739 tree_cons (NULL_TREE
, ptr_type_node
,
3740 tree_cons (NULL_TREE
, ptr_type_node
,
3741 tree_cons (NULL_TREE
, ptr_type_node
,
3742 tree_cons (NULL_TREE
, integer_type_node
,
3744 void_ftype_ptr_ptr_ptr_luns
3745 = build_function_type (void_type_node
,
3746 tree_cons (NULL_TREE
, ptr_type_node
,
3747 tree_cons (NULL_TREE
, ptr_type_node
,
3748 tree_cons (NULL_TREE
, ptr_type_node
,
3749 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3751 void_ftype_ptr_int_int_int_int
3752 = build_function_type (void_type_node
,
3753 tree_cons (NULL_TREE
, ptr_type_node
,
3754 tree_cons (NULL_TREE
, integer_type_node
,
3755 tree_cons (NULL_TREE
, integer_type_node
,
3756 tree_cons (NULL_TREE
, integer_type_node
,
3757 tree_cons (NULL_TREE
, integer_type_node
,
3759 void_ftype_ptr_luns_long_long_bool_ptr_int
3760 = build_function_type (void_type_node
,
3761 tree_cons (NULL_TREE
, ptr_type_node
,
3762 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3763 tree_cons (NULL_TREE
, long_integer_type_node
,
3764 tree_cons (NULL_TREE
, long_integer_type_node
,
3765 tree_cons (NULL_TREE
, boolean_type_node
,
3766 tree_cons (NULL_TREE
, ptr_type_node
,
3767 tree_cons (NULL_TREE
, integer_type_node
,
3769 void_ftype_ptr_int_ptr_int_int_int
3770 = build_function_type (void_type_node
,
3771 tree_cons (NULL_TREE
, ptr_type_node
,
3772 tree_cons (NULL_TREE
, integer_type_node
,
3773 tree_cons (NULL_TREE
, ptr_type_node
,
3774 tree_cons (NULL_TREE
, integer_type_node
,
3775 tree_cons (NULL_TREE
, integer_type_node
,
3776 tree_cons (NULL_TREE
, integer_type_node
,
3778 void_ftype_ptr_luns_ptr_luns_luns_luns
3779 = build_function_type (void_type_node
,
3780 tree_cons (NULL_TREE
, ptr_type_node
,
3781 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3782 tree_cons (NULL_TREE
, ptr_type_node
,
3783 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3784 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3785 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3787 void_ftype_ptr_int_ptr_int_ptr_int
3788 = build_function_type (void_type_node
,
3789 tree_cons (NULL_TREE
, ptr_type_node
,
3790 tree_cons (NULL_TREE
, integer_type_node
,
3791 tree_cons (NULL_TREE
, ptr_type_node
,
3792 tree_cons (NULL_TREE
, integer_type_node
,
3793 tree_cons (NULL_TREE
, ptr_type_node
,
3794 tree_cons (NULL_TREE
, integer_type_node
,
3796 void_ftype_long_int_ptr_int_ptr_int
3797 = build_function_type (void_type_node
,
3798 tree_cons (NULL_TREE
, long_integer_type_node
,
3799 tree_cons (NULL_TREE
, integer_type_node
,
3800 tree_cons (NULL_TREE
, ptr_type_node
,
3801 tree_cons (NULL_TREE
, integer_type_node
,
3802 tree_cons (NULL_TREE
, ptr_type_node
,
3803 tree_cons (NULL_TREE
, integer_type_node
,
3806 = build_function_type (void_type_node
,
3807 tree_cons (NULL_TREE
, void_type_node
,
3810 void_ftype_ptr_ptr_int
3811 = build_function_type (void_type_node
,
3812 tree_cons (NULL_TREE
, ptr_type_node
,
3813 tree_cons (NULL_TREE
, ptr_type_node
,
3814 tree_cons (NULL_TREE
, integer_type_node
,
3817 void_ftype_ptr_luns_luns_cptr_luns_luns_luns
3818 = build_function_type (void_type_node
,
3819 tree_cons (NULL_TREE
, ptr_type_node
,
3820 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3821 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3822 tree_cons (NULL_TREE
, const_ptr_type_node
,
3823 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3824 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3825 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3828 ptr_ftype_luns_ptr_int
3829 = build_function_type (ptr_type_node
,
3830 tree_cons (NULL_TREE
, long_unsigned_type_node
,
3831 tree_cons (NULL_TREE
, ptr_type_node
,
3832 tree_cons (NULL_TREE
, integer_type_node
,
3836 = build_function_type (double_type_node
,
3837 tree_cons (NULL_TREE
, double_type_node
,
3840 /* These are compiler-internal function calls, not intended
3841 to be directly called by user code */
3842 builtin_function ("__allocate", ptr_ftype_luns_ptr_int
,
3843 0, NOT_BUILT_IN
, NULL_PTR
);
3844 builtin_function ("_allocate_global_memory", void_ftype_refptr_int_ptr_int
,
3845 0, NOT_BUILT_IN
, NULL_PTR
);
3846 builtin_function ("_allocate_memory", void_ftype_refptr_int_ptr_int
,
3847 0, NOT_BUILT_IN
, NULL_PTR
);
3848 builtin_function ("__andpowerset", bool_ftype_ptr_ptr_ptr_luns
,
3849 0, NOT_BUILT_IN
, NULL_PTR
);
3850 builtin_function ("__bitsetpowerset", void_ftype_ptr_int_int_int_int
,
3851 0, NOT_BUILT_IN
, NULL_PTR
);
3852 builtin_function ("__cardpowerset", long_ftype_ptr_luns
,
3853 0, NOT_BUILT_IN
, NULL_PTR
);
3854 builtin_function ("__cause_ex1", void_ftype_cptr_cptr_int
,
3855 0, NOT_BUILT_IN
, NULL_PTR
);
3856 builtin_function ("__concatstring", ptr_ftype_ptr_ptr_int_ptr_int
,
3857 0, NOT_BUILT_IN
, NULL_PTR
);
3858 builtin_function ("__continue", void_ftype_ptr_ptr_int
,
3859 0, NOT_BUILT_IN
, NULL_PTR
);
3860 builtin_function ("__diffpowerset", void_ftype_ptr_ptr_ptr_luns
,
3861 0, NOT_BUILT_IN
, NULL_PTR
);
3862 builtin_function ("__eqpowerset", bool_ftype_ptr_ptr_luns
,
3863 0, NOT_BUILT_IN
, NULL_PTR
);
3864 builtin_function ("__ffsetclrpowerset", find_bit_ftype
,
3865 0, NOT_BUILT_IN
, NULL_PTR
);
3866 builtin_function ("__flsetclrpowerset", find_bit_ftype
,
3867 0, NOT_BUILT_IN
, NULL_PTR
);
3868 builtin_function ("__flsetpowerset", int_ftype_ptr_luns_long_ptr_int
,
3869 0, NOT_BUILT_IN
, NULL_PTR
);
3870 builtin_function ("__ffsetpowerset", int_ftype_ptr_luns_long_ptr_int
,
3871 0, NOT_BUILT_IN
, NULL_PTR
);
3872 builtin_function ("__inbitstring", bool_ftype_luns_ptr_luns_long_ptr_int
,
3873 0, NOT_BUILT_IN
, NULL_PTR
);
3874 builtin_function ("__inpowerset", bool_ftype_luns_ptr_luns_long
,
3875 0, NOT_BUILT_IN
, NULL_PTR
);
3876 builtin_function ("__lepowerset", bool_ftype_ptr_ptr_luns
,
3877 0, NOT_BUILT_IN
, NULL_PTR
);
3878 builtin_function ("__ltpowerset", bool_ftype_ptr_ptr_luns
,
3879 0, NOT_BUILT_IN
, NULL_PTR
);
3880 /* Currently under experimentation. */
3881 builtin_function ("memmove", memcpy_ftype
,
3882 0, NOT_BUILT_IN
, NULL_PTR
);
3883 builtin_function ("memcmp", memcmp_ftype
,
3884 0, NOT_BUILT_IN
, NULL_PTR
);
3886 /* this comes from c-decl.c (init_decl_processing) */
3887 builtin_function ("__builtin_alloca",
3888 build_function_type (ptr_type_node
,
3889 tree_cons (NULL_TREE
,
3892 BUILT_IN_ALLOCA
, BUILT_IN_NORMAL
, "alloca");
3894 builtin_function ("memset", ptr_ftype_ptr_int_int
,
3895 0, NOT_BUILT_IN
, NULL_PTR
);
3896 builtin_function ("__notpowerset", bool_ftype_ptr_ptr_luns
,
3897 0, NOT_BUILT_IN
, NULL_PTR
);
3898 builtin_function ("__orpowerset", bool_ftype_ptr_ptr_ptr_luns
,
3899 0, NOT_BUILT_IN
, NULL_PTR
);
3900 builtin_function ("__psslice", void_ftype_ptr_int_ptr_int_int_int
,
3901 0, NOT_BUILT_IN
, NULL_PTR
);
3902 builtin_function ("__pscpy", void_ftype_ptr_luns_luns_cptr_luns_luns_luns
,
3903 0, NOT_BUILT_IN
, NULL_PTR
);
3904 builtin_function ("_return_memory", void_ftype_ptr_ptr_int
,
3905 0, NOT_BUILT_IN
, NULL_PTR
);
3906 builtin_function ("__setbitpowerset", void_ftype_ptr_luns_long_long_bool_ptr_int
,
3907 0, NOT_BUILT_IN
, NULL_PTR
);
3908 builtin_function ("__terminate", void_ftype_ptr_ptr_int
,
3909 0, NOT_BUILT_IN
, NULL_PTR
);
3910 builtin_function ("__unhandled_ex", void_ftype_cptr_cptr_int
,
3911 0, NOT_BUILT_IN
, NULL_PTR
);
3912 builtin_function ("__xorpowerset", bool_ftype_ptr_ptr_ptr_luns
,
3913 0, NOT_BUILT_IN
, NULL_PTR
);
3915 /* declare floating point functions */
3916 builtin_function ("__sin", double_ftype_double
, 0, NOT_BUILT_IN
, "sin");
3917 builtin_function ("__cos", double_ftype_double
, 0, NOT_BUILT_IN
, "cos");
3918 builtin_function ("__tan", double_ftype_double
, 0, NOT_BUILT_IN
, "tan");
3919 builtin_function ("__asin", double_ftype_double
, 0, NOT_BUILT_IN
, "asin");
3920 builtin_function ("__acos", double_ftype_double
, 0, NOT_BUILT_IN
, "acos");
3921 builtin_function ("__atan", double_ftype_double
, 0, NOT_BUILT_IN
, "atan");
3922 builtin_function ("__exp", double_ftype_double
, 0, NOT_BUILT_IN
, "exp");
3923 builtin_function ("__log", double_ftype_double
, 0, NOT_BUILT_IN
, "log");
3924 builtin_function ("__log10", double_ftype_double
, 0, NOT_BUILT_IN
, "log10");
3925 builtin_function ("__sqrt", double_ftype_double
, 0, NOT_BUILT_IN
, "sqrt");
3931 /* These are predefined value builtin routine calls, built
3932 by the compiler, but over-ridable by user procedures of
3933 the same names. Note the lack of a leading underscore. */
3934 builtin_function ((ignore_case
|| ! special_UC
) ? "abs" : "ABS",
3935 chill_predefined_function_type
,
3936 BUILT_IN_CH_ABS
, BUILT_IN_NORMAL
, NULL_PTR
);
3937 builtin_function ((ignore_case
|| ! special_UC
) ? "abstime" : "ABSTIME",
3938 chill_predefined_function_type
,
3939 BUILT_IN_ABSTIME
, BUILT_IN_NORMAL
, NULL_PTR
);
3940 builtin_function ((ignore_case
|| ! special_UC
) ? "allocate" : "ALLOCATE",
3941 chill_predefined_function_type
,
3942 BUILT_IN_ALLOCATE
, BUILT_IN_NORMAL
, NULL_PTR
);
3943 builtin_function ((ignore_case
|| ! special_UC
) ? "allocate_memory" : "ALLOCATE_MEMORY",
3944 chill_predefined_function_type
,
3945 BUILT_IN_ALLOCATE_MEMORY
, BUILT_IN_NORMAL
, NULL_PTR
);
3946 builtin_function ((ignore_case
|| ! special_UC
) ? "addr" : "ADDR",
3947 chill_predefined_function_type
,
3948 BUILT_IN_ADDR
, BUILT_IN_NORMAL
, NULL_PTR
);
3949 builtin_function ((ignore_case
|| ! special_UC
) ? "allocate_global_memory" : "ALLOCATE_GLOBAL_MEMORY",
3950 chill_predefined_function_type
,
3951 BUILT_IN_ALLOCATE_GLOBAL_MEMORY
, BUILT_IN_NORMAL
, NULL_PTR
);
3952 builtin_function ((ignore_case
|| ! special_UC
) ? "arccos" : "ARCCOS",
3953 chill_predefined_function_type
,
3954 BUILT_IN_ARCCOS
, BUILT_IN_NORMAL
, NULL_PTR
);
3955 builtin_function ((ignore_case
|| ! special_UC
) ? "arcsin" : "ARCSIN",
3956 chill_predefined_function_type
,
3957 BUILT_IN_ARCSIN
, BUILT_IN_NORMAL
, NULL_PTR
);
3958 builtin_function ((ignore_case
|| ! special_UC
) ? "arctan" : "ARCTAN",
3959 chill_predefined_function_type
,
3960 BUILT_IN_ARCTAN
, BUILT_IN_NORMAL
, NULL_PTR
);
3961 builtin_function ((ignore_case
|| ! special_UC
) ? "card" : "CARD",
3962 chill_predefined_function_type
,
3963 BUILT_IN_CARD
, BUILT_IN_NORMAL
, NULL_PTR
);
3964 builtin_function ((ignore_case
|| ! special_UC
) ? "cos" : "COS",
3965 chill_predefined_function_type
,
3966 BUILT_IN_CH_COS
, BUILT_IN_NORMAL
, NULL_PTR
);
3967 builtin_function ((ignore_case
|| ! special_UC
) ? "days" : "DAYS",
3968 chill_predefined_function_type
,
3969 BUILT_IN_DAYS
, BUILT_IN_NORMAL
, NULL_PTR
);
3970 builtin_function ((ignore_case
|| ! special_UC
) ? "descr" : "DESCR",
3971 chill_predefined_function_type
,
3972 BUILT_IN_DESCR
, BUILT_IN_NORMAL
, NULL_PTR
);
3973 builtin_function ((ignore_case
|| ! special_UC
) ? "getstack" : "GETSTACK",
3974 chill_predefined_function_type
,
3975 BUILT_IN_GETSTACK
, BUILT_IN_NORMAL
, NULL_PTR
);
3976 builtin_function ((ignore_case
|| ! special_UC
) ? "exp" : "EXP",
3977 chill_predefined_function_type
,
3978 BUILT_IN_EXP
, BUILT_IN_NORMAL
, NULL_PTR
);
3979 builtin_function ((ignore_case
|| ! special_UC
) ? "hours" : "HOURS",
3980 chill_predefined_function_type
,
3981 BUILT_IN_HOURS
, BUILT_IN_NORMAL
, NULL_PTR
);
3982 builtin_function ((ignore_case
|| ! special_UC
) ? "inttime" : "INTTIME",
3983 chill_predefined_function_type
,
3984 BUILT_IN_INTTIME
, BUILT_IN_NORMAL
, NULL_PTR
);
3985 builtin_function ((ignore_case
|| ! special_UC
) ? "length" : "LENGTH",
3986 chill_predefined_function_type
,
3987 BUILT_IN_LENGTH
, BUILT_IN_NORMAL
, NULL_PTR
);
3988 builtin_function ((ignore_case
|| ! special_UC
) ? "log" : "LOG",
3989 chill_predefined_function_type
,
3990 BUILT_IN_LOG
, BUILT_IN_NORMAL
, NULL_PTR
);
3991 builtin_function ((ignore_case
|| ! special_UC
) ? "lower" : "LOWER",
3992 chill_predefined_function_type
,
3993 BUILT_IN_LOWER
, BUILT_IN_NORMAL
, NULL_PTR
);
3994 builtin_function ((ignore_case
|| ! special_UC
) ? "ln" : "LN",
3995 chill_predefined_function_type
,
3996 BUILT_IN_LN
, BUILT_IN_NORMAL
, NULL_PTR
);
3997 /* Note: these are *not* the C integer MAX and MIN. They're
3998 for powerset arguments. */
3999 builtin_function ((ignore_case
|| ! special_UC
) ? "max" : "MAX",
4000 chill_predefined_function_type
,
4001 BUILT_IN_MAX
, BUILT_IN_NORMAL
, NULL_PTR
);
4002 builtin_function ((ignore_case
|| ! special_UC
) ? "millisecs" : "MILLISECS",
4003 chill_predefined_function_type
,
4004 BUILT_IN_MILLISECS
, BUILT_IN_NORMAL
, NULL_PTR
);
4005 builtin_function ((ignore_case
|| ! special_UC
) ? "min" : "MIN",
4006 chill_predefined_function_type
,
4007 BUILT_IN_MIN
, BUILT_IN_NORMAL
, NULL_PTR
);
4008 builtin_function ((ignore_case
|| ! special_UC
) ? "minutes" : "MINUTES",
4009 chill_predefined_function_type
,
4010 BUILT_IN_MINUTES
, BUILT_IN_NORMAL
, NULL_PTR
);
4011 builtin_function ((ignore_case
|| ! special_UC
) ? "num" : "NUM",
4012 chill_predefined_function_type
,
4013 BUILT_IN_NUM
, BUILT_IN_NORMAL
, NULL_PTR
);
4014 builtin_function ((ignore_case
|| ! special_UC
) ? "pred" : "PRED",
4015 chill_predefined_function_type
,
4016 BUILT_IN_PRED
, BUILT_IN_NORMAL
, NULL_PTR
);
4017 builtin_function ((ignore_case
|| ! special_UC
) ? "return_memory" : "RETURN_MEMORY",
4018 chill_predefined_function_type
,
4019 BUILT_IN_RETURN_MEMORY
, BUILT_IN_NORMAL
, NULL_PTR
);
4020 builtin_function ((ignore_case
|| ! special_UC
) ? "secs" : "SECS",
4021 chill_predefined_function_type
,
4022 BUILT_IN_SECS
, BUILT_IN_NORMAL
, NULL_PTR
);
4023 builtin_function ((ignore_case
|| ! special_UC
) ? "sin" : "SIN",
4024 chill_predefined_function_type
,
4025 BUILT_IN_CH_SIN
, BUILT_IN_NORMAL
, NULL_PTR
);
4026 builtin_function ((ignore_case
|| ! special_UC
) ? "size" : "SIZE",
4027 chill_predefined_function_type
,
4028 BUILT_IN_SIZE
, BUILT_IN_NORMAL
, NULL_PTR
);
4029 builtin_function ((ignore_case
|| ! special_UC
) ? "sqrt" : "SQRT",
4030 chill_predefined_function_type
,
4031 BUILT_IN_SQRT
, BUILT_IN_NORMAL
, NULL_PTR
);
4032 builtin_function ((ignore_case
|| ! special_UC
) ? "succ" : "SUCC",
4033 chill_predefined_function_type
,
4034 BUILT_IN_SUCC
, BUILT_IN_NORMAL
, NULL_PTR
);
4035 builtin_function ((ignore_case
|| ! special_UC
) ? "tan" : "TAN",
4036 chill_predefined_function_type
,
4037 BUILT_IN_TAN
, BUILT_IN_NORMAL
, NULL_PTR
);
4038 builtin_function ((ignore_case
|| ! special_UC
) ? "terminate" : "TERMINATE",
4039 chill_predefined_function_type
,
4040 BUILT_IN_TERMINATE
, BUILT_IN_NORMAL
, NULL_PTR
);
4041 builtin_function ((ignore_case
|| ! special_UC
) ? "upper" : "UPPER",
4042 chill_predefined_function_type
,
4043 BUILT_IN_UPPER
, BUILT_IN_NORMAL
, NULL_PTR
);
4045 build_chill_descr_type ();
4046 build_chill_inttime_type ();
4048 endlink
= tree_cons (NULL_TREE
, void_type_node
, NULL_TREE
);
4050 start_identifier_warnings ();
4055 /* Return a definition for a builtin function named NAME and whose data type
4056 is TYPE. TYPE should be a function type with argument types.
4057 FUNCTION_CODE tells later passes how to compile calls to this function.
4058 See tree.h for its possible values.
4060 If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
4061 the name to be called if we can't opencode the function. */
4064 builtin_function (name
, type
, function_code
, class, library_name
)
4068 enum built_in_class
class;
4069 const char *library_name
;
4071 tree decl
= build_decl (FUNCTION_DECL
, get_identifier (name
), type
);
4072 DECL_EXTERNAL (decl
) = 1;
4073 TREE_PUBLIC (decl
) = 1;
4074 /* If -traditional, permit redefining a builtin function any way you like.
4075 (Though really, if the program redefines these functions,
4076 it probably won't work right unless compiled with -fno-builtin.) */
4077 if (flag_traditional
&& name
[0] != '_')
4078 DECL_BUILT_IN_NONANSI (decl
) = 1;
4080 DECL_ASSEMBLER_NAME (decl
) = get_identifier (library_name
);
4081 make_decl_rtl (decl
, NULL_PTR
, 1);
4083 DECL_BUILT_IN_CLASS (decl
) = class;
4084 DECL_FUNCTION_CODE (decl
) = function_code
;
4089 /* Print a warning if a constant expression had overflow in folding.
4090 Invoke this function on every expression that the language
4091 requires to be a constant expression. */
4094 constant_expression_warning (value
)
4097 if ((TREE_CODE (value
) == INTEGER_CST
|| TREE_CODE (value
) == REAL_CST
4098 || TREE_CODE (value
) == COMPLEX_CST
)
4099 && TREE_CONSTANT_OVERFLOW (value
) && pedantic
)
4100 pedwarn ("overflow in constant expression");
4104 /* Finish processing of a declaration;
4105 If the length of an array type is not known before,
4106 it must be determined now, from the initial value, or it is an error. */
4112 int was_incomplete
= (DECL_SIZE (decl
) == 0);
4113 int temporary
= allocation_temporary_p ();
4115 /* Pop back to the obstack that is current for this binding level.
4116 This is because MAXINDEX, rtl, etc. to be made below
4117 must go in the permanent obstack. But don't discard the
4118 temporary data yet. */
4120 #if 0 /* pop_obstacks was near the end; this is what was here. */
4121 if (current_scope
== global_scope
&& temporary
)
4122 end_temporary_allocation ();
4125 if (TREE_CODE (decl
) == VAR_DECL
)
4127 if (DECL_SIZE (decl
) == 0
4128 && TYPE_SIZE (TREE_TYPE (decl
)) != 0)
4129 layout_decl (decl
, 0);
4131 if (DECL_SIZE (decl
) == 0 && TREE_CODE (TREE_TYPE (decl
)) != ERROR_MARK
)
4133 error_with_decl (decl
, "storage size of `%s' isn't known");
4134 TREE_TYPE (decl
) = error_mark_node
;
4137 if ((DECL_EXTERNAL (decl
) || TREE_STATIC (decl
))
4138 && DECL_SIZE (decl
) != 0)
4140 if (TREE_CODE (DECL_SIZE (decl
)) == INTEGER_CST
)
4141 constant_expression_warning (DECL_SIZE (decl
));
4145 /* Output the assembler code and/or RTL code for variables and functions,
4146 unless the type is an undefined structure or union.
4147 If not, it will get done when the type is completed. */
4149 if (TREE_CODE (decl
) == VAR_DECL
|| TREE_CODE (decl
) == FUNCTION_DECL
)
4151 /* The last argument (at_end) is set to 1 as a kludge to force
4152 assemble_variable to be called. */
4153 if (TREE_CODE (TREE_TYPE (decl
)) != ERROR_MARK
)
4154 rest_of_decl_compilation (decl
, (char*) 0, global_bindings_p (), 1);
4156 /* Compute the RTL of a decl if not yet set.
4157 (For normal user variables, satisfy_decl sets it.) */
4158 if (! TREE_STATIC (decl
) && ! DECL_EXTERNAL (decl
))
4162 /* If we used it already as memory, it must stay in memory. */
4163 TREE_ADDRESSABLE (decl
) = TREE_USED (decl
);
4164 /* If it's still incomplete now, no init will save it. */
4165 if (DECL_SIZE (decl
) == 0)
4166 DECL_INITIAL (decl
) = 0;
4172 if (TREE_CODE (decl
) == TYPE_DECL
)
4174 rest_of_decl_compilation (decl
, NULL_PTR
,
4175 global_bindings_p (), 0);
4178 /* ??? After 2.3, test (init != 0) instead of TREE_CODE. */
4179 if (!(TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INLINE (decl
))
4180 && temporary
&& TREE_PERMANENT (decl
))
4182 /* We need to remember that this array HAD an initialization,
4183 but discard the actual temporary nodes,
4184 since we can't have a permanent node keep pointing to them. */
4185 /* We make an exception for inline functions, since it's
4186 normal for a local extern redeclaration of an inline function
4187 to have a copy of the top-level decl's DECL_INLINE. */
4188 if (DECL_INITIAL (decl
) != 0)
4189 DECL_INITIAL (decl
) = error_mark_node
;
4193 /* Resume permanent allocation, if not within a function. */
4194 /* The corresponding push_obstacks_nochange is in start_decl,
4195 and in push_parm_decl and in grokfield. */
4199 /* If we have gone back from temporary to permanent allocation,
4200 actually free the temporary space that we no longer need. */
4201 if (temporary
&& !allocation_temporary_p ())
4202 permanent_allocation (0);
4204 /* At the end of a declaration, throw away any variable type sizes
4205 of types defined inside that declaration. There is no use
4206 computing them in the following function definition. */
4207 if (current_scope
== global_scope
)
4208 get_pending_sizes ();
4211 /* If DECL has a cleanup, build and return that cleanup here.
4212 This is a callback called by expand_expr. */
4215 maybe_build_cleanup (decl
)
4216 tree decl ATTRIBUTE_UNUSED
;
4218 /* There are no cleanups in C. */
4222 /* Make TYPE a complete type based on INITIAL_VALUE.
4223 Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered,
4224 2 if there was no information (in which case assume 1 if DO_DEFAULT). */
4227 complete_array_type (type
, initial_value
, do_default
)
4228 tree type ATTRIBUTE_UNUSED
, initial_value ATTRIBUTE_UNUSED
;
4229 int do_default ATTRIBUTE_UNUSED
;
4231 /* Only needed so we can link with ../c-typeck.c. */
4235 /* Make sure that the tag NAME is defined *in the current binding level*
4236 at least as a forward reference.
4237 CODE says which kind of tag NAME ought to be.
4239 We also do a push_obstacks_nochange
4240 whose matching pop is in finish_struct. */
4243 start_struct (code
, name
)
4244 enum chill_tree_code code
;
4245 tree name ATTRIBUTE_UNUSED
;
4247 /* If there is already a tag defined at this binding level
4248 (as a forward reference), just return it. */
4250 register tree ref
= 0;
4252 push_obstacks_nochange ();
4253 if (current_scope
== global_scope
)
4254 end_temporary_allocation ();
4256 /* Otherwise create a forward-reference just so the tag is in scope. */
4258 ref
= make_node (code
);
4259 /* pushtag (name, ref); */
4264 /* Function to help qsort sort FIELD_DECLs by name order. */
4267 field_decl_cmp (x
, y
)
4270 return (long)DECL_NAME (*x
) - (long)DECL_NAME (*y
);
4273 /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
4274 FIELDLIST is a chain of FIELD_DECL nodes for the fields.
4276 We also do a pop_obstacks to match the push in start_struct. */
4279 finish_struct (t
, fieldlist
)
4280 register tree t
, fieldlist
;
4284 /* Install struct as DECL_CONTEXT of each field decl. */
4285 for (x
= fieldlist
; x
; x
= TREE_CHAIN (x
))
4286 DECL_CONTEXT (x
) = t
;
4288 TYPE_FIELDS (t
) = fieldlist
;
4291 t
= layout_chill_struct_type (t
);
4293 /* The matching push is in start_struct. */
4299 /* Lay out the type T, and its element type, and so on. */
4302 layout_array_type (t
)
4305 if (TYPE_SIZE (t
) != 0)
4307 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
4308 layout_array_type (TREE_TYPE (t
));
4312 /* Begin compiling the definition of an enumeration type.
4313 NAME is its name (or null if anonymous).
4314 Returns the type object, as yet incomplete.
4315 Also records info about it so that build_enumerator
4316 may be used to declare the individual values as they are read. */
4320 tree name ATTRIBUTE_UNUSED
;
4322 register tree enumtype
;
4324 /* If this is the real definition for a previous forward reference,
4325 fill in the contents in the same object that used to be the
4326 forward reference. */
4329 /* The corresponding pop_obstacks is in finish_enum. */
4330 push_obstacks_nochange ();
4331 /* If these symbols and types are global, make them permanent. */
4332 if (current_scope
== global_scope
)
4333 end_temporary_allocation ();
4336 enumtype
= make_node (ENUMERAL_TYPE
);
4337 /* pushtag (name, enumtype); */
4341 /* Determine the precision this type needs. */
4343 get_type_precision (minnode
, maxnode
)
4344 tree minnode
, maxnode
;
4346 unsigned precision
= 0;
4348 if (TREE_INT_CST_HIGH (minnode
) >= 0
4349 ? tree_int_cst_lt (TYPE_MAX_VALUE (unsigned_type_node
), maxnode
)
4350 : (tree_int_cst_lt (minnode
, TYPE_MIN_VALUE (integer_type_node
))
4351 || tree_int_cst_lt (TYPE_MAX_VALUE (integer_type_node
), maxnode
)))
4352 precision
= TYPE_PRECISION (long_long_integer_type_node
);
4355 HOST_WIDE_INT maxvalue
= TREE_INT_CST_LOW (maxnode
);
4356 HOST_WIDE_INT minvalue
= TREE_INT_CST_LOW (minnode
);
4359 precision
= floor_log2 (maxvalue
) + 1;
4362 /* Compute number of bits to represent magnitude of a negative value.
4363 Add one to MINVALUE since range of negative numbers
4364 includes the power of two. */
4365 unsigned negprecision
= floor_log2 (-minvalue
- 1) + 1;
4366 if (negprecision
> precision
)
4367 precision
= negprecision
;
4368 precision
+= 1; /* room for sign bit */
4378 layout_enum (enumtype
)
4381 register tree pair
, tem
;
4382 tree minnode
= 0, maxnode
= 0;
4383 unsigned precision
= 0;
4385 /* Do arithmetic using double integers, but don't use fold/build. */
4386 union tree_node enum_next_node
;
4387 /* This is 1 plus the last enumerator constant value. */
4388 tree enum_next_value
= &enum_next_node
;
4390 /* Nonzero means that there was overflow computing enum_next_value. */
4391 int enum_overflow
= 0;
4393 tree values
= TYPE_VALUES (enumtype
);
4395 if (TYPE_SIZE (enumtype
) != NULL_TREE
)
4398 /* Initialize enum_next_value to zero. */
4399 TREE_TYPE (enum_next_value
) = integer_type_node
;
4400 TREE_INT_CST_LOW (enum_next_value
) = TREE_INT_CST_LOW (integer_zero_node
);
4401 TREE_INT_CST_HIGH (enum_next_value
) = TREE_INT_CST_HIGH (integer_zero_node
);
4403 /* After processing and defining all the values of an enumeration type,
4404 install their decls in the enumeration type and finish it off.
4406 TYPE_VALUES currently contains a list of (purpose: NAME, value: DECL).
4407 This gets converted to a list of (purpose: NAME, value: VALUE). */
4410 /* For each enumerator, calculate values, if defaulted.
4411 Convert to correct type (the enumtype).
4412 Also, calculate the minimum and maximum values. */
4414 for (pair
= values
; pair
; pair
= TREE_CHAIN (pair
))
4416 tree decl
= TREE_VALUE (pair
);
4417 tree value
= DECL_INITIAL (decl
);
4419 /* Remove no-op casts from the value. */
4420 if (value
!= NULL_TREE
)
4421 STRIP_TYPE_NOPS (value
);
4423 if (value
!= NULL_TREE
)
4425 if (TREE_CODE (value
) == INTEGER_CST
)
4427 constant_expression_warning (value
);
4428 if (tree_int_cst_lt (value
, integer_zero_node
))
4430 error ("enumerator value for `%s' is less than 0",
4431 IDENTIFIER_POINTER (DECL_NAME (decl
)));
4432 value
= error_mark_node
;
4437 error ("enumerator value for `%s' not integer constant",
4438 IDENTIFIER_POINTER (DECL_NAME (decl
)));
4439 value
= error_mark_node
;
4443 if (value
!= error_mark_node
)
4445 if (value
== NULL_TREE
) /* Default based on previous value. */
4447 value
= enum_next_value
;
4449 error ("overflow in enumeration values");
4451 value
= build_int_2 (TREE_INT_CST_LOW (value
),
4452 TREE_INT_CST_HIGH (value
));
4453 TREE_TYPE (value
) = enumtype
;
4454 DECL_INITIAL (decl
) = value
;
4455 CH_DERIVED_FLAG (value
) = 1;
4458 minnode
= maxnode
= value
;
4461 if (tree_int_cst_lt (maxnode
, value
))
4463 if (tree_int_cst_lt (value
, minnode
))
4467 /* Set basis for default for next value. */
4468 add_double (TREE_INT_CST_LOW (value
), TREE_INT_CST_HIGH (value
), 1, 0,
4469 &TREE_INT_CST_LOW (enum_next_value
),
4470 &TREE_INT_CST_HIGH (enum_next_value
));
4471 enum_overflow
= tree_int_cst_lt (enum_next_value
, value
);
4474 DECL_INITIAL (decl
) = value
; /* error_mark_node */
4477 /* Fix all error_mark_nodes in enum. Increment maxnode and assign value.
4478 This is necessary to make a duplicate value check in the enum */
4479 for (pair
= values
; pair
; pair
= TREE_CHAIN (pair
))
4481 tree decl
= TREE_VALUE (pair
);
4482 if (DECL_INITIAL (decl
) == error_mark_node
)
4485 add_double (TREE_INT_CST_LOW (maxnode
), TREE_INT_CST_HIGH (maxnode
), 1, 0,
4486 &TREE_INT_CST_LOW (enum_next_value
),
4487 &TREE_INT_CST_HIGH (enum_next_value
));
4488 value
= build_int_2 (TREE_INT_CST_LOW (enum_next_value
),
4489 TREE_INT_CST_HIGH (enum_next_value
));
4490 TREE_TYPE (value
) = enumtype
;
4491 CH_DERIVED_FLAG (value
) = 1;
4492 DECL_INITIAL (decl
) = value
;
4498 /* Now check if we have duplicate values within the enum */
4499 for (pair
= values
; pair
; pair
= TREE_CHAIN (pair
))
4502 tree decl1
= TREE_VALUE (pair
);
4503 tree val1
= DECL_INITIAL (decl1
);
4505 for (succ
= TREE_CHAIN (pair
); succ
; succ
= TREE_CHAIN (succ
))
4509 tree decl2
= TREE_VALUE (succ
);
4510 tree val2
= DECL_INITIAL (decl2
);
4511 if (tree_int_cst_equal (val1
, val2
))
4512 error ("enumerators `%s' and `%s' have equal values",
4513 IDENTIFIER_POINTER (DECL_NAME (decl1
)),
4514 IDENTIFIER_POINTER (DECL_NAME (decl2
)));
4519 TYPE_MIN_VALUE (enumtype
) = minnode
;
4520 TYPE_MAX_VALUE (enumtype
) = maxnode
;
4522 precision
= get_type_precision (minnode
, maxnode
);
4524 if (flag_short_enums
|| precision
> TYPE_PRECISION (integer_type_node
))
4525 /* Use the width of the narrowest normal C type which is wide enough. */
4526 TYPE_PRECISION (enumtype
) = TYPE_PRECISION (type_for_size (precision
, 1));
4528 TYPE_PRECISION (enumtype
) = TYPE_PRECISION (integer_type_node
);
4530 layout_type (enumtype
);
4533 /* An enum can have some negative values; then it is signed. */
4534 TREE_UNSIGNED (enumtype
) = ! tree_int_cst_lt (minnode
, integer_zero_node
);
4536 /* Z200/1988 page 19 says:
4537 For each pair of integer literal expression e1, e2 in the set list NUM (e1)
4538 and NUM (e2) must deliver different non-negative results */
4539 TREE_UNSIGNED (enumtype
) = 1;
4542 for (pair
= values
; pair
; pair
= TREE_CHAIN (pair
))
4544 tree decl
= TREE_VALUE (pair
);
4546 DECL_SIZE (decl
) = TYPE_SIZE (enumtype
);
4547 DECL_SIZE_UNIT (decl
) = TYPE_SIZE_UNIT (enumtype
);
4548 DECL_ALIGN (decl
) = TYPE_ALIGN (enumtype
);
4549 DECL_USER_ALIGN (decl
) = TYPE_USER_ALIGN (enumtype
);
4551 /* Set the TREE_VALUE to the name, rather than the decl,
4552 since that is what the rest of the compiler expects. */
4553 TREE_VALUE (pair
) = DECL_INITIAL (decl
);
4556 /* Fix up all variant types of this enum type. */
4557 for (tem
= TYPE_MAIN_VARIANT (enumtype
); tem
; tem
= TYPE_NEXT_VARIANT (tem
))
4559 TYPE_VALUES (tem
) = TYPE_VALUES (enumtype
);
4560 TYPE_MIN_VALUE (tem
) = TYPE_MIN_VALUE (enumtype
);
4561 TYPE_MAX_VALUE (tem
) = TYPE_MAX_VALUE (enumtype
);
4562 TYPE_SIZE (tem
) = TYPE_SIZE (enumtype
);
4563 TYPE_MODE (tem
) = TYPE_MODE (enumtype
);
4564 TYPE_PRECISION (tem
) = TYPE_PRECISION (enumtype
);
4565 TYPE_ALIGN (tem
) = TYPE_ALIGN (enumtype
);
4566 TYPE_USER_ALIGN (tem
) = TYPE_USER_ALIGN (enumtype
);
4567 TREE_UNSIGNED (tem
) = TREE_UNSIGNED (enumtype
);
4571 /* This matches a push in start_enum. */
4577 finish_enum (enumtype
, values
)
4578 register tree enumtype
, values
;
4580 TYPE_VALUES (enumtype
) = values
= nreverse (values
);
4582 /* If satisfy_decl is called on one of the enum CONST_DECLs,
4583 this will make sure that the enumtype gets laid out then. */
4584 for ( ; values
; values
= TREE_CHAIN (values
))
4585 TREE_TYPE (TREE_VALUE (values
)) = enumtype
;
4591 /* Build and install a CONST_DECL for one value of the
4592 current enumeration type (one that was begun with start_enum).
4593 Return a tree-list containing the CONST_DECL and its value.
4594 Assignment of sequential values by default is handled here. */
4597 build_enumerator (name
, value
)
4601 int named
= name
!= NULL_TREE
;
4606 (void) get_next_decl ();
4610 if (name
== NULL_TREE
)
4612 static int unnamed_value_warned
= 0;
4613 static int next_dummy_enum_value
= 0;
4615 if (!unnamed_value_warned
)
4617 unnamed_value_warned
= 1;
4618 warning ("undefined value in SET mode is obsolete and deprecated");
4620 sprintf (buf
, "__star_%d", next_dummy_enum_value
++);
4621 name
= get_identifier (buf
);
4624 decl
= build_decl (CONST_DECL
, name
, integer_type_node
);
4625 CH_DECL_ENUM (decl
) = 1;
4626 DECL_INITIAL (decl
) = value
;
4631 push_obstacks_nochange ();
4638 return build_tree_list (name
, decl
);
4641 tree old_value
= lookup_name_current_level (name
);
4643 if (old_value
!= NULL_TREE
4644 && TREE_CODE (old_value
)=!= CONST_DECL
4645 && (value
== NULL_TREE
|| operand_equal_p (value
, old_value
, 1)))
4647 if (value
== NULL_TREE
)
4649 if (TREE_CODE (old_value
) == CONST_DECL
)
4650 value
= DECL_INITIAL (old_value
);
4654 return saveable_tree_cons (old_value
, value
, NULL_TREE
);
4659 /* Record that this function is going to be a varargs function.
4660 This is called before store_parm_decls, which is too early
4661 to call mark_varargs directly. */
4666 c_function_varargs
= 1;
4669 /* Function needed for CHILL interface. */
4673 return current_function_parms
;
4676 /* Save and restore the variables in this file and elsewhere
4677 that keep track of the progress of compilation of the current function.
4678 Used for nested functions. */
4682 struct c_function
*next
;
4683 struct scope
*scope
;
4684 tree chill_result_decl
;
4685 int result_never_set
;
4688 struct c_function
*c_function_chain
;
4690 /* Save and reinitialize the variables
4691 used during compilation of a C function. */
4694 push_chill_function_context ()
4696 struct c_function
*p
4697 = (struct c_function
*) xmalloc (sizeof (struct c_function
));
4699 push_function_context ();
4701 p
->next
= c_function_chain
;
4702 c_function_chain
= p
;
4704 p
->scope
= current_scope
;
4705 p
->chill_result_decl
= chill_result_decl
;
4706 p
->result_never_set
= result_never_set
;
4709 /* Restore the variables used during compilation of a C function. */
4712 pop_chill_function_context ()
4714 struct c_function
*p
= c_function_chain
;
4717 /* Bring back all the labels that were shadowed. */
4718 for (link
= shadowed_labels
; link
; link
= TREE_CHAIN (link
))
4719 if (DECL_NAME (TREE_VALUE (link
)) != 0)
4720 IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link
)))
4721 = TREE_VALUE (link
);
4724 pop_function_context ();
4726 c_function_chain
= p
->next
;
4728 current_scope
= p
->scope
;
4729 chill_result_decl
= p
->chill_result_decl
;
4730 result_never_set
= p
->result_never_set
;
4735 /* Following from Jukka Virtanen's GNU Pascal */
4736 /* To implement WITH statement:
4738 1) Call shadow_record_fields for each record_type element in the WITH
4739 element list. Each call creates a new binding level.
4741 2) construct a component_ref for EACH field in the record,
4742 and store it to the IDENTIFIER_LOCAL_VALUE after adding
4743 the old value to the shadow list
4745 3) let lookup_name do the rest
4747 4) pop all of the binding levels after the WITH statement ends.
4748 (restoring old local values) You have to keep track of the number
4749 of times you called it.
4753 * Save an arbitrary tree-expression as the IDENTIFIER_LOCAL_VALUE
4754 * of a name. Save the name's previous value. Check for name
4755 * collisions with another value under the same name at the same
4756 * nesting level. This is used to implement the DO WITH construct
4757 * and the temporary for the location iteration loop.
4760 save_expr_under_name (name
, expr
)
4763 tree alias
= build_alias_decl (NULL_TREE
, NULL_TREE
, name
);
4765 DECL_ABSTRACT_ORIGIN (alias
) = expr
;
4766 TREE_CHAIN (alias
) = NULL_TREE
;
4767 pushdecllist (alias
, 0);
4771 do_based_decl (name
, mode
, base_var
)
4772 tree name
, mode
, base_var
;
4777 push_obstacks (&permanent_obstack
, &permanent_obstack
);
4778 decl
= make_node (BASED_DECL
);
4779 DECL_NAME (decl
) = name
;
4780 TREE_TYPE (decl
) = mode
;
4781 DECL_ABSTRACT_ORIGIN (decl
) = base_var
;
4788 decl
= get_next_decl ();
4789 if (name
!= DECL_NAME (decl
))
4791 /* FIXME: This isn't a complete test */
4792 base_decl
= lookup_name (base_var
);
4793 if (base_decl
== NULL_TREE
)
4794 error ("BASE variable never declared");
4795 else if (TREE_CODE (base_decl
) == FUNCTION_DECL
)
4796 error ("cannot BASE a variable on a PROC/PROCESS name");
4801 do_based_decls (names
, mode
, base_var
)
4802 tree names
, mode
, base_var
;
4804 if (names
== NULL_TREE
|| TREE_CODE (names
) == TREE_LIST
)
4806 for (; names
!= NULL_TREE
; names
= TREE_CHAIN (names
))
4807 do_based_decl (names
, mode
, base_var
);
4809 else if (TREE_CODE (names
) != ERROR_MARK
)
4810 do_based_decl (names
, mode
, base_var
);
4814 * Declare the fields so that lookup_name() will find them as
4815 * component refs for Pascal WITH or CHILL DO WITH.
4817 * Proceeds to the inner layers of Pascal/CHILL variant record
4819 * Internal routine of shadow_record_fields ()
4822 handle_one_level (parent
, fields
)
4823 tree parent
, fields
;
4827 switch (TREE_CODE (TREE_TYPE (parent
)))
4831 for (field
= fields
; field
; field
= TREE_CHAIN (field
)) {
4832 name
= DECL_NAME (field
);
4833 if (name
== NULL_TREE
|| name
== ELSE_VARIANT_NAME
)
4834 /* proceed through variant part */
4835 handle_one_level (parent
, TYPE_FIELDS (TREE_TYPE (field
)));
4838 tree field_alias
= make_node (WITH_DECL
);
4839 DECL_NAME (field_alias
) = name
;
4840 TREE_TYPE (field_alias
) = TREE_TYPE (field
);
4841 DECL_ABSTRACT_ORIGIN (field_alias
) = parent
;
4842 TREE_CHAIN (field_alias
) = NULL_TREE
;
4843 pushdecllist (field_alias
, 0);
4848 error ("INTERNAL ERROR: handle_one_level is broken");
4853 * For each FIELD_DECL node in a RECORD_TYPE, we have to declare
4854 * a name so that lookup_name will find a COMPONENT_REF node
4855 * when the name is referenced. This happens in Pascal WITH statement.
4858 shadow_record_fields (struct_val
)
4861 if (pass
== 1 || struct_val
== NULL_TREE
)
4864 handle_one_level (struct_val
, TYPE_FIELDS (TREE_TYPE (struct_val
)));
4867 static char exception_prefix
[] = "__Ex_";
4870 build_chill_exception_decl (name
)
4873 tree decl
, ex_name
, ex_init
, ex_type
;
4874 int name_len
= strlen (name
);
4875 char *ex_string
= (char *)
4876 alloca (strlen (exception_prefix
) + name_len
+ 1);
4878 sprintf(ex_string
, "%s%s", exception_prefix
, name
);
4879 ex_name
= get_identifier (ex_string
);
4880 decl
= IDENTIFIER_LOCAL_VALUE (ex_name
);
4884 /* finish_decl is too eager about switching back to the
4885 ambient context. This decl's rtl must live in the permanent_obstack. */
4886 push_obstacks (&permanent_obstack
, &permanent_obstack
);
4887 push_obstacks_nochange ();
4888 ex_type
= build_array_type (char_type_node
,
4889 build_index_2_type (integer_zero_node
,
4890 build_int_2 (name_len
, 0)));
4891 decl
= build_lang_decl (VAR_DECL
, ex_name
, ex_type
);
4892 ex_init
= build_string (name_len
, name
);
4893 TREE_TYPE (ex_init
) = ex_type
;
4894 DECL_INITIAL (decl
) = ex_init
;
4895 TREE_READONLY (decl
) = 1;
4896 TREE_STATIC (decl
) = 1;
4897 pushdecl_top_level (decl
);
4899 pop_obstacks (); /* Return to the ambient context. */
4903 extern tree module_init_list
;
4906 * This function is called from the parser to preface the entire
4907 * compilation. It contains module-level actions and reach-bound
4911 start_outer_function ()
4913 start_chill_function (pass
< 2 ? get_identifier ("_GLOBAL_")
4914 : DECL_NAME (global_function_decl
),
4915 void_type_node
, NULL_TREE
, NULL_TREE
, NULL_TREE
);
4916 global_function_decl
= current_function_decl
;
4917 global_scope
= current_scope
;
4918 chill_at_module_level
= 1;
4921 /* This function finishes the global_function_decl, and if it is non-empty
4922 * (as indiacted by seen_action), adds it to module_init_list.
4925 finish_outer_function ()
4927 /* If there was module-level code in this module (not just function
4928 declarations), we allocate space for this module's init list entry,
4929 and fill in the module's function's address. */
4931 extern tree initializer_type
;
4932 const char *fname_str
= IDENTIFIER_POINTER (DECL_NAME (current_function_decl
));
4933 char *init_entry_name
= (char *)xmalloc ((unsigned)(strlen (fname_str
) + 20));
4935 tree init_entry_decl
;
4938 finish_chill_function ();
4940 chill_at_module_level
= 0;
4946 sprintf (init_entry_name
, "__tmp_%s_init_entry", fname_str
);
4947 init_entry_id
= get_identifier (init_entry_name
);
4949 init_entry_decl
= build1 (ADDR_EXPR
,
4950 TREE_TYPE (TYPE_FIELDS (initializer_type
)),
4951 global_function_decl
);
4952 TREE_CONSTANT (init_entry_decl
) = 1;
4953 initializer
= build (CONSTRUCTOR
, initializer_type
, NULL_TREE
,
4954 tree_cons (NULL_TREE
, init_entry_decl
,
4955 build_tree_list (NULL_TREE
,
4956 null_pointer_node
)));
4957 TREE_CONSTANT (initializer
) = 1;
4959 = do_decl (init_entry_id
, initializer_type
, 1, 1, initializer
, 0);
4960 DECL_SOURCE_LINE (init_entry_decl
) = 0;
4962 /* tell chill_finish_compile that there's
4963 module-level code to be processed. */
4964 module_init_list
= integer_one_node
;
4965 else if (build_constructor
)
4966 module_init_list
= tree_cons (global_function_decl
,
4970 make_decl_rtl (global_function_decl
, NULL
, 0);