1 /* Process declarations and variables for C compiler.
2 Copyright (C) 1988, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
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 C 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 /* ??? not all decl nodes are given the most useful possible
28 line numbers. For example, the CONST_DECLs for enum values. */
50 static tree get_sentry
PROTO((tree
));
51 static void mark_vtable_entries
PROTO((tree
));
52 static void import_export_template
PROTO((tree
));
53 static void grok_function_init
PROTO((tree
, tree
));
54 static int finish_vtable_vardecl
PROTO((tree
, tree
));
55 static int prune_vtable_vardecl
PROTO((tree
, tree
));
56 static void finish_sigtable_vardecl
PROTO((tree
, tree
));
58 extern int current_class_depth
;
60 /* A list of virtual function tables we must make sure to write out. */
63 /* A list of static class variables. This is needed, because a
64 static class variable can be declared inside the class without
65 an initializer, and then initialized, staticly, outside the class. */
68 /* A list of functions which were declared inline, but which we
69 may need to emit outline anyway. */
70 static tree saved_inlines
;
72 /* Used to help generate temporary names which are unique within
73 a function. Reset to 0 by start_function. */
75 int temp_name_counter
;
77 /* Same, but not reset. Local temp variables and global temp variables
78 can have the same name. */
79 static int global_temp_name_counter
;
81 /* Flag used when debugging spew.c */
83 extern int spew_debug
;
85 /* Nonzero if we're done parsing and into end-of-file activities. */
89 /* Functions called along with real static constructors and destructors. */
91 tree static_ctors
, static_dtors
;
93 /* C (and C++) language-specific option variables. */
95 /* Nonzero means allow type mismatches in conditional expressions;
96 just make their values `void'. */
98 int flag_cond_mismatch
;
100 /* Nonzero means give `double' the same size as `float'. */
102 int flag_short_double
;
104 /* Nonzero means don't recognize the keyword `asm'. */
108 /* Nonzero means don't recognize any extension keywords. */
110 int flag_no_gnu_keywords
;
112 /* Nonzero means don't recognize the non-ANSI builtin functions. */
116 /* Nonzero means don't recognize the non-ANSI builtin functions.
119 int flag_no_nonansi_builtin
;
121 /* Nonzero means do some things the same way PCC does. Only provided so
122 the compiler will link. */
124 int flag_traditional
;
126 /* Nonzero means to treat bitfields as unsigned unless they say `signed'. */
128 int flag_signed_bitfields
= 1;
130 /* Nonzero means handle `#ident' directives. 0 means ignore them. */
134 /* Nonzero means enable obscure ANSI features and disable GNU extensions
135 that might cause ANSI-compliant code to be miscompiled. */
139 /* Nonzero means do argument matching for overloading according to the
140 ANSI rules, rather than what g++ used to believe to be correct. */
142 int flag_ansi_overloading
= 1;
144 /* Nonzero means do emit exported implementations of functions even if
145 they can be inlined. */
147 int flag_implement_inlines
= 1;
149 /* Nonzero means do emit exported implementations of templates, instead of
150 multiple static copies in each file that needs a definition. */
152 int flag_external_templates
;
154 /* Nonzero means that the decision to emit or not emit the implementation of a
155 template depends on where the template is instantiated, rather than where
158 int flag_alt_external_templates
;
160 /* Nonzero means that implicit instantiations will be emitted if needed. */
162 int flag_implicit_templates
= 1;
164 /* Nonzero means warn about implicit declarations. */
166 int warn_implicit
= 1;
168 /* Nonzero means warn when all ctors or dtors are private, and the class
171 int warn_ctor_dtor_privacy
= 1;
173 /* True if we want to implement vtables using "thunks".
174 The default is off. */
176 #ifndef DEFAULT_VTABLE_THUNKS
177 #define DEFAULT_VTABLE_THUNKS 0
179 int flag_vtable_thunks
= DEFAULT_VTABLE_THUNKS
;
181 /* True if we want to deal with repository information. */
183 int flag_use_repository
;
185 /* Nonzero means give string constants the type `const char *'
186 to get extra warnings from them. These warnings will be too numerous
187 to be useful, except in thoroughly ANSIfied programs. */
189 int warn_write_strings
;
191 /* Nonzero means warn about pointer casts that can drop a type qualifier
192 from the pointer target type. */
196 /* Nonzero means warn that dbx info for template class methods isn't fully
199 int warn_template_debugging
;
201 /* Nonzero means warn about sizeof(function) or addition/subtraction
202 of function pointers. */
204 int warn_pointer_arith
= 1;
206 /* Nonzero means warn for any function def without prototype decl. */
208 int warn_missing_prototypes
;
210 /* Nonzero means warn about multiple (redundant) decls for the same single
211 variable or function. */
213 int warn_redundant_decls
;
215 /* Warn if initializer is not completely bracketed. */
217 int warn_missing_braces
;
219 /* Warn about comparison of signed and unsigned values. */
221 int warn_sign_compare
;
223 /* Warn about *printf or *scanf format/argument anomalies. */
227 /* Warn about a subscript that has type char. */
229 int warn_char_subscripts
;
231 /* Warn if a type conversion is done that might have confusing results. */
235 /* Warn if adding () is suggested. */
237 int warn_parentheses
;
239 /* Non-zero means warn in function declared in derived class has the
240 same name as a virtual in the base class, but fails to match the
241 type signature of any virtual function in the base class. */
242 int warn_overloaded_virtual
;
244 /* Non-zero means warn when declaring a class that has a non virtual
245 destructor, when it really ought to have a virtual one. */
248 /* Non-zero means warn when a function is declared extern and later inline. */
249 int warn_extern_inline
;
251 /* Non-zero means warn when the compiler will reorder code. */
254 /* Non-zero means warn when synthesis behavior differs from Cfront's. */
257 /* Non-zero means warn when we convert a pointer to member function
258 into a pointer to (void or function). */
259 int warn_pmf2ptr
= 1;
261 /* Nonzero means warn about violation of some Effective C++ style rules. */
265 /* Nonzero means warn where overload resolution chooses a promotion from
266 unsigned to signed over a conversion to an unsigned of the same size. */
270 /* Nonzero means warn when an old-style cast is used. */
272 int warn_old_style_cast
;
274 /* Nonzero means `$' can be in an identifier. */
276 #ifndef DOLLARS_IN_IDENTIFIERS
277 #define DOLLARS_IN_IDENTIFIERS 1
279 int dollars_in_ident
= DOLLARS_IN_IDENTIFIERS
;
281 /* Nonzero for -fno-strict-prototype switch: do not consider empty
282 argument prototype to mean function takes no arguments. */
284 int flag_strict_prototype
= 2;
285 int strict_prototype
= 1;
286 int strict_prototypes_lang_c
, strict_prototypes_lang_cplusplus
= 1;
288 /* Nonzero means that labels can be used as first-class objects */
292 /* Non-zero means to collect statistics which might be expensive
293 and to print them when we are done. */
294 int flag_detailed_statistics
;
296 /* C++ specific flags. */
297 /* Nonzero for -fall-virtual: make every member function (except
298 constructors) lay down in the virtual function table. Calls
299 can then either go through the virtual function table or not,
302 int flag_all_virtual
;
304 /* Zero means that `this' is a *const. This gives nice behavior in the
305 2.0 world. 1 gives 1.2-compatible behavior. 2 gives Spring behavior.
306 -2 means we're constructing an object and it has fixed type. */
308 int flag_this_is_variable
;
310 /* Nonzero means memoize our member lookups. */
312 int flag_memoize_lookups
; int flag_save_memoized_contexts
;
314 /* 3 means write out only virtuals function tables `defined'
315 in this implementation file.
316 2 means write out only specific virtual function tables
317 and give them (C) public access.
318 1 means write out virtual function tables and give them
320 0 means write out virtual function tables and give them
321 (C) static access (default).
322 -1 means declare virtual function tables extern. */
326 /* Nonzero means we should attempt to elide constructors when possible.
327 FIXME: This flag is obsolete, and should be torn out along with the
328 old overloading code. */
330 int flag_elide_constructors
;
332 /* Nonzero means recognize and handle signature language constructs. */
334 int flag_handle_signatures
;
336 /* Nonzero means that member functions defined in class scope are
337 inline by default. */
339 int flag_default_inline
= 1;
341 /* Controls whether enums and ints freely convert.
342 1 means with complete freedom.
343 0 means enums can convert to ints, but not vice-versa. */
344 int flag_int_enum_equivalence
;
346 /* Controls whether compiler generates 'type descriptor' that give
347 run-time type information. */
350 /* Nonzero if we wish to output cross-referencing information
351 for the GNU class browser. */
352 extern int flag_gnu_xref
;
354 /* Nonzero if compiler can make `reasonable' assumptions about
355 references and objects. For example, the compiler must be
356 conservative about the following and not assume that `a' is nonnull:
361 In general, it is `reasonable' to assume that for many programs,
362 and better code can be generated in that case. */
364 int flag_assume_nonnull_objects
= 1;
366 /* Nonzero if we want to support huge (> 2^(sizeof(short)*8-1) bytes)
369 int flag_huge_objects
;
371 /* Nonzero if we want to conserve space in the .o files. We do this
372 by putting uninitialized data and runtime initialized data into
373 .common instead of .data at the expense of not flagging multiple
376 int flag_conserve_space
;
378 /* Nonzero if we want to obey access control semantics. */
380 int flag_access_control
= 1;
382 /* Nonzero if we want to understand the operator names, i.e. 'bitand'. */
384 int flag_operator_names
;
386 /* Nonzero if we want to check the return value of new and avoid calling
387 constructors if it is a null pointer. */
391 /* Nonzero if we want the new ANSI rules for pushing a new scope for `for'
392 initialization variables.
393 0: Old rules, set by -fno-for-scope.
394 2: New ANSI rules, set by -ffor-scope.
395 1: Try to implement new ANSI rules, but with backup compatibility
396 (and warnings). This is the default, for now. */
398 int flag_new_for_scope
= 1;
400 /* Nonzero if we want to emit defined symbols with common-like linkage as
401 weak symbols where possible, in order to conform to C++ semantics.
402 Otherwise, emit them as local symbols. */
406 /* Maximum template instantiation depth. Must be at least 17 for ANSI
409 int max_tinst_depth
= 17;
411 /* The name-mangling scheme to use. Must be 1 or greater to support
412 template functions with identical types, but different template
414 int name_mangling_version
= 1;
416 /* Nonzero means that guiding declarations are allowed. */
417 int flag_guiding_decls
;
419 /* Table of language-dependent -f options.
420 STRING is the option name. VARIABLE is the address of the variable.
421 ON_VALUE is the value to store in VARIABLE
422 if `-fSTRING' is seen as an option.
423 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
425 static struct { char *string
; int *variable
; int on_value
;} lang_f_options
[] =
427 {"signed-char", &flag_signed_char
, 1},
428 {"unsigned-char", &flag_signed_char
, 0},
429 {"signed-bitfields", &flag_signed_bitfields
, 1},
430 {"unsigned-bitfields", &flag_signed_bitfields
, 0},
431 {"short-enums", &flag_short_enums
, 1},
432 {"short-double", &flag_short_double
, 1},
433 {"cond-mismatch", &flag_cond_mismatch
, 1},
434 {"asm", &flag_no_asm
, 0},
435 {"builtin", &flag_no_builtin
, 0},
436 {"ident", &flag_no_ident
, 0},
437 {"labels-ok", &flag_labels_ok
, 1},
438 {"stats", &flag_detailed_statistics
, 1},
439 {"this-is-variable", &flag_this_is_variable
, 1},
440 {"strict-prototype", &flag_strict_prototype
, 1},
441 {"all-virtual", &flag_all_virtual
, 1},
442 {"memoize-lookups", &flag_memoize_lookups
, 1},
443 {"elide-constructors", &flag_elide_constructors
, 1},
444 {"handle-exceptions", &flag_exceptions
, 1},
445 {"handle-signatures", &flag_handle_signatures
, 1},
446 {"default-inline", &flag_default_inline
, 1},
447 {"dollars-in-identifiers", &dollars_in_ident
, 1},
448 {"enum-int-equiv", &flag_int_enum_equivalence
, 1},
449 {"rtti", &flag_rtti
, 1},
450 {"xref", &flag_gnu_xref
, 1},
451 {"nonnull-objects", &flag_assume_nonnull_objects
, 1},
452 {"implement-inlines", &flag_implement_inlines
, 1},
453 {"external-templates", &flag_external_templates
, 1},
454 {"implicit-templates", &flag_implicit_templates
, 1},
455 {"ansi-overloading", &flag_ansi_overloading
, 1},
456 {"huge-objects", &flag_huge_objects
, 1},
457 {"conserve-space", &flag_conserve_space
, 1},
458 {"vtable-thunks", &flag_vtable_thunks
, 1},
459 {"access-control", &flag_access_control
, 1},
460 {"nonansi-builtins", &flag_no_nonansi_builtin
, 0},
461 {"gnu-keywords", &flag_no_gnu_keywords
, 0},
462 {"operator-names", &flag_operator_names
, 1},
463 {"check-new", &flag_check_new
, 1},
464 {"repo", &flag_use_repository
, 1},
465 {"for-scope", &flag_new_for_scope
, 2},
466 {"weak", &flag_weak
, 1}
469 /* Decode the string P as a language-specific option.
470 Return 1 if it is recognized (and handle it);
471 return 0 if not recognized. */
474 lang_decode_option (p
)
477 if (!strcmp (p
, "-ftraditional") || !strcmp (p
, "-traditional"))
478 flag_writable_strings
= 1,
479 flag_this_is_variable
= 1, flag_new_for_scope
= 0;
480 /* The +e options are for cfront compatibility. They come in as
481 `-+eN', to kludge around gcc.c's argument handling. */
482 else if (p
[0] == '-' && p
[1] == '+' && p
[2] == 'e')
484 int old_write_virtuals
= write_virtuals
;
487 else if (p
[3] == '0')
489 else if (p
[3] == '2')
491 else error ("invalid +e option");
492 if (old_write_virtuals
!= 0
493 && write_virtuals
!= old_write_virtuals
)
494 error ("conflicting +e options given");
496 else if (p
[0] == '-' && p
[1] == 'f')
498 /* Some kind of -f option.
499 P's value is the option sans `-f'.
500 Search for it in the table of options. */
504 /* Try special -f options. */
506 if (!strcmp (p
, "handle-exceptions")
507 || !strcmp (p
, "no-handle-exceptions"))
508 warning ("-fhandle-exceptions has been renamed to -fexceptions (and is now on by default)");
510 if (!strcmp (p
, "save-memoized"))
512 flag_memoize_lookups
= 1;
513 flag_save_memoized_contexts
= 1;
516 else if (!strcmp (p
, "no-save-memoized"))
518 flag_memoize_lookups
= 0;
519 flag_save_memoized_contexts
= 0;
522 else if (! strcmp (p
, "alt-external-templates"))
524 flag_external_templates
= 1;
525 flag_alt_external_templates
= 1;
528 else if (! strcmp (p
, "no-alt-external-templates"))
530 flag_alt_external_templates
= 0;
533 else if (!strcmp (p
, "repo"))
535 flag_use_repository
= 1;
536 flag_implicit_templates
= 0;
539 else if (!strcmp (p
, "guiding-decls"))
541 flag_guiding_decls
= 1;
542 name_mangling_version
= 0;
545 else if (!strcmp (p
, "no-guiding-decls"))
547 flag_guiding_decls
= 0;
550 else if (!strncmp (p
, "template-depth-", 15))
555 if (*endp
>= '0' && *endp
<= '9')
559 error ("Invalid option `%s'", p
- 2);
560 goto template_depth_lose
;
563 max_tinst_depth
= atoi (p
+ 15);
564 template_depth_lose
: ;
566 else if (!strncmp (p
, "name-mangling-version-", 22))
571 if (*endp
>= '0' && *endp
<= '9')
575 error ("Invalid option `%s'", p
- 2);
576 goto mangling_version_lose
;
579 name_mangling_version
= atoi (p
+ 22);
580 mangling_version_lose
: ;
583 !found
&& j
< sizeof (lang_f_options
) / sizeof (lang_f_options
[0]);
586 if (!strcmp (p
, lang_f_options
[j
].string
))
588 *lang_f_options
[j
].variable
= lang_f_options
[j
].on_value
;
589 /* A goto here would be cleaner,
590 but breaks the vax pcc. */
593 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
594 && ! strcmp (p
+3, lang_f_options
[j
].string
))
596 *lang_f_options
[j
].variable
= ! lang_f_options
[j
].on_value
;
602 else if (p
[0] == '-' && p
[1] == 'W')
606 /* The -W options control the warning behavior of the compiler. */
609 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-')
612 if (!strcmp (p
, "implicit"))
613 warn_implicit
= setting
;
614 else if (!strcmp (p
, "return-type"))
615 warn_return_type
= setting
;
616 else if (!strcmp (p
, "ctor-dtor-privacy"))
617 warn_ctor_dtor_privacy
= setting
;
618 else if (!strcmp (p
, "write-strings"))
619 warn_write_strings
= setting
;
620 else if (!strcmp (p
, "cast-qual"))
621 warn_cast_qual
= setting
;
622 else if (!strcmp (p
, "char-subscripts"))
623 warn_char_subscripts
= setting
;
624 else if (!strcmp (p
, "pointer-arith"))
625 warn_pointer_arith
= setting
;
626 else if (!strcmp (p
, "missing-prototypes"))
627 warn_missing_prototypes
= setting
;
628 else if (!strcmp (p
, "redundant-decls"))
629 warn_redundant_decls
= setting
;
630 else if (!strcmp (p
, "missing-braces"))
631 warn_missing_braces
= setting
;
632 else if (!strcmp (p
, "sign-compare"))
633 warn_sign_compare
= setting
;
634 else if (!strcmp (p
, "format"))
635 warn_format
= setting
;
636 else if (!strcmp (p
, "conversion"))
637 warn_conversion
= setting
;
638 else if (!strcmp (p
, "parentheses"))
639 warn_parentheses
= setting
;
640 else if (!strcmp (p
, "non-virtual-dtor"))
641 warn_nonvdtor
= setting
;
642 else if (!strcmp (p
, "extern-inline"))
643 warn_extern_inline
= setting
;
644 else if (!strcmp (p
, "reorder"))
645 warn_reorder
= setting
;
646 else if (!strcmp (p
, "synth"))
647 warn_synth
= setting
;
648 else if (!strcmp (p
, "pmf-conversions"))
649 warn_pmf2ptr
= setting
;
650 else if (!strcmp (p
, "effc++"))
652 else if (!strcmp (p
, "sign-promo"))
653 warn_sign_promo
= setting
;
654 else if (!strcmp (p
, "old-style-cast"))
655 warn_old_style_cast
= setting
;
656 else if (!strcmp (p
, "comment"))
657 ; /* cpp handles this one. */
658 else if (!strcmp (p
, "comments"))
659 ; /* cpp handles this one. */
660 else if (!strcmp (p
, "trigraphs"))
661 ; /* cpp handles this one. */
662 else if (!strcmp (p
, "import"))
663 ; /* cpp handles this one. */
664 else if (!strcmp (p
, "all"))
666 warn_return_type
= setting
;
667 warn_unused
= setting
;
668 warn_implicit
= setting
;
669 warn_ctor_dtor_privacy
= setting
;
670 warn_switch
= setting
;
671 warn_format
= setting
;
672 warn_parentheses
= setting
;
673 warn_missing_braces
= setting
;
674 warn_sign_compare
= setting
;
675 warn_extern_inline
= setting
;
676 warn_nonvdtor
= setting
;
677 /* We save the value of warn_uninitialized, since if they put
678 -Wuninitialized on the command line, we need to generate a
679 warning about not using it without also specifying -O. */
680 if (warn_uninitialized
!= 1)
681 warn_uninitialized
= (setting
? 2 : 0);
682 warn_template_debugging
= setting
;
683 warn_reorder
= setting
;
684 warn_sign_promo
= setting
;
687 else if (!strcmp (p
, "overloaded-virtual"))
688 warn_overloaded_virtual
= setting
;
691 else if (!strcmp (p
, "-ansi"))
692 flag_no_nonansi_builtin
= 1, flag_ansi
= 1,
693 flag_no_gnu_keywords
= 1, flag_operator_names
= 1;
695 /* Undocumented, only ever used when you're invoking cc1plus by hand, since
696 it's probably safe to assume no sane person would ever want to use this
697 under normal circumstances. */
698 else if (!strcmp (p
, "-spew-debug"))
707 /* Incorporate `const' and `volatile' qualifiers for member functions.
708 FUNCTION is a TYPE_DECL or a FUNCTION_DECL.
709 QUALS is a list of qualifiers. */
712 grok_method_quals (ctype
, function
, quals
)
713 tree ctype
, function
, quals
;
715 tree fntype
= TREE_TYPE (function
);
716 tree raises
= TYPE_RAISES_EXCEPTIONS (fntype
);
720 extern tree ridpointers
[];
722 if (TREE_VALUE (quals
) == ridpointers
[(int)RID_CONST
])
724 if (TYPE_READONLY (ctype
))
725 error ("duplicate `%s' %s",
726 IDENTIFIER_POINTER (TREE_VALUE (quals
)),
727 (TREE_CODE (function
) == FUNCTION_DECL
728 ? "for member function" : "in type declaration"));
729 ctype
= build_type_variant (ctype
, 1, TYPE_VOLATILE (ctype
));
730 build_pointer_type (ctype
);
732 else if (TREE_VALUE (quals
) == ridpointers
[(int)RID_VOLATILE
])
734 if (TYPE_VOLATILE (ctype
))
735 error ("duplicate `%s' %s",
736 IDENTIFIER_POINTER (TREE_VALUE (quals
)),
737 (TREE_CODE (function
) == FUNCTION_DECL
738 ? "for member function" : "in type declaration"));
739 ctype
= build_type_variant (ctype
, TYPE_READONLY (ctype
), 1);
740 build_pointer_type (ctype
);
743 my_friendly_abort (20);
744 quals
= TREE_CHAIN (quals
);
747 fntype
= build_cplus_method_type (ctype
, TREE_TYPE (fntype
),
748 (TREE_CODE (fntype
) == METHOD_TYPE
749 ? TREE_CHAIN (TYPE_ARG_TYPES (fntype
))
750 : TYPE_ARG_TYPES (fntype
)));
752 fntype
= build_exception_variant (fntype
, raises
);
754 TREE_TYPE (function
) = fntype
;
758 #if 0 /* Not used. */
759 /* This routine replaces cryptic DECL_NAMEs with readable DECL_NAMEs.
760 It leaves DECL_ASSEMBLER_NAMEs with the correct value. */
761 /* This does not yet work with user defined conversion operators
765 substitute_nice_name (decl
)
768 if (DECL_NAME (decl
) && TREE_CODE (DECL_NAME (decl
)) == IDENTIFIER_NODE
)
770 char *n
= decl_as_string (DECL_NAME (decl
), 1);
771 if (n
[strlen (n
) - 1] == ' ')
772 n
[strlen (n
) - 1] = 0;
773 DECL_NAME (decl
) = get_identifier (n
);
778 /* Warn when -fexternal-templates is used and #pragma
779 interface/implementation is not used all the times it should be,
783 warn_if_unknown_interface (decl
)
786 static int already_warned
= 0;
787 if (already_warned
++)
790 if (flag_alt_external_templates
)
792 struct tinst_level
*til
= tinst_for_decl ();
794 char *sf
= input_filename
;
799 input_filename
= til
->file
;
801 cp_warning ("template `%#D' instantiated in file without #pragma interface",
807 cp_warning_at ("template `%#D' defined in file without #pragma interface",
811 /* A subroutine of the parser, to handle a component list. */
814 grok_x_components (specs
, components
)
815 tree specs
, components
;
817 register tree t
, x
, tcode
;
819 /* We just got some friends. They have been recorded elsewhere. */
820 if (components
== void_type_node
)
823 if (components
== NULL_TREE
)
825 t
= groktypename (build_decl_list (specs
, NULL_TREE
));
829 error ("error in component specification");
833 switch (TREE_CODE (t
))
836 /* Static anonymous unions come out as VAR_DECLs. */
837 if (TREE_CODE (TREE_TYPE (t
)) == UNION_TYPE
838 && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_TYPE (t
))))
841 /* We return SPECS here, because in the parser it was ending
842 up with not doing anything to $$, which is what SPECS
848 /* This code may be needed for UNION_TYPEs as
850 tcode
= record_type_node
;
851 if (CLASSTYPE_DECLARED_CLASS (t
))
852 tcode
= class_type_node
;
853 else if (IS_SIGNATURE (t
))
854 tcode
= signature_type_node
;
856 t
= xref_tag (tcode
, TYPE_IDENTIFIER (t
), NULL_TREE
, 0);
857 if (TYPE_CONTEXT (t
))
858 CLASSTYPE_NO_GLOBALIZE (t
) = 1;
864 if (TREE_CODE (t
) == UNION_TYPE
)
865 tcode
= union_type_node
;
867 tcode
= enum_type_node
;
869 t
= xref_tag (tcode
, TYPE_IDENTIFIER (t
), NULL_TREE
, 0);
870 if (TREE_CODE (t
) == UNION_TYPE
&& TYPE_CONTEXT (t
))
871 CLASSTYPE_NO_GLOBALIZE (t
) = 1;
872 if (TREE_CODE (t
) == UNION_TYPE
873 && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t
)))
875 /* See also shadow_tag. */
877 struct pending_inline
**p
;
879 x
= build_lang_field_decl (FIELD_DECL
, NULL_TREE
, t
);
881 /* Wipe out memory of synthesized methods */
882 TYPE_HAS_CONSTRUCTOR (t
) = 0;
883 TYPE_HAS_DEFAULT_CONSTRUCTOR (t
) = 0;
884 TYPE_HAS_INIT_REF (t
) = 0;
885 TYPE_HAS_CONST_INIT_REF (t
) = 0;
886 TYPE_HAS_ASSIGN_REF (t
) = 0;
887 TYPE_HAS_ASSIGNMENT (t
) = 0;
888 TYPE_HAS_CONST_ASSIGN_REF (t
) = 0;
890 q
= &TYPE_METHODS (t
);
893 if (DECL_ARTIFICIAL (*q
))
894 *q
= TREE_CHAIN (*q
);
896 q
= &TREE_CHAIN (*q
);
898 if (TYPE_METHODS (t
))
899 error ("an anonymous union cannot have function members");
901 p
= &pending_inlines
;
902 for (; *p
; *p
= (*p
)->next
)
903 if (DECL_CONTEXT ((*p
)->fndecl
) != t
)
906 else if (TREE_CODE (t
) == ENUMERAL_TYPE
)
907 x
= grok_enum_decls (t
, NULL_TREE
);
914 if (t
!= void_type_node
)
915 error ("empty component declaration");
921 t
= TREE_TYPE (components
);
922 if (TREE_CODE (t
) == ENUMERAL_TYPE
&& TREE_NONLOCAL_FLAG (t
))
923 return grok_enum_decls (t
, components
);
929 /* Classes overload their constituent function names automatically.
930 When a function name is declared in a record structure,
931 its name is changed to it overloaded name. Since names for
932 constructors and destructors can conflict, we place a leading
935 CNAME is the name of the class we are grokking for.
937 FUNCTION is a FUNCTION_DECL. It was created by `grokdeclarator'.
939 FLAGS contains bits saying what's special about today's
940 arguments. 1 == DESTRUCTOR. 2 == OPERATOR.
942 If FUNCTION is a destructor, then we must add the `auto-delete' field
943 as a second parameter. There is some hair associated with the fact
944 that we must "declare" this variable in the manner consistent with the
945 way the rest of the arguments were declared.
947 QUALS are the qualifiers for the this pointer. */
950 grokclassfn (ctype
, cname
, function
, flags
, quals
)
951 tree ctype
, cname
, function
;
952 enum overload_flags flags
;
955 tree fn_name
= DECL_NAME (function
);
959 tree fntype
= TREE_TYPE (function
);
960 tree raises
= TYPE_RAISES_EXCEPTIONS (fntype
);
962 if (fn_name
== NULL_TREE
)
964 error ("name missing for member function");
965 fn_name
= get_identifier ("<anonymous>");
966 DECL_NAME (function
) = fn_name
;
970 qualtype
= grok_method_quals (ctype
, function
, quals
);
974 arg_types
= TYPE_ARG_TYPES (TREE_TYPE (function
));
975 if (TREE_CODE (TREE_TYPE (function
)) == METHOD_TYPE
)
977 /* Must add the class instance variable up front. */
978 /* Right now we just make this a pointer. But later
979 we may wish to make it special. */
980 tree type
= TREE_VALUE (arg_types
);
983 if ((flag_this_is_variable
> 0)
984 && (flags
== DTOR_FLAG
|| DECL_CONSTRUCTOR_P (function
)))
987 if (DECL_CONSTRUCTOR_P (function
))
989 if (TYPE_USES_VIRTUAL_BASECLASSES (ctype
))
991 DECL_CONSTRUCTOR_FOR_VBASE_P (function
) = 1;
992 /* In this case we need "in-charge" flag saying whether
993 this constructor is responsible for initialization
994 of virtual baseclasses or not. */
995 parm
= build_decl (PARM_DECL
, in_charge_identifier
, integer_type_node
);
996 /* Mark the artificial `__in_chrg' parameter as "artificial". */
997 SET_DECL_ARTIFICIAL (parm
);
998 DECL_ARG_TYPE (parm
) = integer_type_node
;
999 TREE_READONLY (parm
) = 1;
1000 TREE_CHAIN (parm
) = last_function_parms
;
1001 last_function_parms
= parm
;
1005 parm
= build_decl (PARM_DECL
, this_identifier
, type
);
1006 /* Mark the artificial `this' parameter as "artificial". */
1007 SET_DECL_ARTIFICIAL (parm
);
1008 DECL_ARG_TYPE (parm
) = type
;
1009 /* We can make this a register, so long as we don't
1010 accidentally complain if someone tries to take its address. */
1011 DECL_REGISTER (parm
) = 1;
1013 TREE_READONLY (parm
) = 1;
1014 TREE_CHAIN (parm
) = last_function_parms
;
1015 last_function_parms
= parm
;
1018 if (flags
== DTOR_FLAG
)
1021 int len
= sizeof (DESTRUCTOR_DECL_PREFIX
)-1;
1023 arg_types
= hash_tree_chain (integer_type_node
, void_list_node
);
1024 TREE_SIDE_EFFECTS (arg_types
) = 1;
1025 /* Build the overload name. It will look like `7Example'. */
1026 if (IDENTIFIER_TYPE_VALUE (cname
))
1027 dbuf
= build_overload_name (IDENTIFIER_TYPE_VALUE (cname
), 1, 1);
1028 else if (IDENTIFIER_LOCAL_VALUE (cname
))
1029 dbuf
= build_overload_name (TREE_TYPE (IDENTIFIER_LOCAL_VALUE (cname
)), 1, 1);
1031 /* Using ctype fixes the `X::Y::~Y()' crash. The cname has no type when
1032 it's defined out of the class definition, since poplevel_class wipes
1033 it out. This used to be internal error 346. */
1034 dbuf
= build_overload_name (ctype
, 1, 1);
1035 buf
= (char *) alloca (strlen (dbuf
) + sizeof (DESTRUCTOR_DECL_PREFIX
));
1036 bcopy (DESTRUCTOR_DECL_PREFIX
, buf
, len
);
1039 DECL_ASSEMBLER_NAME (function
) = get_identifier (buf
);
1040 parm
= build_decl (PARM_DECL
, in_charge_identifier
, integer_type_node
);
1041 /* Mark the artificial `__in_chrg' parameter as "artificial". */
1042 SET_DECL_ARTIFICIAL (parm
);
1043 TREE_READONLY (parm
) = 1;
1044 DECL_ARG_TYPE (parm
) = integer_type_node
;
1045 /* This is the same chain as DECL_ARGUMENTS (...). */
1046 TREE_CHAIN (last_function_parms
) = parm
;
1048 fntype
= build_cplus_method_type (qualtype
, void_type_node
,
1052 fntype
= build_exception_variant (fntype
, raises
);
1054 TREE_TYPE (function
) = fntype
;
1055 TYPE_HAS_DESTRUCTOR (ctype
) = 1;
1059 tree these_arg_types
;
1061 if (DECL_CONSTRUCTOR_FOR_VBASE_P (function
))
1063 arg_types
= hash_tree_chain (integer_type_node
,
1064 TREE_CHAIN (arg_types
));
1065 fntype
= build_cplus_method_type (qualtype
,
1066 TREE_TYPE (TREE_TYPE (function
)),
1070 fntype
= build_exception_variant (fntype
, raises
);
1072 TREE_TYPE (function
) = fntype
;
1073 arg_types
= TYPE_ARG_TYPES (TREE_TYPE (function
));
1076 these_arg_types
= arg_types
;
1078 if (TREE_CODE (TREE_TYPE (function
)) == FUNCTION_TYPE
)
1079 /* Only true for static member functions. */
1080 these_arg_types
= hash_tree_chain (build_pointer_type (qualtype
),
1083 DECL_ASSEMBLER_NAME (function
)
1084 = build_decl_overload (fn_name
, these_arg_types
,
1085 1 + DECL_CONSTRUCTOR_P (function
));
1088 /* This code is going into the compiler, but currently, it makes
1089 libg++/src/Integer.cc not compile. The problem is that the nice name
1090 winds up going into the symbol table, and conversion operations look
1091 for the manged name. */
1092 substitute_nice_name (function
);
1096 DECL_ARGUMENTS (function
) = last_function_parms
;
1097 /* First approximations. */
1098 DECL_CONTEXT (function
) = ctype
;
1099 DECL_CLASS_CONTEXT (function
) = ctype
;
1102 /* Work on the expr used by alignof (this is only called by the parser). */
1111 if (TREE_CODE (expr
) == COMPONENT_REF
1112 && DECL_BIT_FIELD (TREE_OPERAND (expr
, 1)))
1113 error ("`__alignof__' applied to a bit-field");
1115 if (TREE_CODE (expr
) == INDIRECT_REF
)
1117 best
= t
= TREE_OPERAND (expr
, 0);
1118 bestalign
= TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t
)));
1120 while (TREE_CODE (t
) == NOP_EXPR
1121 && TREE_CODE (TREE_TYPE (TREE_OPERAND (t
, 0))) == POINTER_TYPE
)
1124 t
= TREE_OPERAND (t
, 0);
1125 thisalign
= TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t
)));
1126 if (thisalign
> bestalign
)
1127 best
= t
, bestalign
= thisalign
;
1129 return c_alignof (TREE_TYPE (TREE_TYPE (best
)));
1133 /* ANSI says arrays and fns are converted inside comma.
1134 But we can't convert them in build_compound_expr
1135 because that would break commas in lvalues.
1136 So do the conversion here if operand was a comma. */
1137 if (TREE_CODE (expr
) == COMPOUND_EXPR
1138 && (TREE_CODE (TREE_TYPE (expr
)) == ARRAY_TYPE
1139 || TREE_CODE (TREE_TYPE (expr
)) == FUNCTION_TYPE
))
1140 expr
= default_conversion (expr
);
1141 return c_alignof (TREE_TYPE (expr
));
1145 /* Create an ARRAY_REF, checking for the user doing things backwards
1149 grok_array_decl (array_expr
, index_exp
)
1150 tree array_expr
, index_exp
;
1152 tree type
= TREE_TYPE (array_expr
);
1153 tree p1
, p2
, i1
, i2
;
1155 if (type
== error_mark_node
|| index_exp
== error_mark_node
)
1156 return error_mark_node
;
1157 if (processing_template_decl
)
1158 return build_min (ARRAY_REF
, type
? TREE_TYPE (type
) : NULL_TREE
,
1159 array_expr
, index_exp
);
1161 if (type
== NULL_TREE
)
1163 /* Something has gone very wrong. Assume we are mistakenly reducing
1164 an expression instead of a declaration. */
1165 error ("parser may be lost: is there a '{' missing somewhere?");
1169 if (TREE_CODE (type
) == OFFSET_TYPE
1170 || TREE_CODE (type
) == REFERENCE_TYPE
)
1171 type
= TREE_TYPE (type
);
1173 /* If they have an `operator[]', use that. */
1174 if (TYPE_LANG_SPECIFIC (type
)
1175 && TYPE_OVERLOADS_ARRAY_REF (complete_type (type
)))
1176 return build_opfncall (ARRAY_REF
, LOOKUP_NORMAL
,
1177 array_expr
, index_exp
, NULL_TREE
);
1179 /* Otherwise, create an ARRAY_REF for a pointer or array type. */
1181 if (TREE_CODE (type
) == ARRAY_TYPE
)
1184 p1
= build_expr_type_conversion (WANT_POINTER
, array_expr
, 0);
1186 if (TREE_CODE (TREE_TYPE (index_exp
)) == ARRAY_TYPE
)
1189 p2
= build_expr_type_conversion (WANT_POINTER
, index_exp
, 0);
1191 i1
= build_expr_type_conversion (WANT_INT
| WANT_ENUM
, array_expr
, 0);
1192 i2
= build_expr_type_conversion (WANT_INT
| WANT_ENUM
, index_exp
, 0);
1194 if ((p1
&& i2
) && (i1
&& p2
))
1195 error ("ambiguous conversion for array subscript");
1198 array_expr
= p1
, index_exp
= i2
;
1200 array_expr
= p2
, index_exp
= i1
;
1203 cp_error ("invalid types `%T[%T]' for array subscript",
1204 type
, TREE_TYPE (index_exp
));
1205 return error_mark_node
;
1208 if (array_expr
== error_mark_node
|| index_exp
== error_mark_node
)
1209 error ("ambiguous conversion for array subscript");
1211 return build_array_ref (array_expr
, index_exp
);
1214 /* Given the cast expression EXP, checking out its validity. Either return
1215 an error_mark_node if there was an unavoidable error, return a cast to
1216 void for trying to delete a pointer w/ the value 0, or return the
1217 call to delete. If DOING_VEC is 1, we handle things differently
1218 for doing an array delete. If DOING_VEC is 2, they gave us the
1219 array size as an argument to delete.
1220 Implements ARM $5.3.4. This is called from the parser. */
1223 delete_sanity (exp
, size
, doing_vec
, use_global_delete
)
1225 int doing_vec
, use_global_delete
;
1229 enum tree_code code
;
1230 /* For a regular vector delete (aka, no size argument) we will pass
1231 this down as a NULL_TREE into build_vec_delete. */
1232 tree maxindex
= NULL_TREE
;
1234 if (exp
== error_mark_node
)
1237 if (processing_template_decl
)
1239 t
= build_min (DELETE_EXPR
, void_type_node
, exp
, size
);
1240 DELETE_EXPR_USE_GLOBAL (t
) = use_global_delete
;
1241 DELETE_EXPR_USE_VEC (t
) = doing_vec
;
1245 t
= stabilize_reference (convert_from_reference (exp
));
1246 type
= TREE_TYPE (t
);
1247 code
= TREE_CODE (type
);
1252 maxindex
= build_binary_op (MINUS_EXPR
, size
, integer_one_node
, 1);
1253 pedwarn ("anachronistic use of array size in vector delete");
1258 if (code
!= POINTER_TYPE
)
1260 cp_error ("type `%#T' argument given to `delete', expected pointer",
1262 return error_mark_node
;
1265 /* Deleting a pointer with the value zero is valid and has no effect. */
1266 if (integer_zerop (t
))
1267 return build1 (NOP_EXPR
, void_type_node
, t
);
1270 if (code
== POINTER_TYPE
)
1273 /* As of Valley Forge, you can delete a pointer to constant. */
1274 /* You can't delete a pointer to constant. */
1275 if (TREE_READONLY (TREE_TYPE (type
)))
1277 error ("`const *' cannot be deleted");
1278 return error_mark_node
;
1281 /* You also can't delete functions. */
1282 if (TREE_CODE (TREE_TYPE (type
)) == FUNCTION_TYPE
)
1284 error ("cannot delete a function");
1285 return error_mark_node
;
1290 /* If the type has no destructor, then we should build a regular
1291 delete, instead of a vector delete. Otherwise, we would end
1292 up passing a bogus offset into __builtin_delete, which is
1293 not expecting it. */
1295 && TREE_CODE (type
) == POINTER_TYPE
1296 && !TYPE_HAS_DESTRUCTOR (TREE_TYPE (type
)))
1299 use_global_delete
= 1;
1304 return build_vec_delete (t
, maxindex
, integer_one_node
,
1305 integer_two_node
, use_global_delete
);
1308 if (IS_AGGR_TYPE (TREE_TYPE (type
))
1309 && TYPE_GETS_REG_DELETE (TREE_TYPE (type
)))
1311 /* Only do access checking here; we'll be calling op delete
1312 from the destructor. */
1313 tree tmp
= build_opfncall (DELETE_EXPR
, LOOKUP_NORMAL
, t
,
1314 size_zero_node
, NULL_TREE
);
1315 if (tmp
== error_mark_node
)
1316 return error_mark_node
;
1319 return build_delete (type
, t
, integer_three_node
,
1320 LOOKUP_NORMAL
, use_global_delete
);
1324 /* Report an error if the indicated template declaration is not the
1325 sort of thing that should be a member template. */
1328 check_member_template (tmpl
)
1333 my_friendly_assert (TREE_CODE (tmpl
) == TEMPLATE_DECL
, 0);
1334 decl
= DECL_TEMPLATE_RESULT (tmpl
);
1336 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1338 if (current_function_decl
)
1339 /* 14.5.2.2 [temp.mem]
1341 A local class shall not have member templates. */
1342 cp_error ("declaration of of member template `%#D' in local class",
1345 if (DECL_VIRTUAL_P (decl
))
1347 /* 14.5.2.3 [temp.mem]
1349 A member function template shall not be virtual. */
1351 ("invalid use of `virtual' in template declaration of `%#D'",
1353 DECL_VIRTUAL_P (decl
) = 0;
1356 /* The debug-information generating code doesn't know what to do
1357 with member templates. */
1358 DECL_IGNORED_P (tmpl
) = 1;
1360 else if (TREE_CODE (decl
) == TYPE_DECL
&&
1361 AGGREGATE_TYPE_P (TREE_TYPE (decl
)))
1363 if (current_function_decl
)
1364 /* 14.5.2.2 [temp.mem]
1366 A local class shall not have member templates. */
1367 cp_error ("declaration of of member template `%#D' in local class",
1370 /* We don't handle member template classes yet. */
1371 sorry ("member templates classes");
1374 cp_error ("template declaration of `%#D'", decl
);
1377 /* Sanity check: report error if this function FUNCTION is not
1378 really a member of the class (CTYPE) it is supposed to belong to.
1379 CNAME is the same here as it is for grokclassfn above. */
1382 check_classfn (ctype
, function
)
1383 tree ctype
, function
;
1385 tree fn_name
= DECL_NAME (function
);
1387 tree method_vec
= CLASSTYPE_METHOD_VEC (complete_type (ctype
));
1390 tree templates
= NULL_TREE
;
1392 if (method_vec
!= 0)
1394 methods
= &TREE_VEC_ELT (method_vec
, 0);
1395 end
= TREE_VEC_END (method_vec
);
1397 /* First suss out ctors and dtors. */
1398 if (*methods
&& fn_name
== DECL_NAME (*methods
)
1399 && DECL_CONSTRUCTOR_P (function
))
1401 if (*++methods
&& fn_name
== DECL_NAME (*methods
)
1402 && DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (function
)))
1405 while (++methods
!= end
)
1408 if (fn_name
== DECL_NAME (*methods
))
1414 if (DECL_ASSEMBLER_NAME (function
) == DECL_ASSEMBLER_NAME (fndecl
))
1417 /* This doesn't work for static member functions that are
1418 pretending to be methods. */
1419 /* We have to do more extensive argument checking here, as
1420 the name may have been changed by asm("new_name"). */
1421 if (decls_match (function
, fndecl
))
1424 if (DECL_NAME (function
) == DECL_NAME (fndecl
))
1426 tree p1
= TYPE_ARG_TYPES (TREE_TYPE (function
));
1427 tree p2
= TYPE_ARG_TYPES (TREE_TYPE (fndecl
));
1429 /* Get rid of the this parameter on functions that become
1431 if (DECL_STATIC_FUNCTION_P (fndecl
)
1432 && TREE_CODE (TREE_TYPE (function
)) == METHOD_TYPE
)
1433 p1
= TREE_CHAIN (p1
);
1435 if (comptypes (TREE_TYPE (TREE_TYPE (function
)),
1436 TREE_TYPE (TREE_TYPE (fndecl
)), 1)
1437 && compparms (p1
, p2
, 3)
1438 && (DECL_TEMPLATE_SPECIALIZATION (function
)
1439 == DECL_TEMPLATE_SPECIALIZATION (fndecl
))
1440 && (!DECL_TEMPLATE_SPECIALIZATION (function
)
1441 || (DECL_TI_TEMPLATE (function
)
1442 == DECL_TI_TEMPLATE (fndecl
))))
1445 if (is_member_template (fndecl
))
1446 /* This function might be an instantiation
1447 or specialization of fndecl. */
1449 scratch_tree_cons (NULL_TREE
, fndecl
, templates
);
1452 fndecl
= DECL_CHAIN (fndecl
);
1456 else if (TREE_CODE (fndecl
) == TEMPLATE_DECL
1457 && IDENTIFIER_TYPENAME_P (DECL_NAME (fndecl
))
1458 && IDENTIFIER_TYPENAME_P (fn_name
))
1459 /* The method in the class is a member template
1460 conversion operator. We are declaring another
1461 conversion operator. It is possible that even though
1462 the names don't match, there is some specialization
1465 scratch_tree_cons (NULL_TREE
, fndecl
, templates
);
1470 /* This function might be an instantiation or a specialization.
1471 We should verify that this is possible. If it is, we must
1472 somehow add the new declaration to the method vector for the
1473 class. Perhaps we should use add_method? For now, we simply
1474 return NULL_TREE, which lets the caller know that this
1475 function is new, but we don't print an error message. */
1480 tree fndecl
= *methods
;
1481 cp_error ("prototype for `%#D' does not match any in class `%T'",
1483 cp_error_at ("candidate%s: %+#D", DECL_CHAIN (fndecl
) ? "s are" : " is",
1485 while (fndecl
= DECL_CHAIN (fndecl
), fndecl
)
1486 cp_error_at (" %#D", fndecl
);
1491 cp_error ("no `%#D' member function declared in class `%T'",
1495 /* If we did not find the method in the class, add it to avoid
1497 add_method (ctype
, methods
, function
);
1501 /* Process the specs, declarator (NULL if omitted) and width (NULL if omitted)
1502 of a structure component, returning a FIELD_DECL node.
1503 QUALS is a list of type qualifiers for this decl (such as for declaring
1504 const member functions).
1506 This is done during the parsing of the struct declaration.
1507 The FIELD_DECL nodes are chained together and the lot of them
1508 are ultimately passed to `build_struct' to make the RECORD_TYPE node.
1512 If class A defines that certain functions in class B are friends, then
1513 the way I have set things up, it is B who is interested in permission
1514 granted by A. However, it is in A's context that these declarations
1515 are parsed. By returning a void_type_node, class A does not attempt
1516 to incorporate the declarations of the friends within its structure.
1518 DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING
1519 CHANGES TO CODE IN `start_method'. */
1522 grokfield (declarator
, declspecs
, init
, asmspec_tree
, attrlist
)
1523 tree declarator
, declspecs
, init
, asmspec_tree
, attrlist
;
1525 register tree value
;
1527 int flags
= LOOKUP_ONLYCONVERTING
;
1529 /* Convert () initializers to = initializers. */
1530 if (init
== NULL_TREE
&& declarator
!= NULL_TREE
1531 && TREE_CODE (declarator
) == CALL_EXPR
1532 && TREE_OPERAND (declarator
, 0)
1533 && (TREE_CODE (TREE_OPERAND (declarator
, 0)) == IDENTIFIER_NODE
1534 || TREE_CODE (TREE_OPERAND (declarator
, 0)) == SCOPE_REF
)
1535 && parmlist_is_exprlist (TREE_OPERAND (declarator
, 1)))
1537 init
= TREE_OPERAND (declarator
, 1);
1538 declarator
= TREE_OPERAND (declarator
, 0);
1542 if (declspecs
== NULL_TREE
1543 && TREE_CODE (declarator
) == SCOPE_REF
1544 && TREE_CODE (TREE_OPERAND (declarator
, 1)) == IDENTIFIER_NODE
)
1546 /* Access declaration */
1547 if (! IS_AGGR_TYPE_CODE (TREE_CODE (TREE_OPERAND (declarator
, 0))))
1549 else if (TREE_COMPLEXITY (declarator
) == current_class_depth
)
1550 pop_nested_class (1);
1551 return do_class_using_decl (declarator
);
1555 && TREE_CODE (init
) == TREE_LIST
1556 && TREE_VALUE (init
) == error_mark_node
1557 && TREE_CHAIN (init
) == NULL_TREE
)
1560 value
= grokdeclarator (declarator
, declspecs
, FIELD
, init
!= 0, NULL_TREE
);
1562 return value
; /* friend or constructor went bad. */
1564 /* Pass friendly classes back. */
1565 if (TREE_CODE (value
) == VOID_TYPE
)
1566 return void_type_node
;
1568 if (DECL_NAME (value
) != NULL_TREE
1569 && IDENTIFIER_POINTER (DECL_NAME (value
))[0] == '_'
1570 && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (value
)), "_vptr"))
1571 cp_error ("member `%D' conflicts with virtual function table field name", value
);
1573 /* Stash away type declarations. */
1574 if (TREE_CODE (value
) == TYPE_DECL
)
1576 DECL_NONLOCAL (value
) = 1;
1577 DECL_CONTEXT (value
) = current_class_type
;
1578 DECL_CLASS_CONTEXT (value
) = current_class_type
;
1579 CLASSTYPE_LOCAL_TYPEDECLS (current_class_type
) = 1;
1581 pushdecl_class_level (value
);
1585 if (IS_SIGNATURE (current_class_type
)
1586 && TREE_CODE (value
) != FUNCTION_DECL
)
1588 error ("field declaration not allowed in signature");
1589 return void_type_node
;
1592 if (DECL_IN_AGGR_P (value
))
1594 cp_error ("`%D' is already defined in the class %T", value
,
1595 DECL_CONTEXT (value
));
1596 return void_type_node
;
1600 asmspec
= TREE_STRING_POINTER (asmspec_tree
);
1604 if (IS_SIGNATURE (current_class_type
)
1605 && TREE_CODE (value
) == FUNCTION_DECL
)
1607 error ("function declarations cannot have initializers in signature");
1610 else if (TREE_CODE (value
) == FUNCTION_DECL
)
1612 grok_function_init (value
, init
);
1615 else if (pedantic
&& TREE_CODE (value
) != VAR_DECL
)
1616 /* Already complained in grokdeclarator. */
1620 /* We allow initializers to become parameters to base
1622 if (TREE_CODE (init
) == TREE_LIST
)
1624 if (TREE_CHAIN (init
) == NULL_TREE
)
1625 init
= TREE_VALUE (init
);
1627 init
= digest_init (TREE_TYPE (value
), init
, (tree
*)0);
1630 if (TREE_CODE (init
) == CONST_DECL
)
1631 init
= DECL_INITIAL (init
);
1632 else if (TREE_READONLY_DECL_P (init
))
1633 init
= decl_constant_value (init
);
1634 else if (TREE_CODE (init
) == CONSTRUCTOR
)
1635 init
= digest_init (TREE_TYPE (value
), init
, (tree
*)0);
1636 my_friendly_assert (TREE_PERMANENT (init
), 192);
1637 if (init
== error_mark_node
)
1638 /* We must make this look different than `error_mark_node'
1639 because `decl_const_value' would mis-interpret it
1640 as only meaning that this VAR_DECL is defined. */
1641 init
= build1 (NOP_EXPR
, TREE_TYPE (value
), init
);
1642 else if (processing_template_decl
)
1644 else if (! TREE_CONSTANT (init
))
1646 /* We can allow references to things that are effectively
1647 static, since references are initialized with the address. */
1648 if (TREE_CODE (TREE_TYPE (value
)) != REFERENCE_TYPE
1649 || (TREE_STATIC (init
) == 0
1650 && (TREE_CODE_CLASS (TREE_CODE (init
)) != 'd'
1651 || DECL_EXTERNAL (init
) == 0)))
1653 error ("field initializer is not constant");
1654 init
= error_mark_node
;
1660 /* The corresponding pop_obstacks is in cp_finish_decl. */
1661 push_obstacks_nochange ();
1663 if (processing_template_decl
&& ! current_function_decl
1664 && (TREE_CODE (value
) == VAR_DECL
|| TREE_CODE (value
) == FUNCTION_DECL
))
1665 push_template_decl (value
);
1668 cplus_decl_attributes (value
, TREE_PURPOSE (attrlist
),
1669 TREE_VALUE (attrlist
));
1671 if (TREE_CODE (value
) == VAR_DECL
)
1673 /* We cannot call pushdecl here, because that would
1674 fill in the value of our TREE_CHAIN. Instead, we
1675 modify cp_finish_decl to do the right thing, namely, to
1676 put this decl out straight away. */
1677 if (TREE_PUBLIC (value
))
1679 /* current_class_type can be NULL_TREE in case of error. */
1680 if (asmspec
== 0 && current_class_type
)
1682 TREE_PUBLIC (value
) = 1;
1683 DECL_INITIAL (value
) = error_mark_node
;
1684 DECL_ASSEMBLER_NAME (value
)
1685 = build_static_name (current_class_type
, DECL_NAME (value
));
1687 if (! processing_template_decl
)
1688 pending_statics
= perm_tree_cons (NULL_TREE
, value
, pending_statics
);
1690 /* Static consts need not be initialized in the class definition. */
1691 if (init
!= NULL_TREE
&& TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (value
)))
1693 static int explanation
= 0;
1695 error ("initializer invalid for static member with constructor");
1696 if (explanation
++ == 0)
1697 error ("(you really want to initialize it separately)");
1700 /* Force the compiler to know when an uninitialized static
1701 const member is being used. */
1702 if (TYPE_READONLY (value
) && init
== 0)
1703 TREE_USED (value
) = 1;
1705 DECL_INITIAL (value
) = init
;
1706 DECL_IN_AGGR_P (value
) = 1;
1707 DECL_CONTEXT (value
) = current_class_type
;
1708 DECL_CLASS_CONTEXT (value
) = current_class_type
;
1710 cp_finish_decl (value
, init
, asmspec_tree
, 1, flags
);
1711 pushdecl_class_level (value
);
1714 if (TREE_CODE (value
) == FIELD_DECL
)
1718 /* This must override the asm specifier which was placed
1719 by grokclassfn. Lay this out fresh. */
1720 DECL_RTL (value
) = NULL_RTX
;
1721 DECL_ASSEMBLER_NAME (value
) = get_identifier (asmspec
);
1723 if (DECL_INITIAL (value
) == error_mark_node
)
1724 init
= error_mark_node
;
1725 cp_finish_decl (value
, init
, asmspec_tree
, 1, flags
);
1726 DECL_INITIAL (value
) = init
;
1727 DECL_IN_AGGR_P (value
) = 1;
1730 if (TREE_CODE (value
) == FUNCTION_DECL
)
1732 check_default_args (value
);
1733 if (DECL_CHAIN (value
) != NULL_TREE
)
1735 /* Need a fresh node here so that we don't get circularity
1736 when we link these together. */
1737 value
= copy_node (value
);
1738 /* When does this happen? */
1739 my_friendly_assert (init
== NULL_TREE
, 193);
1743 /* This must override the asm specifier which was placed
1744 by grokclassfn. Lay this out fresh. */
1745 DECL_RTL (value
) = NULL_RTX
;
1746 DECL_ASSEMBLER_NAME (value
) = get_identifier (asmspec
);
1748 cp_finish_decl (value
, init
, asmspec_tree
, 1, flags
);
1750 /* Pass friends back this way. */
1751 if (DECL_FRIEND_P (value
))
1752 return void_type_node
;
1754 #if 0 /* Just because a fn is declared doesn't mean we'll try to define it. */
1755 if (current_function_decl
&& ! IS_SIGNATURE (current_class_type
))
1756 cp_error ("method `%#D' of local class must be defined in class body",
1760 DECL_IN_AGGR_P (value
) = 1;
1763 my_friendly_abort (21);
1768 /* Like `grokfield', but for bitfields.
1769 WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node. */
1772 grokbitfield (declarator
, declspecs
, width
)
1773 tree declarator
, declspecs
, width
;
1775 register tree value
= grokdeclarator (declarator
, declspecs
, BITFIELD
,
1778 if (! value
) return NULL_TREE
; /* friends went bad. */
1780 /* Pass friendly classes back. */
1781 if (TREE_CODE (value
) == VOID_TYPE
)
1782 return void_type_node
;
1784 if (TREE_CODE (value
) == TYPE_DECL
)
1786 cp_error ("cannot declare `%D' to be a bitfield type", value
);
1790 if (IS_SIGNATURE (current_class_type
))
1792 error ("field declaration not allowed in signature");
1793 return void_type_node
;
1796 if (DECL_IN_AGGR_P (value
))
1798 cp_error ("`%D' is already defined in the class %T", value
,
1799 DECL_CONTEXT (value
));
1800 return void_type_node
;
1803 GNU_xref_member (current_class_name
, value
);
1805 if (TREE_STATIC (value
))
1807 cp_error ("static member `%D' cannot be a bitfield", value
);
1810 cp_finish_decl (value
, NULL_TREE
, NULL_TREE
, 0, 0);
1812 if (width
!= error_mark_node
)
1814 constant_expression_warning (width
);
1815 DECL_INITIAL (value
) = width
;
1816 DECL_BIT_FIELD (value
) = 1;
1819 DECL_IN_AGGR_P (value
) = 1;
1824 grokoptypename (declspecs
, declarator
)
1825 tree declspecs
, declarator
;
1827 tree t
= grokdeclarator (declarator
, declspecs
, TYPENAME
, 0, NULL_TREE
);
1828 return build_typename_overload (t
);
1831 /* When a function is declared with an initializer,
1832 do the right thing. Currently, there are two possibilities:
1837 // initialization possibility #1.
1838 virtual void f () = 0;
1860 // initialization possibility #2
1867 copy_assignment_arg_p (parmtype
, virtualp
)
1871 if (current_class_type
== NULL_TREE
)
1874 if (TREE_CODE (parmtype
) == REFERENCE_TYPE
)
1875 parmtype
= TREE_TYPE (parmtype
);
1877 if ((TYPE_MAIN_VARIANT (parmtype
) == current_class_type
)
1879 /* Non-standard hack to support old Booch components. */
1880 || (! virtualp
&& DERIVED_FROM_P (parmtype
, current_class_type
))
1889 grok_function_init (decl
, init
)
1893 /* An initializer for a function tells how this function should
1895 tree type
= TREE_TYPE (decl
);
1897 if (TREE_CODE (type
) == FUNCTION_TYPE
)
1898 cp_error ("initializer specified for non-member function `%D'", decl
);
1900 /* We'll check for this in finish_struct_1. */
1901 else if (DECL_VINDEX (decl
) == NULL_TREE
)
1902 cp_error ("initializer specified for non-virtual method `%D'", decl
);
1904 else if (integer_zerop (init
))
1907 /* Mark this function as being "defined". */
1908 DECL_INITIAL (decl
) = error_mark_node
;
1909 /* pure virtual destructors must be defined. */
1910 /* pure virtual needs to be defined (as abort) only when put in
1911 vtbl. For wellformed call, it should be itself. pr4737 */
1912 if (!DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl
)))
1914 extern tree abort_fndecl
;
1915 /* Give this node rtl from `abort'. */
1916 DECL_RTL (decl
) = DECL_RTL (abort_fndecl
);
1919 DECL_ABSTRACT_VIRTUAL_P (decl
) = 1;
1920 if (DECL_NAME (decl
) == ansi_opname
[(int) MODIFY_EXPR
])
1923 = TREE_VALUE (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl
))));
1925 if (copy_assignment_arg_p (parmtype
, 1))
1926 TYPE_HAS_ABSTRACT_ASSIGN_REF (current_class_type
) = 1;
1929 else if (TREE_CODE (init
) == OFFSET_REF
1930 && TREE_OPERAND (init
, 0) == NULL_TREE
1931 && TREE_CODE (TREE_TYPE (init
)) == METHOD_TYPE
)
1933 tree basetype
= DECL_CLASS_CONTEXT (init
);
1934 tree basefn
= TREE_OPERAND (init
, 1);
1935 if (TREE_CODE (basefn
) != FUNCTION_DECL
)
1936 cp_error ("non-method initializer invalid for method `%D'", decl
);
1937 else if (! BINFO_OFFSET_ZEROP (TYPE_BINFO (DECL_CLASS_CONTEXT (basefn
))))
1938 sorry ("base member function from other than first base class");
1941 tree binfo
= get_binfo (basetype
, TYPE_METHOD_BASETYPE (type
), 1);
1942 if (binfo
== error_mark_node
)
1944 else if (binfo
== 0)
1945 error_not_base_type (TYPE_METHOD_BASETYPE (TREE_TYPE (init
)),
1946 TYPE_METHOD_BASETYPE (type
));
1949 /* Mark this function as being defined,
1950 and give it new rtl. */
1951 DECL_INITIAL (decl
) = error_mark_node
;
1952 DECL_RTL (decl
) = DECL_RTL (basefn
);
1957 cp_error ("invalid initializer for virtual method `%D'", decl
);
1961 cplus_decl_attributes (decl
, attributes
, prefix_attributes
)
1962 tree decl
, attributes
, prefix_attributes
;
1964 if (decl
== NULL_TREE
|| decl
== void_type_node
)
1967 if (TREE_CODE (decl
) == TEMPLATE_DECL
)
1968 decl
= DECL_TEMPLATE_RESULT (decl
);
1970 decl_attributes (decl
, attributes
, prefix_attributes
);
1972 if (TREE_CODE (decl
) == TYPE_DECL
)
1973 SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (decl
), TREE_TYPE (decl
));
1976 /* CONSTRUCTOR_NAME:
1977 Return the name for the constructor (or destructor) for the
1978 specified class. Argument can be RECORD_TYPE, TYPE_DECL, or
1979 IDENTIFIER_NODE. When given a template, this routine doesn't
1980 lose the specialization. */
1983 constructor_name_full (thing
)
1986 if (TREE_CODE (thing
) == TEMPLATE_TYPE_PARM
)
1987 thing
= TYPE_NAME (thing
);
1988 else if (IS_AGGR_TYPE_CODE (TREE_CODE (thing
)))
1990 if (TYPE_WAS_ANONYMOUS (thing
) && TYPE_HAS_CONSTRUCTOR (thing
))
1991 thing
= DECL_NAME (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (thing
), 0));
1993 thing
= TYPE_NAME (thing
);
1995 if (TREE_CODE (thing
) == TYPE_DECL
1996 || (TREE_CODE (thing
) == TEMPLATE_DECL
1997 && TREE_CODE (DECL_TEMPLATE_RESULT (thing
)) == TYPE_DECL
))
1998 thing
= DECL_NAME (thing
);
1999 my_friendly_assert (TREE_CODE (thing
) == IDENTIFIER_NODE
, 197);
2003 /* CONSTRUCTOR_NAME:
2004 Return the name for the constructor (or destructor) for the
2005 specified class. Argument can be RECORD_TYPE, TYPE_DECL, or
2006 IDENTIFIER_NODE. When given a template, return the plain
2007 unspecialized name. */
2010 constructor_name (thing
)
2014 thing
= constructor_name_full (thing
);
2015 t
= IDENTIFIER_TEMPLATE (thing
);
2021 /* Cache the value of this class's main virtual function table pointer
2022 in a register variable. This will save one indirection if a
2023 more than one virtual function call is made this function. */
2028 extern tree base_init_expr
;
2030 if (base_init_expr
== 0
2031 && DECL_CONSTRUCTOR_P (current_function_decl
))
2033 if (processing_template_decl
)
2034 add_tree (build_min_nt
2036 current_member_init_list
, current_base_init_list
));
2038 emit_base_init (current_class_type
, 0);
2042 /* Record the existence of an addressable inline function. */
2045 mark_inline_for_output (decl
)
2048 decl
= DECL_MAIN_VARIANT (decl
);
2049 if (DECL_SAVED_INLINE (decl
))
2051 my_friendly_assert (TREE_PERMANENT (decl
), 363);
2052 DECL_SAVED_INLINE (decl
) = 1;
2054 if (DECL_PENDING_INLINE_INFO (decl
) != 0
2055 && ! DECL_PENDING_INLINE_INFO (decl
)->deja_vu
)
2057 struct pending_inline
*t
= pending_inlines
;
2058 my_friendly_assert (DECL_SAVED_INSNS (decl
) == 0, 198);
2061 if (t
== DECL_PENDING_INLINE_INFO (decl
))
2067 t
= DECL_PENDING_INLINE_INFO (decl
);
2068 t
->next
= pending_inlines
;
2069 pending_inlines
= t
;
2071 DECL_PENDING_INLINE_INFO (decl
) = 0;
2074 saved_inlines
= perm_tree_cons (NULL_TREE
, decl
, saved_inlines
);
2080 temp_name_counter
= 0;
2083 /* Hand off a unique name which can be used for variable we don't really
2084 want to know about anyway, for example, the anonymous variables which
2085 are needed to make references work. Declare this thing so we can use it.
2086 The variable created will be of type TYPE.
2088 STATICP is nonzero if this variable should be static. */
2091 get_temp_name (type
, staticp
)
2095 char buf
[sizeof (AUTO_TEMP_FORMAT
) + 20];
2097 int toplev
= toplevel_bindings_p ();
2099 push_obstacks_nochange ();
2100 if (toplev
|| staticp
)
2102 end_temporary_allocation ();
2103 sprintf (buf
, AUTO_TEMP_FORMAT
, global_temp_name_counter
++);
2104 decl
= pushdecl_top_level (build_decl (VAR_DECL
, get_identifier (buf
), type
));
2108 sprintf (buf
, AUTO_TEMP_FORMAT
, temp_name_counter
++);
2109 decl
= pushdecl (build_decl (VAR_DECL
, get_identifier (buf
), type
));
2111 TREE_USED (decl
) = 1;
2112 TREE_STATIC (decl
) = staticp
;
2113 DECL_ARTIFICIAL (decl
) = 1;
2115 /* If this is a local variable, then lay out its rtl now.
2116 Otherwise, callers of this function are responsible for dealing
2117 with this variable's rtl. */
2121 expand_decl_init (decl
);
2128 /* Get a variable which we can use for multiple assignments.
2129 It is not entered into current_binding_level, because
2130 that breaks things when it comes time to do final cleanups
2131 (which take place "outside" the binding contour of the function). */
2134 get_temp_regvar (type
, init
)
2137 static char buf
[sizeof (AUTO_TEMP_FORMAT
) + 20] = { '_' };
2140 sprintf (buf
+1, AUTO_TEMP_FORMAT
, temp_name_counter
++);
2141 decl
= build_decl (VAR_DECL
, get_identifier (buf
), type
);
2142 TREE_USED (decl
) = 1;
2143 DECL_REGISTER (decl
) = 1;
2146 store_init_value (decl
, init
);
2148 /* We can expand these without fear, since they cannot need
2149 constructors or destructors. */
2151 expand_decl_init (decl
);
2156 /* Finish off the processing of a UNION_TYPE structure.
2157 If there are static members, then all members are
2158 static, and must be laid out together. If the
2159 union is an anonymous union, we arrange for that
2160 as well. PUBLIC_P is nonzero if this union is
2161 not declared static. */
2164 finish_anon_union (anon_union_decl
)
2165 tree anon_union_decl
;
2167 tree type
= TREE_TYPE (anon_union_decl
);
2168 tree field
, main_decl
= NULL_TREE
;
2169 tree elems
= NULL_TREE
;
2170 int public_p
= TREE_PUBLIC (anon_union_decl
);
2171 int static_p
= TREE_STATIC (anon_union_decl
);
2172 int external_p
= DECL_EXTERNAL (anon_union_decl
);
2174 if ((field
= TYPE_FIELDS (type
)) == NULL_TREE
)
2179 error ("global anonymous unions must be declared static");
2183 for (; field
; field
= TREE_CHAIN (field
))
2186 if (TREE_CODE (field
) != FIELD_DECL
)
2189 if (TREE_PRIVATE (field
))
2190 cp_pedwarn_at ("private member `%#D' in anonymous union", field
);
2191 else if (TREE_PROTECTED (field
))
2192 cp_pedwarn_at ("protected member `%#D' in anonymous union", field
);
2194 decl
= build_decl (VAR_DECL
, DECL_NAME (field
), TREE_TYPE (field
));
2195 /* tell `pushdecl' that this is not tentative. */
2196 DECL_INITIAL (decl
) = error_mark_node
;
2197 TREE_PUBLIC (decl
) = public_p
;
2198 TREE_STATIC (decl
) = static_p
;
2199 DECL_EXTERNAL (decl
) = external_p
;
2200 decl
= pushdecl (decl
);
2202 /* Only write out one anon union element--choose the one that
2203 can hold them all. */
2204 if (main_decl
== NULL_TREE
2205 && 1 == simple_cst_equal (DECL_SIZE (decl
),
2206 DECL_SIZE (anon_union_decl
)))
2212 /* ??? This causes there to be no debug info written out
2214 TREE_ASM_WRITTEN (decl
) = 1;
2217 DECL_INITIAL (decl
) = NULL_TREE
;
2218 /* If there's a cleanup to do, it belongs in the
2219 TREE_PURPOSE of the following TREE_LIST. */
2220 elems
= scratch_tree_cons (NULL_TREE
, decl
, elems
);
2221 TREE_TYPE (elems
) = type
;
2227 make_decl_rtl (main_decl
, 0, toplevel_bindings_p ());
2228 DECL_RTL (anon_union_decl
) = DECL_RTL (main_decl
);
2232 warning ("anonymous union with no members");
2237 /* The following call assumes that there are never any cleanups
2238 for anonymous unions--a reasonable assumption. */
2239 expand_anon_union_decl (anon_union_decl
, NULL_TREE
, elems
);
2242 /* Finish and output a table which is generated by the compiler.
2243 NAME is the name to give the table.
2244 TYPE is the type of the table entry.
2245 INIT is all the elements in the table.
2246 PUBLICP is non-zero if this table should be given external access. */
2249 finish_table (name
, type
, init
, publicp
)
2250 tree name
, type
, init
;
2253 tree itype
, atype
, decl
;
2254 static tree empty_table
;
2258 itype
= build_index_type (size_int (list_length (init
) - 1));
2259 atype
= build_cplus_array_type (type
, itype
);
2260 layout_type (atype
);
2262 if (TREE_VALUE (init
) == integer_zero_node
2263 && TREE_CHAIN (init
) == NULL_TREE
)
2266 if (empty_table
== NULL_TREE
)
2269 empty_table
= get_temp_name (atype
, 1);
2270 init
= build (CONSTRUCTOR
, atype
, NULL_TREE
, init
);
2271 TREE_CONSTANT (init
) = 1;
2272 TREE_STATIC (init
) = 1;
2273 DECL_INITIAL (empty_table
) = init
;
2274 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table
)),
2275 IDENTIFIER_POINTER (DECL_NAME (empty_table
)));
2276 cp_finish_decl (empty_table
, NULL_TREE
, asmspec
, 0, 0);
2281 if (name
== NULL_TREE
)
2285 decl
= get_temp_name (atype
, 1);
2289 decl
= build_decl (VAR_DECL
, name
, atype
);
2290 decl
= pushdecl (decl
);
2291 TREE_STATIC (decl
) = 1;
2296 TREE_PUBLIC (decl
) = publicp
;
2297 init
= build (CONSTRUCTOR
, atype
, NULL_TREE
, init
);
2298 TREE_CONSTANT (init
) = 1;
2299 TREE_STATIC (init
) = 1;
2300 DECL_INITIAL (decl
) = init
;
2301 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (decl
)),
2302 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2306 /* This will cause DECL to point to EMPTY_TABLE in rtl-land. */
2307 DECL_EXTERNAL (decl
) = 1;
2308 TREE_STATIC (decl
) = 0;
2310 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table
)),
2311 IDENTIFIER_POINTER (DECL_NAME (empty_table
)));
2314 cp_finish_decl (decl
, NULL_TREE
, asmspec
, 0, 0);
2318 /* Finish processing a builtin type TYPE. It's name is NAME,
2319 its fields are in the array FIELDS. LEN is the number of elements
2320 in FIELDS minus one, or put another way, it is the maximum subscript
2323 It is given the same alignment as ALIGN_TYPE. */
2326 finish_builtin_type (type
, name
, fields
, len
, align_type
)
2335 TYPE_FIELDS (type
) = fields
[0];
2336 for (i
= 0; i
< len
; i
++)
2338 layout_type (TREE_TYPE (fields
[i
]));
2339 DECL_FIELD_CONTEXT (fields
[i
]) = type
;
2340 TREE_CHAIN (fields
[i
]) = fields
[i
+1];
2342 DECL_FIELD_CONTEXT (fields
[i
]) = type
;
2343 DECL_CLASS_CONTEXT (fields
[i
]) = type
;
2344 TYPE_ALIGN (type
) = TYPE_ALIGN (align_type
);
2346 #if 0 /* not yet, should get fixed properly later */
2347 TYPE_NAME (type
) = make_type_decl (get_identifier (name
), type
);
2349 TYPE_NAME (type
) = build_decl (TYPE_DECL
, get_identifier (name
), type
);
2351 TYPE_STUB_DECL (type
) = TYPE_NAME (type
);
2352 layout_decl (TYPE_NAME (type
), 0);
2355 /* Auxiliary functions to make type signatures for
2356 `operator new' and `operator delete' correspond to
2357 what compiler will be expecting. */
2359 extern tree sizetype
;
2362 coerce_new_type (type
)
2367 if (TREE_CODE (type
) == METHOD_TYPE
)
2368 type
= build_function_type (TREE_TYPE (type
), TREE_CHAIN (TYPE_ARG_TYPES (type
)));
2369 if (TREE_TYPE (type
) != ptr_type_node
)
2370 e1
= 1, error ("`operator new' must return type `void *'");
2372 /* Technically the type must be `size_t', but we may not know
2374 if (TYPE_ARG_TYPES (type
) == NULL_TREE
)
2375 e1
= 1, error ("`operator new' takes type `size_t' parameter");
2376 else if (TREE_CODE (TREE_VALUE (TYPE_ARG_TYPES (type
))) != INTEGER_TYPE
2377 || TYPE_PRECISION (TREE_VALUE (TYPE_ARG_TYPES (type
))) != TYPE_PRECISION (sizetype
))
2378 e2
= 1, error ("`operator new' takes type `size_t' as first parameter");
2380 type
= build_function_type (ptr_type_node
, tree_cons (NULL_TREE
, sizetype
, TREE_CHAIN (TYPE_ARG_TYPES (type
))));
2382 type
= build_function_type (ptr_type_node
, TYPE_ARG_TYPES (type
));
2387 coerce_delete_type (type
)
2390 int e1
= 0, e2
= 0, e3
= 0;
2391 tree arg_types
= TYPE_ARG_TYPES (type
);
2393 if (TREE_CODE (type
) == METHOD_TYPE
)
2395 type
= build_function_type (TREE_TYPE (type
), TREE_CHAIN (arg_types
));
2396 arg_types
= TREE_CHAIN (arg_types
);
2399 if (TREE_TYPE (type
) != void_type_node
)
2400 e1
= 1, error ("`operator delete' must return type `void'");
2402 if (arg_types
== NULL_TREE
2403 || TREE_VALUE (arg_types
) != ptr_type_node
)
2404 e2
= 1, error ("`operator delete' takes type `void *' as first parameter");
2407 && TREE_CHAIN (arg_types
)
2408 && TREE_CHAIN (arg_types
) != void_list_node
)
2410 /* Again, technically this argument must be `size_t', but again
2411 we may not know what that is. */
2412 tree t2
= TREE_VALUE (TREE_CHAIN (arg_types
));
2413 if (TREE_CODE (t2
) != INTEGER_TYPE
2414 || TYPE_PRECISION (t2
) != TYPE_PRECISION (sizetype
))
2415 e3
= 1, error ("second argument to `operator delete' must be of type `size_t'");
2416 else if (TREE_CHAIN (TREE_CHAIN (arg_types
)) != void_list_node
)
2419 if (TREE_CHAIN (TREE_CHAIN (arg_types
)))
2420 error ("too many arguments in declaration of `operator delete'");
2422 error ("`...' invalid in specification of `operator delete'");
2427 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
,
2428 build_tree_list (NULL_TREE
, sizetype
));
2431 if (arg_types
== NULL_TREE
)
2432 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
, void_list_node
);
2434 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
, TREE_CHAIN (arg_types
));
2439 type
= build_function_type (void_type_node
, arg_types
);
2444 extern tree abort_fndecl
;
2447 mark_vtable_entries (decl
)
2450 tree entries
= CONSTRUCTOR_ELTS (DECL_INITIAL (decl
));
2454 tree fnaddr
= (flag_vtable_thunks
? TREE_VALUE (TREE_CHAIN (entries
))
2455 : FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries
)));
2456 tree fn
= TREE_OPERAND (fnaddr
, 0);
2457 TREE_ADDRESSABLE (fn
) = 1;
2460 skip_rtti_stuff (&entries
);
2462 for (; entries
; entries
= TREE_CHAIN (entries
))
2464 tree fnaddr
= (flag_vtable_thunks
? TREE_VALUE (entries
)
2465 : FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries
)));
2466 tree fn
= TREE_OPERAND (fnaddr
, 0);
2467 TREE_ADDRESSABLE (fn
) = 1;
2468 if (DECL_LANG_SPECIFIC (fn
) && DECL_ABSTRACT_VIRTUAL_P (fn
))
2470 TREE_OPERAND (fnaddr
, 0) = fn
= copy_node (fn
);
2471 DECL_RTL (fn
) = DECL_RTL (abort_fndecl
);
2472 mark_used (abort_fndecl
);
2474 if (TREE_CODE (fn
) == THUNK_DECL
&& DECL_EXTERNAL (fn
))
2476 DECL_EXTERNAL (fn
) = 0;
2483 /* Set DECL up to have the closest approximation of "initialized common"
2484 linkage available. */
2487 comdat_linkage (decl
)
2491 make_decl_one_only (decl
);
2493 TREE_PUBLIC (decl
) = 0;
2496 /* Set TREE_PUBLIC and/or DECL_EXTERN on the vtable DECL,
2497 based on TYPE and other static flags.
2499 Note that anything public is tagged TREE_PUBLIC, whether
2500 it's public in this file or in another one. */
2503 import_export_vtable (decl
, type
, final
)
2507 if (DECL_INTERFACE_KNOWN (decl
))
2511 if (write_virtuals
< 2 && write_virtuals
!= 0)
2513 TREE_PUBLIC (decl
) = 1;
2514 if (write_virtuals
< 0)
2515 DECL_EXTERNAL (decl
) = 1;
2516 DECL_INTERFACE_KNOWN (decl
) = 1;
2518 else if (CLASSTYPE_INTERFACE_KNOWN (type
))
2520 TREE_PUBLIC (decl
) = 1;
2521 DECL_EXTERNAL (decl
) = ! CLASSTYPE_VTABLE_NEEDS_WRITING (type
);
2522 DECL_INTERFACE_KNOWN (decl
) = 1;
2526 /* We can only wait to decide if we have real non-inline virtual
2527 functions in our class, or if we come from a template. */
2529 int found
= CLASSTYPE_TEMPLATE_INSTANTIATION (type
);
2531 if (! found
&& ! final
)
2534 for (method
= TYPE_METHODS (type
); method
!= NULL_TREE
;
2535 method
= TREE_CHAIN (method
))
2536 if (DECL_VINDEX (method
) != NULL_TREE
2537 && ! DECL_THIS_INLINE (method
)
2538 && ! DECL_ABSTRACT_VIRTUAL_P (method
))
2545 if (final
|| ! found
)
2547 comdat_linkage (decl
);
2548 DECL_EXTERNAL (decl
) = 0;
2552 TREE_PUBLIC (decl
) = 1;
2553 DECL_EXTERNAL (decl
) = 1;
2559 import_export_template (type
)
2562 if (CLASSTYPE_IMPLICIT_INSTANTIATION (type
)
2563 && ! flag_implicit_templates
2564 && CLASSTYPE_INTERFACE_UNKNOWN (type
))
2566 SET_CLASSTYPE_INTERFACE_KNOWN (type
);
2567 CLASSTYPE_INTERFACE_ONLY (type
) = 1;
2568 CLASSTYPE_VTABLE_NEEDS_WRITING (type
) = 0;
2573 finish_prevtable_vardecl (prev
, vars
)
2576 tree ctype
= DECL_CONTEXT (vars
);
2577 import_export_template (ctype
);
2579 #ifndef MULTIPLE_SYMBOL_SPACES
2580 if (CLASSTYPE_INTERFACE_UNKNOWN (ctype
) && TYPE_VIRTUAL_P (ctype
)
2581 && ! CLASSTYPE_TEMPLATE_INSTANTIATION (ctype
))
2584 for (method
= TYPE_METHODS (ctype
); method
!= NULL_TREE
;
2585 method
= TREE_CHAIN (method
))
2587 if (DECL_VINDEX (method
) != NULL_TREE
2588 && !DECL_THIS_INLINE (method
)
2589 && !DECL_ABSTRACT_VIRTUAL_P (method
))
2591 SET_CLASSTYPE_INTERFACE_KNOWN (ctype
);
2592 CLASSTYPE_VTABLE_NEEDS_WRITING (ctype
)
2593 = ! DECL_REALLY_EXTERN (method
);
2594 CLASSTYPE_INTERFACE_ONLY (ctype
) = DECL_REALLY_EXTERN (method
);
2601 import_export_vtable (vars
, ctype
, 1);
2606 finish_vtable_vardecl (prev
, vars
)
2609 if (write_virtuals
>= 0
2610 && ! DECL_EXTERNAL (vars
)
2611 && ((TREE_PUBLIC (vars
) && ! DECL_WEAK (vars
) && ! DECL_ONE_ONLY (vars
))
2612 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (vars
))
2613 || (hack_decl_function_context (vars
) && TREE_USED (vars
)))
2614 && ! TREE_ASM_WRITTEN (vars
))
2617 mark_vtable_entries (vars
);
2618 if (TREE_TYPE (DECL_INITIAL (vars
)) == 0)
2619 store_init_value (vars
, DECL_INITIAL (vars
));
2621 if (write_symbols
== DWARF_DEBUG
|| write_symbols
== DWARF2_DEBUG
)
2623 /* Mark the VAR_DECL node representing the vtable itself as a
2624 "gratuitous" one, thereby forcing dwarfout.c to ignore it.
2625 It is rather important that such things be ignored because
2626 any effort to actually generate DWARF for them will run
2627 into trouble when/if we encounter code like:
2630 struct S { virtual void member (); };
2632 because the artificial declaration of the vtable itself (as
2633 manufactured by the g++ front end) will say that the vtable
2634 is a static member of `S' but only *after* the debug output
2635 for the definition of `S' has already been output. This causes
2636 grief because the DWARF entry for the definition of the vtable
2637 will try to refer back to an earlier *declaration* of the
2638 vtable as a static member of `S' and there won't be one.
2639 We might be able to arrange to have the "vtable static member"
2640 attached to the member list for `S' before the debug info for
2641 `S' get written (which would solve the problem) but that would
2642 require more intrusive changes to the g++ front end. */
2644 DECL_IGNORED_P (vars
) = 1;
2647 rest_of_decl_compilation (vars
, NULL_PTR
, 1, 1);
2650 else if (! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (vars
)))
2651 /* We don't know what to do with this one yet. */
2654 /* We know that PREV must be non-zero here. */
2655 TREE_CHAIN (prev
) = TREE_CHAIN (vars
);
2660 prune_vtable_vardecl (prev
, vars
)
2663 /* We know that PREV must be non-zero here. */
2664 TREE_CHAIN (prev
) = TREE_CHAIN (vars
);
2669 walk_vtables (typedecl_fn
, vardecl_fn
)
2670 register void (*typedecl_fn
) PROTO ((tree
, tree
));
2671 register int (*vardecl_fn
) PROTO ((tree
, tree
));
2676 for (prev
= 0, vars
= getdecls (); vars
; vars
= TREE_CHAIN (vars
))
2678 register tree type
= TREE_TYPE (vars
);
2680 if (TREE_CODE (vars
) == VAR_DECL
&& DECL_VIRTUAL_P (vars
))
2683 flag
|= (*vardecl_fn
) (prev
, vars
);
2685 if (prev
&& TREE_CHAIN (prev
) != vars
)
2688 else if (TREE_CODE (vars
) == TYPE_DECL
2689 && type
!= error_mark_node
2690 && TYPE_LANG_SPECIFIC (type
)
2691 && CLASSTYPE_VSIZE (type
))
2693 if (typedecl_fn
) (*typedecl_fn
) (prev
, vars
);
2703 finish_sigtable_vardecl (prev
, vars
)
2706 /* We don't need to mark sigtable entries as addressable here as is done
2707 for vtables. Since sigtables, unlike vtables, are always written out,
2708 that was already done in build_signature_table_constructor. */
2710 rest_of_decl_compilation (vars
, NULL_PTR
, 1, 1);
2712 /* We know that PREV must be non-zero here. */
2713 TREE_CHAIN (prev
) = TREE_CHAIN (vars
);
2717 walk_sigtables (typedecl_fn
, vardecl_fn
)
2718 register void (*typedecl_fn
) PROTO((tree
, tree
));
2719 register void (*vardecl_fn
) PROTO((tree
, tree
));
2723 for (prev
= 0, vars
= getdecls (); vars
; vars
= TREE_CHAIN (vars
))
2725 register tree type
= TREE_TYPE (vars
);
2727 if (TREE_CODE (vars
) == TYPE_DECL
2728 && type
!= error_mark_node
2729 && IS_SIGNATURE (type
))
2731 if (typedecl_fn
) (*typedecl_fn
) (prev
, vars
);
2733 else if (TREE_CODE (vars
) == VAR_DECL
2734 && TREE_TYPE (vars
) != error_mark_node
2735 && IS_SIGNATURE (TREE_TYPE (vars
)))
2737 if (vardecl_fn
) (*vardecl_fn
) (prev
, vars
);
2744 /* Determines the proper settings of TREE_PUBLIC and DECL_EXTERNAL for an
2745 inline function or template instantiation at end-of-file. */
2748 import_export_decl (decl
)
2751 if (DECL_INTERFACE_KNOWN (decl
))
2754 if (DECL_TEMPLATE_INSTANTIATION (decl
))
2756 DECL_NOT_REALLY_EXTERN (decl
) = 1;
2757 if (DECL_IMPLICIT_INSTANTIATION (decl
)
2758 && (flag_implicit_templates
|| DECL_THIS_INLINE (decl
)))
2760 if (TREE_CODE (decl
) == FUNCTION_DECL
)
2761 comdat_linkage (decl
);
2762 /* Dynamically initialized vars go into common. */
2763 else if (DECL_INITIAL (decl
) == NULL_TREE
2764 || DECL_INITIAL (decl
) == error_mark_node
)
2765 DECL_COMMON (decl
) = 1;
2766 else if (EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl
)))
2768 DECL_COMMON (decl
) = 1;
2769 DECL_INITIAL (decl
) = error_mark_node
;
2773 /* Statically initialized vars are weak or comdat, if
2776 make_decl_one_only (decl
);
2778 /* we can't do anything useful; leave vars for explicit
2780 DECL_NOT_REALLY_EXTERN (decl
) = 0;
2784 DECL_NOT_REALLY_EXTERN (decl
) = 0;
2786 else if (DECL_FUNCTION_MEMBER_P (decl
))
2788 tree ctype
= DECL_CLASS_CONTEXT (decl
);
2789 if (CLASSTYPE_INTERFACE_KNOWN (ctype
) && ! DECL_ARTIFICIAL (decl
))
2791 DECL_NOT_REALLY_EXTERN (decl
)
2792 = ! (CLASSTYPE_INTERFACE_ONLY (ctype
)
2793 || (DECL_THIS_INLINE (decl
) && ! flag_implement_inlines
));
2796 comdat_linkage (decl
);
2798 /* tinfo function */
2799 else if (DECL_ARTIFICIAL (decl
) && DECL_MUTABLE_P (decl
))
2801 tree ctype
= TREE_TYPE (DECL_NAME (decl
));
2802 if (IS_AGGR_TYPE (ctype
) && CLASSTYPE_INTERFACE_KNOWN (ctype
)
2803 && TYPE_VIRTUAL_P (ctype
))
2805 DECL_NOT_REALLY_EXTERN (decl
)
2806 = ! (CLASSTYPE_INTERFACE_ONLY (ctype
)
2807 || (DECL_THIS_INLINE (decl
) && ! flag_implement_inlines
));
2809 else if (TYPE_BUILT_IN (ctype
) && ctype
== TYPE_MAIN_VARIANT (ctype
))
2810 DECL_NOT_REALLY_EXTERN (decl
) = 0;
2812 comdat_linkage (decl
);
2815 comdat_linkage (decl
);
2817 DECL_INTERFACE_KNOWN (decl
) = 1;
2821 build_cleanup (decl
)
2825 tree type
= TREE_TYPE (decl
);
2827 if (TREE_CODE (type
) == ARRAY_TYPE
)
2831 mark_addressable (decl
);
2832 temp
= build1 (ADDR_EXPR
, build_pointer_type (type
), decl
);
2834 temp
= build_delete (TREE_TYPE (temp
), temp
,
2836 LOOKUP_NORMAL
|LOOKUP_NONVIRTUAL
|LOOKUP_DESTRUCTOR
, 0);
2840 extern int parse_time
, varconst_time
;
2841 extern tree pending_templates
;
2842 extern tree maybe_templates
;
2844 extern struct obstack permanent_obstack
;
2850 tree sname
= get_id_2 ("__sn", base
);
2851 tree sentry
= IDENTIFIER_GLOBAL_VALUE (sname
);
2854 push_obstacks (&permanent_obstack
, &permanent_obstack
);
2855 sentry
= build_decl (VAR_DECL
, sname
, integer_type_node
);
2856 TREE_PUBLIC (sentry
) = 1;
2857 DECL_ARTIFICIAL (sentry
) = 1;
2858 TREE_STATIC (sentry
) = 1;
2859 TREE_USED (sentry
) = 1;
2860 DECL_COMMON (sentry
) = 1;
2861 pushdecl_top_level (sentry
);
2862 cp_finish_decl (sentry
, NULL_TREE
, NULL_TREE
, 0, 0);
2868 /* This routine is called from the last rule in yyparse ().
2869 Its job is to create all the code needed to initialize and
2870 destroy the global aggregates. We do the destruction
2871 first, since that way we only need to reverse the decls once. */
2877 int start_time
, this_time
;
2881 int needs_cleaning
= 0, needs_messing_up
= 0;
2885 /* Bad parse errors. Just forget about it. */
2886 if (! global_bindings_p () || current_class_type
)
2889 start_time
= get_run_time ();
2891 /* Otherwise, GDB can get confused, because in only knows
2892 about source for LINENO-1 lines. */
2895 interface_unknown
= 1;
2898 for (fnname
= pending_templates
; fnname
; fnname
= TREE_CHAIN (fnname
))
2900 tree decl
= TREE_VALUE (fnname
);
2901 if (TREE_CODE_CLASS (TREE_CODE (decl
)) == 't')
2903 instantiate_class_template (decl
);
2904 if (CLASSTYPE_TEMPLATE_INSTANTIATION (decl
))
2905 for (vars
= TYPE_METHODS (decl
); vars
; vars
= TREE_CHAIN (vars
))
2906 if (! DECL_ARTIFICIAL (vars
))
2907 instantiate_decl (vars
);
2910 instantiate_decl (decl
);
2913 for (fnname
= maybe_templates
; fnname
; fnname
= TREE_CHAIN (fnname
))
2915 tree args
, fn
, decl
= TREE_VALUE (fnname
);
2917 if (DECL_INITIAL (decl
))
2920 fn
= TREE_PURPOSE (fnname
);
2921 args
= get_bindings (fn
, decl
);
2922 fn
= instantiate_template (fn
, args
);
2923 instantiate_decl (fn
);
2926 /* Push into C language context, because that's all
2928 push_lang_context (lang_name_c
);
2931 /* The reason for pushing garbage onto the global_binding_level is to
2932 ensure that we can slice out _DECLs which pertain to virtual function
2933 tables. If the last thing pushed onto the global_binding_level was a
2934 virtual function table, then slicing it out would slice away all the
2935 decls (i.e., we lose the head of the chain).
2937 There are several ways of getting the same effect, from changing the
2938 way that iterators over the chain treat the elements that pertain to
2939 virtual function tables, moving the implementation of this code to
2940 decl.c (where we can manipulate global_binding_level directly),
2941 popping the garbage after pushing it and slicing away the vtable
2942 stuff, or just leaving it alone. */
2944 /* Make last thing in global scope not be a virtual function table. */
2945 #if 0 /* not yet, should get fixed properly later */
2946 vars
= make_type_decl (get_identifier (" @%$#@!"), integer_type_node
);
2948 vars
= build_decl (TYPE_DECL
, get_identifier (" @%$#@!"), integer_type_node
);
2950 DECL_IGNORED_P (vars
) = 1;
2951 SET_DECL_ARTIFICIAL (vars
);
2955 /* Walk to mark the inline functions we need, then output them so
2956 that we can pick up any other tdecls that those routines need. */
2957 walk_vtables ((void (*) PROTO ((tree
, tree
))) 0,
2958 finish_prevtable_vardecl
);
2960 for (vars
= pending_statics
; vars
; vars
= TREE_CHAIN (vars
))
2962 tree decl
= TREE_VALUE (vars
);
2964 if (DECL_TEMPLATE_INSTANTIATION (decl
)
2965 && ! DECL_IN_AGGR_P (decl
))
2967 import_export_decl (decl
);
2968 DECL_EXTERNAL (decl
) = ! DECL_NOT_REALLY_EXTERN (decl
);
2972 for (vars
= static_aggregates
; vars
; vars
= TREE_CHAIN (vars
))
2973 if (! TREE_ASM_WRITTEN (TREE_VALUE (vars
)))
2974 rest_of_decl_compilation (TREE_VALUE (vars
), 0, 1, 1);
2975 vars
= static_aggregates
;
2977 if (static_ctors
|| vars
|| register_exception_table_p ())
2978 needs_messing_up
= 1;
2982 /* See if we really need the hassle. */
2983 while (vars
&& needs_cleaning
== 0)
2985 tree decl
= TREE_VALUE (vars
);
2986 tree type
= TREE_TYPE (decl
);
2987 if (TYPE_NEEDS_DESTRUCTOR (type
) && ! TREE_STATIC (vars
))
2993 vars
= TREE_CHAIN (vars
);
2996 if (needs_cleaning
== 0)
2999 fnname
= get_file_function_name ('D');
3000 start_function (void_list_node
,
3001 make_call_declarator (fnname
, void_list_node
, NULL_TREE
,
3004 fnname
= DECL_ASSEMBLER_NAME (current_function_decl
);
3005 store_parm_decls ();
3010 expand_start_bindings (0);
3012 /* These must be done in backward order to destroy,
3013 in which they happen to be! */
3014 for (vars
= static_aggregates
; vars
; vars
= TREE_CHAIN (vars
))
3016 tree decl
= TREE_VALUE (vars
);
3017 tree type
= TREE_TYPE (decl
);
3018 tree temp
= TREE_PURPOSE (vars
);
3020 if (TYPE_NEEDS_DESTRUCTOR (type
) && ! TREE_STATIC (vars
)
3021 && ! DECL_EXTERNAL (decl
))
3023 int protect
= (TREE_PUBLIC (decl
) && (DECL_COMMON (decl
)
3024 || DECL_ONE_ONLY (decl
)
3025 || DECL_WEAK (decl
)));
3027 temp
= build_cleanup (decl
);
3031 tree sentry
= get_sentry (DECL_ASSEMBLER_NAME (decl
));
3032 sentry
= build_unary_op (PREDECREMENT_EXPR
, sentry
, 0);
3033 sentry
= build_binary_op (EQ_EXPR
, sentry
, integer_zero_node
, 1);
3034 expand_start_cond (sentry
, 0);
3037 expand_expr_stmt (temp
);
3044 for (; static_dtors
; static_dtors
= TREE_CHAIN (static_dtors
))
3045 expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors
),
3048 expand_end_bindings (getdecls (), 1, 0);
3052 finish_function (lineno
, 0, 0);
3054 assemble_destructor (IDENTIFIER_POINTER (fnname
));
3056 /* if it needed cleaning, then it will need messing up: drop through */
3059 /* Must do this while we think we are at the top level. */
3060 vars
= nreverse (static_aggregates
);
3061 if (needs_messing_up
)
3063 fnname
= get_file_function_name ('I');
3064 start_function (void_list_node
,
3065 make_call_declarator (fnname
, void_list_node
, NULL_TREE
,
3068 fnname
= DECL_ASSEMBLER_NAME (current_function_decl
);
3069 store_parm_decls ();
3074 expand_start_bindings (0);
3076 if (register_exception_table_p ())
3077 register_exception_table ();
3081 tree decl
= TREE_VALUE (vars
);
3082 tree init
= TREE_PURPOSE (vars
);
3084 /* If this was a static attribute within some function's scope,
3085 then don't initialize it here. Also, don't bother
3086 with initializers that contain errors. */
3087 if (TREE_STATIC (vars
)
3088 || DECL_EXTERNAL (decl
)
3089 || (init
&& TREE_CODE (init
) == TREE_LIST
3090 && value_member (error_mark_node
, init
)))
3093 if (TREE_CODE (decl
) == VAR_DECL
)
3095 int protect
= (TREE_PUBLIC (decl
) && (DECL_COMMON (decl
)
3096 || DECL_ONE_ONLY (decl
)
3097 || DECL_WEAK (decl
)));
3099 /* Set these global variables so that GDB at least puts
3100 us near the declaration which required the initialization. */
3101 input_filename
= DECL_SOURCE_FILE (decl
);
3102 lineno
= DECL_SOURCE_LINE (decl
);
3103 emit_note (input_filename
, lineno
);
3105 /* 9.5p5: The initializer of a static member of a class has
3106 the same access rights as a member function. */
3107 DECL_CLASS_CONTEXT (current_function_decl
) = DECL_CONTEXT (decl
);
3108 DECL_STATIC_FUNCTION_P (current_function_decl
) = 1;
3112 tree sentry
= get_sentry (DECL_ASSEMBLER_NAME (decl
));
3113 sentry
= build_unary_op (PREINCREMENT_EXPR
, sentry
, 0);
3114 sentry
= build_binary_op
3115 (EQ_EXPR
, sentry
, integer_one_node
, 1);
3116 expand_start_cond (sentry
, 0);
3119 expand_start_target_temps ();
3121 if (IS_AGGR_TYPE (TREE_TYPE (decl
))
3122 || TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
3123 expand_aggr_init (decl
, init
, 0, 0);
3124 else if (TREE_CODE (init
) == TREE_VEC
)
3126 expand_expr (expand_vec_init (decl
, TREE_VEC_ELT (init
, 0),
3127 TREE_VEC_ELT (init
, 1),
3128 TREE_VEC_ELT (init
, 2), 0),
3129 const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
3132 expand_assignment (decl
, init
, 0, 0);
3134 /* Cleanup any temporaries needed for the initial value. */
3135 expand_end_target_temps ();
3140 DECL_CLASS_CONTEXT (current_function_decl
) = NULL_TREE
;
3141 DECL_STATIC_FUNCTION_P (current_function_decl
) = 0;
3143 else if (decl
== error_mark_node
)
3145 else my_friendly_abort (22);
3148 vars
= TREE_CHAIN (vars
);
3151 for (; static_ctors
; static_ctors
= TREE_CHAIN (static_ctors
))
3152 expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors
),
3155 expand_end_bindings (getdecls (), 1, 0);
3159 finish_function (lineno
, 0, 0);
3160 assemble_constructor (IDENTIFIER_POINTER (fnname
));
3163 expand_builtin_throw ();
3165 permanent_allocation (1);
3167 /* Done with C language context needs. */
3168 pop_lang_context ();
3170 /* Now write out any static class variables (which may have since
3171 learned how to be initialized). */
3172 while (pending_statics
)
3174 tree decl
= TREE_VALUE (pending_statics
);
3176 /* Output DWARF debug information. */
3177 #ifdef DWARF_DEBUGGING_INFO
3178 if (write_symbols
== DWARF_DEBUG
)
3179 dwarfout_file_scope_decl (decl
, 1);
3181 #ifdef DWARF2_DEBUGGING_INFO
3182 if (write_symbols
== DWARF2_DEBUG
)
3183 dwarf2out_decl (decl
);
3186 DECL_DEFER_OUTPUT (decl
) = 0;
3187 rest_of_decl_compilation
3188 (decl
, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)), 1, 1);
3190 pending_statics
= TREE_CHAIN (pending_statics
);
3193 this_time
= get_run_time ();
3194 parse_time
-= this_time
- start_time
;
3195 varconst_time
+= this_time
- start_time
;
3197 start_time
= get_run_time ();
3199 if (flag_handle_signatures
)
3200 walk_sigtables ((void (*) PROTO ((tree
, tree
))) 0,
3201 finish_sigtable_vardecl
);
3203 for (fnname
= saved_inlines
; fnname
; fnname
= TREE_CHAIN (fnname
))
3205 tree decl
= TREE_VALUE (fnname
);
3206 import_export_decl (decl
);
3209 /* Now write out inline functions which had their addresses taken and
3210 which were not declared virtual and which were not declared `extern
3213 int reconsider
= 1; /* More may be referenced; check again */
3217 tree
*p
= &saved_inlines
;
3220 /* We need to do this each time so that newly completed template
3221 types don't wind up at the front of the list. Sigh. */
3222 vars
= build_decl (TYPE_DECL
, make_anon_name (), integer_type_node
);
3223 DECL_IGNORED_P (vars
) = 1;
3224 SET_DECL_ARTIFICIAL (vars
);
3227 reconsider
|= walk_vtables ((void (*) PROTO((tree
, tree
))) 0,
3228 finish_vtable_vardecl
);
3232 tree decl
= TREE_VALUE (*p
);
3234 if (DECL_ARTIFICIAL (decl
) && ! DECL_INITIAL (decl
)
3236 && (! DECL_REALLY_EXTERN (decl
) || DECL_INLINE (decl
)))
3238 if (DECL_MUTABLE_P (decl
))
3239 synthesize_tinfo_fn (decl
);
3241 synthesize_method (decl
);
3245 /* Catch new template instantiations. */
3246 if (decl
!= TREE_VALUE (*p
))
3249 if (TREE_ASM_WRITTEN (decl
)
3250 || (DECL_SAVED_INSNS (decl
) == 0 && ! DECL_ARTIFICIAL (decl
)))
3251 *p
= TREE_CHAIN (*p
);
3252 else if (DECL_INITIAL (decl
) == 0)
3253 p
= &TREE_CHAIN (*p
);
3254 else if ((TREE_PUBLIC (decl
) && ! DECL_WEAK (decl
)
3255 && ! DECL_ONE_ONLY (decl
))
3256 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))
3257 || flag_keep_inline_functions
)
3259 if (DECL_NOT_REALLY_EXTERN (decl
))
3261 DECL_EXTERNAL (decl
) = 0;
3263 /* We can't inline this function after it's been
3264 emitted. We want a variant of
3265 output_inline_function that doesn't prevent
3266 subsequent integration... */
3267 DECL_INLINE (decl
) = 0;
3268 output_inline_function (decl
);
3269 permanent_allocation (1);
3272 *p
= TREE_CHAIN (*p
);
3275 p
= &TREE_CHAIN (*p
);
3280 /* Now delete from the chain of variables all virtual function tables.
3281 We output them all ourselves, because each will be treated specially. */
3283 walk_vtables ((void (*) PROTO((tree
, tree
))) 0,
3284 prune_vtable_vardecl
);
3286 if (write_virtuals
== 2)
3288 /* Now complain about an virtual function tables promised
3289 but not delivered. */
3290 while (pending_vtables
)
3292 if (TREE_PURPOSE (pending_vtables
) == NULL_TREE
)
3293 error ("virtual function table for `%s' not defined",
3294 IDENTIFIER_POINTER (TREE_VALUE (pending_vtables
)));
3295 pending_vtables
= TREE_CHAIN (pending_vtables
);
3301 this_time
= get_run_time ();
3302 parse_time
-= this_time
- start_time
;
3303 varconst_time
+= this_time
- start_time
;
3305 if (flag_detailed_statistics
)
3307 dump_tree_statistics ();
3308 dump_time_statistics ();
3312 /* This is something of the form 'A()()()()()+1' that has turned out to be an
3313 expr. Since it was parsed like a type, we need to wade through and fix
3314 that. Unfortunately, since operator() is left-associative, we can't use
3315 tail recursion. In the above example, TYPE is `A', and DECL is
3318 Maybe this shouldn't be recursive, but how often will it actually be
3322 reparse_absdcl_as_expr (type
, decl
)
3325 /* do build_functional_cast (type, NULL_TREE) at bottom */
3326 if (TREE_OPERAND (decl
, 0) == NULL_TREE
)
3327 return build_functional_cast (type
, NULL_TREE
);
3330 decl
= reparse_decl_as_expr (type
, TREE_OPERAND (decl
, 0));
3332 decl
= build_x_function_call (decl
, NULL_TREE
, current_class_ref
);
3334 if (TREE_CODE (decl
) == CALL_EXPR
&& TREE_TYPE (decl
) != void_type_node
)
3335 decl
= require_complete_type (decl
);
3340 /* This is something of the form `int ((int)(int)(int)1)' that has turned
3341 out to be an expr. Since it was parsed like a type, we need to wade
3342 through and fix that. Since casts are right-associative, we are
3343 reversing the order, so we don't have to recurse.
3345 In the above example, DECL is the `(int)(int)(int)', and EXPR is the
3349 reparse_absdcl_as_casts (decl
, expr
)
3354 if (TREE_CODE (expr
) == CONSTRUCTOR
3355 && TREE_TYPE (expr
) == 0)
3357 type
= groktypename (TREE_VALUE (TREE_OPERAND (decl
, 1)));
3358 decl
= TREE_OPERAND (decl
, 0);
3360 if (IS_SIGNATURE (type
))
3362 error ("cast specifies signature type");
3363 return error_mark_node
;
3366 expr
= digest_init (type
, expr
, (tree
*) 0);
3367 if (TREE_CODE (type
) == ARRAY_TYPE
&& TYPE_SIZE (type
) == 0)
3369 int failure
= complete_array_type (type
, expr
, 1);
3371 my_friendly_abort (78);
3377 type
= groktypename (TREE_VALUE (TREE_OPERAND (decl
, 1)));
3378 decl
= TREE_OPERAND (decl
, 0);
3379 expr
= build_c_cast (type
, expr
);
3382 if (warn_old_style_cast
)
3383 warning ("use of old-style cast");
3388 /* Given plain tree nodes for an expression, build up the full semantics. */
3391 build_expr_from_tree (t
)
3394 if (t
== NULL_TREE
|| t
== error_mark_node
)
3397 switch (TREE_CODE (t
))
3399 case IDENTIFIER_NODE
:
3400 return do_identifier (t
, 0);
3403 if (LOOKUP_EXPR_GLOBAL (t
))
3404 return do_scoped_id (TREE_OPERAND (t
, 0), 0);
3406 return do_identifier (TREE_OPERAND (t
, 0), 0);
3408 case TEMPLATE_ID_EXPR
:
3409 return lookup_template_function (build_expr_from_tree
3410 (TREE_OPERAND (t
, 0)),
3411 build_expr_from_tree
3412 (TREE_OPERAND (t
, 1)));
3415 return build_x_indirect_ref
3416 (build_expr_from_tree (TREE_OPERAND (t
, 0)), "unary *");
3419 return build_functional_cast
3420 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3422 case REINTERPRET_CAST_EXPR
:
3423 return build_reinterpret_cast
3424 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3426 case CONST_CAST_EXPR
:
3427 return build_const_cast
3428 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3430 case DYNAMIC_CAST_EXPR
:
3431 return build_dynamic_cast
3432 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3434 case STATIC_CAST_EXPR
:
3435 return build_static_cast
3436 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3438 case PREDECREMENT_EXPR
:
3439 case PREINCREMENT_EXPR
:
3440 case POSTDECREMENT_EXPR
:
3441 case POSTINCREMENT_EXPR
:
3445 case TRUTH_NOT_EXPR
:
3447 case CONVERT_EXPR
: /* Unary + */
3450 return build_x_unary_op (TREE_CODE (t
),
3451 build_expr_from_tree (TREE_OPERAND (t
, 0)));
3456 case TRUNC_DIV_EXPR
:
3458 case FLOOR_DIV_EXPR
:
3459 case ROUND_DIV_EXPR
:
3460 case EXACT_DIV_EXPR
:
3462 case BIT_ANDTC_EXPR
:
3465 case TRUNC_MOD_EXPR
:
3466 case FLOOR_MOD_EXPR
:
3467 case TRUTH_ANDIF_EXPR
:
3468 case TRUTH_ORIF_EXPR
:
3469 case TRUTH_AND_EXPR
:
3484 return build_x_binary_op
3486 build_expr_from_tree (TREE_OPERAND (t
, 0)),
3487 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3490 return build_m_component_ref
3491 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3492 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3495 return build_offset_ref (TREE_OPERAND (t
, 0), TREE_OPERAND (t
, 1));
3498 if (TREE_OPERAND (t
, 0) == NULL_TREE
)
3500 return build_parse_node (ARRAY_REF
, NULL_TREE
,
3501 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3502 return grok_array_decl (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3503 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3507 tree r
= build_expr_from_tree (TREE_OPERAND (t
, 0));
3508 if (TREE_CODE_CLASS (TREE_CODE (r
)) != 't')
3510 return c_sizeof (r
);
3514 return build_x_modify_expr
3515 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3516 TREE_CODE (TREE_OPERAND (t
, 1)),
3517 build_expr_from_tree (TREE_OPERAND (t
, 2)));
3520 return build_x_arrow
3521 (build_expr_from_tree (TREE_OPERAND (t
, 0)));
3525 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3526 build_expr_from_tree (TREE_OPERAND (t
, 1)),
3527 build_expr_from_tree (TREE_OPERAND (t
, 2)),
3528 NEW_EXPR_USE_GLOBAL (t
));
3531 return delete_sanity
3532 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3533 build_expr_from_tree (TREE_OPERAND (t
, 1)),
3534 DELETE_EXPR_USE_VEC (t
), DELETE_EXPR_USE_GLOBAL (t
));
3537 if (TREE_OPERAND (t
, 1) == NULL_TREE
)
3538 return build_x_compound_expr
3539 (build_expr_from_tree (TREE_OPERAND (t
, 0)));
3541 my_friendly_abort (42);
3543 case METHOD_CALL_EXPR
:
3544 if (TREE_CODE (TREE_OPERAND (t
, 0)) == SCOPE_REF
)
3546 tree ref
= TREE_OPERAND (t
, 0);
3547 return build_scoped_method_call
3548 (build_expr_from_tree (TREE_OPERAND (t
, 1)),
3549 build_expr_from_tree (TREE_OPERAND (ref
, 0)),
3550 TREE_OPERAND (ref
, 1),
3551 build_expr_from_tree (TREE_OPERAND (t
, 2)));
3553 return build_method_call
3554 (build_expr_from_tree (TREE_OPERAND (t
, 1)),
3555 TREE_OPERAND (t
, 0),
3556 build_expr_from_tree (TREE_OPERAND (t
, 2)),
3557 NULL_TREE
, LOOKUP_NORMAL
);
3560 if (TREE_CODE (TREE_OPERAND (t
, 0)) == SCOPE_REF
)
3562 tree ref
= TREE_OPERAND (t
, 0);
3563 return build_member_call
3564 (build_expr_from_tree (TREE_OPERAND (ref
, 0)),
3565 TREE_OPERAND (ref
, 1),
3566 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3570 tree name
= TREE_OPERAND (t
, 0);
3571 if (! really_overloaded_fn (name
))
3572 name
= build_expr_from_tree (name
);
3573 return build_x_function_call
3574 (name
, build_expr_from_tree (TREE_OPERAND (t
, 1)),
3579 return build_x_conditional_expr
3580 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3581 build_expr_from_tree (TREE_OPERAND (t
, 1)),
3582 build_expr_from_tree (TREE_OPERAND (t
, 2)));
3586 tree purpose
, value
, chain
;
3588 if (t
== void_list_node
)
3591 purpose
= TREE_PURPOSE (t
);
3593 purpose
= build_expr_from_tree (purpose
);
3594 value
= TREE_VALUE (t
);
3596 value
= build_expr_from_tree (value
);
3597 chain
= TREE_CHAIN (t
);
3598 if (chain
&& chain
!= void_type_node
)
3599 chain
= build_expr_from_tree (chain
);
3600 return expr_tree_cons (purpose
, value
, chain
);
3604 return build_x_component_ref
3605 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3606 TREE_OPERAND (t
, 1), NULL_TREE
, 1);
3609 return build_throw (build_expr_from_tree (TREE_OPERAND (t
, 0)));
3613 tree r
= build_nt (CONSTRUCTOR
, NULL_TREE
,
3614 build_expr_from_tree (CONSTRUCTOR_ELTS (t
)));
3617 return digest_init (TREE_TYPE (t
), r
, 0);
3622 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t
, 0))) == 't')
3623 return get_typeid (TREE_OPERAND (t
, 0));
3624 return build_x_typeid (build_expr_from_tree (TREE_OPERAND (t
, 0)));
3627 return convert_from_reference (t
);
3634 /* This is something of the form `int (*a)++' that has turned out to be an
3635 expr. It was only converted into parse nodes, so we need to go through
3636 and build up the semantics. Most of the work is done by
3637 build_expr_from_tree, above.
3639 In the above example, TYPE is `int' and DECL is `*a'. */
3642 reparse_decl_as_expr (type
, decl
)
3645 decl
= build_expr_from_tree (decl
);
3647 return build_functional_cast (type
, build_expr_list (NULL_TREE
, decl
));
3652 /* This is something of the form `int (*a)' that has turned out to be a
3653 decl. It was only converted into parse nodes, so we need to do the
3654 checking that make_{pointer,reference}_declarator do. */
3657 finish_decl_parsing (decl
)
3660 extern int current_class_depth
;
3662 switch (TREE_CODE (decl
))
3664 case IDENTIFIER_NODE
:
3667 return make_pointer_declarator
3668 (NULL_TREE
, finish_decl_parsing (TREE_OPERAND (decl
, 0)));
3670 return make_reference_declarator
3671 (NULL_TREE
, finish_decl_parsing (TREE_OPERAND (decl
, 0)));
3673 TREE_OPERAND (decl
, 0) = finish_decl_parsing (TREE_OPERAND (decl
, 0));
3676 push_nested_class (TREE_TYPE (TREE_OPERAND (decl
, 0)), 3);
3677 TREE_COMPLEXITY (decl
) = current_class_depth
;
3680 TREE_OPERAND (decl
, 0) = finish_decl_parsing (TREE_OPERAND (decl
, 0));
3683 my_friendly_abort (5);
3689 check_cp_case_value (value
)
3692 if (value
== NULL_TREE
)
3695 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
3696 STRIP_TYPE_NOPS (value
);
3698 if (TREE_READONLY_DECL_P (value
))
3700 value
= decl_constant_value (value
);
3701 STRIP_TYPE_NOPS (value
);
3703 value
= fold (value
);
3705 if (TREE_CODE (value
) != INTEGER_CST
3706 && value
!= error_mark_node
)
3708 cp_error ("case label `%E' does not reduce to an integer constant",
3710 value
= error_mark_node
;
3713 /* Promote char or short to int. */
3714 value
= default_conversion (value
);
3716 constant_expression_warning (value
);
3721 tree current_namespace
;
3723 /* Get the inner part of a namespace id. It doesn't have any prefix, nor
3724 postfix. Returns 0 if in global namespace. */
3729 tree x
= current_namespace
;
3731 x
= TREE_PURPOSE (x
);
3735 /* Build up a DECL_ASSEMBLER_NAME for NAME in the current namespace. */
3738 current_namespace_id (name
)
3741 tree old_id
= get_namespace_id ();
3744 /* Global names retain old encoding. */
3748 buf
= (char *) alloca (8 + IDENTIFIER_LENGTH (old_id
)
3749 + IDENTIFIER_LENGTH (name
));
3750 sprintf (buf
, "__ns_%s_%s", IDENTIFIER_POINTER (old_id
),
3751 IDENTIFIER_POINTER (name
));
3752 return get_identifier (buf
);
3756 do_namespace_alias (alias
, namespace)
3757 tree alias
, namespace;
3759 sorry ("namespace alias");
3763 do_toplevel_using_decl (decl
)
3767 if (TREE_CODE (decl
) == SCOPE_REF
3768 && TREE_OPERAND (decl
, 0) == std_node
)
3770 sorry ("using-declaration");
3772 if (decl
== NULL_TREE
|| decl
== error_mark_node
)
3775 if (TREE_CODE (decl
) == SCOPE_REF
)
3776 decl
= resolve_scope_to_name (NULL_TREE
, decl
);
3778 /* Is this the right way to do an id list? */
3779 if (TREE_CODE (decl
) != TREE_LIST
)
3786 pushdecl (TREE_VALUE (decl
));
3787 decl
= TREE_CHAIN (decl
);
3793 do_class_using_decl (decl
)
3798 if (TREE_CODE (decl
) != SCOPE_REF
)
3800 cp_error ("using-declaration for non-member at class scope");
3803 name
= TREE_OPERAND (decl
, 1);
3804 if (TREE_CODE (name
) == BIT_NOT_EXPR
)
3806 cp_error ("using-declaration for destructor");
3810 value
= build_lang_field_decl (USING_DECL
, name
, void_type_node
);
3811 DECL_INITIAL (value
) = TREE_OPERAND (decl
, 0);
3816 do_using_directive (namespace)
3819 if (namespace == std_node
)
3821 sorry ("using directive");
3825 check_default_args (x
)
3828 tree arg
= TYPE_ARG_TYPES (TREE_TYPE (x
));
3829 int saw_def
= 0, i
= 0 - (TREE_CODE (TREE_TYPE (x
)) == METHOD_TYPE
);
3830 for (; arg
&& arg
!= void_list_node
; arg
= TREE_CHAIN (arg
), ++i
)
3832 if (TREE_PURPOSE (arg
))
3836 cp_error ("default argument missing for parameter %P of `%#D'",
3847 TREE_USED (decl
) = 1;
3848 if (processing_template_decl
)
3850 assemble_external (decl
);
3851 /* Is it a synthesized method that needs to be synthesized? */
3852 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_CLASS_CONTEXT (decl
)
3853 && DECL_ARTIFICIAL (decl
) && ! DECL_INITIAL (decl
)
3854 /* Kludge: don't synthesize for default args. */
3855 && current_function_decl
)
3856 synthesize_method (decl
);
3857 if (DECL_LANG_SPECIFIC (decl
) && DECL_TEMPLATE_INFO (decl
))
3858 instantiate_decl (decl
);
3861 /* Helper function for named_class_head_sans_basetype nonterminal. */
3864 handle_class_head (aggr
, scope
, id
)
3865 tree aggr
, scope
, id
;
3867 if (TREE_CODE (id
) == TYPE_DECL
)
3871 cp_error ("`%T' does not have a nested type named `%D'", scope
, id
);
3873 cp_error ("no file-scope type named `%D'", id
);
3876 (aggr
, make_anon_name (), NULL_TREE
, 1);
3877 return TYPE_MAIN_DECL (id
);