home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / c-typeck.c < prev    next >
C/C++ Source or Header  |  1996-12-12  |  209KB  |  6,680 lines

  1. /* Build expressions with type checking for C compiler.
  2.    Copyright (C) 1987, 88, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. /* This file is part of the C front end.
  23.    It contains routines to build C expressions given their operands,
  24.    including computing the types of the result, C-specific error checks,
  25.    and some optimization.
  26.  
  27.    There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
  28.    and to process initializations in declarations (since they work
  29.    like a strange sort of assignment).  */
  30.  
  31. #include "config.h"
  32. #include <stdio.h>
  33. #include "tree.h"
  34. #include "c-tree.h"
  35. #include "flags.h"
  36. #include "output.h"
  37.  
  38. /* Nonzero if we've already printed a "missing braces around initializer"
  39.    message within this initializer.  */
  40. static int missing_braces_mentioned;
  41.  
  42. extern char *index ();
  43. extern char *rindex ();
  44.  
  45. static tree quality_type        PROTO((tree, tree));
  46. static int comp_target_types        PROTO((tree, tree));
  47. static int function_types_compatible_p    PROTO((tree, tree));
  48. static int type_lists_compatible_p    PROTO((tree, tree));
  49. static int self_promoting_type_p    PROTO((tree));
  50. static tree decl_constant_value        PROTO((tree));
  51. static tree lookup_field        PROTO((tree, tree, tree *));
  52. static tree convert_arguments        PROTO((tree, tree, tree, tree));
  53. static tree pointer_int_sum        PROTO((enum tree_code, tree, tree));
  54. static tree pointer_diff        PROTO((tree, tree));
  55. static tree unary_complex_lvalue    PROTO((enum tree_code, tree));
  56. static void pedantic_lvalue_warning    PROTO((enum tree_code));
  57. static tree internal_build_compound_expr PROTO((tree, int));
  58. static tree convert_for_assignment    PROTO((tree, tree, char *, tree,
  59.                            tree, int));
  60. static void warn_for_assignment        PROTO((char *, char *, tree, int));
  61. static tree valid_compound_expr_initializer PROTO((tree, tree));
  62. static void push_string            PROTO((char *));
  63. static void push_member_name        PROTO((tree));
  64. static void push_array_bounds        PROTO((int));
  65. static int spelling_length        PROTO((void));
  66. static char *print_spelling        PROTO((char *));
  67. static char *get_spelling        PROTO((char *));
  68. static void warning_init        PROTO((char *, char *,
  69.                            char *));
  70. static tree digest_init            PROTO((tree, tree, int, int));
  71. static void check_init_type_bitfields    PROTO((tree));
  72. static void output_init_element        PROTO((tree, tree, tree, int));
  73. static void output_pending_init_elements PROTO((int));
  74.  
  75. /* Do `exp = require_complete_type (exp);' to make sure exp
  76.    does not have an incomplete type.  (That includes void types.)  */
  77.  
  78. tree
  79. require_complete_type (value)
  80.      tree value;
  81. {
  82.   tree type = TREE_TYPE (value);
  83.  
  84.   /* First, detect a valid value with a complete type.  */
  85.   if (TYPE_SIZE (type) != 0
  86.       && type != void_type_node)
  87.     return value;
  88.  
  89.   incomplete_type_error (value, type);
  90.   return error_mark_node;
  91. }
  92.  
  93. /* Print an error message for invalid use of an incomplete type.
  94.    VALUE is the expression that was used (or 0 if that isn't known)
  95.    and TYPE is the type that was invalid.  */
  96.  
  97. void
  98. incomplete_type_error (value, type)
  99.      tree value;
  100.      tree type;
  101. {
  102.   char *errmsg;
  103.  
  104.   /* Avoid duplicate error message.  */
  105.   if (TREE_CODE (type) == ERROR_MARK)
  106.     return;
  107.  
  108.   if (value != 0 && (TREE_CODE (value) == VAR_DECL
  109.              || TREE_CODE (value) == PARM_DECL))
  110.     error ("`%s' has an incomplete type",
  111.        IDENTIFIER_POINTER (DECL_NAME (value)));
  112.   else
  113.     {
  114.     retry:
  115.       /* We must print an error message.  Be clever about what it says.  */
  116.  
  117.       switch (TREE_CODE (type))
  118.     {
  119.     case RECORD_TYPE:
  120.       errmsg = "invalid use of undefined type `struct %s'";
  121.       break;
  122.  
  123.     case UNION_TYPE:
  124.       errmsg = "invalid use of undefined type `union %s'";
  125.       break;
  126.  
  127.     case ENUMERAL_TYPE:
  128.       errmsg = "invalid use of undefined type `enum %s'";
  129.       break;
  130.  
  131.     case VOID_TYPE:
  132.       error ("invalid use of void expression");
  133.       return;
  134.  
  135.     case ARRAY_TYPE:
  136.       if (TYPE_DOMAIN (type))
  137.         {
  138.           type = TREE_TYPE (type);
  139.           goto retry;
  140.         }
  141.       error ("invalid use of array with unspecified bounds");
  142.       return;
  143.  
  144.     default:
  145.       abort ();
  146.     }
  147.  
  148.       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
  149.     error (errmsg, IDENTIFIER_POINTER (TYPE_NAME (type)));
  150.       else
  151.     /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
  152.     error ("invalid use of incomplete typedef `%s'",
  153.            IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
  154.     }
  155. }
  156.  
  157. /* Return a variant of TYPE which has all the type qualifiers of LIKE
  158.    as well as those of TYPE.  */
  159.  
  160. static tree
  161. qualify_type (type, like)
  162.      tree type, like;
  163. {
  164.   int constflag = TYPE_READONLY (type) || TYPE_READONLY (like);
  165.   int volflag = TYPE_VOLATILE (type) || TYPE_VOLATILE (like);
  166.   return c_build_type_variant (type, constflag, volflag);
  167. }
  168.  
  169. /* Return the common type of two types.
  170.    We assume that comptypes has already been done and returned 1;
  171.    if that isn't so, this may crash.  In particular, we assume that qualifiers
  172.    match.
  173.  
  174.    This is the type for the result of most arithmetic operations
  175.    if the operands have the given two types.  */
  176.  
  177. tree
  178. common_type (t1, t2)
  179.      tree t1, t2;
  180. {
  181.   register enum tree_code code1;
  182.   register enum tree_code code2;
  183.   tree attributes;
  184.  
  185.   /* Save time if the two types are the same.  */
  186.  
  187.   if (t1 == t2) return t1;
  188.  
  189.   /* If one type is nonsense, use the other.  */
  190.   if (t1 == error_mark_node)
  191.     return t2;
  192.   if (t2 == error_mark_node)
  193.     return t1;
  194.  
  195.   /* Merge the attributes */
  196.  
  197.   { register tree a1, a2;
  198.     a1 = TYPE_ATTRIBUTES (t1);
  199.     a2 = TYPE_ATTRIBUTES (t2);
  200.  
  201.     /* Either one unset?  Take the set one.  */
  202.  
  203.     if (!(attributes = a1))
  204.        attributes = a2;
  205.  
  206.     /* One that completely contains the other?  Take it.  */
  207.  
  208.     else if (a2 && !attribute_list_contained (a1, a2))
  209.        if (attribute_list_contained (a2, a1))
  210.       attributes = a2;
  211.        else
  212.     {
  213.       /* Pick the longest list, and hang on the other list.  */
  214.       /* ??? For the moment we punt on the issue of attrs with args.  */
  215.     
  216.       if (list_length (a1) < list_length (a2))
  217.          attributes = a2, a2 = a1;
  218.  
  219.       for (; a2; a2 = TREE_CHAIN (a2))
  220.         if (lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2)),
  221.                   attributes) == NULL_TREE)
  222.           {
  223.         a1 = copy_node (a2);
  224.         TREE_CHAIN (a1) = attributes;
  225.         attributes = a1;
  226.           }
  227.     }
  228.   }
  229.  
  230.   /* Treat an enum type as the unsigned integer type of the same width.  */
  231.  
  232.   if (TREE_CODE (t1) == ENUMERAL_TYPE)
  233.     t1 = type_for_size (TYPE_PRECISION (t1), 1);
  234.   if (TREE_CODE (t2) == ENUMERAL_TYPE)
  235.     t2 = type_for_size (TYPE_PRECISION (t2), 1);
  236.  
  237.   code1 = TREE_CODE (t1);
  238.   code2 = TREE_CODE (t2);
  239.  
  240.   /* If one type is complex, form the common type of the non-complex
  241.      components, then make that complex.  Use T1 or T2 if it is the
  242.      required type.  */
  243.   if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
  244.     {
  245.       tree subtype1 = code1 == COMPLEX_TYPE ? TREE_TYPE (t1) : t1;
  246.       tree subtype2 = code2 == COMPLEX_TYPE ? TREE_TYPE (t2) : t2;
  247.       tree subtype = common_type (subtype1, subtype2);
  248.  
  249.       if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype)
  250.     return build_type_attribute_variant (t1, attributes);
  251.       else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype)
  252.     return build_type_attribute_variant (t2, attributes);
  253.       else
  254.     return build_type_attribute_variant (build_complex_type (subtype),
  255.                          attributes);
  256.     }
  257.  
  258.   switch (code1)
  259.     {
  260.     case INTEGER_TYPE:
  261.     case REAL_TYPE:
  262.       /* If only one is real, use it as the result.  */
  263.  
  264.       if (code1 == REAL_TYPE && code2 != REAL_TYPE)
  265.     return build_type_attribute_variant (t1, attributes);
  266.  
  267.       if (code2 == REAL_TYPE && code1 != REAL_TYPE)
  268.     return build_type_attribute_variant (t2, attributes);
  269.  
  270.       /* Both real or both integers; use the one with greater precision.  */
  271.  
  272.       if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
  273.     return build_type_attribute_variant (t1, attributes);
  274.       else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
  275.     return build_type_attribute_variant (t2, attributes);
  276.  
  277.       /* Same precision.  Prefer longs to ints even when same size.  */
  278.  
  279.       if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
  280.       || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
  281.     return build_type_attribute_variant (long_unsigned_type_node,
  282.                          attributes);
  283.  
  284.       if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
  285.       || TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
  286.     {
  287.       /* But preserve unsignedness from the other type,
  288.          since long cannot hold all the values of an unsigned int.  */
  289.       if (TREE_UNSIGNED (t1) || TREE_UNSIGNED (t2))
  290.          t1 = long_unsigned_type_node;
  291.       else
  292.          t1 = long_integer_type_node;
  293.       return build_type_attribute_variant (t1, attributes);
  294.     }
  295.  
  296.       /* Otherwise prefer the unsigned one.  */
  297.  
  298.       if (TREE_UNSIGNED (t1))
  299.     return build_type_attribute_variant (t1, attributes);
  300.       else
  301.     return build_type_attribute_variant (t2, attributes);
  302.  
  303.     case POINTER_TYPE:
  304.       /* For two pointers, do this recursively on the target type,
  305.      and combine the qualifiers of the two types' targets.  */
  306.       /* This code was turned off; I don't know why.
  307.      But ANSI C specifies doing this with the qualifiers.
  308.      So I turned it on again.  */
  309.       {
  310.     tree target = common_type (TYPE_MAIN_VARIANT (TREE_TYPE (t1)),
  311.                    TYPE_MAIN_VARIANT (TREE_TYPE (t2)));
  312.     int constp
  313.       = TYPE_READONLY (TREE_TYPE (t1)) || TYPE_READONLY (TREE_TYPE (t2));
  314.     int volatilep
  315.       = TYPE_VOLATILE (TREE_TYPE (t1)) || TYPE_VOLATILE (TREE_TYPE (t2));
  316.     t1 = build_pointer_type (c_build_type_variant (target, constp,
  317.                  volatilep));
  318.     return build_type_attribute_variant (t1, attributes);
  319.       }
  320. #if 0
  321.       t1 = build_pointer_type (common_type (TREE_TYPE (t1), TREE_TYPE (t2)));
  322.       return build_type_attribute_variant (t1, attributes);
  323. #endif
  324.  
  325.     case ARRAY_TYPE:
  326.       {
  327.     tree elt = common_type (TREE_TYPE (t1), TREE_TYPE (t2));
  328.     /* Save space: see if the result is identical to one of the args.  */
  329.     if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1))
  330.       return build_type_attribute_variant (t1, attributes);
  331.     if (elt == TREE_TYPE (t2) && TYPE_DOMAIN (t2))
  332.       return build_type_attribute_variant (t2, attributes);
  333.     /* Merge the element types, and have a size if either arg has one.  */
  334.     t1 = build_array_type (elt, TYPE_DOMAIN (TYPE_DOMAIN (t1) ? t1 : t2));
  335.     return build_type_attribute_variant (t1, attributes);
  336.       }
  337.  
  338.     case FUNCTION_TYPE:
  339.       /* Function types: prefer the one that specified arg types.
  340.      If both do, merge the arg types.  Also merge the return types.  */
  341.       {
  342.     tree valtype = common_type (TREE_TYPE (t1), TREE_TYPE (t2));
  343.     tree p1 = TYPE_ARG_TYPES (t1);
  344.     tree p2 = TYPE_ARG_TYPES (t2);
  345.     int len;
  346.     tree newargs, n;
  347.     int i;
  348.  
  349.     /* Save space: see if the result is identical to one of the args.  */
  350.     if (valtype == TREE_TYPE (t1) && ! TYPE_ARG_TYPES (t2))
  351.       return build_type_attribute_variant (t1, attributes);
  352.     if (valtype == TREE_TYPE (t2) && ! TYPE_ARG_TYPES (t1))
  353.       return build_type_attribute_variant (t2, attributes);
  354.  
  355.     /* Simple way if one arg fails to specify argument types.  */
  356.     if (TYPE_ARG_TYPES (t1) == 0)
  357.      {
  358.        t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2));
  359.        return build_type_attribute_variant (t1, attributes);
  360.      }
  361.     if (TYPE_ARG_TYPES (t2) == 0)
  362.      {
  363.        t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1));
  364.        return build_type_attribute_variant (t1, attributes);
  365.      }
  366.  
  367.     /* If both args specify argument types, we must merge the two
  368.        lists, argument by argument.  */
  369.  
  370.     len = list_length (p1);
  371.     newargs = 0;
  372.  
  373.     for (i = 0; i < len; i++)
  374.       newargs = tree_cons (NULL_TREE, NULL_TREE, newargs);
  375.  
  376.     n = newargs;
  377.  
  378.     for (; p1;
  379.          p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n))
  380.       {
  381.         /* A null type means arg type is not specified.
  382.            Take whatever the other function type has.  */
  383.         if (TREE_VALUE (p1) == 0)
  384.           {
  385.         TREE_VALUE (n) = TREE_VALUE (p2);
  386.         goto parm_done;
  387.           }
  388.         if (TREE_VALUE (p2) == 0)
  389.           {
  390.         TREE_VALUE (n) = TREE_VALUE (p1);
  391.         goto parm_done;
  392.           }
  393.           
  394.         /* Given  wait (union {union wait *u; int *i} *)
  395.            and  wait (union wait *),
  396.            prefer  union wait *  as type of parm.  */
  397.         if (TREE_CODE (TREE_VALUE (p1)) == UNION_TYPE
  398.         && TREE_VALUE (p1) != TREE_VALUE (p2))
  399.           {
  400.         tree memb;
  401.         for (memb = TYPE_FIELDS (TREE_VALUE (p1));
  402.              memb; memb = TREE_CHAIN (memb))
  403.           if (comptypes (TREE_TYPE (memb), TREE_VALUE (p2)))
  404.             {
  405.               TREE_VALUE (n) = TREE_VALUE (p2);
  406.               if (pedantic)
  407.             pedwarn ("function types not truly compatible in ANSI C");
  408.               goto parm_done;
  409.             }
  410.           }
  411.         if (TREE_CODE (TREE_VALUE (p2)) == UNION_TYPE
  412.         && TREE_VALUE (p2) != TREE_VALUE (p1))
  413.           {
  414.         tree memb;
  415.         for (memb = TYPE_FIELDS (TREE_VALUE (p2));
  416.              memb; memb = TREE_CHAIN (memb))
  417.           if (comptypes (TREE_TYPE (memb), TREE_VALUE (p1)))
  418.             {
  419.               TREE_VALUE (n) = TREE_VALUE (p1);
  420.               if (pedantic)
  421.             pedwarn ("function types not truly compatible in ANSI C");
  422.               goto parm_done;
  423.             }
  424.           }
  425.         TREE_VALUE (n) = common_type (TREE_VALUE (p1), TREE_VALUE (p2));
  426.       parm_done: ;
  427.       }
  428.  
  429.     t1 = build_function_type (valtype, newargs);
  430.     /* ... falls through ... */
  431.       }
  432.  
  433.     default:
  434.       return build_type_attribute_variant (t1, attributes);
  435.     }
  436.  
  437. }
  438.  
  439. /* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
  440.    or various other operations.  Return 2 if they are compatible
  441.    but a warning may be needed if you use them together.  */
  442.  
  443. int
  444. comptypes (type1, type2)
  445.      tree type1, type2;
  446. {
  447.   register tree t1 = type1;
  448.   register tree t2 = type2;
  449.   int attrval, val;
  450.  
  451.   /* Suppress errors caused by previously reported errors.  */
  452.  
  453.   if (t1 == t2 || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
  454.     return 1;
  455.  
  456.   /* Treat an enum type as the integer type of the same width and 
  457.      signedness.  */
  458.  
  459.   if (TREE_CODE (t1) == ENUMERAL_TYPE)
  460.     t1 = type_for_size (TYPE_PRECISION (t1), TREE_UNSIGNED (t1));
  461.   if (TREE_CODE (t2) == ENUMERAL_TYPE)
  462.     t2 = type_for_size (TYPE_PRECISION (t2), TREE_UNSIGNED (t2));
  463.  
  464.   if (t1 == t2)
  465.     return 1;
  466.  
  467.   /* Different classes of types can't be compatible.  */
  468.  
  469.   if (TREE_CODE (t1) != TREE_CODE (t2)) return 0;
  470.  
  471.   /* Qualifiers must match.  */
  472.  
  473.   if (TYPE_READONLY (t1) != TYPE_READONLY (t2))
  474.     return 0;
  475.   if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2))
  476.     return 0;
  477.  
  478.   /* Allow for two different type nodes which have essentially the same
  479.      definition.  Note that we already checked for equality of the type
  480.      type qualifiers (just above).  */
  481.  
  482.   if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
  483.     return 1;
  484.  
  485. #ifndef COMP_TYPE_ATTRIBUTES
  486. #define COMP_TYPE_ATTRIBUTES(t1,t2)    1
  487. #endif
  488.  
  489.   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
  490.   if (! (attrval = COMP_TYPE_ATTRIBUTES (t1, t2)))
  491.      return 0;
  492.  
  493.   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
  494.   val = 0;
  495.  
  496.   switch (TREE_CODE (t1))
  497.     {
  498.     case POINTER_TYPE:
  499.       val = (TREE_TYPE (t1) == TREE_TYPE (t2)
  500.           ? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2)));
  501.       break;
  502.  
  503.     case FUNCTION_TYPE:
  504.       val = function_types_compatible_p (t1, t2);
  505.       break;
  506.  
  507.     case ARRAY_TYPE:
  508.       {
  509.     tree d1 = TYPE_DOMAIN (t1);
  510.     tree d2 = TYPE_DOMAIN (t2);
  511.     val = 1;
  512.  
  513.     /* Target types must match incl. qualifiers.  */
  514.     if (TREE_TYPE (t1) != TREE_TYPE (t2)
  515.         && 0 == (val = comptypes (TREE_TYPE (t1), TREE_TYPE (t2))))
  516.       return 0;
  517.  
  518.     /* Sizes must match unless one is missing or variable.  */
  519.     if (d1 == 0 || d2 == 0 || d1 == d2
  520.         || TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
  521.         || TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
  522.         || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST
  523.         || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST)
  524.       break;
  525.  
  526.     if (! ((TREE_INT_CST_LOW (TYPE_MIN_VALUE (d1))
  527.           == TREE_INT_CST_LOW (TYPE_MIN_VALUE (d2)))
  528.          && (TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d1))
  529.              == TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d2)))
  530.          && (TREE_INT_CST_LOW (TYPE_MAX_VALUE (d1))
  531.              == TREE_INT_CST_LOW (TYPE_MAX_VALUE (d2)))
  532.          && (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d1))
  533.              == TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d2)))))
  534.        val = 0;
  535.         break;
  536.       }
  537.  
  538.     case RECORD_TYPE:
  539.       if (maybe_objc_comptypes (t1, t2, 0) == 1)
  540.     val = 1;
  541.       break;
  542.     }
  543.   return attrval == 2 && val == 1 ? 2 : val;
  544. }
  545.  
  546. /* Return 1 if TTL and TTR are pointers to types that are equivalent,
  547.    ignoring their qualifiers.  */
  548.  
  549. static int
  550. comp_target_types (ttl, ttr)
  551.      tree ttl, ttr;
  552. {
  553.   int val;
  554.  
  555.   /* Give maybe_objc_comptypes a crack at letting these types through.  */
  556.   if (val = maybe_objc_comptypes (ttl, ttr, 1) >= 0)
  557.     return val;
  558.  
  559. #ifdef NEXT_SEMANTICS
  560.   if (! pedantic)
  561.     {
  562.       /* Ignore pointer qualifiers recursively.
  563.      This way char ** and const char ** are compatible.  */
  564.       ttl = TYPE_MAIN_VARIANT (TREE_TYPE (ttl));
  565.       ttr = TYPE_MAIN_VARIANT (TREE_TYPE (ttr));
  566.       
  567.       if (TREE_CODE (ttl) == POINTER_TYPE 
  568.       && TREE_CODE (ttr) == POINTER_TYPE)
  569.     return comp_target_types (ttl, ttr);
  570.       else
  571.     return comptypes (ttl, ttr);
  572.     }
  573. #endif
  574.  
  575.   val = comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)),
  576.            TYPE_MAIN_VARIANT (TREE_TYPE (ttr)));
  577.  
  578.   if (val == 2 && pedantic)
  579.     pedwarn ("types are not quite compatible");
  580.   return val;
  581. }
  582.  
  583. /* Subroutines of `comptypes'.  */
  584.  
  585. /* Return 1 if two function types F1 and F2 are compatible.
  586.    If either type specifies no argument types,
  587.    the other must specify a fixed number of self-promoting arg types.
  588.    Otherwise, if one type specifies only the number of arguments, 
  589.    the other must specify that number of self-promoting arg types.
  590.    Otherwise, the argument types must match.  */
  591.  
  592. static int
  593. function_types_compatible_p (f1, f2)
  594.      tree f1, f2;
  595. {
  596.   tree args1, args2;
  597.   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
  598.   int val = 1;
  599.   int val1;
  600.  
  601.   if (!(TREE_TYPE (f1) == TREE_TYPE (f2)
  602.     || (val = comptypes (TREE_TYPE (f1), TREE_TYPE (f2)))))
  603.     return 0;
  604.  
  605.   args1 = TYPE_ARG_TYPES (f1);
  606.   args2 = TYPE_ARG_TYPES (f2);
  607.  
  608.   /* An unspecified parmlist matches any specified parmlist
  609.      whose argument types don't need default promotions.  */
  610.  
  611.   if (args1 == 0)
  612.     {
  613.       if (!self_promoting_args_p (args2))
  614.     return 0;
  615.       /* If one of these types comes from a non-prototype fn definition,
  616.      compare that with the other type's arglist.
  617.      If they don't match, ask for a warning (but no error).  */
  618.       if (TYPE_ACTUAL_ARG_TYPES (f1)
  619.       && 1 != type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1)))
  620.     val = 2;
  621.       return val;
  622.     }
  623.   if (args2 == 0)
  624.     {
  625.       if (!self_promoting_args_p (args1))
  626.     return 0;
  627.       if (TYPE_ACTUAL_ARG_TYPES (f2)
  628.       && 1 != type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2)))
  629.     val = 2;
  630.       return val;
  631.     }
  632.  
  633.   /* Both types have argument lists: compare them and propagate results.  */
  634.   val1 = type_lists_compatible_p (args1, args2);
  635.   return val1 != 1 ? val1 : val;
  636. }
  637.  
  638. /* Check two lists of types for compatibility,
  639.    returning 0 for incompatible, 1 for compatible,
  640.    or 2 for compatible with warning.  */
  641.  
  642. static int
  643. type_lists_compatible_p (args1, args2)
  644.      tree args1, args2;
  645. {
  646.   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
  647.   int val = 1;
  648.   int newval = 0;
  649.  
  650.   while (1)
  651.     {
  652.       if (args1 == 0 && args2 == 0)
  653.     return val;
  654.       /* If one list is shorter than the other,
  655.      they fail to match.  */
  656.       if (args1 == 0 || args2 == 0)
  657.     return 0;
  658.       /* A null pointer instead of a type
  659.      means there is supposed to be an argument
  660.      but nothing is specified about what type it has.
  661.      So match anything that self-promotes.  */
  662.       if (TREE_VALUE (args1) == 0)
  663.     {
  664.       if (! self_promoting_type_p (TREE_VALUE (args2)))
  665.         return 0;
  666.     }
  667.       else if (TREE_VALUE (args2) == 0)
  668.     {
  669.       if (! self_promoting_type_p (TREE_VALUE (args1)))
  670.         return 0;
  671.     }
  672.       else if (! (newval = comptypes (TREE_VALUE (args1), TREE_VALUE (args2))))
  673.     {
  674.       /* Allow  wait (union {union wait *u; int *i} *)
  675.          and  wait (union wait *)  to be compatible.  */
  676.       if (TREE_CODE (TREE_VALUE (args1)) == UNION_TYPE
  677.           && (TYPE_NAME (TREE_VALUE (args1)) == 0
  678.           || TYPE_TRANSPARENT_UNION (TREE_VALUE (args1)))
  679.           && TREE_CODE (TYPE_SIZE (TREE_VALUE (args1))) == INTEGER_CST
  680.           && tree_int_cst_equal (TYPE_SIZE (TREE_VALUE (args1)),
  681.                      TYPE_SIZE (TREE_VALUE (args2))))
  682.         {
  683.           tree memb;
  684.           for (memb = TYPE_FIELDS (TREE_VALUE (args1));
  685.            memb; memb = TREE_CHAIN (memb))
  686.         if (comptypes (TREE_TYPE (memb), TREE_VALUE (args2)))
  687.           break;
  688.           if (memb == 0)
  689.         return 0;
  690.         }
  691.       else if (TREE_CODE (TREE_VALUE (args2)) == UNION_TYPE
  692.            && (TYPE_NAME (TREE_VALUE (args2)) == 0
  693.                || TYPE_TRANSPARENT_UNION (TREE_VALUE (args2)))
  694.            && TREE_CODE (TYPE_SIZE (TREE_VALUE (args2))) == INTEGER_CST
  695.            && tree_int_cst_equal (TYPE_SIZE (TREE_VALUE (args2)),
  696.                       TYPE_SIZE (TREE_VALUE (args1))))
  697.         {
  698.           tree memb;
  699.           for (memb = TYPE_FIELDS (TREE_VALUE (args2));
  700.            memb; memb = TREE_CHAIN (memb))
  701.         if (comptypes (TREE_TYPE (memb), TREE_VALUE (args1)))
  702.           break;
  703.           if (memb == 0)
  704.         return 0;
  705.         }
  706.       else
  707.         return 0;
  708.     }
  709.  
  710.       /* comptypes said ok, but record if it said to warn.  */
  711.       if (newval > val)
  712.     val = newval;
  713.  
  714.       args1 = TREE_CHAIN (args1);
  715.       args2 = TREE_CHAIN (args2);
  716.     }
  717. }
  718.  
  719. /* Return 1 if PARMS specifies a fixed number of parameters
  720.    and none of their types is affected by default promotions.  */
  721.  
  722. int
  723. self_promoting_args_p (parms)
  724.      tree parms;
  725. {
  726.   register tree t;
  727.   for (t = parms; t; t = TREE_CHAIN (t))
  728.     {
  729.       register tree type = TREE_VALUE (t);
  730.  
  731.       if (TREE_CHAIN (t) == 0 && type != void_type_node)
  732.     return 0;
  733.  
  734.       if (type == 0)
  735.     return 0;
  736.  
  737.       if (TYPE_MAIN_VARIANT (type) == float_type_node)
  738.     return 0;
  739.  
  740.       if (C_PROMOTING_INTEGER_TYPE_P (type))
  741.     return 0;
  742.     }
  743.   return 1;
  744. }
  745.  
  746. /* Return 1 if TYPE is not affected by default promotions.  */
  747.  
  748. static int
  749. self_promoting_type_p (type)
  750.      tree type;
  751. {
  752.   if (TYPE_MAIN_VARIANT (type) == float_type_node)
  753.     return 0;
  754.  
  755.   if (C_PROMOTING_INTEGER_TYPE_P (type))
  756.     return 0;
  757.  
  758.   return 1;
  759. }
  760.  
  761. /* Return an unsigned type the same as TYPE in other respects.  */
  762.  
  763. tree
  764. unsigned_type (type)
  765.      tree type;
  766. {
  767.   tree type1 = TYPE_MAIN_VARIANT (type);
  768.   if (type1 == signed_char_type_node || type1 == char_type_node)
  769.     return unsigned_char_type_node;
  770.   if (type1 == integer_type_node)
  771.     return unsigned_type_node;
  772.   if (type1 == short_integer_type_node)
  773.     return short_unsigned_type_node;
  774.   if (type1 == long_integer_type_node)
  775.     return long_unsigned_type_node;
  776.   if (type1 == long_long_integer_type_node)
  777.     return long_long_unsigned_type_node;
  778.   if (type1 == intDI_type_node)
  779.     return unsigned_intDI_type_node;
  780.   if (type1 == intSI_type_node)
  781.     return unsigned_intSI_type_node;
  782.   if (type1 == intHI_type_node)
  783.     return unsigned_intHI_type_node;
  784.   if (type1 == intQI_type_node)
  785.     return unsigned_intQI_type_node;
  786.   return type;
  787. }
  788.  
  789. /* Return a signed type the same as TYPE in other respects.  */
  790.  
  791. tree
  792. signed_type (type)
  793.      tree type;
  794. {
  795.   tree type1 = TYPE_MAIN_VARIANT (type);
  796.   if (type1 == unsigned_char_type_node || type1 == char_type_node)
  797.     return signed_char_type_node;
  798.   if (type1 == unsigned_type_node)
  799.     return integer_type_node;
  800.   if (type1 == short_unsigned_type_node)
  801.     return short_integer_type_node;
  802.   if (type1 == long_unsigned_type_node)
  803.     return long_integer_type_node;
  804.   if (type1 == long_long_unsigned_type_node)
  805.     return long_long_integer_type_node;
  806.   if (type1 == unsigned_intDI_type_node)
  807.     return intDI_type_node;
  808.   if (type1 == unsigned_intSI_type_node)
  809.     return intSI_type_node;
  810.   if (type1 == unsigned_intHI_type_node)
  811.     return intHI_type_node;
  812.   if (type1 == unsigned_intQI_type_node)
  813.     return intQI_type_node;
  814.   return type;
  815. }
  816.  
  817. /* Return a type the same as TYPE except unsigned or
  818.    signed according to UNSIGNEDP.  */
  819.  
  820. tree
  821. signed_or_unsigned_type (unsignedp, type)
  822.      int unsignedp;
  823.      tree type;
  824. {
  825.   if (! INTEGRAL_TYPE_P (type))
  826.     return type;
  827.   if (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node))
  828.     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
  829.   if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)) 
  830.     return unsignedp ? unsigned_type_node : integer_type_node;
  831.   if (TYPE_PRECISION (type) == TYPE_PRECISION (short_integer_type_node)) 
  832.     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
  833.   if (TYPE_PRECISION (type) == TYPE_PRECISION (long_integer_type_node)) 
  834.     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
  835.   if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node)) 
  836.     return (unsignedp ? long_long_unsigned_type_node
  837.         : long_long_integer_type_node);
  838.   return type;
  839. }
  840.  
  841. /* Compute the value of the `sizeof' operator.  */
  842.  
  843. tree
  844. c_sizeof (type)
  845.      tree type;
  846. {
  847.   enum tree_code code = TREE_CODE (type);
  848.   tree t;
  849.  
  850.   if (code == FUNCTION_TYPE)
  851.     {
  852.       if (pedantic || warn_pointer_arith)
  853.     pedwarn ("sizeof applied to a function type");
  854.       return size_int (1);
  855.     }
  856.   if (code == VOID_TYPE)
  857.     {
  858.       if (pedantic || warn_pointer_arith)
  859.     pedwarn ("sizeof applied to a void type");
  860.       return size_int (1);
  861.     }
  862.   if (code == ERROR_MARK)
  863.     return size_int (1);
  864.   if (TYPE_SIZE (type) == 0)
  865.     {
  866.       error ("sizeof applied to an incomplete type");
  867.       return size_int (0);
  868.     }
  869.  
  870.   /* Convert in case a char is more than one unit.  */
  871.   t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), 
  872.           size_int (TYPE_PRECISION (char_type_node)));
  873.   /* size_binop does not put the constant in range, so do it now.  */
  874.   if (TREE_CODE (t) == INTEGER_CST && force_fit_type (t, 0))
  875.     TREE_CONSTANT_OVERFLOW (t) = TREE_OVERFLOW (t) = 1;
  876.   return t;
  877. }
  878.  
  879. tree
  880. c_sizeof_nowarn (type)
  881.      tree type;
  882. {
  883.   enum tree_code code = TREE_CODE (type);
  884.   tree t;
  885.  
  886.   if (code == FUNCTION_TYPE
  887.       || code == VOID_TYPE
  888.       || code == ERROR_MARK)
  889.     return size_int (1);
  890.   if (TYPE_SIZE (type) == 0)
  891.     return size_int (0);
  892.  
  893.   /* Convert in case a char is more than one unit.  */
  894.   t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), 
  895.           size_int (TYPE_PRECISION (char_type_node)));
  896.   force_fit_type (t, 0);
  897.   return t;
  898. }
  899.  
  900. /* Compute the size to increment a pointer by.  */
  901.  
  902. tree
  903. c_size_in_bytes (type)
  904.      tree type;
  905. {
  906.   enum tree_code code = TREE_CODE (type);
  907.   tree t;
  908.  
  909.   if (code == FUNCTION_TYPE)
  910.     return size_int (1);
  911.   if (code == VOID_TYPE)
  912.     return size_int (1);
  913.   if (code == ERROR_MARK)
  914.     return size_int (1);
  915.   if (TYPE_SIZE (type) == 0)
  916.     {
  917.       error ("arithmetic on pointer to an incomplete type");
  918.       return size_int (1);
  919.     }
  920.  
  921.   /* Convert in case a char is more than one unit.  */
  922.   t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), 
  923.              size_int (BITS_PER_UNIT));
  924.   force_fit_type (t, 0);
  925.   return t;
  926. }
  927.  
  928. /* Implement the __alignof keyword: Return the minimum required
  929.    alignment of TYPE, measured in bytes.  */
  930.  
  931. tree
  932. c_alignof (type)
  933.      tree type;
  934. {
  935.   enum tree_code code = TREE_CODE (type);
  936.  
  937.   if (code == FUNCTION_TYPE)
  938.     return size_int (FUNCTION_BOUNDARY / BITS_PER_UNIT);
  939.  
  940.   if (code == VOID_TYPE || code == ERROR_MARK)
  941.     return size_int (1);
  942.  
  943.   if (TYPE_SIZE (type) == 0)
  944.     {
  945.       warning ("__alignof applied to an incomplete type");
  946.       return size_int (1);
  947.     }
  948.  
  949.   return size_int (TYPE_ALIGN (type) / BITS_PER_UNIT);
  950. }
  951.  
  952. /* Implement the __alignof keyword: Return the minimum required
  953.    alignment of EXPR, measured in bytes.  For VAR_DECL's and
  954.    FIELD_DECL's return DECL_ALIGN (which can be set from an
  955.    "aligned" __attribute__ specification).  */
  956.  
  957. tree
  958. c_alignof_expr (expr)
  959.      tree expr;
  960. {
  961.   if (TREE_CODE (expr) == VAR_DECL)
  962.     return size_int (DECL_ALIGN (expr) / BITS_PER_UNIT);
  963.  
  964.   if (TREE_CODE (expr) == COMPONENT_REF
  965.       && DECL_BIT_FIELD (TREE_OPERAND (expr, 1)))
  966.     {
  967.       error ("`__alignof' applied to a bit-field");
  968.       return size_int (1);
  969.     }
  970.   else if (TREE_CODE (expr) == COMPONENT_REF
  971.       && TREE_CODE (TREE_OPERAND (expr, 1)) == FIELD_DECL)
  972.     return size_int (DECL_ALIGN (TREE_OPERAND (expr, 1)) / BITS_PER_UNIT);
  973.  
  974.   if (TREE_CODE (expr) == INDIRECT_REF)
  975.     {
  976.       tree t = TREE_OPERAND (expr, 0);
  977.       tree best = t;
  978.       int bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
  979.  
  980.       while (TREE_CODE (t) == NOP_EXPR
  981.           && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE)
  982.     {
  983.       int thisalign;
  984.  
  985.       t = TREE_OPERAND (t, 0);
  986.       thisalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
  987.       if (thisalign > bestalign)
  988.         best = t, bestalign = thisalign;
  989.     }
  990.       return c_alignof (TREE_TYPE (TREE_TYPE (best)));
  991.     }
  992.   else
  993.     return c_alignof (TREE_TYPE (expr));
  994. }
  995. /* Return either DECL or its known constant value (if it has one).  */
  996.  
  997. static tree
  998. decl_constant_value (decl)
  999.      tree decl;
  1000. {
  1001.   if (! TREE_PUBLIC (decl)
  1002.       /* Don't change a variable array bound or initial value to a constant
  1003.      in a place where a variable is invalid.  */
  1004.       && current_function_decl != 0
  1005.       && ! pedantic
  1006.       && ! TREE_THIS_VOLATILE (decl)
  1007.       && TREE_READONLY (decl) && ! ITERATOR_P (decl)
  1008.       && DECL_INITIAL (decl) != 0
  1009.       && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
  1010.       /* This is invalid if initial value is not constant.
  1011.      If it has either a function call, a memory reference,
  1012.      or a variable, then re-evaluating it could give different results.  */
  1013.       && TREE_CONSTANT (DECL_INITIAL (decl))
  1014.       /* Check for cases where this is sub-optimal, even though valid.  */
  1015.       && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR
  1016.       && DECL_MODE (decl) != BLKmode)
  1017.     return DECL_INITIAL (decl);
  1018.   return decl;
  1019. }
  1020.  
  1021. /* Perform default promotions for C data used in expressions.
  1022.    Arrays and functions are converted to pointers;
  1023.    enumeral types or short or char, to int.
  1024.    In addition, manifest constants symbols are replaced by their values.  */
  1025.  
  1026. tree
  1027. default_conversion (exp)
  1028.      tree exp;
  1029. {
  1030.   register tree type = TREE_TYPE (exp);
  1031.   register enum tree_code code = TREE_CODE (type);
  1032.  
  1033.   /* Constants can be used directly unless they're not loadable.  */
  1034.   if (TREE_CODE (exp) == CONST_DECL)
  1035.     exp = DECL_INITIAL (exp);
  1036.  
  1037.   /* Replace a nonvolatile const static variable with its value unless
  1038.      it is an array, in which case we must be sure that taking the
  1039.      address of the array produces consistent results.  */
  1040.   else if (optimize && TREE_CODE (exp) == VAR_DECL && code != ARRAY_TYPE)
  1041.     {
  1042.       exp = decl_constant_value (exp);
  1043.       type = TREE_TYPE (exp);
  1044.     }
  1045.  
  1046.   /* Strip NON_LVALUE_EXPRs and no-op conversions, since we aren't using as
  1047.      an lvalue.  */
  1048.   /* Do not use STRIP_NOPS here!  It will remove conversions from pointer
  1049.      to integer and cause infinite recursion.  */
  1050.   while (TREE_CODE (exp) == NON_LVALUE_EXPR
  1051.      || (TREE_CODE (exp) == NOP_EXPR
  1052.          && TREE_TYPE (TREE_OPERAND (exp, 0)) == TREE_TYPE (exp)))
  1053.     exp = TREE_OPERAND (exp, 0);
  1054.  
  1055.   /* Normally convert enums to int,
  1056.      but convert wide enums to something wider.  */
  1057.   if (code == ENUMERAL_TYPE)
  1058.     {
  1059.       type = type_for_size (MAX (TYPE_PRECISION (type),
  1060.                  TYPE_PRECISION (integer_type_node)),
  1061.                 ((flag_traditional
  1062.                   || TYPE_PRECISION (type) >= TYPE_PRECISION (integer_type_node))
  1063.                  && TREE_UNSIGNED (type)));
  1064.       return convert (type, exp);
  1065.     }
  1066.  
  1067.   if (C_PROMOTING_INTEGER_TYPE_P (type))
  1068.     {
  1069.       /* Traditionally, unsignedness is preserved in default promotions.
  1070.          Also preserve unsignedness if not really getting any wider.  */
  1071.       if (TREE_UNSIGNED (type)
  1072.       && (flag_traditional
  1073.           || TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
  1074.     return convert (unsigned_type_node, exp);
  1075.       return convert (integer_type_node, exp);
  1076.     }
  1077.   if (flag_traditional && !flag_allow_single_precision
  1078.       && TYPE_MAIN_VARIANT (type) == float_type_node)
  1079.     return convert (double_type_node, exp);
  1080.   if (code == VOID_TYPE)
  1081.     {
  1082.       error ("void value not ignored as it ought to be");
  1083.       return error_mark_node;
  1084.     }
  1085.   if (code == FUNCTION_TYPE)
  1086.     {
  1087.       return build_unary_op (ADDR_EXPR, exp, 0);
  1088.     }
  1089.   if (code == ARRAY_TYPE)
  1090.     {
  1091.       register tree adr;
  1092.       tree restype = TREE_TYPE (type);
  1093.       tree ptrtype;
  1094.       int constp = 0;
  1095.       int volatilep = 0;
  1096.  
  1097.       if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'r'
  1098.       || TREE_CODE_CLASS (TREE_CODE (exp)) == 'd')
  1099.     {
  1100.       constp = TREE_READONLY (exp);
  1101.       volatilep = TREE_THIS_VOLATILE (exp);
  1102.     }
  1103.  
  1104.       if (TYPE_READONLY (type) || TYPE_VOLATILE (type)
  1105.       || constp || volatilep)
  1106.     restype = c_build_type_variant (restype,
  1107.                     TYPE_READONLY (type) || constp,
  1108.                     TYPE_VOLATILE (type) || volatilep);
  1109.  
  1110.       if (TREE_CODE (exp) == INDIRECT_REF)
  1111.     return convert (TYPE_POINTER_TO (restype),
  1112.             TREE_OPERAND (exp, 0));
  1113.  
  1114.       if (TREE_CODE (exp) == COMPOUND_EXPR)
  1115.     {
  1116.       tree op1 = default_conversion (TREE_OPERAND (exp, 1));
  1117.       return build (COMPOUND_EXPR, TREE_TYPE (op1),
  1118.             TREE_OPERAND (exp, 0), op1);
  1119.     }
  1120.  
  1121.       if (!lvalue_p (exp)
  1122.       && ! (TREE_CODE (exp) == CONSTRUCTOR && TREE_STATIC (exp)))
  1123.     {
  1124.       error ("invalid use of non-lvalue array");
  1125.       return error_mark_node;
  1126.     }
  1127.  
  1128.       ptrtype = build_pointer_type (restype);
  1129.  
  1130.       if (TREE_CODE (exp) == VAR_DECL)
  1131.     {
  1132.       /* ??? This is not really quite correct
  1133.          in that the type of the operand of ADDR_EXPR
  1134.          is not the target type of the type of the ADDR_EXPR itself.
  1135.          Question is, can this lossage be avoided?  */
  1136.       adr = build1 (ADDR_EXPR, ptrtype, exp);
  1137.       if (mark_addressable (exp) == 0)
  1138.         return error_mark_node;
  1139.       TREE_CONSTANT (adr) = staticp (exp);
  1140.       TREE_SIDE_EFFECTS (adr) = 0;   /* Default would be, same as EXP.  */
  1141.       return adr;
  1142.     }
  1143.       /* This way is better for a COMPONENT_REF since it can
  1144.      simplify the offset for a component.  */
  1145.       adr = build_unary_op (ADDR_EXPR, exp, 1);
  1146.       return convert (ptrtype, adr);
  1147.     }
  1148.  
  1149.   return exp;
  1150. }
  1151.  
  1152. /* Look up component name in the structure type definition.
  1153.  
  1154.    If this component name is found indirectly within an anonymous union,
  1155.    store in *INDIRECT the component which directly contains
  1156.    that anonymous union.  Otherwise, set *INDIRECT to 0.  */
  1157.      
  1158. static tree
  1159. lookup_field (type, component, indirect)
  1160.      tree type, component;
  1161.      tree *indirect;
  1162. {
  1163.   tree field;
  1164.  
  1165.   /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
  1166.      to the field elements.  Use a binary search on this array to quickly
  1167.      find the element.  Otherwise, do a linear search.  TYPE_LANG_SPECIFIC
  1168.      will always be set for structures which have many elements.  */
  1169.  
  1170.   if (TYPE_LANG_SPECIFIC (type))
  1171.     {
  1172.       int bot, top, half;
  1173.       tree *field_array = &TYPE_LANG_SPECIFIC (type)->elts[0];
  1174.  
  1175.       field = TYPE_FIELDS (type);
  1176.       bot = 0;
  1177.       top = TYPE_LANG_SPECIFIC (type)->len;
  1178.       while (top - bot > 1)
  1179.     {
  1180.       half = (top - bot + 1) >> 1;
  1181.       field = field_array[bot+half];
  1182.  
  1183.       if (DECL_NAME (field) == NULL_TREE)
  1184.         {
  1185.           /* Step through all anon unions in linear fashion.  */
  1186.           while (DECL_NAME (field_array[bot]) == NULL_TREE)
  1187.         {
  1188.           tree anon, junk;
  1189.  
  1190.           field = field_array[bot++];
  1191.           anon = lookup_field (TREE_TYPE (field), component, &junk);
  1192.           if (anon != NULL_TREE)
  1193.             {
  1194.               *indirect = field;
  1195.               return anon;
  1196.             }
  1197.         }
  1198.  
  1199.           /* Entire record is only anon unions.  */
  1200.           if (bot > top)
  1201.         return NULL_TREE;
  1202.  
  1203.           /* Restart the binary search, with new lower bound.  */
  1204.           continue;
  1205.         }
  1206.  
  1207.       if (DECL_NAME (field) == component)
  1208.         break;
  1209.       if (DECL_NAME (field) < component)
  1210.         bot += half;
  1211.       else
  1212.         top = bot + half;
  1213.     }
  1214.  
  1215.       if (DECL_NAME (field_array[bot]) == component)
  1216.     field = field_array[bot];
  1217.       else if (DECL_NAME (field) != component)
  1218.     field = 0;
  1219.     }
  1220.   else
  1221.     {
  1222.       for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
  1223.     {
  1224.       if (DECL_NAME (field) == NULL_TREE)
  1225.         {
  1226.           tree junk;
  1227.           tree anon = lookup_field (TREE_TYPE (field), component, &junk);
  1228.           if (anon != NULL_TREE)
  1229.         {
  1230.           *indirect = field;
  1231.           return anon;
  1232.         }
  1233.         }
  1234.  
  1235.       if (DECL_NAME (field) == component)
  1236.         break;
  1237.     }
  1238.     }
  1239.  
  1240.   *indirect = NULL_TREE;
  1241.   return field;
  1242. }
  1243.  
  1244. /* Make an expression to refer to the COMPONENT field of
  1245.    structure or union value DATUM.  COMPONENT is an IDENTIFIER_NODE.  */
  1246.  
  1247. tree
  1248. build_component_ref (datum, component)
  1249.      tree datum, component;
  1250. {
  1251.   register tree type = TREE_TYPE (datum);
  1252.   register enum tree_code code = TREE_CODE (type);
  1253.   register tree field = NULL;
  1254.   register tree ref;
  1255.  
  1256.   /* If DATUM is a COMPOUND_EXPR or COND_EXPR, move our reference inside it
  1257.      unless we are not to support things not strictly ANSI.  */
  1258.   switch (TREE_CODE (datum))
  1259.     {
  1260.     case COMPOUND_EXPR:
  1261.       {
  1262.     tree value = build_component_ref (TREE_OPERAND (datum, 1), component);
  1263.     return build (COMPOUND_EXPR, TREE_TYPE (value),
  1264.               TREE_OPERAND (datum, 0), value);
  1265.       }
  1266.     case COND_EXPR:
  1267.       return build_conditional_expr
  1268.     (TREE_OPERAND (datum, 0),
  1269.      build_component_ref (TREE_OPERAND (datum, 1), component),
  1270.      build_component_ref (TREE_OPERAND (datum, 2), component));
  1271.     }
  1272.  
  1273.   /* See if there is a field or component with name COMPONENT.  */
  1274.  
  1275.   if (code == RECORD_TYPE || code == UNION_TYPE)
  1276.     {
  1277.       tree indirect = 0;
  1278.  
  1279.       if (TYPE_SIZE (type) == 0)
  1280.     {
  1281.       incomplete_type_error (NULL_TREE, type);
  1282.       return error_mark_node;
  1283.     }
  1284.  
  1285.       field = lookup_field (type, component, &indirect);
  1286.  
  1287.       if (!field)
  1288.     {
  1289.       error (code == RECORD_TYPE
  1290.          ? "structure has no member named `%s'"
  1291.          : "union has no member named `%s'",
  1292.          IDENTIFIER_POINTER (component));
  1293.       return error_mark_node;
  1294.     }
  1295.       if (TREE_TYPE (field) == error_mark_node)
  1296.     return error_mark_node;
  1297.  
  1298.       /* If FIELD was found buried within an anonymous union,
  1299.      make one COMPONENT_REF to get that anonymous union,
  1300.      then fall thru to make a second COMPONENT_REF to get FIELD.  */
  1301.       if (indirect != 0)
  1302.     {
  1303.       ref = build (COMPONENT_REF, TREE_TYPE (indirect), datum, indirect);
  1304.       if (TREE_READONLY (datum) || TREE_READONLY (indirect))
  1305.         TREE_READONLY (ref) = 1;
  1306.       if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (indirect))
  1307.         TREE_THIS_VOLATILE (ref) = 1;
  1308.       datum = ref;
  1309.     }
  1310.  
  1311.       ref = build (COMPONENT_REF, TREE_TYPE (field), datum, field);
  1312.  
  1313.       if (TREE_READONLY (datum) || TREE_READONLY (field))
  1314.     TREE_READONLY (ref) = 1;
  1315.       if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (field))
  1316.     TREE_THIS_VOLATILE (ref) = 1;
  1317.  
  1318.       return ref;
  1319.     }
  1320.   else if (code != ERROR_MARK)
  1321.     error ("request for member `%s' in something not a structure or union",
  1322.         IDENTIFIER_POINTER (component));
  1323.  
  1324.   return error_mark_node;
  1325. }
  1326.  
  1327. /* Given an expression PTR for a pointer, return an expression
  1328.    for the value pointed to.
  1329.    ERRORSTRING is the name of the operator to appear in error messages.  */
  1330.  
  1331. tree
  1332. build_indirect_ref (ptr, errorstring)
  1333.      tree ptr;
  1334.      char *errorstring;
  1335. {
  1336.   register tree pointer = default_conversion (ptr);
  1337.   register tree type = TREE_TYPE (pointer);
  1338.  
  1339.   if (TREE_CODE (type) == POINTER_TYPE)
  1340.     {
  1341.       if (TREE_CODE (pointer) == ADDR_EXPR
  1342.       && !flag_volatile
  1343.       && (TREE_TYPE (TREE_OPERAND (pointer, 0))
  1344.           == TREE_TYPE (type)))
  1345.     return TREE_OPERAND (pointer, 0);
  1346.       else
  1347.     {
  1348.       tree t = TREE_TYPE (type);
  1349.       register tree ref = build1 (INDIRECT_REF,
  1350.                       TYPE_MAIN_VARIANT (t), pointer);
  1351.  
  1352.       if (TYPE_SIZE (t) == 0 && TREE_CODE (t) != ARRAY_TYPE)
  1353.         {
  1354. #ifdef NeXT
  1355.           require_complete_type (type);
  1356. #endif
  1357.  
  1358.           error ("dereferencing pointer to incomplete type");
  1359.           return error_mark_node;
  1360.         }
  1361.       if (TREE_CODE (t) == VOID_TYPE)
  1362.         warning ("dereferencing `void *' pointer");
  1363.  
  1364.       /* We *must* set TREE_READONLY when dereferencing a pointer to const,
  1365.          so that we get the proper error message if the result is used
  1366.          to assign to.  Also, &* is supposed to be a no-op.
  1367.          And ANSI C seems to specify that the type of the result
  1368.          should be the const type.  */
  1369.       /* A de-reference of a pointer to const is not a const.  It is valid
  1370.          to change it via some other pointer.  */
  1371.       TREE_READONLY (ref) = TYPE_READONLY (t);
  1372.       TREE_SIDE_EFFECTS (ref)
  1373.         = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer) || flag_volatile;
  1374.       TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
  1375.       return ref;
  1376.     }
  1377.     }
  1378.   else if (TREE_CODE (pointer) != ERROR_MARK)
  1379.     error ("invalid type argument of `%s'", errorstring);
  1380.   return error_mark_node;
  1381. }
  1382.  
  1383. /* This handles expressions of the form "a[i]", which denotes
  1384.    an array reference.
  1385.  
  1386.    This is logically equivalent in C to *(a+i), but we may do it differently.
  1387.    If A is a variable or a member, we generate a primitive ARRAY_REF.
  1388.    This avoids forcing the array out of registers, and can work on
  1389.    arrays that are not lvalues (for example, members of structures returned
  1390.    by functions).  */
  1391.  
  1392. tree
  1393. build_array_ref (array, index)
  1394.      tree array, index;
  1395. {
  1396.   if (index == 0)
  1397.     {
  1398.       error ("subscript missing in array reference");
  1399.       return error_mark_node;
  1400.     }
  1401.  
  1402.   if (TREE_TYPE (array) == error_mark_node
  1403.       || TREE_TYPE (index) == error_mark_node)
  1404.     return error_mark_node;
  1405.  
  1406.   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE
  1407.       && TREE_CODE (array) != INDIRECT_REF)
  1408.     {
  1409.       tree rval, type;
  1410.  
  1411.       /* Subscripting with type char is likely to lose
  1412.      on a machine where chars are signed.
  1413.      So warn on any machine, but optionally.
  1414.      Don't warn for unsigned char since that type is safe.
  1415.      Don't warn for signed char because anyone who uses that
  1416.      must have done so deliberately.  */
  1417.       if (warn_char_subscripts
  1418.       && TYPE_MAIN_VARIANT (TREE_TYPE (index)) == char_type_node)
  1419.     warning ("array subscript has type `char'");
  1420.  
  1421.       /* Apply default promotions *after* noticing character types.  */
  1422.       index = default_conversion (index);
  1423.  
  1424.       /* Require integer *after* promotion, for sake of enums.  */
  1425.       if (TREE_CODE (TREE_TYPE (index)) != INTEGER_TYPE)
  1426.     {
  1427.       error ("array subscript is not an integer");
  1428.       return error_mark_node;
  1429.     }
  1430.  
  1431.       /* An array that is indexed by a non-constant
  1432.      cannot be stored in a register; we must be able to do
  1433.      address arithmetic on its address.
  1434.      Likewise an array of elements of variable size.  */
  1435.       if (TREE_CODE (index) != INTEGER_CST
  1436.       || (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))) != 0
  1437.           && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
  1438.     {
  1439.       if (mark_addressable (array) == 0)
  1440.         return error_mark_node;
  1441.     }
  1442.       /* An array that is indexed by a constant value which is not within
  1443.      the array bounds cannot be stored in a register either; because we
  1444.      would get a crash in store_bit_field/extract_bit_field when trying
  1445.      to access a non-existent part of the register.  */
  1446.       if (TREE_CODE (index) == INTEGER_CST
  1447.       && TYPE_VALUES (TREE_TYPE (array))
  1448.       && ! int_fits_type_p (index, TYPE_VALUES (TREE_TYPE (array))))
  1449.     {
  1450.       if (mark_addressable (array) == 0)
  1451.         return error_mark_node;
  1452.     }
  1453.  
  1454.       if (pedantic && !lvalue_p (array))
  1455.     {
  1456.       if (DECL_REGISTER (array))
  1457.         pedwarn ("ANSI C forbids subscripting `register' array");
  1458.       else
  1459.         pedwarn ("ANSI C forbids subscripting non-lvalue array");
  1460.     }
  1461.  
  1462.       if (pedantic)
  1463.     {
  1464.       tree foo = array;
  1465.       while (TREE_CODE (foo) == COMPONENT_REF)
  1466.         foo = TREE_OPERAND (foo, 0);
  1467.       if (TREE_CODE (foo) == VAR_DECL && DECL_REGISTER (foo))
  1468.         pedwarn ("ANSI C forbids subscripting non-lvalue array");
  1469.     }
  1470.  
  1471.       type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (array)));
  1472.       rval = build (ARRAY_REF, type, array, index);
  1473.       /* Array ref is const/volatile if the array elements are
  1474.          or if the array is.  */
  1475.       TREE_READONLY (rval)
  1476.     |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
  1477.         | TREE_READONLY (array));
  1478.       TREE_SIDE_EFFECTS (rval)
  1479.     |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
  1480.         | TREE_SIDE_EFFECTS (array));
  1481.       TREE_THIS_VOLATILE (rval)
  1482.     |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
  1483.         /* This was added by rms on 16 Nov 91.
  1484.            It fixes  vol struct foo *a;  a->elts[1] 
  1485.            in an inline function.
  1486.            Hope it doesn't break something else.  */
  1487.         | TREE_THIS_VOLATILE (array));
  1488.       return require_complete_type (fold (rval));
  1489.     }
  1490.  
  1491.   {
  1492.     tree ar = default_conversion (array);
  1493.     tree ind = default_conversion (index);
  1494.  
  1495.     /* Put the integer in IND to simplify error checking.  */
  1496.     if (TREE_CODE (TREE_TYPE (ar)) == INTEGER_TYPE)
  1497.       {
  1498.     tree temp = ar;
  1499.     ar = ind;
  1500.     ind = temp;
  1501.       }
  1502.  
  1503.     if (ar == error_mark_node)
  1504.       return ar;
  1505.  
  1506.     if (TREE_CODE (TREE_TYPE (ar)) != POINTER_TYPE)
  1507.       {
  1508.     error ("subscripted value is neither array nor pointer");
  1509.     return error_mark_node;
  1510.       }
  1511.     if (TREE_CODE (TREE_TYPE (ind)) != INTEGER_TYPE)
  1512.       {
  1513.     error ("array subscript is not an integer");
  1514.     return error_mark_node;
  1515.       }
  1516.  
  1517.     return build_indirect_ref (build_binary_op (PLUS_EXPR, ar, ind, 0),
  1518.                    "array indexing");
  1519.   }
  1520. }
  1521.  
  1522. /* Build a function call to function FUNCTION with parameters PARAMS.
  1523.    PARAMS is a list--a chain of TREE_LIST nodes--in which the
  1524.    TREE_VALUE of each node is a parameter-expression.
  1525.    FUNCTION's data type may be a function type or a pointer-to-function.  */
  1526.  
  1527. tree
  1528. build_function_call (function, params)
  1529.      tree function, params;
  1530. {
  1531.   register tree fntype, fundecl = 0;
  1532.   register tree coerced_params;
  1533.   tree name = NULL_TREE, assembler_name = NULL_TREE;
  1534.  
  1535.   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
  1536.   STRIP_TYPE_NOPS (function);
  1537.  
  1538.   /* Convert anything with function type to a pointer-to-function.  */
  1539.   if (TREE_CODE (function) == FUNCTION_DECL)
  1540.     {
  1541.       name = DECL_NAME (function);
  1542.       assembler_name = DECL_ASSEMBLER_NAME (function);
  1543.  
  1544.       /* Differs from default_conversion by not setting TREE_ADDRESSABLE
  1545.      (because calling an inline function does not mean the function
  1546.      needs to be separately compiled).  */
  1547.       fntype = build_type_variant (TREE_TYPE (function),
  1548.                    TREE_READONLY (function),
  1549.                    TREE_THIS_VOLATILE (function));
  1550.       fundecl = function;
  1551.       function = build1 (ADDR_EXPR, build_pointer_type (fntype), function);
  1552.     }
  1553.   else
  1554.     function = default_conversion (function);
  1555.  
  1556.   fntype = TREE_TYPE (function);
  1557.  
  1558.   if (TREE_CODE (fntype) == ERROR_MARK)
  1559.     return error_mark_node;
  1560.  
  1561.   if (!(TREE_CODE (fntype) == POINTER_TYPE
  1562.     && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
  1563.     {
  1564.       error ("called object is not a function");
  1565.       return error_mark_node;
  1566.     }
  1567.  
  1568.   /* fntype now gets the type of function pointed to.  */
  1569.   fntype = TREE_TYPE (fntype);
  1570.  
  1571.   /* Convert the parameters to the types declared in the
  1572.      function prototype, or apply default promotions.  */
  1573.  
  1574.   coerced_params
  1575.     = convert_arguments (TYPE_ARG_TYPES (fntype), params, name, fundecl);
  1576.  
  1577.   /* Check for errors in format strings.  */
  1578.  
  1579.   if (warn_format && (name || assembler_name))
  1580.     check_function_format (name, assembler_name, coerced_params);
  1581.  
  1582.   /* Recognize certain built-in functions so we can make tree-codes
  1583.      other than CALL_EXPR.  We do this when it enables fold-const.c
  1584.      to do something useful.  */
  1585.  
  1586.   if (TREE_CODE (function) == ADDR_EXPR
  1587.       && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL
  1588.       && DECL_BUILT_IN (TREE_OPERAND (function, 0)))
  1589.     switch (DECL_FUNCTION_CODE (TREE_OPERAND (function, 0)))
  1590.       {
  1591.       case BUILT_IN_ABS:
  1592.       case BUILT_IN_LABS:
  1593.       case BUILT_IN_FABS:
  1594.     if (coerced_params == 0)
  1595.       return integer_zero_node;
  1596.     return build_unary_op (ABS_EXPR, TREE_VALUE (coerced_params), 0);
  1597.       }
  1598.  
  1599.   {
  1600.     register tree result
  1601.       = build (CALL_EXPR, TREE_TYPE (fntype),
  1602.            function, coerced_params, NULL_TREE);
  1603.  
  1604.     TREE_SIDE_EFFECTS (result) = 1;
  1605.     if (TREE_TYPE (result) == void_type_node)
  1606.       return result;
  1607.     return require_complete_type (result);
  1608.   }
  1609. }
  1610.  
  1611. /* Convert the argument expressions in the list VALUES
  1612.    to the types in the list TYPELIST.  The result is a list of converted
  1613.    argument expressions.
  1614.  
  1615.    If TYPELIST is exhausted, or when an element has NULL as its type,
  1616.    perform the default conversions.
  1617.  
  1618.    PARMLIST is the chain of parm decls for the function being called.
  1619.    It may be 0, if that info is not available.
  1620.    It is used only for generating error messages.
  1621.  
  1622.    NAME is an IDENTIFIER_NODE or 0.  It is used only for error messages.
  1623.  
  1624.    This is also where warnings about wrong number of args are generated.
  1625.  
  1626.    Both VALUES and the returned value are chains of TREE_LIST nodes
  1627.    with the elements of the list in the TREE_VALUE slots of those nodes.  */
  1628.  
  1629. static tree
  1630. convert_arguments (typelist, values, name, fundecl)
  1631.      tree typelist, values, name, fundecl;
  1632. {
  1633.   register tree typetail, valtail;
  1634.   register tree result = NULL;
  1635.   int parmnum;
  1636.  
  1637.   /* Scan the given expressions and types, producing individual
  1638.      converted arguments and pushing them on RESULT in reverse order.  */
  1639.  
  1640.   for (valtail = values, typetail = typelist, parmnum = 0;
  1641.        valtail;
  1642.        valtail = TREE_CHAIN (valtail), parmnum++)
  1643.     {
  1644.       register tree type = typetail ? TREE_VALUE (typetail) : 0;
  1645.       register tree val = TREE_VALUE (valtail);
  1646.  
  1647.       if (type == void_type_node)
  1648.     {
  1649.       if (name)
  1650.         error ("too many arguments to function `%s'",
  1651.            IDENTIFIER_POINTER (name));
  1652.       else
  1653.         error ("too many arguments to function");
  1654.       break;
  1655.     }
  1656.  
  1657.       /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
  1658.       /* Do not use STRIP_NOPS here!  We do not want an enumerator with value 0
  1659.      to convert automatically to a pointer.  */
  1660.       if (TREE_CODE (val) == NON_LVALUE_EXPR)
  1661.     val = TREE_OPERAND (val, 0);
  1662.  
  1663.       if (TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE
  1664.       || TREE_CODE (TREE_TYPE (val)) == FUNCTION_TYPE)
  1665.     val = default_conversion (val);
  1666.  
  1667.       val = require_complete_type (val);
  1668.  
  1669.       if (type != 0)
  1670.     {
  1671.       /* Formal parm type is specified by a function prototype.  */
  1672.       tree parmval;
  1673.  
  1674.       if (TYPE_SIZE (type) == 0)
  1675.         {
  1676.           error ("type of formal parameter %d is incomplete", parmnum + 1);
  1677.           parmval = val;
  1678.         }
  1679.       else
  1680.         {
  1681.           /* Optionally warn about conversions that
  1682.          differ from the default conversions.  */
  1683.           if (warn_conversion)
  1684.         {
  1685.           int formal_prec = TYPE_PRECISION (type);
  1686.  
  1687.           if (INTEGRAL_TYPE_P (type)
  1688.               && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
  1689.             warn_for_assignment ("%s as integer rather than floating due to prototype", (char *) 0, name, parmnum + 1);
  1690.           else if (TREE_CODE (type) == COMPLEX_TYPE
  1691.                && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
  1692.             warn_for_assignment ("%s as complex rather than floating due to prototype", (char *) 0, name, parmnum + 1);
  1693.           else if (TREE_CODE (type) == REAL_TYPE
  1694.                && INTEGRAL_TYPE_P (TREE_TYPE (val)))
  1695.             warn_for_assignment ("%s as floating rather than integer due to prototype", (char *) 0, name, parmnum + 1);
  1696.           else if (TREE_CODE (type) == REAL_TYPE
  1697.                && TREE_CODE (TREE_TYPE (val)) == COMPLEX_TYPE)
  1698.             warn_for_assignment ("%s as floating rather than complex due to prototype", (char *) 0, name, parmnum + 1);
  1699.           /* ??? At some point, messages should be written about
  1700.              conversions between complex types, but that's too messy
  1701.              to do now.  */
  1702.           else if (TREE_CODE (type) == REAL_TYPE
  1703.                && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
  1704.             {
  1705.               /* Warn if any argument is passed as `float',
  1706.              since without a prototype it would be `double'.  */
  1707.               if (formal_prec == TYPE_PRECISION (float_type_node))
  1708.             warn_for_assignment ("%s as `float' rather than `double' due to prototype", (char *) 0, name, parmnum + 1);
  1709.             }
  1710.           /* Detect integer changing in width or signedness.  */
  1711.           else if (INTEGRAL_TYPE_P (type)
  1712.                && INTEGRAL_TYPE_P (TREE_TYPE (val)))
  1713.             {
  1714.               tree would_have_been = default_conversion (val);
  1715.               tree type1 = TREE_TYPE (would_have_been);
  1716.  
  1717.               if (TREE_CODE (type) == ENUMERAL_TYPE
  1718.               && type == TREE_TYPE (val))
  1719.             /* No warning if function asks for enum
  1720.                and the actual arg is that enum type.  */
  1721.             ;
  1722.               else if (formal_prec != TYPE_PRECISION (type1))
  1723.             warn_for_assignment ("%s with different width due to prototype", (char *) 0, name, parmnum + 1);
  1724.               else if (TREE_UNSIGNED (type) == TREE_UNSIGNED (type1))
  1725.             ;
  1726.               /* Don't complain if the formal parameter type
  1727.              is an enum, because we can't tell now whether
  1728.              the value was an enum--even the same enum.  */
  1729.               else if (TREE_CODE (type) == ENUMERAL_TYPE)
  1730.             ;
  1731.               else if (TREE_CODE (val) == INTEGER_CST
  1732.                    && int_fits_type_p (val, type))
  1733.             /* Change in signedness doesn't matter
  1734.                if a constant value is unaffected.  */
  1735.             ;
  1736.               /* Likewise for a constant in a NOP_EXPR.  */
  1737.               else if (TREE_CODE (val) == NOP_EXPR
  1738.                    && TREE_CODE (TREE_OPERAND (val, 0)) == INTEGER_CST
  1739.                    && int_fits_type_p (TREE_OPERAND (val, 0), type))
  1740.             ;
  1741. #if 0 /* We never get such tree structure here.  */
  1742.               else if (TREE_CODE (TREE_TYPE (val)) == ENUMERAL_TYPE
  1743.                    && int_fits_type_p (TYPE_MIN_VALUE (TREE_TYPE (val)), type)
  1744.                    && int_fits_type_p (TYPE_MAX_VALUE (TREE_TYPE (val)), type))
  1745.             /* Change in signedness doesn't matter
  1746.                if an enum value is unaffected.  */
  1747.             ;
  1748. #endif
  1749.               /* If the value is extended from a narrower
  1750.              unsigned type, it doesn't matter whether we
  1751.              pass it as signed or unsigned; the value
  1752.              certainly is the same either way.  */
  1753.               else if (TYPE_PRECISION (TREE_TYPE (val)) < TYPE_PRECISION (type)
  1754.                    && TREE_UNSIGNED (TREE_TYPE (val)))
  1755.             ;
  1756.               else if (TREE_UNSIGNED (type))
  1757.             warn_for_assignment ("%s as unsigned due to prototype", (char *) 0, name, parmnum + 1);
  1758.               else
  1759.             warn_for_assignment ("%s as signed due to prototype", (char *) 0, name, parmnum + 1);
  1760.             }
  1761.         }
  1762.  
  1763.           parmval = convert_for_assignment (type, val, 
  1764.                             (char *)0, /* arg passing  */
  1765.                         fundecl, name, parmnum + 1);
  1766.           
  1767. #ifdef PROMOTE_PROTOTYPES
  1768.           if ((TREE_CODE (type) == INTEGER_TYPE
  1769.            || TREE_CODE (type) == ENUMERAL_TYPE)
  1770.           && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
  1771.         parmval = default_conversion (parmval);
  1772. #endif
  1773.         }
  1774.       result = tree_cons (NULL_TREE, parmval, result);
  1775.     }
  1776.       else if (TREE_CODE (TREE_TYPE (val)) == REAL_TYPE
  1777.                && (TYPE_PRECISION (TREE_TYPE (val))
  1778.                < TYPE_PRECISION (double_type_node)))
  1779.     /* Convert `float' to `double'.  */
  1780.     result = tree_cons (NULL_TREE, convert (double_type_node, val), result);
  1781.       else
  1782.     /* Convert `short' and `char' to full-size `int'.  */
  1783.     result = tree_cons (NULL_TREE, default_conversion (val), result);
  1784.  
  1785.       if (typetail)
  1786.     typetail = TREE_CHAIN (typetail);
  1787.     }
  1788.  
  1789.   if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
  1790.     {
  1791.       if (name)
  1792.     error ("too few arguments to function `%s'",
  1793.            IDENTIFIER_POINTER (name));
  1794.       else
  1795.     error ("too few arguments to function");
  1796.     }
  1797.  
  1798.   return nreverse (result);
  1799. }
  1800.  
  1801. /* This is the entry point used by the parser
  1802.    for binary operators in the input.
  1803.    In addition to constructing the expression,
  1804.    we check for operands that were written with other binary operators
  1805.    in a way that is likely to confuse the user.  */
  1806.  
  1807. tree
  1808. parser_build_binary_op (code, arg1, arg2)
  1809.      enum tree_code code;
  1810.      tree arg1, arg2;
  1811. {
  1812.   tree result = build_binary_op (code, arg1, arg2, 1);
  1813.  
  1814.   char class;
  1815.   char class1 = TREE_CODE_CLASS (TREE_CODE (arg1));
  1816.   char class2 = TREE_CODE_CLASS (TREE_CODE (arg2));
  1817.   enum tree_code code1 = ERROR_MARK;
  1818.   enum tree_code code2 = ERROR_MARK;
  1819.  
  1820.   if (class1 == 'e' || class1 == '1'
  1821.       || class1 == '2' || class1 == '<')
  1822.     code1 = C_EXP_ORIGINAL_CODE (arg1);
  1823.   if (class2 == 'e' || class2 == '1'
  1824.       || class2 == '2' || class2 == '<')
  1825.     code2 = C_EXP_ORIGINAL_CODE (arg2);
  1826.  
  1827.   /* Check for cases such as x+y<<z which users are likely
  1828.      to misinterpret.  If parens are used, C_EXP_ORIGINAL_CODE
  1829.      is cleared to prevent these warnings.  */
  1830.   if (warn_parentheses)
  1831.     {
  1832.       if (code == LSHIFT_EXPR || code == RSHIFT_EXPR)
  1833.     {
  1834.       if (code1 == PLUS_EXPR || code1 == MINUS_EXPR
  1835.           || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
  1836.         warning ("suggest parentheses around + or - inside shift");
  1837.     }
  1838.  
  1839.       if (code == TRUTH_ORIF_EXPR)
  1840.     {
  1841.       if (code1 == TRUTH_ANDIF_EXPR
  1842.           || code2 == TRUTH_ANDIF_EXPR)
  1843.         warning ("suggest parentheses around && within ||");
  1844.     }
  1845.  
  1846.       if (code == BIT_IOR_EXPR)
  1847.     {
  1848.       if (code1 == BIT_AND_EXPR || code1 == BIT_XOR_EXPR
  1849.           || code1 == PLUS_EXPR || code1 == MINUS_EXPR
  1850.           || code2 == BIT_AND_EXPR || code2 == BIT_XOR_EXPR
  1851.           || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
  1852.         warning ("suggest parentheses around arithmetic in operand of |");
  1853.     }
  1854.  
  1855.       if (code == BIT_XOR_EXPR)
  1856.     {
  1857.       if (code1 == BIT_AND_EXPR
  1858.           || code1 == PLUS_EXPR || code1 == MINUS_EXPR
  1859.           || code2 == BIT_AND_EXPR
  1860.           || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
  1861.         warning ("suggest parentheses around arithmetic in operand of ^");
  1862.     }
  1863.  
  1864.       if (code == BIT_AND_EXPR)
  1865.     {
  1866.       if (code1 == PLUS_EXPR || code1 == MINUS_EXPR
  1867.           || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
  1868.         warning ("suggest parentheses around + or - in operand of &");
  1869.     }
  1870.     }
  1871.  
  1872.   /* Similarly, check for cases like 1<=i<=10 that are probably errors.  */
  1873.   if (TREE_CODE_CLASS (code) == '<' && extra_warnings
  1874.       && (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<'))
  1875.     warning ("comparisons like X<=Y<=Z do not have their mathematical meaning");
  1876.  
  1877.   unsigned_conversion_warning (result, arg1);
  1878.   unsigned_conversion_warning (result, arg2);
  1879.   overflow_warning (result);
  1880.  
  1881.   class = TREE_CODE_CLASS (TREE_CODE (result));
  1882.  
  1883.   /* Record the code that was specified in the source,
  1884.      for the sake of warnings about confusing nesting.  */
  1885.   if (class == 'e' || class == '1'
  1886.       || class == '2' || class == '<')
  1887.     C_SET_EXP_ORIGINAL_CODE (result, code);
  1888.   else
  1889.     {
  1890.       int flag = TREE_CONSTANT (result);
  1891.       /* We used to use NOP_EXPR rather than NON_LVALUE_EXPR
  1892.      so that convert_for_assignment wouldn't strip it.
  1893.      That way, we got warnings for things like p = (1 - 1).
  1894.      But it turns out we should not get those warnings.  */
  1895.       result = build1 (NON_LVALUE_EXPR, TREE_TYPE (result), result);
  1896.       C_SET_EXP_ORIGINAL_CODE (result, code);
  1897.       TREE_CONSTANT (result) = flag;
  1898.     }
  1899.  
  1900.   return result;
  1901. }
  1902.  
  1903. /* Build a binary-operation expression without default conversions.
  1904.    CODE is the kind of expression to build.
  1905.    This function differs from `build' in several ways:
  1906.    the data type of the result is computed and recorded in it,
  1907.    warnings are generated if arg data types are invalid,
  1908.    special handling for addition and subtraction of pointers is known,
  1909.    and some optimization is done (operations on narrow ints
  1910.    are done in the narrower type when that gives the same result).
  1911.    Constant folding is also done before the result is returned.
  1912.  
  1913.    Note that the operands will never have enumeral types, or function
  1914.    or array types, because either they will have the default conversions
  1915.    performed or they have both just been converted to some other type in which
  1916.    the arithmetic is to be done.  */
  1917.  
  1918. tree
  1919. build_binary_op (code, orig_op0, orig_op1, convert_p)
  1920.      enum tree_code code;
  1921.      tree orig_op0, orig_op1;
  1922.      int convert_p;
  1923. {
  1924.   tree type0, type1;
  1925.   register enum tree_code code0, code1;
  1926.   tree op0, op1;
  1927.  
  1928.   /* Expression code to give to the expression when it is built.
  1929.      Normally this is CODE, which is what the caller asked for,
  1930.      but in some special cases we change it.  */
  1931.   register enum tree_code resultcode = code;
  1932.  
  1933.   /* Data type in which the computation is to be performed.
  1934.      In the simplest cases this is the common type of the arguments.  */
  1935.   register tree result_type = NULL;
  1936.  
  1937.   /* Nonzero means operands have already been type-converted
  1938.      in whatever way is necessary.
  1939.      Zero means they need to be converted to RESULT_TYPE.  */
  1940.   int converted = 0;
  1941.  
  1942.   /* Nonzero means create the expression with this type, rather than
  1943.      RESULT_TYPE.  */
  1944.   tree build_type = 0;
  1945.  
  1946.   /* Nonzero means after finally constructing the expression
  1947.      convert it to this type.  */
  1948.   tree final_type = 0;
  1949.  
  1950.   /* Nonzero if this is an operation like MIN or MAX which can
  1951.      safely be computed in short if both args are promoted shorts.
  1952.      Also implies COMMON.
  1953.      -1 indicates a bitwise operation; this makes a difference
  1954.      in the exact conditions for when it is safe to do the operation
  1955.      in a narrower mode.  */
  1956.   int shorten = 0;
  1957.  
  1958.   /* Nonzero if this is a comparison operation;
  1959.      if both args are promoted shorts, compare the original shorts.
  1960.      Also implies COMMON.  */
  1961.   int short_compare = 0;
  1962.  
  1963.   /* Nonzero if this is a right-shift operation, which can be computed on the
  1964.      original short and then promoted if the operand is a promoted short.  */
  1965.   int short_shift = 0;
  1966.  
  1967.   /* Nonzero means set RESULT_TYPE to the common type of the args.  */
  1968.   int common = 0;
  1969.  
  1970.   if (convert_p)
  1971.     {
  1972.       op0 = default_conversion (orig_op0);
  1973.       op1 = default_conversion (orig_op1);
  1974.     }
  1975.   else
  1976.     {
  1977.       op0 = orig_op0;
  1978.       op1 = orig_op1;
  1979.     }
  1980.  
  1981.   type0 = TREE_TYPE (op0);
  1982.   type1 = TREE_TYPE (op1);
  1983.  
  1984.   /* The expression codes of the data types of the arguments tell us
  1985.      whether the arguments are integers, floating, pointers, etc.  */
  1986.   code0 = TREE_CODE (type0);
  1987.   code1 = TREE_CODE (type1);
  1988.  
  1989.   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
  1990.   STRIP_TYPE_NOPS (op0);
  1991.   STRIP_TYPE_NOPS (op1);
  1992.  
  1993.   /* If an error was already reported for one of the arguments,
  1994.      avoid reporting another error.  */
  1995.  
  1996.   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
  1997.     return error_mark_node;
  1998.  
  1999.   switch (code)
  2000.     {
  2001.     case PLUS_EXPR:
  2002.       /* Handle the pointer + int case.  */
  2003.       if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
  2004.     return pointer_int_sum (PLUS_EXPR, op0, op1);
  2005.       else if (code1 == POINTER_TYPE && code0 == INTEGER_TYPE)
  2006.     return pointer_int_sum (PLUS_EXPR, op1, op0);
  2007.       else
  2008.     common = 1;
  2009.       break;
  2010.  
  2011.     case MINUS_EXPR:
  2012.       /* Subtraction of two similar pointers.
  2013.      We must subtract them as integers, then divide by object size.  */
  2014.       if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
  2015.       && comp_target_types (type0, type1))
  2016.     return pointer_diff (op0, op1);
  2017.       /* Handle pointer minus int.  Just like pointer plus int.  */
  2018.       else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
  2019.     return pointer_int_sum (MINUS_EXPR, op0, op1);
  2020.       else
  2021.     common = 1;
  2022.       break;
  2023.  
  2024.     case MULT_EXPR:
  2025.       common = 1;
  2026.       break;
  2027.  
  2028.     case TRUNC_DIV_EXPR:
  2029.     case CEIL_DIV_EXPR:
  2030.     case FLOOR_DIV_EXPR:
  2031.     case ROUND_DIV_EXPR:
  2032.     case EXACT_DIV_EXPR:
  2033.       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
  2034.        || code0 == COMPLEX_TYPE)
  2035.       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
  2036.           || code1 == COMPLEX_TYPE))
  2037.     {
  2038.       if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE))
  2039.         resultcode = RDIV_EXPR;
  2040.       else
  2041.         {
  2042.           /* Although it would be tempting to shorten always here, that
  2043.          loses on some targets, since the modulo instruction is
  2044.          undefined if the quotient can't be represented in the
  2045.          computation mode.  We shorten only if unsigned or if
  2046.          dividing by something we know != -1.  */
  2047.           shorten = (TREE_UNSIGNED (TREE_TYPE (orig_op0))
  2048.              || (TREE_CODE (op1) == INTEGER_CST
  2049.                  && (TREE_INT_CST_LOW (op1) != -1
  2050.                  || TREE_INT_CST_HIGH (op1) != -1)));
  2051.         }
  2052.       common = 1;
  2053.     }
  2054.       break;
  2055.  
  2056.     case BIT_AND_EXPR:
  2057.     case BIT_ANDTC_EXPR:
  2058.     case BIT_IOR_EXPR:
  2059.     case BIT_XOR_EXPR:
  2060.       if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
  2061.     shorten = -1;
  2062.       /* If one operand is a constant, and the other is a short type
  2063.      that has been converted to an int,
  2064.      really do the work in the short type and then convert the
  2065.      result to int.  If we are lucky, the constant will be 0 or 1
  2066.      in the short type, making the entire operation go away.  */
  2067.       if (TREE_CODE (op0) == INTEGER_CST
  2068.       && TREE_CODE (op1) == NOP_EXPR
  2069.       && TYPE_PRECISION (type1) > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op1, 0)))
  2070.       && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op1, 0))))
  2071.     {
  2072.       final_type = result_type;
  2073.       op1 = TREE_OPERAND (op1, 0);
  2074.       result_type = TREE_TYPE (op1);
  2075.     }
  2076.       if (TREE_CODE (op1) == INTEGER_CST
  2077.       && TREE_CODE (op0) == NOP_EXPR
  2078.       && TYPE_PRECISION (type0) > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))
  2079.       && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0))))
  2080.     {
  2081.       final_type = result_type;
  2082.       op0 = TREE_OPERAND (op0, 0);
  2083.       result_type = TREE_TYPE (op0);
  2084.     }
  2085.       break;
  2086.  
  2087.     case TRUNC_MOD_EXPR:
  2088.     case FLOOR_MOD_EXPR:
  2089.       if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
  2090.     {
  2091.       /* Although it would be tempting to shorten always here, that loses
  2092.          on some targets, since the modulo instruction is undefined if the
  2093.          quotient can't be represented in the computation mode.  We shorten
  2094.          only if unsigned or if dividing by something we know != -1.  */
  2095.       shorten = (TREE_UNSIGNED (TREE_TYPE (orig_op0))
  2096.              || (TREE_CODE (op1) == INTEGER_CST
  2097.              && (TREE_INT_CST_LOW (op1) != -1
  2098.                  || TREE_INT_CST_HIGH (op1) != -1)));
  2099.       common = 1;
  2100.     }
  2101.       break;
  2102.  
  2103.     case TRUTH_ANDIF_EXPR:
  2104.     case TRUTH_ORIF_EXPR:
  2105.     case TRUTH_AND_EXPR:
  2106.     case TRUTH_OR_EXPR:
  2107.     case TRUTH_XOR_EXPR:
  2108.       if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
  2109.        || code0 == REAL_TYPE || code0 == COMPLEX_TYPE)
  2110.       && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
  2111.           || code1 == REAL_TYPE || code1 == COMPLEX_TYPE))
  2112.     {
  2113.       /* Result of these operations is always an int,
  2114.          but that does not mean the operands should be
  2115.          converted to ints!  */
  2116.       result_type = integer_type_node;
  2117.       op0 = truthvalue_conversion (op0);
  2118.       op1 = truthvalue_conversion (op1);
  2119.       converted = 1;
  2120.     }
  2121.       break;
  2122.  
  2123.       /* Shift operations: result has same type as first operand;
  2124.      always convert second operand to int.
  2125.      Also set SHORT_SHIFT if shifting rightward.  */
  2126.  
  2127.     case RSHIFT_EXPR:
  2128.       if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
  2129.     {
  2130.       if (TREE_CODE (op1) == INTEGER_CST)
  2131.         {
  2132.           if (tree_int_cst_sgn (op1) < 0)
  2133.         warning ("right shift count is negative");
  2134.           else
  2135.         {
  2136.           if (TREE_INT_CST_LOW (op1) | TREE_INT_CST_HIGH (op1))
  2137.             short_shift = 1;
  2138.           if (TREE_INT_CST_HIGH (op1) != 0
  2139.               || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
  2140.               >= TYPE_PRECISION (type0)))
  2141.             warning ("right shift count >= width of type");
  2142.         }
  2143.         }
  2144.       /* Use the type of the value to be shifted.
  2145.          This is what most traditional C compilers do.  */
  2146.       result_type = type0;
  2147.       /* Unless traditional, convert the shift-count to an integer,
  2148.          regardless of size of value being shifted.  */
  2149.       if (! flag_traditional)
  2150.         {
  2151.           if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
  2152.         op1 = convert (integer_type_node, op1);
  2153.           /* Avoid converting op1 to result_type later.  */
  2154.           converted = 1;
  2155.         }
  2156.     }
  2157.       break;
  2158.  
  2159.     case LSHIFT_EXPR:
  2160.       if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
  2161.     {
  2162.       if (TREE_CODE (op1) == INTEGER_CST)
  2163.         {
  2164.           if (tree_int_cst_sgn (op1) < 0)
  2165.         warning ("left shift count is negative");
  2166.           else if (TREE_INT_CST_HIGH (op1) != 0
  2167.                || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
  2168.                >= TYPE_PRECISION (type0)))
  2169.         warning ("left shift count >= width of type");
  2170.         }
  2171.       /* Use the type of the value to be shifted.
  2172.          This is what most traditional C compilers do.  */
  2173.       result_type = type0;
  2174.       /* Unless traditional, convert the shift-count to an integer,
  2175.          regardless of size of value being shifted.  */
  2176.       if (! flag_traditional)
  2177.         {
  2178.           if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
  2179.         op1 = convert (integer_type_node, op1);
  2180.           /* Avoid converting op1 to result_type later.  */
  2181.           converted = 1;
  2182.         }
  2183.     }
  2184.       break;
  2185.  
  2186.     case RROTATE_EXPR:
  2187.     case LROTATE_EXPR:
  2188.       if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
  2189.     {
  2190.       if (TREE_CODE (op1) == INTEGER_CST)
  2191.         {
  2192.           if (tree_int_cst_sgn (op1) < 0)
  2193.         warning ("shift count is negative");
  2194.           else if (TREE_INT_CST_HIGH (op1) != 0
  2195.                || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
  2196.                >= TYPE_PRECISION (type0)))
  2197.         warning ("shift count >= width of type");
  2198.         }
  2199.       /* Use the type of the value to be shifted.
  2200.          This is what most traditional C compilers do.  */
  2201.       result_type = type0;
  2202.       /* Unless traditional, convert the shift-count to an integer,
  2203.          regardless of size of value being shifted.  */
  2204.       if (! flag_traditional)
  2205.         {
  2206.           if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
  2207.         op1 = convert (integer_type_node, op1);
  2208.           /* Avoid converting op1 to result_type later.  */
  2209.           converted = 1;
  2210.         }
  2211.     }
  2212.       break;
  2213.  
  2214.     case EQ_EXPR:
  2215.     case NE_EXPR:
  2216.       /* Result of comparison is always int,
  2217.      but don't convert the args to int!  */
  2218.       build_type = integer_type_node;
  2219.       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
  2220.        || code0 == COMPLEX_TYPE)
  2221.       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
  2222.           || code1 == COMPLEX_TYPE))
  2223.     short_compare = 1;
  2224.       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
  2225.     {
  2226.       register tree tt0 = TREE_TYPE (type0);
  2227.       register tree tt1 = TREE_TYPE (type1);
  2228.       /* Anything compares with void *.  void * compares with anything.
  2229.          Otherwise, the targets must be compatible
  2230.          and both must be object or both incomplete.  */
  2231.       if (comp_target_types (type0, type1))
  2232.         result_type = common_type (type0, type1);
  2233.       else if (TYPE_MAIN_VARIANT (tt0) == void_type_node)
  2234.         {
  2235.           /* op0 != orig_op0 detects the case of something
  2236.          whose value is 0 but which isn't a valid null ptr const.  */
  2237.           if (pedantic && (!integer_zerop (op0) || op0 != orig_op0)
  2238.           && TREE_CODE (tt1) == FUNCTION_TYPE)
  2239.         pedwarn ("ANSI C forbids comparison of `void *' with function pointer");
  2240.         }
  2241.       else if (TYPE_MAIN_VARIANT (tt1) == void_type_node)
  2242.         {
  2243.           if (pedantic && (!integer_zerop (op1) || op1 != orig_op1)
  2244.           && TREE_CODE (tt0) == FUNCTION_TYPE)
  2245.         pedwarn ("ANSI C forbids comparison of `void *' with function pointer");
  2246.         }
  2247.       else
  2248.         pedwarn ("comparison of distinct pointer types lacks a cast");
  2249.  
  2250.       if (result_type == NULL_TREE)
  2251.         result_type = ptr_type_node;
  2252.     }
  2253.       else if (code0 == POINTER_TYPE && TREE_CODE (op1) == INTEGER_CST
  2254.            && integer_zerop (op1))
  2255.     result_type = type0;
  2256.       else if (code1 == POINTER_TYPE && TREE_CODE (op0) == INTEGER_CST
  2257.            && integer_zerop (op0))
  2258.     result_type = type1;
  2259.       else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
  2260.     {
  2261.       result_type = type0;
  2262.       if (! flag_traditional)
  2263.         pedwarn ("comparison between pointer and integer");
  2264.     }
  2265.       else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
  2266.     {
  2267.       result_type = type1;
  2268.       if (! flag_traditional)
  2269.         pedwarn ("comparison between pointer and integer");
  2270.     }
  2271.       break;
  2272.  
  2273.     case MAX_EXPR:
  2274.     case MIN_EXPR:
  2275.       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
  2276.       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
  2277.     shorten = 1;
  2278.       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
  2279.     {
  2280.       if (comp_target_types (type0, type1))
  2281.         {
  2282.           result_type = common_type (type0, type1);
  2283.           if (pedantic 
  2284.           && TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
  2285.         pedwarn ("ANSI C forbids ordered comparisons of pointers to functions");
  2286.         }
  2287.       else
  2288.         {
  2289.           result_type = ptr_type_node;
  2290.           pedwarn ("comparison of distinct pointer types lacks a cast");
  2291.         }
  2292.     }
  2293.       break;
  2294.  
  2295.     case LE_EXPR:
  2296.     case GE_EXPR:
  2297.     case LT_EXPR:
  2298.     case GT_EXPR:
  2299.       build_type = integer_type_node;
  2300.       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
  2301.       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
  2302.     short_compare = 1;
  2303.       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
  2304.     {
  2305.       if (comp_target_types (type0, type1))
  2306.         {
  2307.           result_type = common_type (type0, type1);
  2308.           if ((TYPE_SIZE (TREE_TYPE (type0)) != 0)
  2309.           != (TYPE_SIZE (TREE_TYPE (type1)) != 0))
  2310.         pedwarn ("comparison of complete and incomplete pointers");
  2311.           else if (pedantic 
  2312.                && TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
  2313.         pedwarn ("ANSI C forbids ordered comparisons of pointers to functions");
  2314.         }
  2315.       else
  2316.         {
  2317.           result_type = ptr_type_node;
  2318.           pedwarn ("comparison of distinct pointer types lacks a cast");
  2319.         }
  2320.     }
  2321.       else if (code0 == POINTER_TYPE && TREE_CODE (op1) == INTEGER_CST
  2322.            && integer_zerop (op1))
  2323.     {
  2324.       result_type = type0;
  2325.       if (pedantic || extra_warnings)
  2326.         pedwarn ("ordered comparison of pointer with integer zero");
  2327.     }
  2328.       else if (code1 == POINTER_TYPE && TREE_CODE (op0) == INTEGER_CST
  2329.            && integer_zerop (op0))
  2330.     {
  2331.       result_type = type1;
  2332.       if (pedantic)
  2333.         pedwarn ("ordered comparison of pointer with integer zero");
  2334.     }
  2335.       else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
  2336.     {
  2337.       result_type = type0;
  2338.       if (! flag_traditional)
  2339.         pedwarn ("comparison between pointer and integer");
  2340.     }
  2341.       else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
  2342.     {
  2343.       result_type = type1;
  2344.       if (! flag_traditional)
  2345.         pedwarn ("comparison between pointer and integer");
  2346.     }
  2347.       break;
  2348.     }
  2349.  
  2350.   if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE)
  2351.       &&
  2352.       (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE))
  2353.     {
  2354.       int none_complex = (code0 != COMPLEX_TYPE && code1 != COMPLEX_TYPE);
  2355.  
  2356.       if (shorten || common || short_compare)
  2357.     result_type = common_type (type0, type1);
  2358.  
  2359.       /* For certain operations (which identify themselves by shorten != 0)
  2360.      if both args were extended from the same smaller type,
  2361.      do the arithmetic in that type and then extend.
  2362.  
  2363.      shorten !=0 and !=1 indicates a bitwise operation.
  2364.      For them, this optimization is safe only if
  2365.      both args are zero-extended or both are sign-extended.
  2366.      Otherwise, we might change the result.
  2367.      Eg, (short)-1 | (unsigned short)-1 is (int)-1
  2368.      but calculated in (unsigned short) it would be (unsigned short)-1.  */
  2369.  
  2370.       if (shorten && none_complex)
  2371.     {
  2372.       int unsigned0, unsigned1;
  2373.       tree arg0 = get_narrower (op0, &unsigned0);
  2374.       tree arg1 = get_narrower (op1, &unsigned1);
  2375.       /* UNS is 1 if the operation to be done is an unsigned one.  */
  2376.       int uns = TREE_UNSIGNED (result_type);
  2377.       tree type;
  2378.  
  2379.       final_type = result_type;
  2380.  
  2381.       /* Handle the case that OP0 (or OP1) does not *contain* a conversion
  2382.          but it *requires* conversion to FINAL_TYPE.  */
  2383.  
  2384.       if ((TYPE_PRECISION (TREE_TYPE (op0))
  2385.            == TYPE_PRECISION (TREE_TYPE (arg0)))
  2386.           && TREE_TYPE (op0) != final_type)
  2387.         unsigned0 = TREE_UNSIGNED (TREE_TYPE (op0));
  2388.       if ((TYPE_PRECISION (TREE_TYPE (op1))
  2389.            == TYPE_PRECISION (TREE_TYPE (arg1)))
  2390.           && TREE_TYPE (op1) != final_type)
  2391.         unsigned1 = TREE_UNSIGNED (TREE_TYPE (op1));
  2392.  
  2393.       /* Now UNSIGNED0 is 1 if ARG0 zero-extends to FINAL_TYPE.  */
  2394.  
  2395.       /* For bitwise operations, signedness of nominal type
  2396.          does not matter.  Consider only how operands were extended.  */
  2397.       if (shorten == -1)
  2398.         uns = unsigned0;
  2399.  
  2400.       /* Note that in all three cases below we refrain from optimizing
  2401.          an unsigned operation on sign-extended args.
  2402.          That would not be valid.  */
  2403.  
  2404.       /* Both args variable: if both extended in same way
  2405.          from same width, do it in that width.
  2406.          Do it unsigned if args were zero-extended.  */
  2407.       if ((TYPE_PRECISION (TREE_TYPE (arg0))
  2408.            < TYPE_PRECISION (result_type))
  2409.           && (TYPE_PRECISION (TREE_TYPE (arg1))
  2410.           == TYPE_PRECISION (TREE_TYPE (arg0)))
  2411.           && unsigned0 == unsigned1
  2412.           && (unsigned0 || !uns))
  2413.         result_type
  2414.           = signed_or_unsigned_type (unsigned0,
  2415.                      common_type (TREE_TYPE (arg0), TREE_TYPE (arg1)));
  2416.       else if (TREE_CODE (arg0) == INTEGER_CST
  2417.            && (unsigned1 || !uns)
  2418.            && (TYPE_PRECISION (TREE_TYPE (arg1))
  2419.                < TYPE_PRECISION (result_type))
  2420.            && (type = signed_or_unsigned_type (unsigned1,
  2421.                                TREE_TYPE (arg1)),
  2422.                int_fits_type_p (arg0, type)))
  2423.         result_type = type;
  2424.       else if (TREE_CODE (arg1) == INTEGER_CST
  2425.            && (unsigned0 || !uns)
  2426.            && (TYPE_PRECISION (TREE_TYPE (arg0))
  2427.                < TYPE_PRECISION (result_type))
  2428.            && (type = signed_or_unsigned_type (unsigned0,
  2429.                                TREE_TYPE (arg0)),
  2430.                int_fits_type_p (arg1, type)))
  2431.         result_type = type;
  2432.     }
  2433.  
  2434.       /* Shifts can be shortened if shifting right.  */
  2435.  
  2436.       if (short_shift)
  2437.     {
  2438.       int unsigned_arg;
  2439.       tree arg0 = get_narrower (op0, &unsigned_arg);
  2440.  
  2441.       final_type = result_type;
  2442.  
  2443.       if (arg0 == op0 && final_type == TREE_TYPE (op0))
  2444.         unsigned_arg = TREE_UNSIGNED (TREE_TYPE (op0));
  2445.  
  2446.       if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
  2447.           /* We can shorten only if the shift count is less than the
  2448.          number of bits in the smaller type size.  */
  2449.           && TREE_INT_CST_HIGH (op1) == 0
  2450.           && TYPE_PRECISION (TREE_TYPE (arg0)) > TREE_INT_CST_LOW (op1)
  2451.           /* If arg is sign-extended and then unsigned-shifted,
  2452.          we can simulate this with a signed shift in arg's type
  2453.          only if the extended result is at least twice as wide
  2454.          as the arg.  Otherwise, the shift could use up all the
  2455.          ones made by sign-extension and bring in zeros.
  2456.          We can't optimize that case at all, but in most machines
  2457.          it never happens because available widths are 2**N.  */
  2458.           && (!TREE_UNSIGNED (final_type)
  2459.           || unsigned_arg
  2460.           || 2 * TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (result_type)))
  2461.         {
  2462.           /* Do an unsigned shift if the operand was zero-extended.  */
  2463.           result_type
  2464.         = signed_or_unsigned_type (unsigned_arg,
  2465.                        TREE_TYPE (arg0));
  2466.           /* Convert value-to-be-shifted to that type.  */
  2467.           if (TREE_TYPE (op0) != result_type)
  2468.         op0 = convert (result_type, op0);
  2469.           converted = 1;
  2470.         }
  2471.     }
  2472.  
  2473.       /* Comparison operations are shortened too but differently.
  2474.      They identify themselves by setting short_compare = 1.  */
  2475.  
  2476.       if (short_compare)
  2477.     {
  2478.       /* Don't write &op0, etc., because that would prevent op0
  2479.          from being kept in a register.
  2480.          Instead, make copies of the our local variables and
  2481.          pass the copies by reference, then copy them back afterward.  */
  2482.       tree xop0 = op0, xop1 = op1, xresult_type = result_type;
  2483.       enum tree_code xresultcode = resultcode;
  2484.       tree val 
  2485.         = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode);
  2486.       if (val != 0)
  2487.         return val;
  2488.       op0 = xop0, op1 = xop1;
  2489.       converted = 1;
  2490.       resultcode = xresultcode;
  2491.  
  2492.       if (extra_warnings)
  2493.         {
  2494.           int op0_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op0));
  2495.           int op1_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op1));
  2496.  
  2497.           int unsignedp0, unsignedp1;
  2498.           tree primop0 = get_narrower (op0, &unsignedp0);
  2499.           tree primop1 = get_narrower (op1, &unsignedp1);
  2500.  
  2501.           /* Avoid spurious warnings for comparison with enumerators.  */
  2502.  
  2503.           xop0 = orig_op0;
  2504.           xop1 = orig_op1;
  2505.           STRIP_TYPE_NOPS (xop0);
  2506.           STRIP_TYPE_NOPS (xop1);
  2507.  
  2508.           /* Give warnings for comparisons between signed and unsigned
  2509.          quantities that may fail.  */
  2510.           /* Do the checking based on the original operand trees, so that
  2511.          casts will be considered, but default promotions won't be.  */
  2512.  
  2513.           /* Do not warn if the comparison is being done in a signed type,
  2514.          since the signed type will only be chosen if it can represent
  2515.          all the values of the unsigned type.  */
  2516.           if (! TREE_UNSIGNED (result_type))
  2517.         /* OK */;
  2518.               /* Do not warn if both operands are unsigned.  */
  2519.               else if (op0_signed == op1_signed)
  2520.                 /* OK */;
  2521.           /* Do not warn if the signed quantity is an unsuffixed
  2522.          integer literal (or some static constant expression
  2523.          involving such literals) and it is non-negative.  */
  2524.           else if ((op0_signed && TREE_CODE (xop0) == INTEGER_CST
  2525.             && tree_int_cst_sgn (xop0) >= 0)
  2526.                || (op1_signed && TREE_CODE (xop1) == INTEGER_CST
  2527.                && tree_int_cst_sgn (xop1) >= 0))
  2528.         /* OK */;
  2529.           /* Do not warn if the comparison is an equality operation,
  2530.                  the unsigned quantity is an integral constant and it does
  2531.                  not use the most significant bit of result_type.  */
  2532.           else if ((resultcode == EQ_EXPR || resultcode == NE_EXPR)
  2533.                && ((op0_signed && TREE_CODE (xop1) == INTEGER_CST
  2534.                 && int_fits_type_p (xop1, signed_type (result_type))
  2535.                || (op1_signed && TREE_CODE (xop0) == INTEGER_CST
  2536.                    && int_fits_type_p (xop0, signed_type (result_type))))))
  2537.         /* OK */;
  2538.           else
  2539.         warning ("comparison between signed and unsigned");
  2540.  
  2541.           /* Warn if two unsigned values are being compared in a size
  2542.          larger than their original size, and one (and only one) is the
  2543.          result of a `~' operator.  This comparison will always fail.
  2544.  
  2545.          Also warn if one operand is a constant, and the constant
  2546.          does not have all bits set that are set in the ~ operand
  2547.          when it is extended.  */
  2548.  
  2549.           if ((TREE_CODE (primop0) == BIT_NOT_EXPR)
  2550.           != (TREE_CODE (primop1) == BIT_NOT_EXPR))
  2551.         {
  2552.           if (TREE_CODE (primop0) == BIT_NOT_EXPR)
  2553.             primop0 = get_narrower (TREE_OPERAND (primop0, 0),
  2554.                         &unsignedp0);
  2555.           else
  2556.             primop1 = get_narrower (TREE_OPERAND (primop1, 0),
  2557.                         &unsignedp1);
  2558.           
  2559.           if (TREE_CODE (primop0) == INTEGER_CST
  2560.               || TREE_CODE (primop1) == INTEGER_CST)
  2561.             {
  2562.               tree primop;
  2563.               long constant, mask;
  2564.               int unsignedp, bits;
  2565.  
  2566.               if (TREE_CODE (primop0) == INTEGER_CST)
  2567.             {
  2568.               primop = primop1;
  2569.               unsignedp = unsignedp1;
  2570.               constant = TREE_INT_CST_LOW (primop0);
  2571.             }
  2572.               else
  2573.             {
  2574.               primop = primop0;
  2575.               unsignedp = unsignedp0;
  2576.               constant = TREE_INT_CST_LOW (primop1);
  2577.             }
  2578.  
  2579.               bits = TYPE_PRECISION (TREE_TYPE (primop));
  2580.               if (bits < TYPE_PRECISION (result_type)
  2581.               && bits < HOST_BITS_PER_LONG && unsignedp)
  2582.             {
  2583.               mask = (~0L) << bits;
  2584.               if ((mask & constant) != mask)
  2585.                 warning ("comparison of promoted ~unsigned with constant");
  2586.             }
  2587.             }
  2588.           else if (unsignedp0 && unsignedp1
  2589.                && (TYPE_PRECISION (TREE_TYPE (primop0))
  2590.                    < TYPE_PRECISION (result_type))
  2591.                && (TYPE_PRECISION (TREE_TYPE (primop1))
  2592.                    < TYPE_PRECISION (result_type)))
  2593.             warning ("comparison of promoted ~unsigned with unsigned");
  2594.         }
  2595.         }
  2596.     }
  2597.     }
  2598.  
  2599.   /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
  2600.      If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
  2601.      Then the expression will be built.
  2602.      It will be given type FINAL_TYPE if that is nonzero;
  2603.      otherwise, it will be given type RESULT_TYPE.  */
  2604.  
  2605.   if (!result_type)
  2606.     {
  2607.       binary_op_error (code);
  2608.       return error_mark_node;
  2609.     }
  2610.  
  2611.   if (! converted)
  2612.     {
  2613.       if (TREE_TYPE (op0) != result_type)
  2614.     op0 = convert (result_type, op0); 
  2615.       if (TREE_TYPE (op1) != result_type)
  2616.     op1 = convert (result_type, op1); 
  2617.     }
  2618.  
  2619.   if (build_type == NULL_TREE)
  2620.     build_type = result_type;
  2621.  
  2622.   {
  2623.     register tree result = build (resultcode, build_type, op0, op1);
  2624.     register tree folded;
  2625.  
  2626.     folded = fold (result);
  2627.     if (folded == result)
  2628.       TREE_CONSTANT (folded) = TREE_CONSTANT (op0) & TREE_CONSTANT (op1);
  2629.     if (final_type != 0)
  2630.       return convert (final_type, folded);
  2631.     return folded;
  2632.   }
  2633. }
  2634.  
  2635. /* Return a tree for the sum or difference (RESULTCODE says which)
  2636.    of pointer PTROP and integer INTOP.  */
  2637.  
  2638. static tree
  2639. pointer_int_sum (resultcode, ptrop, intop)
  2640.      enum tree_code resultcode;
  2641.      register tree ptrop, intop;
  2642. {
  2643.   tree size_exp;
  2644.  
  2645.   register tree result;
  2646.   register tree folded;
  2647.  
  2648.   /* The result is a pointer of the same type that is being added.  */
  2649.  
  2650.   register tree result_type = TREE_TYPE (ptrop);
  2651.  
  2652.   if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
  2653.     {
  2654.       if (pedantic || warn_pointer_arith)
  2655.     pedwarn ("pointer of type `void *' used in arithmetic");
  2656.       size_exp = integer_one_node;
  2657.     }
  2658.   else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE)
  2659.     {
  2660.       if (pedantic || warn_pointer_arith)
  2661.     pedwarn ("pointer to a function used in arithmetic");
  2662.       size_exp = integer_one_node;
  2663.     }
  2664.   else
  2665.     size_exp = c_size_in_bytes (TREE_TYPE (result_type));
  2666.  
  2667.   /* If what we are about to multiply by the size of the elements
  2668.      contains a constant term, apply distributive law
  2669.      and multiply that constant term separately.
  2670.      This helps produce common subexpressions.  */
  2671.  
  2672.   if ((TREE_CODE (intop) == PLUS_EXPR || TREE_CODE (intop) == MINUS_EXPR)
  2673.       && ! TREE_CONSTANT (intop)
  2674.       && TREE_CONSTANT (TREE_OPERAND (intop, 1))
  2675.       && TREE_CONSTANT (size_exp)
  2676.       /* If the constant comes from pointer subtraction,
  2677.      skip this optimization--it would cause an error.  */
  2678.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (intop, 0))) == INTEGER_TYPE
  2679.       /* If the constant is unsigned, and smaller than the pointer size,
  2680.      then we must skip this optimization.  This is because it could cause
  2681.      an overflow error if the constant is negative but INTOP is not.  */
  2682.       && (! TREE_UNSIGNED (TREE_TYPE (intop))
  2683.       || (TYPE_PRECISION (TREE_TYPE (intop))
  2684.           == TYPE_PRECISION (TREE_TYPE (ptrop)))))
  2685.     {
  2686.       enum tree_code subcode = resultcode;
  2687.       tree int_type = TREE_TYPE (intop);
  2688.       if (TREE_CODE (intop) == MINUS_EXPR)
  2689.     subcode = (subcode == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR);
  2690.       /* Convert both subexpression types to the type of intop,
  2691.      because weird cases involving pointer arithmetic
  2692.      can result in a sum or difference with different type args.  */
  2693.       ptrop = build_binary_op (subcode, ptrop,
  2694.                    convert (int_type, TREE_OPERAND (intop, 1)), 1);
  2695.       intop = convert (int_type, TREE_OPERAND (intop, 0));
  2696.     }
  2697.  
  2698.   /* Convert the integer argument to a type the same size as a pointer
  2699.      so the multiply won't overflow spuriously.  */
  2700.  
  2701.   if (TYPE_PRECISION (TREE_TYPE (intop)) != POINTER_SIZE)
  2702.     intop = convert (type_for_size (POINTER_SIZE, 0), intop);
  2703.  
  2704.   /* Replace the integer argument with a suitable product by the object size.
  2705.      Do this multiplication as signed, then convert to the appropriate
  2706.      pointer type (actually unsigned integral).  */
  2707.  
  2708.   intop = convert (result_type,
  2709.            build_binary_op (MULT_EXPR, intop,
  2710.                     convert (TREE_TYPE (intop), size_exp), 1));
  2711.  
  2712.   /* Create the sum or difference.  */
  2713.  
  2714.   result = build (resultcode, result_type, ptrop, intop);
  2715.  
  2716.   folded = fold (result);
  2717.   if (folded == result)
  2718.     TREE_CONSTANT (folded) = TREE_CONSTANT (ptrop) & TREE_CONSTANT (intop);
  2719.   return folded;
  2720. }
  2721.  
  2722. /* Return a tree for the difference of pointers OP0 and OP1.
  2723.    The resulting tree has type int.  */
  2724.  
  2725. static tree
  2726. pointer_diff (op0, op1)
  2727.      register tree op0, op1;
  2728. {
  2729.   register tree result, folded;
  2730.   tree restype = ptrdiff_type_node;
  2731.  
  2732.   tree target_type = TREE_TYPE (TREE_TYPE (op0));
  2733.  
  2734.   if (pedantic || warn_pointer_arith)
  2735.     {
  2736.       if (TREE_CODE (target_type) == VOID_TYPE)
  2737.     pedwarn ("pointer of type `void *' used in subtraction");
  2738.       if (TREE_CODE (target_type) == FUNCTION_TYPE)
  2739.     pedwarn ("pointer to a function used in subtraction");
  2740.     }
  2741.  
  2742.   /* First do the subtraction as integers;
  2743.      then drop through to build the divide operator.  */
  2744.  
  2745.   op0 = build_binary_op (MINUS_EXPR, convert (restype, op0),
  2746.              convert (restype, op1), 1);
  2747.   /* This generates an error if op1 is pointer to incomplete type.  */
  2748.   if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (op1))) == 0)
  2749.     error ("arithmetic on pointer to an incomplete type");
  2750.  
  2751.   /* This generates an error if op0 is pointer to incomplete type.  */
  2752.   op1 = c_size_in_bytes (target_type);
  2753.  
  2754.   /* Divide by the size, in easiest possible way.  */
  2755.  
  2756.   result = build (EXACT_DIV_EXPR, restype, op0, convert (restype, op1));
  2757.  
  2758.   folded = fold (result);
  2759.   if (folded == result)
  2760.     TREE_CONSTANT (folded) = TREE_CONSTANT (op0) & TREE_CONSTANT (op1);
  2761.   return folded;
  2762. }
  2763.  
  2764. /* Construct and perhaps optimize a tree representation
  2765.    for a unary operation.  CODE, a tree_code, specifies the operation
  2766.    and XARG is the operand.  NOCONVERT nonzero suppresses
  2767.    the default promotions (such as from short to int).  */
  2768.  
  2769. tree
  2770. build_unary_op (code, xarg, noconvert)
  2771.      enum tree_code code;
  2772.      tree xarg;
  2773.      int noconvert;
  2774. {
  2775.   /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
  2776.   register tree arg = xarg;
  2777.   register tree argtype = 0;
  2778.   register enum tree_code typecode = TREE_CODE (TREE_TYPE (arg));
  2779.   char *errstring = NULL;
  2780.   tree val;
  2781.  
  2782.   if (typecode == ERROR_MARK)
  2783.     return error_mark_node;
  2784.   if (typecode == ENUMERAL_TYPE)
  2785.     typecode = INTEGER_TYPE;
  2786.  
  2787.   switch (code)
  2788.     {
  2789.     case CONVERT_EXPR:
  2790.       /* This is used for unary plus, because a CONVERT_EXPR
  2791.      is enough to prevent anybody from looking inside for
  2792.      associativity, but won't generate any code.  */
  2793.       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
  2794.         || typecode == COMPLEX_TYPE))
  2795.         errstring = "wrong type argument to unary plus";
  2796.       else if (!noconvert)
  2797.     arg = default_conversion (arg);
  2798.       break;
  2799.  
  2800.     case NEGATE_EXPR:
  2801.       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
  2802.         || typecode == COMPLEX_TYPE))
  2803.         errstring = "wrong type argument to unary minus";
  2804.       else if (!noconvert)
  2805.     arg = default_conversion (arg);
  2806.       break;
  2807.  
  2808.     case BIT_NOT_EXPR:
  2809.       if (typecode == COMPLEX_TYPE)
  2810.     {
  2811.       code = CONJ_EXPR;
  2812.       if (!noconvert)
  2813.         arg = default_conversion (arg);
  2814.     }
  2815.       else if (typecode != INTEGER_TYPE)
  2816.         errstring = "wrong type argument to bit-complement";
  2817.       else if (!noconvert)
  2818.     arg = default_conversion (arg);
  2819.       break;
  2820.  
  2821.     case ABS_EXPR:
  2822.       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
  2823.         || typecode == COMPLEX_TYPE))
  2824.         errstring = "wrong type argument to abs";
  2825.       else if (!noconvert)
  2826.     arg = default_conversion (arg);
  2827.       break;
  2828.  
  2829.     case CONJ_EXPR:
  2830.       /* Conjugating a real value is a no-op, but allow it anyway.  */
  2831.       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
  2832.         || typecode == COMPLEX_TYPE))
  2833.     errstring = "wrong type argument to conjugation";
  2834.       else if (!noconvert)
  2835.     arg = default_conversion (arg);
  2836.       break;
  2837.  
  2838.     case TRUTH_NOT_EXPR:
  2839.       if (typecode != INTEGER_TYPE
  2840.       && typecode != REAL_TYPE && typecode != POINTER_TYPE
  2841.       && typecode != COMPLEX_TYPE
  2842.       /* These will convert to a pointer.  */
  2843.       && typecode != ARRAY_TYPE && typecode != FUNCTION_TYPE)
  2844.     {
  2845.       errstring = "wrong type argument to unary exclamation mark";
  2846.       break;
  2847.     }
  2848.       arg = truthvalue_conversion (arg);
  2849.       return invert_truthvalue (arg);
  2850.  
  2851.     case NOP_EXPR:
  2852.       break;
  2853.  
  2854.     case REALPART_EXPR:
  2855.       if (TREE_CODE (arg) == COMPLEX_CST)
  2856.     return TREE_REALPART (arg);
  2857.       else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
  2858.     return fold (build1 (REALPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg));
  2859.       else
  2860.     return arg;
  2861.  
  2862.     case IMAGPART_EXPR:
  2863.       if (TREE_CODE (arg) == COMPLEX_CST)
  2864.     return TREE_IMAGPART (arg);
  2865.       else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
  2866.     return fold (build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg));
  2867.       else
  2868.     return convert (TREE_TYPE (arg), integer_zero_node);
  2869.       
  2870.     case PREINCREMENT_EXPR:
  2871.     case POSTINCREMENT_EXPR:
  2872.     case PREDECREMENT_EXPR:
  2873.     case POSTDECREMENT_EXPR:
  2874.       /* Handle complex lvalues (when permitted)
  2875.      by reduction to simpler cases.  */
  2876.  
  2877.       val = unary_complex_lvalue (code, arg);
  2878.       if (val != 0)
  2879.     return val;
  2880.  
  2881.       /* Increment or decrement the real part of the value,
  2882.      and don't change the imaginary part.  */
  2883.       if (typecode == COMPLEX_TYPE)
  2884.     {
  2885.       tree real, imag;
  2886.  
  2887.       arg = stabilize_reference (arg);
  2888.       real = build_unary_op (REALPART_EXPR, arg, 1);
  2889.       imag = build_unary_op (IMAGPART_EXPR, arg, 1);
  2890.       return build (COMPLEX_EXPR, TREE_TYPE (arg),
  2891.             build_unary_op (code, real, 1), imag);
  2892.     }
  2893.  
  2894.       /* Report invalid types.  */
  2895.  
  2896.       if (typecode != POINTER_TYPE
  2897.       && typecode != INTEGER_TYPE && typecode != REAL_TYPE)
  2898.     {
  2899.       if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
  2900.         errstring ="wrong type argument to increment";
  2901.       else
  2902.         errstring ="wrong type argument to decrement";
  2903.       break;
  2904.     }
  2905.  
  2906.       {
  2907.     register tree inc;
  2908.     tree result_type = TREE_TYPE (arg);
  2909.  
  2910.     arg = get_unwidened (arg, 0);
  2911.     argtype = TREE_TYPE (arg);
  2912.  
  2913.     /* Compute the increment.  */
  2914.  
  2915.     if (typecode == POINTER_TYPE)
  2916.       {
  2917.         /* If pointer target is an undefined struct,
  2918.            we just cannot know how to do the arithmetic.  */
  2919.         if (TYPE_SIZE (TREE_TYPE (result_type)) == 0)
  2920.           error ("%s of pointer to unknown structure",
  2921.                ((code == PREINCREMENT_EXPR
  2922.              || code == POSTINCREMENT_EXPR)
  2923.             ? "increment" : "decrement"));
  2924.         else if ((pedantic || warn_pointer_arith)
  2925.              && (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE
  2926.              || TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE))
  2927.           pedwarn ("wrong type argument to %s",
  2928.                ((code == PREINCREMENT_EXPR
  2929.              || code == POSTINCREMENT_EXPR)
  2930.             ? "increment" : "decrement"));
  2931.         inc = c_size_in_bytes (TREE_TYPE (result_type));
  2932.       }
  2933.     else
  2934.       inc = integer_one_node;
  2935.  
  2936.     inc = convert (argtype, inc);
  2937.  
  2938.     /* Handle incrementing a cast-expression.  */
  2939.  
  2940.     while (1)
  2941.       switch (TREE_CODE (arg))
  2942.         {
  2943.         case NOP_EXPR:
  2944.         case CONVERT_EXPR:
  2945.         case FLOAT_EXPR:
  2946.         case FIX_TRUNC_EXPR:
  2947.         case FIX_FLOOR_EXPR:
  2948.         case FIX_ROUND_EXPR:
  2949.         case FIX_CEIL_EXPR:
  2950.           pedantic_lvalue_warning (CONVERT_EXPR);
  2951.           /* If the real type has the same machine representation
  2952.          as the type it is cast to, we can make better output
  2953.          by adding directly to the inside of the cast.  */
  2954.           if ((TREE_CODE (TREE_TYPE (arg))
  2955.            == TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))))
  2956.           && (TYPE_MODE (TREE_TYPE (arg))
  2957.               == TYPE_MODE (TREE_TYPE (TREE_OPERAND (arg, 0)))))
  2958.         arg = TREE_OPERAND (arg, 0);
  2959.           else
  2960.         {
  2961.           tree incremented, modify, value;
  2962.           arg = stabilize_reference (arg);
  2963.           if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR)
  2964.             value = arg;
  2965.           else
  2966.             value = save_expr (arg);
  2967.           incremented = build (((code == PREINCREMENT_EXPR
  2968.                      || code == POSTINCREMENT_EXPR)
  2969.                     ? PLUS_EXPR : MINUS_EXPR),
  2970.                        argtype, value, inc);
  2971.           TREE_SIDE_EFFECTS (incremented) = 1;
  2972.           modify = build_modify_expr (arg, NOP_EXPR, incremented);
  2973.           value = build (COMPOUND_EXPR, TREE_TYPE (arg), modify, value);
  2974.           TREE_USED (value) = 1;
  2975.           return value;
  2976.         }
  2977.           break;
  2978.  
  2979.         default:
  2980.           goto give_up;
  2981.         }
  2982.       give_up:
  2983.  
  2984.     /* Complain about anything else that is not a true lvalue.  */
  2985.     if (!lvalue_or_else (arg, ((code == PREINCREMENT_EXPR
  2986.                     || code == POSTINCREMENT_EXPR)
  2987.                    ? "increment" : "decrement")))
  2988.       return error_mark_node;
  2989.  
  2990.     /* Report a read-only lvalue.  */
  2991.     if (TREE_READONLY (arg))
  2992.       readonly_warning (arg, 
  2993.                 ((code == PREINCREMENT_EXPR
  2994.                   || code == POSTINCREMENT_EXPR)
  2995.                  ? "increment" : "decrement"));
  2996.  
  2997.     val = build (code, TREE_TYPE (arg), arg, inc);
  2998.     TREE_SIDE_EFFECTS (val) = 1;
  2999.     val = convert (result_type, val);
  3000.     if (TREE_CODE (val) != code)
  3001.       TREE_NO_UNUSED_WARNING (val) = 1;
  3002.     return val;
  3003.       }
  3004.  
  3005.     case ADDR_EXPR:
  3006.       /* Note that this operation never does default_conversion
  3007.      regardless of NOCONVERT.  */
  3008.  
  3009.       /* Let &* cancel out to simplify resulting code.  */
  3010.       if (TREE_CODE (arg) == INDIRECT_REF)
  3011.     {
  3012.       /* Don't let this be an lvalue.  */
  3013.       if (lvalue_p (TREE_OPERAND (arg, 0)))
  3014.         return non_lvalue (TREE_OPERAND (arg, 0));
  3015.       return TREE_OPERAND (arg, 0);
  3016.     }
  3017.  
  3018.       /* For &x[y], return x+y */
  3019.       if (TREE_CODE (arg) == ARRAY_REF)
  3020.     {
  3021.       if (mark_addressable (TREE_OPERAND (arg, 0)) == 0)
  3022.         return error_mark_node;
  3023.       return build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0),
  3024.                   TREE_OPERAND (arg, 1), 1);
  3025.     }
  3026.  
  3027.       /* Handle complex lvalues (when permitted)
  3028.      by reduction to simpler cases.  */
  3029.       val = unary_complex_lvalue (code, arg);
  3030.       if (val != 0)
  3031.     return val;
  3032.  
  3033. #if 0 /* Turned off because inconsistent;
  3034.      float f; *&(int)f = 3.4 stores in int format
  3035.      whereas (int)f = 3.4 stores in float format.  */
  3036.       /* Address of a cast is just a cast of the address
  3037.      of the operand of the cast.  */
  3038.       switch (TREE_CODE (arg))
  3039.     {
  3040.     case NOP_EXPR:
  3041.     case CONVERT_EXPR:
  3042.     case FLOAT_EXPR:
  3043.     case FIX_TRUNC_EXPR:
  3044.     case FIX_FLOOR_EXPR:
  3045.     case FIX_ROUND_EXPR:
  3046.     case FIX_CEIL_EXPR:
  3047.       if (pedantic)
  3048.         pedwarn ("ANSI C forbids the address of a cast expression");
  3049.       return convert (build_pointer_type (TREE_TYPE (arg)),
  3050.               build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0),
  3051.                       0));
  3052.     }
  3053. #endif
  3054.  
  3055.       /* Allow the address of a constructor if all the elements
  3056.      are constant.  */
  3057.       if (TREE_CODE (arg) == CONSTRUCTOR && TREE_CONSTANT (arg))
  3058.     ;
  3059.       /* Anything not already handled and not a true memory reference
  3060.      is an error.  */
  3061.       else if (typecode != FUNCTION_TYPE && !lvalue_or_else (arg, "unary `&'"))
  3062.     return error_mark_node;
  3063.  
  3064.       /* Ordinary case; arg is a COMPONENT_REF or a decl.  */
  3065.       argtype = TREE_TYPE (arg);
  3066.       /* If the lvalue is const or volatile,
  3067.      merge that into the type that the address will point to.  */
  3068.       if (TREE_CODE_CLASS (TREE_CODE (arg)) == 'd'
  3069.       || TREE_CODE_CLASS (TREE_CODE (arg)) == 'r')
  3070.     {
  3071.       if (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg))
  3072.         argtype = c_build_type_variant (argtype,
  3073.                         TREE_READONLY (arg),
  3074.                         TREE_THIS_VOLATILE (arg));
  3075.     }
  3076.  
  3077.       argtype = build_pointer_type (argtype);
  3078.  
  3079.       if (mark_addressable (arg) == 0)
  3080.     return error_mark_node;
  3081.  
  3082.       {
  3083.     tree addr;
  3084.  
  3085.     if (TREE_CODE (arg) == COMPONENT_REF)
  3086.       {
  3087.         tree field = TREE_OPERAND (arg, 1);
  3088.  
  3089.         addr = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0), 0);
  3090.  
  3091.         if (DECL_BIT_FIELD (field))
  3092.           {
  3093.         error ("attempt to take address of bit-field structure member `%s'",
  3094.                IDENTIFIER_POINTER (DECL_NAME (field)));
  3095.         return error_mark_node;
  3096.           }
  3097.  
  3098.         addr = convert (argtype, addr);
  3099.  
  3100.         if (! integer_zerop (DECL_FIELD_BITPOS (field)))
  3101.           {
  3102.         tree offset
  3103.           = size_binop (EASY_DIV_EXPR, DECL_FIELD_BITPOS (field),
  3104.                 size_int (BITS_PER_UNIT));
  3105.         int flag = TREE_CONSTANT (addr);
  3106.         addr = fold (build (PLUS_EXPR, argtype,
  3107.                     addr, convert (argtype, offset)));
  3108.         TREE_CONSTANT (addr) = flag;
  3109.           }
  3110.       }
  3111.     else
  3112.       addr = build1 (code, argtype, arg);
  3113.  
  3114.     /* Address of a static or external variable or
  3115.        file-scope function counts as a constant.  */
  3116.     if (staticp (arg)
  3117.         && ! (TREE_CODE (arg) == FUNCTION_DECL
  3118.           && DECL_CONTEXT (arg) != 0))
  3119.       TREE_CONSTANT (addr) = 1;
  3120.     return addr;
  3121.       }
  3122.     }
  3123.  
  3124.   if (!errstring)
  3125.     {
  3126.       if (argtype == 0)
  3127.     argtype = TREE_TYPE (arg);
  3128.       return fold (build1 (code, argtype, arg));
  3129.     }
  3130.  
  3131.   error (errstring);
  3132.   return error_mark_node;
  3133. }
  3134.  
  3135. #if 0
  3136. /* If CONVERSIONS is a conversion expression or a nested sequence of such,
  3137.    convert ARG with the same conversions in the same order
  3138.    and return the result.  */
  3139.  
  3140. static tree
  3141. convert_sequence (conversions, arg)
  3142.      tree conversions;
  3143.      tree arg;
  3144. {
  3145.   switch (TREE_CODE (conversions))
  3146.     {
  3147.     case NOP_EXPR:
  3148.     case CONVERT_EXPR:
  3149.     case FLOAT_EXPR:
  3150.     case FIX_TRUNC_EXPR:
  3151.     case FIX_FLOOR_EXPR:
  3152.     case FIX_ROUND_EXPR:
  3153.     case FIX_CEIL_EXPR:
  3154.       return convert (TREE_TYPE (conversions),
  3155.               convert_sequence (TREE_OPERAND (conversions, 0),
  3156.                     arg));
  3157.  
  3158.     default:
  3159.       return arg;
  3160.     }
  3161. }
  3162. #endif /* 0 */
  3163.  
  3164. /* Return nonzero if REF is an lvalue valid for this language.
  3165.    Lvalues can be assigned, unless their type has TYPE_READONLY.
  3166.    Lvalues can have their address taken, unless they have DECL_REGISTER.  */
  3167.  
  3168. int
  3169. lvalue_p (ref)
  3170.      tree ref;
  3171. {
  3172.   register enum tree_code code = TREE_CODE (ref);
  3173.  
  3174.   switch (code)
  3175.     {
  3176.     case REALPART_EXPR:
  3177.     case IMAGPART_EXPR:
  3178.     case COMPONENT_REF:
  3179.       return lvalue_p (TREE_OPERAND (ref, 0));
  3180.  
  3181.     case STRING_CST:
  3182.       return 1;
  3183.  
  3184.     case INDIRECT_REF:
  3185.     case ARRAY_REF:
  3186.     case VAR_DECL:
  3187.     case PARM_DECL:
  3188.     case RESULT_DECL:
  3189.     case ERROR_MARK:
  3190.       if (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
  3191.       && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
  3192.     return 1;
  3193.       break;
  3194.     }
  3195.   return 0;
  3196. }
  3197.  
  3198. /* Return nonzero if REF is an lvalue valid for this language;
  3199.    otherwise, print an error message and return zero.  */
  3200.  
  3201. int
  3202. lvalue_or_else (ref, string)
  3203.      tree ref;
  3204.      char *string;
  3205. {
  3206.   int win = lvalue_p (ref);
  3207.   if (! win)
  3208.     error ("invalid lvalue in %s", string);
  3209.   return win;
  3210. }
  3211.  
  3212. /* Apply unary lvalue-demanding operator CODE to the expression ARG
  3213.    for certain kinds of expressions which are not really lvalues
  3214.    but which we can accept as lvalues.
  3215.  
  3216.    If ARG is not a kind of expression we can handle, return zero.  */
  3217.    
  3218. static tree
  3219. unary_complex_lvalue (code, arg)
  3220.      enum tree_code code;
  3221.      tree arg;
  3222. {
  3223.   /* Handle (a, b) used as an "lvalue".  */
  3224.   if (TREE_CODE (arg) == COMPOUND_EXPR)
  3225.     {
  3226.       tree real_result = build_unary_op (code, TREE_OPERAND (arg, 1), 0);
  3227.       pedantic_lvalue_warning (COMPOUND_EXPR);
  3228.       return build (COMPOUND_EXPR, TREE_TYPE (real_result),
  3229.             TREE_OPERAND (arg, 0), real_result);
  3230.     }
  3231.  
  3232.   /* Handle (a ? b : c) used as an "lvalue".  */
  3233.   if (TREE_CODE (arg) == COND_EXPR)
  3234.     {
  3235.       pedantic_lvalue_warning (COND_EXPR);
  3236.       return (build_conditional_expr
  3237.           (TREE_OPERAND (arg, 0),
  3238.            build_unary_op (code, TREE_OPERAND (arg, 1), 0),
  3239.            build_unary_op (code, TREE_OPERAND (arg, 2), 0)));
  3240.     }
  3241.  
  3242.   return 0;
  3243. }
  3244.  
  3245. /* If pedantic, warn about improper lvalue.   CODE is either COND_EXPR
  3246.    COMPOUND_EXPR, or CONVERT_EXPR (for casts).  */
  3247.  
  3248. static void
  3249. pedantic_lvalue_warning (code)
  3250.      enum tree_code code;
  3251. {
  3252.   if (pedantic)
  3253.     pedwarn ("ANSI C forbids use of %s expressions as lvalues",
  3254.          code == COND_EXPR ? "conditional"
  3255.          : code == COMPOUND_EXPR ? "compound" : "cast");
  3256. }
  3257.  
  3258. /* Warn about storing in something that is `const'.  */
  3259.  
  3260. void
  3261. readonly_warning (arg, string)
  3262.      tree arg;
  3263.      char *string;
  3264. {
  3265.   char buf[80];
  3266.   strcpy (buf, string);
  3267.  
  3268.   /* Forbid assignments to iterators.  */
  3269.   if (TREE_CODE (arg) == VAR_DECL && ITERATOR_P (arg))
  3270.     {
  3271.       strcat (buf, " of iterator `%s'");
  3272.       pedwarn (buf, IDENTIFIER_POINTER (DECL_NAME (arg)));
  3273.     }
  3274.  
  3275.   if (TREE_CODE (arg) == COMPONENT_REF)
  3276.     {
  3277.       if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
  3278.     readonly_warning (TREE_OPERAND (arg, 0), string);
  3279.       else
  3280.     {
  3281.       strcat (buf, " of read-only member `%s'");
  3282.       pedwarn (buf, IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (arg, 1))));
  3283.     }
  3284.     }
  3285.   else if (TREE_CODE (arg) == VAR_DECL)
  3286.     {
  3287.       strcat (buf, " of read-only variable `%s'");
  3288.       pedwarn (buf, IDENTIFIER_POINTER (DECL_NAME (arg)));
  3289.     }
  3290.   else
  3291.     {
  3292.       pedwarn ("%s of read-only location", buf);
  3293.     }
  3294. }
  3295.  
  3296. /* Mark EXP saying that we need to be able to take the
  3297.    address of it; it should not be allocated in a register.
  3298.    Value is 1 if successful.  */
  3299.  
  3300. int
  3301. mark_addressable (exp)
  3302.      tree exp;
  3303. {
  3304.   register tree x = exp;
  3305.   while (1)
  3306.     switch (TREE_CODE (x))
  3307.       {
  3308.       case ADDR_EXPR:
  3309.       case COMPONENT_REF:
  3310.       case ARRAY_REF:
  3311.       case REALPART_EXPR:
  3312.       case IMAGPART_EXPR:
  3313.     x = TREE_OPERAND (x, 0);
  3314.     break;
  3315.  
  3316.       case CONSTRUCTOR:
  3317.     TREE_ADDRESSABLE (x) = 1;
  3318.     return 1;
  3319.  
  3320.       case VAR_DECL:
  3321.       case CONST_DECL:
  3322.       case PARM_DECL:
  3323.       case RESULT_DECL:
  3324.     if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
  3325.         && DECL_NONLOCAL (x))
  3326.       {
  3327.         if (TREE_PUBLIC (x))
  3328.           {
  3329.         error ("global register variable `%s' used in nested function",
  3330.                IDENTIFIER_POINTER (DECL_NAME (x)));
  3331.         return 0;
  3332.           }
  3333.         pedwarn ("register variable `%s' used in nested function",
  3334.              IDENTIFIER_POINTER (DECL_NAME (x)));
  3335.       }
  3336.     else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
  3337.       {
  3338.         if (TREE_PUBLIC (x))
  3339.           {
  3340.         error ("address of global register variable `%s' requested",
  3341.                IDENTIFIER_POINTER (DECL_NAME (x)));
  3342.         return 0;
  3343.           }
  3344.  
  3345.         /* If we are making this addressable due to its having
  3346.            volatile components, give a different error message.  Also
  3347.            handle the case of an unnamed parameter by not trying
  3348.            to give the name.  */
  3349.  
  3350.         else if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (x)))
  3351.           {
  3352.         error ("cannot put object with volatile field into register");
  3353.         return 0;
  3354.           }
  3355.  
  3356.         pedwarn ("address of register variable `%s' requested",
  3357.              IDENTIFIER_POINTER (DECL_NAME (x)));
  3358.       }
  3359.     put_var_into_stack (x);
  3360.  
  3361.     /* drops in */
  3362.       case FUNCTION_DECL:
  3363.     TREE_ADDRESSABLE (x) = 1;
  3364. #if 0  /* poplevel deals with this now.  */
  3365.     if (DECL_CONTEXT (x) == 0)
  3366.       TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
  3367. #endif
  3368.  
  3369.       default:
  3370.     return 1;
  3371.     }
  3372. }
  3373.  
  3374. /* Build and return a conditional expression IFEXP ? OP1 : OP2.  */
  3375.  
  3376. tree
  3377. build_conditional_expr (ifexp, op1, op2)
  3378.      tree ifexp, op1, op2;
  3379. {
  3380.   register tree type1;
  3381.   register tree type2;
  3382.   register enum tree_code code1;
  3383.   register enum tree_code code2;
  3384.   register tree result_type = NULL;
  3385.   tree orig_op1 = op1, orig_op2 = op2;
  3386.  
  3387.   /* If second operand is omitted, it is the same as the first one;
  3388.      make sure it is calculated only once.  */
  3389.   if (op1 == 0)
  3390.     {
  3391.       if (pedantic)
  3392.     pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
  3393.       ifexp = op1 = save_expr (ifexp);
  3394.     }
  3395.  
  3396.   ifexp = truthvalue_conversion (default_conversion (ifexp));
  3397.  
  3398. #if 0 /* Produces wrong result if within sizeof.  */
  3399.   /* Don't promote the operands separately if they promote
  3400.      the same way.  Return the unpromoted type and let the combined
  3401.      value get promoted if necessary.  */
  3402.  
  3403.   if (TREE_TYPE (op1) == TREE_TYPE (op2)
  3404.       && TREE_CODE (TREE_TYPE (op1)) != ARRAY_TYPE
  3405.       && TREE_CODE (TREE_TYPE (op1)) != ENUMERAL_TYPE
  3406.       && TREE_CODE (TREE_TYPE (op1)) != FUNCTION_TYPE)
  3407.     {
  3408.       if (TREE_CODE (ifexp) == INTEGER_CST)
  3409.     return pedantic_non_lvalue (integer_zerop (ifexp) ? op2 : op1);
  3410.  
  3411.       return fold (build (COND_EXPR, TREE_TYPE (op1), ifexp, op1, op2));
  3412.     }
  3413. #endif
  3414.  
  3415.   /* Promote both alternatives.  */
  3416.  
  3417.   if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE)
  3418.     op1 = default_conversion (op1);
  3419.   if (TREE_CODE (TREE_TYPE (op2)) != VOID_TYPE)
  3420.     op2 = default_conversion (op2);
  3421.  
  3422.   if (TREE_CODE (ifexp) == ERROR_MARK
  3423.       || TREE_CODE (TREE_TYPE (op1)) == ERROR_MARK
  3424.       || TREE_CODE (TREE_TYPE (op2)) == ERROR_MARK)
  3425.     return error_mark_node;
  3426.  
  3427.   type1 = TREE_TYPE (op1);
  3428.   code1 = TREE_CODE (type1);
  3429.   type2 = TREE_TYPE (op2);
  3430.   code2 = TREE_CODE (type2);
  3431.       
  3432.   /* Quickly detect the usual case where op1 and op2 have the same type
  3433.      after promotion.  */
  3434.   if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))
  3435.     {
  3436.       if (type1 == type2)
  3437.     result_type = type1;
  3438.       else
  3439.     result_type = TYPE_MAIN_VARIANT (type1);
  3440.     }
  3441.   else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE)
  3442.            && (code2 == INTEGER_TYPE || code2 == REAL_TYPE))
  3443.     {
  3444.       result_type = common_type (type1, type2);
  3445.     }
  3446.   else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
  3447.     {
  3448.       if (pedantic && (code1 != VOID_TYPE || code2 != VOID_TYPE))
  3449.     pedwarn ("ANSI C forbids conditional expr with only one void side");
  3450.       result_type = void_type_node;
  3451.     }
  3452.   else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
  3453.     {
  3454.       if (comp_target_types (type1, type2))
  3455.     result_type = common_type (type1, type2);
  3456.       else if (integer_zerop (op1) && TREE_TYPE (type1) == void_type_node
  3457.            && TREE_CODE (orig_op1) != NOP_EXPR)
  3458.     result_type = qualify_type (type2, type1);
  3459.       else if (integer_zerop (op2) && TREE_TYPE (type2) == void_type_node
  3460.            && TREE_CODE (orig_op2) != NOP_EXPR)
  3461.     result_type = qualify_type (type1, type2);
  3462.       else if (TYPE_MAIN_VARIANT (TREE_TYPE (type1)) == void_type_node)
  3463.     {
  3464.       if (pedantic && TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
  3465.         pedwarn ("ANSI C forbids conditional expr between `void *' and function pointer");
  3466.       result_type = qualify_type (type1, type2);
  3467.     }
  3468.       else if (TYPE_MAIN_VARIANT (TREE_TYPE (type2)) == void_type_node)
  3469.     {
  3470.       if (pedantic && TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)
  3471.         pedwarn ("ANSI C forbids conditional expr between `void *' and function pointer");
  3472.       result_type = qualify_type (type2, type1);
  3473.     }
  3474.       else
  3475.     {
  3476.       pedwarn ("pointer type mismatch in conditional expression");
  3477.       result_type = build_pointer_type (void_type_node);
  3478.     }
  3479.     }
  3480.   else if (code1 == POINTER_TYPE && code2 == INTEGER_TYPE)
  3481.     {
  3482.       if (! integer_zerop (op2))
  3483.     pedwarn ("pointer/integer type mismatch in conditional expression");
  3484.       else
  3485.     {
  3486.       op2 = null_pointer_node;
  3487. #if 0  /* The spec seems to say this is permitted.  */
  3488.       if (pedantic && TREE_CODE (type1) == FUNCTION_TYPE)
  3489.         pedwarn ("ANSI C forbids conditional expr between 0 and function pointer");
  3490. #endif
  3491.     }
  3492.       result_type = type1;
  3493.     }
  3494.   else if (code2 == POINTER_TYPE && code1 == INTEGER_TYPE)
  3495.     {
  3496.       if (!integer_zerop (op1))
  3497.     pedwarn ("pointer/integer type mismatch in conditional expression");
  3498.       else
  3499.     {
  3500.       op1 = null_pointer_node;
  3501. #if 0  /* The spec seems to say this is permitted.  */
  3502.       if (pedantic && TREE_CODE (type2) == FUNCTION_TYPE)
  3503.         pedwarn ("ANSI C forbids conditional expr between 0 and function pointer");
  3504. #endif
  3505.     }
  3506.       result_type = type2;
  3507.     }
  3508.  
  3509.   if (!result_type)
  3510.     {
  3511.       if (flag_cond_mismatch)
  3512.     result_type = void_type_node;
  3513.       else
  3514.     {
  3515.       error ("type mismatch in conditional expression");
  3516.       return error_mark_node;
  3517.     }
  3518.     }
  3519.  
  3520.   /* Merge const and volatile flags of the incoming types.  */
  3521.   result_type
  3522.     = build_type_variant (result_type,
  3523.               TREE_READONLY (op1) || TREE_READONLY (op2),
  3524.               TREE_THIS_VOLATILE (op1) || TREE_THIS_VOLATILE (op2));
  3525.  
  3526.   if (result_type != TREE_TYPE (op1))
  3527.     op1 = convert_and_check (result_type, op1);
  3528.   if (result_type != TREE_TYPE (op2))
  3529.     op2 = convert_and_check (result_type, op2);
  3530.     
  3531. #if 0
  3532.   if (code1 == RECORD_TYPE || code1 == UNION_TYPE)
  3533.     {
  3534.       result_type = TREE_TYPE (op1);
  3535.       if (TREE_CONSTANT (ifexp))
  3536.     return pedantic_non_lvalue (integer_zerop (ifexp) ? op2 : op1);
  3537.  
  3538.       if (TYPE_MODE (result_type) == BLKmode)
  3539.     {
  3540.       register tree tempvar
  3541.         = build_decl (VAR_DECL, NULL_TREE, result_type);
  3542.       register tree xop1 = build_modify_expr (tempvar, op1);
  3543.       register tree xop2 = build_modify_expr (tempvar, op2);
  3544.       register tree result = fold (build (COND_EXPR, result_type,
  3545.                           ifexp, xop1, xop2));
  3546.  
  3547.       layout_decl (tempvar, TYPE_ALIGN (result_type));
  3548.       /* No way to handle variable-sized objects here.
  3549.          I fear that the entire handling of BLKmode conditional exprs
  3550.          needs to be redone.  */
  3551.       if (TREE_CODE (DECL_SIZE (tempvar)) != INTEGER_CST)
  3552.         abort ();
  3553.       DECL_RTL (tempvar)
  3554.         = assign_stack_local (DECL_MODE (tempvar),
  3555.                   (TREE_INT_CST_LOW (DECL_SIZE (tempvar))
  3556.                    + BITS_PER_UNIT - 1)
  3557.                   / BITS_PER_UNIT,
  3558.                   0);
  3559.  
  3560.       TREE_SIDE_EFFECTS (result)
  3561.         = TREE_SIDE_EFFECTS (ifexp) | TREE_SIDE_EFFECTS (op1)
  3562.           | TREE_SIDE_EFFECTS (op2);
  3563.       return build (COMPOUND_EXPR, result_type, result, tempvar);
  3564.     }
  3565.     }
  3566. #endif /* 0 */
  3567.     
  3568.   if (TREE_CODE (ifexp) == INTEGER_CST)
  3569.     return pedantic_non_lvalue (integer_zerop (ifexp) ? op2 : op1);
  3570.  
  3571.   return fold (build (COND_EXPR, result_type, ifexp, op1, op2));
  3572. }
  3573.  
  3574. /* Given a list of expressions, return a compound expression
  3575.    that performs them all and returns the value of the last of them.  */
  3576.  
  3577. tree
  3578. build_compound_expr (list)
  3579.      tree list;
  3580. {
  3581.   return internal_build_compound_expr (list, TRUE);
  3582. }
  3583.  
  3584. static tree
  3585. internal_build_compound_expr (list, first_p)
  3586.      tree list;
  3587.      int first_p;
  3588. {
  3589.   register tree rest;
  3590.  
  3591.   if (TREE_CHAIN (list) == 0)
  3592.     {
  3593. #if 0 /* If something inside inhibited lvalueness, we should not override.  */
  3594.       /* Consider (x, y+0), which is not an lvalue since y+0 is not.  */
  3595.  
  3596.       /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
  3597.       if (TREE_CODE (list) == NON_LVALUE_EXPR)
  3598.     list = TREE_OPERAND (list, 0);
  3599. #endif
  3600.  
  3601.       /* Don't let (0, 0) be null pointer constant.  */
  3602.       if (!first_p && integer_zerop (TREE_VALUE (list)))
  3603.     return non_lvalue (TREE_VALUE (list));
  3604.       return TREE_VALUE (list);
  3605.     }
  3606.  
  3607.   if (TREE_CHAIN (list) != 0 && TREE_CHAIN (TREE_CHAIN (list)) == 0)
  3608.     {
  3609.       /* Convert arrays to pointers when there really is a comma operator.  */
  3610.       if (TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (list)))) == ARRAY_TYPE)
  3611.     TREE_VALUE (TREE_CHAIN (list))
  3612.       = default_conversion (TREE_VALUE (TREE_CHAIN (list)));
  3613.     }
  3614.  
  3615.   rest = internal_build_compound_expr (TREE_CHAIN (list), FALSE);
  3616.  
  3617.   if (! TREE_SIDE_EFFECTS (TREE_VALUE (list)))
  3618.     {
  3619.       /* The left-hand operand of a comma expression is like an expression
  3620.          statement: with -W or -Wunused, we should warn if it doesn't have
  3621.      any side-effects, unless it was explicitly cast to (void).  */
  3622.       if ((extra_warnings || warn_unused)
  3623.            && ! (TREE_CODE (TREE_VALUE (list)) == CONVERT_EXPR
  3624.                 && TREE_TYPE (TREE_VALUE (list)) == void_type_node))
  3625.         warning ("left-hand operand of comma expression has no effect");
  3626.  
  3627.       /* When pedantic, a compound expression can be neither an lvalue
  3628.          nor an integer constant expression.  */
  3629.       if (! pedantic)
  3630.         return rest;
  3631.     }
  3632.  
  3633.   /* With -Wunused, we should also warn if the left-hand operand does have
  3634.      side-effects, but computes a value which is not used.  For example, in
  3635.      `foo() + bar(), baz()' the result of the `+' operator is not used,
  3636.      so we should issue a warning.  */
  3637.   else if (warn_unused)
  3638.     warn_if_unused_value (TREE_VALUE (list));
  3639.  
  3640.   return build (COMPOUND_EXPR, TREE_TYPE (rest), TREE_VALUE (list), rest);
  3641. }
  3642.  
  3643. /* Build an expression representing a cast to type TYPE of expression EXPR.  */
  3644.  
  3645. tree
  3646. build_c_cast (type, expr)
  3647.      register tree type;
  3648.      tree expr;
  3649. {
  3650.   register tree value = expr;
  3651.   
  3652.   if (type == error_mark_node || expr == error_mark_node)
  3653.     return error_mark_node;
  3654.  
  3655.   if (TREE_CODE (type) != POINTER_TYPE
  3656.       || !is_protocol_qualified_id (type))
  3657.     type = TYPE_MAIN_VARIANT (type);
  3658.  
  3659. #if 0
  3660.   /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
  3661.   if (TREE_CODE (value) == NON_LVALUE_EXPR)
  3662.     value = TREE_OPERAND (value, 0);
  3663. #endif
  3664.  
  3665.   if (TREE_CODE (type) == ARRAY_TYPE)
  3666.     {
  3667.       error ("cast specifies array type");
  3668.       return error_mark_node;
  3669.     }
  3670.  
  3671.   if (TREE_CODE (type) == FUNCTION_TYPE)
  3672.     {
  3673.       error ("cast specifies function type");
  3674.       return error_mark_node;
  3675.     }
  3676.  
  3677.   if (type == TREE_TYPE (value))
  3678.     {
  3679.       if (pedantic)
  3680.     {
  3681.       if (TREE_CODE (type) == RECORD_TYPE
  3682.           || TREE_CODE (type) == UNION_TYPE)
  3683.         pedwarn ("ANSI C forbids casting nonscalar to the same type");
  3684.     }
  3685.     }
  3686.   else if (TREE_CODE (type) == UNION_TYPE)
  3687.     {
  3688.       tree field;
  3689.       if (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
  3690.       || TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE)
  3691.     value = default_conversion (value);
  3692.  
  3693.       for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
  3694.     if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
  3695.                TYPE_MAIN_VARIANT (TREE_TYPE (value))))
  3696.       break;
  3697.  
  3698.       if (field)
  3699.     {
  3700.       char *name;
  3701.       tree t;
  3702.  
  3703.       if (pedantic)
  3704.         pedwarn ("ANSI C forbids casts to union type");
  3705.       if (TYPE_NAME (type) != 0)
  3706.         {
  3707.           if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
  3708.         name = IDENTIFIER_POINTER (TYPE_NAME (type));
  3709.           else
  3710.         name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
  3711.         }
  3712.       else
  3713.         name = "";
  3714.       t = digest_init (type, build (CONSTRUCTOR, type, NULL_TREE,
  3715.                     build_tree_list (field, value)),
  3716.                0, 0);
  3717.       TREE_CONSTANT (t) = TREE_CONSTANT (value);
  3718.       return t;
  3719.     }
  3720.       error ("cast to union type from type not present in union");
  3721.       return error_mark_node;
  3722.     }
  3723.   else
  3724.     {
  3725.       tree otype, ovalue;
  3726.  
  3727.       /* If casting to void, avoid the error that would come
  3728.      from default_conversion in the case of a non-lvalue array.  */
  3729.       if (type == void_type_node)
  3730.     return build1 (CONVERT_EXPR, type, value);
  3731.  
  3732.       /* Convert functions and arrays to pointers,
  3733.      but don't convert any other types.  */
  3734.       if (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE
  3735.       || TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE)
  3736.     value = default_conversion (value);
  3737.       otype = TREE_TYPE (value);
  3738.  
  3739.       /* Optionally warn about potentially worrisome casts.  */
  3740.  
  3741.       if (warn_cast_qual
  3742.       && TREE_CODE (type) == POINTER_TYPE
  3743.       && TREE_CODE (otype) == POINTER_TYPE)
  3744.     {
  3745.       if (TYPE_VOLATILE (TREE_TYPE (otype))
  3746.           && ! TYPE_VOLATILE (TREE_TYPE (type)))
  3747.         pedwarn ("cast discards `volatile' from pointer target type");
  3748.       if (TYPE_READONLY (TREE_TYPE (otype))
  3749.           && ! TYPE_READONLY (TREE_TYPE (type)))
  3750.         pedwarn ("cast discards `const' from pointer target type");
  3751.     }
  3752.  
  3753.       /* Warn about possible alignment problems.  */
  3754.       if (STRICT_ALIGNMENT && warn_cast_align
  3755.       && TREE_CODE (type) == POINTER_TYPE
  3756.       && TREE_CODE (otype) == POINTER_TYPE
  3757.       && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
  3758.       && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
  3759.       && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype)))
  3760.     warning ("cast increases required alignment of target type");
  3761.  
  3762.       if (TREE_CODE (type) == INTEGER_TYPE
  3763.       && TREE_CODE (otype) == POINTER_TYPE
  3764.       && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
  3765.       && !TREE_CONSTANT (value))
  3766.     warning ("cast from pointer to integer of different size");
  3767.  
  3768.       if (warn_bad_function_cast
  3769.       && TREE_CODE (value) == CALL_EXPR
  3770.       && TREE_CODE (type) != TREE_CODE (otype))
  3771.     warning ("cast does not match function type");
  3772.  
  3773.       if (TREE_CODE (type) == POINTER_TYPE
  3774.       && TREE_CODE (otype) == INTEGER_TYPE
  3775.       && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
  3776. #if 0
  3777.       /* Don't warn about converting 0 to pointer,
  3778.          provided the 0 was explicit--not cast or made by folding.  */
  3779.       && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value))
  3780. #endif
  3781.       /* Don't warn about converting any constant.  */
  3782.       && !TREE_CONSTANT (value))
  3783.     warning ("cast to pointer from integer of different size");
  3784.  
  3785.       ovalue = value;
  3786.       value = convert (type, value);
  3787.  
  3788.       /* Ignore any integer overflow caused by the cast.  */
  3789.       if (TREE_CODE (value) == INTEGER_CST)
  3790.     {
  3791.       TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
  3792.       TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
  3793.     }
  3794.     }
  3795.  
  3796.   /* Pedantically, don't ley (void *) (FOO *) 0 be a null pointer constant.  */
  3797.   if (pedantic && TREE_CODE (value) == INTEGER_CST
  3798.       && TREE_CODE (expr) == INTEGER_CST
  3799.       && TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE)
  3800.     value = non_lvalue (value);
  3801.  
  3802.   /* If pedantic, don't let a cast be an lvalue.  */
  3803.   if (value == expr && pedantic)
  3804.     value = non_lvalue (value);
  3805.  
  3806.   return value;
  3807. }
  3808.  
  3809. /* Build an assignment expression of lvalue LHS from value RHS.
  3810.    MODIFYCODE is the code for a binary operator that we use
  3811.    to combine the old value of LHS with RHS to get the new value.
  3812.    Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.  */
  3813.  
  3814. tree
  3815. build_modify_expr (lhs, modifycode, rhs)
  3816.      tree lhs, rhs;
  3817.      enum tree_code modifycode;
  3818. {
  3819.   register tree result;
  3820.   tree newrhs;
  3821.   tree lhstype = TREE_TYPE (lhs);
  3822.   tree olhstype = lhstype;
  3823.  
  3824.   /* Types that aren't fully specified cannot be used in assignments.  */
  3825.   lhs = require_complete_type (lhs);
  3826.  
  3827.   /* Avoid duplicate error messages from operands that had errors.  */
  3828.   if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
  3829.     return error_mark_node;
  3830.  
  3831.   /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
  3832.   /* Do not use STRIP_NOPS here.  We do not want an enumerator
  3833.      whose value is 0 to count as a null pointer constant.  */
  3834.   if (TREE_CODE (rhs) == NON_LVALUE_EXPR)
  3835.     rhs = TREE_OPERAND (rhs, 0);
  3836.  
  3837.   newrhs = rhs;
  3838.  
  3839.   /* Handle control structure constructs used as "lvalues".  */
  3840.  
  3841.   switch (TREE_CODE (lhs))
  3842.     {
  3843.       /* Handle (a, b) used as an "lvalue".  */
  3844.     case COMPOUND_EXPR:
  3845.       pedantic_lvalue_warning (COMPOUND_EXPR);
  3846.       newrhs = build_modify_expr (TREE_OPERAND (lhs, 1),
  3847.                   modifycode, rhs);
  3848.       if (TREE_CODE (newrhs) == ERROR_MARK)
  3849.     return error_mark_node;
  3850.       return build (COMPOUND_EXPR, lhstype,
  3851.             TREE_OPERAND (lhs, 0), newrhs);
  3852.  
  3853.       /* Handle (a ? b : c) used as an "lvalue".  */
  3854.     case COND_EXPR:
  3855.       pedantic_lvalue_warning (COND_EXPR);
  3856.       rhs = save_expr (rhs);
  3857.       {
  3858.     /* Produce (a ? (b = rhs) : (c = rhs))
  3859.        except that the RHS goes through a save-expr
  3860.        so the code to compute it is only emitted once.  */
  3861.     tree cond
  3862.       = build_conditional_expr (TREE_OPERAND (lhs, 0),
  3863.                     build_modify_expr (TREE_OPERAND (lhs, 1),
  3864.                                modifycode, rhs),
  3865.                     build_modify_expr (TREE_OPERAND (lhs, 2),
  3866.                                modifycode, rhs));
  3867.     if (TREE_CODE (cond) == ERROR_MARK)
  3868.       return cond;
  3869.     /* Make sure the code to compute the rhs comes out
  3870.        before the split.  */
  3871.     return build (COMPOUND_EXPR, TREE_TYPE (lhs),
  3872.               /* But cast it to void to avoid an "unused" error.  */
  3873.               convert (void_type_node, rhs), cond);
  3874.       }
  3875.     }
  3876.  
  3877.   /* If a binary op has been requested, combine the old LHS value with the RHS
  3878.      producing the value we should actually store into the LHS.  */
  3879.  
  3880.   if (modifycode != NOP_EXPR)
  3881.     {
  3882.       lhs = stabilize_reference (lhs);
  3883.       newrhs = build_binary_op (modifycode, lhs, rhs, 1);
  3884.     }
  3885.  
  3886.   /* Handle a cast used as an "lvalue".
  3887.      We have already performed any binary operator using the value as cast.
  3888.      Now convert the result to the cast type of the lhs,
  3889.      and then true type of the lhs and store it there;
  3890.      then convert result back to the cast type to be the value
  3891.      of the assignment.  */
  3892.  
  3893.   switch (TREE_CODE (lhs))
  3894.     {
  3895.     case NOP_EXPR:
  3896.     case CONVERT_EXPR:
  3897.     case FLOAT_EXPR:
  3898.     case FIX_TRUNC_EXPR:
  3899.     case FIX_FLOOR_EXPR:
  3900.     case FIX_ROUND_EXPR:
  3901.     case FIX_CEIL_EXPR:
  3902.       if (TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE
  3903.       || TREE_CODE (TREE_TYPE (newrhs)) == FUNCTION_TYPE)
  3904.     newrhs = default_conversion (newrhs);
  3905.       {
  3906.     tree inner_lhs = TREE_OPERAND (lhs, 0);
  3907.     tree result;
  3908.     result = build_modify_expr (inner_lhs, NOP_EXPR,
  3909.                     convert (TREE_TYPE (inner_lhs),
  3910.                          convert (lhstype, newrhs)));
  3911.     if (TREE_CODE (result) == ERROR_MARK)
  3912.       return result;
  3913.     pedantic_lvalue_warning (CONVERT_EXPR);
  3914.     return convert (TREE_TYPE (lhs), result);
  3915.       }
  3916.     }
  3917.  
  3918.   /* Now we have handled acceptable kinds of LHS that are not truly lvalues.
  3919.      Reject anything strange now.  */
  3920.  
  3921.   if (!lvalue_or_else (lhs, "assignment"))
  3922.     return error_mark_node;
  3923.  
  3924.   /* Warn about storing in something that is `const'.  */
  3925.  
  3926.   if (TREE_READONLY (lhs) || TYPE_READONLY (lhstype)
  3927.       || ((TREE_CODE (lhstype) == RECORD_TYPE
  3928.        || TREE_CODE (lhstype) == UNION_TYPE)
  3929.       && C_TYPE_FIELDS_READONLY (lhstype)))
  3930.     readonly_warning (lhs, "assignment");
  3931.  
  3932.   /* If storing into a structure or union member,
  3933.      it has probably been given type `int'.
  3934.      Compute the type that would go with
  3935.      the actual amount of storage the member occupies.  */
  3936.  
  3937.   if (TREE_CODE (lhs) == COMPONENT_REF
  3938.       && (TREE_CODE (lhstype) == INTEGER_TYPE
  3939.       || TREE_CODE (lhstype) == REAL_TYPE
  3940.       || TREE_CODE (lhstype) == ENUMERAL_TYPE))
  3941.     lhstype = TREE_TYPE (get_unwidened (lhs, 0));
  3942.  
  3943.   /* If storing in a field that is in actuality a short or narrower than one,
  3944.      we must store in the field in its actual type.  */
  3945.  
  3946.   if (lhstype != TREE_TYPE (lhs))
  3947.     {
  3948.       lhs = copy_node (lhs);
  3949.       TREE_TYPE (lhs) = lhstype;
  3950.     }
  3951.  
  3952.   /* Convert new value to destination type.  */
  3953.  
  3954.   newrhs = convert_for_assignment (lhstype, newrhs, "assignment",
  3955.                    NULL_TREE, NULL_TREE, 0);
  3956.   if (TREE_CODE (newrhs) == ERROR_MARK)
  3957.     return error_mark_node;
  3958.  
  3959.   result = build (MODIFY_EXPR, lhstype, lhs, newrhs);
  3960.   TREE_SIDE_EFFECTS (result) = 1;
  3961.  
  3962.   /* If we got the LHS in a different type for storing in,
  3963.      convert the result back to the nominal type of LHS
  3964.      so that the value we return always has the same type
  3965.      as the LHS argument.  */
  3966.  
  3967.   if (olhstype == TREE_TYPE (result))
  3968.     return result;
  3969.   return convert_for_assignment (olhstype, result, "assignment",
  3970.                  NULL_TREE, NULL_TREE, 0);
  3971. }
  3972.  
  3973. /* Convert value RHS to type TYPE as preparation for an assignment
  3974.    to an lvalue of type TYPE.
  3975.    The real work of conversion is done by `convert'.
  3976.    The purpose of this function is to generate error messages
  3977.    for assignments that are not allowed in C.
  3978.    ERRTYPE is a string to use in error messages:
  3979.    "assignment", "return", etc.  If it is null, this is parameter passing
  3980.    for a function call (and different error messages are output).  Otherwise,
  3981.    it may be a name stored in the spelling stack and interpreted by
  3982.    get_spelling.
  3983.  
  3984.    FUNNAME is the name of the function being called,
  3985.    as an IDENTIFIER_NODE, or null.
  3986.    PARMNUM is the number of the argument, for printing in error messages.  */
  3987.  
  3988. static tree
  3989. convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
  3990.      tree type, rhs;
  3991.      char *errtype;
  3992.      tree fundecl, funname;
  3993.      int parmnum;
  3994. {
  3995.   register enum tree_code codel = TREE_CODE (type);
  3996.   register tree rhstype;
  3997.   register enum tree_code coder;
  3998.  
  3999.   /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
  4000.   /* Do not use STRIP_NOPS here.  We do not want an enumerator
  4001.      whose value is 0 to count as a null pointer constant.  */
  4002.   if (TREE_CODE (rhs) == NON_LVALUE_EXPR)
  4003.     rhs = TREE_OPERAND (rhs, 0);
  4004.  
  4005.   if (TREE_CODE (TREE_TYPE (rhs)) == ARRAY_TYPE
  4006.       || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE)
  4007.     rhs = default_conversion (rhs);
  4008.   else if (optimize && TREE_CODE (rhs) == VAR_DECL)
  4009.     rhs = decl_constant_value (rhs);
  4010.  
  4011.   rhstype = TREE_TYPE (rhs);
  4012.   coder = TREE_CODE (rhstype);
  4013.  
  4014.   if (coder == ERROR_MARK)
  4015.     return error_mark_node;
  4016.  
  4017.   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
  4018.     {
  4019.       overflow_warning (rhs);
  4020.       /* Check for Objective-C protocols.  This will issue a warning if
  4021.      there are protocol violations.  No need to use the return value.  */
  4022.       maybe_objc_comptypes (type, rhstype, 0);
  4023.       return rhs;
  4024.     }
  4025.  
  4026.   if (coder == VOID_TYPE)
  4027.     {
  4028.       error ("void value not ignored as it ought to be");
  4029.       return error_mark_node;
  4030.     }
  4031.   /* Arithmetic types all interconvert, and enum is treated like int.  */
  4032.   if ((codel == INTEGER_TYPE || codel == REAL_TYPE || codel == ENUMERAL_TYPE
  4033.        || codel == COMPLEX_TYPE)
  4034.       && (coder == INTEGER_TYPE || coder == REAL_TYPE || coder == ENUMERAL_TYPE
  4035.       || coder == COMPLEX_TYPE))
  4036.     return convert_and_check (type, rhs);
  4037.  
  4038.   /* Conversion to a union from its member types.  */
  4039.   else if (codel == UNION_TYPE)
  4040.     {
  4041.       tree memb_types;
  4042.  
  4043.       for (memb_types = TYPE_FIELDS (type); memb_types;
  4044.        memb_types = TREE_CHAIN (memb_types))
  4045.     {
  4046.       if (comptypes (TREE_TYPE (memb_types), TREE_TYPE (rhs)))
  4047.         {
  4048.           if (pedantic
  4049.           && !(fundecl != 0 && DECL_IN_SYSTEM_HEADER (fundecl)))
  4050.         pedwarn ("ANSI C prohibits argument conversion to union type");
  4051.           return build1 (NOP_EXPR, type, rhs);
  4052.         }
  4053.  
  4054.       else if (coder == POINTER_TYPE
  4055.            && TREE_CODE (TREE_TYPE (memb_types)) == POINTER_TYPE)
  4056.         {
  4057.           tree memb_type = TREE_TYPE (memb_types);
  4058.           register tree ttl = TREE_TYPE (memb_type);
  4059.           register tree ttr = TREE_TYPE (rhstype);
  4060.  
  4061.           /* Any non-function converts to a [const][volatile] void *
  4062.          and vice versa; otherwise, targets must be the same.
  4063.          Meanwhile, the lhs target must have all the qualifiers of
  4064.          the rhs.  */
  4065.           if (TYPE_MAIN_VARIANT (ttl) == void_type_node
  4066.           || TYPE_MAIN_VARIANT (ttr) == void_type_node
  4067.           || comp_target_types (memb_type, rhstype))
  4068.         {
  4069.           /* Const and volatile mean something different for function
  4070.              types, so the usual warnings are not appropriate.  */
  4071.           if (TREE_CODE (ttr) != FUNCTION_TYPE
  4072.               || TREE_CODE (ttl) != FUNCTION_TYPE)
  4073.             {
  4074.               if (! TYPE_READONLY (ttl) && TYPE_READONLY (ttr))
  4075.             warn_for_assignment ("%s discards `const' from pointer target type",
  4076.                          get_spelling (errtype), funname,
  4077.                          parmnum);
  4078.               if (! TYPE_VOLATILE (ttl) && TYPE_VOLATILE (ttr))
  4079.             warn_for_assignment ("%s discards `volatile' from pointer target type",
  4080.                          get_spelling (errtype), funname,
  4081.                          parmnum);
  4082.             }
  4083.           else
  4084.             {
  4085.               /* Because const and volatile on functions are
  4086.              restrictions that say the function will not do
  4087.              certain things, it is okay to use a const or volatile
  4088.              function where an ordinary one is wanted, but not
  4089.              vice-versa.  */
  4090.               if (TYPE_READONLY (ttl) && ! TYPE_READONLY (ttr))
  4091.             warn_for_assignment ("%s makes `const *' function pointer from non-const",
  4092.                          get_spelling (errtype), funname,
  4093.                          parmnum);
  4094.               if (TYPE_VOLATILE (ttl) && ! TYPE_VOLATILE (ttr))
  4095.             warn_for_assignment ("%s makes `volatile *' function pointer from non-volatile",
  4096.                          get_spelling (errtype), funname,
  4097.                          parmnum);
  4098.             }
  4099.  
  4100.           if (pedantic
  4101.               && !(fundecl != 0 && DECL_IN_SYSTEM_HEADER (fundecl)))
  4102.             pedwarn ("ANSI C prohibits argument conversion to union type");
  4103.           return build1 (NOP_EXPR, type, rhs);
  4104.         }
  4105.         }
  4106.  
  4107.       /* Can convert integer zero to any pointer type.  */
  4108.       else if (TREE_CODE (TREE_TYPE (memb_types)) == POINTER_TYPE
  4109.            && (integer_zerop (rhs)
  4110.                || (TREE_CODE (rhs) == NOP_EXPR
  4111.                && integer_zerop (TREE_OPERAND (rhs, 0)))))
  4112.         return build1 (NOP_EXPR, type, null_pointer_node);
  4113.     }
  4114.     }
  4115.  
  4116.   /* Conversions among pointers */
  4117.   else if (codel == POINTER_TYPE && coder == POINTER_TYPE)
  4118.     {
  4119.       register tree ttl = TREE_TYPE (type);
  4120.       register tree ttr = TREE_TYPE (rhstype);
  4121.  
  4122.       /* Any non-function converts to a [const][volatile] void *
  4123.      and vice versa; otherwise, targets must be the same.
  4124.      Meanwhile, the lhs target must have all the qualifiers of the rhs.  */
  4125.       if (TYPE_MAIN_VARIANT (ttl) == void_type_node
  4126.       || TYPE_MAIN_VARIANT (ttr) == void_type_node
  4127.       || comp_target_types (type, rhstype)
  4128.       || (unsigned_type (TYPE_MAIN_VARIANT (ttl))
  4129.           == unsigned_type (TYPE_MAIN_VARIANT (ttr))))
  4130.     {
  4131.       if (pedantic
  4132.           && ((TYPE_MAIN_VARIANT (ttl) == void_type_node
  4133.            && TREE_CODE (ttr) == FUNCTION_TYPE)
  4134.           ||
  4135.           (TYPE_MAIN_VARIANT (ttr) == void_type_node
  4136.            /* Check TREE_CODE to catch cases like (void *) (char *) 0
  4137.               which are not ANSI null ptr constants.  */
  4138.            && (!integer_zerop (rhs) || TREE_CODE (rhs) == NOP_EXPR)
  4139.            && TREE_CODE (ttl) == FUNCTION_TYPE)))
  4140.         warn_for_assignment ("ANSI forbids %s between function pointer and `void *'",
  4141.                  get_spelling (errtype), funname, parmnum);
  4142.       /* Const and volatile mean something different for function types,
  4143.          so the usual warnings are not appropriate.  */
  4144.       else if (TREE_CODE (ttr) != FUNCTION_TYPE
  4145.            && TREE_CODE (ttl) != FUNCTION_TYPE)
  4146.         {
  4147.           if (! TYPE_READONLY (ttl) && TYPE_READONLY (ttr))
  4148.         warn_for_assignment ("%s discards `const' from pointer target type",
  4149.                      get_spelling (errtype), funname, parmnum);
  4150.           else if (! TYPE_VOLATILE (ttl) && TYPE_VOLATILE (ttr))
  4151.         warn_for_assignment ("%s discards `volatile' from pointer target type",
  4152.                      get_spelling (errtype), funname, parmnum);
  4153.           /* If this is not a case of ignoring a mismatch in signedness,
  4154.          no warning.  */
  4155.           else if (TYPE_MAIN_VARIANT (ttl) == void_type_node
  4156.                || TYPE_MAIN_VARIANT (ttr) == void_type_node
  4157.                || comp_target_types (type, rhstype))
  4158.         ;
  4159.           /* If there is a mismatch, do warn.  */
  4160.           else if (pedantic)
  4161.         warn_for_assignment ("pointer targets in %s differ in signedness",
  4162.                      get_spelling (errtype), funname, parmnum);
  4163.         }
  4164.       else if (TREE_CODE (ttl) == FUNCTION_TYPE
  4165.            && TREE_CODE (ttr) == FUNCTION_TYPE)
  4166.         {
  4167.           /* Because const and volatile on functions are restrictions
  4168.          that say the function will not do certain things,
  4169.          it is okay to use a const or volatile function
  4170.          where an ordinary one is wanted, but not vice-versa.  */
  4171.           if (TYPE_READONLY (ttl) && ! TYPE_READONLY (ttr))
  4172.         warn_for_assignment ("%s makes `const *' function pointer from non-const",
  4173.                      get_spelling (errtype), funname, parmnum);
  4174.           if (TYPE_VOLATILE (ttl) && ! TYPE_VOLATILE (ttr))
  4175.         warn_for_assignment ("%s makes `volatile *' function pointer from non-volatile",
  4176.                      get_spelling (errtype), funname, parmnum);
  4177.         }
  4178.     }
  4179.       else
  4180.     warn_for_assignment ("%s from incompatible pointer type",
  4181.                  get_spelling (errtype), funname, parmnum);
  4182.       return convert (type, rhs);
  4183.     }
  4184.   else if (codel == POINTER_TYPE && coder == INTEGER_TYPE)
  4185.     {
  4186.       /* An explicit constant 0 can convert to a pointer,
  4187.      or one that results from arithmetic, even including
  4188.      a cast to integer type.  */
  4189.       if (! (TREE_CODE (rhs) == INTEGER_CST && integer_zerop (rhs))
  4190.       &&
  4191.       ! (TREE_CODE (rhs) == NOP_EXPR
  4192.          && TREE_CODE (TREE_TYPE (rhs)) == INTEGER_TYPE
  4193.          && TREE_CODE (TREE_OPERAND (rhs, 0)) == INTEGER_CST
  4194.          && integer_zerop (TREE_OPERAND (rhs, 0))))
  4195.     {
  4196.       warn_for_assignment ("%s makes pointer from integer without a cast",
  4197.                    get_spelling (errtype), funname, parmnum);
  4198.       return convert (type, rhs);
  4199.     }
  4200.       return null_pointer_node;
  4201.     }
  4202.   else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
  4203.     {
  4204.       warn_for_assignment ("%s makes integer from pointer without a cast",
  4205.                get_spelling (errtype), funname, parmnum);
  4206.       return convert (type, rhs);
  4207.     }
  4208.  
  4209.   if (!errtype)
  4210.     {
  4211.       if (funname)
  4212.      {
  4213.        tree selector = maybe_building_objc_message_expr ();
  4214.  
  4215.        if (selector && parmnum > 2)
  4216.          error ("incompatible type for argument %d of `%s'",
  4217.            parmnum - 2, IDENTIFIER_POINTER (selector));
  4218.        else
  4219.         error ("incompatible type for argument %d of `%s'",
  4220.            parmnum, IDENTIFIER_POINTER (funname));
  4221.     }
  4222.       else
  4223.     error ("incompatible type for argument %d of indirect function call",
  4224.            parmnum);
  4225.     }
  4226.   else
  4227.     error ("incompatible types in %s", get_spelling (errtype));
  4228.  
  4229.   return error_mark_node;
  4230. }
  4231.  
  4232. /* Print a warning using MSG.
  4233.    It gets OPNAME as its one parameter.
  4234.    If OPNAME is null, it is replaced by "passing arg ARGNUM of `FUNCTION'".
  4235.    FUNCTION and ARGNUM are handled specially if we are building an
  4236.    Objective-C selector.  */
  4237.  
  4238. int flag_next_runtime;
  4239.  
  4240. static void
  4241. warn_for_assignment (msg, opname, function, argnum)
  4242.      char *msg;
  4243.      char *opname;
  4244.      tree function;
  4245.      int argnum;
  4246. {
  4247.   static char argstring[] = "passing arg %d of `%s'";
  4248.   static char argnofun[] =  "passing arg %d";
  4249.  
  4250.   if (opname == 0)
  4251.     {
  4252.       tree selector = maybe_building_objc_message_expr ();
  4253.       
  4254.       if (selector && argnum > (flag_next_runtime ? 2 : 3))
  4255.     {
  4256.       function = selector;
  4257.       argnum -= (flag_next_runtime ? 2 : 3);
  4258.     }
  4259.       if (function)
  4260.     {
  4261.       /* Function name is known; supply it.  */
  4262.       opname = (char *) alloca (IDENTIFIER_LENGTH (function)
  4263.                     + sizeof (argstring) + 25 /*%d*/ + 1);
  4264.       sprintf (opname, argstring, argnum, IDENTIFIER_POINTER (function));
  4265.     }
  4266.       else
  4267.     {
  4268.       /* Function name unknown (call through ptr); just give arg number.  */
  4269.       opname = (char *) alloca (sizeof (argnofun) + 25 /*%d*/ + 1);
  4270.       sprintf (opname, argnofun, argnum);
  4271.     }
  4272.     }
  4273.   pedwarn (msg, opname);
  4274. }
  4275.  
  4276. /* Return nonzero if VALUE is a valid constant-valued expression
  4277.    for use in initializing a static variable; one that can be an
  4278.    element of a "constant" initializer.
  4279.  
  4280.    Return null_pointer_node if the value is absolute;
  4281.    if it is relocatable, return the variable that determines the relocation.
  4282.    We assume that VALUE has been folded as much as possible;
  4283.    therefore, we do not need to check for such things as
  4284.    arithmetic-combinations of integers.  */
  4285.  
  4286. tree
  4287. initializer_constant_valid_p (value, endtype)
  4288.      tree value;
  4289.      tree endtype;
  4290. {
  4291.   switch (TREE_CODE (value))
  4292.     {
  4293.     case CONSTRUCTOR:
  4294.       if ((TREE_CODE (TREE_TYPE (value)) == UNION_TYPE
  4295.        || TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE)
  4296.       && TREE_CONSTANT (value))
  4297.     return
  4298.       initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)),
  4299.                     endtype);
  4300.     
  4301.       return TREE_STATIC (value) ? null_pointer_node : 0;
  4302.  
  4303.     case INTEGER_CST:
  4304.     case REAL_CST:
  4305.     case STRING_CST:
  4306.     case COMPLEX_CST:
  4307.       return null_pointer_node;
  4308.  
  4309.     case ADDR_EXPR:
  4310.       return TREE_OPERAND (value, 0);
  4311.  
  4312.     case NON_LVALUE_EXPR:
  4313.       return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
  4314.  
  4315.     case CONVERT_EXPR:
  4316.     case NOP_EXPR:
  4317. #ifdef NEXT_SEMANTICS
  4318.       /* Allow conversions between pointer types.  */
  4319.       if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
  4320.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE)
  4321.     return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
  4322. #endif
  4323.       /* Allow conversions between pointer types.  */
  4324.       if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
  4325.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE)
  4326.     return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
  4327.  
  4328.       /* Allow conversions between real types.  */
  4329.       if (TREE_CODE (TREE_TYPE (value)) == REAL_TYPE
  4330.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == REAL_TYPE)
  4331.     return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
  4332.  
  4333.       /* Allow length-preserving conversions between integer types.  */
  4334.       if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
  4335.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
  4336.       && (TYPE_PRECISION (TREE_TYPE (value))
  4337.           == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
  4338.     return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
  4339.  
  4340.       /* Allow conversions between other integer types only if
  4341.      explicit value.  */
  4342.       if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
  4343.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE)
  4344.     {
  4345.       tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
  4346.                              endtype);
  4347.       if (inner == null_pointer_node)
  4348.         return null_pointer_node;
  4349.       return 0;
  4350.     }
  4351.  
  4352.       /* Allow (int) &foo provided int is as wide as a pointer.  */
  4353.       if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
  4354.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE
  4355.       && (TYPE_PRECISION (TREE_TYPE (value))
  4356.           >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
  4357.     return initializer_constant_valid_p (TREE_OPERAND (value, 0),
  4358.                          endtype);
  4359.  
  4360.       /* Likewise conversions from int to pointers.  */
  4361.       if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
  4362.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
  4363.       && (TYPE_PRECISION (TREE_TYPE (value))
  4364.           <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
  4365.     return initializer_constant_valid_p (TREE_OPERAND (value, 0),
  4366.                          endtype);
  4367.  
  4368.       /* Allow conversions to union types if the value inside is okay.  */
  4369.       if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE)
  4370.     return initializer_constant_valid_p (TREE_OPERAND (value, 0),
  4371.                          endtype);
  4372.       return 0;
  4373.  
  4374.     case PLUS_EXPR:
  4375.       if (TREE_CODE (endtype) == INTEGER_TYPE
  4376.       && TYPE_PRECISION (endtype) < POINTER_SIZE)
  4377.     return 0;
  4378.       {
  4379.     tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
  4380.                             endtype);
  4381.     tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
  4382.                             endtype);
  4383.     /* If either term is absolute, use the other terms relocation.  */
  4384.     if (valid0 == null_pointer_node)
  4385.       return valid1;
  4386.     if (valid1 == null_pointer_node)
  4387.       return valid0;
  4388.     return 0;
  4389.       }
  4390.  
  4391.     case MINUS_EXPR:
  4392.       if (TREE_CODE (endtype) == INTEGER_TYPE
  4393.       && TYPE_PRECISION (endtype) < POINTER_SIZE)
  4394.     return 0;
  4395.       {
  4396.     tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
  4397.                             endtype);
  4398.     tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
  4399.                             endtype);
  4400.     /* Win if second argument is absolute.  */
  4401.     if (valid1 == null_pointer_node)
  4402.       return valid0;
  4403.     /* Win if both arguments have the same relocation.
  4404.        Then the value is absolute.  */
  4405.     if (valid0 == valid1)
  4406.       return null_pointer_node;
  4407.     return 0;
  4408.       }
  4409.     }
  4410.  
  4411.   return 0;
  4412. }
  4413.  
  4414. /* If VALUE is a compound expr all of whose expressions are constant, then
  4415.    return its value.  Otherwise, return error_mark_node.
  4416.  
  4417.    This is for handling COMPOUND_EXPRs as initializer elements
  4418.    which is allowed with a warning when -pedantic is specified.  */
  4419.  
  4420. static tree
  4421. valid_compound_expr_initializer (value, endtype)
  4422.      tree value;
  4423.      tree endtype;
  4424. {
  4425.   if (TREE_CODE (value) == COMPOUND_EXPR)
  4426.     {
  4427.       if (valid_compound_expr_initializer (TREE_OPERAND (value, 0), endtype)
  4428.       == error_mark_node)
  4429.     return error_mark_node;
  4430.       return valid_compound_expr_initializer (TREE_OPERAND (value, 1),
  4431.                           endtype);
  4432.     }
  4433.   else if (! TREE_CONSTANT (value)
  4434.        && ! initializer_constant_valid_p (value, endtype))
  4435.     return error_mark_node;
  4436.   else
  4437.     return value;
  4438. }
  4439.  
  4440. /* Perform appropriate conversions on the initial value of a variable,
  4441.    store it in the declaration DECL,
  4442.    and print any error messages that are appropriate.
  4443.    If the init is invalid, store an ERROR_MARK.  */
  4444.  
  4445. void
  4446. store_init_value (decl, init)
  4447.      tree decl, init;
  4448. {
  4449.   register tree value, type;
  4450.  
  4451.   /* If variable's type was invalidly declared, just ignore it.  */
  4452.  
  4453.   type = TREE_TYPE (decl);
  4454.   if (TREE_CODE (type) == ERROR_MARK)
  4455.     return;
  4456.  
  4457.   /* Digest the specified initializer into an expression.  */
  4458.  
  4459.   value = digest_init (type, init, TREE_STATIC (decl),
  4460.                TREE_STATIC (decl) || pedantic);
  4461.  
  4462.   /* Store the expression if valid; else report error.  */
  4463.  
  4464. #if 0
  4465.   /* Note that this is the only place we can detect the error
  4466.      in a case such as   struct foo bar = (struct foo) { x, y };
  4467.      where there is one initial value which is a constructor expression.  */
  4468.   if (value == error_mark_node)
  4469.     ;
  4470.   else if (TREE_STATIC (decl) && ! TREE_CONSTANT (value))
  4471.     {
  4472.       error ("initializer for static variable is not constant");
  4473.       value = error_mark_node;
  4474.     }
  4475.   else if (TREE_STATIC (decl)
  4476.        && initializer_constant_valid_p (value, TREE_TYPE (value)) == 0)
  4477.     {
  4478.       error ("initializer for static variable uses complicated arithmetic");
  4479.       value = error_mark_node;
  4480.     }
  4481.   else
  4482.     {
  4483.       if (pedantic && TREE_CODE (value) == CONSTRUCTOR)
  4484.     {
  4485.       if (! TREE_CONSTANT (value))
  4486.         pedwarn ("aggregate initializer is not constant");
  4487.       else if (! TREE_STATIC (value))
  4488.         pedwarn ("aggregate initializer uses complicated arithmetic");
  4489.     }
  4490.     }
  4491. #endif
  4492.  
  4493.   DECL_INITIAL (decl) = value;
  4494.  
  4495.   /* ANSI wants warnings about out-of-range constant initializers.  */
  4496.   STRIP_TYPE_NOPS (value);
  4497.   constant_expression_warning (value);
  4498. }
  4499.  
  4500. /* Methods for storing and printing names for error messages.  */
  4501.  
  4502. /* Implement a spelling stack that allows components of a name to be pushed
  4503.    and popped.  Each element on the stack is this structure.  */
  4504.  
  4505. struct spelling
  4506. {
  4507.   int kind;
  4508.   union
  4509.     {
  4510.       int i;
  4511.       char *s;
  4512.     } u;
  4513. };
  4514.  
  4515. #define SPELLING_STRING 1
  4516. #define SPELLING_MEMBER 2
  4517. #define SPELLING_BOUNDS 3
  4518.  
  4519. static struct spelling *spelling;    /* Next stack element (unused).  */
  4520. static struct spelling *spelling_base;    /* Spelling stack base.  */
  4521. static int spelling_size;        /* Size of the spelling stack.  */
  4522.  
  4523. /* Macros to save and restore the spelling stack around push_... functions.
  4524.    Alternative to SAVE_SPELLING_STACK.  */
  4525.  
  4526. #define SPELLING_DEPTH() (spelling - spelling_base)
  4527. #define RESTORE_SPELLING_DEPTH(depth) (spelling = spelling_base + depth)
  4528.  
  4529. /* Save and restore the spelling stack around arbitrary C code.  */
  4530.  
  4531. #define SAVE_SPELLING_DEPTH(code)        \
  4532. {                        \
  4533.   int __depth = SPELLING_DEPTH ();        \
  4534.   code;                        \
  4535.   RESTORE_SPELLING_DEPTH (__depth);        \
  4536. }
  4537.  
  4538. /* Push an element on the spelling stack with type KIND and assign VALUE
  4539.    to MEMBER.  */
  4540.  
  4541. #define PUSH_SPELLING(KIND, VALUE, MEMBER)                \
  4542. {                                    \
  4543.   int depth = SPELLING_DEPTH ();                    \
  4544.                                     \
  4545.   if (depth >= spelling_size)                        \
  4546.     {                                    \
  4547.       spelling_size += 10;                        \
  4548.       if (spelling_base == 0)                        \
  4549.     spelling_base                            \
  4550.       = (struct spelling *) xmalloc (spelling_size * sizeof (struct spelling));    \
  4551.       else                                \
  4552.         spelling_base                            \
  4553.       = (struct spelling *) xrealloc (spelling_base,        \
  4554.                       spelling_size * sizeof (struct spelling));    \
  4555.       RESTORE_SPELLING_DEPTH (depth);                    \
  4556.     }                                    \
  4557.                                     \
  4558.   spelling->kind = (KIND);                        \
  4559.   spelling->MEMBER = (VALUE);                        \
  4560.   spelling++;                                \
  4561. }
  4562.  
  4563. /* Push STRING on the stack.  Printed literally.  */
  4564.  
  4565. static void
  4566. push_string (string)
  4567.      char *string;
  4568. {
  4569.   PUSH_SPELLING (SPELLING_STRING, string, u.s);
  4570. }
  4571.  
  4572. /* Push a member name on the stack.  Printed as '.' STRING.  */
  4573.  
  4574. static void
  4575. push_member_name (decl)
  4576.      tree decl;
  4577.      
  4578. {
  4579.   char *string
  4580.     = DECL_NAME (decl) ? IDENTIFIER_POINTER (DECL_NAME (decl)) : "<anonymous>";
  4581.   PUSH_SPELLING (SPELLING_MEMBER, string, u.s);
  4582. }
  4583.  
  4584. /* Push an array bounds on the stack.  Printed as [BOUNDS].  */
  4585.  
  4586. static void
  4587. push_array_bounds (bounds)
  4588.      int bounds;
  4589. {
  4590.   PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i);
  4591. }
  4592.  
  4593. /* Compute the maximum size in bytes of the printed spelling.  */
  4594.  
  4595. static int
  4596. spelling_length ()
  4597. {
  4598.   register int size = 0;
  4599.   register struct spelling *p;
  4600.  
  4601.   for (p = spelling_base; p < spelling; p++)
  4602.     {
  4603.       if (p->kind == SPELLING_BOUNDS)
  4604.     size += 25;
  4605.       else
  4606.     size += strlen (p->u.s) + 1;
  4607.     }
  4608.  
  4609.   return size;
  4610. }
  4611.  
  4612. /* Print the spelling to BUFFER and return it.  */
  4613.  
  4614. static char *
  4615. print_spelling (buffer)
  4616.      register char *buffer;
  4617. {
  4618.   register char *d = buffer;
  4619.   register char *s;
  4620.   register struct spelling *p;
  4621.  
  4622.   for (p = spelling_base; p < spelling; p++)
  4623.     if (p->kind == SPELLING_BOUNDS)
  4624.       {
  4625.     sprintf (d, "[%d]", p->u.i);
  4626.     d += strlen (d);
  4627.       }
  4628.     else
  4629.       {
  4630.     if (p->kind == SPELLING_MEMBER)
  4631.       *d++ = '.';
  4632.     for (s = p->u.s; *d = *s++; d++)
  4633.       ;
  4634.       }
  4635.   *d++ = '\0';
  4636.   return buffer;
  4637. }
  4638.  
  4639. /* Provide a means to pass component names derived from the spelling stack.  */
  4640.  
  4641. char initialization_message;
  4642.  
  4643. /* Interpret the spelling of the given ERRTYPE message.  */
  4644.  
  4645. static char *
  4646. get_spelling (errtype)
  4647.      char *errtype;
  4648. {
  4649.   static char *buffer;
  4650.   static int size = -1;
  4651.  
  4652.   if (errtype == &initialization_message)
  4653.     {
  4654.       /* Avoid counting chars */
  4655.       static char message[] = "initialization of `%s'";
  4656.       register int needed = sizeof (message) + spelling_length () + 1;
  4657.       char *temp;
  4658.  
  4659.       if (size < 0)
  4660.     buffer = (char *) xmalloc (size = needed);
  4661.       if (needed > size)
  4662.     buffer = (char *) xrealloc (buffer, size = needed);
  4663.  
  4664.       temp = (char *) alloca (needed);
  4665.       sprintf (buffer, message, print_spelling (temp));
  4666.       return buffer;
  4667.     }
  4668.  
  4669.   return errtype;
  4670. }
  4671.  
  4672. /* Issue an error message for a bad initializer component.
  4673.    FORMAT describes the message.  OFWHAT is the name for the component.
  4674.    LOCAL is a format string for formatting the insertion of the name
  4675.    into the message.
  4676.  
  4677.    If OFWHAT is null, the component name is stored on the spelling stack.
  4678.    If the component name is a null string, then LOCAL is omitted entirely.  */
  4679.  
  4680. void
  4681. error_init (format, local, ofwhat)
  4682.      char *format, *local, *ofwhat;
  4683. {
  4684.   char *buffer;
  4685.  
  4686.   if (ofwhat == 0)
  4687.     ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
  4688.   buffer = (char *) alloca (strlen (local) + strlen (ofwhat) + 2);
  4689.  
  4690.   if (*ofwhat)
  4691.     sprintf (buffer, local, ofwhat);
  4692.   else
  4693.     buffer[0] = 0;
  4694.  
  4695.   error (format, buffer);
  4696. }
  4697.  
  4698. /* Issue a pedantic warning for a bad initializer component.
  4699.    FORMAT describes the message.  OFWHAT is the name for the component.
  4700.    LOCAL is a format string for formatting the insertion of the name
  4701.    into the message.
  4702.  
  4703.    If OFWHAT is null, the component name is stored on the spelling stack.
  4704.    If the component name is a null string, then LOCAL is omitted entirely.  */
  4705.  
  4706. void
  4707. pedwarn_init (format, local, ofwhat)
  4708.      char *format, *local, *ofwhat;
  4709. {
  4710.   char *buffer;
  4711.  
  4712.   if (ofwhat == 0)
  4713.     ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
  4714.   buffer = (char *) alloca (strlen (local) + strlen (ofwhat) + 2);
  4715.  
  4716.   if (*ofwhat)
  4717.     sprintf (buffer, local, ofwhat);
  4718.   else
  4719.     buffer[0] = 0;
  4720.  
  4721.   pedwarn (format, buffer);
  4722. }
  4723.  
  4724. /* Issue a warning for a bad initializer component.
  4725.    FORMAT describes the message.  OFWHAT is the name for the component.
  4726.    LOCAL is a format string for formatting the insertion of the name
  4727.    into the message.
  4728.  
  4729.    If OFWHAT is null, the component name is stored on the spelling stack.
  4730.    If the component name is a null string, then LOCAL is omitted entirely.  */
  4731.  
  4732. static void
  4733. warning_init (format, local, ofwhat)
  4734.      char *format, *local, *ofwhat;
  4735. {
  4736.   char *buffer;
  4737.  
  4738.   if (ofwhat == 0)
  4739.     ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
  4740.   buffer = (char *) alloca (strlen (local) + strlen (ofwhat) + 2);
  4741.  
  4742.   if (*ofwhat)
  4743.     sprintf (buffer, local, ofwhat);
  4744.   else
  4745.     buffer[0] = 0;
  4746.  
  4747.   warning (format, buffer);
  4748. }
  4749.  
  4750. /* Digest the parser output INIT as an initializer for type TYPE.
  4751.    Return a C expression of type TYPE to represent the initial value.
  4752.  
  4753.    The arguments REQUIRE_CONSTANT and CONSTRUCTOR_CONSTANT request errors
  4754.    if non-constant initializers or elements are seen.  CONSTRUCTOR_CONSTANT
  4755.    applies only to elements of constructors.  */
  4756.  
  4757. static tree
  4758. digest_init (type, init, require_constant, constructor_constant)
  4759.      tree type, init;
  4760.      int require_constant, constructor_constant;
  4761. {
  4762.   enum tree_code code = TREE_CODE (type);
  4763.   tree inside_init = init;
  4764.  
  4765.   if (init == error_mark_node)
  4766.     return init;
  4767.  
  4768.   /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
  4769.   /* Do not use STRIP_NOPS here.  We do not want an enumerator
  4770.      whose value is 0 to count as a null pointer constant.  */
  4771.   if (TREE_CODE (init) == NON_LVALUE_EXPR)
  4772.     inside_init = TREE_OPERAND (init, 0);
  4773.  
  4774.   /* Initialization of an array of chars from a string constant
  4775.      optionally enclosed in braces.  */
  4776.  
  4777.   if (code == ARRAY_TYPE)
  4778.     {
  4779.       tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
  4780.       if ((typ1 == char_type_node
  4781.        || typ1 == signed_char_type_node
  4782.        || typ1 == unsigned_char_type_node
  4783.        || typ1 == unsigned_wchar_type_node
  4784.        || typ1 == signed_wchar_type_node)
  4785.       && ((inside_init && TREE_CODE (inside_init) == STRING_CST)))
  4786.     {
  4787.       if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
  4788.              TYPE_MAIN_VARIANT (type)))
  4789.         return inside_init;
  4790.  
  4791.       if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)))
  4792.            != char_type_node)
  4793.           && TYPE_PRECISION (typ1) == TYPE_PRECISION (char_type_node))
  4794.         {
  4795.           error_init ("char-array%s initialized from wide string",
  4796.               " `%s'", NULL);
  4797.           return error_mark_node;
  4798.         }
  4799.       if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)))
  4800.            == char_type_node)
  4801.           && TYPE_PRECISION (typ1) != TYPE_PRECISION (char_type_node))
  4802.         {
  4803.           error_init ("int-array%s initialized from non-wide string",
  4804.               " `%s'", NULL);
  4805.           return error_mark_node;
  4806.         }
  4807.  
  4808.       TREE_TYPE (inside_init) = type;
  4809.       if (TYPE_DOMAIN (type) != 0
  4810.           && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
  4811.         {
  4812.           register int size = TREE_INT_CST_LOW (TYPE_SIZE (type));
  4813.           size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
  4814.           /* Subtract 1 (or sizeof (wchar_t))
  4815.          because it's ok to ignore the terminating null char
  4816.          that is counted in the length of the constant.  */
  4817.           if (size < TREE_STRING_LENGTH (inside_init)
  4818.           - (TYPE_PRECISION (typ1) != TYPE_PRECISION (char_type_node)
  4819.              ? TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT
  4820.              : 1))
  4821.         pedwarn_init (
  4822.           "initializer-string for array of chars%s is too long",
  4823.           " `%s'", NULL);
  4824.         }
  4825.       return inside_init;
  4826.     }
  4827.     }
  4828.  
  4829.   /* Any type can be initialized
  4830.      from an expression of the same type, optionally with braces.  */
  4831.  
  4832.   if (inside_init && TREE_TYPE (inside_init) != 0
  4833.       && (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
  4834.              TYPE_MAIN_VARIANT (type))
  4835.       || (code == ARRAY_TYPE
  4836.           && comptypes (TREE_TYPE (inside_init), type))
  4837.       || (code == POINTER_TYPE
  4838.           && (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
  4839.           || TREE_CODE (TREE_TYPE (inside_init)) == FUNCTION_TYPE)
  4840.           && comptypes (TREE_TYPE (TREE_TYPE (inside_init)),
  4841.                 TREE_TYPE (type)))))
  4842.     {
  4843.       if (code == POINTER_TYPE
  4844.       && (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
  4845.           || TREE_CODE (TREE_TYPE (inside_init)) == FUNCTION_TYPE))
  4846.     inside_init = default_conversion (inside_init);
  4847.       else if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST
  4848.            && TREE_CODE (inside_init) != CONSTRUCTOR)
  4849.     {
  4850.       error_init ("array%s initialized from non-constant array expression",
  4851.               " `%s'", NULL);
  4852.       return error_mark_node;
  4853.     }
  4854.  
  4855.       if (optimize && TREE_CODE (inside_init) == VAR_DECL)
  4856.     inside_init = decl_constant_value (inside_init);
  4857.  
  4858.       /* Compound expressions can only occur here if -pedantic or
  4859.      -pedantic-errors is specified.  In the later case, we always want
  4860.      an error.  In the former case, we simply want a warning.  */
  4861.       if (require_constant && pedantic
  4862.       && TREE_CODE (inside_init) == COMPOUND_EXPR)
  4863.     {
  4864.       inside_init
  4865.         = valid_compound_expr_initializer (inside_init,
  4866.                            TREE_TYPE (inside_init));
  4867.       if (inside_init == error_mark_node)
  4868.         error_init ("initializer element%s is not constant",
  4869.             " for `%s'", NULL);
  4870.       else
  4871.         pedwarn_init ("initializer element%s is not constant",
  4872.               " for `%s'", NULL);
  4873.       if (flag_pedantic_errors)
  4874.         inside_init = error_mark_node;
  4875.     }
  4876.       else if (require_constant && ! TREE_CONSTANT (inside_init))
  4877.     {
  4878.       error_init ("initializer element%s is not constant",
  4879.               " for `%s'", NULL);
  4880.       inside_init = error_mark_node;
  4881.     }
  4882.       else if (require_constant
  4883.            && initializer_constant_valid_p (inside_init, TREE_TYPE (inside_init)) == 0)
  4884.     {
  4885.       error_init ("initializer element%s is not computable at load time",
  4886.               " for `%s'", NULL);
  4887.       inside_init = error_mark_node;
  4888.     }
  4889.  
  4890.       return inside_init;
  4891.     }
  4892.  
  4893.   /* Handle scalar types, including conversions.  */
  4894.  
  4895.   if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
  4896.       || code == ENUMERAL_TYPE || code == COMPLEX_TYPE)
  4897.     {
  4898.       /* Note that convert_for_assignment calls default_conversion
  4899.      for arrays and functions.  We must not call it in the
  4900.      case where inside_init is a null pointer constant.  */
  4901.       inside_init
  4902.     = convert_for_assignment (type, init, "initialization",
  4903.                   NULL_TREE, NULL_TREE, 0);
  4904.  
  4905.       if (require_constant && ! TREE_CONSTANT (inside_init))
  4906.     {
  4907.       error_init ("initializer element%s is not constant",
  4908.               " for `%s'", NULL);
  4909.       inside_init = error_mark_node;
  4910.     }
  4911.       else if (require_constant
  4912.            && initializer_constant_valid_p (inside_init, TREE_TYPE (inside_init)) == 0)
  4913.     {
  4914.       error_init ("initializer element%s is not computable at load time",
  4915.               " for `%s'", NULL);
  4916.       inside_init = error_mark_node;
  4917.     }
  4918.  
  4919.       return inside_init;
  4920.     }
  4921.  
  4922.   /* Come here only for records and arrays.  */
  4923.  
  4924.   if (TYPE_SIZE (type) && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  4925.     {
  4926.       error_init ("variable-sized object%s may not be initialized",
  4927.           " `%s'", NULL);
  4928.       return error_mark_node;
  4929.     }
  4930.  
  4931.   /* Traditionally, you can write  struct foo x = 0;
  4932.      and it initializes the first element of x to 0.  */
  4933.   if (flag_traditional)
  4934.     {
  4935.       tree top = 0, prev = 0, otype = type;
  4936.       while (TREE_CODE (type) == RECORD_TYPE
  4937.          || TREE_CODE (type) == ARRAY_TYPE
  4938.          || TREE_CODE (type) == QUAL_UNION_TYPE
  4939.          || TREE_CODE (type) == UNION_TYPE)
  4940.     {
  4941.       tree temp = build (CONSTRUCTOR, type, NULL_TREE, NULL_TREE);
  4942.       if (prev == 0)
  4943.         top = temp;
  4944.       else
  4945.         TREE_OPERAND (prev, 1) = build_tree_list (NULL_TREE, temp);
  4946.       prev = temp;
  4947.       if (TREE_CODE (type) == ARRAY_TYPE)
  4948.         type = TREE_TYPE (type);
  4949.       else if (TYPE_FIELDS (type))
  4950.         type = TREE_TYPE (TYPE_FIELDS (type));
  4951.       else
  4952.         {
  4953.           error_init ("invalid initializer%s", " for `%s'", NULL);
  4954.           return error_mark_node;
  4955.         }
  4956.     }
  4957.  
  4958.       if (otype != type)
  4959.     {
  4960.       TREE_OPERAND (prev, 1)
  4961.         = build_tree_list (NULL_TREE,
  4962.                    digest_init (type, init, require_constant,
  4963.                         constructor_constant));
  4964.       return top;
  4965.     }
  4966.       else
  4967.     return error_mark_node;
  4968.     }
  4969.   error_init ("invalid initializer%s", " for `%s'", NULL);
  4970.   return error_mark_node;
  4971. }
  4972.  
  4973. /* Handle initializers that use braces.  */
  4974.  
  4975. /* Type of object we are accumulating a constructor for.
  4976.    This type is always a RECORD_TYPE, UNION_TYPE or ARRAY_TYPE.  */
  4977. static tree constructor_type;
  4978.  
  4979. /* For a RECORD_TYPE or UNION_TYPE, this is the chain of fields
  4980.    left to fill.  */
  4981. static tree constructor_fields;
  4982.  
  4983. /* For an ARRAY_TYPE, this is the specified index
  4984.    at which to store the next element we get.
  4985.    This is a special INTEGER_CST node that we modify in place.  */
  4986. static tree constructor_index;
  4987.  
  4988. /* For an ARRAY_TYPE, this is the end index of the range
  4989.    to initialize with the next element, or NULL in the ordinary case
  4990.    where the element is used just once.  */
  4991. static tree constructor_range_end;
  4992.  
  4993. /* For an ARRAY_TYPE, this is the maximum index.  */
  4994. static tree constructor_max_index;
  4995.  
  4996. /* For a RECORD_TYPE, this is the first field not yet written out.  */
  4997. static tree constructor_unfilled_fields;
  4998.  
  4999. /* For an ARRAY_TYPE, this is the index of the first element
  5000.    not yet written out.
  5001.    This is a special INTEGER_CST node that we modify in place.  */
  5002. static tree constructor_unfilled_index;
  5003.  
  5004. /* In a RECORD_TYPE, the byte index of the next consecutive field.
  5005.    This is so we can generate gaps between fields, when appropriate.
  5006.    This is a special INTEGER_CST node that we modify in place.  */
  5007. static tree constructor_bit_index;
  5008.  
  5009. /* If we are saving up the elements rather than allocating them,
  5010.    this is the list of elements so far (in reverse order,
  5011.    most recent first).  */
  5012. static tree constructor_elements;
  5013.  
  5014. /* 1 if so far this constructor's elements are all compile-time constants.  */
  5015. static int constructor_constant;
  5016.  
  5017. /* 1 if so far this constructor's elements are all valid address constants.  */
  5018. static int constructor_simple;
  5019.  
  5020. /* 1 if this constructor is erroneous so far.  */
  5021. static int constructor_erroneous;
  5022.  
  5023. /* 1 if have called defer_addressed_constants.  */
  5024. static int constructor_subconstants_deferred;
  5025.  
  5026. /* List of pending elements at this constructor level.
  5027.    These are elements encountered out of order
  5028.    which belong at places we haven't reached yet in actually
  5029.    writing the output.  */
  5030. static tree constructor_pending_elts;
  5031.  
  5032. /* The SPELLING_DEPTH of this constructor.  */
  5033. static int constructor_depth;
  5034.  
  5035. /* 0 if implicitly pushing constructor levels is allowed.  */
  5036. int constructor_no_implicit = 0; /* 0 for C; 1 for some other languages. */
  5037.  
  5038. /* 1 if this constructor level was entered implicitly.  */
  5039. static int constructor_implicit;
  5040.  
  5041. static int require_constant_value;
  5042. static int require_constant_elements;
  5043.  
  5044. /* 1 if it is ok to output this constructor as we read it.
  5045.    0 means must accumulate a CONSTRUCTOR expression.  */
  5046. static int constructor_incremental;
  5047.  
  5048. /* DECL node for which an initializer is being read.
  5049.    0 means we are reading a constructor expression
  5050.    such as (struct foo) {...}.  */
  5051. static tree constructor_decl;
  5052.  
  5053. /* start_init saves the ASMSPEC arg here for really_start_incremental_init.  */
  5054. static char *constructor_asmspec;
  5055.  
  5056. /* Nonzero if this is an initializer for a top-level decl.  */
  5057. static int constructor_top_level;
  5058.  
  5059. /* When we finish reading a constructor expression
  5060.    (constructor_decl is 0), the CONSTRUCTOR goes here.  */
  5061. static tree constructor_result;
  5062.  
  5063. /* This stack has a level for each implicit or explicit level of
  5064.    structuring in the initializer, including the outermost one.  It
  5065.    saves the values of most of the variables above.  */
  5066.  
  5067. struct constructor_stack
  5068. {
  5069.   struct constructor_stack *next;
  5070.   tree type;
  5071.   tree fields;
  5072.   tree index;
  5073.   tree range_end;
  5074.   tree max_index;
  5075.   tree unfilled_index;
  5076.   tree unfilled_fields;
  5077.   tree bit_index;
  5078.   tree elements;
  5079.   int offset;
  5080.   tree pending_elts;
  5081.   int depth;
  5082.   /* If nonzero, this value should replace the entire
  5083.      constructor at this level.  */
  5084.   tree replacement_value;
  5085.   char constant;
  5086.   char simple;
  5087.   char implicit;
  5088.   char incremental;
  5089.   char erroneous;
  5090.   char outer;
  5091. };
  5092.  
  5093. struct constructor_stack *constructor_stack;
  5094.  
  5095. /* This stack records separate initializers that are nested.
  5096.    Nested initializers can't happen in ANSI C, but GNU C allows them
  5097.    in cases like { ... (struct foo) { ... } ... }.  */
  5098.  
  5099. struct initializer_stack
  5100. {
  5101.   struct initializer_stack *next;
  5102.   tree decl;
  5103.   char *asmspec;
  5104.   struct constructor_stack *constructor_stack;
  5105.   tree elements;
  5106.   struct spelling *spelling;
  5107.   struct spelling *spelling_base;
  5108.   int spelling_size;
  5109.   char top_level;
  5110.   char incremental;
  5111.   char require_constant_value;
  5112.   char require_constant_elements;
  5113.   char deferred;
  5114. };
  5115.  
  5116. struct initializer_stack *initializer_stack;
  5117.  
  5118. /* Prepare to parse and output the initializer for variable DECL.  */
  5119.  
  5120. void
  5121. start_init (decl, asmspec_tree, top_level)
  5122.      tree decl;
  5123.      tree asmspec_tree;
  5124.      int top_level;
  5125. {
  5126.   char *locus;
  5127.   struct initializer_stack *p
  5128.     = (struct initializer_stack *) xmalloc (sizeof (struct initializer_stack));
  5129.   char *asmspec = 0;
  5130.  
  5131.   if (asmspec_tree)
  5132.     asmspec = TREE_STRING_POINTER (asmspec_tree);
  5133.  
  5134.   p->decl = constructor_decl;
  5135.   p->asmspec = constructor_asmspec;
  5136.   p->incremental = constructor_incremental;
  5137.   p->require_constant_value = require_constant_value;
  5138.   p->require_constant_elements = require_constant_elements;
  5139.   p->constructor_stack = constructor_stack;
  5140.   p->elements = constructor_elements;
  5141.   p->spelling = spelling;
  5142.   p->spelling_base = spelling_base;
  5143.   p->spelling_size = spelling_size;
  5144.   p->deferred = constructor_subconstants_deferred;
  5145.   p->top_level = constructor_top_level;
  5146.   p->next = initializer_stack;
  5147.   initializer_stack = p;
  5148.  
  5149.   constructor_decl = decl;
  5150.   constructor_incremental = top_level;
  5151.   constructor_asmspec = asmspec;
  5152.   constructor_subconstants_deferred = 0;
  5153.   constructor_top_level = top_level;
  5154.  
  5155.   if (decl != 0)
  5156.     {
  5157.       require_constant_value = TREE_STATIC (decl);
  5158.       require_constant_elements
  5159.     = ((TREE_STATIC (decl) || pedantic)
  5160.        /* For a scalar, you can always use any value to initialize,
  5161.           even within braces.  */
  5162.        && (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
  5163.            || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
  5164.            || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
  5165.            || TREE_CODE (TREE_TYPE (decl)) == QUAL_UNION_TYPE));
  5166.       locus = IDENTIFIER_POINTER (DECL_NAME (decl));
  5167.       constructor_incremental |= TREE_STATIC (decl);
  5168.     }
  5169.   else
  5170.     {
  5171.       require_constant_value = 0;
  5172.       require_constant_elements = 0;
  5173.       locus = "(anonymous)";
  5174.     }
  5175.  
  5176.   constructor_stack = 0;
  5177.  
  5178.   missing_braces_mentioned = 0;
  5179.  
  5180.   spelling_base = 0;
  5181.   spelling_size = 0;
  5182.   RESTORE_SPELLING_DEPTH (0);
  5183.  
  5184.   if (locus)
  5185.     push_string (locus);
  5186. }
  5187.  
  5188. void
  5189. finish_init ()
  5190. {
  5191.   struct initializer_stack *p = initializer_stack;
  5192.  
  5193.   /* Output subconstants (string constants, usually)
  5194.      that were referenced within this initializer and saved up.
  5195.      Must do this if and only if we called defer_addressed_constants.  */
  5196.   if (constructor_subconstants_deferred)
  5197.     output_deferred_addressed_constants ();
  5198.  
  5199.   /* Free the whole constructor stack of this initializer.  */
  5200.   while (constructor_stack)
  5201.     {
  5202.       struct constructor_stack *q = constructor_stack;
  5203.       constructor_stack = q->next;
  5204.       free (q);
  5205.     }
  5206.  
  5207.   /* Pop back to the data of the outer initializer (if any).  */
  5208.   constructor_decl = p->decl;
  5209.   constructor_asmspec = p->asmspec;
  5210.   constructor_incremental = p->incremental;
  5211.   require_constant_value = p->require_constant_value;
  5212.   require_constant_elements = p->require_constant_elements;
  5213.   constructor_stack = p->constructor_stack;
  5214.   constructor_elements = p->elements;
  5215.   spelling = p->spelling;
  5216.   spelling_base = p->spelling_base;
  5217.   spelling_size = p->spelling_size;
  5218.   constructor_subconstants_deferred = p->deferred;
  5219.   constructor_top_level = p->top_level;
  5220.   initializer_stack = p->next;
  5221.   free (p);
  5222. }
  5223.  
  5224. /* Call here when we see the initializer is surrounded by braces.
  5225.    This is instead of a call to push_init_level;
  5226.    it is matched by a call to pop_init_level.
  5227.  
  5228.    TYPE is the type to initialize, for a constructor expression.
  5229.    For an initializer for a decl, TYPE is zero.  */
  5230.  
  5231. void
  5232. really_start_incremental_init (type)
  5233.      tree type;
  5234. {
  5235.   struct constructor_stack *p
  5236.     = (struct constructor_stack *) xmalloc (sizeof (struct constructor_stack));
  5237.  
  5238.   if (type == 0)
  5239.     type = TREE_TYPE (constructor_decl);
  5240.  
  5241.   /* Turn off constructor_incremental if type is a struct with bitfields.
  5242.      Do this before the first push, so that the corrected value
  5243.      is available in finish_init.  */
  5244.   check_init_type_bitfields (type);
  5245.  
  5246.   p->type = constructor_type;
  5247.   p->fields = constructor_fields;
  5248.   p->index = constructor_index;
  5249.   p->range_end = constructor_range_end;
  5250.   p->max_index = constructor_max_index;
  5251.   p->unfilled_index = constructor_unfilled_index;
  5252.   p->unfilled_fields = constructor_unfilled_fields;
  5253.   p->bit_index = constructor_bit_index;
  5254.   p->elements = 0;
  5255.   p->constant = constructor_constant;
  5256.   p->simple = constructor_simple;
  5257.   p->erroneous = constructor_erroneous;
  5258.   p->pending_elts = constructor_pending_elts;
  5259.   p->depth = constructor_depth;
  5260.   p->replacement_value = 0;
  5261.   p->implicit = 0;
  5262.   p->incremental = constructor_incremental;
  5263.   p->outer = 0;
  5264.   p->next = 0;
  5265.   constructor_stack = p;
  5266.  
  5267.   constructor_constant = 1;
  5268.   constructor_simple = 1;
  5269.   constructor_depth = SPELLING_DEPTH ();
  5270.   constructor_elements = 0;
  5271.   constructor_pending_elts = 0;
  5272.   constructor_type = type;
  5273.  
  5274.   if (TREE_CODE (constructor_type) == RECORD_TYPE
  5275.       || TREE_CODE (constructor_type) == UNION_TYPE)
  5276.     {
  5277.       constructor_fields = TYPE_FIELDS (constructor_type);
  5278.       /* Skip any nameless bit fields at the beginning.  */
  5279.       while (constructor_fields != 0 && DECL_BIT_FIELD (constructor_fields)
  5280.          && DECL_NAME (constructor_fields) == 0)
  5281.     constructor_fields = TREE_CHAIN (constructor_fields);
  5282.       constructor_unfilled_fields = constructor_fields;
  5283.       constructor_bit_index = copy_node (integer_zero_node);
  5284.     }
  5285.   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  5286.     {
  5287.       constructor_range_end = 0;
  5288.       if (TYPE_DOMAIN (constructor_type))
  5289.     {
  5290.       constructor_max_index
  5291.         = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
  5292.       constructor_index
  5293.         = copy_node (TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
  5294.     }
  5295.       else
  5296.     constructor_index = copy_node (integer_zero_node);
  5297.       constructor_unfilled_index = copy_node (constructor_index);
  5298.     }
  5299.   else
  5300.     {
  5301.       /* Handle the case of int x = {5}; */
  5302.       constructor_fields = constructor_type;
  5303.       constructor_unfilled_fields = constructor_type;
  5304.     }
  5305.  
  5306.   if (constructor_incremental)
  5307.     {
  5308.       int momentary = suspend_momentary ();
  5309.       push_obstacks_nochange ();
  5310.       if (TREE_PERMANENT (constructor_decl))
  5311.     end_temporary_allocation ();
  5312.       make_decl_rtl (constructor_decl, constructor_asmspec,
  5313.              constructor_top_level);
  5314.       assemble_variable (constructor_decl, constructor_top_level, 0, 1);
  5315.       pop_obstacks ();
  5316.       resume_momentary (momentary);
  5317.     }
  5318.  
  5319.   if (constructor_incremental)
  5320.     {
  5321.       defer_addressed_constants ();
  5322.       constructor_subconstants_deferred = 1;
  5323.     }
  5324. }
  5325.  
  5326. /* 
  5327.    Answer if DECL is currently not initialized, but will be
  5328.    shortly.  That is, if we're in the middle of initializing it.
  5329.  */
  5330.  
  5331. int
  5332. lang_decl_being_initialized (decl)
  5333.      tree decl;
  5334. {
  5335.   struct initializer_stack *p;
  5336.   if (!decl)
  5337.     return 0;
  5338.   if (decl == constructor_decl)
  5339.     return 1;
  5340.   for (p = initializer_stack; p; p = p->next)
  5341.     if (decl == p->decl)
  5342.       return 1;
  5343.   return 0;
  5344. }
  5345.  
  5346.  
  5347. /* Push down into a subobject, for initialization.
  5348.    If this is for an explicit set of braces, IMPLICIT is 0.
  5349.    If it is because the next element belongs at a lower level,
  5350.    IMPLICIT is 1.  */
  5351.  
  5352. void
  5353. push_init_level (implicit)
  5354.      int implicit;
  5355. {
  5356.   struct constructor_stack *p;
  5357.  
  5358.   /* If we've exhausted any levels that didn't have braces,
  5359.      pop them now.  */
  5360.   while (constructor_stack->implicit)
  5361.     {
  5362.       if ((TREE_CODE (constructor_type) == RECORD_TYPE
  5363.        || TREE_CODE (constructor_type) == UNION_TYPE)
  5364.       && constructor_fields == 0)
  5365.     process_init_element (pop_init_level (1));
  5366.       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
  5367.            && tree_int_cst_lt (constructor_max_index, constructor_index))
  5368.     process_init_element (pop_init_level (1));
  5369.       else
  5370.     break;
  5371.     }
  5372.  
  5373.   /* Structure elements may require alignment.  Do this now
  5374.      if necessary for the subaggregate.  */
  5375.   if (constructor_incremental && constructor_type != 0
  5376.       && TREE_CODE (constructor_type) == RECORD_TYPE && constructor_fields)
  5377.     {
  5378.       /* Advance to offset of this element.  */
  5379.       if (! tree_int_cst_equal (constructor_bit_index,
  5380.                 DECL_FIELD_BITPOS (constructor_fields)))
  5381.     {
  5382.       int next = (TREE_INT_CST_LOW
  5383.               (DECL_FIELD_BITPOS (constructor_fields))
  5384.               / BITS_PER_UNIT);
  5385.       int here = (TREE_INT_CST_LOW (constructor_bit_index)
  5386.               / BITS_PER_UNIT);
  5387.  
  5388.       assemble_zeros (next - here);
  5389.     }
  5390.     }
  5391.  
  5392.   p = (struct constructor_stack *) xmalloc (sizeof (struct constructor_stack));
  5393.   p->type = constructor_type;
  5394.   p->fields = constructor_fields;
  5395.   p->index = constructor_index;
  5396.   p->range_end = constructor_range_end;
  5397.   p->max_index = constructor_max_index;
  5398.   p->unfilled_index = constructor_unfilled_index;
  5399.   p->unfilled_fields = constructor_unfilled_fields;
  5400.   p->bit_index = constructor_bit_index;
  5401.   p->elements = constructor_elements;
  5402.   p->constant = constructor_constant;
  5403.   p->simple = constructor_simple;
  5404.   p->erroneous = constructor_erroneous;
  5405.   p->pending_elts = constructor_pending_elts;
  5406.   p->depth = constructor_depth;
  5407.   p->replacement_value = 0;
  5408.   p->implicit = implicit;
  5409.   p->incremental = constructor_incremental;
  5410.   p->outer = 0;
  5411.   p->next = constructor_stack;
  5412.   constructor_stack = p;
  5413.  
  5414.   constructor_constant = 1;
  5415.   constructor_simple = 1;
  5416.   constructor_depth = SPELLING_DEPTH ();
  5417.   constructor_elements = 0;
  5418.   constructor_pending_elts = 0;
  5419.  
  5420.   /* Don't die if an entire brace-pair level is superfluous
  5421.      in the containing level.  */
  5422.   if (constructor_type == 0)
  5423.     ;
  5424.   else if (TREE_CODE (constructor_type) == RECORD_TYPE
  5425.        || TREE_CODE (constructor_type) == UNION_TYPE)
  5426.     {
  5427.       /* Don't die if there are extra init elts at the end.  */
  5428.       if (constructor_fields == 0)
  5429.     constructor_type = 0;
  5430.       else
  5431.     {
  5432.       constructor_type = TREE_TYPE (constructor_fields);
  5433.       push_member_name (constructor_fields);
  5434.       constructor_depth++;
  5435.       if (constructor_fields != constructor_unfilled_fields)
  5436.         constructor_incremental = 0;
  5437.     }
  5438.     }
  5439.   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  5440.     {
  5441.       constructor_type = TREE_TYPE (constructor_type);
  5442.       push_array_bounds (TREE_INT_CST_LOW (constructor_index));
  5443.       constructor_depth++;
  5444.       if (! tree_int_cst_equal (constructor_index, constructor_unfilled_index)
  5445.       || constructor_range_end != 0)
  5446.     constructor_incremental = 0;
  5447.     }
  5448.  
  5449.   if (constructor_type == 0)
  5450.     {
  5451.       error_init ("extra brace group at end of initializer%s",
  5452.           " for `%s'", NULL);
  5453.       constructor_fields = 0;
  5454.       constructor_unfilled_fields = 0;
  5455.       return;
  5456.     }
  5457.  
  5458.   /* Turn off constructor_incremental if type is a struct with bitfields.  */
  5459.   check_init_type_bitfields (constructor_type);
  5460.  
  5461.   if (implicit && warn_missing_braces && !missing_braces_mentioned)
  5462.     {
  5463.       missing_braces_mentioned = 1;
  5464.       warning_init ("missing braces around initializer%s", " for `%s'", NULL);
  5465.     }
  5466.  
  5467.   if (TREE_CODE (constructor_type) == RECORD_TYPE
  5468.        || TREE_CODE (constructor_type) == UNION_TYPE)
  5469.     {
  5470.       constructor_fields = TYPE_FIELDS (constructor_type);
  5471.       /* Skip any nameless bit fields at the beginning.  */
  5472.       while (constructor_fields != 0 && DECL_BIT_FIELD (constructor_fields)
  5473.          && DECL_NAME (constructor_fields) == 0)
  5474.     constructor_fields = TREE_CHAIN (constructor_fields);
  5475.       constructor_unfilled_fields = constructor_fields;
  5476.       constructor_bit_index = copy_node (integer_zero_node);
  5477.     }
  5478.   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  5479.     {
  5480.       constructor_range_end = 0;
  5481.       if (TYPE_DOMAIN (constructor_type))
  5482.     {
  5483.       constructor_max_index
  5484.         = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
  5485.       constructor_index
  5486.         = copy_node (TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
  5487.     }
  5488.       else
  5489.     constructor_index = copy_node (integer_zero_node);
  5490.       constructor_unfilled_index = copy_node (constructor_index);
  5491.     }
  5492.   else
  5493.     {
  5494.       warning_init ("braces around scalar initializer%s", " for `%s'", NULL);
  5495.       constructor_fields = constructor_type;
  5496.       constructor_unfilled_fields = constructor_type;
  5497.     }
  5498. }
  5499.  
  5500. /* Don't read a struct incrementally if it has any bitfields,
  5501.    because the incremental reading code doesn't know how to
  5502.    handle bitfields yet.  */
  5503.  
  5504. static void
  5505. check_init_type_bitfields (type)
  5506.      tree type;
  5507. {
  5508.   if (TREE_CODE (type) == RECORD_TYPE)
  5509.     {
  5510.       tree tail;
  5511.       for (tail = TYPE_FIELDS (type); tail;
  5512.        tail = TREE_CHAIN (tail))
  5513.     {
  5514.       if (DECL_BIT_FIELD (tail)
  5515.           /* This catches cases like `int foo : 8;'.  */
  5516.           || DECL_MODE (tail) != TYPE_MODE (TREE_TYPE (tail)))
  5517.         {
  5518.           constructor_incremental = 0;
  5519.           break;
  5520.         }
  5521.  
  5522.       check_init_type_bitfields (TREE_TYPE (tail));
  5523.     }
  5524.     }
  5525.  
  5526.   else if (TREE_CODE (type) == ARRAY_TYPE)
  5527.     check_init_type_bitfields (TREE_TYPE (type));
  5528. }
  5529.  
  5530. /* At the end of an implicit or explicit brace level, 
  5531.    finish up that level of constructor.
  5532.    If we were outputting the elements as they are read, return 0
  5533.    from inner levels (process_init_element ignores that),
  5534.    but return error_mark_node from the outermost level
  5535.    (that's what we want to put in DECL_INITIAL).
  5536.    Otherwise, return a CONSTRUCTOR expression.  */
  5537.  
  5538. tree
  5539. pop_init_level (implicit)
  5540.      int implicit;
  5541. {
  5542.   struct constructor_stack *p;
  5543.   int size = 0;
  5544.   tree constructor = 0;
  5545.  
  5546.   if (implicit == 0)
  5547.     {
  5548.       /* When we come to an explicit close brace,
  5549.      pop any inner levels that didn't have explicit braces.  */
  5550.       while (constructor_stack->implicit)
  5551.     process_init_element (pop_init_level (1));
  5552.     }
  5553.  
  5554.   p = constructor_stack;
  5555.  
  5556.   if (constructor_type != 0)
  5557.     size = int_size_in_bytes (constructor_type);
  5558.  
  5559.   /* Now output all pending elements.  */
  5560.   output_pending_init_elements (1);
  5561.  
  5562. #if 0 /* c-parse.in warns about {}.  */
  5563.   /* In ANSI, each brace level must have at least one element.  */
  5564.   if (! implicit && pedantic
  5565.       && (TREE_CODE (constructor_type) == ARRAY_TYPE
  5566.       ? integer_zerop (constructor_unfilled_index)
  5567.       : constructor_unfilled_fields == TYPE_FIELDS (constructor_type)))
  5568.     pedwarn_init ("empty braces in initializer%s", " for `%s'", NULL);
  5569. #endif
  5570.  
  5571.   /* Pad out the end of the structure.  */
  5572.   
  5573.   if (p->replacement_value)
  5574.     {
  5575.       /* If this closes a superfluous brace pair,
  5576.      just pass out the element between them.  */
  5577.       constructor = p->replacement_value;
  5578.       /* If this is the top level thing within the initializer,
  5579.      and it's for a variable, then since we already called
  5580.      assemble_variable, we must output the value now.  */
  5581.       if (p->next == 0 && constructor_decl != 0
  5582.       && constructor_incremental)
  5583.     {
  5584.       constructor = digest_init (constructor_type, constructor,
  5585.                      require_constant_value,
  5586.                      require_constant_elements);
  5587.  
  5588.       /* If initializing an array of unknown size,
  5589.          determine the size now.  */
  5590.       if (TREE_CODE (constructor_type) == ARRAY_TYPE
  5591.           && TYPE_DOMAIN (constructor_type) == 0)
  5592.         {
  5593.           int failure;
  5594.           int momentary_p;
  5595.  
  5596.           push_obstacks_nochange ();
  5597.           if (TREE_PERMANENT (constructor_type))
  5598.         end_temporary_allocation ();
  5599.  
  5600.           momentary_p = suspend_momentary (); 
  5601.  
  5602.           /* We shouldn't have an incomplete array type within
  5603.          some other type.  */
  5604.           if (constructor_stack->next)
  5605.         abort ();
  5606.  
  5607.           failure
  5608.         = complete_array_type (constructor_type,
  5609.                        constructor, 0);
  5610.           if (failure)
  5611.         abort ();
  5612.  
  5613.           size = int_size_in_bytes (constructor_type);
  5614.           resume_momentary (momentary_p);
  5615.           pop_obstacks ();
  5616.         }
  5617.  
  5618.       output_constant (constructor, size);
  5619.     }
  5620.     }
  5621.   else if (constructor_type == 0)
  5622.     ;
  5623.   else if (TREE_CODE (constructor_type) != RECORD_TYPE
  5624.        && TREE_CODE (constructor_type) != UNION_TYPE
  5625.        && TREE_CODE (constructor_type) != ARRAY_TYPE
  5626.        && ! constructor_incremental)
  5627.     {
  5628.       /* A nonincremental scalar initializer--just return
  5629.      the element, after verifying there is just one.  */
  5630.       if (constructor_elements == 0)
  5631.     {
  5632.       error_init ("empty scalar initializer%s",
  5633.               " for `%s'", NULL);
  5634.       constructor = error_mark_node;
  5635.     }
  5636.       else if (TREE_CHAIN (constructor_elements) != 0)
  5637.     {
  5638.       error_init ("extra elements in scalar initializer%s",
  5639.               " for `%s'", NULL);
  5640.       constructor = TREE_VALUE (constructor_elements);
  5641.     }
  5642.       else
  5643.     constructor = TREE_VALUE (constructor_elements);
  5644.     }
  5645.   else if (! constructor_incremental)
  5646.     {
  5647.       if (constructor_erroneous)
  5648.     constructor = error_mark_node;
  5649.       else
  5650.     {
  5651.       int momentary = suspend_momentary ();
  5652.  
  5653.       constructor = build (CONSTRUCTOR, constructor_type, NULL_TREE,
  5654.                    nreverse (constructor_elements));
  5655.       if (constructor_constant)
  5656.         TREE_CONSTANT (constructor) = 1;
  5657.       if (constructor_constant && constructor_simple)
  5658.         TREE_STATIC (constructor) = 1;
  5659.  
  5660.       resume_momentary (momentary);
  5661.     }
  5662.     }
  5663.   else
  5664.     {
  5665.       tree filled;
  5666.       int momentary = suspend_momentary ();
  5667.  
  5668.       if (TREE_CODE (constructor_type) == RECORD_TYPE
  5669.       || TREE_CODE (constructor_type) == UNION_TYPE)
  5670.     {
  5671.       /* Find the offset of the end of that field.  */
  5672.       filled = size_binop (CEIL_DIV_EXPR,
  5673.                    constructor_bit_index,
  5674.                    size_int (BITS_PER_UNIT));
  5675.     }
  5676.       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  5677.     {
  5678.       /* If initializing an array of unknown size,
  5679.          determine the size now.  */
  5680.       if (TREE_CODE (constructor_type) == ARRAY_TYPE
  5681.           && TYPE_DOMAIN (constructor_type) == 0)
  5682.         {
  5683.           tree maxindex
  5684.         = size_binop (MINUS_EXPR,
  5685.                   constructor_unfilled_index,
  5686.                   integer_one_node);
  5687.  
  5688.           push_obstacks_nochange ();
  5689.           if (TREE_PERMANENT (constructor_type))
  5690.         end_temporary_allocation ();
  5691.           maxindex = copy_node (maxindex);
  5692.           TYPE_DOMAIN (constructor_type) = build_index_type (maxindex);
  5693.           TREE_TYPE (maxindex) = TYPE_DOMAIN (constructor_type);
  5694.  
  5695.           /* TYPE_MAX_VALUE is always one less than the number of elements
  5696.          in the array, because we start counting at zero.  Therefore,
  5697.          warn only if the value is less than zero.  */
  5698.           if (pedantic
  5699.           && (tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
  5700.               < 0))
  5701.         error_with_decl (constructor_decl,
  5702.                  "zero or negative array size `%s'");
  5703.           layout_type (constructor_type);
  5704.           size = int_size_in_bytes (constructor_type);
  5705.           pop_obstacks ();
  5706.         }
  5707.  
  5708.       filled = size_binop (MULT_EXPR, constructor_unfilled_index,
  5709.                    size_in_bytes (TREE_TYPE (constructor_type)));
  5710.     }
  5711.       else
  5712.     filled = 0;
  5713.  
  5714.       if (filled != 0)
  5715.     assemble_zeros (size - TREE_INT_CST_LOW (filled));
  5716.  
  5717.       resume_momentary (momentary);
  5718.     }
  5719.  
  5720.       
  5721.   constructor_type = p->type;
  5722.   constructor_fields = p->fields;
  5723.   constructor_index = p->index;
  5724.   constructor_range_end = p->range_end;
  5725.   constructor_max_index = p->max_index;
  5726.   constructor_unfilled_index = p->unfilled_index;
  5727.   constructor_unfilled_fields = p->unfilled_fields;
  5728.   constructor_bit_index = p->bit_index;
  5729.   constructor_elements = p->elements;
  5730.   constructor_constant = p->constant;
  5731.   constructor_simple = p->simple;
  5732.   constructor_erroneous = p->erroneous;
  5733.   constructor_pending_elts = p->pending_elts;
  5734.   constructor_depth = p->depth;
  5735.   constructor_incremental = p->incremental;
  5736.   RESTORE_SPELLING_DEPTH (constructor_depth);
  5737.  
  5738.   constructor_stack = p->next;
  5739.   free (p);
  5740.  
  5741.   if (constructor == 0)
  5742.     {
  5743.       if (constructor_stack == 0)
  5744.     return error_mark_node;
  5745.       return NULL_TREE;
  5746.     }
  5747.   return constructor;
  5748. }
  5749.  
  5750. /* Within an array initializer, specify the next index to be initialized.
  5751.    FIRST is that index.  If LAST is nonzero, then initialize a range
  5752.    of indices, running from FIRST through LAST.  */
  5753.  
  5754. void
  5755. set_init_index (first, last)
  5756.      tree first, last;
  5757. {
  5758.   while ((TREE_CODE (first) == NOP_EXPR
  5759.       || TREE_CODE (first) == CONVERT_EXPR
  5760.       || TREE_CODE (first) == NON_LVALUE_EXPR)
  5761.      && (TYPE_MODE (TREE_TYPE (first))
  5762.          == TYPE_MODE (TREE_TYPE (TREE_OPERAND (first, 0)))))
  5763.     (first) = TREE_OPERAND (first, 0);
  5764.   if (last)
  5765.     while ((TREE_CODE (last) == NOP_EXPR
  5766.         || TREE_CODE (last) == CONVERT_EXPR
  5767.         || TREE_CODE (last) == NON_LVALUE_EXPR)
  5768.        && (TYPE_MODE (TREE_TYPE (last))
  5769.            == TYPE_MODE (TREE_TYPE (TREE_OPERAND (last, 0)))))
  5770.       (last) = TREE_OPERAND (last, 0);
  5771.  
  5772.   if (TREE_CODE (first) != INTEGER_CST)
  5773.     error_init ("nonconstant array index in initializer%s", " for `%s'", NULL);
  5774.   else if (last != 0 && TREE_CODE (last) != INTEGER_CST)
  5775.     error_init ("nonconstant array index in initializer%s", " for `%s'", NULL);
  5776.   else if (! constructor_unfilled_index)
  5777.     error_init ("array index in non-array initializer%s", " for `%s'", NULL);
  5778.   else if (tree_int_cst_lt (first, constructor_unfilled_index))
  5779.     error_init ("duplicate array index in initializer%s", " for `%s'", NULL);
  5780.   else
  5781.     {
  5782.       TREE_INT_CST_LOW (constructor_index)
  5783.     = TREE_INT_CST_LOW (first);
  5784.       TREE_INT_CST_HIGH (constructor_index)
  5785.     = TREE_INT_CST_HIGH (first);
  5786.  
  5787.       if (last != 0 && tree_int_cst_lt (last, first))
  5788.     error_init ("empty index range in initializer%s", " for `%s'", NULL);
  5789.       else
  5790.     {
  5791.       if (pedantic)
  5792.         pedwarn ("ANSI C forbids specifying element to initialize");
  5793.       constructor_range_end = last;
  5794.     }
  5795.     }
  5796. }
  5797.  
  5798. /* Within a struct initializer, specify the next field to be initialized.  */
  5799.  
  5800. void
  5801. set_init_label (fieldname)
  5802.      tree fieldname;
  5803. {
  5804.   tree tail;
  5805.   int passed = 0;
  5806.  
  5807.   /* Don't die if an entire brace-pair level is superfluous
  5808.      in the containing level.  */
  5809.   if (constructor_type == 0)
  5810.     return;
  5811.  
  5812.   for (tail = TYPE_FIELDS (constructor_type); tail;
  5813.        tail = TREE_CHAIN (tail))
  5814.     {
  5815.       if (tail == constructor_unfilled_fields)
  5816.     passed = 1;
  5817.       if (DECL_NAME (tail) == fieldname)
  5818.     break;
  5819.     }
  5820.  
  5821.   if (tail == 0)
  5822.     error ("unknown field `%s' specified in initializer",
  5823.        IDENTIFIER_POINTER (fieldname));
  5824.   else if (!passed)
  5825.     error ("field `%s' already initialized",
  5826.        IDENTIFIER_POINTER (fieldname));
  5827.   else
  5828.     {
  5829.       constructor_fields = tail;
  5830.       if (pedantic)
  5831.     pedwarn ("ANSI C forbids specifying structure member to initialize");
  5832.     }
  5833. }
  5834.  
  5835. /* "Output" the next constructor element.
  5836.    At top level, really output it to assembler code now.
  5837.    Otherwise, collect it in a list from which we will make a CONSTRUCTOR.
  5838.    TYPE is the data type that the containing data type wants here.
  5839.    FIELD is the field (a FIELD_DECL) or the index that this element fills.
  5840.  
  5841.    PENDING if non-nil means output pending elements that belong
  5842.    right after this element.  (PENDING is normally 1;
  5843.    it is 0 while outputting pending elements, to avoid recursion.)  */
  5844.  
  5845. static void
  5846. output_init_element (value, type, field, pending)
  5847.      tree value, type, field;
  5848.      int pending;
  5849. {
  5850.   int duplicate = 0;
  5851.  
  5852.   if (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE
  5853.       || (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
  5854.       && !(TREE_CODE (value) == STRING_CST
  5855.            && TREE_CODE (type) == ARRAY_TYPE
  5856.            && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
  5857.       && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
  5858.              TYPE_MAIN_VARIANT (type))))
  5859.     value = default_conversion (value);
  5860.  
  5861.   if (value == error_mark_node)
  5862.     constructor_erroneous = 1;
  5863.   else if (!TREE_CONSTANT (value))
  5864.     constructor_constant = 0;
  5865.   else if (initializer_constant_valid_p (value, TREE_TYPE (value)) == 0
  5866.        || ((TREE_CODE (constructor_type) == RECORD_TYPE
  5867.         || TREE_CODE (constructor_type) == UNION_TYPE)
  5868.            && DECL_BIT_FIELD (field) && TREE_CODE (value) != INTEGER_CST))
  5869.     constructor_simple = 0;
  5870.  
  5871.   if (require_constant_value && ! TREE_CONSTANT (value))
  5872.     {
  5873.       error_init ("initializer element%s is not constant",
  5874.           " for `%s'", NULL);
  5875.       value = error_mark_node;
  5876.     }
  5877.   else if (require_constant_elements
  5878.        && initializer_constant_valid_p (value, TREE_TYPE (value)) == 0)
  5879.     {
  5880.       error_init ("initializer element%s is not computable at load time",
  5881.           " for `%s'", NULL);
  5882.       value = error_mark_node;
  5883.     }
  5884.  
  5885.   /* If this element duplicates one on constructor_pending_elts,
  5886.      print a message and ignore it.  Don't do this when we're
  5887.      processing elements taken off constructor_pending_elts,
  5888.      because we'd always get spurious errors.  */
  5889.   if (pending)
  5890.     {
  5891.       if (TREE_CODE (constructor_type) == RECORD_TYPE
  5892.       || TREE_CODE (constructor_type) == UNION_TYPE)
  5893.     {
  5894.       if (purpose_member (field, constructor_pending_elts))
  5895.         {
  5896.           error_init ("duplicate initializer%s", " for `%s'", NULL);
  5897.           duplicate = 1;
  5898.         }
  5899.     }
  5900.       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  5901.     {
  5902.       tree tail;
  5903.       for (tail = constructor_pending_elts; tail;
  5904.            tail = TREE_CHAIN (tail))
  5905.         if (TREE_PURPOSE (tail) != 0
  5906.         && TREE_CODE (TREE_PURPOSE (tail)) == INTEGER_CST
  5907.         && tree_int_cst_equal (TREE_PURPOSE (tail), constructor_index))
  5908.           break;
  5909.  
  5910.       if (tail != 0)
  5911.         {
  5912.           error_init ("duplicate initializer%s", " for `%s'", NULL);
  5913.           duplicate = 1;
  5914.         }
  5915.     }
  5916.     }
  5917.  
  5918.   /* If this element doesn't come next in sequence,
  5919.      put it on constructor_pending_elts.  */
  5920.   if (TREE_CODE (constructor_type) == ARRAY_TYPE
  5921.       && !tree_int_cst_equal (field, constructor_unfilled_index))
  5922.     {
  5923.       if (! duplicate)
  5924.     /* The copy_node is needed in case field is actually
  5925.        constructor_index, which is modified in place.  */
  5926.     constructor_pending_elts
  5927.       = tree_cons (copy_node (field),
  5928.                digest_init (type, value, require_constant_value, 
  5929.                     require_constant_elements),
  5930.                constructor_pending_elts);
  5931.     }
  5932.   else if (TREE_CODE (constructor_type) == RECORD_TYPE
  5933.        && field != constructor_unfilled_fields)
  5934.     {
  5935.       /* We do this for records but not for unions.  In a union,
  5936.      no atter which field is specified, it can be initialized
  5937.      right away since it starts at the beginning of the union.  */
  5938.       if (!duplicate)
  5939.     constructor_pending_elts
  5940.       = tree_cons (field,
  5941.                digest_init (type, value, require_constant_value, 
  5942.                     require_constant_elements),
  5943.                constructor_pending_elts);
  5944.     }
  5945.   else
  5946.     {
  5947.       /* Otherwise, output this element either to
  5948.      constructor_elements or to the assembler file.  */
  5949.  
  5950.       if (!duplicate)
  5951.     {
  5952.       if (! constructor_incremental)
  5953.         {
  5954.           if (field && TREE_CODE (field) == INTEGER_CST)
  5955.         field = copy_node (field);
  5956.           constructor_elements
  5957.         = tree_cons (field, digest_init (type, value,
  5958.                          require_constant_value, 
  5959.                          require_constant_elements),
  5960.                  constructor_elements);
  5961.         }
  5962.       else
  5963.         {
  5964.           /* Structure elements may require alignment.
  5965.          Do this, if necessary.  */
  5966.           if (TREE_CODE (constructor_type) == RECORD_TYPE)
  5967.         {
  5968.           /* Advance to offset of this element.  */
  5969.           if (! tree_int_cst_equal (constructor_bit_index,
  5970.                         DECL_FIELD_BITPOS (field)))
  5971.             {
  5972.               int next = (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
  5973.                   / BITS_PER_UNIT);
  5974.               int here = (TREE_INT_CST_LOW (constructor_bit_index)
  5975.                   / BITS_PER_UNIT);
  5976.  
  5977.               assemble_zeros (next - here);
  5978.             }
  5979.         }
  5980.           output_constant (digest_init (type, value,
  5981.                         require_constant_value,
  5982.                         require_constant_elements),
  5983.                    int_size_in_bytes (type));
  5984.  
  5985.           /* For a record or union,
  5986.          keep track of end position of last field.  */
  5987.           if (TREE_CODE (constructor_type) == RECORD_TYPE
  5988.           || TREE_CODE (constructor_type) == UNION_TYPE)
  5989.         {
  5990.           tree temp = size_binop (PLUS_EXPR, DECL_FIELD_BITPOS (field),
  5991.                       DECL_SIZE (field));
  5992.           TREE_INT_CST_LOW (constructor_bit_index)
  5993.             = TREE_INT_CST_LOW (temp);
  5994.           TREE_INT_CST_HIGH (constructor_bit_index)
  5995.             = TREE_INT_CST_HIGH (temp);
  5996.         }
  5997.         }
  5998.     }
  5999.  
  6000.       /* Advance the variable that indicates sequential elements output.  */
  6001.       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  6002.     {
  6003.       tree tem = size_binop (PLUS_EXPR, constructor_unfilled_index,
  6004.                  integer_one_node);
  6005.       TREE_INT_CST_LOW (constructor_unfilled_index)
  6006.         = TREE_INT_CST_LOW (tem);
  6007.       TREE_INT_CST_HIGH (constructor_unfilled_index)
  6008.         = TREE_INT_CST_HIGH (tem);
  6009.     }
  6010.       else if (TREE_CODE (constructor_type) == RECORD_TYPE)
  6011.     constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
  6012.       else if (TREE_CODE (constructor_type) == UNION_TYPE)
  6013.     constructor_unfilled_fields = 0;
  6014.  
  6015.       /* Now output any pending elements which have become next.  */
  6016.       if (pending)
  6017.     output_pending_init_elements (0);
  6018.     }
  6019. }
  6020.  
  6021. /* Output any pending elements which have become next.
  6022.    As we output elements, constructor_unfilled_{fields,index}
  6023.    advances, which may cause other elements to become next;
  6024.    if so, they too are output.
  6025.  
  6026.    If ALL is 0, we return when there are
  6027.    no more pending elements to output now.
  6028.  
  6029.    If ALL is 1, we output space as necessary so that
  6030.    we can output all the pending elements.  */
  6031.  
  6032. static void
  6033. output_pending_init_elements (all)
  6034.      int all;
  6035. {
  6036.   tree tail;
  6037.   tree next;
  6038.  
  6039.  retry:
  6040.  
  6041.   /* Look thru the whole pending list.
  6042.      If we find an element that should be output now,
  6043.      output it.  Otherwise, set NEXT to the element
  6044.      that comes first among those still pending.  */
  6045.      
  6046.   next = 0;
  6047.   for (tail = constructor_pending_elts; tail;
  6048.        tail = TREE_CHAIN (tail))
  6049.     {
  6050.       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  6051.     {
  6052.       if (tree_int_cst_equal (TREE_PURPOSE (tail),
  6053.                   constructor_unfilled_index))
  6054.         {
  6055.           output_init_element (TREE_VALUE (tail),
  6056.                    TREE_TYPE (constructor_type),
  6057.                    constructor_unfilled_index, 0);
  6058.           goto retry;
  6059.         }
  6060.       else if (tree_int_cst_lt (TREE_PURPOSE (tail),
  6061.                     constructor_unfilled_index))
  6062.         ;
  6063.       else if (next == 0
  6064.            || tree_int_cst_lt (TREE_PURPOSE (tail), next))
  6065.         next = TREE_PURPOSE (tail);
  6066.     }
  6067.       else if (TREE_CODE (constructor_type) == RECORD_TYPE
  6068.            || TREE_CODE (constructor_type) == UNION_TYPE)
  6069.     {
  6070.       if (TREE_PURPOSE (tail) == constructor_unfilled_fields)
  6071.         {
  6072.           output_init_element (TREE_VALUE (tail),
  6073.                    TREE_TYPE (constructor_unfilled_fields),
  6074.                    constructor_unfilled_fields,
  6075.                    0);
  6076.           goto retry;
  6077.         }
  6078.       else if (constructor_unfilled_fields == 0
  6079.            || tree_int_cst_lt (DECL_FIELD_BITPOS (TREE_PURPOSE (tail)),
  6080.                        DECL_FIELD_BITPOS (constructor_unfilled_fields)))
  6081.         ;
  6082.       else if (next == 0
  6083.            || tree_int_cst_lt (DECL_FIELD_BITPOS (TREE_PURPOSE (tail)),
  6084.                        DECL_FIELD_BITPOS (next)))
  6085.         next = TREE_PURPOSE (tail);
  6086.     }
  6087.     }
  6088.  
  6089.   /* Ordinarily return, but not if we want to output all
  6090.      and there are elements left.  */
  6091.   if (! (all && next != 0))
  6092.     return;
  6093.  
  6094.   /* Generate space up to the position of NEXT.  */
  6095.   if (constructor_incremental)
  6096.     {
  6097.       tree filled;
  6098.       tree nextpos_tree = size_int (0);
  6099.  
  6100.       if (TREE_CODE (constructor_type) == RECORD_TYPE
  6101.       || TREE_CODE (constructor_type) == UNION_TYPE)
  6102.     {
  6103.       /* Find the last field written out, if any.  */
  6104.       for (tail = TYPE_FIELDS (constructor_type); tail;
  6105.            tail = TREE_CHAIN (tail))
  6106.         if (TREE_CHAIN (tail) == constructor_unfilled_fields)
  6107.           break;
  6108.  
  6109.       if (tail)
  6110.         /* Find the offset of the end of that field.  */
  6111.         filled = size_binop (CEIL_DIV_EXPR,
  6112.                  size_binop (PLUS_EXPR,
  6113.                          DECL_FIELD_BITPOS (tail),
  6114.                          DECL_SIZE (tail)),
  6115.                  size_int (BITS_PER_UNIT));
  6116.       else
  6117.         filled = size_int (0);
  6118.  
  6119.       nextpos_tree = size_binop (CEIL_DIV_EXPR,
  6120.                      DECL_FIELD_BITPOS (next),
  6121.                      size_int (BITS_PER_UNIT));
  6122.  
  6123.       TREE_INT_CST_HIGH (constructor_bit_index)
  6124.         = TREE_INT_CST_HIGH (DECL_FIELD_BITPOS (next));
  6125.       TREE_INT_CST_LOW (constructor_bit_index)
  6126.         = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (next));
  6127.       constructor_unfilled_fields = next;
  6128.     }
  6129.       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  6130.     {
  6131.       filled = size_binop (MULT_EXPR, constructor_unfilled_index,
  6132.                    size_in_bytes (TREE_TYPE (constructor_type)));
  6133.       nextpos_tree
  6134.         = size_binop (MULT_EXPR, next,
  6135.               size_in_bytes (TREE_TYPE (constructor_type)));
  6136.       TREE_INT_CST_LOW (constructor_unfilled_index)
  6137.         = TREE_INT_CST_LOW (next);
  6138.       TREE_INT_CST_HIGH (constructor_unfilled_index)
  6139.         = TREE_INT_CST_HIGH (next);
  6140.     }
  6141.       else
  6142.     filled = 0;
  6143.  
  6144.       if (filled)
  6145.     {
  6146.       int nextpos = TREE_INT_CST_LOW (nextpos_tree);
  6147.  
  6148.       assemble_zeros (nextpos - TREE_INT_CST_LOW (filled));
  6149.     }
  6150.     }
  6151.   else
  6152.     {
  6153.       /* If it's not incremental, just skip over the gap,
  6154.      so that after jumping to retry we will output the next
  6155.      successive element.  */
  6156.       if (TREE_CODE (constructor_type) == RECORD_TYPE
  6157.       || TREE_CODE (constructor_type) == UNION_TYPE)
  6158.     constructor_unfilled_fields = next;
  6159.       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  6160.     {
  6161.       TREE_INT_CST_LOW (constructor_unfilled_index)
  6162.         = TREE_INT_CST_LOW (next);
  6163.       TREE_INT_CST_HIGH (constructor_unfilled_index)
  6164.         = TREE_INT_CST_HIGH (next);
  6165.     }
  6166.     }
  6167.  
  6168.   goto retry;
  6169. }
  6170.  
  6171. /* Add one non-braced element to the current constructor level.
  6172.    This adjusts the current position within the constructor's type.
  6173.    This may also start or terminate implicit levels
  6174.    to handle a partly-braced initializer.
  6175.  
  6176.    Once this has found the correct level for the new element,
  6177.    it calls output_init_element.
  6178.  
  6179.    Note: if we are incrementally outputting this constructor,
  6180.    this function may be called with a null argument
  6181.    representing a sub-constructor that was already incrementally output.
  6182.    When that happens, we output nothing, but we do the bookkeeping
  6183.    to skip past that element of the current constructor.  */
  6184.  
  6185. void
  6186. process_init_element (value)
  6187.      tree value;
  6188. {
  6189.   extern int errorcount;
  6190.   tree orig_value = value;
  6191.   int string_flag = value != 0 && TREE_CODE (value) == STRING_CST;
  6192.  
  6193.   /* Handle superfluous braces around string cst as in
  6194.      char x[] = {"foo"}; */
  6195.   if (string_flag
  6196.       && constructor_type
  6197.       && TREE_CODE (constructor_type) == ARRAY_TYPE
  6198.       && TREE_CODE (TREE_TYPE (constructor_type)) == INTEGER_TYPE
  6199.       && integer_zerop (constructor_unfilled_index))
  6200.     {
  6201.       constructor_stack->replacement_value = value;
  6202.       return;
  6203.     }
  6204.  
  6205.   if (constructor_stack->replacement_value != 0)
  6206.     {
  6207.       error_init ("excess elements in struct initializer%s",
  6208.           " after `%s'", NULL_PTR);
  6209.       return;
  6210.     }
  6211.  
  6212.   /* Sometimes an error-mark will cause an infinite loop */
  6213.   if (value && TREE_CODE (value) == ERROR_MARK && errorcount)
  6214.     {
  6215.       fatal ("too many errors, bailing out");
  6216.     }
  6217.  
  6218.   /* Ignore elements of a brace group if it is entirely superfluous
  6219.      and has already been diagnosed.  */
  6220.   if (constructor_type == 0)
  6221.     return;
  6222.  
  6223.   /* If we've exhausted any levels that didn't have braces,
  6224.      pop them now.  */
  6225.   while (constructor_stack->implicit)
  6226.     {
  6227.       if ((TREE_CODE (constructor_type) == RECORD_TYPE
  6228.        || TREE_CODE (constructor_type) == UNION_TYPE)
  6229.       && constructor_fields == 0)
  6230.     process_init_element (pop_init_level (1));
  6231.       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
  6232.            && tree_int_cst_lt (constructor_max_index, constructor_index))
  6233.     process_init_element (pop_init_level (1));
  6234.       else
  6235.     break;
  6236.     }
  6237.  
  6238.   while (1)
  6239.     {
  6240.       if (TREE_CODE (constructor_type) == RECORD_TYPE)
  6241.     {
  6242.       tree fieldtype;
  6243.       enum tree_code fieldcode;
  6244.  
  6245.       if (constructor_fields == 0)
  6246.         {
  6247.           pedwarn_init ("excess elements in struct initializer%s",
  6248.                 " after `%s'", NULL_PTR);
  6249.           break;
  6250.         }
  6251.  
  6252.       fieldtype = TREE_TYPE (constructor_fields);
  6253.       if (fieldtype != error_mark_node)
  6254.         fieldtype = TYPE_MAIN_VARIANT (fieldtype);
  6255.       fieldcode = TREE_CODE (fieldtype);
  6256.  
  6257.       /* Accept a string constant to initialize a subarray.  */
  6258.       if (value != 0
  6259.           && fieldcode == ARRAY_TYPE
  6260.           && TREE_CODE (TREE_TYPE (fieldtype)) == INTEGER_TYPE
  6261.           && string_flag)
  6262.         value = orig_value;
  6263.       /* Otherwise, if we have come to a subaggregate,
  6264.          and we don't have an element of its type, push into it.  */
  6265.       else if (value != 0 && !constructor_no_implicit
  6266.            && value != error_mark_node
  6267.            && TYPE_MAIN_VARIANT (TREE_TYPE (value)) != fieldtype
  6268.            && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE
  6269.                || fieldcode == UNION_TYPE))
  6270.         {
  6271.           push_init_level (1);
  6272.           continue;
  6273.         }
  6274.  
  6275.       if (value)
  6276.         {
  6277.           push_member_name (constructor_fields);
  6278.           output_init_element (value, fieldtype, constructor_fields, 1);
  6279.           RESTORE_SPELLING_DEPTH (constructor_depth);
  6280.         }
  6281.       else
  6282.         /* Do the bookkeeping for an element that was
  6283.            directly output as a constructor.  */
  6284.         {
  6285.           /* For a record, keep track of end position of last field.  */
  6286.           tree temp = size_binop (PLUS_EXPR,
  6287.                       DECL_FIELD_BITPOS (constructor_fields),
  6288.                       DECL_SIZE (constructor_fields));
  6289.           TREE_INT_CST_LOW (constructor_bit_index)
  6290.         = TREE_INT_CST_LOW (temp);
  6291.           TREE_INT_CST_HIGH (constructor_bit_index)
  6292.         = TREE_INT_CST_HIGH (temp);
  6293.  
  6294.           constructor_unfilled_fields = TREE_CHAIN (constructor_fields);
  6295.         }
  6296.  
  6297.       constructor_fields = TREE_CHAIN (constructor_fields);
  6298.       /* Skip any nameless bit fields at the beginning.  */
  6299.       while (constructor_fields != 0 && DECL_BIT_FIELD (constructor_fields)
  6300.          && DECL_NAME (constructor_fields) == 0)
  6301.         constructor_fields = TREE_CHAIN (constructor_fields);
  6302.       break;
  6303.     }
  6304.       if (TREE_CODE (constructor_type) == UNION_TYPE)
  6305.     {
  6306.       tree fieldtype;
  6307.       enum tree_code fieldcode;
  6308.  
  6309.       if (constructor_fields == 0)
  6310.         {
  6311.           pedwarn_init ("excess elements in union initializer%s",
  6312.                 " after `%s'", NULL_PTR);
  6313.           break;
  6314.         }
  6315.  
  6316.       fieldtype = TREE_TYPE (constructor_fields);
  6317.       if (fieldtype != error_mark_node)
  6318.         fieldtype = TYPE_MAIN_VARIANT (fieldtype);
  6319.       fieldcode = TREE_CODE (fieldtype);
  6320.  
  6321.       /* Accept a string constant to initialize a subarray.  */
  6322.       if (value != 0
  6323.           && fieldcode == ARRAY_TYPE
  6324.           && TREE_CODE (TREE_TYPE (fieldtype)) == INTEGER_TYPE
  6325.           && string_flag)
  6326.         value = orig_value;
  6327.       /* Otherwise, if we have come to a subaggregate,
  6328.          and we don't have an element of its type, push into it.  */
  6329.       else if (value != 0 && !constructor_no_implicit
  6330.            && value != error_mark_node
  6331.            && TYPE_MAIN_VARIANT (TREE_TYPE (value)) != fieldtype
  6332.            && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE
  6333.                || fieldcode == UNION_TYPE))
  6334.         {
  6335.           push_init_level (1);
  6336.           continue;
  6337.         }
  6338.  
  6339.       if (value)
  6340.         {
  6341.           push_member_name (constructor_fields);
  6342.           output_init_element (value, fieldtype, constructor_fields, 1);
  6343.           RESTORE_SPELLING_DEPTH (constructor_depth);
  6344.         }
  6345.       else
  6346.         /* Do the bookkeeping for an element that was
  6347.            directly output as a constructor.  */
  6348.         {
  6349.           TREE_INT_CST_LOW (constructor_bit_index)
  6350.         = TREE_INT_CST_LOW (DECL_SIZE (constructor_fields));
  6351.           TREE_INT_CST_HIGH (constructor_bit_index)
  6352.         = TREE_INT_CST_HIGH (DECL_SIZE (constructor_fields));
  6353.  
  6354.           constructor_unfilled_fields = TREE_CHAIN (constructor_fields);
  6355.         }
  6356.  
  6357.       constructor_fields = 0;
  6358.       break;
  6359.     }
  6360.       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
  6361.     {
  6362.       tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
  6363.       enum tree_code eltcode = TREE_CODE (elttype);
  6364.  
  6365.       /* Accept a string constant to initialize a subarray.  */
  6366.       if (value != 0
  6367.           && eltcode == ARRAY_TYPE
  6368.           && TREE_CODE (TREE_TYPE (elttype)) == INTEGER_TYPE
  6369.           && string_flag)
  6370.         value = orig_value;
  6371.       /* Otherwise, if we have come to a subaggregate,
  6372.          and we don't have an element of its type, push into it.  */
  6373.       else if (value != 0 && !constructor_no_implicit
  6374.            && value != error_mark_node
  6375.            && TYPE_MAIN_VARIANT (TREE_TYPE (value)) != elttype
  6376.            && (eltcode == RECORD_TYPE || eltcode == ARRAY_TYPE
  6377.                || eltcode == UNION_TYPE))
  6378.         {
  6379.           push_init_level (1);
  6380.           continue;
  6381.         }
  6382.  
  6383.       if (constructor_max_index != 0
  6384.           && tree_int_cst_lt (constructor_max_index, constructor_index))
  6385.         {
  6386.           pedwarn_init ("excess elements in array initializer%s",
  6387.                 " after `%s'", NULL_PTR);
  6388.           break;
  6389.         }
  6390.  
  6391.       /* In the case of [LO .. HI] = VALUE, only evaluate VALUE once. */
  6392.       if (constructor_range_end)
  6393.         value = save_expr (value);
  6394.  
  6395.       /* Now output the actual element.
  6396.          Ordinarily, output once.
  6397.          If there is a range, repeat it till we advance past the range.  */
  6398.       do
  6399.         {
  6400.           tree tem;
  6401.  
  6402.           if (value)
  6403.         {
  6404.           push_array_bounds (TREE_INT_CST_LOW (constructor_index));
  6405.           output_init_element (value, elttype, constructor_index, 1);
  6406.           RESTORE_SPELLING_DEPTH (constructor_depth);
  6407.         }
  6408.  
  6409.           tem = size_binop (PLUS_EXPR, constructor_index,
  6410.                 integer_one_node);
  6411.           TREE_INT_CST_LOW (constructor_index)
  6412.         = TREE_INT_CST_LOW (tem);
  6413.           TREE_INT_CST_HIGH (constructor_index)
  6414.         = TREE_INT_CST_HIGH (tem);
  6415.  
  6416.           if (!value)
  6417.         /* If we are doing the bookkeeping for an element that was
  6418.            directly output as a constructor,
  6419.            we must update constructor_unfilled_index.  */
  6420.         {
  6421.           TREE_INT_CST_LOW (constructor_unfilled_index)
  6422.             = TREE_INT_CST_LOW (constructor_index);
  6423.           TREE_INT_CST_HIGH (constructor_unfilled_index)
  6424.             = TREE_INT_CST_HIGH (constructor_index);
  6425.         }
  6426.         }
  6427.       while (! (constructor_range_end == 0
  6428.             || tree_int_cst_lt (constructor_range_end,
  6429.                     constructor_index)));
  6430.  
  6431.       break;
  6432.     }
  6433.  
  6434.       /* Handle the sole element allowed in a braced initializer
  6435.      for a scalar variable.  */
  6436.       if (constructor_fields == 0)
  6437.     {
  6438.       pedwarn_init ("excess elements in scalar initializer%s",
  6439.             " after `%s'", NULL_PTR);
  6440.       break;
  6441.     }
  6442.  
  6443.       if (value)
  6444.     output_init_element (value, constructor_type, NULL_TREE, 1);
  6445.       constructor_fields = 0;
  6446.       break;
  6447.     }
  6448.  
  6449.   /* If the (lexically) previous elments are not now saved,
  6450.      we can discard the storage for them.  */
  6451.   if (constructor_incremental && constructor_pending_elts == 0 && value != 0
  6452.       && constructor_stack == 0)
  6453.     clear_momentary ();
  6454. }
  6455.  
  6456. /* Expand an ASM statement with operands, handling output operands
  6457.    that are not variables or INDIRECT_REFS by transforming such
  6458.    cases into cases that expand_asm_operands can handle.
  6459.  
  6460.    Arguments are same as for expand_asm_operands.  */
  6461.  
  6462. void
  6463. c_expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
  6464.      tree string, outputs, inputs, clobbers;
  6465.      int vol;
  6466.      char *filename;
  6467.      int line;
  6468. {
  6469.   int noutputs = list_length (outputs);
  6470.   register int i;
  6471.   /* o[I] is the place that output number I should be written.  */
  6472.   register tree *o = (tree *) alloca (noutputs * sizeof (tree));
  6473.   register tree tail;
  6474.  
  6475.   if (TREE_CODE (string) == ADDR_EXPR)
  6476.     string = TREE_OPERAND (string, 0);
  6477.   if (TREE_CODE (string) != STRING_CST)
  6478.     {
  6479.       error ("asm template is not a string constant");
  6480.       return;
  6481.     }
  6482.  
  6483.   /* Record the contents of OUTPUTS before it is modified.  */
  6484.   for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
  6485.     o[i] = TREE_VALUE (tail);
  6486.  
  6487.   /* Perform default conversions on array and function inputs.  */
  6488.   /* Don't do this for other types--
  6489.      it would screw up operands expected to be in memory.  */
  6490.   for (i = 0, tail = inputs; tail; tail = TREE_CHAIN (tail), i++)
  6491.     if (TREE_CODE (TREE_TYPE (TREE_VALUE (tail))) == ARRAY_TYPE
  6492.     || TREE_CODE (TREE_TYPE (TREE_VALUE (tail))) == FUNCTION_TYPE)
  6493.       TREE_VALUE (tail) = default_conversion (TREE_VALUE (tail));
  6494.  
  6495.   /* Generate the ASM_OPERANDS insn;
  6496.      store into the TREE_VALUEs of OUTPUTS some trees for
  6497.      where the values were actually stored.  */
  6498.   expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line);
  6499.  
  6500.   /* Copy all the intermediate outputs into the specified outputs.  */
  6501.   for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
  6502.     {
  6503.       if (o[i] != TREE_VALUE (tail))
  6504.     {
  6505.       expand_expr (build_modify_expr (o[i], NOP_EXPR, TREE_VALUE (tail)),
  6506.                0, VOIDmode, 0);
  6507.       free_temp_slots ();
  6508.     }
  6509.       /* Detect modification of read-only values.
  6510.      (Otherwise done by build_modify_expr.)  */
  6511.       else
  6512.     {
  6513.       tree type = TREE_TYPE (o[i]);
  6514.       if (TREE_READONLY (o[i])
  6515.           || TYPE_READONLY (type)
  6516.           || ((TREE_CODE (type) == RECORD_TYPE
  6517.            || TREE_CODE (type) == UNION_TYPE)
  6518.           && C_TYPE_FIELDS_READONLY (type)))
  6519.         readonly_warning (o[i], "modification by `asm'");
  6520.     }
  6521.     }
  6522.  
  6523.   /* Those MODIFY_EXPRs could do autoincrements.  */
  6524.   emit_queue ();
  6525. }
  6526.  
  6527. /* Expand a C `return' statement.
  6528.    RETVAL is the expression for what to return,
  6529.    or a null pointer for `return;' with no value.  */
  6530.  
  6531. void
  6532. c_expand_return (retval)
  6533.      tree retval;
  6534. {
  6535.   tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl));
  6536.  
  6537.   if (TREE_THIS_VOLATILE (current_function_decl))
  6538.     warning ("function declared `noreturn' has a `return' statement");
  6539.  
  6540.   if (!retval)
  6541.     {
  6542.       current_function_returns_null = 1;
  6543.       if (warn_return_type && valtype != 0 && TREE_CODE (valtype) != VOID_TYPE)
  6544.     warning ("`return' with no value, in function returning non-void");
  6545.       expand_null_return ();
  6546.     }
  6547.   else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE)
  6548.     {
  6549.       current_function_returns_null = 1;
  6550.       if (pedantic || TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
  6551.     pedwarn ("`return' with a value, in function returning void");
  6552.       expand_return (retval);
  6553.     }
  6554.   else
  6555.     {
  6556.       tree t = convert_for_assignment (valtype, retval, "return",
  6557.                        NULL_TREE, NULL_TREE, 0);
  6558.       tree res = DECL_RESULT (current_function_decl);
  6559.       tree inner;
  6560.  
  6561.       if (t == error_mark_node)
  6562.     return;
  6563.  
  6564.       inner = t = convert (TREE_TYPE (res), t);
  6565.  
  6566.       /* Strip any conversions, additions, and subtractions, and see if
  6567.      we are returning the address of a local variable.  Warn if so.  */
  6568.       while (1)
  6569.     {
  6570.       switch (TREE_CODE (inner))
  6571.         {
  6572.         case NOP_EXPR:   case NON_LVALUE_EXPR:  case CONVERT_EXPR:
  6573.         case PLUS_EXPR:
  6574.           inner = TREE_OPERAND (inner, 0);
  6575.           continue;
  6576.  
  6577.         case MINUS_EXPR:
  6578.           /* If the second operand of the MINUS_EXPR has a pointer
  6579.          type (or is converted from it), this may be valid, so
  6580.          don't give a warning.  */
  6581.           {
  6582.         tree op1 = TREE_OPERAND (inner, 1);
  6583.  
  6584.         while (! POINTER_TYPE_P (TREE_TYPE (op1))
  6585.                && (TREE_CODE (op1) == NOP_EXPR
  6586.                || TREE_CODE (op1) == NON_LVALUE_EXPR
  6587.                || TREE_CODE (op1) == CONVERT_EXPR))
  6588.           op1 = TREE_OPERAND (op1, 0);
  6589.  
  6590.         if (POINTER_TYPE_P (TREE_TYPE (op1)))
  6591.           break;
  6592.  
  6593.         inner = TREE_OPERAND (inner, 0);
  6594.         continue;
  6595.           }
  6596.           
  6597.         case ADDR_EXPR:
  6598.           inner = TREE_OPERAND (inner, 0);
  6599.  
  6600.           while (TREE_CODE_CLASS (TREE_CODE (inner)) == 'r')
  6601.         inner = TREE_OPERAND (inner, 0);
  6602.  
  6603.           if (TREE_CODE (inner) == VAR_DECL
  6604.           && ! DECL_EXTERNAL (inner)
  6605.           && ! TREE_STATIC (inner)
  6606.           && DECL_CONTEXT (inner) == current_function_decl)
  6607.         warning ("function returns address of local variable");
  6608.           break;
  6609.         }
  6610.  
  6611.       break;
  6612.     }
  6613.  
  6614.       t = build (MODIFY_EXPR, TREE_TYPE (res), res, t);
  6615.       TREE_SIDE_EFFECTS (t) = 1;
  6616.       expand_return (t);
  6617.       current_function_returns_value = 1;
  6618.     }
  6619. }
  6620.  
  6621. /* Start a C switch statement, testing expression EXP.
  6622.    Return EXP if it is valid, an error node otherwise.  */
  6623.  
  6624. tree
  6625. c_expand_start_case (exp)
  6626.      tree exp;
  6627. {
  6628.   register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
  6629.   tree type = TREE_TYPE (exp);
  6630.  
  6631.   if (code != INTEGER_TYPE && code != ENUMERAL_TYPE && code != ERROR_MARK)
  6632.     {
  6633.       error ("switch quantity not an integer");
  6634.       exp = error_mark_node;
  6635.     }
  6636.   else
  6637.     {
  6638.       tree index;
  6639.       type = TYPE_MAIN_VARIANT (TREE_TYPE (exp));
  6640.  
  6641.       if (warn_traditional
  6642.       && (type == long_integer_type_node
  6643.           || type == long_unsigned_type_node))
  6644.     pedwarn ("`long' switch expression not converted to `int' in ANSI C");
  6645.  
  6646.       exp = default_conversion (exp);
  6647.       type = TREE_TYPE (exp);
  6648.       index = get_unwidened (exp, NULL_TREE);
  6649.       /* We can't strip a conversion from a signed type to an unsigned,
  6650.      because if we did, int_fits_type_p would do the wrong thing
  6651.      when checking case values for being in range,
  6652.      and it's too hard to do the right thing.  */
  6653.       if (TREE_UNSIGNED (TREE_TYPE (exp))
  6654.       == TREE_UNSIGNED (TREE_TYPE (index)))
  6655.     exp = index;
  6656.     }
  6657.  
  6658.   expand_start_case (1, exp, type, "switch statement");
  6659.  
  6660.   return exp;
  6661. }
  6662.  
  6663. /* Initializers for const declarations should be kept
  6664.    longer than to the end of the declaration, so that 
  6665.    the optimizer can inline them.  */
  6666.  
  6667. void
  6668. push_momentary_for_initlist ()
  6669. {
  6670.   push_momentary ();
  6671.   if (   constructor_decl
  6672.       && TREE_READONLY (constructor_decl)
  6673.       && ! TREE_SIDE_EFFECTS (constructor_decl)
  6674.       && TREE_CODE (constructor_decl) == VAR_DECL)
  6675.     {
  6676.       suspend_momentary ();
  6677.     }
  6678. }
  6679.  
  6680.