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. */
41 extern tree
get_file_function_name ();
51 static tree get_sentry
PROTO((tree
));
52 static void mark_vtable_entries
PROTO((tree
));
53 static void import_export_template
PROTO((tree
));
54 static void grok_function_init
PROTO((tree
, tree
));
55 static int finish_vtable_vardecl
PROTO((tree
, tree
));
56 static int prune_vtable_vardecl
PROTO((tree
, tree
));
57 static void finish_sigtable_vardecl
PROTO((tree
, tree
));
59 extern int current_class_depth
;
61 /* A list of virtual function tables we must make sure to write out. */
64 /* A list of static class variables. This is needed, because a
65 static class variable can be declared inside the class without
66 an initializer, and then initialized, staticly, outside the class. */
69 /* A list of functions which were declared inline, but which we
70 may need to emit outline anyway. */
71 static tree saved_inlines
;
73 /* Used to help generate temporary names which are unique within
74 a function. Reset to 0 by start_function. */
76 int temp_name_counter
;
78 /* Same, but not reset. Local temp variables and global temp variables
79 can have the same name. */
80 static int global_temp_name_counter
;
82 /* Flag used when debugging spew.c */
84 extern int spew_debug
;
86 /* Nonzero if we're done parsing and into end-of-file activities. */
90 /* Functions called along with real static constructors and destructors. */
92 tree static_ctors
, static_dtors
;
94 /* C (and C++) language-specific option variables. */
96 /* Nonzero means allow type mismatches in conditional expressions;
97 just make their values `void'. */
99 int flag_cond_mismatch
;
101 /* Nonzero means give `double' the same size as `float'. */
103 int flag_short_double
;
105 /* Nonzero means don't recognize the keyword `asm'. */
109 /* Nonzero means don't recognize any extension keywords. */
111 int flag_no_gnu_keywords
;
113 /* Nonzero means don't recognize the non-ANSI builtin functions. */
117 /* Nonzero means don't recognize the non-ANSI builtin functions.
120 int flag_no_nonansi_builtin
;
122 /* Nonzero means do some things the same way PCC does. Only provided so
123 the compiler will link. */
125 int flag_traditional
;
127 /* Nonzero means to treat bitfields as unsigned unless they say `signed'. */
129 int flag_signed_bitfields
= 1;
131 /* Nonzero means handle `#ident' directives. 0 means ignore them. */
135 /* Nonzero means enable obscure ANSI features and disable GNU extensions
136 that might cause ANSI-compliant code to be miscompiled. */
140 /* Nonzero means do argument matching for overloading according to the
141 ANSI rules, rather than what g++ used to believe to be correct. */
143 int flag_ansi_overloading
= 1;
145 /* Nonzero means do emit exported implementations of functions even if
146 they can be inlined. */
148 int flag_implement_inlines
= 1;
150 /* Nonzero means do emit exported implementations of templates, instead of
151 multiple static copies in each file that needs a definition. */
153 int flag_external_templates
;
155 /* Nonzero means that the decision to emit or not emit the implementation of a
156 template depends on where the template is instantiated, rather than where
159 int flag_alt_external_templates
;
161 /* Nonzero means that implicit instantiations will be emitted if needed. */
163 int flag_implicit_templates
= 1;
165 /* Nonzero means warn about implicit declarations. */
167 int warn_implicit
= 1;
169 /* Nonzero means warn when all ctors or dtors are private, and the class
172 int warn_ctor_dtor_privacy
= 1;
174 /* True if we want to implement vtables using "thunks".
175 The default is off. */
177 #ifndef DEFAULT_VTABLE_THUNKS
178 #define DEFAULT_VTABLE_THUNKS 0
180 int flag_vtable_thunks
= DEFAULT_VTABLE_THUNKS
;
182 /* True if we want to deal with repository information. */
184 int flag_use_repository
;
186 /* Nonzero means give string constants the type `const char *'
187 to get extra warnings from them. These warnings will be too numerous
188 to be useful, except in thoroughly ANSIfied programs. */
190 int warn_write_strings
;
192 /* Nonzero means warn about pointer casts that can drop a type qualifier
193 from the pointer target type. */
197 /* Nonzero means warn that dbx info for template class methods isn't fully
200 int warn_template_debugging
;
202 /* Nonzero means warn about sizeof(function) or addition/subtraction
203 of function pointers. */
205 int warn_pointer_arith
= 1;
207 /* Nonzero means warn for any function def without prototype decl. */
209 int warn_missing_prototypes
;
211 /* Nonzero means warn about multiple (redundant) decls for the same single
212 variable or function. */
214 int warn_redundant_decls
;
216 /* Warn if initializer is not completely bracketed. */
218 int warn_missing_braces
;
220 /* Warn about comparison of signed and unsigned values. */
222 int warn_sign_compare
;
224 /* Warn about *printf or *scanf format/argument anomalies. */
228 /* Warn about a subscript that has type char. */
230 int warn_char_subscripts
;
232 /* Warn if a type conversion is done that might have confusing results. */
236 /* Warn if adding () is suggested. */
238 int warn_parentheses
;
240 /* Non-zero means warn in function declared in derived class has the
241 same name as a virtual in the base class, but fails to match the
242 type signature of any virtual function in the base class. */
243 int warn_overloaded_virtual
;
245 /* Non-zero means warn when declaring a class that has a non virtual
246 destructor, when it really ought to have a virtual one. */
249 /* Non-zero means warn when a function is declared extern and later inline. */
250 int warn_extern_inline
;
252 /* Non-zero means warn when the compiler will reorder code. */
255 /* Non-zero means warn when synthesis behavior differs from Cfront's. */
258 /* Non-zero means warn when we convert a pointer to member function
259 into a pointer to (void or function). */
260 int warn_pmf2ptr
= 1;
262 /* Nonzero means warn about violation of some Effective C++ style rules. */
266 /* Nonzero means warn where overload resolution chooses a promotion from
267 unsigned to signed over a conversion to an unsigned of the same size. */
271 /* Nonzero means `$' can be in an identifier.
272 See cccp.c for reasons why this breaks some obscure ANSI C programs. */
274 #ifndef DOLLARS_IN_IDENTIFIERS
275 #define DOLLARS_IN_IDENTIFIERS 1
277 int dollars_in_ident
= DOLLARS_IN_IDENTIFIERS
;
279 /* Nonzero for -fno-strict-prototype switch: do not consider empty
280 argument prototype to mean function takes no arguments. */
282 int flag_strict_prototype
= 2;
283 int strict_prototype
= 1;
284 int strict_prototypes_lang_c
, strict_prototypes_lang_cplusplus
= 1;
286 /* Nonzero means that labels can be used as first-class objects */
290 /* Non-zero means to collect statistics which might be expensive
291 and to print them when we are done. */
292 int flag_detailed_statistics
;
294 /* C++ specific flags. */
295 /* Nonzero for -fall-virtual: make every member function (except
296 constructors) lay down in the virtual function table. Calls
297 can then either go through the virtual function table or not,
300 int flag_all_virtual
;
302 /* Zero means that `this' is a *const. This gives nice behavior in the
303 2.0 world. 1 gives 1.2-compatible behavior. 2 gives Spring behavior.
304 -2 means we're constructing an object and it has fixed type. */
306 int flag_this_is_variable
;
308 /* Nonzero means memoize our member lookups. */
310 int flag_memoize_lookups
; int flag_save_memoized_contexts
;
312 /* 3 means write out only virtuals function tables `defined'
313 in this implementation file.
314 2 means write out only specific virtual function tables
315 and give them (C) public access.
316 1 means write out virtual function tables and give them
318 0 means write out virtual function tables and give them
319 (C) static access (default).
320 -1 means declare virtual function tables extern. */
324 /* Nonzero means we should attempt to elide constructors when possible.
325 FIXME: This flag is obsolete, and should be torn out along with the
326 old overloading code. */
328 int flag_elide_constructors
;
330 /* Nonzero means recognize and handle signature language constructs. */
332 int flag_handle_signatures
;
334 /* Nonzero means that member functions defined in class scope are
335 inline by default. */
337 int flag_default_inline
= 1;
339 /* Controls whether enums and ints freely convert.
340 1 means with complete freedom.
341 0 means enums can convert to ints, but not vice-versa. */
342 int flag_int_enum_equivalence
;
344 /* Controls whether compiler generates 'type descriptor' that give
345 run-time type information. */
348 /* Nonzero if we wish to output cross-referencing information
349 for the GNU class browser. */
350 extern int flag_gnu_xref
;
352 /* Nonzero if compiler can make `reasonable' assumptions about
353 references and objects. For example, the compiler must be
354 conservative about the following and not assume that `a' is nonnull:
359 In general, it is `reasonable' to assume that for many programs,
360 and better code can be generated in that case. */
362 int flag_assume_nonnull_objects
= 1;
364 /* Nonzero if we want to support huge (> 2^(sizeof(short)*8-1) bytes)
367 int flag_huge_objects
;
369 /* Nonzero if we want to conserve space in the .o files. We do this
370 by putting uninitialized data and runtime initialized data into
371 .common instead of .data at the expense of not flagging multiple
374 int flag_conserve_space
;
376 /* Nonzero if we want to obey access control semantics. */
378 int flag_access_control
= 1;
380 /* Nonzero if we want to understand the operator names, i.e. 'bitand'. */
382 int flag_operator_names
;
384 /* Nonzero if we want to check the return value of new and avoid calling
385 constructors if it is a null pointer. */
389 /* Nonzero if we want the new ANSI rules for pushing a new scope for `for'
390 initialization variables.
391 0: Old rules, set by -fno-for-scope.
392 2: New ANSI rules, set by -ffor-scope.
393 1: Try to implement new ANSI rules, but with backup compatibility
394 (and warnings). This is the default, for now. */
396 int flag_new_for_scope
= 1;
398 /* Nonzero if we want to emit defined symbols with common-like linkage as
399 weak symbols where possible, in order to conform to C++ semantics.
400 Otherwise, emit them as local symbols. */
404 /* Maximum template instantiation depth. Must be at least 17 for ANSI
407 int max_tinst_depth
= 17;
409 /* The name-mangling scheme to use. Must be 1 or greater to support
410 template functions with identical types, but different template
412 int name_mangling_version
= 1;
414 /* Nonzero means that guiding declarations are allowed. */
415 int flag_guiding_decls
;
417 /* Table of language-dependent -f options.
418 STRING is the option name. VARIABLE is the address of the variable.
419 ON_VALUE is the value to store in VARIABLE
420 if `-fSTRING' is seen as an option.
421 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
423 static struct { char *string
; int *variable
; int on_value
;} lang_f_options
[] =
425 {"signed-char", &flag_signed_char
, 1},
426 {"unsigned-char", &flag_signed_char
, 0},
427 {"signed-bitfields", &flag_signed_bitfields
, 1},
428 {"unsigned-bitfields", &flag_signed_bitfields
, 0},
429 {"short-enums", &flag_short_enums
, 1},
430 {"short-double", &flag_short_double
, 1},
431 {"cond-mismatch", &flag_cond_mismatch
, 1},
432 {"asm", &flag_no_asm
, 0},
433 {"builtin", &flag_no_builtin
, 0},
434 {"ident", &flag_no_ident
, 0},
435 {"labels-ok", &flag_labels_ok
, 1},
436 {"stats", &flag_detailed_statistics
, 1},
437 {"this-is-variable", &flag_this_is_variable
, 1},
438 {"strict-prototype", &flag_strict_prototype
, 1},
439 {"all-virtual", &flag_all_virtual
, 1},
440 {"memoize-lookups", &flag_memoize_lookups
, 1},
441 {"elide-constructors", &flag_elide_constructors
, 1},
442 {"handle-exceptions", &flag_exceptions
, 1},
443 {"handle-signatures", &flag_handle_signatures
, 1},
444 {"default-inline", &flag_default_inline
, 1},
445 {"dollars-in-identifiers", &dollars_in_ident
, 1},
446 {"enum-int-equiv", &flag_int_enum_equivalence
, 1},
447 {"rtti", &flag_rtti
, 1},
448 {"xref", &flag_gnu_xref
, 1},
449 {"nonnull-objects", &flag_assume_nonnull_objects
, 1},
450 {"implement-inlines", &flag_implement_inlines
, 1},
451 {"external-templates", &flag_external_templates
, 1},
452 {"implicit-templates", &flag_implicit_templates
, 1},
453 {"ansi-overloading", &flag_ansi_overloading
, 1},
454 {"huge-objects", &flag_huge_objects
, 1},
455 {"conserve-space", &flag_conserve_space
, 1},
456 {"vtable-thunks", &flag_vtable_thunks
, 1},
457 {"access-control", &flag_access_control
, 1},
458 {"nonansi-builtins", &flag_no_nonansi_builtin
, 0},
459 {"gnu-keywords", &flag_no_gnu_keywords
, 0},
460 {"operator-names", &flag_operator_names
, 1},
461 {"check-new", &flag_check_new
, 1},
462 {"repo", &flag_use_repository
, 1},
463 {"for-scope", &flag_new_for_scope
, 2},
464 {"weak", &flag_weak
, 1}
467 /* Decode the string P as a language-specific option.
468 Return 1 if it is recognized (and handle it);
469 return 0 if not recognized. */
472 lang_decode_option (p
)
475 if (!strcmp (p
, "-ftraditional") || !strcmp (p
, "-traditional"))
476 dollars_in_ident
= 1, flag_writable_strings
= 1,
477 flag_this_is_variable
= 1, flag_new_for_scope
= 0;
478 /* The +e options are for cfront compatibility. They come in as
479 `-+eN', to kludge around gcc.c's argument handling. */
480 else if (p
[0] == '-' && p
[1] == '+' && p
[2] == 'e')
482 int old_write_virtuals
= write_virtuals
;
485 else if (p
[3] == '0')
487 else if (p
[3] == '2')
489 else error ("invalid +e option");
490 if (old_write_virtuals
!= 0
491 && write_virtuals
!= old_write_virtuals
)
492 error ("conflicting +e options given");
494 else if (p
[0] == '-' && p
[1] == 'f')
496 /* Some kind of -f option.
497 P's value is the option sans `-f'.
498 Search for it in the table of options. */
502 /* Try special -f options. */
504 if (!strcmp (p
, "handle-exceptions")
505 || !strcmp (p
, "no-handle-exceptions"))
506 warning ("-fhandle-exceptions has been renamed to -fexceptions (and is now on by default)");
508 if (!strcmp (p
, "save-memoized"))
510 flag_memoize_lookups
= 1;
511 flag_save_memoized_contexts
= 1;
514 else if (!strcmp (p
, "no-save-memoized"))
516 flag_memoize_lookups
= 0;
517 flag_save_memoized_contexts
= 0;
520 else if (! strcmp (p
, "alt-external-templates"))
522 flag_external_templates
= 1;
523 flag_alt_external_templates
= 1;
526 else if (! strcmp (p
, "no-alt-external-templates"))
528 flag_alt_external_templates
= 0;
531 else if (!strcmp (p
, "repo"))
533 flag_use_repository
= 1;
534 flag_implicit_templates
= 0;
537 else if (!strcmp (p
, "guiding-decls"))
539 flag_guiding_decls
= 1;
540 name_mangling_version
= 0;
543 else if (!strcmp (p
, "no-guiding-decls"))
545 flag_guiding_decls
= 0;
548 else if (!strncmp (p
, "template-depth-", 15))
553 if (*endp
>= '0' && *endp
<= '9')
557 error ("Invalid option `%s'", p
- 2);
558 goto template_depth_lose
;
561 max_tinst_depth
= atoi (p
+ 15);
562 template_depth_lose
: ;
564 else if (!strncmp (p
, "name-mangling-version-", 22))
569 if (*endp
>= '0' && *endp
<= '9')
573 error ("Invalid option `%s'", p
- 2);
574 goto mangling_version_lose
;
577 name_mangling_version
= atoi (p
+ 22);
578 mangling_version_lose
:
581 !found
&& j
< sizeof (lang_f_options
) / sizeof (lang_f_options
[0]);
584 if (!strcmp (p
, lang_f_options
[j
].string
))
586 *lang_f_options
[j
].variable
= lang_f_options
[j
].on_value
;
587 /* A goto here would be cleaner,
588 but breaks the vax pcc. */
591 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
592 && ! strcmp (p
+3, lang_f_options
[j
].string
))
594 *lang_f_options
[j
].variable
= ! lang_f_options
[j
].on_value
;
600 else if (p
[0] == '-' && p
[1] == 'W')
604 /* The -W options control the warning behavior of the compiler. */
607 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-')
610 if (!strcmp (p
, "implicit"))
611 warn_implicit
= setting
;
612 else if (!strcmp (p
, "return-type"))
613 warn_return_type
= setting
;
614 else if (!strcmp (p
, "ctor-dtor-privacy"))
615 warn_ctor_dtor_privacy
= setting
;
616 else if (!strcmp (p
, "write-strings"))
617 warn_write_strings
= setting
;
618 else if (!strcmp (p
, "cast-qual"))
619 warn_cast_qual
= setting
;
620 else if (!strcmp (p
, "char-subscripts"))
621 warn_char_subscripts
= setting
;
622 else if (!strcmp (p
, "pointer-arith"))
623 warn_pointer_arith
= setting
;
624 else if (!strcmp (p
, "missing-prototypes"))
625 warn_missing_prototypes
= setting
;
626 else if (!strcmp (p
, "redundant-decls"))
627 warn_redundant_decls
= setting
;
628 else if (!strcmp (p
, "missing-braces"))
629 warn_missing_braces
= setting
;
630 else if (!strcmp (p
, "sign-compare"))
631 warn_sign_compare
= setting
;
632 else if (!strcmp (p
, "format"))
633 warn_format
= setting
;
634 else if (!strcmp (p
, "conversion"))
635 warn_conversion
= setting
;
636 else if (!strcmp (p
, "parentheses"))
637 warn_parentheses
= setting
;
638 else if (!strcmp (p
, "non-virtual-dtor"))
639 warn_nonvdtor
= setting
;
640 else if (!strcmp (p
, "extern-inline"))
641 warn_extern_inline
= setting
;
642 else if (!strcmp (p
, "reorder"))
643 warn_reorder
= setting
;
644 else if (!strcmp (p
, "synth"))
645 warn_synth
= setting
;
646 else if (!strcmp (p
, "pmf-conversions"))
647 warn_pmf2ptr
= setting
;
648 else if (!strcmp (p
, "effc++"))
650 else if (!strcmp (p
, "sign-promo"))
651 warn_sign_promo
= setting
;
652 else if (!strcmp (p
, "comment"))
653 ; /* cpp handles this one. */
654 else if (!strcmp (p
, "comments"))
655 ; /* cpp handles this one. */
656 else if (!strcmp (p
, "trigraphs"))
657 ; /* cpp handles this one. */
658 else if (!strcmp (p
, "import"))
659 ; /* cpp handles this one. */
660 else if (!strcmp (p
, "all"))
662 warn_return_type
= setting
;
663 warn_unused
= setting
;
664 warn_implicit
= setting
;
665 warn_ctor_dtor_privacy
= setting
;
666 warn_switch
= setting
;
667 warn_format
= setting
;
668 warn_parentheses
= setting
;
669 warn_missing_braces
= setting
;
670 warn_sign_compare
= setting
;
671 warn_extern_inline
= setting
;
672 warn_nonvdtor
= setting
;
673 /* We save the value of warn_uninitialized, since if they put
674 -Wuninitialized on the command line, we need to generate a
675 warning about not using it without also specifying -O. */
676 if (warn_uninitialized
!= 1)
677 warn_uninitialized
= (setting
? 2 : 0);
678 warn_template_debugging
= setting
;
679 warn_reorder
= setting
;
680 warn_sign_promo
= setting
;
683 else if (!strcmp (p
, "overloaded-virtual"))
684 warn_overloaded_virtual
= setting
;
687 else if (!strcmp (p
, "-ansi"))
688 dollars_in_ident
= 0, flag_no_nonansi_builtin
= 1, flag_ansi
= 1,
689 flag_no_gnu_keywords
= 1, flag_operator_names
= 1;
691 /* Undocumented, only ever used when you're invoking cc1plus by hand, since
692 it's probably safe to assume no sane person would ever want to use this
693 under normal circumstances. */
694 else if (!strcmp (p
, "-spew-debug"))
703 /* Incorporate `const' and `volatile' qualifiers for member functions.
704 FUNCTION is a TYPE_DECL or a FUNCTION_DECL.
705 QUALS is a list of qualifiers. */
708 grok_method_quals (ctype
, function
, quals
)
709 tree ctype
, function
, quals
;
711 tree fntype
= TREE_TYPE (function
);
712 tree raises
= TYPE_RAISES_EXCEPTIONS (fntype
);
716 extern tree ridpointers
[];
718 if (TREE_VALUE (quals
) == ridpointers
[(int)RID_CONST
])
720 if (TYPE_READONLY (ctype
))
721 error ("duplicate `%s' %s",
722 IDENTIFIER_POINTER (TREE_VALUE (quals
)),
723 (TREE_CODE (function
) == FUNCTION_DECL
724 ? "for member function" : "in type declaration"));
725 ctype
= build_type_variant (ctype
, 1, TYPE_VOLATILE (ctype
));
726 build_pointer_type (ctype
);
728 else if (TREE_VALUE (quals
) == ridpointers
[(int)RID_VOLATILE
])
730 if (TYPE_VOLATILE (ctype
))
731 error ("duplicate `%s' %s",
732 IDENTIFIER_POINTER (TREE_VALUE (quals
)),
733 (TREE_CODE (function
) == FUNCTION_DECL
734 ? "for member function" : "in type declaration"));
735 ctype
= build_type_variant (ctype
, TYPE_READONLY (ctype
), 1);
736 build_pointer_type (ctype
);
739 my_friendly_abort (20);
740 quals
= TREE_CHAIN (quals
);
743 fntype
= build_cplus_method_type (ctype
, TREE_TYPE (fntype
),
744 (TREE_CODE (fntype
) == METHOD_TYPE
745 ? TREE_CHAIN (TYPE_ARG_TYPES (fntype
))
746 : TYPE_ARG_TYPES (fntype
)));
748 fntype
= build_exception_variant (fntype
, raises
);
750 TREE_TYPE (function
) = fntype
;
754 #if 0 /* Not used. */
755 /* This routine replaces cryptic DECL_NAMEs with readable DECL_NAMEs.
756 It leaves DECL_ASSEMBLER_NAMEs with the correct value. */
757 /* This does not yet work with user defined conversion operators
761 substitute_nice_name (decl
)
764 if (DECL_NAME (decl
) && TREE_CODE (DECL_NAME (decl
)) == IDENTIFIER_NODE
)
766 char *n
= decl_as_string (DECL_NAME (decl
), 1);
767 if (n
[strlen (n
) - 1] == ' ')
768 n
[strlen (n
) - 1] = 0;
769 DECL_NAME (decl
) = get_identifier (n
);
774 /* Warn when -fexternal-templates is used and #pragma
775 interface/implementation is not used all the times it should be,
779 warn_if_unknown_interface (decl
)
782 static int already_warned
= 0;
783 if (already_warned
++)
786 if (flag_alt_external_templates
)
788 struct tinst_level
*til
= tinst_for_decl ();
790 char *sf
= input_filename
;
795 input_filename
= til
->file
;
797 cp_warning ("template `%#D' instantiated in file without #pragma interface",
803 cp_warning_at ("template `%#D' defined in file without #pragma interface",
807 /* A subroutine of the parser, to handle a component list. */
810 grok_x_components (specs
, components
)
811 tree specs
, components
;
813 register tree t
, x
, tcode
;
815 /* We just got some friends. They have been recorded elsewhere. */
816 if (components
== void_type_node
)
819 if (components
== NULL_TREE
)
821 t
= groktypename (build_decl_list (specs
, NULL_TREE
));
825 error ("error in component specification");
829 switch (TREE_CODE (t
))
832 /* Static anonymous unions come out as VAR_DECLs. */
833 if (TREE_CODE (TREE_TYPE (t
)) == UNION_TYPE
834 && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_TYPE (t
))))
837 /* We return SPECS here, because in the parser it was ending
838 up with not doing anything to $$, which is what SPECS
844 /* This code may be needed for UNION_TYPEs as
846 tcode
= record_type_node
;
847 if (CLASSTYPE_DECLARED_CLASS (t
))
848 tcode
= class_type_node
;
849 else if (IS_SIGNATURE (t
))
850 tcode
= signature_type_node
;
852 t
= xref_tag (tcode
, TYPE_IDENTIFIER (t
), NULL_TREE
, 0);
853 if (TYPE_CONTEXT (t
))
854 CLASSTYPE_NO_GLOBALIZE (t
) = 1;
860 if (TREE_CODE (t
) == UNION_TYPE
)
861 tcode
= union_type_node
;
863 tcode
= enum_type_node
;
865 t
= xref_tag (tcode
, TYPE_IDENTIFIER (t
), NULL_TREE
, 0);
866 if (TREE_CODE (t
) == UNION_TYPE
&& TYPE_CONTEXT (t
))
867 CLASSTYPE_NO_GLOBALIZE (t
) = 1;
868 if (TREE_CODE (t
) == UNION_TYPE
869 && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t
)))
871 /* See also shadow_tag. */
873 struct pending_inline
**p
;
875 x
= build_lang_field_decl (FIELD_DECL
, NULL_TREE
, t
);
877 /* Wipe out memory of synthesized methods */
878 TYPE_HAS_CONSTRUCTOR (t
) = 0;
879 TYPE_HAS_DEFAULT_CONSTRUCTOR (t
) = 0;
880 TYPE_HAS_INIT_REF (t
) = 0;
881 TYPE_HAS_CONST_INIT_REF (t
) = 0;
882 TYPE_HAS_ASSIGN_REF (t
) = 0;
883 TYPE_HAS_ASSIGNMENT (t
) = 0;
884 TYPE_HAS_CONST_ASSIGN_REF (t
) = 0;
886 q
= &TYPE_METHODS (t
);
889 if (DECL_ARTIFICIAL (*q
))
890 *q
= TREE_CHAIN (*q
);
892 q
= &TREE_CHAIN (*q
);
894 if (TYPE_METHODS (t
))
895 error ("an anonymous union cannot have function members");
897 p
= &pending_inlines
;
898 for (; *p
; *p
= (*p
)->next
)
899 if (DECL_CONTEXT ((*p
)->fndecl
) != t
)
902 else if (TREE_CODE (t
) == ENUMERAL_TYPE
)
903 x
= grok_enum_decls (t
, NULL_TREE
);
910 if (t
!= void_type_node
)
911 error ("empty component declaration");
917 t
= TREE_TYPE (components
);
918 if (TREE_CODE (t
) == ENUMERAL_TYPE
&& TREE_NONLOCAL_FLAG (t
))
919 return grok_enum_decls (t
, components
);
925 /* Classes overload their constituent function names automatically.
926 When a function name is declared in a record structure,
927 its name is changed to it overloaded name. Since names for
928 constructors and destructors can conflict, we place a leading
931 CNAME is the name of the class we are grokking for.
933 FUNCTION is a FUNCTION_DECL. It was created by `grokdeclarator'.
935 FLAGS contains bits saying what's special about today's
936 arguments. 1 == DESTRUCTOR. 2 == OPERATOR.
938 If FUNCTION is a destructor, then we must add the `auto-delete' field
939 as a second parameter. There is some hair associated with the fact
940 that we must "declare" this variable in the manner consistent with the
941 way the rest of the arguments were declared.
943 QUALS are the qualifiers for the this pointer. */
946 grokclassfn (ctype
, cname
, function
, flags
, quals
)
947 tree ctype
, cname
, function
;
948 enum overload_flags flags
;
951 tree fn_name
= DECL_NAME (function
);
955 tree fntype
= TREE_TYPE (function
);
956 tree raises
= TYPE_RAISES_EXCEPTIONS (fntype
);
958 if (fn_name
== NULL_TREE
)
960 error ("name missing for member function");
961 fn_name
= get_identifier ("<anonymous>");
962 DECL_NAME (function
) = fn_name
;
966 qualtype
= grok_method_quals (ctype
, function
, quals
);
970 arg_types
= TYPE_ARG_TYPES (TREE_TYPE (function
));
971 if (TREE_CODE (TREE_TYPE (function
)) == METHOD_TYPE
)
973 /* Must add the class instance variable up front. */
974 /* Right now we just make this a pointer. But later
975 we may wish to make it special. */
976 tree type
= TREE_VALUE (arg_types
);
979 if ((flag_this_is_variable
> 0)
980 && (flags
== DTOR_FLAG
|| DECL_CONSTRUCTOR_P (function
)))
983 if (DECL_CONSTRUCTOR_P (function
))
985 if (TYPE_USES_VIRTUAL_BASECLASSES (ctype
))
987 DECL_CONSTRUCTOR_FOR_VBASE_P (function
) = 1;
988 /* In this case we need "in-charge" flag saying whether
989 this constructor is responsible for initialization
990 of virtual baseclasses or not. */
991 parm
= build_decl (PARM_DECL
, in_charge_identifier
, integer_type_node
);
992 /* Mark the artificial `__in_chrg' parameter as "artificial". */
993 SET_DECL_ARTIFICIAL (parm
);
994 DECL_ARG_TYPE (parm
) = integer_type_node
;
995 TREE_READONLY (parm
) = 1;
996 TREE_CHAIN (parm
) = last_function_parms
;
997 last_function_parms
= parm
;
1001 parm
= build_decl (PARM_DECL
, this_identifier
, type
);
1002 /* Mark the artificial `this' parameter as "artificial". */
1003 SET_DECL_ARTIFICIAL (parm
);
1004 DECL_ARG_TYPE (parm
) = type
;
1005 /* We can make this a register, so long as we don't
1006 accidentally complain if someone tries to take its address. */
1007 DECL_REGISTER (parm
) = 1;
1009 TREE_READONLY (parm
) = 1;
1010 TREE_CHAIN (parm
) = last_function_parms
;
1011 last_function_parms
= parm
;
1014 if (flags
== DTOR_FLAG
)
1017 int len
= sizeof (DESTRUCTOR_DECL_PREFIX
)-1;
1019 arg_types
= hash_tree_chain (integer_type_node
, void_list_node
);
1020 TREE_SIDE_EFFECTS (arg_types
) = 1;
1021 /* Build the overload name. It will look like `7Example'. */
1022 if (IDENTIFIER_TYPE_VALUE (cname
))
1023 dbuf
= build_overload_name (IDENTIFIER_TYPE_VALUE (cname
), 1, 1);
1024 else if (IDENTIFIER_LOCAL_VALUE (cname
))
1025 dbuf
= build_overload_name (TREE_TYPE (IDENTIFIER_LOCAL_VALUE (cname
)), 1, 1);
1027 /* Using ctype fixes the `X::Y::~Y()' crash. The cname has no type when
1028 it's defined out of the class definition, since poplevel_class wipes
1029 it out. This used to be internal error 346. */
1030 dbuf
= build_overload_name (ctype
, 1, 1);
1031 buf
= (char *) alloca (strlen (dbuf
) + sizeof (DESTRUCTOR_DECL_PREFIX
));
1032 bcopy (DESTRUCTOR_DECL_PREFIX
, buf
, len
);
1035 DECL_ASSEMBLER_NAME (function
) = get_identifier (buf
);
1036 parm
= build_decl (PARM_DECL
, in_charge_identifier
, integer_type_node
);
1037 /* Mark the artificial `__in_chrg' parameter as "artificial". */
1038 SET_DECL_ARTIFICIAL (parm
);
1039 TREE_READONLY (parm
) = 1;
1040 DECL_ARG_TYPE (parm
) = integer_type_node
;
1041 /* This is the same chain as DECL_ARGUMENTS (...). */
1042 TREE_CHAIN (last_function_parms
) = parm
;
1044 fntype
= build_cplus_method_type (qualtype
, void_type_node
,
1048 fntype
= build_exception_variant (fntype
, raises
);
1050 TREE_TYPE (function
) = fntype
;
1051 TYPE_HAS_DESTRUCTOR (ctype
) = 1;
1055 tree these_arg_types
;
1057 if (DECL_CONSTRUCTOR_FOR_VBASE_P (function
))
1059 arg_types
= hash_tree_chain (integer_type_node
,
1060 TREE_CHAIN (arg_types
));
1061 fntype
= build_cplus_method_type (qualtype
,
1062 TREE_TYPE (TREE_TYPE (function
)),
1066 fntype
= build_exception_variant (fntype
, raises
);
1068 TREE_TYPE (function
) = fntype
;
1069 arg_types
= TYPE_ARG_TYPES (TREE_TYPE (function
));
1072 these_arg_types
= arg_types
;
1074 if (TREE_CODE (TREE_TYPE (function
)) == FUNCTION_TYPE
)
1075 /* Only true for static member functions. */
1076 these_arg_types
= hash_tree_chain (build_pointer_type (qualtype
),
1079 DECL_ASSEMBLER_NAME (function
)
1080 = build_decl_overload (fn_name
, these_arg_types
,
1081 1 + DECL_CONSTRUCTOR_P (function
));
1084 /* This code is going into the compiler, but currently, it makes
1085 libg++/src/Integer.cc not compile. The problem is that the nice name
1086 winds up going into the symbol table, and conversion operations look
1087 for the manged name. */
1088 substitute_nice_name (function
);
1092 DECL_ARGUMENTS (function
) = last_function_parms
;
1093 /* First approximations. */
1094 DECL_CONTEXT (function
) = ctype
;
1095 DECL_CLASS_CONTEXT (function
) = ctype
;
1098 /* Work on the expr used by alignof (this is only called by the parser). */
1107 if (TREE_CODE (expr
) == COMPONENT_REF
1108 && DECL_BIT_FIELD (TREE_OPERAND (expr
, 1)))
1109 error ("`__alignof__' applied to a bit-field");
1111 if (TREE_CODE (expr
) == INDIRECT_REF
)
1113 best
= t
= TREE_OPERAND (expr
, 0);
1114 bestalign
= TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t
)));
1116 while (TREE_CODE (t
) == NOP_EXPR
1117 && TREE_CODE (TREE_TYPE (TREE_OPERAND (t
, 0))) == POINTER_TYPE
)
1120 t
= TREE_OPERAND (t
, 0);
1121 thisalign
= TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t
)));
1122 if (thisalign
> bestalign
)
1123 best
= t
, bestalign
= thisalign
;
1125 return c_alignof (TREE_TYPE (TREE_TYPE (best
)));
1129 /* ANSI says arrays and fns are converted inside comma.
1130 But we can't convert them in build_compound_expr
1131 because that would break commas in lvalues.
1132 So do the conversion here if operand was a comma. */
1133 if (TREE_CODE (expr
) == COMPOUND_EXPR
1134 && (TREE_CODE (TREE_TYPE (expr
)) == ARRAY_TYPE
1135 || TREE_CODE (TREE_TYPE (expr
)) == FUNCTION_TYPE
))
1136 expr
= default_conversion (expr
);
1137 return c_alignof (TREE_TYPE (expr
));
1141 /* Create an ARRAY_REF, checking for the user doing things backwards
1145 grok_array_decl (array_expr
, index_exp
)
1146 tree array_expr
, index_exp
;
1148 tree type
= TREE_TYPE (array_expr
);
1149 tree p1
, p2
, i1
, i2
;
1151 if (type
== error_mark_node
|| index_exp
== error_mark_node
)
1152 return error_mark_node
;
1153 if (processing_template_decl
)
1154 return build_min (ARRAY_REF
, type
? TREE_TYPE (type
) : NULL_TREE
,
1155 array_expr
, index_exp
);
1157 if (type
== NULL_TREE
)
1159 /* Something has gone very wrong. Assume we are mistakenly reducing
1160 an expression instead of a declaration. */
1161 error ("parser may be lost: is there a '{' missing somewhere?");
1165 if (TREE_CODE (type
) == OFFSET_TYPE
1166 || TREE_CODE (type
) == REFERENCE_TYPE
)
1167 type
= TREE_TYPE (type
);
1169 /* If they have an `operator[]', use that. */
1170 if (TYPE_LANG_SPECIFIC (type
)
1171 && TYPE_OVERLOADS_ARRAY_REF (complete_type (type
)))
1172 return build_opfncall (ARRAY_REF
, LOOKUP_NORMAL
,
1173 array_expr
, index_exp
, NULL_TREE
);
1175 /* Otherwise, create an ARRAY_REF for a pointer or array type. */
1177 if (TREE_CODE (type
) == ARRAY_TYPE
)
1180 p1
= build_expr_type_conversion (WANT_POINTER
, array_expr
, 0);
1182 if (TREE_CODE (TREE_TYPE (index_exp
)) == ARRAY_TYPE
)
1185 p2
= build_expr_type_conversion (WANT_POINTER
, index_exp
, 0);
1187 i1
= build_expr_type_conversion (WANT_INT
| WANT_ENUM
, array_expr
, 0);
1188 i2
= build_expr_type_conversion (WANT_INT
| WANT_ENUM
, index_exp
, 0);
1190 if ((p1
&& i2
) && (i1
&& p2
))
1191 error ("ambiguous conversion for array subscript");
1194 array_expr
= p1
, index_exp
= i2
;
1196 array_expr
= p2
, index_exp
= i1
;
1199 cp_error ("invalid types `%T[%T]' for array subscript",
1200 type
, TREE_TYPE (index_exp
));
1201 return error_mark_node
;
1204 if (array_expr
== error_mark_node
|| index_exp
== error_mark_node
)
1205 error ("ambiguous conversion for array subscript");
1207 return build_array_ref (array_expr
, index_exp
);
1210 /* Given the cast expression EXP, checking out its validity. Either return
1211 an error_mark_node if there was an unavoidable error, return a cast to
1212 void for trying to delete a pointer w/ the value 0, or return the
1213 call to delete. If DOING_VEC is 1, we handle things differently
1214 for doing an array delete. If DOING_VEC is 2, they gave us the
1215 array size as an argument to delete.
1216 Implements ARM $5.3.4. This is called from the parser. */
1219 delete_sanity (exp
, size
, doing_vec
, use_global_delete
)
1221 int doing_vec
, use_global_delete
;
1225 enum tree_code code
;
1226 /* For a regular vector delete (aka, no size argument) we will pass
1227 this down as a NULL_TREE into build_vec_delete. */
1228 tree maxindex
= NULL_TREE
;
1230 if (exp
== error_mark_node
)
1233 if (processing_template_decl
)
1235 t
= build_min (DELETE_EXPR
, void_type_node
, exp
, size
);
1236 DELETE_EXPR_USE_GLOBAL (t
) = use_global_delete
;
1237 DELETE_EXPR_USE_VEC (t
) = doing_vec
;
1241 t
= stabilize_reference (convert_from_reference (exp
));
1242 type
= TREE_TYPE (t
);
1243 code
= TREE_CODE (type
);
1248 maxindex
= build_binary_op (MINUS_EXPR
, size
, integer_one_node
, 1);
1249 pedwarn ("anachronistic use of array size in vector delete");
1254 if (code
!= POINTER_TYPE
)
1256 cp_error ("type `%#T' argument given to `delete', expected pointer",
1258 return error_mark_node
;
1261 /* Deleting a pointer with the value zero is valid and has no effect. */
1262 if (integer_zerop (t
))
1263 return build1 (NOP_EXPR
, void_type_node
, t
);
1266 if (code
== POINTER_TYPE
)
1269 /* As of Valley Forge, you can delete a pointer to constant. */
1270 /* You can't delete a pointer to constant. */
1271 if (TREE_READONLY (TREE_TYPE (type
)))
1273 error ("`const *' cannot be deleted");
1274 return error_mark_node
;
1277 /* You also can't delete functions. */
1278 if (TREE_CODE (TREE_TYPE (type
)) == FUNCTION_TYPE
)
1280 error ("cannot delete a function");
1281 return error_mark_node
;
1286 /* If the type has no destructor, then we should build a regular
1287 delete, instead of a vector delete. Otherwise, we would end
1288 up passing a bogus offset into __builtin_delete, which is
1289 not expecting it. */
1291 && TREE_CODE (type
) == POINTER_TYPE
1292 && !TYPE_HAS_DESTRUCTOR (TREE_TYPE (type
)))
1295 use_global_delete
= 1;
1300 return build_vec_delete (t
, maxindex
, integer_one_node
,
1301 integer_two_node
, use_global_delete
);
1304 if (IS_AGGR_TYPE (TREE_TYPE (type
))
1305 && TYPE_GETS_REG_DELETE (TREE_TYPE (type
)))
1307 /* Only do access checking here; we'll be calling op delete
1308 from the destructor. */
1309 tree tmp
= build_opfncall (DELETE_EXPR
, LOOKUP_NORMAL
, t
,
1310 size_zero_node
, NULL_TREE
);
1311 if (tmp
== error_mark_node
)
1312 return error_mark_node
;
1315 return build_delete (type
, t
, integer_three_node
,
1316 LOOKUP_NORMAL
, use_global_delete
);
1320 /* Report an error if the indicated template declaration is not the
1321 sort of thing that should be a member template. */
1324 check_member_template (tmpl
)
1329 my_friendly_assert (TREE_CODE (tmpl
) == TEMPLATE_DECL
, 0);
1330 decl
= DECL_TEMPLATE_RESULT (tmpl
);
1332 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1334 if (current_function_decl
)
1335 /* 14.5.2.2 [temp.mem]
1337 A local class shall not have member templates. */
1338 cp_error ("declaration of of member template `%#D' in local class",
1341 if (DECL_VIRTUAL_P (decl
))
1343 /* 14.5.2.3 [temp.mem]
1345 A member function template shall not be virtual. */
1347 ("invalid use of `virtual' in template declaration of `%#D'",
1349 DECL_VIRTUAL_P (decl
) = 0;
1352 /* The debug-information generating code doesn't know what to do
1353 with member templates. */
1354 DECL_IGNORED_P (tmpl
) = 1;
1356 else if (TREE_CODE (decl
) == TYPE_DECL
&&
1357 AGGREGATE_TYPE_P (TREE_TYPE (decl
)))
1359 if (current_function_decl
)
1360 /* 14.5.2.2 [temp.mem]
1362 A local class shall not have member templates. */
1363 cp_error ("declaration of of member template `%#D' in local class",
1366 /* We don't handle member template classes yet. */
1367 sorry ("member templates classes");
1370 cp_error ("template declaration of `%#D'", decl
);
1373 /* Sanity check: report error if this function FUNCTION is not
1374 really a member of the class (CTYPE) it is supposed to belong to.
1375 CNAME is the same here as it is for grokclassfn above. */
1378 check_classfn (ctype
, function
)
1379 tree ctype
, function
;
1381 tree fn_name
= DECL_NAME (function
);
1383 tree method_vec
= CLASSTYPE_METHOD_VEC (complete_type (ctype
));
1386 tree templates
= NULL_TREE
;
1388 if (method_vec
!= 0)
1390 methods
= &TREE_VEC_ELT (method_vec
, 0);
1391 end
= TREE_VEC_END (method_vec
);
1393 /* First suss out ctors and dtors. */
1394 if (*methods
&& fn_name
== DECL_NAME (*methods
)
1395 && DECL_CONSTRUCTOR_P (function
))
1397 if (*++methods
&& fn_name
== DECL_NAME (*methods
)
1398 && DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (function
)))
1401 while (++methods
!= end
)
1404 if (fn_name
== DECL_NAME (*methods
))
1410 if (DECL_ASSEMBLER_NAME (function
) == DECL_ASSEMBLER_NAME (fndecl
))
1413 /* This doesn't work for static member functions that are
1414 pretending to be methods. */
1415 /* We have to do more extensive argument checking here, as
1416 the name may have been changed by asm("new_name"). */
1417 if (decls_match (function
, fndecl
))
1420 if (DECL_NAME (function
) == DECL_NAME (fndecl
))
1422 tree p1
= TYPE_ARG_TYPES (TREE_TYPE (function
));
1423 tree p2
= TYPE_ARG_TYPES (TREE_TYPE (fndecl
));
1425 /* Get rid of the this parameter on functions that become
1427 if (DECL_STATIC_FUNCTION_P (fndecl
)
1428 && TREE_CODE (TREE_TYPE (function
)) == METHOD_TYPE
)
1429 p1
= TREE_CHAIN (p1
);
1431 if (comptypes (TREE_TYPE (TREE_TYPE (function
)),
1432 TREE_TYPE (TREE_TYPE (fndecl
)), 1)
1433 && compparms (p1
, p2
, 3)
1434 && (DECL_TEMPLATE_SPECIALIZATION (function
)
1435 == DECL_TEMPLATE_SPECIALIZATION (fndecl
))
1436 && (!DECL_TEMPLATE_SPECIALIZATION (function
)
1437 || (DECL_TI_TEMPLATE (function
)
1438 == DECL_TI_TEMPLATE (fndecl
))))
1441 if (is_member_template (fndecl
))
1442 /* This function might be an instantiation
1443 or specialization of fndecl. */
1445 tree_cons (NULL_TREE
, fndecl
, templates
);
1448 fndecl
= DECL_CHAIN (fndecl
);
1452 else if (TREE_CODE (fndecl
) == TEMPLATE_DECL
1453 && IDENTIFIER_TYPENAME_P (DECL_NAME (fndecl
))
1454 && IDENTIFIER_TYPENAME_P (fn_name
))
1455 /* The method in the class is a member template
1456 conversion operator. We are declaring another
1457 conversion operator. It is possible that even though
1458 the names don't match, there is some specialization
1461 tree_cons (NULL_TREE
, fndecl
, templates
);
1466 /* This function might be an instantiation or a specialization.
1467 We should verify that this is possible. If it is, we must
1468 somehow add the new declaration to the method vector for the
1469 class. Perhaps we should use add_method? For now, we simply
1470 return NULL_TREE, which lets the caller know that this
1471 function is new, but we don't print an error message. */
1476 tree fndecl
= *methods
;
1477 cp_error ("prototype for `%#D' does not match any in class `%T'",
1479 cp_error_at ("candidate%s: %+#D", DECL_CHAIN (fndecl
) ? "s are" : " is",
1481 while (fndecl
= DECL_CHAIN (fndecl
), fndecl
)
1482 cp_error_at (" %#D", fndecl
);
1487 cp_error ("no `%#D' member function declared in class `%T'",
1491 /* If we did not find the method in the class, add it to avoid
1493 add_method (ctype
, methods
, function
);
1497 /* Process the specs, declarator (NULL if omitted) and width (NULL if omitted)
1498 of a structure component, returning a FIELD_DECL node.
1499 QUALS is a list of type qualifiers for this decl (such as for declaring
1500 const member functions).
1502 This is done during the parsing of the struct declaration.
1503 The FIELD_DECL nodes are chained together and the lot of them
1504 are ultimately passed to `build_struct' to make the RECORD_TYPE node.
1508 If class A defines that certain functions in class B are friends, then
1509 the way I have set things up, it is B who is interested in permission
1510 granted by A. However, it is in A's context that these declarations
1511 are parsed. By returning a void_type_node, class A does not attempt
1512 to incorporate the declarations of the friends within its structure.
1514 DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING
1515 CHANGES TO CODE IN `start_method'. */
1518 grokfield (declarator
, declspecs
, init
, asmspec_tree
, attrlist
)
1519 tree declarator
, declspecs
, init
, asmspec_tree
, attrlist
;
1521 register tree value
;
1523 int flags
= LOOKUP_ONLYCONVERTING
;
1525 /* Convert () initializers to = initializers. */
1526 if (init
== NULL_TREE
&& declarator
!= NULL_TREE
1527 && TREE_CODE (declarator
) == CALL_EXPR
1528 && TREE_OPERAND (declarator
, 0)
1529 && (TREE_CODE (TREE_OPERAND (declarator
, 0)) == IDENTIFIER_NODE
1530 || TREE_CODE (TREE_OPERAND (declarator
, 0)) == SCOPE_REF
)
1531 && parmlist_is_exprlist (TREE_OPERAND (declarator
, 1)))
1533 init
= TREE_OPERAND (declarator
, 1);
1534 declarator
= TREE_OPERAND (declarator
, 0);
1538 if (declspecs
== NULL_TREE
1539 && TREE_CODE (declarator
) == SCOPE_REF
1540 && TREE_CODE (TREE_OPERAND (declarator
, 1)) == IDENTIFIER_NODE
)
1542 /* Access declaration */
1543 if (! IS_AGGR_TYPE_CODE (TREE_CODE (TREE_OPERAND (declarator
, 0))))
1545 else if (TREE_COMPLEXITY (declarator
) == current_class_depth
)
1546 pop_nested_class (1);
1547 return do_class_using_decl (declarator
);
1551 && TREE_CODE (init
) == TREE_LIST
1552 && TREE_VALUE (init
) == error_mark_node
1553 && TREE_CHAIN (init
) == NULL_TREE
)
1556 value
= grokdeclarator (declarator
, declspecs
, FIELD
, init
!= 0, NULL_TREE
);
1558 return value
; /* friend or constructor went bad. */
1560 /* Pass friendly classes back. */
1561 if (TREE_CODE (value
) == VOID_TYPE
)
1562 return void_type_node
;
1564 if (DECL_NAME (value
) != NULL_TREE
1565 && IDENTIFIER_POINTER (DECL_NAME (value
))[0] == '_'
1566 && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (value
)), "_vptr"))
1567 cp_error ("member `%D' conflicts with virtual function table field name", value
);
1569 /* Stash away type declarations. */
1570 if (TREE_CODE (value
) == TYPE_DECL
)
1572 DECL_NONLOCAL (value
) = 1;
1573 DECL_CONTEXT (value
) = current_class_type
;
1574 DECL_CLASS_CONTEXT (value
) = current_class_type
;
1575 CLASSTYPE_LOCAL_TYPEDECLS (current_class_type
) = 1;
1577 pushdecl_class_level (value
);
1581 if (IS_SIGNATURE (current_class_type
)
1582 && TREE_CODE (value
) != FUNCTION_DECL
)
1584 error ("field declaration not allowed in signature");
1585 return void_type_node
;
1588 if (DECL_IN_AGGR_P (value
))
1590 cp_error ("`%D' is already defined in the class %T", value
,
1591 DECL_CONTEXT (value
));
1592 return void_type_node
;
1596 asmspec
= TREE_STRING_POINTER (asmspec_tree
);
1600 if (IS_SIGNATURE (current_class_type
)
1601 && TREE_CODE (value
) == FUNCTION_DECL
)
1603 error ("function declarations cannot have initializers in signature");
1606 else if (TREE_CODE (value
) == FUNCTION_DECL
)
1608 grok_function_init (value
, init
);
1611 else if (pedantic
&& TREE_CODE (value
) != VAR_DECL
)
1612 /* Already complained in grokdeclarator. */
1616 /* We allow initializers to become parameters to base
1618 if (TREE_CODE (init
) == TREE_LIST
)
1620 if (TREE_CHAIN (init
) == NULL_TREE
)
1621 init
= TREE_VALUE (init
);
1623 init
= digest_init (TREE_TYPE (value
), init
, (tree
*)0);
1626 if (TREE_CODE (init
) == CONST_DECL
)
1627 init
= DECL_INITIAL (init
);
1628 else if (TREE_READONLY_DECL_P (init
))
1629 init
= decl_constant_value (init
);
1630 else if (TREE_CODE (init
) == CONSTRUCTOR
)
1631 init
= digest_init (TREE_TYPE (value
), init
, (tree
*)0);
1632 my_friendly_assert (TREE_PERMANENT (init
), 192);
1633 if (init
== error_mark_node
)
1634 /* We must make this look different than `error_mark_node'
1635 because `decl_const_value' would mis-interpret it
1636 as only meaning that this VAR_DECL is defined. */
1637 init
= build1 (NOP_EXPR
, TREE_TYPE (value
), init
);
1638 else if (processing_template_decl
)
1640 else if (! TREE_CONSTANT (init
))
1642 /* We can allow references to things that are effectively
1643 static, since references are initialized with the address. */
1644 if (TREE_CODE (TREE_TYPE (value
)) != REFERENCE_TYPE
1645 || (TREE_STATIC (init
) == 0
1646 && (TREE_CODE_CLASS (TREE_CODE (init
)) != 'd'
1647 || DECL_EXTERNAL (init
) == 0)))
1649 error ("field initializer is not constant");
1650 init
= error_mark_node
;
1656 /* The corresponding pop_obstacks is in cp_finish_decl. */
1657 push_obstacks_nochange ();
1659 if (processing_template_decl
&& ! current_function_decl
1660 && (TREE_CODE (value
) == VAR_DECL
|| TREE_CODE (value
) == FUNCTION_DECL
))
1661 push_template_decl (value
);
1664 cplus_decl_attributes (value
, TREE_PURPOSE (attrlist
),
1665 TREE_VALUE (attrlist
));
1667 if (TREE_CODE (value
) == VAR_DECL
)
1669 /* We cannot call pushdecl here, because that would
1670 fill in the value of our TREE_CHAIN. Instead, we
1671 modify cp_finish_decl to do the right thing, namely, to
1672 put this decl out straight away. */
1673 if (TREE_PUBLIC (value
))
1675 /* current_class_type can be NULL_TREE in case of error. */
1676 if (asmspec
== 0 && current_class_type
)
1678 TREE_PUBLIC (value
) = 1;
1679 DECL_INITIAL (value
) = error_mark_node
;
1680 DECL_ASSEMBLER_NAME (value
)
1681 = build_static_name (current_class_type
, DECL_NAME (value
));
1683 if (! processing_template_decl
)
1684 pending_statics
= perm_tree_cons (NULL_TREE
, value
, pending_statics
);
1686 /* Static consts need not be initialized in the class definition. */
1687 if (init
!= NULL_TREE
&& TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (value
)))
1689 static int explanation
= 0;
1691 error ("initializer invalid for static member with constructor");
1692 if (explanation
++ == 0)
1693 error ("(you really want to initialize it separately)");
1696 /* Force the compiler to know when an uninitialized static
1697 const member is being used. */
1698 if (TYPE_READONLY (value
) && init
== 0)
1699 TREE_USED (value
) = 1;
1701 DECL_INITIAL (value
) = init
;
1702 DECL_IN_AGGR_P (value
) = 1;
1703 DECL_CONTEXT (value
) = current_class_type
;
1704 DECL_CLASS_CONTEXT (value
) = current_class_type
;
1706 cp_finish_decl (value
, init
, asmspec_tree
, 1, flags
);
1707 pushdecl_class_level (value
);
1710 if (TREE_CODE (value
) == FIELD_DECL
)
1714 /* This must override the asm specifier which was placed
1715 by grokclassfn. Lay this out fresh. */
1716 DECL_RTL (value
) = NULL_RTX
;
1717 DECL_ASSEMBLER_NAME (value
) = get_identifier (asmspec
);
1719 if (DECL_INITIAL (value
) == error_mark_node
)
1720 init
= error_mark_node
;
1721 cp_finish_decl (value
, init
, asmspec_tree
, 1, flags
);
1722 DECL_INITIAL (value
) = init
;
1723 DECL_IN_AGGR_P (value
) = 1;
1726 if (TREE_CODE (value
) == FUNCTION_DECL
)
1728 check_default_args (value
);
1729 if (DECL_CHAIN (value
) != NULL_TREE
)
1731 /* Need a fresh node here so that we don't get circularity
1732 when we link these together. */
1733 value
= copy_node (value
);
1734 /* When does this happen? */
1735 my_friendly_assert (init
== NULL_TREE
, 193);
1739 /* This must override the asm specifier which was placed
1740 by grokclassfn. Lay this out fresh. */
1741 DECL_RTL (value
) = NULL_RTX
;
1742 DECL_ASSEMBLER_NAME (value
) = get_identifier (asmspec
);
1744 cp_finish_decl (value
, init
, asmspec_tree
, 1, flags
);
1746 /* Pass friends back this way. */
1747 if (DECL_FRIEND_P (value
))
1748 return void_type_node
;
1750 #if 0 /* Just because a fn is declared doesn't mean we'll try to define it. */
1751 if (current_function_decl
&& ! IS_SIGNATURE (current_class_type
))
1752 cp_error ("method `%#D' of local class must be defined in class body",
1756 DECL_IN_AGGR_P (value
) = 1;
1759 my_friendly_abort (21);
1764 /* Like `grokfield', but for bitfields.
1765 WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node. */
1768 grokbitfield (declarator
, declspecs
, width
)
1769 tree declarator
, declspecs
, width
;
1771 register tree value
= grokdeclarator (declarator
, declspecs
, BITFIELD
,
1774 if (! value
) return NULL_TREE
; /* friends went bad. */
1776 /* Pass friendly classes back. */
1777 if (TREE_CODE (value
) == VOID_TYPE
)
1778 return void_type_node
;
1780 if (TREE_CODE (value
) == TYPE_DECL
)
1782 cp_error ("cannot declare `%D' to be a bitfield type", value
);
1786 if (IS_SIGNATURE (current_class_type
))
1788 error ("field declaration not allowed in signature");
1789 return void_type_node
;
1792 if (DECL_IN_AGGR_P (value
))
1794 cp_error ("`%D' is already defined in the class %T", value
,
1795 DECL_CONTEXT (value
));
1796 return void_type_node
;
1799 GNU_xref_member (current_class_name
, value
);
1801 if (TREE_STATIC (value
))
1803 cp_error ("static member `%D' cannot be a bitfield", value
);
1806 cp_finish_decl (value
, NULL_TREE
, NULL_TREE
, 0, 0);
1808 if (width
!= error_mark_node
)
1810 constant_expression_warning (width
);
1811 DECL_INITIAL (value
) = width
;
1812 DECL_BIT_FIELD (value
) = 1;
1815 DECL_IN_AGGR_P (value
) = 1;
1820 grokoptypename (declspecs
, declarator
)
1821 tree declspecs
, declarator
;
1823 tree t
= grokdeclarator (declarator
, declspecs
, TYPENAME
, 0, NULL_TREE
);
1824 return build_typename_overload (t
);
1827 /* When a function is declared with an initializer,
1828 do the right thing. Currently, there are two possibilities:
1833 // initialization possibility #1.
1834 virtual void f () = 0;
1856 // initialization possibility #2
1863 copy_assignment_arg_p (parmtype
, virtualp
)
1867 if (current_class_type
== NULL_TREE
)
1870 if (TREE_CODE (parmtype
) == REFERENCE_TYPE
)
1871 parmtype
= TREE_TYPE (parmtype
);
1873 if ((TYPE_MAIN_VARIANT (parmtype
) == current_class_type
)
1875 /* Non-standard hack to support old Booch components. */
1876 || (! virtualp
&& DERIVED_FROM_P (parmtype
, current_class_type
))
1885 grok_function_init (decl
, init
)
1889 /* An initializer for a function tells how this function should
1891 tree type
= TREE_TYPE (decl
);
1893 if (TREE_CODE (type
) == FUNCTION_TYPE
)
1894 cp_error ("initializer specified for non-member function `%D'", decl
);
1896 /* We'll check for this in finish_struct_1. */
1897 else if (DECL_VINDEX (decl
) == NULL_TREE
)
1898 cp_error ("initializer specified for non-virtual method `%D'", decl
);
1900 else if (integer_zerop (init
))
1903 /* Mark this function as being "defined". */
1904 DECL_INITIAL (decl
) = error_mark_node
;
1905 /* pure virtual destructors must be defined. */
1906 /* pure virtual needs to be defined (as abort) only when put in
1907 vtbl. For wellformed call, it should be itself. pr4737 */
1908 if (!DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl
)))
1910 extern tree abort_fndecl
;
1911 /* Give this node rtl from `abort'. */
1912 DECL_RTL (decl
) = DECL_RTL (abort_fndecl
);
1915 DECL_ABSTRACT_VIRTUAL_P (decl
) = 1;
1916 if (DECL_NAME (decl
) == ansi_opname
[(int) MODIFY_EXPR
])
1919 = TREE_VALUE (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl
))));
1921 if (copy_assignment_arg_p (parmtype
, 1))
1922 TYPE_HAS_ABSTRACT_ASSIGN_REF (current_class_type
) = 1;
1925 else if (TREE_CODE (init
) == OFFSET_REF
1926 && TREE_OPERAND (init
, 0) == NULL_TREE
1927 && TREE_CODE (TREE_TYPE (init
)) == METHOD_TYPE
)
1929 tree basetype
= DECL_CLASS_CONTEXT (init
);
1930 tree basefn
= TREE_OPERAND (init
, 1);
1931 if (TREE_CODE (basefn
) != FUNCTION_DECL
)
1932 cp_error ("non-method initializer invalid for method `%D'", decl
);
1933 else if (! BINFO_OFFSET_ZEROP (TYPE_BINFO (DECL_CLASS_CONTEXT (basefn
))))
1934 sorry ("base member function from other than first base class");
1937 tree binfo
= get_binfo (basetype
, TYPE_METHOD_BASETYPE (type
), 1);
1938 if (binfo
== error_mark_node
)
1940 else if (binfo
== 0)
1941 error_not_base_type (TYPE_METHOD_BASETYPE (TREE_TYPE (init
)),
1942 TYPE_METHOD_BASETYPE (type
));
1945 /* Mark this function as being defined,
1946 and give it new rtl. */
1947 DECL_INITIAL (decl
) = error_mark_node
;
1948 DECL_RTL (decl
) = DECL_RTL (basefn
);
1953 cp_error ("invalid initializer for virtual method `%D'", decl
);
1957 cplus_decl_attributes (decl
, attributes
, prefix_attributes
)
1958 tree decl
, attributes
, prefix_attributes
;
1960 if (decl
== NULL_TREE
|| decl
== void_type_node
)
1963 if (TREE_CODE (decl
) == TEMPLATE_DECL
)
1964 decl
= DECL_TEMPLATE_RESULT (decl
);
1966 decl_attributes (decl
, attributes
, prefix_attributes
);
1968 if (TREE_CODE (decl
) == TYPE_DECL
)
1969 SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (decl
), TREE_TYPE (decl
));
1972 /* CONSTRUCTOR_NAME:
1973 Return the name for the constructor (or destructor) for the
1974 specified class. Argument can be RECORD_TYPE, TYPE_DECL, or
1975 IDENTIFIER_NODE. When given a template, this routine doesn't
1976 lose the specialization. */
1979 constructor_name_full (thing
)
1982 if (TREE_CODE (thing
) == TEMPLATE_TYPE_PARM
)
1983 thing
= TYPE_NAME (thing
);
1984 else if (IS_AGGR_TYPE_CODE (TREE_CODE (thing
)))
1986 if (TYPE_WAS_ANONYMOUS (thing
) && TYPE_HAS_CONSTRUCTOR (thing
))
1987 thing
= DECL_NAME (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (thing
), 0));
1989 thing
= TYPE_NAME (thing
);
1991 if (TREE_CODE (thing
) == TYPE_DECL
1992 || (TREE_CODE (thing
) == TEMPLATE_DECL
1993 && TREE_CODE (DECL_TEMPLATE_RESULT (thing
)) == TYPE_DECL
))
1994 thing
= DECL_NAME (thing
);
1995 my_friendly_assert (TREE_CODE (thing
) == IDENTIFIER_NODE
, 197);
1999 /* CONSTRUCTOR_NAME:
2000 Return the name for the constructor (or destructor) for the
2001 specified class. Argument can be RECORD_TYPE, TYPE_DECL, or
2002 IDENTIFIER_NODE. When given a template, return the plain
2003 unspecialized name. */
2006 constructor_name (thing
)
2010 thing
= constructor_name_full (thing
);
2011 t
= IDENTIFIER_TEMPLATE (thing
);
2017 /* Cache the value of this class's main virtual function table pointer
2018 in a register variable. This will save one indirection if a
2019 more than one virtual function call is made this function. */
2024 extern tree base_init_expr
;
2026 if (base_init_expr
== 0
2027 && DECL_CONSTRUCTOR_P (current_function_decl
))
2029 if (processing_template_decl
)
2030 add_tree (build_min_nt
2032 current_member_init_list
, current_base_init_list
));
2034 emit_base_init (current_class_type
, 0);
2038 /* Record the existence of an addressable inline function. */
2041 mark_inline_for_output (decl
)
2044 decl
= DECL_MAIN_VARIANT (decl
);
2045 if (DECL_SAVED_INLINE (decl
))
2047 my_friendly_assert (TREE_PERMANENT (decl
), 363);
2048 DECL_SAVED_INLINE (decl
) = 1;
2050 if (DECL_PENDING_INLINE_INFO (decl
) != 0
2051 && ! DECL_PENDING_INLINE_INFO (decl
)->deja_vu
)
2053 struct pending_inline
*t
= pending_inlines
;
2054 my_friendly_assert (DECL_SAVED_INSNS (decl
) == 0, 198);
2057 if (t
== DECL_PENDING_INLINE_INFO (decl
))
2063 t
= DECL_PENDING_INLINE_INFO (decl
);
2064 t
->next
= pending_inlines
;
2065 pending_inlines
= t
;
2067 DECL_PENDING_INLINE_INFO (decl
) = 0;
2070 saved_inlines
= perm_tree_cons (NULL_TREE
, decl
, saved_inlines
);
2076 temp_name_counter
= 0;
2079 /* Hand off a unique name which can be used for variable we don't really
2080 want to know about anyway, for example, the anonymous variables which
2081 are needed to make references work. Declare this thing so we can use it.
2082 The variable created will be of type TYPE.
2084 STATICP is nonzero if this variable should be static. */
2087 get_temp_name (type
, staticp
)
2091 char buf
[sizeof (AUTO_TEMP_FORMAT
) + 20];
2093 int toplev
= toplevel_bindings_p ();
2095 push_obstacks_nochange ();
2096 if (toplev
|| staticp
)
2098 end_temporary_allocation ();
2099 sprintf (buf
, AUTO_TEMP_FORMAT
, global_temp_name_counter
++);
2100 decl
= pushdecl_top_level (build_decl (VAR_DECL
, get_identifier (buf
), type
));
2104 sprintf (buf
, AUTO_TEMP_FORMAT
, temp_name_counter
++);
2105 decl
= pushdecl (build_decl (VAR_DECL
, get_identifier (buf
), type
));
2107 TREE_USED (decl
) = 1;
2108 TREE_STATIC (decl
) = staticp
;
2109 DECL_ARTIFICIAL (decl
) = 1;
2111 /* If this is a local variable, then lay out its rtl now.
2112 Otherwise, callers of this function are responsible for dealing
2113 with this variable's rtl. */
2117 expand_decl_init (decl
);
2124 /* Get a variable which we can use for multiple assignments.
2125 It is not entered into current_binding_level, because
2126 that breaks things when it comes time to do final cleanups
2127 (which take place "outside" the binding contour of the function). */
2130 get_temp_regvar (type
, init
)
2133 static char buf
[sizeof (AUTO_TEMP_FORMAT
) + 20] = { '_' };
2136 sprintf (buf
+1, AUTO_TEMP_FORMAT
, temp_name_counter
++);
2137 decl
= build_decl (VAR_DECL
, get_identifier (buf
), type
);
2138 TREE_USED (decl
) = 1;
2139 DECL_REGISTER (decl
) = 1;
2142 store_init_value (decl
, init
);
2144 /* We can expand these without fear, since they cannot need
2145 constructors or destructors. */
2147 expand_decl_init (decl
);
2152 /* Finish off the processing of a UNION_TYPE structure.
2153 If there are static members, then all members are
2154 static, and must be laid out together. If the
2155 union is an anonymous union, we arrange for that
2156 as well. PUBLIC_P is nonzero if this union is
2157 not declared static. */
2160 finish_anon_union (anon_union_decl
)
2161 tree anon_union_decl
;
2163 tree type
= TREE_TYPE (anon_union_decl
);
2164 tree field
, main_decl
= NULL_TREE
;
2165 tree elems
= NULL_TREE
;
2166 int public_p
= TREE_PUBLIC (anon_union_decl
);
2167 int static_p
= TREE_STATIC (anon_union_decl
);
2168 int external_p
= DECL_EXTERNAL (anon_union_decl
);
2170 if ((field
= TYPE_FIELDS (type
)) == NULL_TREE
)
2175 error ("global anonymous unions must be declared static");
2179 for (; field
; field
= TREE_CHAIN (field
))
2182 if (TREE_CODE (field
) != FIELD_DECL
)
2185 if (TREE_PRIVATE (field
))
2186 cp_pedwarn_at ("private member `%#D' in anonymous union", field
);
2187 else if (TREE_PROTECTED (field
))
2188 cp_pedwarn_at ("protected member `%#D' in anonymous union", field
);
2190 decl
= build_decl (VAR_DECL
, DECL_NAME (field
), TREE_TYPE (field
));
2191 /* tell `pushdecl' that this is not tentative. */
2192 DECL_INITIAL (decl
) = error_mark_node
;
2193 TREE_PUBLIC (decl
) = public_p
;
2194 TREE_STATIC (decl
) = static_p
;
2195 DECL_EXTERNAL (decl
) = external_p
;
2196 decl
= pushdecl (decl
);
2198 /* Only write out one anon union element--choose the one that
2199 can hold them all. */
2200 if (main_decl
== NULL_TREE
2201 && 1 == simple_cst_equal (DECL_SIZE (decl
),
2202 DECL_SIZE (anon_union_decl
)))
2208 /* ??? This causes there to be no debug info written out
2210 TREE_ASM_WRITTEN (decl
) = 1;
2213 DECL_INITIAL (decl
) = NULL_TREE
;
2214 /* If there's a cleanup to do, it belongs in the
2215 TREE_PURPOSE of the following TREE_LIST. */
2216 elems
= tree_cons (NULL_TREE
, decl
, elems
);
2217 TREE_TYPE (elems
) = type
;
2223 make_decl_rtl (main_decl
, 0, toplevel_bindings_p ());
2224 DECL_RTL (anon_union_decl
) = DECL_RTL (main_decl
);
2228 warning ("anonymous union with no members");
2233 /* The following call assumes that there are never any cleanups
2234 for anonymous unions--a reasonable assumption. */
2235 expand_anon_union_decl (anon_union_decl
, NULL_TREE
, elems
);
2238 /* Finish and output a table which is generated by the compiler.
2239 NAME is the name to give the table.
2240 TYPE is the type of the table entry.
2241 INIT is all the elements in the table.
2242 PUBLICP is non-zero if this table should be given external access. */
2245 finish_table (name
, type
, init
, publicp
)
2246 tree name
, type
, init
;
2249 tree itype
, atype
, decl
;
2250 static tree empty_table
;
2254 itype
= build_index_type (size_int (list_length (init
) - 1));
2255 atype
= build_cplus_array_type (type
, itype
);
2256 layout_type (atype
);
2258 if (TREE_VALUE (init
) == integer_zero_node
2259 && TREE_CHAIN (init
) == NULL_TREE
)
2262 if (empty_table
== NULL_TREE
)
2265 empty_table
= get_temp_name (atype
, 1);
2266 init
= build (CONSTRUCTOR
, atype
, NULL_TREE
, init
);
2267 TREE_CONSTANT (init
) = 1;
2268 TREE_STATIC (init
) = 1;
2269 DECL_INITIAL (empty_table
) = init
;
2270 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table
)),
2271 IDENTIFIER_POINTER (DECL_NAME (empty_table
)));
2272 cp_finish_decl (empty_table
, NULL_TREE
, asmspec
, 0, 0);
2277 if (name
== NULL_TREE
)
2281 decl
= get_temp_name (atype
, 1);
2285 decl
= build_decl (VAR_DECL
, name
, atype
);
2286 decl
= pushdecl (decl
);
2287 TREE_STATIC (decl
) = 1;
2292 TREE_PUBLIC (decl
) = publicp
;
2293 init
= build (CONSTRUCTOR
, atype
, NULL_TREE
, init
);
2294 TREE_CONSTANT (init
) = 1;
2295 TREE_STATIC (init
) = 1;
2296 DECL_INITIAL (decl
) = init
;
2297 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (decl
)),
2298 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2302 /* This will cause DECL to point to EMPTY_TABLE in rtl-land. */
2303 DECL_EXTERNAL (decl
) = 1;
2304 TREE_STATIC (decl
) = 0;
2306 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table
)),
2307 IDENTIFIER_POINTER (DECL_NAME (empty_table
)));
2310 cp_finish_decl (decl
, NULL_TREE
, asmspec
, 0, 0);
2314 /* Finish processing a builtin type TYPE. It's name is NAME,
2315 its fields are in the array FIELDS. LEN is the number of elements
2316 in FIELDS minus one, or put another way, it is the maximum subscript
2319 It is given the same alignment as ALIGN_TYPE. */
2322 finish_builtin_type (type
, name
, fields
, len
, align_type
)
2331 TYPE_FIELDS (type
) = fields
[0];
2332 for (i
= 0; i
< len
; i
++)
2334 layout_type (TREE_TYPE (fields
[i
]));
2335 DECL_FIELD_CONTEXT (fields
[i
]) = type
;
2336 TREE_CHAIN (fields
[i
]) = fields
[i
+1];
2338 DECL_FIELD_CONTEXT (fields
[i
]) = type
;
2339 DECL_CLASS_CONTEXT (fields
[i
]) = type
;
2340 TYPE_ALIGN (type
) = TYPE_ALIGN (align_type
);
2342 #if 0 /* not yet, should get fixed properly later */
2343 TYPE_NAME (type
) = make_type_decl (get_identifier (name
), type
);
2345 TYPE_NAME (type
) = build_decl (TYPE_DECL
, get_identifier (name
), type
);
2347 TYPE_STUB_DECL (type
) = TYPE_NAME (type
);
2348 layout_decl (TYPE_NAME (type
), 0);
2351 /* Auxiliary functions to make type signatures for
2352 `operator new' and `operator delete' correspond to
2353 what compiler will be expecting. */
2355 extern tree sizetype
;
2358 coerce_new_type (type
)
2363 if (TREE_CODE (type
) == METHOD_TYPE
)
2364 type
= build_function_type (TREE_TYPE (type
), TREE_CHAIN (TYPE_ARG_TYPES (type
)));
2365 if (TREE_TYPE (type
) != ptr_type_node
)
2366 e1
= 1, error ("`operator new' must return type `void *'");
2368 /* Technically the type must be `size_t', but we may not know
2370 if (TYPE_ARG_TYPES (type
) == NULL_TREE
)
2371 e1
= 1, error ("`operator new' takes type `size_t' parameter");
2372 else if (TREE_CODE (TREE_VALUE (TYPE_ARG_TYPES (type
))) != INTEGER_TYPE
2373 || TYPE_PRECISION (TREE_VALUE (TYPE_ARG_TYPES (type
))) != TYPE_PRECISION (sizetype
))
2374 e2
= 1, error ("`operator new' takes type `size_t' as first parameter");
2376 type
= build_function_type (ptr_type_node
, tree_cons (NULL_TREE
, sizetype
, TREE_CHAIN (TYPE_ARG_TYPES (type
))));
2378 type
= build_function_type (ptr_type_node
, TYPE_ARG_TYPES (type
));
2383 coerce_delete_type (type
)
2386 int e1
= 0, e2
= 0, e3
= 0;
2387 tree arg_types
= TYPE_ARG_TYPES (type
);
2389 if (TREE_CODE (type
) == METHOD_TYPE
)
2391 type
= build_function_type (TREE_TYPE (type
), TREE_CHAIN (arg_types
));
2392 arg_types
= TREE_CHAIN (arg_types
);
2395 if (TREE_TYPE (type
) != void_type_node
)
2396 e1
= 1, error ("`operator delete' must return type `void'");
2398 if (arg_types
== NULL_TREE
2399 || TREE_VALUE (arg_types
) != ptr_type_node
)
2400 e2
= 1, error ("`operator delete' takes type `void *' as first parameter");
2403 && TREE_CHAIN (arg_types
)
2404 && TREE_CHAIN (arg_types
) != void_list_node
)
2406 /* Again, technically this argument must be `size_t', but again
2407 we may not know what that is. */
2408 tree t2
= TREE_VALUE (TREE_CHAIN (arg_types
));
2409 if (TREE_CODE (t2
) != INTEGER_TYPE
2410 || TYPE_PRECISION (t2
) != TYPE_PRECISION (sizetype
))
2411 e3
= 1, error ("second argument to `operator delete' must be of type `size_t'");
2412 else if (TREE_CHAIN (TREE_CHAIN (arg_types
)) != void_list_node
)
2415 if (TREE_CHAIN (TREE_CHAIN (arg_types
)))
2416 error ("too many arguments in declaration of `operator delete'");
2418 error ("`...' invalid in specification of `operator delete'");
2423 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
,
2424 build_tree_list (NULL_TREE
, sizetype
));
2427 if (arg_types
== NULL_TREE
)
2428 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
, void_list_node
);
2430 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
, TREE_CHAIN (arg_types
));
2435 type
= build_function_type (void_type_node
, arg_types
);
2440 extern tree abort_fndecl
;
2443 mark_vtable_entries (decl
)
2446 tree entries
= CONSTRUCTOR_ELTS (DECL_INITIAL (decl
));
2450 tree fnaddr
= (flag_vtable_thunks
? TREE_VALUE (TREE_CHAIN (entries
))
2451 : FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries
)));
2452 tree fn
= TREE_OPERAND (fnaddr
, 0);
2453 TREE_ADDRESSABLE (fn
) = 1;
2456 skip_rtti_stuff (&entries
);
2458 for (; entries
; entries
= TREE_CHAIN (entries
))
2460 tree fnaddr
= (flag_vtable_thunks
? TREE_VALUE (entries
)
2461 : FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries
)));
2462 tree fn
= TREE_OPERAND (fnaddr
, 0);
2463 TREE_ADDRESSABLE (fn
) = 1;
2464 if (DECL_LANG_SPECIFIC (fn
) && DECL_ABSTRACT_VIRTUAL_P (fn
))
2466 TREE_OPERAND (fnaddr
, 0) = fn
= copy_node (fn
);
2467 DECL_RTL (fn
) = DECL_RTL (abort_fndecl
);
2468 mark_used (abort_fndecl
);
2470 if (TREE_CODE (fn
) == THUNK_DECL
&& DECL_EXTERNAL (fn
))
2472 DECL_EXTERNAL (fn
) = 0;
2479 /* Set DECL up to have the closest approximation of "initialized common"
2480 linkage available. */
2483 comdat_linkage (decl
)
2487 make_decl_one_only (decl
);
2489 TREE_PUBLIC (decl
) = 0;
2492 /* Set TREE_PUBLIC and/or DECL_EXTERN on the vtable DECL,
2493 based on TYPE and other static flags.
2495 Note that anything public is tagged TREE_PUBLIC, whether
2496 it's public in this file or in another one. */
2499 import_export_vtable (decl
, type
, final
)
2503 if (DECL_INTERFACE_KNOWN (decl
))
2507 if (write_virtuals
< 2 && write_virtuals
!= 0)
2509 TREE_PUBLIC (decl
) = 1;
2510 if (write_virtuals
< 0)
2511 DECL_EXTERNAL (decl
) = 1;
2512 DECL_INTERFACE_KNOWN (decl
) = 1;
2514 else if (CLASSTYPE_INTERFACE_KNOWN (type
))
2516 TREE_PUBLIC (decl
) = 1;
2517 DECL_EXTERNAL (decl
) = ! CLASSTYPE_VTABLE_NEEDS_WRITING (type
);
2518 DECL_INTERFACE_KNOWN (decl
) = 1;
2522 /* We can only wait to decide if we have real non-inline virtual
2523 functions in our class, or if we come from a template. */
2525 int found
= CLASSTYPE_TEMPLATE_INSTANTIATION (type
);
2527 if (! found
&& ! final
)
2530 for (method
= TYPE_METHODS (type
); method
!= NULL_TREE
;
2531 method
= TREE_CHAIN (method
))
2532 if (DECL_VINDEX (method
) != NULL_TREE
2533 && ! DECL_THIS_INLINE (method
)
2534 && ! DECL_ABSTRACT_VIRTUAL_P (method
))
2541 if (final
|| ! found
)
2543 comdat_linkage (decl
);
2544 DECL_EXTERNAL (decl
) = 0;
2548 TREE_PUBLIC (decl
) = 1;
2549 DECL_EXTERNAL (decl
) = 1;
2555 import_export_template (type
)
2558 if (CLASSTYPE_IMPLICIT_INSTANTIATION (type
)
2559 && ! flag_implicit_templates
2560 && CLASSTYPE_INTERFACE_UNKNOWN (type
))
2562 SET_CLASSTYPE_INTERFACE_KNOWN (type
);
2563 CLASSTYPE_INTERFACE_ONLY (type
) = 1;
2564 CLASSTYPE_VTABLE_NEEDS_WRITING (type
) = 0;
2569 finish_prevtable_vardecl (prev
, vars
)
2572 tree ctype
= DECL_CONTEXT (vars
);
2573 import_export_template (ctype
);
2575 #ifndef MULTIPLE_SYMBOL_SPACES
2576 if (CLASSTYPE_INTERFACE_UNKNOWN (ctype
) && TYPE_VIRTUAL_P (ctype
)
2577 && ! CLASSTYPE_TEMPLATE_INSTANTIATION (ctype
))
2580 for (method
= TYPE_METHODS (ctype
); method
!= NULL_TREE
;
2581 method
= TREE_CHAIN (method
))
2583 if (DECL_VINDEX (method
) != NULL_TREE
2584 && !DECL_THIS_INLINE (method
)
2585 && !DECL_ABSTRACT_VIRTUAL_P (method
))
2587 SET_CLASSTYPE_INTERFACE_KNOWN (ctype
);
2588 CLASSTYPE_VTABLE_NEEDS_WRITING (ctype
) = ! DECL_EXTERNAL (method
);
2589 CLASSTYPE_INTERFACE_ONLY (ctype
) = DECL_EXTERNAL (method
);
2596 import_export_vtable (vars
, ctype
, 1);
2601 finish_vtable_vardecl (prev
, vars
)
2604 if (write_virtuals
>= 0
2605 && ! DECL_EXTERNAL (vars
)
2606 && ((TREE_PUBLIC (vars
) && ! DECL_WEAK (vars
) && ! DECL_ONE_ONLY (vars
))
2607 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (vars
))
2608 || (hack_decl_function_context (vars
) && TREE_USED (vars
)))
2609 && ! TREE_ASM_WRITTEN (vars
))
2612 mark_vtable_entries (vars
);
2613 if (TREE_TYPE (DECL_INITIAL (vars
)) == 0)
2614 store_init_value (vars
, DECL_INITIAL (vars
));
2616 if (write_symbols
== DWARF_DEBUG
|| write_symbols
== DWARF2_DEBUG
)
2618 /* Mark the VAR_DECL node representing the vtable itself as a
2619 "gratuitous" one, thereby forcing dwarfout.c to ignore it.
2620 It is rather important that such things be ignored because
2621 any effort to actually generate DWARF for them will run
2622 into trouble when/if we encounter code like:
2625 struct S { virtual void member (); };
2627 because the artificial declaration of the vtable itself (as
2628 manufactured by the g++ front end) will say that the vtable
2629 is a static member of `S' but only *after* the debug output
2630 for the definition of `S' has already been output. This causes
2631 grief because the DWARF entry for the definition of the vtable
2632 will try to refer back to an earlier *declaration* of the
2633 vtable as a static member of `S' and there won't be one.
2634 We might be able to arrange to have the "vtable static member"
2635 attached to the member list for `S' before the debug info for
2636 `S' get written (which would solve the problem) but that would
2637 require more intrusive changes to the g++ front end. */
2639 DECL_IGNORED_P (vars
) = 1;
2642 rest_of_decl_compilation (vars
, NULL_PTR
, 1, 1);
2645 else if (! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (vars
)))
2646 /* We don't know what to do with this one yet. */
2649 /* We know that PREV must be non-zero here. */
2650 TREE_CHAIN (prev
) = TREE_CHAIN (vars
);
2655 prune_vtable_vardecl (prev
, vars
)
2658 /* We know that PREV must be non-zero here. */
2659 TREE_CHAIN (prev
) = TREE_CHAIN (vars
);
2664 walk_vtables (typedecl_fn
, vardecl_fn
)
2665 register void (*typedecl_fn
) PROTO ((tree
, tree
));
2666 register int (*vardecl_fn
) PROTO ((tree
, tree
));
2671 for (prev
= 0, vars
= getdecls (); vars
; vars
= TREE_CHAIN (vars
))
2673 register tree type
= TREE_TYPE (vars
);
2675 if (TREE_CODE (vars
) == VAR_DECL
&& DECL_VIRTUAL_P (vars
))
2678 flag
|= (*vardecl_fn
) (prev
, vars
);
2680 if (prev
&& TREE_CHAIN (prev
) != vars
)
2683 else if (TREE_CODE (vars
) == TYPE_DECL
2684 && type
!= error_mark_node
2685 && TYPE_LANG_SPECIFIC (type
)
2686 && CLASSTYPE_VSIZE (type
))
2688 if (typedecl_fn
) (*typedecl_fn
) (prev
, vars
);
2698 finish_sigtable_vardecl (prev
, vars
)
2701 /* We don't need to mark sigtable entries as addressable here as is done
2702 for vtables. Since sigtables, unlike vtables, are always written out,
2703 that was already done in build_signature_table_constructor. */
2705 rest_of_decl_compilation (vars
, NULL_PTR
, 1, 1);
2707 /* We know that PREV must be non-zero here. */
2708 TREE_CHAIN (prev
) = TREE_CHAIN (vars
);
2712 walk_sigtables (typedecl_fn
, vardecl_fn
)
2713 register void (*typedecl_fn
) PROTO((tree
, tree
));
2714 register void (*vardecl_fn
) PROTO((tree
, tree
));
2718 for (prev
= 0, vars
= getdecls (); vars
; vars
= TREE_CHAIN (vars
))
2720 register tree type
= TREE_TYPE (vars
);
2722 if (TREE_CODE (vars
) == TYPE_DECL
2723 && type
!= error_mark_node
2724 && IS_SIGNATURE (type
))
2726 if (typedecl_fn
) (*typedecl_fn
) (prev
, vars
);
2728 else if (TREE_CODE (vars
) == VAR_DECL
2729 && TREE_TYPE (vars
) != error_mark_node
2730 && IS_SIGNATURE (TREE_TYPE (vars
)))
2732 if (vardecl_fn
) (*vardecl_fn
) (prev
, vars
);
2739 /* Determines the proper settings of TREE_PUBLIC and DECL_EXTERNAL for an
2740 inline function or template instantiation at end-of-file. */
2743 import_export_decl (decl
)
2746 if (DECL_INTERFACE_KNOWN (decl
))
2749 if (DECL_TEMPLATE_INSTANTIATION (decl
))
2751 DECL_NOT_REALLY_EXTERN (decl
) = 1;
2752 if (DECL_IMPLICIT_INSTANTIATION (decl
)
2753 && (flag_implicit_templates
|| DECL_THIS_INLINE (decl
)))
2755 if (TREE_CODE (decl
) == FUNCTION_DECL
)
2756 comdat_linkage (decl
);
2757 /* Dynamically initialized vars go into common. */
2758 else if (DECL_INITIAL (decl
) == NULL_TREE
2759 || DECL_INITIAL (decl
) == error_mark_node
)
2760 DECL_COMMON (decl
) = 1;
2761 else if (EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl
)))
2763 DECL_COMMON (decl
) = 1;
2764 DECL_INITIAL (decl
) = error_mark_node
;
2768 /* Statically initialized vars are weak or comdat, if
2771 make_decl_one_only (decl
);
2773 /* we can't do anything useful; leave vars for explicit
2775 DECL_NOT_REALLY_EXTERN (decl
) = 0;
2779 DECL_NOT_REALLY_EXTERN (decl
) = 0;
2781 else if (DECL_FUNCTION_MEMBER_P (decl
))
2783 tree ctype
= DECL_CLASS_CONTEXT (decl
);
2784 if (CLASSTYPE_INTERFACE_KNOWN (ctype
) && ! DECL_ARTIFICIAL (decl
))
2786 DECL_NOT_REALLY_EXTERN (decl
)
2787 = ! (CLASSTYPE_INTERFACE_ONLY (ctype
)
2788 || (DECL_THIS_INLINE (decl
) && ! flag_implement_inlines
));
2791 comdat_linkage (decl
);
2793 /* tinfo function */
2794 else if (DECL_ARTIFICIAL (decl
) && DECL_MUTABLE_P (decl
))
2796 tree ctype
= TREE_TYPE (DECL_NAME (decl
));
2797 if (IS_AGGR_TYPE (ctype
) && CLASSTYPE_INTERFACE_KNOWN (ctype
)
2798 && TYPE_VIRTUAL_P (ctype
))
2800 DECL_NOT_REALLY_EXTERN (decl
)
2801 = ! (CLASSTYPE_INTERFACE_ONLY (ctype
)
2802 || (DECL_THIS_INLINE (decl
) && ! flag_implement_inlines
));
2804 else if (TYPE_BUILT_IN (ctype
) && ctype
== TYPE_MAIN_VARIANT (ctype
))
2805 DECL_NOT_REALLY_EXTERN (decl
) = 0;
2807 comdat_linkage (decl
);
2809 else if (DECL_C_STATIC (decl
))
2810 TREE_PUBLIC (decl
) = 0;
2812 comdat_linkage (decl
);
2814 DECL_INTERFACE_KNOWN (decl
) = 1;
2818 build_cleanup (decl
)
2822 tree type
= TREE_TYPE (decl
);
2824 if (TREE_CODE (type
) == ARRAY_TYPE
)
2828 mark_addressable (decl
);
2829 temp
= build1 (ADDR_EXPR
, build_pointer_type (type
), decl
);
2831 temp
= build_delete (TREE_TYPE (temp
), temp
,
2833 LOOKUP_NORMAL
|LOOKUP_NONVIRTUAL
|LOOKUP_DESTRUCTOR
, 0);
2837 extern int parse_time
, varconst_time
;
2838 extern tree pending_templates
;
2839 extern tree maybe_templates
;
2841 extern struct obstack permanent_obstack
;
2847 tree sname
= get_id_2 ("__sn", base
);
2848 tree sentry
= IDENTIFIER_GLOBAL_VALUE (sname
);
2851 push_obstacks (&permanent_obstack
, &permanent_obstack
);
2852 sentry
= build_decl (VAR_DECL
, sname
, integer_type_node
);
2853 TREE_PUBLIC (sentry
) = 1;
2854 DECL_ARTIFICIAL (sentry
) = 1;
2855 TREE_STATIC (sentry
) = 1;
2856 TREE_USED (sentry
) = 1;
2857 DECL_COMMON (sentry
) = 1;
2858 pushdecl_top_level (sentry
);
2859 cp_finish_decl (sentry
, NULL_TREE
, NULL_TREE
, 0, 0);
2865 /* This routine is called from the last rule in yyparse ().
2866 Its job is to create all the code needed to initialize and
2867 destroy the global aggregates. We do the destruction
2868 first, since that way we only need to reverse the decls once. */
2874 int start_time
, this_time
;
2878 int needs_cleaning
= 0, needs_messing_up
= 0;
2882 if (flag_detailed_statistics
)
2883 dump_tree_statistics ();
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
, 0);
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, so just disable inlining. We want a
3265 variant of output_inline_function that doesn't
3266 prevent subsequent integration... */
3268 temporary_allocation ();
3269 output_inline_function (decl
);
3270 permanent_allocation (1);
3273 *p
= TREE_CHAIN (*p
);
3276 p
= &TREE_CHAIN (*p
);
3281 /* Now delete from the chain of variables all virtual function tables.
3282 We output them all ourselves, because each will be treated specially. */
3284 walk_vtables ((void (*) PROTO((tree
, tree
))) 0,
3285 prune_vtable_vardecl
);
3287 for (vars
= getdecls (); vars
; vars
= TREE_CHAIN (vars
))
3289 if (TREE_CODE (vars
) == FUNCTION_DECL
3290 && ! DECL_INTERFACE_KNOWN (vars
)
3291 && DECL_C_STATIC (vars
))
3292 TREE_PUBLIC (vars
) = 0;
3295 if (write_virtuals
== 2)
3297 /* Now complain about an virtual function tables promised
3298 but not delivered. */
3299 while (pending_vtables
)
3301 if (TREE_PURPOSE (pending_vtables
) == NULL_TREE
)
3302 error ("virtual function table for `%s' not defined",
3303 IDENTIFIER_POINTER (TREE_VALUE (pending_vtables
)));
3304 pending_vtables
= TREE_CHAIN (pending_vtables
);
3310 this_time
= get_run_time ();
3311 parse_time
-= this_time
- start_time
;
3312 varconst_time
+= this_time
- start_time
;
3314 if (flag_detailed_statistics
)
3315 dump_time_statistics ();
3318 /* This is something of the form 'A()()()()()+1' that has turned out to be an
3319 expr. Since it was parsed like a type, we need to wade through and fix
3320 that. Unfortunately, since operator() is left-associative, we can't use
3321 tail recursion. In the above example, TYPE is `A', and DECL is
3324 Maybe this shouldn't be recursive, but how often will it actually be
3328 reparse_absdcl_as_expr (type
, decl
)
3331 /* do build_functional_cast (type, NULL_TREE) at bottom */
3332 if (TREE_OPERAND (decl
, 0) == NULL_TREE
)
3333 return build_functional_cast (type
, NULL_TREE
);
3336 decl
= reparse_decl_as_expr (type
, TREE_OPERAND (decl
, 0));
3338 decl
= build_x_function_call (decl
, NULL_TREE
, current_class_ref
);
3340 if (TREE_CODE (decl
) == CALL_EXPR
&& TREE_TYPE (decl
) != void_type_node
)
3341 decl
= require_complete_type (decl
);
3346 /* This is something of the form `int ((int)(int)(int)1)' that has turned
3347 out to be an expr. Since it was parsed like a type, we need to wade
3348 through and fix that. Since casts are right-associative, we are
3349 reversing the order, so we don't have to recurse.
3351 In the above example, DECL is the `(int)(int)(int)', and EXPR is the
3355 reparse_absdcl_as_casts (decl
, expr
)
3360 if (TREE_CODE (expr
) == CONSTRUCTOR
3361 && TREE_TYPE (expr
) == 0)
3363 type
= groktypename (TREE_VALUE (TREE_OPERAND (decl
, 1)));
3364 decl
= TREE_OPERAND (decl
, 0);
3366 if (IS_SIGNATURE (type
))
3368 error ("cast specifies signature type");
3369 return error_mark_node
;
3372 expr
= digest_init (type
, expr
, (tree
*) 0);
3373 if (TREE_CODE (type
) == ARRAY_TYPE
&& TYPE_SIZE (type
) == 0)
3375 int failure
= complete_array_type (type
, expr
, 1);
3377 my_friendly_abort (78);
3383 type
= groktypename (TREE_VALUE (TREE_OPERAND (decl
, 1)));
3384 decl
= TREE_OPERAND (decl
, 0);
3385 expr
= build_c_cast (type
, expr
);
3391 /* Given plain tree nodes for an expression, build up the full semantics. */
3394 build_expr_from_tree (t
)
3397 if (t
== NULL_TREE
|| t
== error_mark_node
)
3400 switch (TREE_CODE (t
))
3402 case IDENTIFIER_NODE
:
3403 return do_identifier (t
, 0);
3406 if (LOOKUP_EXPR_GLOBAL (t
))
3407 return do_scoped_id (TREE_OPERAND (t
, 0), 0);
3409 return do_identifier (TREE_OPERAND (t
, 0), 0);
3411 case TEMPLATE_ID_EXPR
:
3412 return lookup_template_function (build_expr_from_tree
3413 (TREE_OPERAND (t
, 0)),
3414 build_expr_from_tree
3415 (TREE_OPERAND (t
, 1)));
3418 return build_x_indirect_ref
3419 (build_expr_from_tree (TREE_OPERAND (t
, 0)), "unary *");
3422 return build_functional_cast
3423 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3425 case REINTERPRET_CAST_EXPR
:
3426 return build_reinterpret_cast
3427 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3429 case CONST_CAST_EXPR
:
3430 return build_const_cast
3431 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3433 case DYNAMIC_CAST_EXPR
:
3434 return build_dynamic_cast
3435 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3437 case STATIC_CAST_EXPR
:
3438 return build_static_cast
3439 (TREE_TYPE (t
), build_expr_from_tree (TREE_OPERAND (t
, 0)));
3441 case PREDECREMENT_EXPR
:
3442 case PREINCREMENT_EXPR
:
3443 case POSTDECREMENT_EXPR
:
3444 case POSTINCREMENT_EXPR
:
3448 case TRUTH_NOT_EXPR
:
3450 case CONVERT_EXPR
: /* Unary + */
3453 return build_x_unary_op (TREE_CODE (t
),
3454 build_expr_from_tree (TREE_OPERAND (t
, 0)));
3459 case TRUNC_DIV_EXPR
:
3461 case FLOOR_DIV_EXPR
:
3462 case ROUND_DIV_EXPR
:
3463 case EXACT_DIV_EXPR
:
3465 case BIT_ANDTC_EXPR
:
3468 case TRUNC_MOD_EXPR
:
3469 case FLOOR_MOD_EXPR
:
3470 case TRUTH_ANDIF_EXPR
:
3471 case TRUTH_ORIF_EXPR
:
3472 case TRUTH_AND_EXPR
:
3487 return build_x_binary_op
3489 build_expr_from_tree (TREE_OPERAND (t
, 0)),
3490 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3493 return build_m_component_ref
3494 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3495 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3498 return build_offset_ref (TREE_OPERAND (t
, 0), TREE_OPERAND (t
, 1));
3501 if (TREE_OPERAND (t
, 0) == NULL_TREE
)
3503 return build_parse_node (ARRAY_REF
, NULL_TREE
,
3504 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3505 return grok_array_decl (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3506 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3510 tree r
= build_expr_from_tree (TREE_OPERAND (t
, 0));
3511 if (TREE_CODE_CLASS (TREE_CODE (r
)) != 't')
3513 return c_sizeof (r
);
3517 return build_x_modify_expr
3518 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3519 TREE_CODE (TREE_OPERAND (t
, 1)),
3520 build_expr_from_tree (TREE_OPERAND (t
, 2)));
3523 return build_x_arrow
3524 (build_expr_from_tree (TREE_OPERAND (t
, 0)));
3528 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3529 build_expr_from_tree (TREE_OPERAND (t
, 1)),
3530 build_expr_from_tree (TREE_OPERAND (t
, 2)),
3531 NEW_EXPR_USE_GLOBAL (t
));
3534 return delete_sanity
3535 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3536 build_expr_from_tree (TREE_OPERAND (t
, 1)),
3537 DELETE_EXPR_USE_VEC (t
), DELETE_EXPR_USE_GLOBAL (t
));
3540 if (TREE_OPERAND (t
, 1) == NULL_TREE
)
3541 return build_x_compound_expr
3542 (build_expr_from_tree (TREE_OPERAND (t
, 0)));
3544 my_friendly_abort (42);
3546 case METHOD_CALL_EXPR
:
3547 if (TREE_CODE (TREE_OPERAND (t
, 0)) == SCOPE_REF
)
3549 tree ref
= TREE_OPERAND (t
, 0);
3550 return build_scoped_method_call
3551 (build_expr_from_tree (TREE_OPERAND (t
, 1)),
3552 build_expr_from_tree (TREE_OPERAND (ref
, 0)),
3553 TREE_OPERAND (ref
, 1),
3554 build_expr_from_tree (TREE_OPERAND (t
, 2)));
3556 return build_method_call
3557 (build_expr_from_tree (TREE_OPERAND (t
, 1)),
3558 TREE_OPERAND (t
, 0),
3559 build_expr_from_tree (TREE_OPERAND (t
, 2)),
3560 NULL_TREE
, LOOKUP_NORMAL
);
3563 if (TREE_CODE (TREE_OPERAND (t
, 0)) == SCOPE_REF
)
3565 tree ref
= TREE_OPERAND (t
, 0);
3566 return build_member_call
3567 (build_expr_from_tree (TREE_OPERAND (ref
, 0)),
3568 TREE_OPERAND (ref
, 1),
3569 build_expr_from_tree (TREE_OPERAND (t
, 1)));
3573 tree name
= TREE_OPERAND (t
, 0);
3574 if (! really_overloaded_fn (name
))
3575 name
= build_expr_from_tree (name
);
3576 return build_x_function_call
3577 (name
, build_expr_from_tree (TREE_OPERAND (t
, 1)),
3582 return build_x_conditional_expr
3583 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3584 build_expr_from_tree (TREE_OPERAND (t
, 1)),
3585 build_expr_from_tree (TREE_OPERAND (t
, 2)));
3589 tree purpose
, value
, chain
;
3591 if (t
== void_list_node
)
3594 purpose
= TREE_PURPOSE (t
);
3596 purpose
= build_expr_from_tree (purpose
);
3597 value
= TREE_VALUE (t
);
3599 value
= build_expr_from_tree (value
);
3600 chain
= TREE_CHAIN (t
);
3601 if (chain
&& chain
!= void_type_node
)
3602 chain
= build_expr_from_tree (chain
);
3603 return tree_cons (purpose
, value
, chain
);
3607 return build_x_component_ref
3608 (build_expr_from_tree (TREE_OPERAND (t
, 0)),
3609 TREE_OPERAND (t
, 1), NULL_TREE
, 1);
3612 return build_throw (build_expr_from_tree (TREE_OPERAND (t
, 0)));
3616 tree r
= build_nt (CONSTRUCTOR
, NULL_TREE
,
3617 build_expr_from_tree (CONSTRUCTOR_ELTS (t
)));
3620 return digest_init (TREE_TYPE (t
), r
, 0);
3625 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t
, 0))) == 't')
3626 return get_typeid (TREE_OPERAND (t
, 0));
3627 return build_x_typeid (build_expr_from_tree (TREE_OPERAND (t
, 0)));
3630 return convert_from_reference (t
);
3637 /* This is something of the form `int (*a)++' that has turned out to be an
3638 expr. It was only converted into parse nodes, so we need to go through
3639 and build up the semantics. Most of the work is done by
3640 build_expr_from_tree, above.
3642 In the above example, TYPE is `int' and DECL is `*a'. */
3645 reparse_decl_as_expr (type
, decl
)
3648 decl
= build_expr_from_tree (decl
);
3650 return build_functional_cast (type
, build_tree_list (NULL_TREE
, decl
));
3655 /* This is something of the form `int (*a)' that has turned out to be a
3656 decl. It was only converted into parse nodes, so we need to do the
3657 checking that make_{pointer,reference}_declarator do. */
3660 finish_decl_parsing (decl
)
3663 extern int current_class_depth
;
3665 switch (TREE_CODE (decl
))
3667 case IDENTIFIER_NODE
:
3670 return make_pointer_declarator
3671 (NULL_TREE
, finish_decl_parsing (TREE_OPERAND (decl
, 0)));
3673 return make_reference_declarator
3674 (NULL_TREE
, finish_decl_parsing (TREE_OPERAND (decl
, 0)));
3676 TREE_OPERAND (decl
, 0) = finish_decl_parsing (TREE_OPERAND (decl
, 0));
3679 push_nested_class (TREE_TYPE (TREE_OPERAND (decl
, 0)), 3);
3680 TREE_COMPLEXITY (decl
) = current_class_depth
;
3683 TREE_OPERAND (decl
, 0) = finish_decl_parsing (TREE_OPERAND (decl
, 0));
3686 my_friendly_abort (5);
3692 check_cp_case_value (value
)
3695 if (value
== NULL_TREE
)
3698 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
3699 STRIP_TYPE_NOPS (value
);
3701 if (TREE_READONLY_DECL_P (value
))
3703 value
= decl_constant_value (value
);
3704 STRIP_TYPE_NOPS (value
);
3706 value
= fold (value
);
3708 if (TREE_CODE (value
) != INTEGER_CST
3709 && value
!= error_mark_node
)
3711 cp_error ("case label `%E' does not reduce to an integer constant",
3713 value
= error_mark_node
;
3716 /* Promote char or short to int. */
3717 value
= default_conversion (value
);
3719 constant_expression_warning (value
);
3724 tree current_namespace
;
3726 /* Get the inner part of a namespace id. It doesn't have any prefix, nor
3727 postfix. Returns 0 if in global namespace. */
3732 tree x
= current_namespace
;
3734 x
= TREE_PURPOSE (x
);
3738 /* Build up a DECL_ASSEMBLER_NAME for NAME in the current namespace. */
3741 current_namespace_id (name
)
3744 tree old_id
= get_namespace_id ();
3747 /* Global names retain old encoding. */
3751 buf
= (char *) alloca (8 + IDENTIFIER_LENGTH (old_id
)
3752 + IDENTIFIER_LENGTH (name
));
3753 sprintf (buf
, "__ns_%s_%s", IDENTIFIER_POINTER (old_id
),
3754 IDENTIFIER_POINTER (name
));
3755 return get_identifier (buf
);
3759 do_namespace_alias (alias
, namespace)
3760 tree alias
, namespace;
3762 sorry ("namespace alias");
3766 do_toplevel_using_decl (decl
)
3770 if (TREE_CODE (decl
) == SCOPE_REF
3771 && TREE_OPERAND (decl
, 0) == std_node
)
3773 sorry ("using-declaration");
3775 if (decl
== NULL_TREE
|| decl
== error_mark_node
)
3778 if (TREE_CODE (decl
) == SCOPE_REF
)
3779 decl
= resolve_scope_to_name (NULL_TREE
, decl
);
3781 /* Is this the right way to do an id list? */
3782 if (TREE_CODE (decl
) != TREE_LIST
)
3789 pushdecl (TREE_VALUE (decl
));
3790 decl
= TREE_CHAIN (decl
);
3796 do_class_using_decl (decl
)
3801 if (TREE_CODE (decl
) != SCOPE_REF
)
3803 cp_error ("using-declaration for non-member at class scope");
3806 name
= TREE_OPERAND (decl
, 1);
3807 if (TREE_CODE (name
) == BIT_NOT_EXPR
)
3809 cp_error ("using-declaration for destructor");
3813 value
= build_lang_field_decl (USING_DECL
, name
, void_type_node
);
3814 DECL_INITIAL (value
) = TREE_OPERAND (decl
, 0);
3819 do_using_directive (namespace)
3822 if (namespace == std_node
)
3824 sorry ("using directive");
3828 check_default_args (x
)
3831 tree arg
= TYPE_ARG_TYPES (TREE_TYPE (x
));
3832 int saw_def
= 0, i
= 0 - (TREE_CODE (TREE_TYPE (x
)) == METHOD_TYPE
);
3833 for (; arg
&& arg
!= void_list_node
; arg
= TREE_CHAIN (arg
), ++i
)
3835 if (TREE_PURPOSE (arg
))
3839 cp_error ("default argument missing for parameter %P of `%#D'",
3850 TREE_USED (decl
) = 1;
3851 if (processing_template_decl
)
3853 assemble_external (decl
);
3854 /* Is it a synthesized method that needs to be synthesized? */
3855 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_CLASS_CONTEXT (decl
)
3856 && DECL_ARTIFICIAL (decl
) && ! DECL_INITIAL (decl
)
3857 /* Kludge: don't synthesize for default args. */
3858 && current_function_decl
)
3859 synthesize_method (decl
);
3860 if (DECL_LANG_SPECIFIC (decl
) && DECL_TEMPLATE_INFO (decl
))
3861 instantiate_decl (decl
);
3864 /* Helper function for named_class_head_sans_basetype nonterminal. */
3867 handle_class_head (aggr
, scope
, id
)
3868 tree aggr
, scope
, id
;
3870 if (TREE_CODE (id
) == TYPE_DECL
)
3874 cp_error ("`%T' does not have a nested type named `%D'", scope
, id
);
3876 cp_error ("no file-scope type named `%D'", id
);
3879 (aggr
, make_anon_name (), NULL_TREE
, 1);
3880 return TYPE_MAIN_DECL (id
);