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
833 && ! (TREE_TYPE (init)
834 && TYPE_PTRMEMFUNC_P (TREE_TYPE (init))))
836 cp_pedwarn ("braces around scalar initializer for `%T'", type);
837 init = CONSTRUCTOR_ELTS (init);
838 if (TREE_CHAIN (init))
839 cp_pedwarn ("ignoring extra initializers for `%T'", type);
840 init = TREE_VALUE (init);
843 return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
844 "initialization", NULL_TREE, 0);
847 /* Come here only for records and arrays (and unions with constructors). */
849 if (TYPE_SIZE (type) && ! TREE_CONSTANT (TYPE_SIZE (type)))
851 cp_error ("variable-sized object of type `%T' may not be initialized",
853 return error_mark_node;
856 if (code == ARRAY_TYPE || code == RECORD_TYPE || code == UNION_TYPE)
858 if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type))
860 cp_error ("subobject of type `%T' must be initialized by constructor, not by `%E'",
862 return error_mark_node;
864 else if (raw_constructor)
865 return process_init_constructor (type, init, (tree *)0);
866 else if (TYPE_NON_AGGREGATE_CLASS (type))
868 int flags = LOOKUP_NORMAL;
869 /* Initialization from { } is copy-initialization. */
871 flags |= LOOKUP_ONLYCONVERTING;
872 return convert_for_initialization (0, type, init, flags,
873 "initialization", NULL_TREE, 0);
877 *tail = old_tail_contents;
878 return process_init_constructor (type, 0, tail);
881 if (code != ARRAY_TYPE)
882 return convert_for_initialization (NULL_TREE, type, init, LOOKUP_NORMAL,
883 "initialization", NULL_TREE, 0);
886 error ("invalid initializer");
887 return error_mark_node;
890 /* Process a constructor for a variable of type TYPE.
891 The constructor elements may be specified either with INIT or with ELTS,
892 only one of which should be non-null.
894 If INIT is specified, it is a CONSTRUCTOR node which is specifically
895 and solely for initializing this datum.
897 If ELTS is specified, it is the address of a variable containing
898 a list of expressions. We take as many elements as we need
899 from the head of the list and update the list.
901 In the resulting constructor, TREE_CONSTANT is set if all elts are
902 constant, and TREE_STATIC is set if, in addition, all elts are simple enough
903 constants that the assembler and linker can compute them. */
906 process_init_constructor (type, init, elts)
907 tree type, init, *elts;
910 /* List of the elements of the result constructor,
912 register tree members = NULL;
918 /* Make TAIL be the list of elements to use for the initialization,
919 no matter how the data was given to us. */
923 if (warn_missing_braces)
924 warning ("aggregate has a partly bracketed initializer");
928 tail = CONSTRUCTOR_ELTS (init);
930 /* Gobble as many elements as needed, and make a constructor or initial value
931 for each element of this aggregate. Chain them together in result.
932 If there are too few, use 0 for each scalar ultimate component. */
934 if (TREE_CODE (type) == ARRAY_TYPE)
936 tree domain = TYPE_DOMAIN (type);
941 len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
942 - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
945 len = -1; /* Take as many as there are */
947 for (i = 0; (len < 0 || i < len) && tail != 0; i++)
951 if (TREE_VALUE (tail) != 0)
954 next1 = digest_init (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
955 TREE_VALUE (tail), &tail1);
956 if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (type))
957 && TYPE_MAIN_VARIANT (TREE_TYPE (type)) != TYPE_MAIN_VARIANT (TREE_TYPE (next1)))
959 /* The fact this needs to be done suggests this code needs
960 to be totally rewritten. */
961 next1 = convert_for_initialization (NULL_TREE, TREE_TYPE (type), next1, LOOKUP_NORMAL, "initialization", NULL_TREE, 0);
963 my_friendly_assert (tail1 == 0
964 || TREE_CODE (tail1) == TREE_LIST, 319);
965 if (tail == tail1 && len < 0)
967 error ("non-empty initializer for array of empty elements");
968 /* Just ignore what we were supposed to use. */
975 next1 = error_mark_node;
976 tail = TREE_CHAIN (tail);
979 if (next1 == error_mark_node)
981 else if (!TREE_CONSTANT (next1))
983 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
985 members = tree_cons (NULL_TREE, next1, members);
988 if (TREE_CODE (type) == RECORD_TYPE)
994 if (TYPE_USES_VIRTUAL_BASECLASSES (type))
996 sorry ("initializer list for object of class with virtual baseclasses");
997 return error_mark_node;
1000 if (TYPE_BINFO_BASETYPES (type))
1002 sorry ("initializer list for object of class with baseclasses");
1003 return error_mark_node;
1006 if (TYPE_VIRTUAL_P (type))
1008 sorry ("initializer list for object using virtual functions");
1009 return error_mark_node;
1013 for (field = TYPE_FIELDS (type); field && tail;
1014 field = TREE_CHAIN (field))
1016 register tree next1;
1018 if (! DECL_NAME (field))
1020 members = tree_cons (field, integer_zero_node, members);
1024 if (TREE_CODE (field) != FIELD_DECL)
1027 if (TREE_VALUE (tail) != 0)
1031 next1 = digest_init (TREE_TYPE (field),
1032 TREE_VALUE (tail), &tail1);
1033 my_friendly_assert (tail1 == 0
1034 || TREE_CODE (tail1) == TREE_LIST, 320);
1039 next1 = error_mark_node;
1040 tail = TREE_CHAIN (tail);
1043 if (next1 == error_mark_node)
1045 else if (!TREE_CONSTANT (next1))
1047 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
1049 members = tree_cons (field, next1, members);
1051 for (; field; field = TREE_CHAIN (field))
1053 if (TREE_CODE (field) != FIELD_DECL)
1056 /* Does this field have a default initialization? */
1057 if (DECL_INITIAL (field))
1059 register tree next1 = DECL_INITIAL (field);
1060 if (TREE_CODE (next1) == ERROR_MARK)
1062 else if (!TREE_CONSTANT (next1))
1064 else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
1066 members = tree_cons (field, next1, members);
1068 else if (TREE_READONLY (field))
1069 error ("uninitialized const member `%s'",
1070 IDENTIFIER_POINTER (DECL_NAME (field)));
1071 else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field))
1072 && CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
1073 error ("member `%s' with uninitialized const fields",
1074 IDENTIFIER_POINTER (DECL_NAME (field)));
1075 else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
1076 error ("member `%s' is uninitialized reference",
1077 IDENTIFIER_POINTER (DECL_NAME (field)));
1081 if (TREE_CODE (type) == UNION_TYPE)
1083 register tree field = TYPE_FIELDS (type);
1084 register tree next1;
1086 /* Find the first named field. ANSI decided in September 1990
1087 that only named fields count here. */
1088 while (field && (DECL_NAME (field) == 0
1089 || TREE_CODE (field) != FIELD_DECL))
1090 field = TREE_CHAIN (field);
1092 /* If this element specifies a field, initialize via that field. */
1093 if (TREE_PURPOSE (tail) != NULL_TREE)
1097 if (TREE_CODE (TREE_PURPOSE (tail)) == FIELD_DECL)
1098 /* Handle the case of a call by build_c_cast. */
1099 field = TREE_PURPOSE (tail), win = 1;
1100 else if (TREE_CODE (TREE_PURPOSE (tail)) != IDENTIFIER_NODE)
1101 error ("index value instead of field name in union initializer");
1105 for (temp = TYPE_FIELDS (type);
1107 temp = TREE_CHAIN (temp))
1108 if (DECL_NAME (temp) == TREE_PURPOSE (tail))
1111 field = temp, win = 1;
1113 error ("no field `%s' in union being initialized",
1114 IDENTIFIER_POINTER (TREE_PURPOSE (tail)));
1117 TREE_VALUE (tail) = error_mark_node;
1119 else if (field == 0)
1121 cp_error ("union `%T' with no named members cannot be initialized",
1123 TREE_VALUE (tail) = error_mark_node;
1126 if (TREE_VALUE (tail) != 0)
1130 next1 = digest_init (TREE_TYPE (field),
1131 TREE_VALUE (tail), &tail1);
1132 if (tail1 != 0 && TREE_CODE (tail1) != TREE_LIST)
1133 my_friendly_abort (357);
1138 next1 = error_mark_node;
1139 tail = TREE_CHAIN (tail);
1142 if (next1 == error_mark_node)
1144 else if (!TREE_CONSTANT (next1))
1146 else if (initializer_constant_valid_p (next1, TREE_TYPE (next1)) == 0)
1148 members = tree_cons (field, next1, members);
1151 /* If arguments were specified as a list, just remove the ones we used. */
1154 /* If arguments were specified as a constructor,
1155 complain unless we used all the elements of the constructor. */
1157 pedwarn ("excess elements in aggregate initializer");
1160 return error_mark_node;
1162 result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (members));
1164 TREE_HAS_CONSTRUCTOR (result) = TREE_HAS_CONSTRUCTOR (init);
1165 if (allconstant) TREE_CONSTANT (result) = 1;
1166 if (allconstant && allsimple) TREE_STATIC (result) = 1;
1170 /* Given a structure or union value DATUM, construct and return
1171 the structure or union component which results from narrowing
1172 that value by the type specified in BASETYPE. For example, given the
1175 class L { int ii; };
1176 class A : L { ... };
1177 class B : L { ... };
1178 class C : A, B { ... };
1186 x.A::ii refers to the ii member of the L part of
1187 of A part of the C object named by X. In this case,
1188 DATUM would be x, and BASETYPE would be A. */
1191 build_scoped_ref (datum, basetype)
1196 tree type = TREE_TYPE (datum);
1198 if (datum == error_mark_node)
1199 return error_mark_node;
1201 if (TREE_CODE (type) == REFERENCE_TYPE)
1202 type = TREE_TYPE (type);
1204 type = TYPE_MAIN_VARIANT (type);
1206 /* This is an easy conversion. */
1207 if (is_aggr_type (basetype, 1))
1209 tree binfo = TYPE_BINFO (basetype);
1210 if (binfo != TYPE_BINFO (type))
1212 binfo = get_binfo (binfo, type, 1);
1213 if (binfo == error_mark_node)
1214 return error_mark_node;
1216 return error_not_base_type (basetype, type);
1219 switch (TREE_CODE (datum))
1224 case FIX_TRUNC_EXPR:
1225 case FIX_FLOOR_EXPR:
1226 case FIX_ROUND_EXPR:
1228 ref = convert_pointer_to (binfo,
1229 build_unary_op (ADDR_EXPR, TREE_OPERAND (datum, 0), 0));
1232 ref = convert_pointer_to (binfo,
1233 build_unary_op (ADDR_EXPR, datum, 0));
1235 return build_indirect_ref (ref, "(compiler error in build_scoped_ref)");
1237 return error_mark_node;
1240 /* Build a reference to an object specified by the C++ `->' operator.
1241 Usually this just involves dereferencing the object, but if the
1242 `->' operator is overloaded, then such overloads must be
1243 performed until an object which does not have the `->' operator
1244 overloaded is found. An error is reported when circular pointer
1245 delegation is detected. */
1248 build_x_arrow (datum)
1251 tree types_memoized = NULL_TREE;
1252 register tree rval = datum;
1253 tree type = TREE_TYPE (rval);
1256 if (type == error_mark_node)
1257 return error_mark_node;
1259 if (processing_template_decl)
1260 return build_min_nt (ARROW_EXPR, rval);
1262 if (TREE_CODE (rval) == OFFSET_REF)
1264 rval = resolve_offset_ref (datum);
1265 type = TREE_TYPE (rval);
1268 if (TREE_CODE (type) == REFERENCE_TYPE)
1270 rval = convert_from_reference (rval);
1271 type = TREE_TYPE (rval);
1274 if (IS_AGGR_TYPE (type) && TYPE_OVERLOADS_ARROW (complete_type (type)))
1276 while ((rval = build_opfncall (COMPONENT_REF, LOOKUP_NORMAL, rval, NULL_TREE, NULL_TREE)))
1278 if (rval == error_mark_node)
1279 return error_mark_node;
1281 if (value_member (TREE_TYPE (rval), types_memoized))
1283 error ("circular pointer delegation detected");
1284 return error_mark_node;
1288 types_memoized = tree_cons (NULL_TREE, TREE_TYPE (rval),
1293 if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
1294 last_rval = convert_from_reference (last_rval);
1297 last_rval = default_conversion (rval);
1299 /* Signature pointers are not dereferenced. */
1300 if (TYPE_LANG_SPECIFIC (TREE_TYPE (last_rval))
1301 && IS_SIGNATURE_POINTER (TREE_TYPE (last_rval)))
1304 if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
1305 return build_indirect_ref (last_rval, NULL_PTR);
1308 error ("result of `operator->()' yields non-pointer result");
1310 error ("base operand of `->' is not a pointer");
1311 return error_mark_node;
1314 /* Make an expression to refer to the COMPONENT field of
1315 structure or union value DATUM. COMPONENT is an arbitrary
1316 expression. DATUM has not already been checked out to be of
1319 For C++, COMPONENT may be a TREE_LIST. This happens when we must
1320 return an object of member type to a method of the current class,
1321 but there is not yet enough typing information to know which one.
1322 As a special case, if there is only one method by that name,
1323 it is returned. Otherwise we return an expression which other
1324 routines will have to know how to deal with later. */
1327 build_m_component_ref (datum, component)
1328 tree datum, component;
1331 tree objtype = TREE_TYPE (datum);
1335 if (processing_template_decl)
1336 return build_min_nt (DOTSTAR_EXPR, datum, component);
1338 if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component)))
1340 type = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (component)));
1345 component = build_indirect_ref (component, NULL_PTR);
1346 type = TREE_TYPE (component);
1347 rettype = TREE_TYPE (type);
1350 if (datum == error_mark_node || component == error_mark_node)
1351 return error_mark_node;
1353 if (TREE_CODE (type) != OFFSET_TYPE && TREE_CODE (type) != METHOD_TYPE)
1355 cp_error ("`%E' cannot be used as a member pointer, since it is of type `%T'", component, type);
1356 return error_mark_node;
1359 if (TREE_CODE (objtype) == REFERENCE_TYPE)
1360 objtype = TREE_TYPE (objtype);
1361 objtype = TYPE_MAIN_VARIANT (objtype);
1363 if (! IS_AGGR_TYPE (objtype))
1365 cp_error ("cannot apply member pointer `%E' to `%E'", component, datum);
1366 cp_error ("which is of non-aggregate type `%T'", objtype);
1367 return error_mark_node;
1370 binfo = get_binfo (TYPE_METHOD_BASETYPE (type), objtype, 1);
1371 if (binfo == NULL_TREE)
1373 cp_error ("member type `%T::' incompatible with object type `%T'",
1374 TYPE_METHOD_BASETYPE (type), objtype);
1375 return error_mark_node;
1377 else if (binfo == error_mark_node)
1378 return error_mark_node;
1380 component = build (OFFSET_REF, rettype, datum, component);
1381 if (TREE_CODE (type) == OFFSET_TYPE)
1382 component = resolve_offset_ref (component);
1386 /* Return a tree node for the expression TYPENAME '(' PARMS ')'. */
1389 build_functional_cast (exp, parms)
1395 /* This is either a call to a constructor,
1396 or a C cast in C++'s `functional' notation. */
1399 if (exp == error_mark_node || parms == error_mark_node)
1400 return error_mark_node;
1402 if (TREE_CODE (exp) == IDENTIFIER_NODE)
1404 if (IDENTIFIER_HAS_TYPE_VALUE (exp))
1405 /* Either an enum or an aggregate type. */
1406 type = IDENTIFIER_TYPE_VALUE (exp);
1409 type = lookup_name (exp, 1);
1410 if (!type || TREE_CODE (type) != TYPE_DECL)
1412 cp_error ("`%T' fails to be a typedef or built-in type", exp);
1413 return error_mark_node;
1415 type = TREE_TYPE (type);
1418 else if (TREE_CODE (exp) == TYPE_DECL)
1419 type = TREE_TYPE (exp);
1423 if (processing_template_decl)
1424 return build_min (CAST_EXPR, type, parms);
1426 if (IS_SIGNATURE (type))
1428 error ("signature type not allowed in cast or constructor expression");
1429 return error_mark_node;
1432 if (! IS_AGGR_TYPE (type))
1434 /* this must build a C cast */
1435 if (parms == NULL_TREE)
1436 parms = integer_zero_node;
1439 if (TREE_CHAIN (parms) != NULL_TREE)
1440 pedwarn ("initializer list being treated as compound expression");
1441 parms = build_compound_expr (parms);
1444 return build_c_cast (type, parms);
1447 /* Prepare to evaluate as a call to a constructor. If this expression
1448 is actually used, for example,
1450 return X (arg1, arg2, ...);
1452 then the slot being initialized will be filled in. */
1454 if (TYPE_SIZE (complete_type (type)) == NULL_TREE)
1456 cp_error ("type `%T' is not yet defined", type);
1457 return error_mark_node;
1460 if (parms && TREE_CHAIN (parms) == NULL_TREE)
1461 return build_c_cast (type, TREE_VALUE (parms));
1463 exp = build_method_call (NULL_TREE, ctor_identifier, parms,
1464 TYPE_BINFO (type), LOOKUP_NORMAL);
1466 if (exp == error_mark_node)
1467 return error_mark_node;
1469 return build_cplus_new (type, exp);
1472 /* Return the character string for the name that encodes the
1473 enumeral value VALUE in the domain TYPE. */
1476 enum_name_string (value, type)
1480 register tree values = TYPE_VALUES (type);
1481 register HOST_WIDE_INT intval = TREE_INT_CST_LOW (value);
1483 my_friendly_assert (TREE_CODE (type) == ENUMERAL_TYPE, 324);
1485 && TREE_INT_CST_LOW (TREE_VALUE (values)) != intval)
1486 values = TREE_CHAIN (values);
1487 if (values == NULL_TREE)
1489 char *buf = (char *)oballoc (16 + TYPE_NAME_LENGTH (type));
1491 /* Value must have been cast. */
1492 sprintf (buf, "(enum %s)%d",
1493 TYPE_NAME_STRING (type), intval);
1496 return IDENTIFIER_POINTER (TREE_PURPOSE (values));
1500 /* Print out a language-specific error message for
1501 (Pascal) case or (C) switch statements.
1502 CODE tells what sort of message to print.
1503 TYPE is the type of the switch index expression.
1504 NEW is the new value that we were trying to add.
1505 OLD is the old value that stopped us from adding it. */
1508 report_case_error (code, type, new_value, old_value)
1511 tree new_value, old_value;
1516 error ("case label not within a switch statement");
1518 error ("default label not within a switch statement");
1524 error ("multiple default labels in one switch");
1527 if (TREE_CODE (new_value) == RANGE_EXPR)
1528 if (TREE_CODE (old_value) == RANGE_EXPR)
1530 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1531 if (TREE_CODE (type) == ENUMERAL_TYPE)
1532 sprintf (buf, "overlapping ranges [%s..%s], [%s..%s] in case expression",
1533 enum_name_string (TREE_OPERAND (new_value, 0), type),
1534 enum_name_string (TREE_OPERAND (new_value, 1), type),
1535 enum_name_string (TREE_OPERAND (old_value, 0), type),
1536 enum_name_string (TREE_OPERAND (old_value, 1), type));
1538 sprintf (buf, "overlapping ranges [%d..%d], [%d..%d] in case expression",
1539 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
1540 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
1541 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
1542 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)));
1547 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1548 if (TREE_CODE (type) == ENUMERAL_TYPE)
1549 sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
1550 enum_name_string (TREE_OPERAND (new_value, 0), type),
1551 enum_name_string (TREE_OPERAND (new_value, 1), type),
1552 enum_name_string (old_value, type));
1554 sprintf (buf, "range [%d..%d] includes (%d) in case expression",
1555 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
1556 TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
1557 TREE_INT_CST_LOW (old_value));
1560 else if (TREE_CODE (old_value) == RANGE_EXPR)
1562 char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
1563 if (TREE_CODE (type) == ENUMERAL_TYPE)
1564 sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
1565 enum_name_string (TREE_OPERAND (old_value, 0), type),
1566 enum_name_string (TREE_OPERAND (old_value, 1), type),
1567 enum_name_string (new_value, type));
1569 sprintf (buf, "range [%d..%d] includes (%d) in case expression",
1570 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
1571 TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)),
1572 TREE_INT_CST_LOW (new_value));
1577 if (TREE_CODE (type) == ENUMERAL_TYPE)
1578 error ("duplicate label `%s' in switch statement",
1579 enum_name_string (new_value, type));
1581 error ("duplicate label (%d) in switch statement",
1582 TREE_INT_CST_LOW (new_value));
1587 if (TREE_CODE (type) == ENUMERAL_TYPE)
1588 warning ("case value out of range for enum %s",
1589 TYPE_NAME_STRING (type));
1591 warning ("case value out of range");
1595 if (TREE_CODE (type) == ENUMERAL_TYPE)
1596 error ("range values `%s' and `%s' reversed",
1597 enum_name_string (new_value, type),
1598 enum_name_string (old_value, type));
1600 error ("range values reversed");
1606 check_for_new_type (string, inptree)
1608 flagged_type_tree inptree;
1610 if (pedantic && inptree.new_type_flag)
1611 pedwarn ("ANSI C++ forbids defining types within %s",string);