1 /* Report error messages, build initializers, and perform
2 some front-end optimizations for C++ compiler.
3 Copyright (C) '87, '88, '89, '92, 1993, 1994 Free Software Foundation, Inc.
4 Hacked by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
23 /* This file is part of the C++ front end.
24 It contains routines to build C++ expressions given their operands,
25 including computing the types of the result, C and C++ specific error
26 checks, and some optimization.
28 There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
29 and to process initializations in declarations (since they work
30 like a strange sort of assignment). */
38 static tree process_init_constructor ();
39 extern void pedwarn (), error ();
41 extern int errorcount;
42 extern int sorrycount;
44 /* Print an error message stemming from an attempt to use
45 BASETYPE as a base class for TYPE. */
47 error_not_base_type (basetype, type)
50 if (TREE_CODE (basetype) == FUNCTION_DECL)
51 basetype = DECL_CLASS_CONTEXT (basetype);
52 cp_error ("type `%T' is not a base type for type `%T'", basetype, type);
53 return error_mark_node;
57 binfo_or_else (parent_or_type, type)
58 tree parent_or_type, type;
61 if (TYPE_MAIN_VARIANT (parent_or_type) == TYPE_MAIN_VARIANT (type))
62 return TYPE_BINFO (parent_or_type);
63 if ((binfo = get_binfo (parent_or_type, TYPE_MAIN_VARIANT (type), 0)))
65 if (binfo == error_mark_node)
69 error_not_base_type (parent_or_type, type);
73 /* Print an error message stemming from an invalid use of an
76 TYPE is the type or binfo which draws the error.
77 MSG is the message to print.
78 ARG is an optional argument which may provide more information. */
80 error_with_aggr_type (type, msg, arg)
87 if (TREE_CODE (type) == TREE_VEC)
88 type = BINFO_TYPE (type);
90 name = TYPE_NAME (type);
91 if (TREE_CODE (name) == TYPE_DECL)
92 name = DECL_NAME (name);
93 error (msg, IDENTIFIER_POINTER (name), arg);
96 /* According to ARM $7.1.6, "A `const' object may be initialized, but its
97 value may not be changed thereafter. Thus, we emit hard errors for these,
98 rather than just pedwarns. If `SOFT' is 1, then we just pedwarn. (For
99 example, conversions to references.) */
101 readonly_error (arg, string, soft)
114 if (TREE_CODE (arg) == COMPONENT_REF)
116 if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
117 fmt = "%s of member `%s' in read-only structure";
119 fmt = "%s of read-only member `%s'";
120 (*fn) (fmt, string, lang_printable_name (TREE_OPERAND (arg, 1)));
122 else if (TREE_CODE (arg) == VAR_DECL)
124 if (DECL_LANG_SPECIFIC (arg)
125 && DECL_IN_AGGR_P (arg)
126 && !TREE_STATIC (arg))
127 fmt = "%s of constant field `%s'";
129 fmt = "%s of read-only variable `%s'";
130 (*fn) (fmt, string, lang_printable_name (arg));
132 else if (TREE_CODE (arg) == PARM_DECL)
133 (*fn) ("%s of read-only parameter `%s'", string,
134 lang_printable_name (arg));
135 else if (TREE_CODE (arg) == INDIRECT_REF
136 && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE
137 && (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL
138 || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
139 (*fn) ("%s of read-only reference `%s'",
140 string, lang_printable_name (TREE_OPERAND (arg, 0)));
141 else if (TREE_CODE (arg) == RESULT_DECL)
142 (*fn) ("%s of read-only named return value `%s'",
143 string, lang_printable_name (arg));
145 (*fn) ("%s of read-only location", string);
148 /* Print an error message for invalid use of a type which declares
149 virtual functions which are not inheritable. */
151 abstract_virtuals_error (decl, type)
155 tree u = CLASSTYPE_ABSTRACT_VIRTUALS (type);
159 if (TREE_CODE (decl) == RESULT_DECL)
162 if (TREE_CODE (decl) == VAR_DECL)
163 cp_error ("cannot declare variable `%D' to be of type `%T'",
165 else if (TREE_CODE (decl) == PARM_DECL)
166 cp_error ("cannot declare parameter `%D' to be of type `%T'",
168 else if (TREE_CODE (decl) == FIELD_DECL)
169 cp_error ("cannot declare field `%D' to be of type `%T'",
171 else if (TREE_CODE (decl) == FUNCTION_DECL
172 && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
173 cp_error ("invalid return type for method `%#D'", decl);
174 else if (TREE_CODE (decl) == FUNCTION_DECL)
175 cp_error ("invalid return type for function `%#D'", decl);
177 else cp_error ("cannot allocate an object of type `%T'", type);
178 /* Only go through this once. */
179 if (TREE_PURPOSE (u) == NULL_TREE)
181 error (" since the following virtual functions are abstract:");
182 TREE_PURPOSE (u) = error_mark_node;
185 cp_error ("\t%#D", TREE_VALUE (u));
189 else cp_error (" since type `%T' has abstract virtual functions", type);
192 /* Print an error message for invalid use of a signature type.
193 Signatures are treated similar to abstract classes here, they
194 cannot be instantiated. */
196 signature_error (decl, type)
202 if (TREE_CODE (decl) == RESULT_DECL)
205 if (TREE_CODE (decl) == VAR_DECL)
206 cp_error ("cannot declare variable `%D' to be of signature type `%T'",
208 else if (TREE_CODE (decl) == PARM_DECL)
209 cp_error ("cannot declare parameter `%D' to be of signature type `%T'",
211 else if (TREE_CODE (decl) == FIELD_DECL)
212 cp_error ("cannot declare field `%D' to be of signature type `%T'",
214 else if (TREE_CODE (decl) == FUNCTION_DECL
215 && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
216 cp_error ("invalid return type for method `%#D'", decl);
217 else if (TREE_CODE (decl) == FUNCTION_DECL)
218 cp_error ("invalid return type for function `%#D'", decl);
221 cp_error ("cannot allocate an object of signature type `%T'", type);
224 /* Print an error message for invalid use of an incomplete type.
225 VALUE is the expression that was used (or 0 if that isn't known)
226 and TYPE is the type that was invalid. */
229 incomplete_type_error (value, type)
235 /* Avoid duplicate error message. */
236 if (TREE_CODE (type) == ERROR_MARK)
239 if (value != 0 && (TREE_CODE (value) == VAR_DECL
240 || TREE_CODE (value) == PARM_DECL))
241 error ("`%s' has an incomplete type",
242 IDENTIFIER_POINTER (DECL_NAME (value)));
246 /* We must print an error message. Be clever about what it says. */
248 switch (TREE_CODE (type))
251 errmsg = "invalid use of undefined type `struct %s'";
255 errmsg = "invalid use of undefined type `union %s'";
259 errmsg = "invalid use of undefined type `enum %s'";
263 error ("invalid use of void expression");
267 if (TYPE_DOMAIN (type))
269 type = TREE_TYPE (type);
272 error ("invalid use of array with unspecified bounds");
276 error ("invalid use of member type (did you forget the `&' ?)");
280 my_friendly_abort (108);
283 error_with_aggr_type (type, errmsg);
287 /* Like error(), but don't call report_error_function(). */
294 extern char * progname;
297 fprintf (stderr, "%s:%d: ", input_filename, lineno);
299 fprintf (stderr, "%s: ", progname);
301 fprintf (stderr, s, v, v2);
302 fprintf (stderr, "\n");
305 /* There are times when the compiler can get very confused, confused
306 to the point of giving up by aborting, simply because of previous
307 input errors. It is much better to have the user go back and
308 correct those errors first, and see if it makes us happier, than it
309 is to abort on him. This is because when one has a 10,000 line
310 program, and the compiler comes back with ``core dump'', the user
311 is left not knowing even where to begin to fix things and no place
312 to even try and work around things.
314 The parameter is to uniquely identify the problem to the user, so
315 that they can say, I am having problem 59, and know that fix 7 will
316 probably solve their problem. Or, we can document what problem
317 59 is, so they can understand how to work around it, should they
320 Note, there will be no more calls in the C++ front end to abort,
321 because the C++ front end is so unreliable still. The C front end
322 can get away with calling abort, because for most of the calls to
323 abort on most machines, it, I suspect, can be proven that it is
324 impossible to ever call abort. The same is not yet true for C++,
325 one day, maybe it will be.
327 We used to tell people to "fix the above error[s] and try recompiling
328 the program" via a call to fatal, but that message tended to look
329 silly. So instead, we just do the equivalent of a call to fatal in the
330 same situation (call exit). */
332 /* First used: 0 (reserved), Last used: 357. Free: */
334 static int abortcount = 0;
337 my_friendly_abort (i)
340 /* if the previous error came through here, i.e. report_error_function
341 ended up calling us again, don't just exit; we want a diagnostic of
344 current_function_decl = NULL_TREE;
345 else if (errorcount > 0 || sorrycount > 0)
350 ack ("Internal compiler error.");
352 ack ("Internal compiler error %d.", i);
353 ack ("Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.");
356 error ("confused by earlier errors, bailing out");
363 error ("Internal compiler error.");
365 error ("Internal compiler error %d.", i);
367 fatal ("Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.");
371 my_friendly_assert (cond, where)
375 my_friendly_abort (where);
378 /* Return nonzero if VALUE is a valid constant-valued expression
379 for use in initializing a static variable; one that can be an
380 element of a "constant" initializer.
382 Return 1 if the value is absolute; return 2 if it is relocatable.
383 We assume that VALUE has been folded as much as possible;
384 therefore, we do not need to check for such things as
385 arithmetic-combinations of integers. */
388 initializer_constant_valid_p (value)
391 switch (TREE_CODE (value))
394 return TREE_STATIC (value);
406 /* Allow conversions between types of the same kind. */
407 if (TREE_CODE (TREE_TYPE (value))
408 == TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))))
409 return initializer_constant_valid_p (TREE_OPERAND (value, 0));
410 /* Allow (int) &foo provided int is as wide as a pointer. */
411 if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
412 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE
413 && ! tree_int_cst_lt (TYPE_SIZE (TREE_TYPE (value)),
414 TYPE_SIZE (TREE_TYPE (TREE_OPERAND (value, 0)))))
415 return initializer_constant_valid_p (TREE_OPERAND (value, 0));
420 int valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0));
421 int valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1));
422 if (valid0 == 1 && valid1 == 2)
424 if (valid0 == 2 && valid1 == 1)
431 int valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0));
432 int valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1));
433 if (valid0 == 2 && valid1 == 1)
443 /* Perform appropriate conversions on the initial value of a variable,
444 store it in the declaration DECL,
445 and print any error messages that are appropriate.
446 If the init is invalid, store an ERROR_MARK.
448 C++: Note that INIT might be a TREE_LIST, which would mean that it is
449 a base class initializer for some aggregate type, hopefully compatible
450 with DECL. If INIT is a single element, and DECL is an aggregate
451 type, we silently convert INIT into a TREE_LIST, allowing a constructor
454 If INIT is a TREE_LIST and there is no constructor, turn INIT
455 into a CONSTRUCTOR and use standard initialization techniques.
456 Perhaps a warning should be generated?
458 Returns value of initializer if initialization could not be
459 performed for static variable. In that case, caller must do
463 store_init_value (decl, init)
466 register tree value, type;
468 /* If variable's type was invalidly declared, just ignore it. */
470 type = TREE_TYPE (decl);
471 if (TREE_CODE (type) == ERROR_MARK)
474 /* Take care of C++ business up here. */
475 type = TYPE_MAIN_VARIANT (type);
477 /* implicitly tests if IS_AGGR_TYPE. */
478 if (TYPE_NEEDS_CONSTRUCTING (type) && TREE_CODE (init) != CONSTRUCTOR)
479 my_friendly_abort (109);
480 else if (IS_AGGR_TYPE (type))
482 /* Although we are not allowed to declare variables of signature
483 type, we complain about a possible constructor call in such a
484 declaration as well. */
485 if (TREE_CODE (init) == TREE_LIST
486 && IS_SIGNATURE (type))
488 cp_error ("constructor syntax cannot be used with signature type `%T'",
490 init = error_mark_node;
492 else if (TREE_CODE (init) == TREE_LIST)
494 cp_error ("constructor syntax used, but no constructor declared for type `%T'", type);
495 init = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (init));
498 if (TREE_CODE (init) == CONSTRUCTOR)
504 /* Check that we're really an aggregate as ARM 8.4.1 defines it. */
505 if (CLASSTYPE_N_BASECLASSES (type))
506 cp_error_at ("initializer list construction illegal for derived class object `%D'", decl);
507 if (CLASSTYPE_VTBL_PTR (type))
508 cp_error_at ("initializer list construction illegal for polymorphic class object `%D'", decl);
509 if (TYPE_NEEDS_CONSTRUCTING (type))
511 cp_error_at ("initializer list construction illegal for `%D'", decl);
512 error ("due to the presence of a constructor");
514 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
515 if (TREE_PRIVATE (field) || TREE_PROTECTED (field))
517 cp_error_at ("initializer list construction illegal for `%D'", decl);
518 cp_error_at ("due to non-public access of member `%D'", field);
520 funcs = TYPE_METHODS (type);
522 for (func = 0; func < TREE_VEC_LENGTH (funcs); func++)
524 field = TREE_VEC_ELT (funcs, func);
525 if (field && (TREE_PRIVATE (field) || TREE_PROTECTED (field)))
527 cp_error_at ("initializer list construction illegal for `%D'", decl);
528 cp_error_at ("due to non-public access of member `%D'", field);
534 else if (TREE_CODE (init) == TREE_LIST
535 && TREE_TYPE (init) != unknown_type_node)
537 if (TREE_CODE (decl) == RESULT_DECL)
539 if (TREE_CHAIN (init))
541 warning ("comma expression used to initialize return value");
542 init = build_compound_expr (init);
545 init = TREE_VALUE (init);
547 else if (TREE_TYPE (init) != 0
548 && TREE_CODE (TREE_TYPE (init)) == OFFSET_TYPE)
550 /* Use the type of our variable to instantiate
551 the type of our initializer. */
552 init = instantiate_type (type, init, 1);
554 else if (TREE_CODE (init) == TREE_LIST
555 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
557 error ("cannot initialize arrays using this syntax");
562 /* We get here with code like `int a (2);' */
564 if (TREE_CHAIN (init) != NULL_TREE)
566 pedwarn ("initializer list being treated as compound expression");
567 init = build_compound_expr (init);
570 init = TREE_VALUE (init);
574 /* End of special C++ code. */
576 /* Digest the specified initializer into an expression. */
578 value = digest_init (type, init, (tree *) 0);
580 /* Store the expression if valid; else report error. */
582 if (TREE_CODE (value) == ERROR_MARK)
584 else if (TREE_STATIC (decl)
585 && (! TREE_CONSTANT (value)
586 || ! initializer_constant_valid_p (value)
588 /* A STATIC PUBLIC int variable doesn't have to be
589 run time inited when doing pic. (mrs) */
590 /* Since ctors and dtors are the only things that can
591 reference vtables, and they are always written down
592 the the vtable definition, we can leave the
593 vtables in initialized data space.
594 However, other initialized data cannot be initialized
595 this way. Instead a global file-level initializer
597 || (flag_pic && !DECL_VIRTUAL_P (decl) && TREE_PUBLIC (decl))
604 if (pedantic && TREE_CODE (value) == CONSTRUCTOR)
606 if (! TREE_CONSTANT (value) || ! TREE_STATIC (value))
607 pedwarn ("ANSI C++ forbids non-constant aggregate initializer expressions");
610 DECL_INITIAL (decl) = value;
614 /* Digest the parser output INIT as an initializer for type TYPE.
615 Return a C expression of type TYPE to represent the initial value.
617 If TAIL is nonzero, it points to a variable holding a list of elements
618 of which INIT is the first. We update the list stored there by
619 removing from the head all the elements that we use.
620 Normally this is only one; we use more than one element only if
621 TYPE is an aggregate and INIT is not a constructor. */
624 digest_init (type, init, tail)
625 tree type, init, *tail;
627 enum tree_code code = TREE_CODE (type);
629 tree old_tail_contents;
630 /* Nonzero if INIT is a braced grouping, which comes in as a CONSTRUCTOR
631 tree node which has no TREE_TYPE. */
634 /* By default, assume we use one element from a list.
635 We correct this later in the sole case where it is not true. */
639 old_tail_contents = *tail;
640 *tail = TREE_CHAIN (*tail);
643 if (init == error_mark_node || (TREE_CODE (init) == TREE_LIST
644 && TREE_VALUE (init) == error_mark_node))
645 return error_mark_node;
647 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
648 if (TREE_CODE (init) == NON_LVALUE_EXPR)
649 init = TREE_OPERAND (init, 0);
651 if (init && TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (type))
652 init = default_conversion (init);
654 if (init && TYPE_PTRMEMFUNC_P (type)
655 && ((TREE_CODE (init) == ADDR_EXPR
656 && TREE_CODE (TREE_TYPE (init)) == POINTER_TYPE
657 && TREE_CODE (TREE_TYPE (TREE_TYPE (init))) == METHOD_TYPE)
658 || integer_zerop (init)
659 || (TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))))
661 return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), init, 0);
664 raw_constructor = TREE_CODE (init) == CONSTRUCTOR && TREE_TYPE (init) == 0;
666 if (init && raw_constructor
667 && CONSTRUCTOR_ELTS (init) != 0
668 && TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0)
670 element = TREE_VALUE (CONSTRUCTOR_ELTS (init));
671 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
672 if (element && TREE_CODE (element) == NON_LVALUE_EXPR)
673 element = TREE_OPERAND (element, 0);
674 if (element == error_mark_node)
678 /* Any type can be initialized from an expression of the same type,
679 optionally with braces. */
681 if (init && TREE_TYPE (init)
682 && (TYPE_MAIN_VARIANT (TREE_TYPE (init)) == type
683 || (code == ARRAY_TYPE && comptypes (TREE_TYPE (init), type, 1))))
685 if (pedantic && code == ARRAY_TYPE
686 && TREE_CODE (init) != STRING_CST)
687 pedwarn ("ANSI C++ forbids initializing array from array expression");
688 if (TREE_CODE (init) == CONST_DECL)
689 init = DECL_INITIAL (init);
690 else if (TREE_READONLY_DECL_P (init))
691 init = decl_constant_value (init);
695 if (element && (TREE_TYPE (element) == type
696 || (code == ARRAY_TYPE && TREE_TYPE (element)
697 && comptypes (TREE_TYPE (element), type, 1))))
699 if (pedantic && code == ARRAY_TYPE)
700 pedwarn ("ANSI C++ forbids initializing array from array expression");
701 if (pedantic && (code == RECORD_TYPE || code == UNION_TYPE))
702 pedwarn ("ANSI C++ forbids single nonscalar initializer with braces");
703 if (TREE_CODE (element) == CONST_DECL)
704 element = DECL_INITIAL (element);
705 else if (TREE_READONLY_DECL_P (element))
706 element = decl_constant_value (element);
710 /* Initialization of an array of chars from a string constant
711 optionally enclosed in braces. */
713 if (code == ARRAY_TYPE)
715 tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
716 if ((typ1 == char_type_node
717 || typ1 == signed_char_type_node
718 || typ1 == unsigned_char_type_node
719 || typ1 == unsigned_wchar_type_node
720 || typ1 == signed_wchar_type_node)
721 && ((init && TREE_CODE (init) == STRING_CST)
722 || (element && TREE_CODE (element) == STRING_CST)))
724 tree string = element ? element : init;
726 if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
728 && TYPE_PRECISION (typ1) == BITS_PER_UNIT)
730 error ("char-array initialized from wide string");
731 return error_mark_node;
733 if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
735 && TYPE_PRECISION (typ1) != BITS_PER_UNIT)
737 error ("int-array initialized from non-wide string");
738 return error_mark_node;
742 && typ1 != char_type_node
743 && typ1 != signed_char_type_node
744 && typ1 != unsigned_char_type_node)
745 pedwarn ("ANSI C++ forbids string initializer except for `char' elements");
746 TREE_TYPE (string) = type;
747 if (TYPE_DOMAIN (type) != 0
748 && TREE_CONSTANT (TYPE_SIZE (type)))
751 = TREE_INT_CST_LOW (TYPE_SIZE (type));
752 size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
753 /* In C it is ok to subtract 1 from the length of the string
754 because it's ok to ignore the terminating null char that is
755 counted in the length of the constant, but in C++ this would
757 if (size < TREE_STRING_LENGTH (string))
758 pedwarn ("initializer-string for array of chars is too long");
764 /* Handle scalar types, including conversions,
765 and signature pointers and references. */
767 if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
768 || code == ENUMERAL_TYPE || code == REFERENCE_TYPE
769 || code == BOOLEAN_TYPE
770 || (code == RECORD_TYPE && ! raw_constructor
771 && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type))))
777 error ("initializer for scalar variable requires one element");
778 return error_mark_node;
783 return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
784 "initialization", NULL_TREE, 0);
787 /* Come here only for records and arrays (and unions with constructors). */
789 if (TYPE_SIZE (type) && ! TREE_CONSTANT (TYPE_SIZE (type)))
791 cp_error ("variable-sized object of type `%T' may not be initialized",
793 return error_mark_node;
796 if (code == ARRAY_TYPE || code == RECORD_TYPE || code == UNION_TYPE)
799 return process_init_constructor (type, init, (tree *)0);
800 else if (TYPE_NEEDS_CONSTRUCTING (type))
802 /* This can only be reached when caller is initializing
803 ARRAY_TYPE. In that case, we don't want to convert
804 INIT to TYPE. We will let `expand_vec_init' do it. */
809 *tail = old_tail_contents;
810 return process_init_constructor (type, 0, tail);
812 else if (flag_traditional)
813 /* Traditionally one can say `char x[100] = 0;'. */
814 return process_init_constructor (type,
815 build_nt (CONSTRUCTOR, 0,
816 tree_cons (0, init, 0)),
818 if (code != ARRAY_TYPE)
819 return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
820 "initialization", NULL_TREE, 0);
823 error ("invalid initializer");
824 return error_mark_node;
827 /* Process a constructor for a variable of type TYPE.
828 The constructor elements may be specified either with INIT or with ELTS,
829 only one of which should be non-null.
831 If INIT is specified, it is a CONSTRUCTOR node which is specifically
832 and solely for initializing this datum.
834 If ELTS is specified, it is the address of a variable containing
835 a list of expressions. We take as many elements as we need
836 from the head of the list and update the list.
838 In the resulting constructor, TREE_CONSTANT is set if all elts are
839 constant, and TREE_STATIC is set if, in addition, all elts are simple enough
840 constants that the assembler and linker can compute them. */
843 process_init_constructor (type, init, elts)
844 tree type, init, *elts;
846 extern tree empty_init_node;
848 /* List of the elements of the result constructor,
850 register tree members = NULL;
856 /* Make TAIL be the list of elements to use for the initialization,
857 no matter how the data was given to us. */
861 if (warn_missing_braces)
862 warning ("aggregate has a partly bracketed initializer");
866 tail = CONSTRUCTOR_ELTS (init);
868 /* Gobble as many elements as needed, and make a constructor or initial value
869 for each element of this aggregate. Chain them together in result.
870 If there are too few, use 0 for each scalar ultimate component. */
872 if (TREE_CODE (type) == ARRAY_TYPE)
874 tree domain = TYPE_DOMAIN (type);
879 len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
880 - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
883 len = -1; /* Take as many as there are */
885 for (i = 0; (len < 0 || i < len) && tail != 0; i++)
889 if (TREE_VALUE (tail) != 0)
892 next1 = digest_init (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
893 TREE_VALUE (tail), &tail1);
894 my_friendly_assert (tail1 == 0
895 || TREE_CODE (tail1) == TREE_LIST, 319);
896 if (tail == tail1 && len < 0)
898 error ("non-empty initializer for array of empty elements");
899 /* Just ignore what we were supposed to use. */
906 next1 = error_mark_node;
907 tail = TREE_CHAIN (tail);
910 if (next1 == error_mark_node)
912 else if (!TREE_CONSTANT (next1))
914 else if (! initializer_constant_valid_p (next1))
916 members = tree_cons (NULL_TREE, next1, members);
919 if (TREE_CODE (type) == RECORD_TYPE && init != empty_init_node)
925 if (TYPE_USES_VIRTUAL_BASECLASSES (type))
927 sorry ("initializer list for object of class with virtual baseclasses");
928 return error_mark_node;
931 if (TYPE_BINFO_BASETYPES (type))
933 sorry ("initializer list for object of class with baseclasses");
934 return error_mark_node;
937 if (TYPE_VIRTUAL_P (type))
939 sorry ("initializer list for object using virtual functions");
940 return error_mark_node;
944 for (field = TYPE_FIELDS (type); field && tail;
945 field = TREE_CHAIN (field))
949 if (! DECL_NAME (field))
951 members = tree_cons (field, integer_zero_node, members);
955 if (TREE_CODE (field) != FIELD_DECL)
958 if (TREE_VALUE (tail) != 0)
962 next1 = digest_init (TREE_TYPE (field),
963 TREE_VALUE (tail), &tail1);
964 my_friendly_assert (tail1 == 0
965 || TREE_CODE (tail1) == TREE_LIST, 320);
970 next1 = error_mark_node;
971 tail = TREE_CHAIN (tail);
974 if (next1 == error_mark_node)
976 else if (!TREE_CONSTANT (next1))
978 else if (! initializer_constant_valid_p (next1))
980 members = tree_cons (field, next1, members);
982 for (; field; field = TREE_CHAIN (field))
984 if (TREE_CODE (field) != FIELD_DECL)
987 /* Does this field have a default initialization? */
988 if (DECL_INITIAL (field))
990 register tree next1 = DECL_INITIAL (field);
991 if (TREE_CODE (next1) == ERROR_MARK)
993 else if (!TREE_CONSTANT (next1))
995 else if (! initializer_constant_valid_p (next1))
997 members = tree_cons (field, next1, members);
999 else if (TREE_READONLY (field))
1000 error ("uninitialized const member `%s'",
1001 IDENTIFIER_POINTER (DECL_NAME (field)));
1002 else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field))
1003 && CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
1004 error ("member `%s' with uninitialized const fields",
1005 IDENTIFIER_POINTER (DECL_NAME (field)));
1006 else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
1007 error ("member `%s' is uninitialized reference",
1008 IDENTIFIER_POINTER (DECL_NAME (field)));
1012 if (TREE_CODE (type) == UNION_TYPE && init != empty_init_node)
1014 register tree field = TYPE_FIELDS (type);
1015 register tree next1;
1017 /* Find the first named field. ANSI decided in September 1990
1018 that only named fields count here. */
1019 while (field && DECL_NAME (field) == 0)
1020 field = TREE_CHAIN (field);
1022 /* If this element specifies a field, initialize via that field. */
1023 if (TREE_PURPOSE (tail) != NULL_TREE)
1027 if (TREE_CODE (TREE_PURPOSE (tail)) == FIELD_DECL)
1028 /* Handle the case of a call by build_c_cast. */
1029 field = TREE_PURPOSE (tail), win = 1;
1030 else if (TREE_CODE (TREE_PURPOSE (tail)) != IDENTIFIER_NODE)
1031 error ("index value instead of field name in union initializer");
1035 for (temp = TYPE_FIELDS (type);
1037 temp = TREE_CHAIN (temp))
1038 if (DECL_NAME (temp) == TREE_PURPOSE (tail))
1041 field = temp, win = 1;
1043 error ("no field `%s' in union being initialized",
1044 IDENTIFIER_POINTER (TREE_PURPOSE (tail)));
1047 TREE_VALUE (tail) = error_mark_node;
1049 else if (field == 0)
1051 cp_error ("union `%T' with no named members cannot be initialized",
1053 TREE_VALUE (tail) = error_mark_node;
1056 if (TREE_VALUE (tail) != 0)
1060 next1 = digest_init (TREE_TYPE (field),
1061 TREE_VALUE (tail), &tail1);
1062 if (tail1 != 0 && TREE_CODE (tail1) != TREE_LIST)
1063 my_friendly_abort (357);
1068 next1 = error_mark_node;
1069 tail = TREE_CHAIN (tail);
1072 if (next1 == error_mark_node)
1074 else if (!TREE_CONSTANT (next1))
1076 else if (initializer_constant_valid_p (next1) == 0)
1078 members = tree_cons (field, next1, members);
1081 /* If arguments were specified as a list, just remove the ones we used. */
1084 /* If arguments were specified as a constructor,
1085 complain unless we used all the elements of the constructor. */
1087 pedwarn ("excess elements in aggregate initializer");
1090 return error_mark_node;
1092 result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (members));
1094 TREE_HAS_CONSTRUCTOR (result) = TREE_HAS_CONSTRUCTOR (init);
1095 if (allconstant) TREE_CONSTANT (result) = 1;
1096 if (allconstant && allsimple) TREE_STATIC (result) = 1;
1100 /* Given a structure or union value DATUM, construct and return
1101 the structure or union component which results from narrowing
1102 that value by the types specified in TYPES. For example, given the
1105 class L { int ii; };
1106 class A : L { ... };
1107 class B : L { ... };
1108 class C : A, B { ... };
1116 x::C::A::L::ii refers to the ii member of the L part of
1117 of A part of the C object named by X. In this case,
1118 DATUM would be x, and TYPES would be a SCOPE_REF consisting of
1125 The last entry in the SCOPE_REF is always an IDENTIFIER_NODE.
1130 build_scoped_ref (datum, types)
1135 tree type = TREE_TYPE (datum);
1137 if (datum == error_mark_node)
1138 return error_mark_node;
1140 if (TREE_CODE (type) == REFERENCE_TYPE)
1141 type = TREE_TYPE (type);
1143 type = TYPE_MAIN_VARIANT (type);
1145 if (TREE_CODE (types) == SCOPE_REF)
1147 /* We have some work to do. */
1148 struct type_chain { tree type; struct type_chain *next; } *chain = 0, *head = 0, scratch;
1149 ref = build_unary_op (ADDR_EXPR, datum, 0);
1150 while (TREE_CODE (types) == SCOPE_REF)
1152 tree t = TREE_OPERAND (types, 1);
1153 if (is_aggr_typedef (t, 1))
1155 head = (struct type_chain *)alloca (sizeof (struct type_chain));
1156 head->type = IDENTIFIER_TYPE_VALUE (t);
1159 types = TREE_OPERAND (types, 0);
1161 else return error_mark_node;
1163 if (! is_aggr_typedef (types, 1))
1164 return error_mark_node;
1167 head->type = IDENTIFIER_TYPE_VALUE (types);
1172 tree binfo = chain->type;
1173 type = TREE_TYPE (TREE_TYPE (ref));
1174 if (binfo != TYPE_BINFO (type))
1176 binfo = get_binfo (binfo, type, 1);
1177 if (binfo == error_mark_node)
1178 return error_mark_node;
1180 return error_not_base_type (chain->type, type);
1181 ref = convert_pointer_to (binfo, ref);
1183 chain = chain->next;
1185 return build_indirect_ref (ref, "(compiler error in build_scoped_ref)");
1188 /* This is an easy conversion. */
1189 if (is_aggr_typedef (types, 1))
1191 tree binfo = TYPE_BINFO (IDENTIFIER_TYPE_VALUE (types));
1192 if (binfo != TYPE_BINFO (type))
1194 binfo = get_binfo (binfo, type, 1);
1195 if (binfo == error_mark_node)
1196 return error_mark_node;
1198 return error_not_base_type (IDENTIFIER_TYPE_VALUE (types), type);
1201 switch (TREE_CODE (datum))
1206 case FIX_TRUNC_EXPR:
1207 case FIX_FLOOR_EXPR:
1208 case FIX_ROUND_EXPR:
1210 ref = convert_pointer_to (binfo,
1211 build_unary_op (ADDR_EXPR, TREE_OPERAND (datum, 0), 0));
1214 ref = convert_pointer_to (binfo,
1215 build_unary_op (ADDR_EXPR, datum, 0));
1217 return build_indirect_ref (ref, "(compiler error in build_scoped_ref)");
1219 return error_mark_node;
1222 /* Build a reference to an object specified by the C++ `->' operator.
1223 Usually this just involves dereferencing the object, but if the
1224 `->' operator is overloaded, then such overloads must be
1225 performed until an object which does not have the `->' operator
1226 overloaded is found. An error is reported when circular pointer
1227 delegation is detected. */
1229 build_x_arrow (datum)
1232 tree types_memoized = NULL_TREE;
1233 register tree rval = datum;
1234 tree type = TREE_TYPE (rval);
1237 if (type == error_mark_node)
1238 return error_mark_node;
1240 if (TREE_CODE (type) == REFERENCE_TYPE)
1242 rval = convert_from_reference (rval);
1243 type = TREE_TYPE (rval);
1246 if (IS_AGGR_TYPE (type) && TYPE_OVERLOADS_ARROW (type))
1248 while ((rval = build_opfncall (COMPONENT_REF, LOOKUP_NORMAL, rval, NULL_TREE, NULL_TREE)))
1250 if (rval == error_mark_node)
1251 return error_mark_node;
1253 if (value_member (TREE_TYPE (rval), types_memoized))
1255 error ("circular pointer delegation detected");
1256 return error_mark_node;
1260 types_memoized = tree_cons (NULL_TREE, TREE_TYPE (rval),
1265 if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
1266 last_rval = convert_from_reference (last_rval);
1269 last_rval = default_conversion (rval);
1272 /* Signature pointers are not dereferenced. */
1273 if (TYPE_LANG_SPECIFIC (TREE_TYPE (last_rval))
1274 && IS_SIGNATURE_POINTER (TREE_TYPE (last_rval)))
1277 if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
1278 return build_indirect_ref (last_rval, NULL_PTR);
1280 if (TREE_CODE (TREE_TYPE (last_rval)) == OFFSET_TYPE)
1282 if (TREE_CODE (last_rval) == OFFSET_REF
1283 && TREE_STATIC (TREE_OPERAND (last_rval, 1)))
1285 last_rval = TREE_OPERAND (last_rval, 1);
1286 if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
1287 last_rval = convert_from_reference (last_rval);
1290 compiler_error ("invalid member type in build_x_arrow");
1291 return error_mark_node;
1295 error ("result of `operator->()' yields non-pointer result");
1297 error ("base operand of `->' is not a pointer");
1298 return error_mark_node;
1301 /* Make an expression to refer to the COMPONENT field of
1302 structure or union value DATUM. COMPONENT is an arbitrary
1303 expression. DATUM has not already been checked out to be of
1306 For C++, COMPONENT may be a TREE_LIST. This happens when we must
1307 return an object of member type to a method of the current class,
1308 but there is not yet enough typing information to know which one.
1309 As a special case, if there is only one method by that name,
1310 it is returned. Otherwise we return an expression which other
1311 routines will have to know how to deal with later. */
1313 build_m_component_ref (datum, component)
1314 tree datum, component;
1317 tree objtype = TREE_TYPE (datum);
1320 if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component)))
1322 type = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (component)));
1327 component = build_indirect_ref (component, NULL_PTR);
1328 type = TREE_TYPE (component);
1329 rettype = TREE_TYPE (TREE_TYPE (component));
1332 if (datum == error_mark_node || component == error_mark_node)
1333 return error_mark_node;
1335 if (TREE_CODE (type) != OFFSET_TYPE && TREE_CODE (type) != METHOD_TYPE)
1337 cp_error ("`%E' cannot be used as a member pointer, since it is of type `%T'", component, type);
1338 return error_mark_node;
1341 if (TREE_CODE (objtype) == REFERENCE_TYPE)
1342 objtype = TREE_TYPE (objtype);
1344 if (! IS_AGGR_TYPE (objtype))
1346 cp_error ("cannot apply member pointer `%E' to `%E'", component, datum);
1347 cp_error ("which is of non-aggregate type `%T'", objtype);
1348 return error_mark_node;
1351 if (! comptypes (TYPE_METHOD_BASETYPE (type), objtype, 0))
1353 cp_error ("member type `%T::' incompatible with object type `%T'",
1354 TYPE_METHOD_BASETYPE (type), objtype);
1355 return error_mark_node;
1358 return build (OFFSET_REF, rettype, datum, component);
1361 /* Return a tree node for the expression TYPENAME '(' PARMS ')'.
1363 Because we cannot tell whether this construct is really a call to a
1364 constructor or a request for a type conversion, we try both, and
1365 report any ambiguities we find. */
1367 build_functional_cast (exp, parms)
1371 /* This is either a call to a constructor,
1372 or a C cast in C++'s `functional' notation. */
1373 tree type, name = NULL_TREE;
1374 tree expr_as_ctor = NULL_TREE;
1375 tree expr_as_conversion = NULL_TREE;
1377 if (exp == error_mark_node || parms == error_mark_node)
1378 return error_mark_node;
1380 if (TREE_CODE (exp) == IDENTIFIER_NODE)
1384 if (IDENTIFIER_HAS_TYPE_VALUE (exp))
1385 /* Either an enum or an aggregate type. */
1386 type = IDENTIFIER_TYPE_VALUE (exp);
1389 type = lookup_name (exp, 1);
1390 if (!type || TREE_CODE (type) != TYPE_DECL)
1392 cp_error ("`%T' fails to be a typedef or built-in type", name);
1393 return error_mark_node;
1395 type = TREE_TYPE (type);
1401 if (IS_SIGNATURE (type))
1403 error ("signature type not allowed in cast or constructor expression");
1404 return error_mark_node;
1407 /* Prepare to evaluate as a call to a constructor. If this expression
1408 is actually used, for example,
1410 return X (arg1, arg2, ...);
1412 then the slot being initialized will be filled in. */
1414 if (name == NULL_TREE)
1416 name = TYPE_NAME (type);
1417 if (TREE_CODE (name) == TYPE_DECL)
1418 name = DECL_NAME (name);
1421 if (! IS_AGGR_TYPE (type))
1423 /* this must build a C cast */
1424 if (parms == NULL_TREE)
1425 return build1 (NOP_EXPR, type, integer_zero_node);
1426 return build_c_cast (type, build_compound_expr (parms));
1429 if (TYPE_SIZE (type) == NULL_TREE)
1431 cp_error ("type `%T' is not yet defined", type);
1432 return error_mark_node;
1435 if (parms && TREE_CHAIN (parms) == NULL_TREE)
1437 = build_type_conversion (CONVERT_EXPR, type, TREE_VALUE (parms), 0);
1439 if (! TYPE_HAS_CONSTRUCTOR (type) && parms != NULL_TREE)
1443 if (parms == NULL_TREE)
1444 msg = "argument missing in cast to `%T' type";
1445 else if (TREE_CHAIN (parms) == NULL_TREE)
1447 if (expr_as_conversion == NULL_TREE)
1448 msg = "conversion to type `%T' failed";
1450 else msg = "type `%T' does not have a constructor";
1452 if (expr_as_conversion)
1453 return expr_as_conversion;
1455 cp_error (msg, type);
1456 return error_mark_node;
1460 int flags = LOOKUP_SPECULATIVELY|LOOKUP_NORMAL;
1462 if (parms && TREE_CHAIN (parms) == NULL_TREE)
1463 flags |= LOOKUP_NO_CONVERSION;
1465 expr_as_ctor = build_method_call (NULL_TREE, name, parms,
1468 if (expr_as_ctor == error_mark_node)
1469 return error_mark_node;
1471 else if (expr_as_ctor)
1473 if (expr_as_conversion && expr_as_conversion != error_mark_node)
1475 /* ANSI C++ June 5 1992 WP 12.3.2.6.1 */
1476 cp_error ("ambiguity between conversion to `%T' and constructor",
1478 return error_mark_node;
1481 if (current_function_decl)
1482 return build_cplus_new (type, expr_as_ctor, 0);
1485 register tree parm = TREE_OPERAND (expr_as_ctor, 1);
1487 /* Initializers for static variables and parameters have
1488 to handle doing the initialization and cleanup themselves. */
1489 my_friendly_assert (TREE_CODE (expr_as_ctor) == CALL_EXPR, 322);
1491 /* The following assertion fails in cases where we are initializing
1492 a static member variable of a particular instance of a template
1493 class with a call to a constructor of the given instance, as in:
1495 TMPL<int> object = TMPL<int>();
1497 Curiously, the assertion does not fail if we do the same thing
1498 for a static member of a non-template class, as in:
1502 I can't see why we should care here whether or not the initializer
1503 expression involves a call to `new', so for the time being, it
1504 seems best to just avoid doing this assertion. */
1505 my_friendly_assert (TREE_CALLS_NEW (TREE_VALUE (parm)), 323);
1507 TREE_VALUE (parm) = NULL_TREE;
1508 expr_as_ctor = build_indirect_ref (expr_as_ctor, NULL_PTR);
1509 TREE_HAS_CONSTRUCTOR (expr_as_ctor) = 1;
1511 return expr_as_ctor;
1514 if (expr_as_conversion)
1515 return expr_as_conversion;
1517 cp_error ("no suitable conversion to `%T' exists", type);
1518 return error_mark_node;
1522 /* Return the character string for the name that encodes the
1523 enumeral value VALUE in the domain TYPE. */
1525 enum_name_string (value, type)
1529 register tree values = TYPE_VALUES (type);
1530 register HOST_WIDE_INT intval = TREE_INT_CST_LOW (value);
1532 my_friendly_assert (TREE_CODE (type) == ENUMERAL_TYPE, 324);
1534 && TREE_INT_CST_LOW (TREE_VALUE (values)) != intval)
1535 values = TREE_CHAIN (values);
1536 if (values == NULL_TREE)
1538 char *buf = (char *)oballoc (16 + TYPE_NAME_LENGTH (type));
1540 /* Value must have been cast. */
1541 sprintf (buf, "(enum %s)%d",
1542 TYPE_NAME_STRING (type), intval);
1545 return IDENTIFIER_POINTER (TREE_PURPOSE (values));
1548 /* Print out a language-specific error message for
1549 (Pascal) case or (C) switch statements.
1550 CODE tells what sort of message to print.
1551 TYPE is the type of the switch index expression.
1552 NEW is the new value that we were trying to add.
1553 OLD is the old value that stopped us from adding it. */
1555 report_case_error (code, type, new_value, old_value)
1558 tree new_value, old_value;
1563 error ("case label not within a switch statement");
1565 error ("default label not within a switch statement");
1571 error ("multiple default labels in one switch");
1574 if (TREE_CODE (new_value) == RANGE_EXPR)
1575 if (TREE_CODE (old_value) == RANGE_EXPR)
1577 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1578 if (TREE_CODE (type) == ENUMERAL_TYPE)
1579 sprintf (buf, "overlapping ranges [%s..%s], [%s..%s] in case expression",
1580 enum_name_string (TREE_OPERAND (new_value, 0), type),
1581 enum_name_string (TREE_OPERAND (new_value, 1), type),
1582 enum_name_string (TREE_OPERAND (old_value, 0), type),
1583 enum_name_string (TREE_OPERAND (old_value, 1), type));
1585 sprintf (buf, "overlapping ranges [%d..%d], [%d..%d] in case expression",
1586 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
1587 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
1588 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
1589 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)));
1594 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1595 if (TREE_CODE (type) == ENUMERAL_TYPE)
1596 sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
1597 enum_name_string (TREE_OPERAND (new_value, 0), type),
1598 enum_name_string (TREE_OPERAND (new_value, 1), type),
1599 enum_name_string (old_value, type));
1601 sprintf (buf, "range [%d..%d] includes (%d) in case expression",
1602 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
1603 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
1604 TREE_INT_CST_LOW (old_value));
1607 else if (TREE_CODE (old_value) == RANGE_EXPR)
1609 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1610 if (TREE_CODE (type) == ENUMERAL_TYPE)
1611 sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
1612 enum_name_string (TREE_OPERAND (old_value, 0), type),
1613 enum_name_string (TREE_OPERAND (old_value, 1), type),
1614 enum_name_string (new_value, type));
1616 sprintf (buf, "range [%d..%d] includes (%d) in case expression",
1617 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
1618 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)),
1619 TREE_INT_CST_LOW (new_value));
1624 if (TREE_CODE (type) == ENUMERAL_TYPE)
1625 error ("duplicate label `%s' in switch statement",
1626 enum_name_string (new_value, type));
1628 error ("duplicate label (%d) in switch statement",
1629 TREE_INT_CST_LOW (new_value));
1634 if (TREE_CODE (type) == ENUMERAL_TYPE)
1635 warning ("case value out of range for enum %s",
1636 TYPE_NAME_STRING (type));
1638 warning ("case value out of range");
1642 if (TREE_CODE (type) == ENUMERAL_TYPE)
1643 error ("range values `%s' and `%s' reversed",
1644 enum_name_string (new_value, type),
1645 enum_name_string (old_value, type));
1647 error ("range values reversed");