1 /* Process declarations and variables for C compiler.
2 Copyright (C) 1988, 1992, 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* Process declarations and symbol lookup for C front end.
23 Also constructs types; the standard scalar types at initialization,
24 and structure, union, array and enum types when they are declared. */
26 /* ??? not all decl nodes are given the most useful possible
27 line numbers. For example, the CONST_DECLs for enum values. */
38 extern tree
grokdeclarator ();
39 extern tree
get_file_function_name ();
40 extern tree cleanups_this_call
;
41 static void grok_function_init ();
43 /* A list of virtual function tables we must make sure to write out. */
46 /* A list of static class variables. This is needed, because a
47 static class variable can be declared inside the class without
48 an initializer, and then initialized, staticly, outside the class. */
51 /* A list of functions which were declared inline, but which we
52 may need to emit outline anyway. */
53 static tree saved_inlines
;
55 /* Used to help generate temporary names which are unique within
56 a function. Reset to 0 by start_function. */
58 static int temp_name_counter
;
60 /* Same, but not reset. Local temp variables and global temp variables
61 can have the same name. */
62 static int global_temp_name_counter
;
64 /* Flag used when debugging spew.c */
66 extern int spew_debug
;
68 /* C (and C++) language-specific option variables. */
70 /* Nonzero means allow type mismatches in conditional expressions;
71 just make their values `void'. */
73 int flag_cond_mismatch
;
75 /* Nonzero means give `double' the same size as `float'. */
77 int flag_short_double
;
79 /* Nonzero means don't recognize the keyword `asm'. */
83 /* Nonzero means don't recognize the non-ANSI builtin functions. */
87 /* Nonzero means do some things the same way PCC does. */
91 /* Nonzero means to treat bitfields as unsigned unless they say `signed'. */
93 int flag_signed_bitfields
= 1;
95 /* Nonzero means handle `#ident' directives. 0 means ignore them. */
97 int flag_no_ident
= 0;
99 /* Nonzero means disable GNU extensions. */
103 /* Nonzero means do emit exported implementations of functions even if
104 they can be inlined. */
106 int flag_implement_inlines
= 1;
108 /* Nonzero means do emit exported implementations of templates, instead of
109 multiple static copies in each file that needs a definition. */
111 int flag_external_templates
= 0;
113 /* Nonzero means that the decision to emit or not emit the implementation of a
114 template depends on where the template is instantiated, rather than where
117 int flag_alt_external_templates
= 0;
119 /* Nonzero means that implicit instantiations will be emitted if needed. */
121 int flag_implicit_templates
= 1;
123 /* Nonzero means warn about implicit declarations. */
125 int warn_implicit
= 1;
127 /* Nonzero means warn when all ctors or dtors are private, and the class
130 int warn_ctor_dtor_privacy
= 1;
132 /* True if we want to implement vtbvales using "thunks".
133 The default is off now, but will be on later.
135 Also causes output of vtables to be controlled by whether
136 we seen the class's first non-inline virtual function. */
137 int flag_vtable_thunks
= 0;
139 /* Nonzero means give string constants the type `const char *'
140 to get extra warnings from them. These warnings will be too numerous
141 to be useful, except in thoroughly ANSIfied programs. */
143 int warn_write_strings
;
145 /* Nonzero means warn about pointer casts that can drop a type qualifier
146 from the pointer target type. */
150 /* Nonzero means warn that dbx info for template class methods isn't fully
153 int warn_template_debugging
;
155 /* Warn about traditional constructs whose meanings changed in ANSI C. */
157 int warn_traditional
;
159 /* Nonzero means warn about sizeof(function) or addition/subtraction
160 of function pointers. */
162 int warn_pointer_arith
;
164 /* Nonzero means warn for non-prototype function decls
165 or non-prototyped defs without previous prototype. */
167 int warn_strict_prototypes
;
169 /* Nonzero means warn for any function def without prototype decl. */
171 int warn_missing_prototypes
;
173 /* Nonzero means warn about multiple (redundant) decls for the same single
174 variable or function. */
176 int warn_redundant_decls
;
178 /* Warn if initializer is not completely bracketed. */
180 int warn_missing_braces
;
182 /* Warn about *printf or *scanf format/argument anomalies. */
186 /* Warn about a subscript that has type char. */
188 int warn_char_subscripts
;
190 /* Warn if a type conversion is done that might have confusing results. */
194 /* Warn if adding () is suggested. */
196 int warn_parentheses
= 1;
198 /* Non-zero means warn in function declared in derived class has the
199 same name as a virtual in the base class, but fails to match the
200 type signature of any virtual function in the base class. */
201 int warn_overloaded_virtual
;
203 /* Non-zero means warn when declaring a class that has a non virtual
204 destructor, when it really ought to have a virtual one. */
205 int warn_nonvdtor
= 1;
207 /* Non-zero means warn when a function is declared extern and later inline. */
208 int warn_extern_inline
;
210 /* Nonzero means `$' can be in an identifier.
211 See cccp.c for reasons why this breaks some obscure ANSI C programs. */
213 #ifndef DOLLARS_IN_IDENTIFIERS
214 #define DOLLARS_IN_IDENTIFIERS 1
216 int dollars_in_ident
= DOLLARS_IN_IDENTIFIERS
;
218 /* Nonzero for -no-strict-prototype switch: do not consider empty
219 argument prototype to mean function takes no arguments. */
221 int strict_prototype
= 1;
222 int strict_prototypes_lang_c
, strict_prototypes_lang_cplusplus
= 1;
224 /* Nonzero means that labels can be used as first-class objects */
228 /* Non-zero means to collect statistics which might be expensive
229 and to print them when we are done. */
230 int flag_detailed_statistics
;
232 /* C++ specific flags. */
233 /* Nonzero for -fall-virtual: make every member function (except
234 constructors) lay down in the virtual function table. Calls
235 can then either go through the virtual function table or not,
238 int flag_all_virtual
;
240 /* Zero means that `this' is a *const. This gives nice behavior in the
241 2.0 world. 1 gives 1.2-compatible behavior. 2 gives Spring behavior.
242 -2 means we're constructing an object and it has fixed type. */
244 int flag_this_is_variable
;
246 /* Nonzero means memoize our member lookups. */
248 int flag_memoize_lookups
; int flag_save_memoized_contexts
;
250 /* 3 means write out only virtuals function tables `defined'
251 in this implementation file.
252 2 means write out only specific virtual function tables
253 and give them (C) public access.
254 1 means write out virtual function tables and give them
256 0 means write out virtual function tables and give them
257 (C) static access (default).
258 -1 means declare virtual function tables extern. */
262 /* Nonzero means we should attempt to elide constructors when possible. */
264 int flag_elide_constructors
;
266 /* Nonzero means recognize and handle exception handling constructs.
267 Use ansi syntax and semantics. WORK IN PROGRESS! */
269 int flag_handle_exceptions
;
271 /* Nonzero means recognize and handle signature language constructs. */
273 int flag_handle_signatures
;
275 /* Nonzero means that member functions defined in class scope are
276 inline by default. */
278 int flag_default_inline
= 1;
280 /* Controls whether enums and ints freely convert.
281 1 means with complete freedom.
282 0 means enums can convert to ints, but not vice-versa. */
283 int flag_int_enum_equivalence
;
285 /* Controls whether compiler is operating under LUCID's Cadillac
286 system. 1 means yes, 0 means no. */
289 /* Controls whether compiler generates code to build objects
290 that can be collected when they become garbage. */
293 /* Controls whether compiler generates 'dossiers' that give
294 run-time type information. */
297 /* Nonzero if we wish to output cross-referencing information
298 for the GNU class browser. */
299 extern int flag_gnu_xref
;
301 /* Nonzero if compiler can make `reasonable' assumptions about
302 references and objects. For example, the compiler must be
303 conservative about the following and not assume that `a' is nonnull:
308 In general, it is `reasonable' to assume that for many programs,
309 and better code can be generated in that case. */
311 int flag_assume_nonnull_objects
;
313 /* Nonzero if we want to support huge (> 2^(sizeof(short)*8-1) bytes)
315 int flag_huge_objects
;
317 /* Nonzero if we want to conserve space in the .o files. We do this
318 by putting uninitialized data and runtime initialized data into
319 .common instead of .data at the expense of not flaging multiple
321 int flag_conserve_space
;
323 /* Table of language-dependent -f options.
324 STRING is the option name. VARIABLE is the address of the variable.
325 ON_VALUE is the value to store in VARIABLE
326 if `-fSTRING' is seen as an option.
327 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
329 static struct { char *string
; int *variable
; int on_value
;} lang_f_options
[] =
331 {"signed-char", &flag_signed_char
, 1},
332 {"unsigned-char", &flag_signed_char
, 0},
333 {"signed-bitfields", &flag_signed_bitfields
, 1},
334 {"unsigned-bitfields", &flag_signed_bitfields
, 0},
335 {"short-enums", &flag_short_enums
, 1},
336 {"short-double", &flag_short_double
, 1},
337 {"cond-mismatch", &flag_cond_mismatch
, 1},
338 {"asm", &flag_no_asm
, 0},
339 {"builtin", &flag_no_builtin
, 0},
340 {"ident", &flag_no_ident
, 0},
341 {"labels-ok", &flag_labels_ok
, 1},
342 {"stats", &flag_detailed_statistics
, 1},
343 {"this-is-variable", &flag_this_is_variable
, 1},
344 {"strict-prototype", &strict_prototypes_lang_cplusplus
, 1},
345 {"all-virtual", &flag_all_virtual
, 1},
346 {"memoize-lookups", &flag_memoize_lookups
, 1},
347 {"elide-constructors", &flag_elide_constructors
, 1},
348 {"handle-exceptions", &flag_handle_exceptions
, 1},
349 {"handle-signatures", &flag_handle_signatures
, 1},
350 {"default-inline", &flag_default_inline
, 1},
351 {"dollars-in-identifiers", &dollars_in_ident
, 1},
352 {"enum-int-equiv", &flag_int_enum_equivalence
, 1},
354 {"dossier", &flag_dossier
, 1},
355 {"xref", &flag_gnu_xref
, 1},
356 {"nonnull-objects", &flag_assume_nonnull_objects
, 1},
357 {"implement-inlines", &flag_implement_inlines
, 1},
358 {"external-templates", &flag_external_templates
, 1},
359 {"implicit-templates", &flag_implicit_templates
, 1},
360 {"huge-objects", &flag_huge_objects
, 1},
361 {"conserve-space", &flag_conserve_space
, 1},
362 {"vtable-thunks", &flag_vtable_thunks
, 1},
363 {"short-temps", &flag_short_temps
, 1},
366 /* Decode the string P as a language-specific option.
367 Return 1 if it is recognized (and handle it);
368 return 0 if not recognized. */
371 lang_decode_option (p
)
374 if (!strcmp (p
, "-ftraditional") || !strcmp (p
, "-traditional"))
375 flag_traditional
= 1, dollars_in_ident
= 1, flag_writable_strings
= 1,
376 flag_this_is_variable
= 1;
377 /* The +e options are for cfront compatibility. They come in as
378 `-+eN', to kludge around gcc.c's argument handling. */
379 else if (p
[0] == '-' && p
[1] == '+' && p
[2] == 'e')
381 int old_write_virtuals
= write_virtuals
;
384 else if (p
[3] == '0')
386 else if (p
[3] == '2')
388 else error ("invalid +e option");
389 if (old_write_virtuals
!= 0
390 && write_virtuals
!= old_write_virtuals
)
391 error ("conflicting +e options given");
393 else if (p
[0] == '-' && p
[1] == 'f')
395 /* Some kind of -f option.
396 P's value is the option sans `-f'.
397 Search for it in the table of options. */
401 /* Try special -f options. */
403 if (!strcmp (p
, "save-memoized"))
405 flag_memoize_lookups
= 1;
406 flag_save_memoized_contexts
= 1;
409 if (!strcmp (p
, "no-save-memoized"))
411 flag_memoize_lookups
= 0;
412 flag_save_memoized_contexts
= 0;
415 else if (! strncmp (p
, "cadillac", 8))
417 flag_cadillac
= atoi (p
+9);
420 else if (! strncmp (p
, "no-cadillac", 11))
425 else if (! strcmp (p
, "gc"))
428 /* This must come along for the ride. */
432 else if (! strcmp (p
, "no-gc"))
435 /* This must come along for the ride. */
439 else if (! strcmp (p
, "alt-external-templates"))
441 flag_external_templates
= 1;
442 flag_alt_external_templates
= 1;
445 else if (! strcmp (p
, "no-alt-external-templates"))
447 flag_alt_external_templates
= 0;
451 !found
&& j
< sizeof (lang_f_options
) / sizeof (lang_f_options
[0]);
454 if (!strcmp (p
, lang_f_options
[j
].string
))
456 *lang_f_options
[j
].variable
= lang_f_options
[j
].on_value
;
457 /* A goto here would be cleaner,
458 but breaks the vax pcc. */
461 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-'
462 && ! strcmp (p
+3, lang_f_options
[j
].string
))
464 *lang_f_options
[j
].variable
= ! lang_f_options
[j
].on_value
;
470 else if (p
[0] == '-' && p
[1] == 'W')
474 /* The -W options control the warning behavior of the compiler. */
477 if (p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-')
480 if (!strcmp (p
, "implicit"))
481 warn_implicit
= setting
;
482 else if (!strcmp (p
, "return-type"))
483 warn_return_type
= setting
;
484 else if (!strcmp (p
, "ctor-dtor-privacy"))
485 warn_ctor_dtor_privacy
= setting
;
486 else if (!strcmp (p
, "write-strings"))
487 warn_write_strings
= setting
;
488 else if (!strcmp (p
, "cast-qual"))
489 warn_cast_qual
= setting
;
490 else if (!strcmp (p
, "traditional"))
491 warn_traditional
= setting
;
492 else if (!strcmp (p
, "char-subscripts"))
493 warn_char_subscripts
= setting
;
494 else if (!strcmp (p
, "pointer-arith"))
495 warn_pointer_arith
= setting
;
496 else if (!strcmp (p
, "strict-prototypes"))
497 warn_strict_prototypes
= setting
;
498 else if (!strcmp (p
, "missing-prototypes"))
499 warn_missing_prototypes
= setting
;
500 else if (!strcmp (p
, "redundant-decls"))
501 warn_redundant_decls
= setting
;
502 else if (!strcmp (p
, "missing-braces"))
503 warn_missing_braces
= setting
;
504 else if (!strcmp (p
, "format"))
505 warn_format
= setting
;
506 else if (!strcmp (p
, "conversion"))
507 warn_conversion
= setting
;
508 else if (!strcmp (p
, "parentheses"))
509 warn_parentheses
= setting
;
510 else if (!strcmp (p
, "extern-inline"))
511 warn_extern_inline
= setting
;
512 else if (!strcmp (p
, "comment"))
513 ; /* cpp handles this one. */
514 else if (!strcmp (p
, "comments"))
515 ; /* cpp handles this one. */
516 else if (!strcmp (p
, "trigraphs"))
517 ; /* cpp handles this one. */
518 else if (!strcmp (p
, "import"))
519 ; /* cpp handles this one. */
520 else if (!strcmp (p
, "all"))
522 extra_warnings
= setting
;
523 warn_return_type
= setting
;
524 warn_unused
= setting
;
525 warn_implicit
= setting
;
526 warn_ctor_dtor_privacy
= setting
;
527 warn_switch
= setting
;
528 warn_format
= setting
;
529 warn_missing_braces
= setting
;
530 warn_extern_inline
= setting
;
531 /* We save the value of warn_uninitialized, since if they put
532 -Wuninitialized on the command line, we need to generate a
533 warning about not using it without also specifying -O. */
534 if (warn_uninitialized
!= 1)
535 warn_uninitialized
= (setting
? 2 : 0);
536 warn_template_debugging
= setting
;
539 else if (!strcmp (p
, "overloaded-virtual"))
540 warn_overloaded_virtual
= setting
;
543 else if (!strcmp (p
, "-ansi"))
544 flag_no_asm
= 1, dollars_in_ident
= 0, flag_ansi
= 1;
546 /* Undocumented, only ever used when you're invoking cc1plus by hand, since
547 it's probably safe to assume no sane person would ever want to use this
548 under normal circumstances. */
549 else if (!strcmp (p
, "-spew-debug"))
558 /* Incorporate `const' and `volatile' qualifiers for member functions.
559 FUNCTION is a TYPE_DECL or a FUNCTION_DECL.
560 QUALS is a list of qualifiers. */
562 grok_method_quals (ctype
, function
, quals
)
563 tree ctype
, function
, quals
;
565 tree fntype
= TREE_TYPE (function
);
566 tree raises
= TYPE_RAISES_EXCEPTIONS (fntype
);
570 extern tree ridpointers
[];
572 if (TREE_VALUE (quals
) == ridpointers
[(int)RID_CONST
])
574 if (TYPE_READONLY (ctype
))
575 error ("duplicate `%s' %s",
576 IDENTIFIER_POINTER (TREE_VALUE (quals
)),
577 (TREE_CODE (function
) == FUNCTION_DECL
578 ? "for member function" : "in type declaration"));
579 ctype
= build_type_variant (ctype
, 1, TYPE_VOLATILE (ctype
));
580 build_pointer_type (ctype
);
582 else if (TREE_VALUE (quals
) == ridpointers
[(int)RID_VOLATILE
])
584 if (TYPE_VOLATILE (ctype
))
585 error ("duplicate `%s' %s",
586 IDENTIFIER_POINTER (TREE_VALUE (quals
)),
587 (TREE_CODE (function
) == FUNCTION_DECL
588 ? "for member function" : "in type declaration"));
589 ctype
= build_type_variant (ctype
, TYPE_READONLY (ctype
), 1);
590 build_pointer_type (ctype
);
593 my_friendly_abort (20);
594 quals
= TREE_CHAIN (quals
);
597 fntype
= build_cplus_method_type (ctype
, TREE_TYPE (fntype
),
598 (TREE_CODE (fntype
) == METHOD_TYPE
599 ? TREE_CHAIN (TYPE_ARG_TYPES (fntype
))
600 : TYPE_ARG_TYPES (fntype
)));
602 fntype
= build_exception_variant (ctype
, fntype
, raises
);
604 TREE_TYPE (function
) = fntype
;
608 #if 0 /* Not used. */
609 /* This routine replaces cryptic DECL_NAMEs with readable DECL_NAMEs.
610 It leaves DECL_ASSEMBLER_NAMEs with the correct value. */
611 /* This does not yet work with user defined conversion operators
614 substitute_nice_name (decl
)
617 if (DECL_NAME (decl
) && TREE_CODE (DECL_NAME (decl
)) == IDENTIFIER_NODE
)
619 char *n
= decl_as_string (DECL_NAME (decl
), 1);
620 if (n
[strlen (n
) - 1] == ' ')
621 n
[strlen (n
) - 1] = 0;
622 DECL_NAME (decl
) = get_identifier (n
);
627 /* Warn when -fexternal-templates is used and #pragma
628 interface/implementation is not used all the times it should be,
631 warn_if_unknown_interface ()
633 static int already_warned
= 0;
634 if (++already_warned
== 1)
635 warning ("templates that are built with -fexternal-templates should be in files that have #pragma interface/implementation");
638 /* A subroutine of the parser, to handle a component list. */
640 grok_x_components (specs
, components
)
641 tree specs
, components
;
643 register tree t
, x
, tcode
;
645 /* We just got some friends. They have been recorded elsewhere. */
646 if (components
== void_type_node
)
649 if (components
== NULL_TREE
)
651 t
= groktypename (build_decl_list (specs
, NULL_TREE
));
655 error ("error in component specification");
659 switch (TREE_CODE (t
))
662 /* Static anonymous unions come out as VAR_DECLs. */
663 if (TREE_CODE (TREE_TYPE (t
)) == UNION_TYPE
664 && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_TYPE (t
))))
667 /* We return SPECS here, because in the parser it was ending
668 up with not doing anything to $$, which is what SPECS
674 /* This code may be needed for UNION_TYPEs as
676 tcode
= record_type_node
;
677 if (CLASSTYPE_DECLARED_CLASS(t
))
678 tcode
= class_type_node
;
679 else if (IS_SIGNATURE(t
))
680 tcode
= signature_type_node
;
681 else if (CLASSTYPE_DECLARED_EXCEPTION(t
))
682 tcode
= exception_type_node
;
684 t
= xref_defn_tag(tcode
, TYPE_IDENTIFIER(t
), NULL_TREE
);
686 CLASSTYPE_NO_GLOBALIZE(t
) = 1;
687 if (TYPE_LANG_SPECIFIC (t
)
688 && CLASSTYPE_DECLARED_EXCEPTION (t
))
695 if (TREE_CODE(t
) == UNION_TYPE
)
696 tcode
= union_type_node
;
698 tcode
= enum_type_node
;
700 t
= xref_defn_tag(tcode
, TYPE_IDENTIFIER(t
), NULL_TREE
);
701 if (TREE_CODE(t
) == UNION_TYPE
&& TYPE_CONTEXT(t
))
702 CLASSTYPE_NO_GLOBALIZE(t
) = 1;
703 if (TREE_CODE (t
) == UNION_TYPE
704 && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t
)))
706 struct pending_inline
**p
;
707 x
= build_lang_field_decl (FIELD_DECL
, NULL_TREE
, t
);
709 /* Wipe out memory of synthesized methods */
710 TYPE_HAS_CONSTRUCTOR (t
) = 0;
711 TYPE_HAS_DEFAULT_CONSTRUCTOR (t
) = 0;
712 TYPE_HAS_INIT_REF (t
) = 0;
713 TYPE_HAS_CONST_INIT_REF (t
) = 0;
714 TYPE_HAS_ASSIGN_REF (t
) = 0;
715 TYPE_HAS_ASSIGNMENT (t
) = 0;
716 TYPE_HAS_CONST_ASSIGN_REF (t
) = 0;
718 p
= &pending_inlines
;
719 for (; *p
; *p
= (*p
)->next
)
720 if (DECL_CONTEXT ((*p
)->fndecl
) != t
)
723 else if (TREE_CODE (t
) == ENUMERAL_TYPE
)
724 x
= grok_enum_decls (t
, NULL_TREE
);
731 if (t
!= void_type_node
)
732 error ("empty component declaration");
738 t
= TREE_TYPE (components
);
739 if (TREE_CODE (t
) == ENUMERAL_TYPE
&& TREE_NONLOCAL_FLAG (t
))
740 return grok_enum_decls (t
, components
);
746 /* Classes overload their constituent function names automatically.
747 When a function name is declared in a record structure,
748 its name is changed to it overloaded name. Since names for
749 constructors and destructors can conflict, we place a leading
752 CNAME is the name of the class we are grokking for.
754 FUNCTION is a FUNCTION_DECL. It was created by `grokdeclarator'.
756 FLAGS contains bits saying what's special about today's
757 arguments. 1 == DESTRUCTOR. 2 == OPERATOR.
759 If FUNCTION is a destructor, then we must add the `auto-delete' field
760 as a second parameter. There is some hair associated with the fact
761 that we must "declare" this variable in the manner consistent with the
762 way the rest of the arguments were declared.
764 QUALS are the qualifiers for the this pointer. */
767 grokclassfn (ctype
, cname
, function
, flags
, quals
)
768 tree ctype
, cname
, function
;
769 enum overload_flags flags
;
772 tree fn_name
= DECL_NAME (function
);
777 if (fn_name
== NULL_TREE
)
779 error ("name missing for member function");
780 fn_name
= get_identifier ("<anonymous>");
781 DECL_NAME (function
) = fn_name
;
785 qualtype
= grok_method_quals (ctype
, function
, quals
);
789 arg_types
= TYPE_ARG_TYPES (TREE_TYPE (function
));
790 if (TREE_CODE (TREE_TYPE (function
)) == METHOD_TYPE
)
792 /* Must add the class instance variable up front. */
793 /* Right now we just make this a pointer. But later
794 we may wish to make it special. */
795 tree type
= TREE_VALUE (arg_types
);
797 if ((flag_this_is_variable
> 0)
798 && (flags
== DTOR_FLAG
|| DECL_CONSTRUCTOR_P (function
)))
799 type
= TYPE_MAIN_VARIANT (type
);
801 if (DECL_CONSTRUCTOR_P (function
))
803 if (TYPE_USES_VIRTUAL_BASECLASSES (ctype
))
805 DECL_CONSTRUCTOR_FOR_VBASE_P (function
) = 1;
806 /* In this case we need "in-charge" flag saying whether
807 this constructor is responsible for initialization
808 of virtual baseclasses or not. */
809 parm
= build_decl (PARM_DECL
, in_charge_identifier
, integer_type_node
);
810 /* Mark the artificial `__in_chrg' parameter as "artificial". */
811 SET_DECL_ARTIFICIAL (parm
);
812 DECL_ARG_TYPE (parm
) = integer_type_node
;
813 DECL_REGISTER (parm
) = 1;
814 TREE_CHAIN (parm
) = last_function_parms
;
815 last_function_parms
= parm
;
819 parm
= build_decl (PARM_DECL
, this_identifier
, type
);
820 /* Mark the artificial `this' parameter as "artificial". */
821 SET_DECL_ARTIFICIAL (parm
);
822 DECL_ARG_TYPE (parm
) = type
;
823 /* We can make this a register, so long as we don't
824 accidentally complain if someone tries to take its address. */
825 DECL_REGISTER (parm
) = 1;
826 if (TYPE_READONLY (type
))
827 TREE_READONLY (parm
) = 1;
828 TREE_CHAIN (parm
) = last_function_parms
;
829 last_function_parms
= parm
;
832 if (flags
== DTOR_FLAG
)
835 tree const_integer_type
= build_type_variant (integer_type_node
, 1, 0);
836 int len
= sizeof (DESTRUCTOR_DECL_PREFIX
)-1;
838 arg_types
= hash_tree_chain (const_integer_type
, void_list_node
);
839 TREE_SIDE_EFFECTS (arg_types
) = 1;
840 /* Build the overload name. It will look like `7Example'. */
841 if (IDENTIFIER_TYPE_VALUE (cname
))
842 dbuf
= build_overload_name (IDENTIFIER_TYPE_VALUE (cname
), 1, 1);
843 else if (IDENTIFIER_LOCAL_VALUE (cname
))
844 dbuf
= build_overload_name (TREE_TYPE (IDENTIFIER_LOCAL_VALUE (cname
)), 1, 1);
846 /* Using ctype fixes the `X::Y::~Y()' crash. The cname has no type when
847 it's defined out of the class definition, since poplevel_class wipes
848 it out. This used to be internal error 346. */
849 dbuf
= build_overload_name (ctype
, 1, 1);
850 buf
= (char *) alloca (strlen (dbuf
) + sizeof (DESTRUCTOR_DECL_PREFIX
));
851 bcopy (DESTRUCTOR_DECL_PREFIX
, buf
, len
);
854 DECL_ASSEMBLER_NAME (function
) = get_identifier (buf
);
855 parm
= build_decl (PARM_DECL
, in_charge_identifier
, const_integer_type
);
856 /* Mark the artificial `__in_chrg' parameter as "artificial". */
857 SET_DECL_ARTIFICIAL (parm
);
858 TREE_USED (parm
) = 1;
860 /* We don't need to mark the __in_chrg parameter itself as `const'
861 since its type is already `const int'. In fact we MUST NOT mark
862 it as `const' cuz that will screw up the debug info (causing it
863 to say that the type of __in_chrg is `const const int'). */
864 TREE_READONLY (parm
) = 1;
866 DECL_ARG_TYPE (parm
) = const_integer_type
;
867 /* This is the same chain as DECL_ARGUMENTS (...). */
868 TREE_CHAIN (last_function_parms
) = parm
;
870 TREE_TYPE (function
) = build_cplus_method_type (qualtype
, void_type_node
,
872 TYPE_HAS_DESTRUCTOR (ctype
) = 1;
876 tree these_arg_types
;
878 if (DECL_CONSTRUCTOR_FOR_VBASE_P (function
))
880 arg_types
= hash_tree_chain (integer_type_node
,
881 TREE_CHAIN (arg_types
));
883 = build_cplus_method_type (qualtype
,
884 TREE_TYPE (TREE_TYPE (function
)),
886 arg_types
= TYPE_ARG_TYPES (TREE_TYPE (function
));
889 these_arg_types
= arg_types
;
891 if (TREE_CODE (TREE_TYPE (function
)) == FUNCTION_TYPE
)
892 /* Only true for static member functions. */
893 these_arg_types
= hash_tree_chain (TYPE_POINTER_TO (qualtype
),
896 DECL_ASSEMBLER_NAME (function
)
897 = build_decl_overload (fn_name
, these_arg_types
,
898 1 + DECL_CONSTRUCTOR_P (function
));
901 /* This code is going into the compiler, but currently, it makes
902 libg++/src/Interger.cc not compile. The problem is that the nice name
903 winds up going into the symbol table, and conversion operations look
904 for the manged name. */
905 substitute_nice_name (function
);
909 DECL_ARGUMENTS (function
) = last_function_parms
;
910 /* First approximations. */
911 DECL_CONTEXT (function
) = ctype
;
912 DECL_CLASS_CONTEXT (function
) = ctype
;
915 /* Work on the expr used by alignof (this is only called by the parser). */
923 if (TREE_CODE (expr
) == COMPONENT_REF
924 && DECL_BIT_FIELD (TREE_OPERAND (expr
, 1)))
925 error ("`__alignof__' applied to a bit-field");
927 if (TREE_CODE (expr
) == INDIRECT_REF
)
929 best
= t
= TREE_OPERAND (expr
, 0);
930 bestalign
= TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t
)));
932 while (TREE_CODE (t
) == NOP_EXPR
933 && TREE_CODE (TREE_TYPE (TREE_OPERAND (t
, 0))) == POINTER_TYPE
)
936 t
= TREE_OPERAND (t
, 0);
937 thisalign
= TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t
)));
938 if (thisalign
> bestalign
)
939 best
= t
, bestalign
= thisalign
;
941 return c_alignof (TREE_TYPE (TREE_TYPE (best
)));
945 /* ANSI says arrays and fns are converted inside comma.
946 But we can't convert them in build_compound_expr
947 because that would break commas in lvalues.
948 So do the conversion here if operand was a comma. */
949 if (TREE_CODE (expr
) == COMPOUND_EXPR
950 && (TREE_CODE (TREE_TYPE (expr
)) == ARRAY_TYPE
951 || TREE_CODE (TREE_TYPE (expr
)) == FUNCTION_TYPE
))
952 expr
= default_conversion (expr
);
953 return c_alignof (TREE_TYPE (expr
));
957 /* Create an ARRAY_REF, checking for the user doing things backwards
960 grok_array_decl (array_expr
, index_exp
)
961 tree array_expr
, index_exp
;
963 tree type
= TREE_TYPE (array_expr
);
965 if (type
== error_mark_node
|| index_exp
== error_mark_node
)
966 return error_mark_node
;
967 if (type
== NULL_TREE
)
969 /* Something has gone very wrong. Assume we are mistakenly reducing
970 an expression instead of a declaration. */
971 error ("parser may be lost: is there a '{' missing somewhere?");
975 if (TREE_CODE (type
) == OFFSET_TYPE
976 || TREE_CODE (type
) == REFERENCE_TYPE
)
977 type
= TREE_TYPE (type
);
979 /* If they have an `operator[]', use that. */
980 if (TYPE_LANG_SPECIFIC (type
)
981 && TYPE_OVERLOADS_ARRAY_REF (type
))
982 return build_opfncall (ARRAY_REF
, LOOKUP_NORMAL
,
983 array_expr
, index_exp
, NULL_TREE
);
985 /* Otherwise, create an ARRAY_REF for a pointer or array type. */
986 if (TREE_CODE (type
) == POINTER_TYPE
987 || TREE_CODE (type
) == ARRAY_TYPE
)
988 return build_array_ref (array_expr
, index_exp
);
990 /* Woops, looks like they did something like `5[a]' instead of `a[5]'.
991 We don't emit a warning or error for this, since it's allowed
994 type
= TREE_TYPE (index_exp
);
996 if (TREE_CODE (type
) == OFFSET_TYPE
997 || TREE_CODE (type
) == REFERENCE_TYPE
)
998 type
= TREE_TYPE (type
);
1000 if (TYPE_LANG_SPECIFIC (type
)
1001 && TYPE_OVERLOADS_ARRAY_REF (type
))
1002 error ("array expression backwards");
1003 else if (TREE_CODE (type
) == POINTER_TYPE
1004 || TREE_CODE (type
) == ARRAY_TYPE
)
1005 return build_array_ref (index_exp
, array_expr
);
1007 error("`[]' applied to non-pointer type");
1009 /* We gave an error, so give an error. Huh? */
1010 return error_mark_node
;
1013 /* Given the cast expression EXP, checking out its validity. Either return
1014 an error_mark_node if there was an unavoidable error, return a cast to
1015 void for trying to delete a pointer w/ the value 0, or return the
1016 call to delete. If DOING_VEC is 1, we handle things differently
1017 for doing an array delete. If DOING_VEC is 2, they gave us the
1018 array size as an argument to delete.
1019 Implements ARM $5.3.4. This is called from the parser. */
1021 delete_sanity (exp
, size
, doing_vec
, use_global_delete
)
1023 int doing_vec
, use_global_delete
;
1025 tree t
= stabilize_reference (convert_from_reference (exp
));
1026 tree type
= TREE_TYPE (t
);
1027 enum tree_code code
= TREE_CODE (type
);
1028 /* For a regular vector delete (aka, no size argument) we will pass
1029 this down as a NULL_TREE into build_vec_delete. */
1030 tree maxindex
= NULL_TREE
;
1031 /* This is used for deleting arrays. */
1037 maxindex
= build_binary_op (MINUS_EXPR
, size
, integer_one_node
, 1);
1038 if (! flag_traditional
)
1039 pedwarn ("anachronistic use of array size in vector delete");
1042 elt_size
= c_sizeof (type
);
1045 if (code
!= POINTER_TYPE
)
1047 cp_error ("type `%#T' argument given to `delete', expected pointer",
1049 return error_mark_node
;
1052 /* Deleting a pointer with the value zero is legal and has no effect. */
1053 if (integer_zerop (t
))
1054 return build1 (NOP_EXPR
, void_type_node
, t
);
1057 /* You can't delete a pointer to constant. */
1058 if (code
== POINTER_TYPE
&& TREE_READONLY (TREE_TYPE (type
)))
1060 error ("`const *' cannot be deleted");
1061 return error_mark_node
;
1065 /* If the type has no destructor, then we should build a regular
1066 delete, instead of a vector delete. Otherwise, we would end
1067 up passing a bogus offset into __builtin_delete, which is
1068 not expecting it. */
1070 && TREE_CODE (type
) == POINTER_TYPE
1071 && !TYPE_HAS_DESTRUCTOR (TREE_TYPE (type
)))
1074 use_global_delete
= 1;
1079 return build_vec_delete (t
, maxindex
, elt_size
, integer_one_node
,
1080 integer_two_node
, use_global_delete
);
1082 return build_delete (type
, t
, integer_three_node
,
1083 LOOKUP_NORMAL
|LOOKUP_HAS_IN_CHARGE
,
1087 /* Sanity check: report error if this function FUNCTION is not
1088 really a member of the class (CTYPE) it is supposed to belong to.
1089 CNAME is the same here as it is for grokclassfn above. */
1092 check_classfn (ctype
, cname
, function
)
1093 tree ctype
, cname
, function
;
1095 tree fn_name
= DECL_NAME (function
);
1097 tree method_vec
= CLASSTYPE_METHOD_VEC (ctype
);
1101 if (method_vec
!= 0)
1103 methods
= &TREE_VEC_ELT (method_vec
, 0);
1104 end
= TREE_VEC_END (method_vec
);
1106 /* First suss out ctors and dtors. */
1107 if (*methods
&& fn_name
== cname
)
1110 while (++methods
!= end
)
1112 if (fn_name
== DECL_NAME (*methods
))
1118 if (DECL_ASSEMBLER_NAME (function
) == DECL_ASSEMBLER_NAME (fndecl
))
1120 fndecl
= DECL_CHAIN (fndecl
);
1128 cp_error ("argument list for `%D' does not match any in class `%T'",
1133 cp_error ("no `%D' member function declared in class `%T'",
1137 /* If we did not find the method in the class, add it to
1138 avoid spurious errors. */
1139 add_method (ctype
, methods
, function
);
1142 /* Process the specs, declarator (NULL if omitted) and width (NULL if omitted)
1143 of a structure component, returning a FIELD_DECL node.
1144 QUALS is a list of type qualifiers for this decl (such as for declaring
1145 const member functions).
1147 This is done during the parsing of the struct declaration.
1148 The FIELD_DECL nodes are chained together and the lot of them
1149 are ultimately passed to `build_struct' to make the RECORD_TYPE node.
1153 If class A defines that certain functions in class B are friends, then
1154 the way I have set things up, it is B who is interested in permission
1155 granted by A. However, it is in A's context that these declarations
1156 are parsed. By returning a void_type_node, class A does not attempt
1157 to incorporate the declarations of the friends within its structure.
1159 DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING
1160 CHANGES TO CODE IN `start_method'. */
1163 grokfield (declarator
, declspecs
, raises
, init
, asmspec_tree
)
1164 tree declarator
, declspecs
, raises
, init
, asmspec_tree
;
1166 register tree value
;
1169 /* Convert () initializers to = initializers. */
1170 if (init
== NULL_TREE
&& declarator
!= NULL_TREE
1171 && TREE_CODE (declarator
) == CALL_EXPR
1172 && TREE_OPERAND (declarator
, 0)
1173 && (TREE_CODE (TREE_OPERAND (declarator
, 0)) == IDENTIFIER_NODE
1174 || TREE_CODE (TREE_OPERAND (declarator
, 0)) == SCOPE_REF
)
1175 && parmlist_is_exprlist (TREE_OPERAND (declarator
, 1)))
1177 init
= TREE_OPERAND (declarator
, 1);
1178 declarator
= TREE_OPERAND (declarator
, 0);
1182 && TREE_CODE (init
) == TREE_LIST
1183 && TREE_VALUE (init
) == error_mark_node
1184 && TREE_CHAIN (init
) == NULL_TREE
)
1187 value
= grokdeclarator (declarator
, declspecs
, FIELD
, init
!= 0, raises
);
1189 return value
; /* friend or constructor went bad. */
1191 /* Pass friendly classes back. */
1192 if (TREE_CODE (value
) == VOID_TYPE
)
1193 return void_type_node
;
1195 if (DECL_NAME (value
) != NULL_TREE
1196 && IDENTIFIER_POINTER (DECL_NAME (value
))[0] == '_'
1197 && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (value
)), "_vptr"))
1198 cp_error ("member `%D' conflicts with virtual function table field name", value
);
1200 /* Stash away type declarations. */
1201 if (TREE_CODE (value
) == TYPE_DECL
)
1203 DECL_NONLOCAL (value
) = 1;
1204 DECL_CONTEXT (value
) = current_class_type
;
1205 DECL_CLASS_CONTEXT (value
) = current_class_type
;
1206 CLASSTYPE_LOCAL_TYPEDECLS (current_class_type
) = 1;
1207 pushdecl_class_level (value
);
1211 if (IS_SIGNATURE (current_class_type
)
1212 && TREE_CODE (value
) != FUNCTION_DECL
)
1214 error ("field declaration not allowed in signature");
1215 return void_type_node
;
1218 if (DECL_IN_AGGR_P (value
))
1220 cp_error ("`%D' is already defined in the class %T", value
,
1221 DECL_CONTEXT (value
));
1222 return void_type_node
;
1226 cadillac_start_decl (value
);
1229 asmspec
= TREE_STRING_POINTER (asmspec_tree
);
1233 if (IS_SIGNATURE (current_class_type
)
1234 && TREE_CODE (value
) == FUNCTION_DECL
)
1236 error ("function declarations cannot have initializers in signature");
1239 else if (TREE_CODE (value
) == FUNCTION_DECL
)
1241 grok_function_init (value
, init
);
1244 else if (pedantic
&& ! TREE_STATIC (value
))
1245 /* Already complained in grokdeclarator. */
1249 /* We allow initializers to become parameters to base
1251 if (TREE_CODE (init
) == TREE_LIST
)
1253 if (TREE_CHAIN (init
) == NULL_TREE
)
1254 init
= TREE_VALUE (init
);
1256 init
= digest_init (TREE_TYPE (value
), init
, (tree
*)0);
1259 if (TREE_CODE (init
) == CONST_DECL
)
1260 init
= DECL_INITIAL (init
);
1261 else if (TREE_READONLY_DECL_P (init
))
1262 init
= decl_constant_value (init
);
1263 else if (TREE_CODE (init
) == CONSTRUCTOR
)
1264 init
= digest_init (TREE_TYPE (value
), init
, (tree
*)0);
1265 my_friendly_assert (TREE_PERMANENT (init
), 192);
1266 if (init
== error_mark_node
)
1267 /* We must make this look different than `error_mark_node'
1268 because `decl_const_value' would mis-interpret it
1269 as only meaning that this VAR_DECL is defined. */
1270 init
= build1 (NOP_EXPR
, TREE_TYPE (value
), init
);
1271 else if (! TREE_CONSTANT (init
))
1273 /* We can allow references to things that are effectively
1274 static, since references are initialized with the address. */
1275 if (TREE_CODE (TREE_TYPE (value
)) != REFERENCE_TYPE
1276 || (TREE_STATIC (init
) == 0
1277 && (TREE_CODE_CLASS (TREE_CODE (init
)) != 'd'
1278 || DECL_EXTERNAL (init
) == 0)))
1280 error ("field initializer is not constant");
1281 init
= error_mark_node
;
1287 /* The corresponding pop_obstacks is in finish_decl. */
1288 push_obstacks_nochange ();
1290 if (TREE_CODE (value
) == VAR_DECL
)
1292 /* We cannot call pushdecl here, because that would
1293 fill in the value of our TREE_CHAIN. Instead, we
1294 modify finish_decl to do the right thing, namely, to
1295 put this decl out straight away. */
1296 if (TREE_STATIC (value
))
1298 /* current_class_type can be NULL_TREE in case of error. */
1299 if (asmspec
== 0 && current_class_type
)
1304 buf2
= build_overload_name (current_class_type
, 1, 1);
1305 buf
= (char *)alloca (IDENTIFIER_LENGTH (DECL_NAME (value
))
1306 + sizeof (STATIC_NAME_FORMAT
)
1308 sprintf (buf
, STATIC_NAME_FORMAT
, buf2
,
1309 IDENTIFIER_POINTER (DECL_NAME (value
)));
1310 name
= get_identifier (buf
);
1311 TREE_PUBLIC (value
) = 1;
1312 DECL_INITIAL (value
) = error_mark_node
;
1313 DECL_ASSEMBLER_NAME (value
) = name
;
1315 pending_statics
= perm_tree_cons (NULL_TREE
, value
, pending_statics
);
1317 /* Static consts need not be initialized in the class definition. */
1318 if (init
!= NULL_TREE
&& TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (value
)))
1320 static int explanation
= 0;
1322 error ("initializer invalid for static member with constructor");
1323 if (explanation
++ == 0)
1324 error ("(you really want to initialize it separately)");
1327 /* Force the compiler to know when an uninitialized static
1328 const member is being used. */
1329 if (TYPE_READONLY (value
) && init
== 0)
1330 TREE_USED (value
) = 1;
1332 DECL_INITIAL (value
) = init
;
1333 DECL_IN_AGGR_P (value
) = 1;
1335 finish_decl (value
, init
, asmspec_tree
, 1);
1336 pushdecl_class_level (value
);
1339 if (TREE_CODE (value
) == FIELD_DECL
)
1342 DECL_ASSEMBLER_NAME (value
) = get_identifier (asmspec
);
1343 if (DECL_INITIAL (value
) == error_mark_node
)
1344 init
= error_mark_node
;
1345 finish_decl (value
, init
, asmspec_tree
, 1);
1346 DECL_INITIAL (value
) = init
;
1347 DECL_IN_AGGR_P (value
) = 1;
1350 if (TREE_CODE (value
) == FUNCTION_DECL
)
1352 if (DECL_CHAIN (value
) != NULL_TREE
)
1354 /* Need a fresh node here so that we don't get circularity
1355 when we link these together. */
1356 value
= copy_node (value
);
1357 /* When does this happen? */
1358 my_friendly_assert (init
== NULL_TREE
, 193);
1360 finish_decl (value
, init
, asmspec_tree
, 1);
1362 /* Pass friends back this way. */
1363 if (DECL_FRIEND_P (value
))
1364 return void_type_node
;
1366 if (current_function_decl
&& ! IS_SIGNATURE (current_class_type
))
1367 cp_error ("method `%#D' of local class must be defined in class body",
1370 DECL_IN_AGGR_P (value
) = 1;
1373 my_friendly_abort (21);
1378 /* Like `grokfield', but for bitfields.
1379 WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node. */
1382 grokbitfield (declarator
, declspecs
, width
)
1383 tree declarator
, declspecs
, width
;
1385 register tree value
= grokdeclarator (declarator
, declspecs
, BITFIELD
, 0, NULL_TREE
);
1387 if (! value
) return NULL_TREE
; /* friends went bad. */
1389 /* Pass friendly classes back. */
1390 if (TREE_CODE (value
) == VOID_TYPE
)
1391 return void_type_node
;
1393 if (TREE_CODE (value
) == TYPE_DECL
)
1395 cp_error ("cannot declare `%D' to be a bitfield type", value
);
1399 if (IS_SIGNATURE (current_class_type
))
1401 error ("field declaration not allowed in signature");
1402 return void_type_node
;
1405 if (DECL_IN_AGGR_P (value
))
1407 cp_error ("`%D' is already defined in the class %T", value
,
1408 DECL_CONTEXT (value
));
1409 return void_type_node
;
1412 GNU_xref_member (current_class_name
, value
);
1414 if (TREE_STATIC (value
))
1416 cp_error ("static member `%D' cannot be a bitfield", value
);
1419 finish_decl (value
, NULL_TREE
, NULL_TREE
, 0);
1421 if (width
!= error_mark_node
)
1423 /* detect invalid field size. */
1424 if (TREE_CODE (width
) == CONST_DECL
)
1425 width
= DECL_INITIAL (width
);
1426 else if (TREE_READONLY_DECL_P (width
))
1427 width
= decl_constant_value (width
);
1428 if (TREE_CODE (width
) != INTEGER_CST
)
1430 cp_error ("structure field `%D' width not an integer constant",
1432 DECL_INITIAL (value
) = NULL_TREE
;
1436 constant_expression_warning (width
);
1437 DECL_INITIAL (value
) = width
;
1438 DECL_BIT_FIELD (value
) = 1;
1442 DECL_IN_AGGR_P (value
) = 1;
1447 /* Like GROKFIELD, except that the declarator has been
1448 buried in DECLSPECS. Find the declarator, and
1449 return something that looks like it came from
1452 groktypefield (declspecs
, parmlist
)
1456 tree spec
= declspecs
;
1457 tree prev
= NULL_TREE
;
1459 tree type_id
= NULL_TREE
;
1460 tree quals
= NULL_TREE
;
1461 tree lengths
= NULL_TREE
;
1462 tree decl
= NULL_TREE
;
1466 register tree id
= TREE_VALUE (spec
);
1468 if (TREE_CODE (spec
) != TREE_LIST
)
1469 /* Certain parse errors slip through. For example,
1470 `int class ();' is not caught by the parser. Try
1471 weakly to recover here. */
1474 if (TREE_CODE (id
) == TYPE_DECL
1475 || (TREE_CODE (id
) == IDENTIFIER_NODE
&& TREE_TYPE (id
)))
1477 /* We have a constructor/destructor or
1478 conversion operator. Use it. */
1480 TREE_CHAIN (prev
) = TREE_CHAIN (spec
);
1482 declspecs
= TREE_CHAIN (spec
);
1488 spec
= TREE_CHAIN (spec
);
1491 /* Nope, we have a conversion operator to a scalar type or something
1492 else, that includes things like constructor declarations for
1497 tree id
= TREE_VALUE (spec
);
1499 if (TREE_CODE (id
) == IDENTIFIER_NODE
)
1501 if (id
== ridpointers
[(int)RID_INT
]
1502 || id
== ridpointers
[(int)RID_DOUBLE
]
1503 || id
== ridpointers
[(int)RID_FLOAT
]
1504 || id
== ridpointers
[(int)RID_WCHAR
])
1507 error ("extra `%s' ignored",
1508 IDENTIFIER_POINTER (id
));
1512 else if (id
== ridpointers
[(int)RID_LONG
]
1513 || id
== ridpointers
[(int)RID_SHORT
]
1514 || id
== ridpointers
[(int)RID_CHAR
])
1516 lengths
= tree_cons (NULL_TREE
, id
, lengths
);
1518 else if (id
== ridpointers
[(int)RID_VOID
])
1521 error ("spurious `void' type ignored");
1523 error ("conversion to `void' type invalid");
1525 else if (id
== ridpointers
[(int)RID_AUTO
]
1526 || id
== ridpointers
[(int)RID_REGISTER
]
1527 || id
== ridpointers
[(int)RID_TYPEDEF
]
1528 || id
== ridpointers
[(int)RID_CONST
]
1529 || id
== ridpointers
[(int)RID_VOLATILE
])
1531 error ("type specifier `%s' used invalidly",
1532 IDENTIFIER_POINTER (id
));
1534 else if (id
== ridpointers
[(int)RID_FRIEND
]
1535 || id
== ridpointers
[(int)RID_VIRTUAL
]
1536 || id
== ridpointers
[(int)RID_INLINE
]
1537 || id
== ridpointers
[(int)RID_UNSIGNED
]
1538 || id
== ridpointers
[(int)RID_SIGNED
]
1539 || id
== ridpointers
[(int)RID_STATIC
]
1540 || id
== ridpointers
[(int)RID_EXTERN
])
1542 quals
= tree_cons (NULL_TREE
, id
, quals
);
1546 /* Happens when we have a global typedef
1547 and a class-local member function with
1553 else if (TREE_CODE (id
) == RECORD_TYPE
)
1555 type_id
= TYPE_NAME (id
);
1556 if (TREE_CODE (type_id
) == TYPE_DECL
)
1557 type_id
= DECL_NAME (type_id
);
1558 if (type_id
== NULL_TREE
)
1559 error ("identifier for aggregate type conversion omitted");
1561 else if (TREE_CODE_CLASS (TREE_CODE (id
)) == 't')
1562 error ("`operator' missing on conversion operator or tag missing from type");
1564 my_friendly_abort (194);
1565 spec
= TREE_CHAIN (spec
);
1569 declspecs
= chainon (lengths
, quals
);
1572 if (TREE_CHAIN (lengths
))
1573 error ("multiple length specifiers");
1574 type_id
= ridpointers
[(int)RID_INT
];
1575 declspecs
= chainon (lengths
, quals
);
1579 error ("no type given, defaulting to `operator int ...'");
1580 type_id
= ridpointers
[(int)RID_INT
];
1587 decl
= grokdeclarator (build_parse_node (CALL_EXPR
, type_id
, parmlist
, NULL_TREE
),
1588 declspecs
, FIELD
, 0, NULL_TREE
);
1589 if (decl
== NULL_TREE
)
1592 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_CHAIN (decl
) != NULL_TREE
)
1594 /* Need a fresh node here so that we don't get circularity
1595 when we link these together. */
1596 decl
= copy_node (decl
);
1599 if (decl
== void_type_node
1600 || (TREE_CODE (decl
) == FUNCTION_DECL
1601 && TREE_CODE (TREE_TYPE (decl
)) != METHOD_TYPE
))
1602 /* bunch of friends. */
1605 if (DECL_IN_AGGR_P (decl
))
1607 cp_error ("`%D' already defined in the class ", decl
);
1608 return void_type_node
;
1611 finish_decl (decl
, NULL_TREE
, NULL_TREE
, 0);
1613 /* If this declaration is common to another declaration
1614 complain about such redundancy, and return NULL_TREE
1615 so that we don't build a circular list. */
1616 if (DECL_CHAIN (decl
))
1618 cp_error ("function `%D' declared twice in class %T", decl
,
1619 DECL_CONTEXT (decl
));
1622 DECL_IN_AGGR_P (decl
) = 1;
1628 grokoptypename (declspecs
, declarator
)
1629 tree declspecs
, declarator
;
1631 tree t
= grokdeclarator (declarator
, declspecs
, TYPENAME
, 0, NULL_TREE
);
1632 return build_typename_overload (t
);
1635 /* When a function is declared with an initializer,
1636 do the right thing. Currently, there are two possibilities:
1641 // initialization possibility #1.
1642 virtual void f () = 0;
1664 // initialization possibility #2
1671 copy_assignment_arg_p (parmtype
, virtualp
)
1675 if (TREE_CODE (parmtype
) == REFERENCE_TYPE
)
1676 parmtype
= TREE_TYPE (parmtype
);
1678 if ((TYPE_MAIN_VARIANT (parmtype
) == current_class_type
)
1679 || (virtualp
&& DERIVED_FROM_P (parmtype
, current_class_type
)))
1686 grok_function_init (decl
, init
)
1690 /* An initializer for a function tells how this function should
1692 tree type
= TREE_TYPE (decl
);
1694 if (TREE_CODE (type
) == FUNCTION_TYPE
)
1695 cp_error ("initializer specified for non-member function `%D'", decl
);
1696 else if (DECL_VINDEX (decl
) == NULL_TREE
)
1697 cp_error ("initializer specified for non-virtual method `%D'", decl
);
1698 else if (integer_zerop (init
))
1701 /* Mark this function as being "defined". */
1702 DECL_INITIAL (decl
) = error_mark_node
;
1703 /* pure virtual destructors must be defined. */
1704 /* pure virtual needs to be defined (as abort) only when put in
1705 vtbl. For wellformed call, it should be itself. pr4737 */
1706 if (!DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl
)))
1708 extern tree abort_fndecl
;
1709 /* Give this node rtl from `abort'. */
1710 DECL_RTL (decl
) = DECL_RTL (abort_fndecl
);
1713 DECL_ABSTRACT_VIRTUAL_P (decl
) = 1;
1714 if (DECL_NAME (decl
) == ansi_opname
[(int) MODIFY_EXPR
])
1717 = TREE_VALUE (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl
))));
1719 if (copy_assignment_arg_p (parmtype
, 1))
1720 TYPE_HAS_ABSTRACT_ASSIGN_REF (current_class_type
) = 1;
1723 else if (TREE_CODE (init
) == OFFSET_REF
1724 && TREE_OPERAND (init
, 0) == NULL_TREE
1725 && TREE_CODE (TREE_TYPE (init
)) == METHOD_TYPE
)
1727 tree basetype
= DECL_CLASS_CONTEXT (init
);
1728 tree basefn
= TREE_OPERAND (init
, 1);
1729 if (TREE_CODE (basefn
) != FUNCTION_DECL
)
1730 cp_error ("non-method initializer invalid for method `%D'", decl
);
1731 else if (! BINFO_OFFSET_ZEROP (TYPE_BINFO (DECL_CLASS_CONTEXT (basefn
))))
1732 sorry ("base member function from other than first base class");
1735 tree binfo
= get_binfo (basetype
, TYPE_METHOD_BASETYPE (type
), 1);
1736 if (binfo
== error_mark_node
)
1738 else if (binfo
== 0)
1739 error_not_base_type (TYPE_METHOD_BASETYPE (TREE_TYPE (init
)),
1740 TYPE_METHOD_BASETYPE (type
));
1743 /* Mark this function as being defined,
1744 and give it new rtl. */
1745 DECL_INITIAL (decl
) = error_mark_node
;
1746 DECL_RTL (decl
) = DECL_RTL (basefn
);
1751 cp_error ("invalid initializer for virtual method `%D'", decl
);
1754 /* When we get a declaration of the form
1756 type cname::fname ...
1758 the node for `cname::fname' gets built here in a special way.
1759 Namely, we push into `cname's scope. When this declaration is
1760 processed, we pop back out. */
1762 build_push_scope (cname
, name
)
1766 extern int current_class_depth
;
1770 if (cname
== error_mark_node
)
1771 return error_mark_node
;
1773 ctype
= IDENTIFIER_TYPE_VALUE (cname
);
1775 if (TREE_CODE (ctype
) == TEMPLATE_TYPE_PARM
)
1777 else if (ctype
== NULL_TREE
|| ! IS_AGGR_TYPE (ctype
))
1779 cp_error ("`%T' not defined as aggregate type", cname
);
1782 else if (IS_SIGNATURE (ctype
))
1784 error ("cannot push into signature scope, scope resolution operator ignored");
1788 rval
= build_parse_node (SCOPE_REF
, cname
, name
);
1790 /* Don't need to push the scope if we're already in it.
1791 We also don't need to push the scope for a ptr-to-member/method. */
1793 if (ctype
== current_class_type
|| TREE_CODE (name
) != IDENTIFIER_NODE
1797 /* We do need to push the scope in this case, since CTYPE helps
1798 determine subsequent intializers (i.e., Foo::Bar x = foo_enum_1;). */
1800 push_nested_class (ctype
, 3);
1801 TREE_COMPLEXITY (rval
) = current_class_depth
;
1805 void cplus_decl_attributes (decl
, attributes
)
1806 tree decl
, attributes
;
1808 if (decl
&& decl
!= void_type_node
)
1809 decl_attributes (decl
, attributes
);
1812 /* CONSTRUCTOR_NAME:
1813 Return the name for the constructor (or destructor) for the
1814 specified class. Argument can be RECORD_TYPE, TYPE_DECL, or
1815 IDENTIFIER_NODE. When given a template, this routine doesn't
1816 lose the specialization. */
1818 constructor_name_full (thing
)
1821 if (TREE_CODE (thing
) == UNINSTANTIATED_P_TYPE
)
1822 return DECL_NAME (UPT_TEMPLATE (thing
));
1823 if (IS_AGGR_TYPE_CODE (TREE_CODE (thing
)))
1825 if (TYPE_WAS_ANONYMOUS (thing
) && TYPE_HAS_CONSTRUCTOR (thing
))
1826 thing
= DECL_NAME (TREE_VEC_ELT (TYPE_METHODS (thing
), 0));
1828 thing
= TYPE_NAME (thing
);
1830 if (TREE_CODE (thing
) == TYPE_DECL
1831 || (TREE_CODE (thing
) == TEMPLATE_DECL
1832 && DECL_TEMPLATE_IS_CLASS (thing
)))
1833 thing
= DECL_NAME (thing
);
1834 my_friendly_assert (TREE_CODE (thing
) == IDENTIFIER_NODE
, 197);
1838 /* CONSTRUCTOR_NAME:
1839 Return the name for the constructor (or destructor) for the
1840 specified class. Argument can be RECORD_TYPE, TYPE_DECL, or
1841 IDENTIFIER_NODE. When given a template, return the plain
1842 unspecialized name. */
1844 constructor_name (thing
)
1848 thing
= constructor_name_full (thing
);
1849 t
= IDENTIFIER_TEMPLATE (thing
);
1852 t
= TREE_PURPOSE (t
);
1853 return DECL_NAME (t
);
1856 /* Cache the value of this class's main virtual function table pointer
1857 in a register variable. This will save one indirection if a
1858 more than one virtual function call is made this function. */
1862 extern rtx base_init_insns
;
1864 if (base_init_insns
== 0
1865 && DECL_CONSTRUCTOR_P (current_function_decl
))
1866 emit_base_init (current_class_type
, 0);
1869 /* This has something a little wrong with it.
1871 On a sun4, code like:
1876 is generated, when the below is used when -O4 is given. The delay
1877 slot it filled with an instruction that is safe, when this isn't
1887 virtual void print() { printf("xxx"); }
1899 And that is why this is disabled for now. (mrs)
1902 if ((flag_this_is_variable
& 1) == 0
1904 && current_class_type
1905 && CLASSTYPE_VSIZE (current_class_type
)
1906 && ! DECL_STATIC_FUNCTION_P (current_function_decl
))
1908 tree vfield
= build_vfield_ref (C_C_D
, current_class_type
);
1909 current_vtable_decl
= CLASSTYPE_VTBL_PTR (current_class_type
);
1910 DECL_RTL (current_vtable_decl
) = 0;
1911 DECL_INITIAL (current_vtable_decl
) = error_mark_node
;
1912 /* Have to cast the initializer, since it may have come from a
1913 more base class then we ascribe CURRENT_VTABLE_DECL to be. */
1914 finish_decl (current_vtable_decl
, convert_force (TREE_TYPE (current_vtable_decl
), vfield
), 0, 0);
1915 current_vtable_decl
= build_indirect_ref (current_vtable_decl
, NULL_PTR
);
1919 current_vtable_decl
= NULL_TREE
;
1922 /* Record the existence of an addressable inline function. */
1924 mark_inline_for_output (decl
)
1927 if (DECL_SAVED_INLINE (decl
))
1929 DECL_SAVED_INLINE (decl
) = 1;
1930 if (DECL_PENDING_INLINE_INFO (decl
) != 0
1931 && ! DECL_PENDING_INLINE_INFO (decl
)->deja_vu
)
1933 struct pending_inline
*t
= pending_inlines
;
1934 my_friendly_assert (DECL_SAVED_INSNS (decl
) == 0, 198);
1937 if (t
== DECL_PENDING_INLINE_INFO (decl
))
1943 t
= DECL_PENDING_INLINE_INFO (decl
);
1944 t
->next
= pending_inlines
;
1945 pending_inlines
= t
;
1947 DECL_PENDING_INLINE_INFO (decl
) = 0;
1949 saved_inlines
= perm_tree_cons (NULL_TREE
, decl
, saved_inlines
);
1955 temp_name_counter
= 0;
1958 /* Hand off a unique name which can be used for variable we don't really
1959 want to know about anyway, for example, the anonymous variables which
1960 are needed to make references work. Declare this thing so we can use it.
1961 The variable created will be of type TYPE.
1963 STATICP is nonzero if this variable should be static. */
1966 get_temp_name (type
, staticp
)
1970 char buf
[sizeof (AUTO_TEMP_FORMAT
) + 20];
1972 int toplev
= global_bindings_p ();
1974 push_obstacks_nochange ();
1975 if (toplev
|| staticp
)
1977 end_temporary_allocation ();
1978 sprintf (buf
, AUTO_TEMP_FORMAT
, global_temp_name_counter
++);
1979 decl
= pushdecl_top_level (build_decl (VAR_DECL
, get_identifier (buf
), type
));
1983 sprintf (buf
, AUTO_TEMP_FORMAT
, temp_name_counter
++);
1984 decl
= pushdecl (build_decl (VAR_DECL
, get_identifier (buf
), type
));
1986 TREE_USED (decl
) = 1;
1987 TREE_STATIC (decl
) = staticp
;
1989 /* If this is a local variable, then lay out its rtl now.
1990 Otherwise, callers of this function are responsible for dealing
1991 with this variable's rtl. */
1995 expand_decl_init (decl
);
2002 /* Get a variable which we can use for multiple assignments.
2003 It is not entered into current_binding_level, because
2004 that breaks things when it comes time to do final cleanups
2005 (which take place "outside" the binding contour of the function). */
2007 get_temp_regvar (type
, init
)
2010 static char buf
[sizeof (AUTO_TEMP_FORMAT
) + 20] = { '_' };
2013 sprintf (buf
+1, AUTO_TEMP_FORMAT
, temp_name_counter
++);
2014 decl
= build_decl (VAR_DECL
, get_identifier (buf
), type
);
2015 TREE_USED (decl
) = 1;
2016 DECL_REGISTER (decl
) = 1;
2019 store_init_value (decl
, init
);
2021 /* We can expand these without fear, since they cannot need
2022 constructors or destructors. */
2024 expand_decl_init (decl
);
2026 if (type_needs_gc_entry (type
))
2027 DECL_GC_OFFSET (decl
) = size_int (++current_function_obstack_index
);
2032 /* Make the macro TEMP_NAME_P available to units which do not
2033 include c-tree.h. */
2038 return TEMP_NAME_P (decl
);
2041 /* Finish off the processing of a UNION_TYPE structure.
2042 If there are static members, then all members are
2043 static, and must be laid out together. If the
2044 union is an anonymous union, we arrange for that
2045 as well. PUBLIC_P is nonzero if this union is
2046 not declared static. */
2048 finish_anon_union (anon_union_decl
)
2049 tree anon_union_decl
;
2051 tree type
= TREE_TYPE (anon_union_decl
);
2052 tree field
, main_decl
= NULL_TREE
;
2053 tree elems
= NULL_TREE
;
2054 int public_p
= TREE_PUBLIC (anon_union_decl
);
2055 int static_p
= TREE_STATIC (anon_union_decl
);
2056 int external_p
= DECL_EXTERNAL (anon_union_decl
);
2058 if ((field
= TYPE_FIELDS (type
)) == NULL_TREE
)
2063 error ("global anonymous unions must be declared static");
2069 tree decl
= build_decl (VAR_DECL
, DECL_NAME (field
), TREE_TYPE (field
));
2070 /* tell `pushdecl' that this is not tentative. */
2071 DECL_INITIAL (decl
) = error_mark_node
;
2072 TREE_PUBLIC (decl
) = public_p
;
2073 TREE_STATIC (decl
) = static_p
;
2074 DECL_EXTERNAL (decl
) = external_p
;
2075 decl
= pushdecl (decl
);
2077 /* Only write out one anon union element--choose the one that
2078 can hold them all. */
2079 if (main_decl
== NULL_TREE
2080 && simple_cst_equal (DECL_SIZE (decl
), DECL_SIZE (anon_union_decl
)))
2086 /* ??? This causes there to be no debug info written out
2088 TREE_ASM_WRITTEN (decl
) = 1;
2091 DECL_INITIAL (decl
) = NULL_TREE
;
2092 /* If there's a cleanup to do, it belongs in the
2093 TREE_PURPOSE of the following TREE_LIST. */
2094 elems
= tree_cons (NULL_TREE
, decl
, elems
);
2095 TREE_TYPE (elems
) = type
;
2096 field
= TREE_CHAIN (field
);
2100 make_decl_rtl (main_decl
, 0, global_bindings_p ());
2101 DECL_RTL (anon_union_decl
) = DECL_RTL (main_decl
);
2104 /* The following call assumes that there are never any cleanups
2105 for anonymous unions--a reasonable assumption. */
2106 expand_anon_union_decl (anon_union_decl
, NULL_TREE
, elems
);
2109 cadillac_finish_anon_union (anon_union_decl
);
2112 /* Finish and output a table which is generated by the compiler.
2113 NAME is the name to give the table.
2114 TYPE is the type of the table entry.
2115 INIT is all the elements in the table.
2116 PUBLICP is non-zero if this table should be given external access. */
2118 finish_table (name
, type
, init
, publicp
)
2119 tree name
, type
, init
;
2122 tree itype
, atype
, decl
;
2123 static tree empty_table
;
2127 itype
= build_index_type (size_int (list_length (init
) - 1));
2128 atype
= build_cplus_array_type (type
, itype
);
2129 layout_type (atype
);
2131 if (TREE_VALUE (init
) == integer_zero_node
2132 && TREE_CHAIN (init
) == NULL_TREE
)
2134 if (empty_table
== NULL_TREE
)
2136 empty_table
= get_temp_name (atype
, 1);
2137 init
= build (CONSTRUCTOR
, atype
, NULL_TREE
, init
);
2138 TREE_CONSTANT (init
) = 1;
2139 TREE_STATIC (init
) = 1;
2140 DECL_INITIAL (empty_table
) = init
;
2141 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table
)),
2142 IDENTIFIER_POINTER (DECL_NAME (empty_table
)));
2143 finish_decl (empty_table
, init
, asmspec
, 0);
2148 if (name
== NULL_TREE
)
2152 decl
= get_temp_name (atype
, 1);
2156 decl
= build_decl (VAR_DECL
, name
, atype
);
2157 decl
= pushdecl (decl
);
2158 TREE_STATIC (decl
) = 1;
2163 TREE_PUBLIC (decl
) = publicp
;
2164 init
= build (CONSTRUCTOR
, atype
, NULL_TREE
, init
);
2165 TREE_CONSTANT (init
) = 1;
2166 TREE_STATIC (init
) = 1;
2167 DECL_INITIAL (decl
) = init
;
2168 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (decl
)),
2169 IDENTIFIER_POINTER (DECL_NAME (decl
)));
2173 /* This will cause DECL to point to EMPTY_TABLE in rtl-land. */
2174 DECL_EXTERNAL (decl
) = 1;
2175 TREE_STATIC (decl
) = 0;
2177 asmspec
= build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table
)),
2178 IDENTIFIER_POINTER (DECL_NAME (empty_table
)));
2181 finish_decl (decl
, init
, asmspec
, 0);
2185 /* Finish processing a builtin type TYPE. It's name is NAME,
2186 its fields are in the array FIELDS. LEN is the number of elements
2187 in FIELDS minus one, or put another way, it is the maximum subscript
2190 It is given the same alignment as ALIGN_TYPE. */
2192 finish_builtin_type (type
, name
, fields
, len
, align_type
)
2201 TYPE_FIELDS (type
) = fields
[0];
2202 for (i
= 0; i
< len
; i
++)
2204 layout_type (TREE_TYPE (fields
[i
]));
2205 DECL_FIELD_CONTEXT (fields
[i
]) = type
;
2206 TREE_CHAIN (fields
[i
]) = fields
[i
+1];
2208 DECL_FIELD_CONTEXT (fields
[i
]) = type
;
2209 DECL_CLASS_CONTEXT (fields
[i
]) = type
;
2210 TYPE_ALIGN (type
) = TYPE_ALIGN (align_type
);
2212 #if 0 /* not yet, should get fixed properly later */
2213 TYPE_NAME (type
) = make_type_decl (get_identifier (name
), type
);
2215 TYPE_NAME (type
) = build_decl (TYPE_DECL
, get_identifier (name
), type
);
2217 layout_decl (TYPE_NAME (type
), 0);
2220 /* Auxiliary functions to make type signatures for
2221 `operator new' and `operator delete' correspond to
2222 what compiler will be expecting. */
2224 extern tree sizetype
;
2227 coerce_new_type (type
)
2232 if (TREE_CODE (type
) == METHOD_TYPE
)
2233 type
= build_function_type (TREE_TYPE (type
), TREE_CHAIN (TYPE_ARG_TYPES (type
)));
2234 if (TREE_TYPE (type
) != ptr_type_node
)
2235 e1
= 1, error ("`operator new' must return type `void *'");
2237 /* Technically the type must be `size_t', but we may not know
2239 if (TYPE_ARG_TYPES (type
) == NULL_TREE
)
2240 e1
= 1, error ("`operator new' takes type `size_t' parameter");
2241 else if (TREE_CODE (TREE_VALUE (TYPE_ARG_TYPES (type
))) != INTEGER_TYPE
2242 || TYPE_PRECISION (TREE_VALUE (TYPE_ARG_TYPES (type
))) != TYPE_PRECISION (sizetype
))
2243 e2
= 1, error ("`operator new' takes type `size_t' as first parameter");
2245 type
= build_function_type (ptr_type_node
, tree_cons (NULL_TREE
, sizetype
, TREE_CHAIN (TYPE_ARG_TYPES (type
))));
2247 type
= build_function_type (ptr_type_node
, TYPE_ARG_TYPES (type
));
2252 coerce_delete_type (type
)
2255 int e1
= 0, e2
= 0, e3
= 0;
2256 tree arg_types
= TYPE_ARG_TYPES (type
);
2258 if (TREE_CODE (type
) == METHOD_TYPE
)
2260 type
= build_function_type (TREE_TYPE (type
), TREE_CHAIN (arg_types
));
2261 arg_types
= TREE_CHAIN (arg_types
);
2263 if (TREE_TYPE (type
) != void_type_node
)
2264 e1
= 1, error ("`operator delete' must return type `void'");
2265 if (arg_types
== NULL_TREE
2266 || TREE_VALUE (arg_types
) != ptr_type_node
)
2267 e2
= 1, error ("`operator delete' takes type `void *' as first parameter");
2270 && TREE_CHAIN (arg_types
)
2271 && TREE_CHAIN (arg_types
) != void_list_node
)
2273 /* Again, technically this argument must be `size_t', but again
2274 we may not know what that is. */
2275 tree t2
= TREE_VALUE (TREE_CHAIN (arg_types
));
2276 if (TREE_CODE (t2
) != INTEGER_TYPE
2277 || TYPE_PRECISION (t2
) != TYPE_PRECISION (sizetype
))
2278 e3
= 1, error ("second argument to `operator delete' must be of type `size_t'");
2279 else if (TREE_CHAIN (TREE_CHAIN (arg_types
)) != void_list_node
)
2282 if (TREE_CHAIN (TREE_CHAIN (arg_types
)))
2283 error ("too many arguments in declaration of `operator delete'");
2285 error ("`...' invalid in specification of `operator delete'");
2289 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
, build_tree_list (NULL_TREE
, sizetype
));
2292 if (arg_types
== NULL_TREE
)
2293 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
, void_list_node
);
2295 arg_types
= tree_cons (NULL_TREE
, ptr_type_node
, TREE_CHAIN (arg_types
));
2300 type
= build_function_type (void_type_node
, arg_types
);
2306 mark_vtable_entries (decl
)
2309 tree entries
= TREE_CHAIN (CONSTRUCTOR_ELTS (DECL_INITIAL (decl
)));
2312 entries
= TREE_CHAIN (entries
);
2314 for (; entries
; entries
= TREE_CHAIN (entries
))
2316 tree fnaddr
= FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries
));
2317 tree fn
= TREE_OPERAND (fnaddr
, 0);
2318 TREE_ADDRESSABLE (fn
) = 1;
2319 if (DECL_ABSTRACT_VIRTUAL_P (fn
))
2321 extern tree abort_fndecl
;
2322 TREE_OPERAND (fnaddr
, 0) = abort_fndecl
;
2327 /* Set TREE_PUBLIC and/or TREE_EXTERN on the vtable DECL,
2328 based on TYPE and other static flags.
2330 Note that anything public is tagged TREE_PUBLIC, whether
2331 it's public in this file or in another one. */
2334 import_export_vtable (decl
, type
)
2337 if (write_virtuals
>= 2
2338 || CLASSTYPE_TEMPLATE_INSTANTIATION (type
))
2340 if (CLASSTYPE_IMPLICIT_INSTANTIATION (type
)
2341 && ! flag_implicit_templates
2342 && CLASSTYPE_INTERFACE_UNKNOWN (type
))
2344 SET_CLASSTYPE_INTERFACE_KNOWN (type
);
2345 CLASSTYPE_INTERFACE_ONLY (type
) = 1;
2346 CLASSTYPE_VTABLE_NEEDS_WRITING (type
) = 0;
2349 if (CLASSTYPE_INTERFACE_KNOWN (type
))
2351 TREE_PUBLIC (decl
) = 1;
2352 DECL_EXTERNAL (decl
) = ! CLASSTYPE_VTABLE_NEEDS_WRITING (type
);
2355 else if (write_virtuals
!= 0)
2357 TREE_PUBLIC (decl
) = 1;
2358 if (write_virtuals
< 0)
2359 DECL_EXTERNAL (decl
) = 1;
2364 finish_vtable_vardecl (prev
, vars
)
2367 tree ctype
= DECL_CONTEXT (vars
);
2368 import_export_vtable (vars
, ctype
);
2370 if (flag_vtable_thunks
&& !CLASSTYPE_INTERFACE_KNOWN (ctype
))
2373 for (method
= CLASSTYPE_METHODS (ctype
); method
!= NULL_TREE
;
2374 method
= DECL_NEXT_METHOD (method
))
2376 if (DECL_VINDEX (method
) != NULL_TREE
&& !DECL_SAVED_INSNS (method
)
2377 && !DECL_ABSTRACT_VIRTUAL_P (method
))
2379 SET_CLASSTYPE_INTERFACE_KNOWN (ctype
);
2380 CLASSTYPE_INTERFACE_ONLY (ctype
) = DECL_EXTERNAL (method
);
2381 TREE_PUBLIC (vars
) = 1;
2382 DECL_EXTERNAL (vars
) = DECL_EXTERNAL (method
);
2388 if (write_virtuals
>= 0
2389 && ! DECL_EXTERNAL (vars
) && (TREE_PUBLIC (vars
) || TREE_USED (vars
)))
2391 extern tree the_null_vtable_entry
;
2393 /* Stuff this virtual function table's size into
2394 `pfn' slot of `the_null_vtable_entry'. */
2395 tree nelts
= array_type_nelts (TREE_TYPE (vars
));
2396 if (flag_vtable_thunks
)
2397 TREE_VALUE (CONSTRUCTOR_ELTS (DECL_INITIAL (vars
))) = nelts
;
2399 SET_FNADDR_FROM_VTABLE_ENTRY (the_null_vtable_entry
, nelts
);
2400 /* Kick out the dossier before writing out the vtable. */
2402 rest_of_decl_compilation (TREE_OPERAND (FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (TREE_CHAIN (CONSTRUCTOR_ELTS (DECL_INITIAL (vars
))))), 0), 0, 1, 1);
2405 mark_vtable_entries (vars
);
2406 if (TREE_TYPE (DECL_INITIAL (vars
)) == 0)
2407 store_init_value (vars
, DECL_INITIAL (vars
));
2409 #ifdef DWARF_DEBUGGING_INFO
2410 if (write_symbols
== DWARF_DEBUG
)
2412 /* Mark the VAR_DECL node representing the vtable itself as a
2413 "gratuitous" one, thereby forcing dwarfout.c to ignore it.
2414 It is rather important that such things be ignored because
2415 any effort to actually generate DWARF for them will run
2416 into trouble when/if we encounter code like:
2419 struct S { virtual void member (); };
2421 because the artificial declaration of the vtable itself (as
2422 manufactured by the g++ front end) will say that the vtable
2423 is a static member of `S' but only *after* the debug output
2424 for the definition of `S' has already been output. This causes
2425 grief because the DWARF entry for the definition of the vtable
2426 will try to refer back to an earlier *declaration* of the
2427 vtable as a static member of `S' and there won't be one.
2428 We might be able to arrange to have the "vtable static member"
2429 attached to the member list for `S' before the debug info for
2430 `S' get written (which would solve the problem) but that would
2431 require more intrusive changes to the g++ front end. */
2433 DECL_IGNORED_P (vars
) = 1;
2435 #endif /* DWARF_DEBUGGING_INFO */
2437 rest_of_decl_compilation (vars
, 0, 1, 1);
2439 else if (TREE_USED (vars
) && flag_vtable_thunks
)
2440 assemble_external (vars
);
2441 /* We know that PREV must be non-zero here. */
2442 TREE_CHAIN (prev
) = TREE_CHAIN (vars
);
2446 walk_vtables (typedecl_fn
, vardecl_fn
)
2447 register void (*typedecl_fn
)();
2448 register void (*vardecl_fn
)();
2452 for (prev
= 0, vars
= getdecls (); vars
; vars
= TREE_CHAIN (vars
))
2454 register tree type
= TREE_TYPE (vars
);
2456 if (TREE_CODE (vars
) == TYPE_DECL
2457 && type
!= error_mark_node
2458 && TYPE_LANG_SPECIFIC (type
)
2459 && CLASSTYPE_VSIZE (type
))
2461 if (typedecl_fn
) (*typedecl_fn
) (prev
, vars
);
2463 else if (TREE_CODE (vars
) == VAR_DECL
&& DECL_VIRTUAL_P (vars
))
2465 if (vardecl_fn
) (*vardecl_fn
) (prev
, vars
);
2472 extern int parse_time
, varconst_time
;
2474 #define TIMEVAR(VAR, BODY) \
2475 do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
2477 /* This routine is called from the last rule in yyparse ().
2478 Its job is to create all the code needed to initialize and
2479 destroy the global aggregates. We do the destruction
2480 first, since that way we only need to reverse the decls once. */
2486 int start_time
, this_time
;
2489 tree vars
= static_aggregates
;
2490 int needs_cleaning
= 0, needs_messing_up
= 0;
2492 build_exception_table ();
2494 if (flag_detailed_statistics
)
2495 dump_tree_statistics ();
2497 /* Bad parse errors. Just forget about it. */
2498 if (! global_bindings_p () || current_class_type
)
2501 start_time
= get_run_time ();
2503 /* Push into C language context, because that's all
2505 push_lang_context (lang_name_c
);
2507 /* Set up the name of the file-level functions we may need. */
2508 /* Use a global object (which is already required to be unique over
2509 the program) rather than the file name (which imposes extra
2510 constraints). -- Raeburn@MIT.EDU, 10 Jan 1990. */
2512 /* See if we really need the hassle. */
2513 while (vars
&& needs_cleaning
== 0)
2515 tree decl
= TREE_VALUE (vars
);
2516 tree type
= TREE_TYPE (decl
);
2517 if (TYPE_NEEDS_DESTRUCTOR (type
))
2520 needs_messing_up
= 1;
2524 needs_messing_up
|= TYPE_NEEDS_CONSTRUCTING (type
);
2525 vars
= TREE_CHAIN (vars
);
2527 if (needs_cleaning
== 0)
2530 /* Otherwise, GDB can get confused, because in only knows
2531 about source for LINENO-1 lines. */
2534 fnname
= get_file_function_name ('D');
2535 start_function (void_list_node
, build_parse_node (CALL_EXPR
, fnname
, void_list_node
, NULL_TREE
), 0, 0);
2536 fnname
= DECL_ASSEMBLER_NAME (current_function_decl
);
2537 store_parm_decls ();
2542 expand_start_bindings (0);
2544 /* These must be done in backward order to destroy,
2545 in which they happen to be! */
2548 tree decl
= TREE_VALUE (vars
);
2549 tree type
= TREE_TYPE (decl
);
2550 tree temp
= TREE_PURPOSE (vars
);
2552 if (TYPE_NEEDS_DESTRUCTOR (type
))
2554 if (TREE_STATIC (vars
))
2555 expand_start_cond (build_binary_op (NE_EXPR
, temp
, integer_zero_node
, 1), 0);
2556 if (TREE_CODE (type
) == ARRAY_TYPE
)
2560 mark_addressable (decl
);
2561 temp
= build1 (ADDR_EXPR
, TYPE_POINTER_TO (type
), decl
);
2563 temp
= build_delete (TREE_TYPE (temp
), temp
,
2564 integer_two_node
, LOOKUP_NORMAL
|LOOKUP_NONVIRTUAL
|LOOKUP_DESTRUCTOR
, 0);
2565 expand_expr_stmt (temp
);
2567 if (TREE_STATIC (vars
))
2570 vars
= TREE_CHAIN (vars
);
2573 expand_end_bindings (getdecls(), 1, 0);
2577 finish_function (lineno
, 0);
2579 assemble_destructor (IDENTIFIER_POINTER (fnname
));
2581 /* if it needed cleaning, then it will need messing up: drop through */
2584 /* Must do this while we think we are at the top level. */
2585 vars
= nreverse (static_aggregates
);
2586 if (vars
!= NULL_TREE
)
2588 fnname
= get_file_function_name ('I');
2589 start_function (void_list_node
, build_parse_node (CALL_EXPR
, fnname
, void_list_node
, NULL_TREE
), 0, 0);
2590 fnname
= DECL_ASSEMBLER_NAME (current_function_decl
);
2591 store_parm_decls ();
2596 expand_start_bindings (0);
2600 tree decl
= TREE_VALUE (vars
);
2601 tree init
= TREE_PURPOSE (vars
);
2602 tree old_cleanups
= cleanups_this_call
;
2604 /* If this was a static attribute within some function's scope,
2605 then don't initialize it here. Also, don't bother
2606 with initializers that contain errors. */
2607 if (TREE_STATIC (vars
)
2608 || (init
&& TREE_CODE (init
) == TREE_LIST
2609 && value_member (error_mark_node
, init
)))
2611 vars
= TREE_CHAIN (vars
);
2615 if (TREE_CODE (decl
) == VAR_DECL
)
2617 /* Set these global variables so that GDB at least puts
2618 us near the declaration which required the initialization. */
2619 input_filename
= DECL_SOURCE_FILE (decl
);
2620 lineno
= DECL_SOURCE_LINE (decl
);
2621 emit_note (input_filename
, lineno
);
2623 /* 9.5p5: The initializer of a static member of a class has
2624 the same acess rights as a member function. */
2625 DECL_CLASS_CONTEXT (current_function_decl
) = DECL_CONTEXT (decl
);
2629 if (TREE_CODE (init
) == VAR_DECL
)
2631 /* This behavior results when there are
2632 multiple declarations of an aggregate,
2633 the last of which defines it. */
2634 if (DECL_RTL (init
) == DECL_RTL (decl
))
2636 my_friendly_assert (DECL_INITIAL (decl
) == error_mark_node
2637 || (TREE_CODE (DECL_INITIAL (decl
)) == CONSTRUCTOR
2638 && CONSTRUCTOR_ELTS (DECL_INITIAL (decl
)) == NULL_TREE
),
2640 init
= DECL_INITIAL (init
);
2641 if (TREE_CODE (init
) == CONSTRUCTOR
2642 && CONSTRUCTOR_ELTS (init
) == NULL_TREE
)
2646 else if (TREE_TYPE (decl
) == TREE_TYPE (init
))
2649 my_friendly_abort (200);
2651 /* point to real decl's rtl anyway. */
2652 DECL_RTL (init
) = DECL_RTL (decl
);
2653 my_friendly_assert (DECL_INITIAL (decl
) == error_mark_node
,
2655 init
= DECL_INITIAL (init
);
2661 if (IS_AGGR_TYPE (TREE_TYPE (decl
))
2663 || TREE_CODE (TREE_TYPE (decl
)) == ARRAY_TYPE
)
2664 expand_aggr_init (decl
, init
, 0);
2665 else if (TREE_CODE (init
) == TREE_VEC
)
2667 expand_expr (expand_vec_init (decl
, TREE_VEC_ELT (init
, 0),
2668 TREE_VEC_ELT (init
, 1),
2669 TREE_VEC_ELT (init
, 2), 0),
2670 const0_rtx
, VOIDmode
, 0);
2674 expand_assignment (decl
, init
, 0, 0);
2676 DECL_CLASS_CONTEXT (current_function_decl
) = NULL_TREE
;
2678 else if (TREE_CODE (decl
) == SAVE_EXPR
)
2680 if (! PARM_DECL_EXPR (decl
))
2682 /* a `new' expression at top level. */
2683 expand_expr (decl
, const0_rtx
, VOIDmode
, 0);
2685 expand_aggr_init (build_indirect_ref (decl
, NULL_PTR
), init
, 0);
2688 else if (decl
== error_mark_node
)
2690 else my_friendly_abort (22);
2691 vars
= TREE_CHAIN (vars
);
2692 /* Cleanup any temporaries needed for the initial value. */
2693 expand_cleanups_to (old_cleanups
);
2696 expand_end_bindings (getdecls(), 1, 0);
2700 finish_function (lineno
, 0);
2701 assemble_constructor (IDENTIFIER_POINTER (fnname
));
2704 /* Done with C language context needs. */
2705 pop_lang_context ();
2707 /* Now write out any static class variables (which may have since
2708 learned how to be initialized). */
2709 while (pending_statics
)
2711 tree decl
= TREE_VALUE (pending_statics
);
2712 if (TREE_USED (decl
) == 1
2713 || TREE_READONLY (decl
) == 0
2714 || DECL_INITIAL (decl
) == 0)
2715 rest_of_decl_compilation (decl
, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)), 1, 1);
2716 pending_statics
= TREE_CHAIN (pending_statics
);
2719 this_time
= get_run_time ();
2720 parse_time
-= this_time
- start_time
;
2721 varconst_time
+= this_time
- start_time
;
2723 start_time
= get_run_time ();
2725 /* Now delete from the chain of variables all virtual function tables.
2726 We output them all ourselves, because each will be treated specially. */
2729 /* The reason for pushing garbage onto the global_binding_level is to
2730 ensure that we can slice out _DECLs which pertain to virtual function
2731 tables. If the last thing pushed onto the global_binding_level was a
2732 virtual function table, then slicing it out would slice away all the
2733 decls (i.e., we lose the head of the chain).
2735 There are several ways of getting the same effect, from changing the
2736 way that iterators over the chain treat the elements that pertain to
2737 virtual function tables, moving the implementation of this code to
2738 decl.c (where we can manipulate global_binding_level directly),
2739 popping the garbage after pushing it and slicing away the vtable
2740 stuff, or just leaving it alone. */
2742 /* Make last thing in global scope not be a virtual function table. */
2743 #if 0 /* not yet, should get fixed properly later */
2744 vars
= make_type_decl (get_identifier (" @%$#@!"), integer_type_node
);
2746 vars
= build_decl (TYPE_DECL
, get_identifier (" @%$#@!"), integer_type_node
);
2748 DECL_IGNORED_P (vars
) = 1;
2749 SET_DECL_ARTIFICIAL (vars
);
2753 walk_vtables ((void (*)())0, finish_vtable_vardecl
);
2755 for (vars
= getdecls (); vars
; vars
= TREE_CHAIN (vars
))
2757 if (TREE_CODE (vars
) == THUNK_DECL
)
2761 /* Now write out inline functions which had their addresses taken
2762 and which were not declared virtual and which were not declared
2764 while (saved_inlines
)
2766 tree decl
= TREE_VALUE (saved_inlines
);
2767 saved_inlines
= TREE_CHAIN (saved_inlines
);
2768 if (TREE_ASM_WRITTEN (decl
))
2770 if (DECL_FUNCTION_MEMBER_P (decl
) && !TREE_PUBLIC (decl
))
2772 tree ctype
= DECL_CLASS_CONTEXT (decl
);
2773 if (CLASSTYPE_INTERFACE_KNOWN (ctype
))
2775 TREE_PUBLIC (decl
) = 1;
2776 DECL_EXTERNAL (decl
)
2777 = (CLASSTYPE_INTERFACE_ONLY (ctype
)
2778 || (DECL_INLINE (decl
) && ! flag_implement_inlines
));
2781 if (TREE_PUBLIC (decl
) || TREE_ADDRESSABLE (decl
)
2782 || flag_keep_inline_functions
)
2784 if (DECL_EXTERNAL (decl
)
2785 || (DECL_IMPLICIT_INSTANTIATION (decl
)
2786 && ! flag_implicit_templates
))
2787 assemble_external (decl
);
2790 temporary_allocation ();
2791 output_inline_function (decl
);
2792 permanent_allocation (1);
2797 if (write_virtuals
== 2)
2799 /* Now complain about an virtual function tables promised
2800 but not delivered. */
2801 while (pending_vtables
)
2803 if (TREE_PURPOSE (pending_vtables
) == NULL_TREE
)
2804 error ("virtual function table for `%s' not defined",
2805 IDENTIFIER_POINTER (TREE_VALUE (pending_vtables
)));
2806 pending_vtables
= TREE_CHAIN (pending_vtables
);
2810 permanent_allocation (1);
2811 this_time
= get_run_time ();
2812 parse_time
-= this_time
- start_time
;
2813 varconst_time
+= this_time
- start_time
;
2815 if (flag_detailed_statistics
)
2816 dump_time_statistics ();
2819 /* This is something of the form 'A()()()()()+1' that has turned out to be an
2820 expr. Since it was parsed like a type, we need to wade through and fix
2821 that. Unfortunately, since operator() is left-associative, we can't use
2822 tail recursion. In the above example, TYPE is `A', and DECL is
2825 Maybe this shouldn't be recursive, but how often will it actually be
2828 reparse_absdcl_as_expr (type
, decl
)
2831 /* do build_functional_cast (type, NULL_TREE) at bottom */
2832 if (TREE_OPERAND (decl
, 0) == NULL_TREE
)
2833 return build_functional_cast (type
, NULL_TREE
);
2836 decl
= reparse_decl_as_expr (type
, TREE_OPERAND (decl
, 0));
2838 decl
= build_x_function_call (decl
, NULL_TREE
, current_class_decl
);
2840 if (TREE_CODE (decl
) == CALL_EXPR
&& TREE_TYPE (decl
) != void_type_node
)
2841 decl
= require_complete_type (decl
);
2846 /* This is something of the form `int ((int)(int)(int)1)' that has turned
2847 out to be an expr. Since it was parsed like a type, we need to wade
2848 through and fix that. Since casts are right-associative, we are
2849 reversing the order, so we don't have to recurse.
2851 In the above example, DECL is the `(int)(int)(int)', and EXPR is the
2854 reparse_absdcl_as_casts (decl
, expr
)
2859 if (TREE_CODE (expr
) == CONSTRUCTOR
)
2861 type
= groktypename (TREE_VALUE (TREE_OPERAND (decl
, 1)));
2862 decl
= TREE_OPERAND (decl
, 0);
2864 if (IS_SIGNATURE (type
))
2866 error ("cast specifies signature type");
2867 return error_mark_node
;
2870 expr
= digest_init (type
, expr
, (tree
*) 0);
2871 if (TREE_CODE (type
) == ARRAY_TYPE
&& TYPE_SIZE (type
) == 0)
2873 int failure
= complete_array_type (type
, expr
, 1);
2875 my_friendly_abort (78);
2881 type
= groktypename (TREE_VALUE (TREE_OPERAND (decl
, 1)));
2882 decl
= TREE_OPERAND (decl
, 0);
2883 expr
= build_c_cast (type
, expr
);
2889 /* Recursive helper function for reparse_decl_as_expr. It may be a good
2890 idea to reimplement this using an explicit stack, rather than recursion. */
2892 reparse_decl_as_expr1 (decl
)
2895 switch (TREE_CODE (decl
))
2897 case IDENTIFIER_NODE
:
2898 return do_identifier (decl
);
2900 return build_x_indirect_ref
2901 (reparse_decl_as_expr1 (TREE_OPERAND (decl
, 0)), "unary *");
2903 return build_x_unary_op (ADDR_EXPR
,
2904 reparse_decl_as_expr1 (TREE_OPERAND (decl
, 0)));
2906 return build_x_unary_op (BIT_NOT_EXPR
,
2907 reparse_decl_as_expr1 (TREE_OPERAND (decl
, 0)));
2909 return build_offset_ref (TREE_OPERAND (decl
, 0), TREE_OPERAND (decl
, 1));
2911 return grok_array_decl (reparse_decl_as_expr1 (TREE_OPERAND (decl
, 0)),
2912 TREE_OPERAND (decl
, 1));
2914 my_friendly_abort (5);
2919 /* This is something of the form `int (*a)++' that has turned out to be an
2920 expr. It was only converted into parse nodes, so we need to go through
2921 and build up the semantics. Most of the work is done by
2922 reparse_decl_as_expr1, above.
2924 In the above example, TYPE is `int' and DECL is `*a'. */
2926 reparse_decl_as_expr (type
, decl
)
2929 decl
= build_tree_list (NULL_TREE
, reparse_decl_as_expr1 (decl
));
2930 return build_functional_cast (type
, decl
);
2933 /* This is something of the form `int (*a)' that has turned out to be a
2934 decl. It was only converted into parse nodes, so we need to do the
2935 checking that make_{pointer,reference}_declarator do. */
2938 finish_decl_parsing (decl
)
2941 extern int current_class_depth
;
2943 switch (TREE_CODE (decl
))
2945 case IDENTIFIER_NODE
:
2948 return make_pointer_declarator
2949 (NULL_TREE
, finish_decl_parsing (TREE_OPERAND (decl
, 0)));
2951 return make_reference_declarator
2952 (NULL_TREE
, finish_decl_parsing (TREE_OPERAND (decl
, 0)));
2954 TREE_OPERAND (decl
, 0) = finish_decl_parsing (TREE_OPERAND (decl
, 0));
2957 push_nested_class (TREE_TYPE (TREE_OPERAND (decl
, 0)), 3);
2958 TREE_COMPLEXITY (decl
) = current_class_depth
;
2961 TREE_OPERAND (decl
, 0) = finish_decl_parsing (TREE_OPERAND (decl
, 0));
2964 my_friendly_abort (5);
2970 check_cp_case_value (value
)
2973 if (value
== NULL_TREE
)
2976 /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
2977 Strip such NOP_EXPRs. */
2978 if (TREE_CODE (value
) == NOP_EXPR
2979 && TREE_TYPE (value
) == TREE_TYPE (TREE_OPERAND (value
, 0)))
2980 value
= TREE_OPERAND (value
, 0);
2982 if (TREE_READONLY_DECL_P (value
))
2984 value
= decl_constant_value (value
);
2985 /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
2986 Strip such NOP_EXPRs. */
2987 if (TREE_CODE (value
) == NOP_EXPR
2988 && TREE_TYPE (value
) == TREE_TYPE (TREE_OPERAND (value
, 0)))
2989 value
= TREE_OPERAND (value
, 0);
2991 value
= fold (value
);
2993 if (TREE_CODE (value
) != INTEGER_CST
2994 && value
!= error_mark_node
)
2996 cp_error ("case label `%E' does not reduce to an integer constant",
2998 value
= error_mark_node
;
3001 /* Promote char or short to int. */
3002 value
= default_conversion (value
);
3004 constant_expression_warning (value
);