1 /* Report error messages, build initializers, and perform
2 some front-end optimizations for C++ compiler.
3 Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 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, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 /* This file is part of the C++ front end.
25 It contains routines to build C++ expressions given their operands,
26 including computing the types of the result, C and C++ specific error
27 checks, and some optimization.
29 There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
30 and to process initializations in declarations (since they work
31 like a strange sort of assignment). */
39 static tree process_init_constructor ();
40 extern void pedwarn (), error ();
42 extern int errorcount;
43 extern int sorrycount;
45 /* Print an error message stemming from an attempt to use
46 BASETYPE as a base class for TYPE. */
48 error_not_base_type (basetype, type)
51 if (TREE_CODE (basetype) == FUNCTION_DECL)
52 basetype = DECL_CLASS_CONTEXT (basetype);
53 cp_error ("type `%T' is not a base type for type `%T'", basetype, type);
54 return error_mark_node;
58 binfo_or_else (parent_or_type, type)
59 tree parent_or_type, type;
62 if (TYPE_MAIN_VARIANT (parent_or_type) == TYPE_MAIN_VARIANT (type))
63 return TYPE_BINFO (parent_or_type);
64 if ((binfo = get_binfo (parent_or_type, TYPE_MAIN_VARIANT (type), 0)))
66 if (binfo == error_mark_node)
70 error_not_base_type (parent_or_type, type);
74 /* According to ARM $7.1.6, "A `const' object may be initialized, but its
75 value may not be changed thereafter. Thus, we emit hard errors for these,
76 rather than just pedwarns. If `SOFT' is 1, then we just pedwarn. (For
77 example, conversions to references.) */
79 readonly_error (arg, string, soft)
92 if (TREE_CODE (arg) == COMPONENT_REF)
94 if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
95 fmt = "%s of member `%D' in read-only structure";
97 fmt = "%s of read-only member `%D'";
98 (*fn) (fmt, string, TREE_OPERAND (arg, 1));
100 else if (TREE_CODE (arg) == VAR_DECL)
102 if (DECL_LANG_SPECIFIC (arg)
103 && DECL_IN_AGGR_P (arg)
104 && !TREE_STATIC (arg))
105 fmt = "%s of constant field `%D'";
107 fmt = "%s of read-only variable `%D'";
108 (*fn) (fmt, string, arg);
110 else if (TREE_CODE (arg) == PARM_DECL)
111 (*fn) ("%s of read-only parameter `%D'", string, arg);
112 else if (TREE_CODE (arg) == INDIRECT_REF
113 && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE
114 && (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL
115 || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
116 (*fn) ("%s of read-only reference `%D'", string, TREE_OPERAND (arg, 0));
117 else if (TREE_CODE (arg) == RESULT_DECL)
118 (*fn) ("%s of read-only named return value `%D'", string, arg);
120 (*fn) ("%s of read-only location", string);
123 /* Print an error message for invalid use of a type which declares
124 virtual functions which are not inheritable. */
126 abstract_virtuals_error (decl, type)
130 tree u = CLASSTYPE_ABSTRACT_VIRTUALS (type);
134 if (TREE_CODE (decl) == RESULT_DECL)
137 if (TREE_CODE (decl) == VAR_DECL)
138 cp_error ("cannot declare variable `%D' to be of type `%T'",
140 else if (TREE_CODE (decl) == PARM_DECL)
141 cp_error ("cannot declare parameter `%D' to be of type `%T'",
143 else if (TREE_CODE (decl) == FIELD_DECL)
144 cp_error ("cannot declare field `%D' to be of type `%T'",
146 else if (TREE_CODE (decl) == FUNCTION_DECL
147 && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
148 cp_error ("invalid return type for method `%#D'", decl);
149 else if (TREE_CODE (decl) == FUNCTION_DECL)
150 cp_error ("invalid return type for function `%#D'", decl);
152 else cp_error ("cannot allocate an object of type `%T'", type);
153 /* Only go through this once. */
154 if (TREE_PURPOSE (u) == NULL_TREE)
156 error (" since the following virtual functions are abstract:");
157 TREE_PURPOSE (u) = error_mark_node;
160 cp_error ("\t%#D", TREE_VALUE (u));
164 else cp_error (" since type `%T' has abstract virtual functions", type);
167 /* Print an error message for invalid use of a signature type.
168 Signatures are treated similar to abstract classes here, they
169 cannot be instantiated. */
171 signature_error (decl, type)
177 if (TREE_CODE (decl) == RESULT_DECL)
180 if (TREE_CODE (decl) == VAR_DECL)
181 cp_error ("cannot declare variable `%D' to be of signature type `%T'",
183 else if (TREE_CODE (decl) == PARM_DECL)
184 cp_error ("cannot declare parameter `%D' to be of signature type `%T'",
186 else if (TREE_CODE (decl) == FIELD_DECL)
187 cp_error ("cannot declare field `%D' to be of signature type `%T'",
189 else if (TREE_CODE (decl) == FUNCTION_DECL
190 && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
191 cp_error ("invalid return type for method `%#D'", decl);
192 else if (TREE_CODE (decl) == FUNCTION_DECL)
193 cp_error ("invalid return type for function `%#D'", decl);
196 cp_error ("cannot allocate an object of signature type `%T'", type);
199 /* Print an error message for invalid use of an incomplete type.
200 VALUE is the expression that was used (or 0 if that isn't known)
201 and TYPE is the type that was invalid. */
204 incomplete_type_error (value, type)
210 /* Avoid duplicate error message. */
211 if (TREE_CODE (type) == ERROR_MARK)
214 if (value != 0 && (TREE_CODE (value) == VAR_DECL
215 || TREE_CODE (value) == PARM_DECL))
216 cp_error ("`%D' has incomplete type", value);
220 /* We must print an error message. Be clever about what it says. */
222 switch (TREE_CODE (type))
227 errmsg = "invalid use of undefined type `%#T'";
231 error ("invalid use of void expression");
235 if (TYPE_DOMAIN (type))
237 type = TREE_TYPE (type);
240 error ("invalid use of array with unspecified bounds");
244 error ("invalid use of member type (did you forget the `&' ?)");
248 my_friendly_abort (108);
251 cp_error (errmsg, type);
255 /* Like error(), but don't call report_error_function(). */
262 extern char * progname;
265 fprintf (stderr, "%s:%d: ", input_filename, lineno);
267 fprintf (stderr, "%s: ", progname);
269 fprintf (stderr, s, v, v2);
270 fprintf (stderr, "\n");
273 /* There are times when the compiler can get very confused, confused
274 to the point of giving up by aborting, simply because of previous
275 input errors. It is much better to have the user go back and
276 correct those errors first, and see if it makes us happier, than it
277 is to abort on him. This is because when one has a 10,000 line
278 program, and the compiler comes back with ``core dump'', the user
279 is left not knowing even where to begin to fix things and no place
280 to even try and work around things.
282 The parameter is to uniquely identify the problem to the user, so
283 that they can say, I am having problem 59, and know that fix 7 will
284 probably solve their problem. Or, we can document what problem
285 59 is, so they can understand how to work around it, should they
288 Note, there will be no more calls in the C++ front end to abort,
289 because the C++ front end is so unreliable still. The C front end
290 can get away with calling abort, because for most of the calls to
291 abort on most machines, it, I suspect, can be proven that it is
292 impossible to ever call abort. The same is not yet true for C++,
293 one day, maybe it will be.
295 We used to tell people to "fix the above error[s] and try recompiling
296 the program" via a call to fatal, but that message tended to look
297 silly. So instead, we just do the equivalent of a call to fatal in the
298 same situation (call exit). */
300 /* First used: 0 (reserved), Last used: 366. Free: */
302 static int abortcount = 0;
305 my_friendly_abort (i)
308 /* if the previous error came through here, i.e. report_error_function
309 ended up calling us again, don't just exit; we want a diagnostic of
312 current_function_decl = NULL_TREE;
313 else if (errorcount > 0 || sorrycount > 0)
318 ack ("Internal compiler error.");
320 ack ("Internal compiler error %d.", i);
321 ack ("Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.");
324 error ("confused by earlier errors, bailing out");
331 error ("Internal compiler error.");
333 error ("Internal compiler error %d.", i);
335 fatal ("Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.");
339 my_friendly_assert (cond, where)
343 my_friendly_abort (where);
346 /* Return nonzero if VALUE is a valid constant-valued expression
347 for use in initializing a static variable; one that can be an
348 element of a "constant" initializer.
350 Return null_pointer_node if the value is absolute;
351 if it is relocatable, return the variable that determines the relocation.
352 We assume that VALUE has been folded as much as possible;
353 therefore, we do not need to check for such things as
354 arithmetic-combinations of integers. */
357 initializer_constant_valid_p (value, endtype)
361 switch (TREE_CODE (value))
364 if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE
365 && TREE_CONSTANT (value))
367 initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)),
370 return TREE_STATIC (value) ? null_pointer_node : 0;
376 return null_pointer_node;
379 return TREE_OPERAND (value, 0);
381 case NON_LVALUE_EXPR:
382 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
386 /* Allow conversions between pointer types. */
387 if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
388 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE)
389 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
391 /* Allow conversions between real types. */
392 if (TREE_CODE (TREE_TYPE (value)) == REAL_TYPE
393 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == REAL_TYPE)
394 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
396 /* Allow length-preserving conversions between integer types. */
397 if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
398 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
399 && (TYPE_PRECISION (TREE_TYPE (value))
400 == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
401 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
403 /* Allow conversions between other integer types only if
405 if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
406 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE)
408 tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
410 if (inner == null_pointer_node)
411 return null_pointer_node;
415 /* Allow (int) &foo provided int is as wide as a pointer. */
416 if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
417 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE
418 && (TYPE_PRECISION (TREE_TYPE (value))
419 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
420 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
423 /* Likewise conversions from int to pointers. */
424 if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
425 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
426 && (TYPE_PRECISION (TREE_TYPE (value))
427 <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
428 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
431 /* Allow conversions to union types if the value inside is okay. */
432 if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE)
433 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
438 if ((TREE_CODE (endtype) == INTEGER_TYPE)
439 && (TYPE_PRECISION (endtype) < POINTER_SIZE))
442 tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
444 tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
446 /* If either term is absolute, use the other terms relocation. */
447 if (valid0 == null_pointer_node)
449 if (valid1 == null_pointer_node)
455 if ((TREE_CODE (endtype) == INTEGER_TYPE)
456 && (TYPE_PRECISION (endtype) < POINTER_SIZE))
459 tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
461 tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
463 /* Win if second argument is absolute. */
464 if (valid1 == null_pointer_node)
466 /* Win if both arguments have the same relocation.
467 Then the value is absolute. */
468 if (valid0 == valid1)
469 return null_pointer_node;
477 /* Perform appropriate conversions on the initial value of a variable,
478 store it in the declaration DECL,
479 and print any error messages that are appropriate.
480 If the init is invalid, store an ERROR_MARK.
482 C++: Note that INIT might be a TREE_LIST, which would mean that it is
483 a base class initializer for some aggregate type, hopefully compatible
484 with DECL. If INIT is a single element, and DECL is an aggregate
485 type, we silently convert INIT into a TREE_LIST, allowing a constructor
488 If INIT is a TREE_LIST and there is no constructor, turn INIT
489 into a CONSTRUCTOR and use standard initialization techniques.
490 Perhaps a warning should be generated?
492 Returns value of initializer if initialization could not be
493 performed for static variable. In that case, caller must do
497 store_init_value (decl, init)
500 register tree value, type;
502 /* If variable's type was invalidly declared, just ignore it. */
504 type = TREE_TYPE (decl);
505 if (TREE_CODE (type) == ERROR_MARK)
509 /* This breaks arrays, and should not have any effect for other decls. */
510 /* Take care of C++ business up here. */
511 type = TYPE_MAIN_VARIANT (type);
514 if (IS_AGGR_TYPE (type))
516 if (! TYPE_HAS_TRIVIAL_INIT_REF (type)
517 && TREE_CODE (init) != CONSTRUCTOR)
518 my_friendly_abort (109);
520 /* Although we are not allowed to declare variables of signature
521 type, we complain about a possible constructor call in such a
522 declaration as well. */
523 if (TREE_CODE (init) == TREE_LIST
524 && IS_SIGNATURE (type))
526 cp_error ("constructor syntax cannot be used with signature type `%T'",
528 init = error_mark_node;
530 else if (TREE_CODE (init) == TREE_LIST)
532 cp_error ("constructor syntax used, but no constructor declared for type `%T'", type);
533 init = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (init));
536 if (TREE_CODE (init) == CONSTRUCTOR)
540 /* Check that we're really an aggregate as ARM 8.4.1 defines it. */
541 if (CLASSTYPE_N_BASECLASSES (type))
542 cp_error_at ("initializer list construction invalid for derived class object `%D'", decl);
543 if (CLASSTYPE_VTBL_PTR (type))
544 cp_error_at ("initializer list construction invalid for polymorphic class object `%D'", decl);
545 if (TYPE_NEEDS_CONSTRUCTING (type))
547 cp_error_at ("initializer list construction invalid for `%D'", decl);
548 error ("due to the presence of a constructor");
550 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
551 if (TREE_PRIVATE (field) || TREE_PROTECTED (field))
553 cp_error_at ("initializer list construction invalid for `%D'", decl);
554 cp_error_at ("due to non-public access of member `%D'", field);
556 for (field = TYPE_METHODS (type); field; field = TREE_CHAIN (field))
557 if (TREE_PRIVATE (field) || TREE_PROTECTED (field))
559 cp_error_at ("initializer list construction invalid for `%D'", decl);
560 cp_error_at ("due to non-public access of member `%D'", field);
565 else if (TREE_CODE (init) == TREE_LIST
566 && TREE_TYPE (init) != unknown_type_node)
568 if (TREE_CODE (decl) == RESULT_DECL)
570 if (TREE_CHAIN (init))
572 warning ("comma expression used to initialize return value");
573 init = build_compound_expr (init);
576 init = TREE_VALUE (init);
578 else if (TREE_TYPE (init) != 0
579 && TREE_CODE (TREE_TYPE (init)) == OFFSET_TYPE)
581 /* Use the type of our variable to instantiate
582 the type of our initializer. */
583 init = instantiate_type (type, init, 1);
585 else if (TREE_CODE (init) == TREE_LIST
586 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
588 error ("cannot initialize arrays using this syntax");
593 /* We get here with code like `int a (2);' */
595 if (TREE_CHAIN (init) != NULL_TREE)
597 pedwarn ("initializer list being treated as compound expression");
598 init = build_compound_expr (init);
601 init = TREE_VALUE (init);
605 /* End of special C++ code. */
607 /* Digest the specified initializer into an expression. */
609 value = digest_init (type, init, (tree *) 0);
611 /* Store the expression if valid; else report error. */
613 if (TREE_CODE (value) == ERROR_MARK)
615 else if (TREE_STATIC (decl)
616 && (! TREE_CONSTANT (value)
617 || ! initializer_constant_valid_p (value, TREE_TYPE (value))
619 /* A STATIC PUBLIC int variable doesn't have to be
620 run time inited when doing pic. (mrs) */
621 /* Since ctors and dtors are the only things that can
622 reference vtables, and they are always written down
623 the the vtable definition, we can leave the
624 vtables in initialized data space.
625 However, other initialized data cannot be initialized
626 this way. Instead a global file-level initializer
628 || (flag_pic && !DECL_VIRTUAL_P (decl) && TREE_PUBLIC (decl))
633 #if 0 /* No, that's C. jason 9/19/94 */
636 if (pedantic && TREE_CODE (value) == CONSTRUCTOR
637 /* Don't complain about non-constant initializers of
638 signature tables and signature pointers/references. */
639 && ! (TYPE_LANG_SPECIFIC (type)
640 && (IS_SIGNATURE (type)
641 || IS_SIGNATURE_POINTER (type)
642 || IS_SIGNATURE_REFERENCE (type))))
644 if (! TREE_CONSTANT (value) || ! TREE_STATIC (value))
645 pedwarn ("ANSI C++ forbids non-constant aggregate initializer expressions");
649 DECL_INITIAL (decl) = value;
653 /* Digest the parser output INIT as an initializer for type TYPE.
654 Return a C expression of type TYPE to represent the initial value.
656 If TAIL is nonzero, it points to a variable holding a list of elements
657 of which INIT is the first. We update the list stored there by
658 removing from the head all the elements that we use.
659 Normally this is only one; we use more than one element only if
660 TYPE is an aggregate and INIT is not a constructor. */
663 digest_init (type, init, tail)
664 tree type, init, *tail;
666 enum tree_code code = TREE_CODE (type);
667 tree element = NULL_TREE;
668 tree old_tail_contents;
669 /* Nonzero if INIT is a braced grouping, which comes in as a CONSTRUCTOR
670 tree node which has no TREE_TYPE. */
673 /* By default, assume we use one element from a list.
674 We correct this later in the sole case where it is not true. */
678 old_tail_contents = *tail;
679 *tail = TREE_CHAIN (*tail);
682 if (init == error_mark_node || (TREE_CODE (init) == TREE_LIST
683 && TREE_VALUE (init) == error_mark_node))
684 return error_mark_node;
686 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
687 if (TREE_CODE (init) == NON_LVALUE_EXPR)
688 init = TREE_OPERAND (init, 0);
690 if (init && TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (type))
691 init = default_conversion (init);
693 if (init && TYPE_PTRMEMFUNC_P (type)
694 && ((TREE_CODE (init) == ADDR_EXPR
695 && ((TREE_CODE (TREE_TYPE (init)) == POINTER_TYPE
696 && TREE_CODE (TREE_TYPE (TREE_TYPE (init))) == METHOD_TYPE)
697 || TREE_CODE (TREE_OPERAND (init, 0)) == TREE_LIST))
698 || TREE_CODE (init) == TREE_LIST
699 || integer_zerop (init)
700 || (TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))))
702 return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), init, 0);
705 raw_constructor = TREE_CODE (init) == CONSTRUCTOR && TREE_TYPE (init) == 0;
707 if (init && raw_constructor
708 && CONSTRUCTOR_ELTS (init) != 0
709 && TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0)
711 element = TREE_VALUE (CONSTRUCTOR_ELTS (init));
712 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
713 if (element && TREE_CODE (element) == NON_LVALUE_EXPR)
714 element = TREE_OPERAND (element, 0);
715 if (element == error_mark_node)
719 /* Any type can be initialized from an expression of the same type,
720 optionally with braces. */
722 if (init && TREE_TYPE (init)
723 && (TYPE_MAIN_VARIANT (TREE_TYPE (init)) == type
724 || (code == ARRAY_TYPE && comptypes (TREE_TYPE (init), type, 1))))
726 if (pedantic && code == ARRAY_TYPE
727 && TREE_CODE (init) != STRING_CST)
728 pedwarn ("ANSI C++ forbids initializing array from array expression");
729 if (TREE_CODE (init) == CONST_DECL)
730 init = DECL_INITIAL (init);
731 else if (TREE_READONLY_DECL_P (init))
732 init = decl_constant_value (init);
736 if (element && (TREE_TYPE (element) == type
737 || (code == ARRAY_TYPE && TREE_TYPE (element)
738 && comptypes (TREE_TYPE (element), type, 1))))
740 if (pedantic && code == ARRAY_TYPE)
741 pedwarn ("ANSI C++ forbids initializing array from array expression");
742 if (pedantic && (code == RECORD_TYPE || code == UNION_TYPE))
743 pedwarn ("ANSI C++ forbids single nonscalar initializer with braces");
744 if (TREE_CODE (element) == CONST_DECL)
745 element = DECL_INITIAL (element);
746 else if (TREE_READONLY_DECL_P (element))
747 element = decl_constant_value (element);
751 /* Initialization of an array of chars from a string constant
752 optionally enclosed in braces. */
754 if (code == ARRAY_TYPE)
756 tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
757 if ((typ1 == char_type_node
758 || typ1 == signed_char_type_node
759 || typ1 == unsigned_char_type_node
760 || typ1 == unsigned_wchar_type_node
761 || typ1 == signed_wchar_type_node)
762 && ((init && TREE_CODE (init) == STRING_CST)
763 || (element && TREE_CODE (element) == STRING_CST)))
765 tree string = element ? element : init;
767 if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
769 && TYPE_PRECISION (typ1) == BITS_PER_UNIT)
771 error ("char-array initialized from wide string");
772 return error_mark_node;
774 if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
776 && TYPE_PRECISION (typ1) != BITS_PER_UNIT)
778 error ("int-array initialized from non-wide string");
779 return error_mark_node;
783 && typ1 != char_type_node
784 && typ1 != signed_char_type_node
785 && typ1 != unsigned_char_type_node)
786 pedwarn ("ANSI C++ forbids string initializer except for `char' elements");
787 TREE_TYPE (string) = type;
788 if (TYPE_DOMAIN (type) != 0
789 && TREE_CONSTANT (TYPE_SIZE (type)))
792 = TREE_INT_CST_LOW (TYPE_SIZE (type));
793 size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
794 /* In C it is ok to subtract 1 from the length of the string
795 because it's ok to ignore the terminating null char that is
796 counted in the length of the constant, but in C++ this would
798 if (size < TREE_STRING_LENGTH (string))
799 pedwarn ("initializer-string for array of chars is too long");
805 /* Handle scalar types, including conversions,
806 and signature pointers and references. */
808 if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
809 || code == ENUMERAL_TYPE || code == REFERENCE_TYPE
810 || code == BOOLEAN_TYPE
811 || (code == RECORD_TYPE && ! raw_constructor
812 && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type))))
818 error ("initializer for scalar variable requires one element");
819 return error_mark_node;
823 while (TREE_CODE (init) == CONSTRUCTOR)
825 cp_pedwarn ("braces around scalar initializer for `%T'", type);
826 init = CONSTRUCTOR_ELTS (init);
827 if (TREE_CHAIN (init))
828 cp_pedwarn ("ignoring extra initializers for `%T'", type);
829 init = TREE_VALUE (init);
832 return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
833 "initialization", NULL_TREE, 0);
836 /* Come here only for records and arrays (and unions with constructors). */
838 if (TYPE_SIZE (type) && ! TREE_CONSTANT (TYPE_SIZE (type)))
840 cp_error ("variable-sized object of type `%T' may not be initialized",
842 return error_mark_node;
845 if (code == ARRAY_TYPE || code == RECORD_TYPE || code == UNION_TYPE)
847 if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type))
849 cp_error ("subobject of type `%T' must be initialized by constructor, not by `%E'",
851 return error_mark_node;
853 else if (raw_constructor)
854 return process_init_constructor (type, init, (tree *)0);
855 else if (TYPE_NON_AGGREGATE_CLASS (type))
858 /* This isn't true. */
859 /* This can only be reached when caller is initializing
860 ARRAY_TYPE. In that case, we don't want to convert
861 INIT to TYPE. We will let `expand_vec_init' do it. */
864 return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
865 "initialization", NULL_TREE, 0);
870 *tail = old_tail_contents;
871 return process_init_constructor (type, 0, tail);
873 else if (flag_traditional)
874 /* Traditionally one can say `char x[100] = 0;'. */
875 return process_init_constructor (type,
876 build_nt (CONSTRUCTOR, 0,
877 tree_cons (0, init, 0)),
879 if (code != ARRAY_TYPE)
880 return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
881 "initialization", NULL_TREE, 0);
884 error ("invalid initializer");
885 return error_mark_node;
888 /* Process a constructor for a variable of type TYPE.
889 The constructor elements may be specified either with INIT or with ELTS,
890 only one of which should be non-null.
892 If INIT is specified, it is a CONSTRUCTOR node which is specifically
893 and solely for initializing this datum.
895 If ELTS is specified, it is the address of a variable containing
896 a list of expressions. We take as many elements as we need
897 from the head of the list and update the list.
899 In the resulting constructor, TREE_CONSTANT is set if all elts are
900 constant, and TREE_STATIC is set if, in addition, all elts are simple enough
901 constants that the assembler and linker can compute them. */
904 process_init_constructor (type, init, elts)
905 tree type, init, *elts;
908 /* List of the elements of the result constructor,
910 register tree members = NULL;
916 /* Make TAIL be the list of elements to use for the initialization,
917 no matter how the data was given to us. */
921 if (warn_missing_braces)
922 warning ("aggregate has a partly bracketed initializer");
926 tail = CONSTRUCTOR_ELTS (init);
928 /* Gobble as many elements as needed, and make a constructor or initial value
929 for each element of this aggregate. Chain them together in result.
930 If there are too few, use 0 for each scalar ultimate component. */
932 if (TREE_CODE (type) == ARRAY_TYPE)
934 tree domain = TYPE_DOMAIN (type);
939 len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
940 - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
943 len = -1; /* Take as many as there are */
945 for (i = 0; (len < 0 || i < len) && tail != 0; i++)
949 if (TREE_VALUE (tail) != 0)
952 next1 = digest_init (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
953 TREE_VALUE (tail), &tail1);
954 if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (type))
955 && TYPE_MAIN_VARIANT (TREE_TYPE (type)) != TYPE_MAIN_VARIANT (TREE_TYPE (next1)))
957 /* The fact this needs to be done suggests this code needs
958 to be totally rewritten. */
959 next1 = convert_for_initialization (NULL_TREE, TREE_TYPE (type), next1, LOOKUP_NORMAL, "initialization", NULL_TREE, 0);
961 my_friendly_assert (tail1 == 0
962 || TREE_CODE (tail1) == TREE_LIST, 319);
963 if (tail == tail1 && len < 0)
965 error ("non-empty initializer for array of empty elements");
966 /* Just ignore what we were supposed to use. */
973 next1 = error_mark_node;
974 tail = TREE_CHAIN (tail);
977 if (next1 == error_mark_node)
979 else if (!TREE_CONSTANT (next1))
981 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
983 members = tree_cons (NULL_TREE, next1, members);
986 if (TREE_CODE (type) == RECORD_TYPE)
992 if (TYPE_USES_VIRTUAL_BASECLASSES (type))
994 sorry ("initializer list for object of class with virtual baseclasses");
995 return error_mark_node;
998 if (TYPE_BINFO_BASETYPES (type))
1000 sorry ("initializer list for object of class with baseclasses");
1001 return error_mark_node;
1004 if (TYPE_VIRTUAL_P (type))
1006 sorry ("initializer list for object using virtual functions");
1007 return error_mark_node;
1011 for (field = TYPE_FIELDS (type); field && tail;
1012 field = TREE_CHAIN (field))
1014 register tree next1;
1016 if (! DECL_NAME (field))
1018 members = tree_cons (field, integer_zero_node, members);
1022 if (TREE_CODE (field) != FIELD_DECL)
1025 if (TREE_VALUE (tail) != 0)
1029 next1 = digest_init (TREE_TYPE (field),
1030 TREE_VALUE (tail), &tail1);
1031 my_friendly_assert (tail1 == 0
1032 || TREE_CODE (tail1) == TREE_LIST, 320);
1037 next1 = error_mark_node;
1038 tail = TREE_CHAIN (tail);
1041 if (next1 == error_mark_node)
1043 else if (!TREE_CONSTANT (next1))
1045 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
1047 members = tree_cons (field, next1, members);
1049 for (; field; field = TREE_CHAIN (field))
1051 if (TREE_CODE (field) != FIELD_DECL)
1054 /* Does this field have a default initialization? */
1055 if (DECL_INITIAL (field))
1057 register tree next1 = DECL_INITIAL (field);
1058 if (TREE_CODE (next1) == ERROR_MARK)
1060 else if (!TREE_CONSTANT (next1))
1062 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
1064 members = tree_cons (field, next1, members);
1066 else if (TREE_READONLY (field))
1067 error ("uninitialized const member `%s'",
1068 IDENTIFIER_POINTER (DECL_NAME (field)));
1069 else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field))
1070 && CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
1071 error ("member `%s' with uninitialized const fields",
1072 IDENTIFIER_POINTER (DECL_NAME (field)));
1073 else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
1074 error ("member `%s' is uninitialized reference",
1075 IDENTIFIER_POINTER (DECL_NAME (field)));
1079 if (TREE_CODE (type) == UNION_TYPE)
1081 register tree field = TYPE_FIELDS (type);
1082 register tree next1;
1084 /* Find the first named field. ANSI decided in September 1990
1085 that only named fields count here. */
1086 while (field && DECL_NAME (field) == 0)
1087 field = TREE_CHAIN (field);
1089 /* If this element specifies a field, initialize via that field. */
1090 if (TREE_PURPOSE (tail) != NULL_TREE)
1094 if (TREE_CODE (TREE_PURPOSE (tail)) == FIELD_DECL)
1095 /* Handle the case of a call by build_c_cast. */
1096 field = TREE_PURPOSE (tail), win = 1;
1097 else if (TREE_CODE (TREE_PURPOSE (tail)) != IDENTIFIER_NODE)
1098 error ("index value instead of field name in union initializer");
1102 for (temp = TYPE_FIELDS (type);
1104 temp = TREE_CHAIN (temp))
1105 if (DECL_NAME (temp) == TREE_PURPOSE (tail))
1108 field = temp, win = 1;
1110 error ("no field `%s' in union being initialized",
1111 IDENTIFIER_POINTER (TREE_PURPOSE (tail)));
1114 TREE_VALUE (tail) = error_mark_node;
1116 else if (field == 0)
1118 cp_error ("union `%T' with no named members cannot be initialized",
1120 TREE_VALUE (tail) = error_mark_node;
1123 if (TREE_VALUE (tail) != 0)
1127 next1 = digest_init (TREE_TYPE (field),
1128 TREE_VALUE (tail), &tail1);
1129 if (tail1 != 0 && TREE_CODE (tail1) != TREE_LIST)
1130 my_friendly_abort (357);
1135 next1 = error_mark_node;
1136 tail = TREE_CHAIN (tail);
1139 if (next1 == error_mark_node)
1141 else if (!TREE_CONSTANT (next1))
1143 else if (initializer_constant_valid_p (next1, TREE_TYPE (next1)) == 0)
1145 members = tree_cons (field, next1, members);
1148 /* If arguments were specified as a list, just remove the ones we used. */
1151 /* If arguments were specified as a constructor,
1152 complain unless we used all the elements of the constructor. */
1154 pedwarn ("excess elements in aggregate initializer");
1157 return error_mark_node;
1159 result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (members));
1161 TREE_HAS_CONSTRUCTOR (result) = TREE_HAS_CONSTRUCTOR (init);
1162 if (allconstant) TREE_CONSTANT (result) = 1;
1163 if (allconstant && allsimple) TREE_STATIC (result) = 1;
1167 /* Given a structure or union value DATUM, construct and return
1168 the structure or union component which results from narrowing
1169 that value by the type specified in BASETYPE. For example, given the
1172 class L { int ii; };
1173 class A : L { ... };
1174 class B : L { ... };
1175 class C : A, B { ... };
1183 x.A::ii refers to the ii member of the L part of
1184 of A part of the C object named by X. In this case,
1185 DATUM would be x, and BASETYPE would be A.
1190 build_scoped_ref (datum, basetype)
1195 tree type = TREE_TYPE (datum);
1197 if (datum == error_mark_node)
1198 return error_mark_node;
1200 if (TREE_CODE (type) == REFERENCE_TYPE)
1201 type = TREE_TYPE (type);
1203 type = TYPE_MAIN_VARIANT (type);
1205 /* This is an easy conversion. */
1206 if (is_aggr_type (basetype, 1))
1208 tree binfo = TYPE_BINFO (basetype);
1209 if (binfo != TYPE_BINFO (type))
1211 binfo = get_binfo (binfo, type, 1);
1212 if (binfo == error_mark_node)
1213 return error_mark_node;
1215 return error_not_base_type (basetype, type);
1218 switch (TREE_CODE (datum))
1223 case FIX_TRUNC_EXPR:
1224 case FIX_FLOOR_EXPR:
1225 case FIX_ROUND_EXPR:
1227 ref = convert_pointer_to (binfo,
1228 build_unary_op (ADDR_EXPR, TREE_OPERAND (datum, 0), 0));
1231 ref = convert_pointer_to (binfo,
1232 build_unary_op (ADDR_EXPR, datum, 0));
1234 return build_indirect_ref (ref, "(compiler error in build_scoped_ref)");
1236 return error_mark_node;
1239 /* Build a reference to an object specified by the C++ `->' operator.
1240 Usually this just involves dereferencing the object, but if the
1241 `->' operator is overloaded, then such overloads must be
1242 performed until an object which does not have the `->' operator
1243 overloaded is found. An error is reported when circular pointer
1244 delegation is detected. */
1246 build_x_arrow (datum)
1249 tree types_memoized = NULL_TREE;
1250 register tree rval = datum;
1251 tree type = TREE_TYPE (rval);
1254 if (type == error_mark_node)
1255 return error_mark_node;
1257 if (current_template_parms)
1258 return build_min_nt (ARROW_EXPR, rval);
1260 if (TREE_CODE (rval) == OFFSET_REF)
1262 rval = resolve_offset_ref (datum);
1263 type = TREE_TYPE (rval);
1266 if (TREE_CODE (type) == REFERENCE_TYPE)
1268 rval = convert_from_reference (rval);
1269 type = TREE_TYPE (rval);
1272 if (IS_AGGR_TYPE (type) && TYPE_OVERLOADS_ARROW (complete_type (type)))
1274 while ((rval = build_opfncall (COMPONENT_REF, LOOKUP_NORMAL, rval, NULL_TREE, NULL_TREE)))
1276 if (rval == error_mark_node)
1277 return error_mark_node;
1279 if (value_member (TREE_TYPE (rval), types_memoized))
1281 error ("circular pointer delegation detected");
1282 return error_mark_node;
1286 types_memoized = tree_cons (NULL_TREE, TREE_TYPE (rval),
1291 if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
1292 last_rval = convert_from_reference (last_rval);
1295 last_rval = default_conversion (rval);
1297 /* Signature pointers are not dereferenced. */
1298 if (TYPE_LANG_SPECIFIC (TREE_TYPE (last_rval))
1299 && IS_SIGNATURE_POINTER (TREE_TYPE (last_rval)))
1302 if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
1303 return build_indirect_ref (last_rval, NULL_PTR);
1306 error ("result of `operator->()' yields non-pointer result");
1308 error ("base operand of `->' is not a pointer");
1309 return error_mark_node;
1312 /* Make an expression to refer to the COMPONENT field of
1313 structure or union value DATUM. COMPONENT is an arbitrary
1314 expression. DATUM has not already been checked out to be of
1317 For C++, COMPONENT may be a TREE_LIST. This happens when we must
1318 return an object of member type to a method of the current class,
1319 but there is not yet enough typing information to know which one.
1320 As a special case, if there is only one method by that name,
1321 it is returned. Otherwise we return an expression which other
1322 routines will have to know how to deal with later. */
1324 build_m_component_ref (datum, component)
1325 tree datum, component;
1328 tree objtype = TREE_TYPE (datum);
1332 if (current_template_parms)
1333 return build_min_nt (DOTSTAR_EXPR, datum, component);
1335 if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component)))
1337 type = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (component)));
1342 component = build_indirect_ref (component, NULL_PTR);
1343 type = TREE_TYPE (component);
1344 rettype = TREE_TYPE (TREE_TYPE (component));
1347 if (datum == error_mark_node || component == error_mark_node)
1348 return error_mark_node;
1350 if (TREE_CODE (type) != OFFSET_TYPE && TREE_CODE (type) != METHOD_TYPE)
1352 cp_error ("`%E' cannot be used as a member pointer, since it is of type `%T'", component, type);
1353 return error_mark_node;
1356 if (TREE_CODE (objtype) == REFERENCE_TYPE)
1357 objtype = TREE_TYPE (objtype);
1358 objtype = TYPE_MAIN_VARIANT (objtype);
1360 if (! IS_AGGR_TYPE (objtype))
1362 cp_error ("cannot apply member pointer `%E' to `%E'", component, datum);
1363 cp_error ("which is of non-aggregate type `%T'", objtype);
1364 return error_mark_node;
1367 binfo = get_binfo (TYPE_METHOD_BASETYPE (type), objtype, 1);
1368 if (binfo == NULL_TREE)
1370 cp_error ("member type `%T::' incompatible with object type `%T'",
1371 TYPE_METHOD_BASETYPE (type), objtype);
1372 return error_mark_node;
1374 else if (binfo == error_mark_node)
1375 return error_mark_node;
1377 return build (OFFSET_REF, rettype, datum, component);
1380 /* Return a tree node for the expression TYPENAME '(' PARMS ')'. */
1382 build_functional_cast (exp, parms)
1388 /* This is either a call to a constructor,
1389 or a C cast in C++'s `functional' notation. */
1392 if (exp == error_mark_node || parms == error_mark_node)
1393 return error_mark_node;
1395 if (TREE_CODE (exp) == IDENTIFIER_NODE)
1397 if (IDENTIFIER_HAS_TYPE_VALUE (exp))
1398 /* Either an enum or an aggregate type. */
1399 type = IDENTIFIER_TYPE_VALUE (exp);
1402 type = lookup_name (exp, 1);
1403 if (!type || TREE_CODE (type) != TYPE_DECL)
1405 cp_error ("`%T' fails to be a typedef or built-in type", exp);
1406 return error_mark_node;
1408 type = TREE_TYPE (type);
1411 else if (TREE_CODE (exp) == TYPE_DECL)
1412 type = TREE_TYPE (exp);
1416 if (current_template_parms)
1417 return build_min (CAST_EXPR, type, parms);
1419 if (IS_SIGNATURE (type))
1421 error ("signature type not allowed in cast or constructor expression");
1422 return error_mark_node;
1425 if (! IS_AGGR_TYPE (type))
1427 /* this must build a C cast */
1428 if (parms == NULL_TREE)
1429 parms = integer_zero_node;
1432 if (TREE_CHAIN (parms) != NULL_TREE)
1433 pedwarn ("initializer list being treated as compound expression");
1434 parms = build_compound_expr (parms);
1437 return build_c_cast (type, parms, 1);
1440 /* Prepare to evaluate as a call to a constructor. If this expression
1441 is actually used, for example,
1443 return X (arg1, arg2, ...);
1445 then the slot being initialized will be filled in. */
1447 if (TYPE_SIZE (complete_type (type)) == NULL_TREE)
1449 cp_error ("type `%T' is not yet defined", type);
1450 return error_mark_node;
1453 if (parms && TREE_CHAIN (parms) == NULL_TREE)
1454 return build_c_cast (type, TREE_VALUE (parms), 1);
1456 exp = build_method_call (NULL_TREE, ctor_identifier, parms,
1457 TYPE_BINFO (type), LOOKUP_NORMAL);
1459 if (exp == error_mark_node)
1460 return error_mark_node;
1462 return build_cplus_new (type, exp);
1465 /* Return the character string for the name that encodes the
1466 enumeral value VALUE in the domain TYPE. */
1468 enum_name_string (value, type)
1472 register tree values = TYPE_VALUES (type);
1473 register HOST_WIDE_INT intval = TREE_INT_CST_LOW (value);
1475 my_friendly_assert (TREE_CODE (type) == ENUMERAL_TYPE, 324);
1477 && TREE_INT_CST_LOW (TREE_VALUE (values)) != intval)
1478 values = TREE_CHAIN (values);
1479 if (values == NULL_TREE)
1481 char *buf = (char *)oballoc (16 + TYPE_NAME_LENGTH (type));
1483 /* Value must have been cast. */
1484 sprintf (buf, "(enum %s)%d",
1485 TYPE_NAME_STRING (type), intval);
1488 return IDENTIFIER_POINTER (TREE_PURPOSE (values));
1492 /* Print out a language-specific error message for
1493 (Pascal) case or (C) switch statements.
1494 CODE tells what sort of message to print.
1495 TYPE is the type of the switch index expression.
1496 NEW is the new value that we were trying to add.
1497 OLD is the old value that stopped us from adding it. */
1499 report_case_error (code, type, new_value, old_value)
1502 tree new_value, old_value;
1507 error ("case label not within a switch statement");
1509 error ("default label not within a switch statement");
1515 error ("multiple default labels in one switch");
1518 if (TREE_CODE (new_value) == RANGE_EXPR)
1519 if (TREE_CODE (old_value) == RANGE_EXPR)
1521 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1522 if (TREE_CODE (type) == ENUMERAL_TYPE)
1523 sprintf (buf, "overlapping ranges [%s..%s], [%s..%s] in case expression",
1524 enum_name_string (TREE_OPERAND (new_value, 0), type),
1525 enum_name_string (TREE_OPERAND (new_value, 1), type),
1526 enum_name_string (TREE_OPERAND (old_value, 0), type),
1527 enum_name_string (TREE_OPERAND (old_value, 1), type));
1529 sprintf (buf, "overlapping ranges [%d..%d], [%d..%d] in case expression",
1530 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
1531 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
1532 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
1533 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)));
1538 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1539 if (TREE_CODE (type) == ENUMERAL_TYPE)
1540 sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
1541 enum_name_string (TREE_OPERAND (new_value, 0), type),
1542 enum_name_string (TREE_OPERAND (new_value, 1), type),
1543 enum_name_string (old_value, type));
1545 sprintf (buf, "range [%d..%d] includes (%d) in case expression",
1546 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
1547 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
1548 TREE_INT_CST_LOW (old_value));
1551 else if (TREE_CODE (old_value) == RANGE_EXPR)
1553 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1554 if (TREE_CODE (type) == ENUMERAL_TYPE)
1555 sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
1556 enum_name_string (TREE_OPERAND (old_value, 0), type),
1557 enum_name_string (TREE_OPERAND (old_value, 1), type),
1558 enum_name_string (new_value, type));
1560 sprintf (buf, "range [%d..%d] includes (%d) in case expression",
1561 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
1562 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)),
1563 TREE_INT_CST_LOW (new_value));
1568 if (TREE_CODE (type) == ENUMERAL_TYPE)
1569 error ("duplicate label `%s' in switch statement",
1570 enum_name_string (new_value, type));
1572 error ("duplicate label (%d) in switch statement",
1573 TREE_INT_CST_LOW (new_value));
1578 if (TREE_CODE (type) == ENUMERAL_TYPE)
1579 warning ("case value out of range for enum %s",
1580 TYPE_NAME_STRING (type));
1582 warning ("case value out of range");
1586 if (TREE_CODE (type) == ENUMERAL_TYPE)
1587 error ("range values `%s' and `%s' reversed",
1588 enum_name_string (new_value, type),
1589 enum_name_string (old_value, type));
1591 error ("range values reversed");