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. */
49 error_not_base_type (basetype, type)
52 if (TREE_CODE (basetype) == FUNCTION_DECL)
53 basetype = DECL_CLASS_CONTEXT (basetype);
54 cp_error ("type `%T' is not a base type for type `%T'", basetype, type);
55 return error_mark_node;
59 binfo_or_else (parent_or_type, type)
60 tree parent_or_type, type;
63 if (TYPE_MAIN_VARIANT (parent_or_type) == TYPE_MAIN_VARIANT (type))
64 return TYPE_BINFO (parent_or_type);
65 if ((binfo = get_binfo (parent_or_type, TYPE_MAIN_VARIANT (type), 0)))
67 if (binfo == error_mark_node)
71 error_not_base_type (parent_or_type, type);
75 /* According to ARM $7.1.6, "A `const' object may be initialized, but its
76 value may not be changed thereafter. Thus, we emit hard errors for these,
77 rather than just pedwarns. If `SOFT' is 1, then we just pedwarn. (For
78 example, conversions to references.) */
81 readonly_error (arg, string, soft)
94 if (TREE_CODE (arg) == COMPONENT_REF)
96 if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
97 fmt = "%s of member `%D' in read-only structure";
99 fmt = "%s of read-only member `%D'";
100 (*fn) (fmt, string, TREE_OPERAND (arg, 1));
102 else if (TREE_CODE (arg) == VAR_DECL)
104 if (DECL_LANG_SPECIFIC (arg)
105 && DECL_IN_AGGR_P (arg)
106 && !TREE_STATIC (arg))
107 fmt = "%s of constant field `%D'";
109 fmt = "%s of read-only variable `%D'";
110 (*fn) (fmt, string, arg);
112 else if (TREE_CODE (arg) == PARM_DECL)
113 (*fn) ("%s of read-only parameter `%D'", string, arg);
114 else if (TREE_CODE (arg) == INDIRECT_REF
115 && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE
116 && (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL
117 || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
118 (*fn) ("%s of read-only reference `%D'", string, TREE_OPERAND (arg, 0));
119 else if (TREE_CODE (arg) == RESULT_DECL)
120 (*fn) ("%s of read-only named return value `%D'", string, arg);
122 (*fn) ("%s of read-only location", string);
125 /* Print an error message for invalid use of a type which declares
126 virtual functions which are not inheritable. */
129 abstract_virtuals_error (decl, type)
133 tree u = CLASSTYPE_ABSTRACT_VIRTUALS (type);
137 if (TREE_CODE (decl) == RESULT_DECL)
140 if (TREE_CODE (decl) == VAR_DECL)
141 cp_error ("cannot declare variable `%D' to be of type `%T'",
143 else if (TREE_CODE (decl) == PARM_DECL)
144 cp_error ("cannot declare parameter `%D' to be of type `%T'",
146 else if (TREE_CODE (decl) == FIELD_DECL)
147 cp_error ("cannot declare field `%D' to be of type `%T'",
149 else if (TREE_CODE (decl) == FUNCTION_DECL
150 && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
151 cp_error ("invalid return type for method `%#D'", decl);
152 else if (TREE_CODE (decl) == FUNCTION_DECL)
153 cp_error ("invalid return type for function `%#D'", decl);
155 else cp_error ("cannot allocate an object of type `%T'", type);
156 /* Only go through this once. */
157 if (TREE_PURPOSE (u) == NULL_TREE)
159 error (" since the following virtual functions are abstract:");
160 TREE_PURPOSE (u) = error_mark_node;
163 cp_error ("\t%#D", TREE_VALUE (u));
167 else cp_error (" since type `%T' has abstract virtual functions", type);
170 /* Print an error message for invalid use of a signature type.
171 Signatures are treated similar to abstract classes here, they
172 cannot be instantiated. */
175 signature_error (decl, type)
181 if (TREE_CODE (decl) == RESULT_DECL)
184 if (TREE_CODE (decl) == VAR_DECL)
185 cp_error ("cannot declare variable `%D' to be of signature type `%T'",
187 else if (TREE_CODE (decl) == PARM_DECL)
188 cp_error ("cannot declare parameter `%D' to be of signature type `%T'",
190 else if (TREE_CODE (decl) == FIELD_DECL)
191 cp_error ("cannot declare field `%D' to be of signature type `%T'",
193 else if (TREE_CODE (decl) == FUNCTION_DECL
194 && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
195 cp_error ("invalid return type for method `%#D'", decl);
196 else if (TREE_CODE (decl) == FUNCTION_DECL)
197 cp_error ("invalid return type for function `%#D'", decl);
200 cp_error ("cannot allocate an object of signature type `%T'", type);
203 /* Print an error message for invalid use of an incomplete type.
204 VALUE is the expression that was used (or 0 if that isn't known)
205 and TYPE is the type that was invalid. */
208 incomplete_type_error (value, type)
214 /* Avoid duplicate error message. */
215 if (TREE_CODE (type) == ERROR_MARK)
218 if (value != 0 && (TREE_CODE (value) == VAR_DECL
219 || TREE_CODE (value) == PARM_DECL))
220 cp_error ("`%D' has incomplete type", value);
224 /* We must print an error message. Be clever about what it says. */
226 switch (TREE_CODE (type))
231 errmsg = "invalid use of undefined type `%#T'";
235 error ("invalid use of void expression");
239 if (TYPE_DOMAIN (type))
241 type = TREE_TYPE (type);
244 error ("invalid use of array with unspecified bounds");
248 error ("invalid use of member type (did you forget the `&' ?)");
252 my_friendly_abort (108);
255 cp_error (errmsg, type);
259 /* Like error(), but don't call report_error_function(). */
267 extern char * progname;
270 fprintf (stderr, "%s:%d: ", input_filename, lineno);
272 fprintf (stderr, "%s: ", progname);
274 fprintf (stderr, s, v, v2);
275 fprintf (stderr, "\n");
278 /* There are times when the compiler can get very confused, confused
279 to the point of giving up by aborting, simply because of previous
280 input errors. It is much better to have the user go back and
281 correct those errors first, and see if it makes us happier, than it
282 is to abort on him. This is because when one has a 10,000 line
283 program, and the compiler comes back with ``core dump'', the user
284 is left not knowing even where to begin to fix things and no place
285 to even try and work around things.
287 The parameter is to uniquely identify the problem to the user, so
288 that they can say, I am having problem 59, and know that fix 7 will
289 probably solve their problem. Or, we can document what problem
290 59 is, so they can understand how to work around it, should they
293 Note, there will be no more calls in the C++ front end to abort,
294 because the C++ front end is so unreliable still. The C front end
295 can get away with calling abort, because for most of the calls to
296 abort on most machines, it, I suspect, can be proven that it is
297 impossible to ever call abort. The same is not yet true for C++,
298 one day, maybe it will be.
300 We used to tell people to "fix the above error[s] and try recompiling
301 the program" via a call to fatal, but that message tended to look
302 silly. So instead, we just do the equivalent of a call to fatal in the
303 same situation (call exit). */
305 /* First used: 0 (reserved), Last used: 367. Free: */
307 static int abortcount = 0;
310 my_friendly_abort (i)
313 /* if the previous error came through here, i.e. report_error_function
314 ended up calling us again, don't just exit; we want a diagnostic of
317 current_function_decl = NULL_TREE;
318 else if (errorcount > 0 || sorrycount > 0)
323 ack ("Internal compiler error.");
325 ack ("Internal compiler error %d.", i);
326 ack ("Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.");
329 error ("confused by earlier errors, bailing out");
336 error ("Internal compiler error.");
338 error ("Internal compiler error %d.", i);
340 fatal ("Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.");
344 my_friendly_assert (cond, where)
348 my_friendly_abort (where);
351 /* Return nonzero if VALUE is a valid constant-valued expression
352 for use in initializing a static variable; one that can be an
353 element of a "constant" initializer.
355 Return null_pointer_node if the value is absolute;
356 if it is relocatable, return the variable that determines the relocation.
357 We assume that VALUE has been folded as much as possible;
358 therefore, we do not need to check for such things as
359 arithmetic-combinations of integers. */
362 initializer_constant_valid_p (value, endtype)
366 switch (TREE_CODE (value))
369 if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE
370 && TREE_CONSTANT (value))
372 initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)),
375 return TREE_STATIC (value) ? null_pointer_node : 0;
381 return null_pointer_node;
384 return TREE_OPERAND (value, 0);
386 case NON_LVALUE_EXPR:
387 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
391 /* Allow conversions between pointer types. */
392 if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
393 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE)
394 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
396 /* Allow conversions between real types. */
397 if (TREE_CODE (TREE_TYPE (value)) == REAL_TYPE
398 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == REAL_TYPE)
399 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
401 /* Allow length-preserving conversions between integer types. */
402 if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
403 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
404 && (TYPE_PRECISION (TREE_TYPE (value))
405 == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
406 return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
408 /* Allow conversions between other integer types only if
410 if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
411 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE)
413 tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
415 if (inner == null_pointer_node)
416 return null_pointer_node;
420 /* Allow (int) &foo provided int is as wide as a pointer. */
421 if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
422 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE
423 && (TYPE_PRECISION (TREE_TYPE (value))
424 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
425 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
428 /* Likewise conversions from int to pointers. */
429 if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
430 && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
431 && (TYPE_PRECISION (TREE_TYPE (value))
432 <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
433 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
436 /* Allow conversions to union types if the value inside is okay. */
437 if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE)
438 return initializer_constant_valid_p (TREE_OPERAND (value, 0),
443 if ((TREE_CODE (endtype) == INTEGER_TYPE)
444 && (TYPE_PRECISION (endtype) < POINTER_SIZE))
447 tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
449 tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
451 /* If either term is absolute, use the other terms relocation. */
452 if (valid0 == null_pointer_node)
454 if (valid1 == null_pointer_node)
460 if ((TREE_CODE (endtype) == INTEGER_TYPE)
461 && (TYPE_PRECISION (endtype) < POINTER_SIZE))
464 tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
466 tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
468 /* Win if second argument is absolute. */
469 if (valid1 == null_pointer_node)
471 /* Win if both arguments have the same relocation.
472 Then the value is absolute. */
473 if (valid0 == valid1)
474 return null_pointer_node;
482 /* Perform appropriate conversions on the initial value of a variable,
483 store it in the declaration DECL,
484 and print any error messages that are appropriate.
485 If the init is invalid, store an ERROR_MARK.
487 C++: Note that INIT might be a TREE_LIST, which would mean that it is
488 a base class initializer for some aggregate type, hopefully compatible
489 with DECL. If INIT is a single element, and DECL is an aggregate
490 type, we silently convert INIT into a TREE_LIST, allowing a constructor
493 If INIT is a TREE_LIST and there is no constructor, turn INIT
494 into a CONSTRUCTOR and use standard initialization techniques.
495 Perhaps a warning should be generated?
497 Returns value of initializer if initialization could not be
498 performed for static variable. In that case, caller must do
502 store_init_value (decl, init)
505 register tree value, type;
507 /* If variable's type was invalidly declared, just ignore it. */
509 type = TREE_TYPE (decl);
510 if (TREE_CODE (type) == ERROR_MARK)
514 /* This breaks arrays, and should not have any effect for other decls. */
515 /* Take care of C++ business up here. */
516 type = TYPE_MAIN_VARIANT (type);
519 if (IS_AGGR_TYPE (type))
521 if (! TYPE_HAS_TRIVIAL_INIT_REF (type)
522 && TREE_CODE (init) != CONSTRUCTOR)
523 my_friendly_abort (109);
525 /* Although we are not allowed to declare variables of signature
526 type, we complain about a possible constructor call in such a
527 declaration as well. */
528 if (TREE_CODE (init) == TREE_LIST
529 && IS_SIGNATURE (type))
531 cp_error ("constructor syntax cannot be used with signature type `%T'",
533 init = error_mark_node;
535 else if (TREE_CODE (init) == TREE_LIST)
537 cp_error ("constructor syntax used, but no constructor declared for type `%T'", type);
538 init = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (init));
541 if (TREE_CODE (init) == CONSTRUCTOR)
545 /* Check that we're really an aggregate as ARM 8.4.1 defines it. */
546 if (CLASSTYPE_N_BASECLASSES (type))
547 cp_error_at ("initializer list construction invalid for derived class object `%D'", decl);
548 if (CLASSTYPE_VTBL_PTR (type))
549 cp_error_at ("initializer list construction invalid for polymorphic class object `%D'", decl);
550 if (TYPE_NEEDS_CONSTRUCTING (type))
552 cp_error_at ("initializer list construction invalid for `%D'", decl);
553 error ("due to the presence of a constructor");
555 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
556 if (TREE_PRIVATE (field) || TREE_PROTECTED (field))
558 cp_error_at ("initializer list construction invalid for `%D'", decl);
559 cp_error_at ("due to non-public access of member `%D'", field);
561 for (field = TYPE_METHODS (type); field; field = TREE_CHAIN (field))
562 if (TREE_PRIVATE (field) || TREE_PROTECTED (field))
564 cp_error_at ("initializer list construction invalid for `%D'", decl);
565 cp_error_at ("due to non-public access of member `%D'", field);
570 else if (TREE_CODE (init) == TREE_LIST
571 && TREE_TYPE (init) != unknown_type_node)
573 if (TREE_CODE (decl) == RESULT_DECL)
575 if (TREE_CHAIN (init))
577 warning ("comma expression used to initialize return value");
578 init = build_compound_expr (init);
581 init = TREE_VALUE (init);
583 else if (TREE_TYPE (init) != 0
584 && TREE_CODE (TREE_TYPE (init)) == OFFSET_TYPE)
586 /* Use the type of our variable to instantiate
587 the type of our initializer. */
588 init = instantiate_type (type, init, 1);
590 else if (TREE_CODE (init) == TREE_LIST
591 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
593 error ("cannot initialize arrays using this syntax");
598 /* We get here with code like `int a (2);' */
600 if (TREE_CHAIN (init) != NULL_TREE)
602 pedwarn ("initializer list being treated as compound expression");
603 init = build_compound_expr (init);
606 init = TREE_VALUE (init);
610 if (TYPE_PTRMEMFUNC_P (type) && TREE_CODE (init) == CONSTRUCTOR
611 && TREE_TYPE (init) == NULL_TREE)
612 cp_pedwarn ("initializer list for `%T'", type);
614 /* End of special C++ code. */
616 /* Digest the specified initializer into an expression. */
618 value = digest_init (type, init, (tree *) 0);
620 /* Store the expression if valid; else report error. */
622 if (TREE_CODE (value) == ERROR_MARK)
624 else if (TREE_STATIC (decl)
625 && (! TREE_CONSTANT (value)
626 || ! initializer_constant_valid_p (value, TREE_TYPE (value))
628 /* A STATIC PUBLIC int variable doesn't have to be
629 run time inited when doing pic. (mrs) */
630 /* Since ctors and dtors are the only things that can
631 reference vtables, and they are always written down
632 the the vtable definition, we can leave the
633 vtables in initialized data space.
634 However, other initialized data cannot be initialized
635 this way. Instead a global file-level initializer
637 || (flag_pic && !DECL_VIRTUAL_P (decl) && TREE_PUBLIC (decl))
642 #if 0 /* No, that's C. jason 9/19/94 */
645 if (pedantic && TREE_CODE (value) == CONSTRUCTOR
646 /* Don't complain about non-constant initializers of
647 signature tables and signature pointers/references. */
648 && ! (TYPE_LANG_SPECIFIC (type)
649 && (IS_SIGNATURE (type)
650 || IS_SIGNATURE_POINTER (type)
651 || IS_SIGNATURE_REFERENCE (type))))
653 if (! TREE_CONSTANT (value) || ! TREE_STATIC (value))
654 pedwarn ("ANSI C++ forbids non-constant aggregate initializer expressions");
658 DECL_INITIAL (decl) = value;
662 /* Digest the parser output INIT as an initializer for type TYPE.
663 Return a C expression of type TYPE to represent the initial value.
665 If TAIL is nonzero, it points to a variable holding a list of elements
666 of which INIT is the first. We update the list stored there by
667 removing from the head all the elements that we use.
668 Normally this is only one; we use more than one element only if
669 TYPE is an aggregate and INIT is not a constructor. */
672 digest_init (type, init, tail)
673 tree type, init, *tail;
675 enum tree_code code = TREE_CODE (type);
676 tree element = NULL_TREE;
677 tree old_tail_contents;
678 /* Nonzero if INIT is a braced grouping, which comes in as a CONSTRUCTOR
679 tree node which has no TREE_TYPE. */
682 /* By default, assume we use one element from a list.
683 We correct this later in the sole case where it is not true. */
687 old_tail_contents = *tail;
688 *tail = TREE_CHAIN (*tail);
691 if (init == error_mark_node || (TREE_CODE (init) == TREE_LIST
692 && TREE_VALUE (init) == error_mark_node))
693 return error_mark_node;
695 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
696 if (TREE_CODE (init) == NON_LVALUE_EXPR)
697 init = TREE_OPERAND (init, 0);
699 if (init && TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (type))
700 init = default_conversion (init);
702 if (init && TYPE_PTRMEMFUNC_P (type)
703 && ((TREE_CODE (init) == ADDR_EXPR
704 && ((TREE_CODE (TREE_TYPE (init)) == POINTER_TYPE
705 && TREE_CODE (TREE_TYPE (TREE_TYPE (init))) == METHOD_TYPE)
706 || TREE_CODE (TREE_OPERAND (init, 0)) == TREE_LIST))
707 || TREE_CODE (init) == TREE_LIST
708 || integer_zerop (init)
709 || (TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))))
711 return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), init, 0);
714 raw_constructor = TREE_CODE (init) == CONSTRUCTOR && TREE_TYPE (init) == 0;
716 if (init && raw_constructor
717 && CONSTRUCTOR_ELTS (init) != 0
718 && TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0)
720 element = TREE_VALUE (CONSTRUCTOR_ELTS (init));
721 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
722 if (element && TREE_CODE (element) == NON_LVALUE_EXPR)
723 element = TREE_OPERAND (element, 0);
724 if (element == error_mark_node)
728 /* Any type can be initialized from an expression of the same type,
729 optionally with braces. */
731 if (init && TREE_TYPE (init)
732 && (TYPE_MAIN_VARIANT (TREE_TYPE (init)) == type
733 || (code == ARRAY_TYPE && comptypes (TREE_TYPE (init), type, 1))))
735 if (pedantic && code == ARRAY_TYPE
736 && TREE_CODE (init) != STRING_CST)
737 pedwarn ("ANSI C++ forbids initializing array from array expression");
738 if (TREE_CODE (init) == CONST_DECL)
739 init = DECL_INITIAL (init);
740 else if (TREE_READONLY_DECL_P (init))
741 init = decl_constant_value (init);
745 if (element && (TREE_TYPE (element) == type
746 || (code == ARRAY_TYPE && TREE_TYPE (element)
747 && comptypes (TREE_TYPE (element), type, 1))))
749 if (pedantic && code == ARRAY_TYPE)
750 pedwarn ("ANSI C++ forbids initializing array from array expression");
751 if (pedantic && (code == RECORD_TYPE || code == UNION_TYPE))
752 pedwarn ("ANSI C++ forbids single nonscalar initializer with braces");
753 if (TREE_CODE (element) == CONST_DECL)
754 element = DECL_INITIAL (element);
755 else if (TREE_READONLY_DECL_P (element))
756 element = decl_constant_value (element);
760 /* Initialization of an array of chars from a string constant
761 optionally enclosed in braces. */
763 if (code == ARRAY_TYPE)
765 tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
766 if ((typ1 == char_type_node
767 || typ1 == signed_char_type_node
768 || typ1 == unsigned_char_type_node
769 || typ1 == unsigned_wchar_type_node
770 || typ1 == signed_wchar_type_node)
771 && ((init && TREE_CODE (init) == STRING_CST)
772 || (element && TREE_CODE (element) == STRING_CST)))
774 tree string = element ? element : init;
776 if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
778 && TYPE_PRECISION (typ1) == BITS_PER_UNIT)
780 error ("char-array initialized from wide string");
781 return error_mark_node;
783 if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
785 && TYPE_PRECISION (typ1) != BITS_PER_UNIT)
787 error ("int-array initialized from non-wide string");
788 return error_mark_node;
792 && typ1 != char_type_node
793 && typ1 != signed_char_type_node
794 && typ1 != unsigned_char_type_node)
795 pedwarn ("ANSI C++ forbids string initializer except for `char' elements");
796 TREE_TYPE (string) = type;
797 if (TYPE_DOMAIN (type) != 0
798 && TREE_CONSTANT (TYPE_SIZE (type)))
801 = TREE_INT_CST_LOW (TYPE_SIZE (type));
802 size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
803 /* In C it is ok to subtract 1 from the length of the string
804 because it's ok to ignore the terminating null char that is
805 counted in the length of the constant, but in C++ this would
807 if (size < TREE_STRING_LENGTH (string))
808 pedwarn ("initializer-string for array of chars is too long");
814 /* Handle scalar types, including conversions,
815 and signature pointers and references. */
817 if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
818 || code == ENUMERAL_TYPE || code == REFERENCE_TYPE
819 || code == BOOLEAN_TYPE
820 || (code == RECORD_TYPE && ! raw_constructor
821 && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type))))
827 error ("initializer for scalar variable requires one element");
828 return error_mark_node;
832 while (TREE_CODE (init) == CONSTRUCTOR)
834 cp_pedwarn ("braces around scalar initializer for `%T'", type);
835 init = CONSTRUCTOR_ELTS (init);
836 if (TREE_CHAIN (init))
837 cp_pedwarn ("ignoring extra initializers for `%T'", type);
838 init = TREE_VALUE (init);
841 return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
842 "initialization", NULL_TREE, 0);
845 /* Come here only for records and arrays (and unions with constructors). */
847 if (TYPE_SIZE (type) && ! TREE_CONSTANT (TYPE_SIZE (type)))
849 cp_error ("variable-sized object of type `%T' may not be initialized",
851 return error_mark_node;
854 if (code == ARRAY_TYPE || code == RECORD_TYPE || code == UNION_TYPE)
856 if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type))
858 cp_error ("subobject of type `%T' must be initialized by constructor, not by `%E'",
860 return error_mark_node;
862 else if (raw_constructor)
863 return process_init_constructor (type, init, (tree *)0);
864 else if (TYPE_NON_AGGREGATE_CLASS (type))
867 /* This isn't true. */
868 /* This can only be reached when caller is initializing
869 ARRAY_TYPE. In that case, we don't want to convert
870 INIT to TYPE. We will let `expand_vec_init' do it. */
873 return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
874 "initialization", NULL_TREE, 0);
879 *tail = old_tail_contents;
880 return process_init_constructor (type, 0, tail);
883 if (code != ARRAY_TYPE)
884 return convert_for_initialization (NULL_TREE, type, init, LOOKUP_NORMAL,
885 "initialization", NULL_TREE, 0);
888 error ("invalid initializer");
889 return error_mark_node;
892 /* Process a constructor for a variable of type TYPE.
893 The constructor elements may be specified either with INIT or with ELTS,
894 only one of which should be non-null.
896 If INIT is specified, it is a CONSTRUCTOR node which is specifically
897 and solely for initializing this datum.
899 If ELTS is specified, it is the address of a variable containing
900 a list of expressions. We take as many elements as we need
901 from the head of the list and update the list.
903 In the resulting constructor, TREE_CONSTANT is set if all elts are
904 constant, and TREE_STATIC is set if, in addition, all elts are simple enough
905 constants that the assembler and linker can compute them. */
908 process_init_constructor (type, init, elts)
909 tree type, init, *elts;
912 /* List of the elements of the result constructor,
914 register tree members = NULL;
920 /* Make TAIL be the list of elements to use for the initialization,
921 no matter how the data was given to us. */
925 if (warn_missing_braces)
926 warning ("aggregate has a partly bracketed initializer");
930 tail = CONSTRUCTOR_ELTS (init);
932 /* Gobble as many elements as needed, and make a constructor or initial value
933 for each element of this aggregate. Chain them together in result.
934 If there are too few, use 0 for each scalar ultimate component. */
936 if (TREE_CODE (type) == ARRAY_TYPE)
938 tree domain = TYPE_DOMAIN (type);
943 len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
944 - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
947 len = -1; /* Take as many as there are */
949 for (i = 0; (len < 0 || i < len) && tail != 0; i++)
953 if (TREE_VALUE (tail) != 0)
956 next1 = digest_init (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
957 TREE_VALUE (tail), &tail1);
958 if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (type))
959 && TYPE_MAIN_VARIANT (TREE_TYPE (type)) != TYPE_MAIN_VARIANT (TREE_TYPE (next1)))
961 /* The fact this needs to be done suggests this code needs
962 to be totally rewritten. */
963 next1 = convert_for_initialization (NULL_TREE, TREE_TYPE (type), next1, LOOKUP_NORMAL, "initialization", NULL_TREE, 0);
965 my_friendly_assert (tail1 == 0
966 || TREE_CODE (tail1) == TREE_LIST, 319);
967 if (tail == tail1 && len < 0)
969 error ("non-empty initializer for array of empty elements");
970 /* Just ignore what we were supposed to use. */
977 next1 = error_mark_node;
978 tail = TREE_CHAIN (tail);
981 if (next1 == error_mark_node)
983 else if (!TREE_CONSTANT (next1))
985 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
987 members = tree_cons (NULL_TREE, next1, members);
990 if (TREE_CODE (type) == RECORD_TYPE)
996 if (TYPE_USES_VIRTUAL_BASECLASSES (type))
998 sorry ("initializer list for object of class with virtual baseclasses");
999 return error_mark_node;
1002 if (TYPE_BINFO_BASETYPES (type))
1004 sorry ("initializer list for object of class with baseclasses");
1005 return error_mark_node;
1008 if (TYPE_VIRTUAL_P (type))
1010 sorry ("initializer list for object using virtual functions");
1011 return error_mark_node;
1015 for (field = TYPE_FIELDS (type); field && tail;
1016 field = TREE_CHAIN (field))
1018 register tree next1;
1020 if (! DECL_NAME (field))
1022 members = tree_cons (field, integer_zero_node, members);
1026 if (TREE_CODE (field) != FIELD_DECL)
1029 if (TREE_VALUE (tail) != 0)
1033 next1 = digest_init (TREE_TYPE (field),
1034 TREE_VALUE (tail), &tail1);
1035 my_friendly_assert (tail1 == 0
1036 || TREE_CODE (tail1) == TREE_LIST, 320);
1041 next1 = error_mark_node;
1042 tail = TREE_CHAIN (tail);
1045 if (next1 == error_mark_node)
1047 else if (!TREE_CONSTANT (next1))
1049 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
1051 members = tree_cons (field, next1, members);
1053 for (; field; field = TREE_CHAIN (field))
1055 if (TREE_CODE (field) != FIELD_DECL)
1058 /* Does this field have a default initialization? */
1059 if (DECL_INITIAL (field))
1061 register tree next1 = DECL_INITIAL (field);
1062 if (TREE_CODE (next1) == ERROR_MARK)
1064 else if (!TREE_CONSTANT (next1))
1066 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
1068 members = tree_cons (field, next1, members);
1070 else if (TREE_READONLY (field))
1071 error ("uninitialized const member `%s'",
1072 IDENTIFIER_POINTER (DECL_NAME (field)));
1073 else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field))
1074 && CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
1075 error ("member `%s' with uninitialized const fields",
1076 IDENTIFIER_POINTER (DECL_NAME (field)));
1077 else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
1078 error ("member `%s' is uninitialized reference",
1079 IDENTIFIER_POINTER (DECL_NAME (field)));
1083 if (TREE_CODE (type) == UNION_TYPE)
1085 register tree field = TYPE_FIELDS (type);
1086 register tree next1;
1088 /* Find the first named field. ANSI decided in September 1990
1089 that only named fields count here. */
1090 while (field && (DECL_NAME (field) == 0
1091 || TREE_CODE (field) != FIELD_DECL))
1092 field = TREE_CHAIN (field);
1094 /* If this element specifies a field, initialize via that field. */
1095 if (TREE_PURPOSE (tail) != NULL_TREE)
1099 if (TREE_CODE (TREE_PURPOSE (tail)) == FIELD_DECL)
1100 /* Handle the case of a call by build_c_cast. */
1101 field = TREE_PURPOSE (tail), win = 1;
1102 else if (TREE_CODE (TREE_PURPOSE (tail)) != IDENTIFIER_NODE)
1103 error ("index value instead of field name in union initializer");
1107 for (temp = TYPE_FIELDS (type);
1109 temp = TREE_CHAIN (temp))
1110 if (DECL_NAME (temp) == TREE_PURPOSE (tail))
1113 field = temp, win = 1;
1115 error ("no field `%s' in union being initialized",
1116 IDENTIFIER_POINTER (TREE_PURPOSE (tail)));
1119 TREE_VALUE (tail) = error_mark_node;
1121 else if (field == 0)
1123 cp_error ("union `%T' with no named members cannot be initialized",
1125 TREE_VALUE (tail) = error_mark_node;
1128 if (TREE_VALUE (tail) != 0)
1132 next1 = digest_init (TREE_TYPE (field),
1133 TREE_VALUE (tail), &tail1);
1134 if (tail1 != 0 && TREE_CODE (tail1) != TREE_LIST)
1135 my_friendly_abort (357);
1140 next1 = error_mark_node;
1141 tail = TREE_CHAIN (tail);
1144 if (next1 == error_mark_node)
1146 else if (!TREE_CONSTANT (next1))
1148 else if (initializer_constant_valid_p (next1, TREE_TYPE (next1)) == 0)
1150 members = tree_cons (field, next1, members);
1153 /* If arguments were specified as a list, just remove the ones we used. */
1156 /* If arguments were specified as a constructor,
1157 complain unless we used all the elements of the constructor. */
1159 pedwarn ("excess elements in aggregate initializer");
1162 return error_mark_node;
1164 result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (members));
1166 TREE_HAS_CONSTRUCTOR (result) = TREE_HAS_CONSTRUCTOR (init);
1167 if (allconstant) TREE_CONSTANT (result) = 1;
1168 if (allconstant && allsimple) TREE_STATIC (result) = 1;
1172 /* Given a structure or union value DATUM, construct and return
1173 the structure or union component which results from narrowing
1174 that value by the type specified in BASETYPE. For example, given the
1177 class L { int ii; };
1178 class A : L { ... };
1179 class B : L { ... };
1180 class C : A, B { ... };
1188 x.A::ii refers to the ii member of the L part of
1189 of A part of the C object named by X. In this case,
1190 DATUM would be x, and BASETYPE would be A. */
1193 build_scoped_ref (datum, basetype)
1198 tree type = TREE_TYPE (datum);
1200 if (datum == error_mark_node)
1201 return error_mark_node;
1203 if (TREE_CODE (type) == REFERENCE_TYPE)
1204 type = TREE_TYPE (type);
1206 type = TYPE_MAIN_VARIANT (type);
1208 /* This is an easy conversion. */
1209 if (is_aggr_type (basetype, 1))
1211 tree binfo = TYPE_BINFO (basetype);
1212 if (binfo != TYPE_BINFO (type))
1214 binfo = get_binfo (binfo, type, 1);
1215 if (binfo == error_mark_node)
1216 return error_mark_node;
1218 return error_not_base_type (basetype, type);
1221 switch (TREE_CODE (datum))
1226 case FIX_TRUNC_EXPR:
1227 case FIX_FLOOR_EXPR:
1228 case FIX_ROUND_EXPR:
1230 ref = convert_pointer_to (binfo,
1231 build_unary_op (ADDR_EXPR, TREE_OPERAND (datum, 0), 0));
1234 ref = convert_pointer_to (binfo,
1235 build_unary_op (ADDR_EXPR, datum, 0));
1237 return build_indirect_ref (ref, "(compiler error in build_scoped_ref)");
1239 return error_mark_node;
1242 /* Build a reference to an object specified by the C++ `->' operator.
1243 Usually this just involves dereferencing the object, but if the
1244 `->' operator is overloaded, then such overloads must be
1245 performed until an object which does not have the `->' operator
1246 overloaded is found. An error is reported when circular pointer
1247 delegation is detected. */
1250 build_x_arrow (datum)
1253 tree types_memoized = NULL_TREE;
1254 register tree rval = datum;
1255 tree type = TREE_TYPE (rval);
1258 if (type == error_mark_node)
1259 return error_mark_node;
1261 if (processing_template_decl)
1262 return build_min_nt (ARROW_EXPR, rval);
1264 if (TREE_CODE (rval) == OFFSET_REF)
1266 rval = resolve_offset_ref (datum);
1267 type = TREE_TYPE (rval);
1270 if (TREE_CODE (type) == REFERENCE_TYPE)
1272 rval = convert_from_reference (rval);
1273 type = TREE_TYPE (rval);
1276 if (IS_AGGR_TYPE (type) && TYPE_OVERLOADS_ARROW (complete_type (type)))
1278 while ((rval = build_opfncall (COMPONENT_REF, LOOKUP_NORMAL, rval, NULL_TREE, NULL_TREE)))
1280 if (rval == error_mark_node)
1281 return error_mark_node;
1283 if (value_member (TREE_TYPE (rval), types_memoized))
1285 error ("circular pointer delegation detected");
1286 return error_mark_node;
1290 types_memoized = tree_cons (NULL_TREE, TREE_TYPE (rval),
1295 if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
1296 last_rval = convert_from_reference (last_rval);
1299 last_rval = default_conversion (rval);
1301 /* Signature pointers are not dereferenced. */
1302 if (TYPE_LANG_SPECIFIC (TREE_TYPE (last_rval))
1303 && IS_SIGNATURE_POINTER (TREE_TYPE (last_rval)))
1306 if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
1307 return build_indirect_ref (last_rval, NULL_PTR);
1310 error ("result of `operator->()' yields non-pointer result");
1312 error ("base operand of `->' is not a pointer");
1313 return error_mark_node;
1316 /* Make an expression to refer to the COMPONENT field of
1317 structure or union value DATUM. COMPONENT is an arbitrary
1318 expression. DATUM has not already been checked out to be of
1321 For C++, COMPONENT may be a TREE_LIST. This happens when we must
1322 return an object of member type to a method of the current class,
1323 but there is not yet enough typing information to know which one.
1324 As a special case, if there is only one method by that name,
1325 it is returned. Otherwise we return an expression which other
1326 routines will have to know how to deal with later. */
1329 build_m_component_ref (datum, component)
1330 tree datum, component;
1333 tree objtype = TREE_TYPE (datum);
1337 if (processing_template_decl)
1338 return build_min_nt (DOTSTAR_EXPR, datum, component);
1340 if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component)))
1342 type = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (component)));
1347 component = build_indirect_ref (component, NULL_PTR);
1348 type = TREE_TYPE (component);
1349 rettype = TREE_TYPE (type);
1352 if (datum == error_mark_node || component == error_mark_node)
1353 return error_mark_node;
1355 if (TREE_CODE (type) != OFFSET_TYPE && TREE_CODE (type) != METHOD_TYPE)
1357 cp_error ("`%E' cannot be used as a member pointer, since it is of type `%T'", component, type);
1358 return error_mark_node;
1361 if (TREE_CODE (objtype) == REFERENCE_TYPE)
1362 objtype = TREE_TYPE (objtype);
1363 objtype = TYPE_MAIN_VARIANT (objtype);
1365 if (! IS_AGGR_TYPE (objtype))
1367 cp_error ("cannot apply member pointer `%E' to `%E'", component, datum);
1368 cp_error ("which is of non-aggregate type `%T'", objtype);
1369 return error_mark_node;
1372 binfo = get_binfo (TYPE_METHOD_BASETYPE (type), objtype, 1);
1373 if (binfo == NULL_TREE)
1375 cp_error ("member type `%T::' incompatible with object type `%T'",
1376 TYPE_METHOD_BASETYPE (type), objtype);
1377 return error_mark_node;
1379 else if (binfo == error_mark_node)
1380 return error_mark_node;
1382 return build (OFFSET_REF, rettype, datum, component);
1385 /* Return a tree node for the expression TYPENAME '(' PARMS ')'. */
1388 build_functional_cast (exp, parms)
1394 /* This is either a call to a constructor,
1395 or a C cast in C++'s `functional' notation. */
1398 if (exp == error_mark_node || parms == error_mark_node)
1399 return error_mark_node;
1401 if (TREE_CODE (exp) == IDENTIFIER_NODE)
1403 if (IDENTIFIER_HAS_TYPE_VALUE (exp))
1404 /* Either an enum or an aggregate type. */
1405 type = IDENTIFIER_TYPE_VALUE (exp);
1408 type = lookup_name (exp, 1);
1409 if (!type || TREE_CODE (type) != TYPE_DECL)
1411 cp_error ("`%T' fails to be a typedef or built-in type", exp);
1412 return error_mark_node;
1414 type = TREE_TYPE (type);
1417 else if (TREE_CODE (exp) == TYPE_DECL)
1418 type = TREE_TYPE (exp);
1422 if (processing_template_decl)
1423 return build_min (CAST_EXPR, type, parms);
1425 if (IS_SIGNATURE (type))
1427 error ("signature type not allowed in cast or constructor expression");
1428 return error_mark_node;
1431 if (! IS_AGGR_TYPE (type))
1433 /* this must build a C cast */
1434 if (parms == NULL_TREE)
1435 parms = integer_zero_node;
1438 if (TREE_CHAIN (parms) != NULL_TREE)
1439 pedwarn ("initializer list being treated as compound expression");
1440 parms = build_compound_expr (parms);
1443 return build_c_cast (type, parms, 1);
1446 /* Prepare to evaluate as a call to a constructor. If this expression
1447 is actually used, for example,
1449 return X (arg1, arg2, ...);
1451 then the slot being initialized will be filled in. */
1453 if (TYPE_SIZE (complete_type (type)) == NULL_TREE)
1455 cp_error ("type `%T' is not yet defined", type);
1456 return error_mark_node;
1459 if (parms && TREE_CHAIN (parms) == NULL_TREE)
1460 return build_c_cast (type, TREE_VALUE (parms), 1);
1462 exp = build_method_call (NULL_TREE, ctor_identifier, parms,
1463 TYPE_BINFO (type), LOOKUP_NORMAL);
1465 if (exp == error_mark_node)
1466 return error_mark_node;
1468 return build_cplus_new (type, exp);
1471 /* Return the character string for the name that encodes the
1472 enumeral value VALUE in the domain TYPE. */
1475 enum_name_string (value, type)
1479 register tree values = TYPE_VALUES (type);
1480 register HOST_WIDE_INT intval = TREE_INT_CST_LOW (value);
1482 my_friendly_assert (TREE_CODE (type) == ENUMERAL_TYPE, 324);
1484 && TREE_INT_CST_LOW (TREE_VALUE (values)) != intval)
1485 values = TREE_CHAIN (values);
1486 if (values == NULL_TREE)
1488 char *buf = (char *)oballoc (16 + TYPE_NAME_LENGTH (type));
1490 /* Value must have been cast. */
1491 sprintf (buf, "(enum %s)%d",
1492 TYPE_NAME_STRING (type), intval);
1495 return IDENTIFIER_POINTER (TREE_PURPOSE (values));
1499 /* Print out a language-specific error message for
1500 (Pascal) case or (C) switch statements.
1501 CODE tells what sort of message to print.
1502 TYPE is the type of the switch index expression.
1503 NEW is the new value that we were trying to add.
1504 OLD is the old value that stopped us from adding it. */
1507 report_case_error (code, type, new_value, old_value)
1510 tree new_value, old_value;
1515 error ("case label not within a switch statement");
1517 error ("default label not within a switch statement");
1523 error ("multiple default labels in one switch");
1526 if (TREE_CODE (new_value) == RANGE_EXPR)
1527 if (TREE_CODE (old_value) == RANGE_EXPR)
1529 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1530 if (TREE_CODE (type) == ENUMERAL_TYPE)
1531 sprintf (buf, "overlapping ranges [%s..%s], [%s..%s] in case expression",
1532 enum_name_string (TREE_OPERAND (new_value, 0), type),
1533 enum_name_string (TREE_OPERAND (new_value, 1), type),
1534 enum_name_string (TREE_OPERAND (old_value, 0), type),
1535 enum_name_string (TREE_OPERAND (old_value, 1), type));
1537 sprintf (buf, "overlapping ranges [%d..%d], [%d..%d] in case expression",
1538 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
1539 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
1540 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
1541 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)));
1546 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1547 if (TREE_CODE (type) == ENUMERAL_TYPE)
1548 sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
1549 enum_name_string (TREE_OPERAND (new_value, 0), type),
1550 enum_name_string (TREE_OPERAND (new_value, 1), type),
1551 enum_name_string (old_value, type));
1553 sprintf (buf, "range [%d..%d] includes (%d) in case expression",
1554 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
1555 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
1556 TREE_INT_CST_LOW (old_value));
1559 else if (TREE_CODE (old_value) == RANGE_EXPR)
1561 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1562 if (TREE_CODE (type) == ENUMERAL_TYPE)
1563 sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
1564 enum_name_string (TREE_OPERAND (old_value, 0), type),
1565 enum_name_string (TREE_OPERAND (old_value, 1), type),
1566 enum_name_string (new_value, type));
1568 sprintf (buf, "range [%d..%d] includes (%d) in case expression",
1569 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
1570 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)),
1571 TREE_INT_CST_LOW (new_value));
1576 if (TREE_CODE (type) == ENUMERAL_TYPE)
1577 error ("duplicate label `%s' in switch statement",
1578 enum_name_string (new_value, type));
1580 error ("duplicate label (%d) in switch statement",
1581 TREE_INT_CST_LOW (new_value));
1586 if (TREE_CODE (type) == ENUMERAL_TYPE)
1587 warning ("case value out of range for enum %s",
1588 TYPE_NAME_STRING (type));
1590 warning ("case value out of range");
1594 if (TREE_CODE (type) == ENUMERAL_TYPE)
1595 error ("range values `%s' and `%s' reversed",
1596 enum_name_string (new_value, type),
1597 enum_name_string (old_value, type));
1599 error ("range values reversed");
1605 check_for_new_type (string, inptree)
1607 flagged_type_tree inptree;
1609 if (pedantic && inptree.new_type_flag)
1610 pedwarn ("ANSI C++ forbids defining types within %s",string);