]> oss.titaniummirror.com Git - msp430-gcc.git/blobdiff - gcc/c-typeck.c
Imported gcc-4.4.3
[msp430-gcc.git] / gcc / c-typeck.c
index 1d86fbaa95615d27fd1636678e6edeca0ac1e9e8..d9c0c1e2216b34e398573bf9046ba85b560f1d60 100644 (file)
@@ -1,12 +1,13 @@
 /* Build expressions with type checking for C compiler.
-   Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,24 +16,22 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 
 /* This file is part of the C front end.
    It contains routines to build C expressions given their operands,
    including computing the types of the result, C-specific error checks,
-   and some optimization.
-
-   There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
-   and to process initializations in declarations (since they work
-   like a strange sort of assignment).  */
+   and some optimization.  */
 
 #include "config.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "rtl.h"
 #include "tree.h"
+#include "langhooks.h"
 #include "c-tree.h"
 #include "tm_p.h"
 #include "flags.h"
@@ -42,53 +41,106 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "intl.h"
 #include "ggc.h"
 #include "target.h"
+#include "tree-iterator.h"
+#include "gimple.h"
+#include "tree-flow.h"
+
+/* Possible cases of implicit bad conversions.  Used to select
+   diagnostic messages in convert_for_assignment.  */
+enum impl_conv {
+  ic_argpass,
+  ic_assign,
+  ic_init,
+  ic_return
+};
+
+/* The level of nesting inside "__alignof__".  */
+int in_alignof;
+
+/* The level of nesting inside "sizeof".  */
+int in_sizeof;
+
+/* The level of nesting inside "typeof".  */
+int in_typeof;
+
+struct c_label_context_se *label_context_stack_se;
+struct c_label_context_vm *label_context_stack_vm;
 
 /* Nonzero if we've already printed a "missing braces around initializer"
    message within this initializer.  */
 static int missing_braces_mentioned;
 
-/* 1 if we explained undeclared var errors.  */
-static int undeclared_variable_notice;
-
-static tree qualify_type               PARAMS ((tree, tree));
-static int comp_target_types           PARAMS ((tree, tree));
-static int function_types_compatible_p PARAMS ((tree, tree));
-static int type_lists_compatible_p     PARAMS ((tree, tree));
-static tree decl_constant_value_for_broken_optimization PARAMS ((tree));
-static tree default_function_array_conversion  PARAMS ((tree));
-static tree lookup_field               PARAMS ((tree, tree));
-static tree convert_arguments          PARAMS ((tree, tree, tree, tree));
-static tree pointer_diff               PARAMS ((tree, tree));
-static tree unary_complex_lvalue       PARAMS ((enum tree_code, tree, int));
-static void pedantic_lvalue_warning    PARAMS ((enum tree_code));
-static tree internal_build_compound_expr PARAMS ((tree, int));
-static tree convert_for_assignment     PARAMS ((tree, tree, const char *,
-                                                tree, tree, int));
-static void warn_for_assignment                PARAMS ((const char *, const char *,
-                                                tree, int));
-static tree valid_compound_expr_initializer PARAMS ((tree, tree));
-static void push_string                        PARAMS ((const char *));
-static void push_member_name           PARAMS ((tree));
-static void push_array_bounds          PARAMS ((int));
-static int spelling_length             PARAMS ((void));
-static char *print_spelling            PARAMS ((char *));
-static void warning_init               PARAMS ((const char *));
-static tree digest_init                        PARAMS ((tree, tree, int, int));
-static void output_init_element                PARAMS ((tree, tree, tree, int));
-static void output_pending_init_elements PARAMS ((int));
-static int set_designator              PARAMS ((int));
-static void push_range_stack           PARAMS ((tree));
-static void add_pending_init           PARAMS ((tree, tree));
-static void set_nonincremental_init    PARAMS ((void));
-static void set_nonincremental_init_from_string        PARAMS ((tree));
-static tree find_init_member           PARAMS ((tree));
+static int require_constant_value;
+static int require_constant_elements;
+
+static bool null_pointer_constant_p (const_tree);
+static tree qualify_type (tree, tree);
+static int tagged_types_tu_compatible_p (const_tree, const_tree);
+static int comp_target_types (tree, tree);
+static int function_types_compatible_p (const_tree, const_tree);
+static int type_lists_compatible_p (const_tree, const_tree);
+static tree decl_constant_value_for_broken_optimization (tree);
+static tree lookup_field (tree, tree);
+static int convert_arguments (int, tree *, tree, tree, tree, tree);
+static tree pointer_diff (tree, tree);
+static tree convert_for_assignment (tree, tree, enum impl_conv, tree, tree,
+                                   int);
+static tree valid_compound_expr_initializer (tree, tree);
+static void push_string (const char *);
+static void push_member_name (tree);
+static int spelling_length (void);
+static char *print_spelling (char *);
+static void warning_init (int, const char *);
+static tree digest_init (tree, tree, bool, int);
+static void output_init_element (tree, bool, tree, tree, int, bool);
+static void output_pending_init_elements (int);
+static int set_designator (int);
+static void push_range_stack (tree);
+static void add_pending_init (tree, tree, bool);
+static void set_nonincremental_init (void);
+static void set_nonincremental_init_from_string (tree);
+static tree find_init_member (tree);
+static void readonly_error (tree, enum lvalue_use);
+static int lvalue_or_else (const_tree, enum lvalue_use);
+static int lvalue_p (const_tree);
+static void record_maybe_used_decl (tree);
+static int comptypes_internal (const_tree, const_tree);
 \f
+/* Return true if EXP is a null pointer constant, false otherwise.  */
+
+static bool
+null_pointer_constant_p (const_tree expr)
+{
+  /* This should really operate on c_expr structures, but they aren't
+     yet available everywhere required.  */
+  tree type = TREE_TYPE (expr);
+  return (TREE_CODE (expr) == INTEGER_CST
+         && !TREE_OVERFLOW (expr)
+         && integer_zerop (expr)
+         && (INTEGRAL_TYPE_P (type)
+             || (TREE_CODE (type) == POINTER_TYPE
+                 && VOID_TYPE_P (TREE_TYPE (type))
+                 && TYPE_QUALS (TREE_TYPE (type)) == TYPE_UNQUALIFIED)));
+}
+\f/* This is a cache to hold if two types are compatible or not.  */
+
+struct tagged_tu_seen_cache {
+  const struct tagged_tu_seen_cache * next;
+  const_tree t1;
+  const_tree t2;
+  /* The return value of tagged_types_tu_compatible_p if we had seen
+     these two types already.  */
+  int val;
+};
+
+static const struct tagged_tu_seen_cache * tagged_tu_seen_base;
+static void free_all_tagged_tu_seen_up_to (const struct tagged_tu_seen_cache *);
+
 /* Do `exp = require_complete_type (exp);' to make sure exp
    does not have an incomplete type.  (That includes void types.)  */
 
 tree
-require_complete_type (value)
-     tree value;
+require_complete_type (tree value)
 {
   tree type = TREE_TYPE (value);
 
@@ -99,7 +151,7 @@ require_complete_type (value)
   if (COMPLETE_TYPE_P (type))
     return value;
 
-  incomplete_type_error (value, type);
+  c_incomplete_type_error (value, type);
   return error_mark_node;
 }
 
@@ -108,9 +160,7 @@ require_complete_type (value)
    and TYPE is the type that was invalid.  */
 
 void
-incomplete_type_error (value, type)
-     tree value;
-     tree type;
+c_incomplete_type_error (const_tree value, const_tree type)
 {
   const char *type_code_string;
 
@@ -120,8 +170,7 @@ incomplete_type_error (value, type)
 
   if (value != 0 && (TREE_CODE (value) == VAR_DECL
                     || TREE_CODE (value) == PARM_DECL))
-    error ("`%s' has an incomplete type",
-          IDENTIFIER_POINTER (DECL_NAME (value)));
+    error ("%qD has an incomplete type", value);
   else
     {
     retry:
@@ -160,41 +209,68 @@ incomplete_type_error (value, type)
          return;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
 
       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
-       error ("invalid use of undefined type `%s %s'",
-              type_code_string, IDENTIFIER_POINTER (TYPE_NAME (type)));
+       error ("invalid use of undefined type %<%s %E%>",
+              type_code_string, TYPE_NAME (type));
       else
        /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
-       error ("invalid use of incomplete typedef `%s'",
-              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
+       error ("invalid use of incomplete typedef %qD", TYPE_NAME (type));
     }
 }
 
+/* Given a type, apply default promotions wrt unnamed function
+   arguments and return the new type.  */
+
+tree
+c_type_promotes_to (tree type)
+{
+  if (TYPE_MAIN_VARIANT (type) == float_type_node)
+    return double_type_node;
+
+  if (c_promoting_integer_type_p (type))
+    {
+      /* Preserve unsignedness if not really getting any wider.  */
+      if (TYPE_UNSIGNED (type)
+         && (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
+       return unsigned_type_node;
+      return integer_type_node;
+    }
+
+  return type;
+}
+
 /* Return a variant of TYPE which has all the type qualifiers of LIKE
    as well as those of TYPE.  */
 
 static tree
-qualify_type (type, like)
-     tree type, like;
+qualify_type (tree type, tree like)
 {
-  return c_build_qualified_type (type, 
+  return c_build_qualified_type (type,
                                 TYPE_QUALS (type) | TYPE_QUALS (like));
 }
+
+/* Return true iff the given tree T is a variable length array.  */
+
+bool
+c_vla_type_p (const_tree t)
+{
+  if (TREE_CODE (t) == ARRAY_TYPE
+      && C_TYPE_VARIABLE_SIZE (t))
+    return true;
+  return false;
+}
 \f
-/* Return the common type of two types.
-   We assume that comptypes has already been done and returned 1;
-   if that isn't so, this may crash.  In particular, we assume that qualifiers
-   match.
+/* Return the composite type of two compatible types.
 
-   This is the type for the result of most arithmetic operations
-   if the operands have the given two types.  */
+   We assume that comptypes has already been done and returned
+   nonzero; if that isn't so, this may crash.  In particular, we
+   assume that qualifiers match.  */
 
 tree
-common_type (t1, t2)
-     tree t1, t2;
+composite_type (tree t1, tree t2)
 {
   enum tree_code code1;
   enum tree_code code2;
@@ -210,128 +286,124 @@ common_type (t1, t2)
   if (t2 == error_mark_node)
     return t1;
 
-  /* Merge the attributes.  */
-  attributes = (*targetm.merge_type_attributes) (t1, t2);
-
-  /* Treat an enum type as the unsigned integer type of the same width.  */
-
-  if (TREE_CODE (t1) == ENUMERAL_TYPE)
-    t1 = type_for_size (TYPE_PRECISION (t1), 1);
-  if (TREE_CODE (t2) == ENUMERAL_TYPE)
-    t2 = type_for_size (TYPE_PRECISION (t2), 1);
-
   code1 = TREE_CODE (t1);
   code2 = TREE_CODE (t2);
 
-  /* If one type is complex, form the common type of the non-complex
-     components, then make that complex.  Use T1 or T2 if it is the
-     required type.  */
-  if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
-    {
-      tree subtype1 = code1 == COMPLEX_TYPE ? TREE_TYPE (t1) : t1;
-      tree subtype2 = code2 == COMPLEX_TYPE ? TREE_TYPE (t2) : t2;
-      tree subtype = common_type (subtype1, subtype2);
-
-      if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype)
-       return build_type_attribute_variant (t1, attributes);
-      else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype)
-       return build_type_attribute_variant (t2, attributes);
-      else
-       return build_type_attribute_variant (build_complex_type (subtype),
-                                            attributes);
-    }
-
-  switch (code1)
-    {
-    case INTEGER_TYPE:
-    case REAL_TYPE:
-      /* If only one is real, use it as the result.  */
-
-      if (code1 == REAL_TYPE && code2 != REAL_TYPE)
-       return build_type_attribute_variant (t1, attributes);
-
-      if (code2 == REAL_TYPE && code1 != REAL_TYPE)
-       return build_type_attribute_variant (t2, attributes);
-
-      /* Both real or both integers; use the one with greater precision.  */
-
-      if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
-       return build_type_attribute_variant (t1, attributes);
-      else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
-       return build_type_attribute_variant (t2, attributes);
-
-      /* Same precision.  Prefer longs to ints even when same size.  */
-
-      if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
-         || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
-       return build_type_attribute_variant (long_unsigned_type_node,
-                                            attributes);
-
-      if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
-         || TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
-       {
-         /* But preserve unsignedness from the other type,
-            since long cannot hold all the values of an unsigned int.  */
-         if (TREE_UNSIGNED (t1) || TREE_UNSIGNED (t2))
-            t1 = long_unsigned_type_node;
-         else
-            t1 = long_integer_type_node;
-         return build_type_attribute_variant (t1, attributes);
-       }
+  /* Merge the attributes.  */
+  attributes = targetm.merge_type_attributes (t1, t2);
 
-      /* Likewise, prefer long double to double even if same size.  */
-      if (TYPE_MAIN_VARIANT (t1) == long_double_type_node
-         || TYPE_MAIN_VARIANT (t2) == long_double_type_node)
-       return build_type_attribute_variant (long_double_type_node,
-                                            attributes);
+  /* If one is an enumerated type and the other is the compatible
+     integer type, the composite type might be either of the two
+     (DR#013 question 3).  For consistency, use the enumerated type as
+     the composite type.  */
 
-      /* Otherwise prefer the unsigned one.  */
+  if (code1 == ENUMERAL_TYPE && code2 == INTEGER_TYPE)
+    return t1;
+  if (code2 == ENUMERAL_TYPE && code1 == INTEGER_TYPE)
+    return t2;
 
-      if (TREE_UNSIGNED (t1))
-       return build_type_attribute_variant (t1, attributes);
-      else
-       return build_type_attribute_variant (t2, attributes);
+  gcc_assert (code1 == code2);
 
+  switch (code1)
+    {
     case POINTER_TYPE:
-      /* For two pointers, do this recursively on the target type,
-        and combine the qualifiers of the two types' targets.  */
-      /* This code was turned off; I don't know why.
-        But ANSI C specifies doing this with the qualifiers.
-        So I turned it on again.  */
+      /* For two pointers, do this recursively on the target type.  */
       {
        tree pointed_to_1 = TREE_TYPE (t1);
        tree pointed_to_2 = TREE_TYPE (t2);
-       tree target = common_type (TYPE_MAIN_VARIANT (pointed_to_1),
-                                  TYPE_MAIN_VARIANT (pointed_to_2));
-       t1 = build_pointer_type (c_build_qualified_type 
-                                (target, 
-                                 TYPE_QUALS (pointed_to_1) | 
-                                 TYPE_QUALS (pointed_to_2)));
-       return build_type_attribute_variant (t1, attributes);
+       tree target = composite_type (pointed_to_1, pointed_to_2);
+       t1 = build_pointer_type (target);
+       t1 = build_type_attribute_variant (t1, attributes);
+       return qualify_type (t1, t2);
       }
-#if 0
-      t1 = build_pointer_type (common_type (TREE_TYPE (t1), TREE_TYPE (t2)));
-      return build_type_attribute_variant (t1, attributes);
-#endif
 
     case ARRAY_TYPE:
       {
-       tree elt = common_type (TREE_TYPE (t1), TREE_TYPE (t2));
+       tree elt = composite_type (TREE_TYPE (t1), TREE_TYPE (t2));
+       int quals;
+       tree unqual_elt;
+       tree d1 = TYPE_DOMAIN (t1);
+       tree d2 = TYPE_DOMAIN (t2);
+       bool d1_variable, d2_variable;
+       bool d1_zero, d2_zero;
+       bool t1_complete, t2_complete;
+
+       /* We should not have any type quals on arrays at all.  */
+       gcc_assert (!TYPE_QUALS (t1) && !TYPE_QUALS (t2));
+
+       t1_complete = COMPLETE_TYPE_P (t1);
+       t2_complete = COMPLETE_TYPE_P (t2);
+
+       d1_zero = d1 == 0 || !TYPE_MAX_VALUE (d1);
+       d2_zero = d2 == 0 || !TYPE_MAX_VALUE (d2);
+
+       d1_variable = (!d1_zero
+                      && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
+                          || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
+       d2_variable = (!d2_zero
+                      && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
+                          || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
+       d1_variable = d1_variable || (d1_zero && c_vla_type_p (t1));
+       d2_variable = d2_variable || (d2_zero && c_vla_type_p (t2));
+
        /* Save space: see if the result is identical to one of the args.  */
-       if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1))
+       if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1)
+           && (d2_variable || d2_zero || !d1_variable))
+         return build_type_attribute_variant (t1, attributes);
+       if (elt == TREE_TYPE (t2) && TYPE_DOMAIN (t2)
+           && (d1_variable || d1_zero || !d2_variable))
+         return build_type_attribute_variant (t2, attributes);
+
+       if (elt == TREE_TYPE (t1) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
          return build_type_attribute_variant (t1, attributes);
-       if (elt == TREE_TYPE (t2) && TYPE_DOMAIN (t2))
+       if (elt == TREE_TYPE (t2) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
          return build_type_attribute_variant (t2, attributes);
-       /* Merge the element types, and have a size if either arg has one.  */
-       t1 = build_array_type (elt, TYPE_DOMAIN (TYPE_DOMAIN (t1) ? t1 : t2));
+
+       /* Merge the element types, and have a size if either arg has
+          one.  We may have qualifiers on the element types.  To set
+          up TYPE_MAIN_VARIANT correctly, we need to form the
+          composite of the unqualified types and add the qualifiers
+          back at the end.  */
+       quals = TYPE_QUALS (strip_array_types (elt));
+       unqual_elt = c_build_qualified_type (elt, TYPE_UNQUALIFIED);
+       t1 = build_array_type (unqual_elt,
+                              TYPE_DOMAIN ((TYPE_DOMAIN (t1)
+                                            && (d2_variable
+                                                || d2_zero
+                                                || !d1_variable))
+                                           ? t1
+                                           : t2));
+       /* Ensure a composite type involving a zero-length array type
+          is a zero-length type not an incomplete type.  */
+       if (d1_zero && d2_zero
+           && (t1_complete || t2_complete)
+           && !COMPLETE_TYPE_P (t1))
+         {
+           TYPE_SIZE (t1) = bitsize_zero_node;
+           TYPE_SIZE_UNIT (t1) = size_zero_node;
+         }
+       t1 = c_build_qualified_type (t1, quals);
        return build_type_attribute_variant (t1, attributes);
       }
 
+    case ENUMERAL_TYPE:
+    case RECORD_TYPE:
+    case UNION_TYPE:
+      if (attributes != NULL)
+       {
+         /* Try harder not to create a new aggregate type.  */
+         if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes))
+           return t1;
+         if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes))
+           return t2;
+       }
+      return build_type_attribute_variant (t1, attributes);
+
     case FUNCTION_TYPE:
       /* Function types: prefer the one that specified arg types.
         If both do, merge the arg types.  Also merge the return types.  */
       {
-       tree valtype = common_type (TREE_TYPE (t1), TREE_TYPE (t2));
+       tree valtype = composite_type (TREE_TYPE (t1), TREE_TYPE (t2));
        tree p1 = TYPE_ARG_TYPES (t1);
        tree p2 = TYPE_ARG_TYPES (t2);
        int len;
@@ -339,28 +411,30 @@ common_type (t1, t2)
        int i;
 
        /* Save space: see if the result is identical to one of the args.  */
-       if (valtype == TREE_TYPE (t1) && ! TYPE_ARG_TYPES (t2))
+       if (valtype == TREE_TYPE (t1) && !TYPE_ARG_TYPES (t2))
          return build_type_attribute_variant (t1, attributes);
-       if (valtype == TREE_TYPE (t2) && ! TYPE_ARG_TYPES (t1))
+       if (valtype == TREE_TYPE (t2) && !TYPE_ARG_TYPES (t1))
          return build_type_attribute_variant (t2, attributes);
 
        /* Simple way if one arg fails to specify argument types.  */
        if (TYPE_ARG_TYPES (t1) == 0)
         {
-          t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2));
-          return build_type_attribute_variant (t1, attributes);
+           t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2));
+           t1 = build_type_attribute_variant (t1, attributes);
+           return qualify_type (t1, t2);
         }
        if (TYPE_ARG_TYPES (t2) == 0)
         {
           t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1));
-          return build_type_attribute_variant (t1, attributes);
+          t1 = build_type_attribute_variant (t1, attributes);
+          return qualify_type (t1, t2);
         }
 
        /* If both args specify argument types, we must merge the two
           lists, argument by argument.  */
-
-       pushlevel (0);
-       declare_parm_level (1);
+       /* Tell global_bindings_p to return false so that variable_size
+          doesn't die on VLAs in parameter types.  */
+       c_override_global_bindings_to_false = true;
 
        len = list_length (p1);
        newargs = 0;
@@ -385,7 +459,7 @@ common_type (t1, t2)
                TREE_VALUE (n) = TREE_VALUE (p1);
                goto parm_done;
              }
-             
+
            /* Given  wait (union {union wait *u; int *i} *)
               and  wait (union wait *),
               prefer  union wait *  as type of parm.  */
@@ -393,37 +467,59 @@ common_type (t1, t2)
                && TREE_VALUE (p1) != TREE_VALUE (p2))
              {
                tree memb;
+               tree mv2 = TREE_VALUE (p2);
+               if (mv2 && mv2 != error_mark_node
+                   && TREE_CODE (mv2) != ARRAY_TYPE)
+                 mv2 = TYPE_MAIN_VARIANT (mv2);
                for (memb = TYPE_FIELDS (TREE_VALUE (p1));
                     memb; memb = TREE_CHAIN (memb))
-                 if (comptypes (TREE_TYPE (memb), TREE_VALUE (p2)))
-                   {
-                     TREE_VALUE (n) = TREE_VALUE (p2);
-                     if (pedantic)
-                       pedwarn ("function types not truly compatible in ISO C");
-                     goto parm_done;
-                   }
+                 {
+                   tree mv3 = TREE_TYPE (memb);
+                   if (mv3 && mv3 != error_mark_node
+                       && TREE_CODE (mv3) != ARRAY_TYPE)
+                     mv3 = TYPE_MAIN_VARIANT (mv3);
+                   if (comptypes (mv3, mv2))
+                     {
+                       TREE_VALUE (n) = composite_type (TREE_TYPE (memb),
+                                                        TREE_VALUE (p2));
+                       pedwarn (input_location, OPT_pedantic, 
+                                "function types not truly compatible in ISO C");
+                       goto parm_done;
+                     }
+                 }
              }
            if (TREE_CODE (TREE_VALUE (p2)) == UNION_TYPE
                && TREE_VALUE (p2) != TREE_VALUE (p1))
              {
                tree memb;
+               tree mv1 = TREE_VALUE (p1);
+               if (mv1 && mv1 != error_mark_node
+                   && TREE_CODE (mv1) != ARRAY_TYPE)
+                 mv1 = TYPE_MAIN_VARIANT (mv1);
                for (memb = TYPE_FIELDS (TREE_VALUE (p2));
                     memb; memb = TREE_CHAIN (memb))
-                 if (comptypes (TREE_TYPE (memb), TREE_VALUE (p1)))
-                   {
-                     TREE_VALUE (n) = TREE_VALUE (p1);
-                     if (pedantic)
-                       pedwarn ("function types not truly compatible in ISO C");
-                     goto parm_done;
-                   }
+                 {
+                   tree mv3 = TREE_TYPE (memb);
+                   if (mv3 && mv3 != error_mark_node
+                       && TREE_CODE (mv3) != ARRAY_TYPE)
+                     mv3 = TYPE_MAIN_VARIANT (mv3);
+                   if (comptypes (mv3, mv1))
+                     {
+                       TREE_VALUE (n) = composite_type (TREE_TYPE (memb),
+                                                        TREE_VALUE (p1));
+                       pedwarn (input_location, OPT_pedantic, 
+                                "function types not truly compatible in ISO C");
+                       goto parm_done;
+                     }
+                 }
              }
-           TREE_VALUE (n) = common_type (TREE_VALUE (p1), TREE_VALUE (p2));
+           TREE_VALUE (n) = composite_type (TREE_VALUE (p1), TREE_VALUE (p2));
          parm_done: ;
          }
 
-       poplevel (0, 0, 0);
-
+       c_override_global_bindings_to_false = false;
        t1 = build_function_type (valtype, newargs);
+       t1 = qualify_type (t1, t2);
        /* ... falls through ...  */
       }
 
@@ -432,2368 +528,2491 @@ common_type (t1, t2)
     }
 
 }
-\f
-/* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
-   or various other operations.  Return 2 if they are compatible
-   but a warning may be needed if you use them together.  */
 
-int
-comptypes (type1, type2)
-     tree type1, type2;
+/* Return the type of a conditional expression between pointers to
+   possibly differently qualified versions of compatible types.
+
+   We assume that comp_target_types has already been done and returned
+   nonzero; if that isn't so, this may crash.  */
+
+static tree
+common_pointer_type (tree t1, tree t2)
 {
-  tree t1 = type1;
-  tree t2 = type2;
-  int attrval, val;
+  tree attributes;
+  tree pointed_to_1, mv1;
+  tree pointed_to_2, mv2;
+  tree target;
+  unsigned target_quals;
 
-  /* Suppress errors caused by previously reported errors.  */
+  /* Save time if the two types are the same.  */
 
-  if (t1 == t2 || !t1 || !t2
-      || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
-    return 1;
+  if (t1 == t2) return t1;
 
-  /* If either type is the internal version of sizetype, return the
-     language version.  */
-  if (TREE_CODE (t1) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t1)
-      && TYPE_DOMAIN (t1) != 0)
-    t1 = TYPE_DOMAIN (t1);
+  /* If one type is nonsense, use the other.  */
+  if (t1 == error_mark_node)
+    return t2;
+  if (t2 == error_mark_node)
+    return t1;
 
-  if (TREE_CODE (t2) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t2)
-      && TYPE_DOMAIN (t2) != 0)
-    t2 = TYPE_DOMAIN (t2);
+  gcc_assert (TREE_CODE (t1) == POINTER_TYPE
+             && TREE_CODE (t2) == POINTER_TYPE);
 
-  /* Treat an enum type as the integer type of the same width and 
-     signedness.  */
+  /* Merge the attributes.  */
+  attributes = targetm.merge_type_attributes (t1, t2);
+
+  /* Find the composite type of the target types, and combine the
+     qualifiers of the two types' targets.  Do not lose qualifiers on
+     array element types by taking the TYPE_MAIN_VARIANT.  */
+  mv1 = pointed_to_1 = TREE_TYPE (t1);
+  mv2 = pointed_to_2 = TREE_TYPE (t2);
+  if (TREE_CODE (mv1) != ARRAY_TYPE)
+    mv1 = TYPE_MAIN_VARIANT (pointed_to_1);
+  if (TREE_CODE (mv2) != ARRAY_TYPE)
+    mv2 = TYPE_MAIN_VARIANT (pointed_to_2);
+  target = composite_type (mv1, mv2);
+
+  /* For function types do not merge const qualifiers, but drop them
+     if used inconsistently.  The middle-end uses these to mark const
+     and noreturn functions.  */
+  if (TREE_CODE (pointed_to_1) == FUNCTION_TYPE)
+    target_quals = TYPE_QUALS (pointed_to_1) & TYPE_QUALS (pointed_to_2);
+  else
+    target_quals = TYPE_QUALS (pointed_to_1) | TYPE_QUALS (pointed_to_2);
+  t1 = build_pointer_type (c_build_qualified_type (target, target_quals));
+  return build_type_attribute_variant (t1, attributes);
+}
 
-  if (TREE_CODE (t1) == ENUMERAL_TYPE)
-    t1 = type_for_size (TYPE_PRECISION (t1), TREE_UNSIGNED (t1));
-  if (TREE_CODE (t2) == ENUMERAL_TYPE)
-    t2 = type_for_size (TYPE_PRECISION (t2), TREE_UNSIGNED (t2));
+/* Return the common type for two arithmetic types under the usual
+   arithmetic conversions.  The default conversions have already been
+   applied, and enumerated types converted to their compatible integer
+   types.  The resulting type is unqualified and has no attributes.
 
-  if (t1 == t2)
-    return 1;
+   This is the type for the result of most arithmetic operations
+   if the operands have the given two types.  */
 
-  /* Different classes of types can't be compatible.  */
+static tree
+c_common_type (tree t1, tree t2)
+{
+  enum tree_code code1;
+  enum tree_code code2;
 
-  if (TREE_CODE (t1) != TREE_CODE (t2)) return 0;
+  /* If one type is nonsense, use the other.  */
+  if (t1 == error_mark_node)
+    return t2;
+  if (t2 == error_mark_node)
+    return t1;
 
-  /* Qualifiers must match.  */
+  if (TYPE_QUALS (t1) != TYPE_UNQUALIFIED)
+    t1 = TYPE_MAIN_VARIANT (t1);
 
-  if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
-    return 0;
+  if (TYPE_QUALS (t2) != TYPE_UNQUALIFIED)
+    t2 = TYPE_MAIN_VARIANT (t2);
 
-  /* Allow for two different type nodes which have essentially the same
-     definition.  Note that we already checked for equality of the type
-     qualifiers (just above).  */
+  if (TYPE_ATTRIBUTES (t1) != NULL_TREE)
+    t1 = build_type_attribute_variant (t1, NULL_TREE);
 
-  if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
-    return 1;
+  if (TYPE_ATTRIBUTES (t2) != NULL_TREE)
+    t2 = build_type_attribute_variant (t2, NULL_TREE);
 
-  /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  if (! (attrval = (*targetm.comp_type_attributes) (t1, t2)))
-     return 0;
+  /* Save time if the two types are the same.  */
 
-  /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  val = 0;
+  if (t1 == t2) return t1;
 
-  switch (TREE_CODE (t1))
+  code1 = TREE_CODE (t1);
+  code2 = TREE_CODE (t2);
+
+  gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE
+             || code1 == FIXED_POINT_TYPE || code1 == REAL_TYPE
+             || code1 == INTEGER_TYPE);
+  gcc_assert (code2 == VECTOR_TYPE || code2 == COMPLEX_TYPE
+             || code2 == FIXED_POINT_TYPE || code2 == REAL_TYPE
+             || code2 == INTEGER_TYPE);
+
+  /* When one operand is a decimal float type, the other operand cannot be
+     a generic float type or a complex type.  We also disallow vector types
+     here.  */
+  if ((DECIMAL_FLOAT_TYPE_P (t1) || DECIMAL_FLOAT_TYPE_P (t2))
+      && !(DECIMAL_FLOAT_TYPE_P (t1) && DECIMAL_FLOAT_TYPE_P (t2)))
     {
-    case POINTER_TYPE:
-      val = (TREE_TYPE (t1) == TREE_TYPE (t2)
-             ? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2)));
-      break;
+      if (code1 == VECTOR_TYPE || code2 == VECTOR_TYPE)
+       {
+         error ("can%'t mix operands of decimal float and vector types");
+         return error_mark_node;
+       }
+      if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
+       {
+         error ("can%'t mix operands of decimal float and complex types");
+         return error_mark_node;
+       }
+      if (code1 == REAL_TYPE && code2 == REAL_TYPE)
+       {
+         error ("can%'t mix operands of decimal float and other float types");
+         return error_mark_node;
+       }
+    }
 
-    case FUNCTION_TYPE:
-      val = function_types_compatible_p (t1, t2);
-      break;
+  /* If one type is a vector type, return that type.  (How the usual
+     arithmetic conversions apply to the vector types extension is not
+     precisely specified.)  */
+  if (code1 == VECTOR_TYPE)
+    return t1;
 
-    case ARRAY_TYPE:
-      {
-       tree d1 = TYPE_DOMAIN (t1);
-       tree d2 = TYPE_DOMAIN (t2);
-       bool d1_variable, d2_variable;
-       bool d1_zero, d2_zero;
-       val = 1;
+  if (code2 == VECTOR_TYPE)
+    return t2;
 
-       /* Target types must match incl. qualifiers.  */
-       if (TREE_TYPE (t1) != TREE_TYPE (t2)
-           && 0 == (val = comptypes (TREE_TYPE (t1), TREE_TYPE (t2))))
-         return 0;
+  /* If one type is complex, form the common type of the non-complex
+     components, then make that complex.  Use T1 or T2 if it is the
+     required type.  */
+  if (code1 == COMPLEX_TYPE || code2 == COMPLEX_TYPE)
+    {
+      tree subtype1 = code1 == COMPLEX_TYPE ? TREE_TYPE (t1) : t1;
+      tree subtype2 = code2 == COMPLEX_TYPE ? TREE_TYPE (t2) : t2;
+      tree subtype = c_common_type (subtype1, subtype2);
 
-       /* Sizes must match unless one is missing or variable.  */
-       if (d1 == 0 || d2 == 0 || d1 == d2)
-         break;
+      if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype)
+       return t1;
+      else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype)
+       return t2;
+      else
+       return build_complex_type (subtype);
+    }
 
-       d1_zero = ! TYPE_MAX_VALUE (d1);
-       d2_zero = ! TYPE_MAX_VALUE (d2);
+  /* If only one is real, use it as the result.  */
 
-       d1_variable = (! d1_zero
-                      && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
-                          || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
-       d2_variable = (! d2_zero
-                      && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
-                          || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
+  if (code1 == REAL_TYPE && code2 != REAL_TYPE)
+    return t1;
 
-       if (d1_variable || d2_variable)
-         break;
-       if (d1_zero && d2_zero)
-         break;
-       if (d1_zero || d2_zero
-           || ! tree_int_cst_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
-           || ! tree_int_cst_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)))
-         val = 0;
+  if (code2 == REAL_TYPE && code1 != REAL_TYPE)
+    return t2;
 
-        break;
-      }
+  /* If both are real and either are decimal floating point types, use
+     the decimal floating point type with the greater precision. */
+
+  if (code1 == REAL_TYPE && code2 == REAL_TYPE)
+    {
+      if (TYPE_MAIN_VARIANT (t1) == dfloat128_type_node
+         || TYPE_MAIN_VARIANT (t2) == dfloat128_type_node)
+       return dfloat128_type_node;
+      else if (TYPE_MAIN_VARIANT (t1) == dfloat64_type_node
+              || TYPE_MAIN_VARIANT (t2) == dfloat64_type_node)
+       return dfloat64_type_node;
+      else if (TYPE_MAIN_VARIANT (t1) == dfloat32_type_node
+              || TYPE_MAIN_VARIANT (t2) == dfloat32_type_node)
+       return dfloat32_type_node;
+    }
+
+  /* Deal with fixed-point types.  */
+  if (code1 == FIXED_POINT_TYPE || code2 == FIXED_POINT_TYPE)
+    {
+      unsigned int unsignedp = 0, satp = 0;
+      enum machine_mode m1, m2;
+      unsigned int fbit1, ibit1, fbit2, ibit2, max_fbit, max_ibit;
+
+      m1 = TYPE_MODE (t1);
+      m2 = TYPE_MODE (t2);
+
+      /* If one input type is saturating, the result type is saturating.  */
+      if (TYPE_SATURATING (t1) || TYPE_SATURATING (t2))
+       satp = 1;
+
+      /* If both fixed-point types are unsigned, the result type is unsigned.
+        When mixing fixed-point and integer types, follow the sign of the
+        fixed-point type.
+        Otherwise, the result type is signed.  */
+      if ((TYPE_UNSIGNED (t1) && TYPE_UNSIGNED (t2)
+          && code1 == FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE)
+         || (code1 == FIXED_POINT_TYPE && code2 != FIXED_POINT_TYPE
+             && TYPE_UNSIGNED (t1))
+         || (code1 != FIXED_POINT_TYPE && code2 == FIXED_POINT_TYPE
+             && TYPE_UNSIGNED (t2)))
+       unsignedp = 1;
+
+      /* The result type is signed.  */
+      if (unsignedp == 0)
+       {
+         /* If the input type is unsigned, we need to convert to the
+            signed type.  */
+         if (code1 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t1))
+           {
+             enum mode_class mclass = (enum mode_class) 0;
+             if (GET_MODE_CLASS (m1) == MODE_UFRACT)
+               mclass = MODE_FRACT;
+             else if (GET_MODE_CLASS (m1) == MODE_UACCUM)
+               mclass = MODE_ACCUM;
+             else
+               gcc_unreachable ();
+             m1 = mode_for_size (GET_MODE_PRECISION (m1), mclass, 0);
+           }
+         if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2))
+           {
+             enum mode_class mclass = (enum mode_class) 0;
+             if (GET_MODE_CLASS (m2) == MODE_UFRACT)
+               mclass = MODE_FRACT;
+             else if (GET_MODE_CLASS (m2) == MODE_UACCUM)
+               mclass = MODE_ACCUM;
+             else
+               gcc_unreachable ();
+             m2 = mode_for_size (GET_MODE_PRECISION (m2), mclass, 0);
+           }
+       }
 
-    case RECORD_TYPE:
-      if (maybe_objc_comptypes (t1, t2, 0) == 1)
-       val = 1;
-      break;
+      if (code1 == FIXED_POINT_TYPE)
+       {
+         fbit1 = GET_MODE_FBIT (m1);
+         ibit1 = GET_MODE_IBIT (m1);
+       }
+      else
+       {
+         fbit1 = 0;
+         /* Signed integers need to subtract one sign bit.  */
+         ibit1 = TYPE_PRECISION (t1) - (!TYPE_UNSIGNED (t1));
+       }
 
-    default:
-      break;
+      if (code2 == FIXED_POINT_TYPE)
+       {
+         fbit2 = GET_MODE_FBIT (m2);
+         ibit2 = GET_MODE_IBIT (m2);
+       }
+      else
+       {
+         fbit2 = 0;
+         /* Signed integers need to subtract one sign bit.  */
+         ibit2 = TYPE_PRECISION (t2) - (!TYPE_UNSIGNED (t2));
+       }
+
+      max_ibit = ibit1 >= ibit2 ?  ibit1 : ibit2;
+      max_fbit = fbit1 >= fbit2 ?  fbit1 : fbit2;
+      return c_common_fixed_point_type_for_size (max_ibit, max_fbit, unsignedp,
+                                                satp);
     }
-  return attrval == 2 && val == 1 ? 2 : val;
-}
 
-/* Return 1 if TTL and TTR are pointers to types that are equivalent,
-   ignoring their qualifiers.  */
+  /* Both real or both integers; use the one with greater precision.  */
 
-static int
-comp_target_types (ttl, ttr)
-     tree ttl, ttr;
-{
-  int val;
+  if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
+    return t1;
+  else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
+    return t2;
 
-  /* Give maybe_objc_comptypes a crack at letting these types through.  */
-  if ((val = maybe_objc_comptypes (ttl, ttr, 1)) >= 0)
-    return val;
+  /* Same precision.  Prefer long longs to longs to ints when the
+     same precision, following the C99 rules on integer type rank
+     (which are equivalent to the C90 rules for C90 types).  */
 
-  val = comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)),
-                  TYPE_MAIN_VARIANT (TREE_TYPE (ttr)));
+  if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node
+      || TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node)
+    return long_long_unsigned_type_node;
 
-  if (val == 2 && pedantic)
-    pedwarn ("types are not quite compatible");
-  return val;
-}
-\f
-/* Subroutines of `comptypes'.  */
-
-/* Return 1 if two function types F1 and F2 are compatible.
-   If either type specifies no argument types,
-   the other must specify a fixed number of self-promoting arg types.
-   Otherwise, if one type specifies only the number of arguments, 
-   the other must specify that number of self-promoting arg types.
-   Otherwise, the argument types must match.  */
-
-static int
-function_types_compatible_p (f1, f2)
-     tree f1, f2;
-{
-  tree args1, args2;
-  /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  int val = 1;
-  int val1;
-
-  if (!(TREE_TYPE (f1) == TREE_TYPE (f2)
-       || (val = comptypes (TREE_TYPE (f1), TREE_TYPE (f2)))))
-    return 0;
-
-  args1 = TYPE_ARG_TYPES (f1);
-  args2 = TYPE_ARG_TYPES (f2);
-
-  /* An unspecified parmlist matches any specified parmlist
-     whose argument types don't need default promotions.  */
-
-  if (args1 == 0)
-    {
-      if (!self_promoting_args_p (args2))
-       return 0;
-      /* If one of these types comes from a non-prototype fn definition,
-        compare that with the other type's arglist.
-        If they don't match, ask for a warning (but no error).  */
-      if (TYPE_ACTUAL_ARG_TYPES (f1)
-         && 1 != type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1)))
-       val = 2;
-      return val;
-    }
-  if (args2 == 0)
+  if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node
+      || TYPE_MAIN_VARIANT (t2) == long_long_integer_type_node)
     {
-      if (!self_promoting_args_p (args1))
-       return 0;
-      if (TYPE_ACTUAL_ARG_TYPES (f2)
-         && 1 != type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2)))
-       val = 2;
-      return val;
+      if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
+       return long_long_unsigned_type_node;
+      else
+       return long_long_integer_type_node;
     }
 
-  /* Both types have argument lists: compare them and propagate results.  */
-  val1 = type_lists_compatible_p (args1, args2);
-  return val1 != 1 ? val1 : val;
-}
-
-/* Check two lists of types for compatibility,
-   returning 0 for incompatible, 1 for compatible,
-   or 2 for compatible with warning.  */
-
-static int
-type_lists_compatible_p (args1, args2)
-     tree args1, args2;
-{
-  /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  int val = 1;
-  int newval = 0;
+  if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
+      || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
+    return long_unsigned_type_node;
 
-  while (1)
+  if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
+      || TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
     {
-      if (args1 == 0 && args2 == 0)
-       return val;
-      /* If one list is shorter than the other,
-        they fail to match.  */
-      if (args1 == 0 || args2 == 0)
-       return 0;
-      /* A null pointer instead of a type
-        means there is supposed to be an argument
-        but nothing is specified about what type it has.
-        So match anything that self-promotes.  */
-      if (TREE_VALUE (args1) == 0)
-       {
-         if (simple_type_promotes_to (TREE_VALUE (args2)) != NULL_TREE)
-           return 0;
-       }
-      else if (TREE_VALUE (args2) == 0)
-       {
-         if (simple_type_promotes_to (TREE_VALUE (args1)) != NULL_TREE)
-           return 0;
-       }
-      else if (! (newval = comptypes (TYPE_MAIN_VARIANT (TREE_VALUE (args1)), 
-                                     TYPE_MAIN_VARIANT (TREE_VALUE (args2)))))
-       {
-         /* Allow  wait (union {union wait *u; int *i} *)
-            and  wait (union wait *)  to be compatible.  */
-         if (TREE_CODE (TREE_VALUE (args1)) == UNION_TYPE
-             && (TYPE_NAME (TREE_VALUE (args1)) == 0
-                 || TYPE_TRANSPARENT_UNION (TREE_VALUE (args1)))
-             && TREE_CODE (TYPE_SIZE (TREE_VALUE (args1))) == INTEGER_CST
-             && tree_int_cst_equal (TYPE_SIZE (TREE_VALUE (args1)),
-                                    TYPE_SIZE (TREE_VALUE (args2))))
-           {
-             tree memb;
-             for (memb = TYPE_FIELDS (TREE_VALUE (args1));
-                  memb; memb = TREE_CHAIN (memb))
-               if (comptypes (TREE_TYPE (memb), TREE_VALUE (args2)))
-                 break;
-             if (memb == 0)
-               return 0;
-           }
-         else if (TREE_CODE (TREE_VALUE (args2)) == UNION_TYPE
-                  && (TYPE_NAME (TREE_VALUE (args2)) == 0
-                      || TYPE_TRANSPARENT_UNION (TREE_VALUE (args2)))
-                  && TREE_CODE (TYPE_SIZE (TREE_VALUE (args2))) == INTEGER_CST
-                  && tree_int_cst_equal (TYPE_SIZE (TREE_VALUE (args2)),
-                                         TYPE_SIZE (TREE_VALUE (args1))))
-           {
-             tree memb;
-             for (memb = TYPE_FIELDS (TREE_VALUE (args2));
-                  memb; memb = TREE_CHAIN (memb))
-               if (comptypes (TREE_TYPE (memb), TREE_VALUE (args1)))
-                 break;
-             if (memb == 0)
-               return 0;
-           }
-         else
-           return 0;
-       }
+      /* But preserve unsignedness from the other type,
+        since long cannot hold all the values of an unsigned int.  */
+      if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
+       return long_unsigned_type_node;
+      else
+       return long_integer_type_node;
+    }
 
-      /* comptypes said ok, but record if it said to warn.  */
-      if (newval > val)
-       val = newval;
+  /* Likewise, prefer long double to double even if same size.  */
+  if (TYPE_MAIN_VARIANT (t1) == long_double_type_node
+      || TYPE_MAIN_VARIANT (t2) == long_double_type_node)
+    return long_double_type_node;
 
-      args1 = TREE_CHAIN (args1);
-      args2 = TREE_CHAIN (args2);
-    }
+  /* Otherwise prefer the unsigned one.  */
+
+  if (TYPE_UNSIGNED (t1))
+    return t1;
+  else
+    return t2;
 }
 \f
-/* Compute the value of the `sizeof' operator.  */
-
+/* Wrapper around c_common_type that is used by c-common.c and other
+   front end optimizations that remove promotions.  ENUMERAL_TYPEs
+   are allowed here and are converted to their compatible integer types.
+   BOOLEAN_TYPEs are allowed here and return either boolean_type_node or
+   preferably a non-Boolean type as the common type.  */
 tree
-c_sizeof (type)
-     tree type;
+common_type (tree t1, tree t2)
 {
-  enum tree_code code = TREE_CODE (type);
-  tree size;
+  if (TREE_CODE (t1) == ENUMERAL_TYPE)
+    t1 = c_common_type_for_size (TYPE_PRECISION (t1), 1);
+  if (TREE_CODE (t2) == ENUMERAL_TYPE)
+    t2 = c_common_type_for_size (TYPE_PRECISION (t2), 1);
 
-  if (code == FUNCTION_TYPE)
-    {
-      if (pedantic || warn_pointer_arith)
-       pedwarn ("sizeof applied to a function type");
-      size = size_one_node;
-    }
-  else if (code == VOID_TYPE)
-    {
-      if (pedantic || warn_pointer_arith)
-       pedwarn ("sizeof applied to a void type");
-      size = size_one_node;
-    }
-  else if (code == ERROR_MARK)
-    size = size_one_node;
-  else if (!COMPLETE_TYPE_P (type))
-    {
-      error ("sizeof applied to an incomplete type");
-      size = size_zero_node;
-    }
-  else
-    /* Convert in case a char is more than one unit.  */
-    size = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
-                      size_int (TYPE_PRECISION (char_type_node)
-                                / BITS_PER_UNIT));
-
-  /* SIZE will have an integer type with TYPE_IS_SIZETYPE set.
-     TYPE_IS_SIZETYPE means that certain things (like overflow) will
-     never happen.  However, this node should really have type
-     `size_t', which is just a typedef for an ordinary integer type.  */
-  return fold (build1 (NOP_EXPR, size_type_node, size));
-}
+  /* If both types are BOOLEAN_TYPE, then return boolean_type_node.  */
+  if (TREE_CODE (t1) == BOOLEAN_TYPE
+      && TREE_CODE (t2) == BOOLEAN_TYPE)
+    return boolean_type_node;
 
-tree
-c_sizeof_nowarn (type)
-     tree type;
-{
-  enum tree_code code = TREE_CODE (type);
-  tree size;
+  /* If either type is BOOLEAN_TYPE, then return the other.  */
+  if (TREE_CODE (t1) == BOOLEAN_TYPE)
+    return t2;
+  if (TREE_CODE (t2) == BOOLEAN_TYPE)
+    return t1;
 
-  if (code == FUNCTION_TYPE || code == VOID_TYPE || code == ERROR_MARK)
-    size = size_one_node;
-  else if (!COMPLETE_TYPE_P (type))
-    size = size_zero_node;
-  else
-    /* Convert in case a char is more than one unit.  */
-    size = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
-                      size_int (TYPE_PRECISION (char_type_node)
-                                / BITS_PER_UNIT));
-
-  /* SIZE will have an integer type with TYPE_IS_SIZETYPE set.
-     TYPE_IS_SIZETYPE means that certain things (like overflow) will
-     never happen.  However, this node should really have type
-     `size_t', which is just a typedef for an ordinary integer type.  */
-  return fold (build1 (NOP_EXPR, size_type_node, size));
+  return c_common_type (t1, t2);
 }
 
-/* Compute the size to increment a pointer by.  */
+/* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
+   or various other operations.  Return 2 if they are compatible
+   but a warning may be needed if you use them together.  */
 
-tree
-c_size_in_bytes (type)
-     tree type;
+int
+comptypes (tree type1, tree type2)
 {
-  enum tree_code code = TREE_CODE (type);
-
-  if (code == FUNCTION_TYPE || code == VOID_TYPE || code == ERROR_MARK)
-    return size_one_node;
+  const struct tagged_tu_seen_cache * tagged_tu_seen_base1 = tagged_tu_seen_base;
+  int val;
 
-  if (!COMPLETE_OR_VOID_TYPE_P (type))
-    {
-      error ("arithmetic on pointer to an incomplete type");
-      return size_one_node;
-    }
+  val = comptypes_internal (type1, type2);
+  free_all_tagged_tu_seen_up_to (tagged_tu_seen_base1);
 
-  /* Convert in case a char is more than one unit.  */
-  return size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
-                    size_int (TYPE_PRECISION (char_type_node)
-                              / BITS_PER_UNIT));
+  return val;
 }
 \f
-/* Return either DECL or its known constant value (if it has one).  */
+/* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
+   or various other operations.  Return 2 if they are compatible
+   but a warning may be needed if you use them together.  This
+   differs from comptypes, in that we don't free the seen types.  */
 
-tree
-decl_constant_value (decl)
-     tree decl;
+static int
+comptypes_internal (const_tree type1, const_tree type2)
 {
-  if (/* Don't change a variable array bound or initial value to a constant
-        in a place where a variable is invalid.  */
-      current_function_decl != 0
-      && ! TREE_THIS_VOLATILE (decl)
-      && TREE_READONLY (decl)
-      && DECL_INITIAL (decl) != 0
-      && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
-      /* This is invalid if initial value is not constant.
-        If it has either a function call, a memory reference,
-        or a variable, then re-evaluating it could give different results.  */
-      && TREE_CONSTANT (DECL_INITIAL (decl))
-      /* Check for cases where this is sub-optimal, even though valid.  */
-      && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR)
-    return DECL_INITIAL (decl);
-  return decl;
-}
+  const_tree t1 = type1;
+  const_tree t2 = type2;
+  int attrval, val;
 
-/* Return either DECL or its known constant value (if it has one), but
-   return DECL if pedantic or DECL has mode BLKmode.  This is for
-   bug-compatibility with the old behavior of decl_constant_value
-   (before GCC 3.0); every use of this function is a bug and it should
-   be removed before GCC 3.1.  It is not appropriate to use pedantic
-   in a way that affects optimization, and BLKmode is probably not the
-   right test for avoiding misoptimizations either.  */
+  /* Suppress errors caused by previously reported errors.  */
 
-static tree
-decl_constant_value_for_broken_optimization (decl)
-     tree decl;
-{
-  if (pedantic || DECL_MODE (decl) == BLKmode)
-    return decl;
-  else
-    return decl_constant_value (decl);
-}
+  if (t1 == t2 || !t1 || !t2
+      || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
+    return 1;
 
+  /* If either type is the internal version of sizetype, return the
+     language version.  */
+  if (TREE_CODE (t1) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t1)
+      && TYPE_ORIG_SIZE_TYPE (t1))
+    t1 = TYPE_ORIG_SIZE_TYPE (t1);
 
-/* Perform the default conversion of arrays and functions to pointers.
-   Return the result of converting EXP.  For any other expression, just
-   return EXP.  */
+  if (TREE_CODE (t2) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t2)
+      && TYPE_ORIG_SIZE_TYPE (t2))
+    t2 = TYPE_ORIG_SIZE_TYPE (t2);
 
-static tree
-default_function_array_conversion (exp)
-     tree exp;
-{
-  tree orig_exp;
-  tree type = TREE_TYPE (exp);
-  enum tree_code code = TREE_CODE (type);
-  int not_lvalue = 0;
 
-  /* Strip NON_LVALUE_EXPRs and no-op conversions, since we aren't using as
-     an lvalue. 
+  /* Enumerated types are compatible with integer types, but this is
+     not transitive: two enumerated types in the same translation unit
+     are compatible with each other only if they are the same type.  */
 
-     Do not use STRIP_NOPS here!  It will remove conversions from pointer
-     to integer and cause infinite recursion.  */
-  orig_exp = exp;
-  while (TREE_CODE (exp) == NON_LVALUE_EXPR
-        || (TREE_CODE (exp) == NOP_EXPR
-            && TREE_TYPE (TREE_OPERAND (exp, 0)) == TREE_TYPE (exp)))
-    {
-      if (TREE_CODE (exp) == NON_LVALUE_EXPR)
-       not_lvalue = 1;
-      exp = TREE_OPERAND (exp, 0);
-    }
+  if (TREE_CODE (t1) == ENUMERAL_TYPE && TREE_CODE (t2) != ENUMERAL_TYPE)
+    t1 = c_common_type_for_size (TYPE_PRECISION (t1), TYPE_UNSIGNED (t1));
+  else if (TREE_CODE (t2) == ENUMERAL_TYPE && TREE_CODE (t1) != ENUMERAL_TYPE)
+    t2 = c_common_type_for_size (TYPE_PRECISION (t2), TYPE_UNSIGNED (t2));
 
-  /* Preserve the original expression code.  */
-  if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (exp))))
-    C_SET_EXP_ORIGINAL_CODE (exp, C_EXP_ORIGINAL_CODE (orig_exp));
+  if (t1 == t2)
+    return 1;
 
-  if (code == FUNCTION_TYPE)
-    {
-      return build_unary_op (ADDR_EXPR, exp, 0);
-    }
-  if (code == ARRAY_TYPE)
-    {
-      tree adr;
-      tree restype = TREE_TYPE (type);
-      tree ptrtype;
-      int constp = 0;
-      int volatilep = 0;
-      int lvalue_array_p;
+  /* Different classes of types can't be compatible.  */
 
-      if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'r' || DECL_P (exp))
-       {
-         constp = TREE_READONLY (exp);
-         volatilep = TREE_THIS_VOLATILE (exp);
-       }
+  if (TREE_CODE (t1) != TREE_CODE (t2))
+    return 0;
 
-      if (TYPE_QUALS (type) || constp || volatilep)
-       restype 
-         = c_build_qualified_type (restype,
-                                   TYPE_QUALS (type) 
-                                   | (constp * TYPE_QUAL_CONST)
-                                   | (volatilep * TYPE_QUAL_VOLATILE));
+  /* Qualifiers must match. C99 6.7.3p9 */
 
-      if (TREE_CODE (exp) == INDIRECT_REF)
-       return convert (TYPE_POINTER_TO (restype),
-                       TREE_OPERAND (exp, 0));
+  if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
+    return 0;
 
-      if (TREE_CODE (exp) == COMPOUND_EXPR)
-       {
-         tree op1 = default_conversion (TREE_OPERAND (exp, 1));
-         return build (COMPOUND_EXPR, TREE_TYPE (op1),
-                       TREE_OPERAND (exp, 0), op1);
-       }
+  /* Allow for two different type nodes which have essentially the same
+     definition.  Note that we already checked for equality of the type
+     qualifiers (just above).  */
 
-      lvalue_array_p = !not_lvalue && lvalue_p (exp);
-      if (!flag_isoc99 && !lvalue_array_p)
-       {
-         /* Before C99, non-lvalue arrays do not decay to pointers.
-            Normally, using such an array would be invalid; but it can
-            be used correctly inside sizeof or as a statement expression.
-            Thus, do not give an error here; an error will result later.  */
-         return exp;
-       }
+  if (TREE_CODE (t1) != ARRAY_TYPE
+      && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
+    return 1;
 
-      ptrtype = build_pointer_type (restype);
+  /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
+  if (!(attrval = targetm.comp_type_attributes (t1, t2)))
+     return 0;
 
-      if (TREE_CODE (exp) == VAR_DECL)
-       {
-         /* ??? This is not really quite correct
-            in that the type of the operand of ADDR_EXPR
-            is not the target type of the type of the ADDR_EXPR itself.
-            Question is, can this lossage be avoided?  */
-         adr = build1 (ADDR_EXPR, ptrtype, exp);
-         if (mark_addressable (exp) == 0)
-           return error_mark_node;
-         TREE_CONSTANT (adr) = staticp (exp);
-         TREE_SIDE_EFFECTS (adr) = 0;   /* Default would be, same as EXP.  */
-         return adr;
-       }
-      /* This way is better for a COMPONENT_REF since it can
-        simplify the offset for a component.  */
-      adr = build_unary_op (ADDR_EXPR, exp, 1);
-      return convert (ptrtype, adr);
-    }
-  return exp;
-}
+  /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
+  val = 0;
 
-/* Perform default promotions for C data used in expressions.
-   Arrays and functions are converted to pointers;
-   enumeral types or short or char, to int.
-   In addition, manifest constants symbols are replaced by their values.  */
+  switch (TREE_CODE (t1))
+    {
+    case POINTER_TYPE:
+      /* Do not remove mode or aliasing information.  */
+      if (TYPE_MODE (t1) != TYPE_MODE (t2)
+         || TYPE_REF_CAN_ALIAS_ALL (t1) != TYPE_REF_CAN_ALIAS_ALL (t2))
+       break;
+      val = (TREE_TYPE (t1) == TREE_TYPE (t2)
+            ? 1 : comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2)));
+      break;
 
-tree
-default_conversion (exp)
-     tree exp;
-{
-  tree orig_exp;
-  tree type = TREE_TYPE (exp);
-  enum tree_code code = TREE_CODE (type);
+    case FUNCTION_TYPE:
+      val = function_types_compatible_p (t1, t2);
+      break;
 
-  if (code == FUNCTION_TYPE || code == ARRAY_TYPE)
-    return default_function_array_conversion (exp);
+    case ARRAY_TYPE:
+      {
+       tree d1 = TYPE_DOMAIN (t1);
+       tree d2 = TYPE_DOMAIN (t2);
+       bool d1_variable, d2_variable;
+       bool d1_zero, d2_zero;
+       val = 1;
 
-  /* Constants can be used directly unless they're not loadable.  */
-  if (TREE_CODE (exp) == CONST_DECL)
-    exp = DECL_INITIAL (exp);
+       /* Target types must match incl. qualifiers.  */
+       if (TREE_TYPE (t1) != TREE_TYPE (t2)
+           && 0 == (val = comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2))))
+         return 0;
 
-  /* Replace a nonvolatile const static variable with its value unless
-     it is an array, in which case we must be sure that taking the
-     address of the array produces consistent results.  */
-  else if (optimize && TREE_CODE (exp) == VAR_DECL && code != ARRAY_TYPE)
-    {
-      exp = decl_constant_value_for_broken_optimization (exp);
-      type = TREE_TYPE (exp);
-    }
+       /* Sizes must match unless one is missing or variable.  */
+       if (d1 == 0 || d2 == 0 || d1 == d2)
+         break;
 
-  /* Strip NON_LVALUE_EXPRs and no-op conversions, since we aren't using as
-     an lvalue. 
+       d1_zero = !TYPE_MAX_VALUE (d1);
+       d2_zero = !TYPE_MAX_VALUE (d2);
 
-     Do not use STRIP_NOPS here!  It will remove conversions from pointer
-     to integer and cause infinite recursion.  */
-  orig_exp = exp;
-  while (TREE_CODE (exp) == NON_LVALUE_EXPR
-        || (TREE_CODE (exp) == NOP_EXPR
-            && TREE_TYPE (TREE_OPERAND (exp, 0)) == TREE_TYPE (exp)))
-    exp = TREE_OPERAND (exp, 0);
+       d1_variable = (!d1_zero
+                      && (TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
+                          || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST));
+       d2_variable = (!d2_zero
+                      && (TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
+                          || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST));
+       d1_variable = d1_variable || (d1_zero && c_vla_type_p (t1));
+       d2_variable = d2_variable || (d2_zero && c_vla_type_p (t2));
 
-  /* Preserve the original expression code.  */
-  if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (exp))))
-    C_SET_EXP_ORIGINAL_CODE (exp, C_EXP_ORIGINAL_CODE (orig_exp));
+       if (d1_variable || d2_variable)
+         break;
+       if (d1_zero && d2_zero)
+         break;
+       if (d1_zero || d2_zero
+           || !tree_int_cst_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
+           || !tree_int_cst_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)))
+         val = 0;
 
-  /* Normally convert enums to int,
-     but convert wide enums to something wider.  */
-  if (code == ENUMERAL_TYPE)
-    {
-      type = type_for_size (MAX (TYPE_PRECISION (type),
-                                TYPE_PRECISION (integer_type_node)),
-                           ((flag_traditional
-                             || (TYPE_PRECISION (type)
-                                 >= TYPE_PRECISION (integer_type_node)))
-                            && TREE_UNSIGNED (type)));
+       break;
+      }
 
-      return convert (type, exp);
-    }
+    case ENUMERAL_TYPE:
+    case RECORD_TYPE:
+    case UNION_TYPE:
+      if (val != 1 && !same_translation_unit_p (t1, t2))
+       {
+         tree a1 = TYPE_ATTRIBUTES (t1);
+         tree a2 = TYPE_ATTRIBUTES (t2);
 
-  if (TREE_CODE (exp) == COMPONENT_REF
-      && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1))
-      /* If it's thinner than an int, promote it like a
-        c_promoting_integer_type_p, otherwise leave it alone.  */
-      && 0 > compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)),
-                              TYPE_PRECISION (integer_type_node)))
-    return convert (flag_traditional && TREE_UNSIGNED (type)
-                   ? unsigned_type_node : integer_type_node,
-                   exp);
+         if (! attribute_list_contained (a1, a2)
+             && ! attribute_list_contained (a2, a1))
+           break;
 
-  if (c_promoting_integer_type_p (type))
-    {
-      /* Traditionally, unsignedness is preserved in default promotions.
-         Also preserve unsignedness if not really getting any wider.  */
-      if (TREE_UNSIGNED (type)
-         && (flag_traditional
-             || TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
-       return convert (unsigned_type_node, exp);
+         if (attrval != 2)
+           return tagged_types_tu_compatible_p (t1, t2);
+         val = tagged_types_tu_compatible_p (t1, t2);
+       }
+      break;
 
-      return convert (integer_type_node, exp);
+    case VECTOR_TYPE:
+      val = TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2)
+           && comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2));
+      break;
+
+    default:
+      break;
     }
+  return attrval == 2 && val == 1 ? 2 : val;
+}
 
-  if (flag_traditional && !flag_allow_single_precision
-      && TYPE_MAIN_VARIANT (type) == float_type_node)
-    return convert (double_type_node, exp);
+/* Return 1 if TTL and TTR are pointers to types that are equivalent,
+   ignoring their qualifiers.  */
 
-  if (code == VOID_TYPE)
-    {
-      error ("void value not ignored as it ought to be");
-      return error_mark_node;
-    }
-  return exp;
+static int
+comp_target_types (tree ttl, tree ttr)
+{
+  int val;
+  tree mvl, mvr;
+
+  /* Do not lose qualifiers on element types of array types that are
+     pointer targets by taking their TYPE_MAIN_VARIANT.  */
+  mvl = TREE_TYPE (ttl);
+  mvr = TREE_TYPE (ttr);
+  if (TREE_CODE (mvl) != ARRAY_TYPE)
+    mvl = TYPE_MAIN_VARIANT (mvl);
+  if (TREE_CODE (mvr) != ARRAY_TYPE)
+    mvr = TYPE_MAIN_VARIANT (mvr);
+  val = comptypes (mvl, mvr);
+
+  if (val == 2)
+    pedwarn (input_location, OPT_pedantic, "types are not quite compatible");
+  return val;
 }
 \f
-/* Look up COMPONENT in a structure or union DECL.
+/* Subroutines of `comptypes'.  */
 
-   If the component name is not found, returns NULL_TREE.  Otherwise,
-   the return value is a TREE_LIST, with each TREE_VALUE a FIELD_DECL
-   stepping down the chain to the component, which is in the last
-   TREE_VALUE of the list.  Normally the list is of length one, but if
-   the component is embedded within (nested) anonymous structures or
-   unions, the list steps down the chain to the component.  */
-     
-static tree
-lookup_field (decl, component)
-     tree decl, component;
+/* Determine whether two trees derive from the same translation unit.
+   If the CONTEXT chain ends in a null, that tree's context is still
+   being parsed, so if two trees have context chains ending in null,
+   they're in the same translation unit.  */
+int
+same_translation_unit_p (const_tree t1, const_tree t2)
 {
-  tree type = TREE_TYPE (decl);
-  tree field;
+  while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL)
+    switch (TREE_CODE_CLASS (TREE_CODE (t1)))
+      {
+      case tcc_declaration:
+       t1 = DECL_CONTEXT (t1); break;
+      case tcc_type:
+       t1 = TYPE_CONTEXT (t1); break;
+      case tcc_exceptional:
+       t1 = BLOCK_SUPERCONTEXT (t1); break;  /* assume block */
+      default: gcc_unreachable ();
+      }
 
-  /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
-     to the field elements.  Use a binary search on this array to quickly
-     find the element.  Otherwise, do a linear search.  TYPE_LANG_SPECIFIC
-     will always be set for structures which have many elements.  */
+  while (t2 && TREE_CODE (t2) != TRANSLATION_UNIT_DECL)
+    switch (TREE_CODE_CLASS (TREE_CODE (t2)))
+      {
+      case tcc_declaration:
+       t2 = DECL_CONTEXT (t2); break;
+      case tcc_type:
+       t2 = TYPE_CONTEXT (t2); break;
+      case tcc_exceptional:
+       t2 = BLOCK_SUPERCONTEXT (t2); break;  /* assume block */
+      default: gcc_unreachable ();
+      }
 
-  if (TYPE_LANG_SPECIFIC (type))
-    {
-      int bot, top, half;
-      tree *field_array = &TYPE_LANG_SPECIFIC (type)->elts[0];
+  return t1 == t2;
+}
 
-      field = TYPE_FIELDS (type);
-      bot = 0;
-      top = TYPE_LANG_SPECIFIC (type)->len;
-      while (top - bot > 1)
-       {
-         half = (top - bot + 1) >> 1;
-         field = field_array[bot+half];
+/* Allocate the seen two types, assuming that they are compatible. */
 
-         if (DECL_NAME (field) == NULL_TREE)
-           {
-             /* Step through all anon unions in linear fashion.  */
-             while (DECL_NAME (field_array[bot]) == NULL_TREE)
-               {
-                 field = field_array[bot++];
-                 if (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
-                     || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
-                   {
-                     tree anon = lookup_field (field, component);
+static struct tagged_tu_seen_cache *
+alloc_tagged_tu_seen_cache (const_tree t1, const_tree t2)
+{
+  struct tagged_tu_seen_cache *tu = XNEW (struct tagged_tu_seen_cache);
+  tu->next = tagged_tu_seen_base;
+  tu->t1 = t1;
+  tu->t2 = t2;
+
+  tagged_tu_seen_base = tu;
+
+  /* The C standard says that two structures in different translation
+     units are compatible with each other only if the types of their
+     fields are compatible (among other things).  We assume that they
+     are compatible until proven otherwise when building the cache.
+     An example where this can occur is:
+     struct a
+     {
+       struct a *next;
+     };
+     If we are comparing this against a similar struct in another TU,
+     and did not assume they were compatible, we end up with an infinite
+     loop.  */
+  tu->val = 1;
+  return tu;
+}
 
-                     if (anon)
-                       return tree_cons (NULL_TREE, field, anon);
-                   } 
-               }
+/* Free the seen types until we get to TU_TIL. */
 
-             /* Entire record is only anon unions.  */
-             if (bot > top)
-               return NULL_TREE;
+static void
+free_all_tagged_tu_seen_up_to (const struct tagged_tu_seen_cache *tu_til)
+{
+  const struct tagged_tu_seen_cache *tu = tagged_tu_seen_base;
+  while (tu != tu_til)
+    {
+      const struct tagged_tu_seen_cache *const tu1
+       = (const struct tagged_tu_seen_cache *) tu;
+      tu = tu1->next;
+      free (CONST_CAST (struct tagged_tu_seen_cache *, tu1));
+    }
+  tagged_tu_seen_base = tu_til;
+}
 
-             /* Restart the binary search, with new lower bound.  */
-             continue;
-           }
+/* Return 1 if two 'struct', 'union', or 'enum' types T1 and T2 are
+   compatible.  If the two types are not the same (which has been
+   checked earlier), this can only happen when multiple translation
+   units are being compiled.  See C99 6.2.7 paragraph 1 for the exact
+   rules.  */
 
-         if (DECL_NAME (field) == component)
-           break;
-         if (DECL_NAME (field) < component)
-           bot += half;
-         else
-           top = bot + half;
-       }
+static int
+tagged_types_tu_compatible_p (const_tree t1, const_tree t2)
+{
+  tree s1, s2;
+  bool needs_warning = false;
+
+  /* We have to verify that the tags of the types are the same.  This
+     is harder than it looks because this may be a typedef, so we have
+     to go look at the original type.  It may even be a typedef of a
+     typedef...
+     In the case of compiler-created builtin structs the TYPE_DECL
+     may be a dummy, with no DECL_ORIGINAL_TYPE.  Don't fault.  */
+  while (TYPE_NAME (t1)
+        && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL
+        && DECL_ORIGINAL_TYPE (TYPE_NAME (t1)))
+    t1 = DECL_ORIGINAL_TYPE (TYPE_NAME (t1));
+
+  while (TYPE_NAME (t2)
+        && TREE_CODE (TYPE_NAME (t2)) == TYPE_DECL
+        && DECL_ORIGINAL_TYPE (TYPE_NAME (t2)))
+    t2 = DECL_ORIGINAL_TYPE (TYPE_NAME (t2));
+
+  /* C90 didn't have the requirement that the two tags be the same.  */
+  if (flag_isoc99 && TYPE_NAME (t1) != TYPE_NAME (t2))
+    return 0;
 
-      if (DECL_NAME (field_array[bot]) == component)
-       field = field_array[bot];
-      else if (DECL_NAME (field) != component)
-       return NULL_TREE;
-    }
-  else
-    {
-      for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
-       {
-         if (DECL_NAME (field) == NULL_TREE
-             && (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
-                 || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE))
-           {
-             tree anon = lookup_field (field, component);
+  /* C90 didn't say what happened if one or both of the types were
+     incomplete; we choose to follow C99 rules here, which is that they
+     are compatible.  */
+  if (TYPE_SIZE (t1) == NULL
+      || TYPE_SIZE (t2) == NULL)
+    return 1;
 
-             if (anon)
-               return tree_cons (NULL_TREE, field, anon);
-           }
+  {
+    const struct tagged_tu_seen_cache * tts_i;
+    for (tts_i = tagged_tu_seen_base; tts_i != NULL; tts_i = tts_i->next)
+      if (tts_i->t1 == t1 && tts_i->t2 == t2)
+       return tts_i->val;
+  }
 
-         if (DECL_NAME (field) == component)
-           break;
-       }
+  switch (TREE_CODE (t1))
+    {
+    case ENUMERAL_TYPE:
+      {
+       struct tagged_tu_seen_cache *tu = alloc_tagged_tu_seen_cache (t1, t2);
+       /* Speed up the case where the type values are in the same order.  */
+       tree tv1 = TYPE_VALUES (t1);
+       tree tv2 = TYPE_VALUES (t2);
 
-      if (field == NULL_TREE)
-       return NULL_TREE;
-    }
+       if (tv1 == tv2)
+         {
+           return 1;
+         }
 
-  return tree_cons (NULL_TREE, field, NULL_TREE);
-}
+       for (;tv1 && tv2; tv1 = TREE_CHAIN (tv1), tv2 = TREE_CHAIN (tv2))
+         {
+           if (TREE_PURPOSE (tv1) != TREE_PURPOSE (tv2))
+             break;
+           if (simple_cst_equal (TREE_VALUE (tv1), TREE_VALUE (tv2)) != 1)
+             {
+               tu->val = 0;
+               return 0;
+             }
+         }
 
-/* Make an expression to refer to the COMPONENT field of
-   structure or union value DATUM.  COMPONENT is an IDENTIFIER_NODE.  */
+       if (tv1 == NULL_TREE && tv2 == NULL_TREE)
+         {
+           return 1;
+         }
+       if (tv1 == NULL_TREE || tv2 == NULL_TREE)
+         {
+           tu->val = 0;
+           return 0;
+         }
 
-tree
-build_component_ref (datum, component)
-     tree datum, component;
-{
-  tree type = TREE_TYPE (datum);
-  enum tree_code code = TREE_CODE (type);
-  tree field = NULL;
-  tree ref;
+       if (list_length (TYPE_VALUES (t1)) != list_length (TYPE_VALUES (t2)))
+         {
+           tu->val = 0;
+           return 0;
+         }
 
-  /* If DATUM is a COMPOUND_EXPR, move our reference inside it.
-     If pedantic ensure that the arguments are not lvalues; otherwise,
-     if the component is an array, it would wrongly decay to a pointer in
-     C89 mode.
-     We cannot do this with a COND_EXPR, because in a conditional expression
-     the default promotions are applied to both sides, and this would yield
-     the wrong type of the result; for example, if the components have
-     type "char".  */
-  switch (TREE_CODE (datum))
-    {
-    case COMPOUND_EXPR:
-      {
-       tree value = build_component_ref (TREE_OPERAND (datum, 1), component);
-       return build (COMPOUND_EXPR, TREE_TYPE (value),
-                     TREE_OPERAND (datum, 0), pedantic_non_lvalue (value));
+       for (s1 = TYPE_VALUES (t1); s1; s1 = TREE_CHAIN (s1))
+         {
+           s2 = purpose_member (TREE_PURPOSE (s1), TYPE_VALUES (t2));
+           if (s2 == NULL
+               || simple_cst_equal (TREE_VALUE (s1), TREE_VALUE (s2)) != 1)
+             {
+               tu->val = 0;
+               return 0;
+             }
+         }
+       return 1;
       }
-    default:
-      break;
-    }
 
-  /* See if there is a field or component with name COMPONENT.  */
-
-  if (code == RECORD_TYPE || code == UNION_TYPE)
-    {
-      if (!COMPLETE_TYPE_P (type))
-       {
-         incomplete_type_error (NULL_TREE, type);
-         return error_mark_node;
-       }
+    case UNION_TYPE:
+      {
+       struct tagged_tu_seen_cache *tu = alloc_tagged_tu_seen_cache (t1, t2);
+       if (list_length (TYPE_FIELDS (t1)) != list_length (TYPE_FIELDS (t2)))
+         {
+           tu->val = 0;
+           return 0;
+         }
 
-      field = lookup_field (datum, component);
+       /*  Speed up the common case where the fields are in the same order. */
+       for (s1 = TYPE_FIELDS (t1), s2 = TYPE_FIELDS (t2); s1 && s2;
+            s1 = TREE_CHAIN (s1), s2 = TREE_CHAIN (s2))
+         {
+           int result;
 
-      if (!field)
-       {
-         error ("%s has no member named `%s'",
-                code == RECORD_TYPE ? "structure" : "union",
-                IDENTIFIER_POINTER (component));
-         return error_mark_node;
-       }
+           if (DECL_NAME (s1) != DECL_NAME (s2))
+             break;
+           result = comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2));
 
-      /* Chain the COMPONENT_REFs if necessary down to the FIELD.
-        This might be better solved in future the way the C++ front
-        end does it - by giving the anonymous entities each a
-        separate name and type, and then have build_component_ref
-        recursively call itself.  We can't do that here.  */
-      for (; field; field = TREE_CHAIN (field))
-       {
-         tree subdatum = TREE_VALUE (field);
+           if (result != 1 && !DECL_NAME (s1))
+             break;
+           if (result == 0)
+             {
+               tu->val = 0;
+               return 0;
+             }
+           if (result == 2)
+             needs_warning = true;
 
-         if (TREE_TYPE (subdatum) == error_mark_node)
-           return error_mark_node;
+           if (TREE_CODE (s1) == FIELD_DECL
+               && simple_cst_equal (DECL_FIELD_BIT_OFFSET (s1),
+                                    DECL_FIELD_BIT_OFFSET (s2)) != 1)
+             {
+               tu->val = 0;
+               return 0;
+             }
+         }
+       if (!s1 && !s2)
+         {
+           tu->val = needs_warning ? 2 : 1;
+           return tu->val;
+         }
 
-         ref = build (COMPONENT_REF, TREE_TYPE (subdatum), datum, subdatum);
-         if (TREE_READONLY (datum) || TREE_READONLY (subdatum))
-           TREE_READONLY (ref) = 1;
-         if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (subdatum))
-           TREE_THIS_VOLATILE (ref) = 1;
+       for (s1 = TYPE_FIELDS (t1); s1; s1 = TREE_CHAIN (s1))
+         {
+           bool ok = false;
 
-         if (TREE_DEPRECATED (subdatum))
-           warn_deprecated_use (subdatum);
+           for (s2 = TYPE_FIELDS (t2); s2; s2 = TREE_CHAIN (s2))
+             if (DECL_NAME (s1) == DECL_NAME (s2))
+               {
+                 int result;
 
-         datum = ref;
-       }
+                 result = comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2));
 
-      return ref;
-    }
-  else if (code != ERROR_MARK)
-    error ("request for member `%s' in something not a structure or union",
-           IDENTIFIER_POINTER (component));
+                 if (result != 1 && !DECL_NAME (s1))
+                   continue;
+                 if (result == 0)
+                   {
+                     tu->val = 0;
+                     return 0;
+                   }
+                 if (result == 2)
+                   needs_warning = true;
 
-  return error_mark_node;
-}
-\f
-/* Given an expression PTR for a pointer, return an expression
-   for the value pointed to.
-   ERRORSTRING is the name of the operator to appear in error messages.  */
+                 if (TREE_CODE (s1) == FIELD_DECL
+                     && simple_cst_equal (DECL_FIELD_BIT_OFFSET (s1),
+                                          DECL_FIELD_BIT_OFFSET (s2)) != 1)
+                   break;
 
-tree
-build_indirect_ref (ptr, errorstring)
-     tree ptr;
-     const char *errorstring;
-{
-  tree pointer = default_conversion (ptr);
-  tree type = TREE_TYPE (pointer);
+                 ok = true;
+                 break;
+               }
+           if (!ok)
+             {
+               tu->val = 0;
+               return 0;
+             }
+         }
+       tu->val = needs_warning ? 2 : 10;
+       return tu->val;
+      }
 
-  if (TREE_CODE (type) == POINTER_TYPE)
-    {
-      if (TREE_CODE (pointer) == ADDR_EXPR
-         && !flag_volatile
-         && (TREE_TYPE (TREE_OPERAND (pointer, 0))
-             == TREE_TYPE (type)))
-       return TREE_OPERAND (pointer, 0);
-      else
-       {
-         tree t = TREE_TYPE (type);
-         tree ref = build1 (INDIRECT_REF, TYPE_MAIN_VARIANT (t), pointer);
+    case RECORD_TYPE:
+      {
+       struct tagged_tu_seen_cache *tu = alloc_tagged_tu_seen_cache (t1, t2);
 
-         if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE)
-           {
-             error ("dereferencing pointer to incomplete type");
-             return error_mark_node;
-           }
-         if (VOID_TYPE_P (t) && skip_evaluation == 0)
-           warning ("dereferencing `void *' pointer");
+       for (s1 = TYPE_FIELDS (t1), s2 = TYPE_FIELDS (t2);
+            s1 && s2;
+            s1 = TREE_CHAIN (s1), s2 = TREE_CHAIN (s2))
+         {
+           int result;
+           if (TREE_CODE (s1) != TREE_CODE (s2)
+               || DECL_NAME (s1) != DECL_NAME (s2))
+             break;
+           result = comptypes_internal (TREE_TYPE (s1), TREE_TYPE (s2));
+           if (result == 0)
+             break;
+           if (result == 2)
+             needs_warning = true;
 
-         /* We *must* set TREE_READONLY when dereferencing a pointer to const,
-            so that we get the proper error message if the result is used
-            to assign to.  Also, &* is supposed to be a no-op.
-            And ANSI C seems to specify that the type of the result
-            should be the const type.  */
-         /* A de-reference of a pointer to const is not a const.  It is valid
-            to change it via some other pointer.  */
-         TREE_READONLY (ref) = TYPE_READONLY (t);
-         TREE_SIDE_EFFECTS (ref)
-           = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer) || flag_volatile;
-         TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
-         return ref;
-       }
+           if (TREE_CODE (s1) == FIELD_DECL
+               && simple_cst_equal (DECL_FIELD_BIT_OFFSET (s1),
+                                    DECL_FIELD_BIT_OFFSET (s2)) != 1)
+             break;
+         }
+       if (s1 && s2)
+         tu->val = 0;
+       else
+         tu->val = needs_warning ? 2 : 1;
+       return tu->val;
+      }
+
+    default:
+      gcc_unreachable ();
     }
-  else if (TREE_CODE (pointer) != ERROR_MARK)
-    error ("invalid type argument of `%s'", errorstring);
-  return error_mark_node;
 }
 
-/* This handles expressions of the form "a[i]", which denotes
-   an array reference.
-
-   This is logically equivalent in C to *(a+i), but we may do it differently.
-   If A is a variable or a member, we generate a primitive ARRAY_REF.
-   This avoids forcing the array out of registers, and can work on
-   arrays that are not lvalues (for example, members of structures returned
-   by functions).  */
+/* Return 1 if two function types F1 and F2 are compatible.
+   If either type specifies no argument types,
+   the other must specify a fixed number of self-promoting arg types.
+   Otherwise, if one type specifies only the number of arguments,
+   the other must specify that number of self-promoting arg types.
+   Otherwise, the argument types must match.  */
 
-tree
-build_array_ref (array, index)
-     tree array, index;
+static int
+function_types_compatible_p (const_tree f1, const_tree f2)
 {
-  if (index == 0)
-    {
-      error ("subscript missing in array reference");
-      return error_mark_node;
-    }
+  tree args1, args2;
+  /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
+  int val = 1;
+  int val1;
+  tree ret1, ret2;
+
+  ret1 = TREE_TYPE (f1);
+  ret2 = TREE_TYPE (f2);
+
+  /* 'volatile' qualifiers on a function's return type used to mean
+     the function is noreturn.  */
+  if (TYPE_VOLATILE (ret1) != TYPE_VOLATILE (ret2))
+    pedwarn (input_location, 0, "function return types not compatible due to %<volatile%>");
+  if (TYPE_VOLATILE (ret1))
+    ret1 = build_qualified_type (TYPE_MAIN_VARIANT (ret1),
+                                TYPE_QUALS (ret1) & ~TYPE_QUAL_VOLATILE);
+  if (TYPE_VOLATILE (ret2))
+    ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2),
+                                TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE);
+  val = comptypes_internal (ret1, ret2);
+  if (val == 0)
+    return 0;
 
-  if (TREE_TYPE (array) == error_mark_node
-      || TREE_TYPE (index) == error_mark_node)
-    return error_mark_node;
+  args1 = TYPE_ARG_TYPES (f1);
+  args2 = TYPE_ARG_TYPES (f2);
+
+  /* An unspecified parmlist matches any specified parmlist
+     whose argument types don't need default promotions.  */
 
-  if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE
-      && TREE_CODE (array) != INDIRECT_REF)
+  if (args1 == 0)
     {
-      tree rval, type;
+      if (!self_promoting_args_p (args2))
+       return 0;
+      /* If one of these types comes from a non-prototype fn definition,
+        compare that with the other type's arglist.
+        If they don't match, ask for a warning (but no error).  */
+      if (TYPE_ACTUAL_ARG_TYPES (f1)
+         && 1 != type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1)))
+       val = 2;
+      return val;
+    }
+  if (args2 == 0)
+    {
+      if (!self_promoting_args_p (args1))
+       return 0;
+      if (TYPE_ACTUAL_ARG_TYPES (f2)
+         && 1 != type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2)))
+       val = 2;
+      return val;
+    }
 
-      /* Subscripting with type char is likely to lose
-        on a machine where chars are signed.
-        So warn on any machine, but optionally.
-        Don't warn for unsigned char since that type is safe.
-        Don't warn for signed char because anyone who uses that
-        must have done so deliberately.  */
-      if (warn_char_subscripts
-         && TYPE_MAIN_VARIANT (TREE_TYPE (index)) == char_type_node)
-       warning ("array subscript has type `char'");
+  /* Both types have argument lists: compare them and propagate results.  */
+  val1 = type_lists_compatible_p (args1, args2);
+  return val1 != 1 ? val1 : val;
+}
 
-      /* Apply default promotions *after* noticing character types.  */
-      index = default_conversion (index);
+/* Check two lists of types for compatibility,
+   returning 0 for incompatible, 1 for compatible,
+   or 2 for compatible with warning.  */
 
-      /* Require integer *after* promotion, for sake of enums.  */
-      if (TREE_CODE (TREE_TYPE (index)) != INTEGER_TYPE)
-       {
-         error ("array subscript is not an integer");
-         return error_mark_node;
-       }
+static int
+type_lists_compatible_p (const_tree args1, const_tree args2)
+{
+  /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
+  int val = 1;
+  int newval = 0;
 
-      /* An array that is indexed by a non-constant
-        cannot be stored in a register; we must be able to do
-        address arithmetic on its address.
-        Likewise an array of elements of variable size.  */
-      if (TREE_CODE (index) != INTEGER_CST
-         || (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array)))
-             && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
-       {
-         if (mark_addressable (array) == 0)
-           return error_mark_node;
-       }
-      /* An array that is indexed by a constant value which is not within
-        the array bounds cannot be stored in a register either; because we
-        would get a crash in store_bit_field/extract_bit_field when trying
-        to access a non-existent part of the register.  */
-      if (TREE_CODE (index) == INTEGER_CST
-         && TYPE_VALUES (TREE_TYPE (array))
-         && ! int_fits_type_p (index, TYPE_VALUES (TREE_TYPE (array))))
+  while (1)
+    {
+      tree a1, mv1, a2, mv2;
+      if (args1 == 0 && args2 == 0)
+       return val;
+      /* If one list is shorter than the other,
+        they fail to match.  */
+      if (args1 == 0 || args2 == 0)
+       return 0;
+      mv1 = a1 = TREE_VALUE (args1);
+      mv2 = a2 = TREE_VALUE (args2);
+      if (mv1 && mv1 != error_mark_node && TREE_CODE (mv1) != ARRAY_TYPE)
+       mv1 = TYPE_MAIN_VARIANT (mv1);
+      if (mv2 && mv2 != error_mark_node && TREE_CODE (mv2) != ARRAY_TYPE)
+       mv2 = TYPE_MAIN_VARIANT (mv2);
+      /* A null pointer instead of a type
+        means there is supposed to be an argument
+        but nothing is specified about what type it has.
+        So match anything that self-promotes.  */
+      if (a1 == 0)
        {
-         if (mark_addressable (array) == 0)
-           return error_mark_node;
+         if (c_type_promotes_to (a2) != a2)
+           return 0;
        }
-
-      if (pedantic)
+      else if (a2 == 0)
        {
-         tree foo = array;
-         while (TREE_CODE (foo) == COMPONENT_REF)
-           foo = TREE_OPERAND (foo, 0);
-         if (TREE_CODE (foo) == VAR_DECL && DECL_REGISTER (foo))
-           pedwarn ("ISO C forbids subscripting `register' array");
-         else if (! flag_isoc99 && ! lvalue_p (foo))
-           pedwarn ("ISO C89 forbids subscripting non-lvalue array");
+         if (c_type_promotes_to (a1) != a1)
+           return 0;
        }
-
-      type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (array)));
-      rval = build (ARRAY_REF, type, array, index);
-      /* Array ref is const/volatile if the array elements are
-         or if the array is.  */
-      TREE_READONLY (rval)
-       |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
-           | TREE_READONLY (array));
-      TREE_SIDE_EFFECTS (rval)
-       |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
-           | TREE_SIDE_EFFECTS (array));
-      TREE_THIS_VOLATILE (rval)
-       |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
-           /* This was added by rms on 16 Nov 91.
-              It fixes  vol struct foo *a;  a->elts[1] 
-              in an inline function.
-              Hope it doesn't break something else.  */
-           | TREE_THIS_VOLATILE (array));
-      return require_complete_type (fold (rval));
-    }
-
-  {
-    tree ar = default_conversion (array);
-    tree ind = default_conversion (index);
-
-    /* Do the same warning check as above, but only on the part that's
-       syntactically the index and only if it is also semantically
-       the index.  */
-    if (warn_char_subscripts
-       && TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE
-       && TYPE_MAIN_VARIANT (TREE_TYPE (index)) == char_type_node)
-      warning ("subscript has type `char'");
-
-    /* Put the integer in IND to simplify error checking.  */
-    if (TREE_CODE (TREE_TYPE (ar)) == INTEGER_TYPE)
-      {
-       tree temp = ar;
-       ar = ind;
-       ind = temp;
-      }
-
-    if (ar == error_mark_node)
-      return ar;
-
-    if (TREE_CODE (TREE_TYPE (ar)) != POINTER_TYPE
-       || TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) == FUNCTION_TYPE)
-      {
-       error ("subscripted value is neither array nor pointer");
-       return error_mark_node;
-      }
-    if (TREE_CODE (TREE_TYPE (ind)) != INTEGER_TYPE)
-      {
-       error ("array subscript is not an integer");
-       return error_mark_node;
-      }
-
-    return build_indirect_ref (build_binary_op (PLUS_EXPR, ar, ind, 0),
-                              "array indexing");
-  }
-}
-\f
-/* Build an external reference to identifier ID.  FUN indicates
-   whether this will be used for a function call.  */
-tree
-build_external_ref (id, fun)
-     tree id;
-     int fun;
-{
-  tree ref;
-  tree decl = lookup_name (id);
-  tree objc_ivar = lookup_objc_ivar (id);
-
-  if (decl && TREE_DEPRECATED (decl))
-    warn_deprecated_use (decl);
-
-  if (!decl || decl == error_mark_node || C_DECL_ANTICIPATED (decl))
-    {
-      if (objc_ivar)
-       ref = objc_ivar;
-      else if (fun)
+      /* If one of the lists has an error marker, ignore this arg.  */
+      else if (TREE_CODE (a1) == ERROR_MARK
+              || TREE_CODE (a2) == ERROR_MARK)
+       ;
+      else if (!(newval = comptypes_internal (mv1, mv2)))
        {
-         if (!decl || decl == error_mark_node)
-           /* Ordinary implicit function declaration.  */
-           ref = implicitly_declare (id);
-         else
+         /* Allow  wait (union {union wait *u; int *i} *)
+            and  wait (union wait *)  to be compatible.  */
+         if (TREE_CODE (a1) == UNION_TYPE
+             && (TYPE_NAME (a1) == 0
+                 || TYPE_TRANSPARENT_UNION (a1))
+             && TREE_CODE (TYPE_SIZE (a1)) == INTEGER_CST
+             && tree_int_cst_equal (TYPE_SIZE (a1),
+                                    TYPE_SIZE (a2)))
            {
-             /* Implicit declaration of built-in function.  Don't
-                change the built-in declaration, but don't let this
-                go by silently, either.  */
-             implicit_decl_warning (id);
-
-             /* only issue this warning once */
-             C_DECL_ANTICIPATED (decl) = 0;
-             ref = decl;
+             tree memb;
+             for (memb = TYPE_FIELDS (a1);
+                  memb; memb = TREE_CHAIN (memb))
+               {
+                 tree mv3 = TREE_TYPE (memb);
+                 if (mv3 && mv3 != error_mark_node
+                     && TREE_CODE (mv3) != ARRAY_TYPE)
+                   mv3 = TYPE_MAIN_VARIANT (mv3);
+                 if (comptypes_internal (mv3, mv2))
+                   break;
+               }
+             if (memb == 0)
+               return 0;
            }
-       }
-      else
-       {
-         /* Reference to undeclared variable, including reference to
-            builtin outside of function-call context.  */
-         if (current_function_decl == 0)
-           error ("`%s' undeclared here (not in a function)",
-                  IDENTIFIER_POINTER (id));
-         else
+         else if (TREE_CODE (a2) == UNION_TYPE
+                  && (TYPE_NAME (a2) == 0
+                      || TYPE_TRANSPARENT_UNION (a2))
+                  && TREE_CODE (TYPE_SIZE (a2)) == INTEGER_CST
+                  && tree_int_cst_equal (TYPE_SIZE (a2),
+                                         TYPE_SIZE (a1)))
            {
-             if (IDENTIFIER_GLOBAL_VALUE (id) != error_mark_node
-                 || IDENTIFIER_ERROR_LOCUS (id) != current_function_decl)
+             tree memb;
+             for (memb = TYPE_FIELDS (a2);
+                  memb; memb = TREE_CHAIN (memb))
                {
-                 error ("`%s' undeclared (first use in this function)",
-                        IDENTIFIER_POINTER (id));
-
-                 if (! undeclared_variable_notice)
-                   {
-                     error ("(Each undeclared identifier is reported only once");
-                     error ("for each function it appears in.)");
-                     undeclared_variable_notice = 1;
-                   }
+                 tree mv3 = TREE_TYPE (memb);
+                 if (mv3 && mv3 != error_mark_node
+                     && TREE_CODE (mv3) != ARRAY_TYPE)
+                   mv3 = TYPE_MAIN_VARIANT (mv3);
+                 if (comptypes_internal (mv3, mv1))
+                   break;
                }
-             IDENTIFIER_GLOBAL_VALUE (id) = error_mark_node;
-             IDENTIFIER_ERROR_LOCUS (id) = current_function_decl;
+             if (memb == 0)
+               return 0;
            }
-         return error_mark_node;
-       }
-    }
-  else
-    {
-      /* Properly declared variable or function reference.  */
-      if (!objc_ivar)
-       ref = decl;
-      else if (decl != objc_ivar && IDENTIFIER_LOCAL_VALUE (id))
-       {
-         warning ("local declaration of `%s' hides instance variable",
-                  IDENTIFIER_POINTER (id));
-         ref = decl;
+         else
+           return 0;
        }
-      else
-       ref = objc_ivar;
+
+      /* comptypes said ok, but record if it said to warn.  */
+      if (newval > val)
+       val = newval;
+
+      args1 = TREE_CHAIN (args1);
+      args2 = TREE_CHAIN (args2);
     }
+}
+\f
+/* Compute the size to increment a pointer by.  */
 
-  if (TREE_TYPE (ref) == error_mark_node)
-    return error_mark_node;
+static tree
+c_size_in_bytes (const_tree type)
+{
+  enum tree_code code = TREE_CODE (type);
 
-  if (!skip_evaluation)
-    assemble_external (ref);
-  TREE_USED (ref) = 1;
+  if (code == FUNCTION_TYPE || code == VOID_TYPE || code == ERROR_MARK)
+    return size_one_node;
 
-  if (TREE_CODE (ref) == CONST_DECL)
+  if (!COMPLETE_OR_VOID_TYPE_P (type))
     {
-      ref = DECL_INITIAL (ref);
-      TREE_CONSTANT (ref) = 1;
+      error ("arithmetic on pointer to an incomplete type");
+      return size_one_node;
     }
 
-  return ref;
+  /* Convert in case a char is more than one unit.  */
+  return size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
+                    size_int (TYPE_PRECISION (char_type_node)
+                              / BITS_PER_UNIT));
 }
-
-/* Build a function call to function FUNCTION with parameters PARAMS.
-   PARAMS is a list--a chain of TREE_LIST nodes--in which the
-   TREE_VALUE of each node is a parameter-expression.
-   FUNCTION's data type may be a function type or a pointer-to-function.  */
+\f
+/* Return either DECL or its known constant value (if it has one).  */
 
 tree
-build_function_call (function, params)
-     tree function, params;
+decl_constant_value (tree decl)
 {
-  tree fntype, fundecl = 0;
-  tree coerced_params;
-  tree name = NULL_TREE, assembler_name = NULL_TREE, result;
-
-  /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
-  STRIP_TYPE_NOPS (function);
-
-  /* Convert anything with function type to a pointer-to-function.  */
-  if (TREE_CODE (function) == FUNCTION_DECL)
-    {
-      name = DECL_NAME (function);
-      assembler_name = DECL_ASSEMBLER_NAME (function);
-
-      /* Differs from default_conversion by not setting TREE_ADDRESSABLE
-        (because calling an inline function does not mean the function
-        needs to be separately compiled).  */
-      fntype = build_type_variant (TREE_TYPE (function),
-                                  TREE_READONLY (function),
-                                  TREE_THIS_VOLATILE (function));
-      fundecl = function;
-      function = build1 (ADDR_EXPR, build_pointer_type (fntype), function);
-    }
-  else
-    function = default_conversion (function);
+  if (/* Don't change a variable array bound or initial value to a constant
+        in a place where a variable is invalid.  Note that DECL_INITIAL
+        isn't valid for a PARM_DECL.  */
+      current_function_decl != 0
+      && TREE_CODE (decl) != PARM_DECL
+      && !TREE_THIS_VOLATILE (decl)
+      && TREE_READONLY (decl)
+      && DECL_INITIAL (decl) != 0
+      && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
+      /* This is invalid if initial value is not constant.
+        If it has either a function call, a memory reference,
+        or a variable, then re-evaluating it could give different results.  */
+      && TREE_CONSTANT (DECL_INITIAL (decl))
+      /* Check for cases where this is sub-optimal, even though valid.  */
+      && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR)
+    return DECL_INITIAL (decl);
+  return decl;
+}
 
-  fntype = TREE_TYPE (function);
+/* Return either DECL or its known constant value (if it has one), but
+   return DECL if pedantic or DECL has mode BLKmode.  This is for
+   bug-compatibility with the old behavior of decl_constant_value
+   (before GCC 3.0); every use of this function is a bug and it should
+   be removed before GCC 3.1.  It is not appropriate to use pedantic
+   in a way that affects optimization, and BLKmode is probably not the
+   right test for avoiding misoptimizations either.  */
 
-  if (TREE_CODE (fntype) == ERROR_MARK)
-    return error_mark_node;
+static tree
+decl_constant_value_for_broken_optimization (tree decl)
+{
+  tree ret;
 
-  if (!(TREE_CODE (fntype) == POINTER_TYPE
-       && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
-    {
-      error ("called object is not a function");
-      return error_mark_node;
-    }
+  if (pedantic || DECL_MODE (decl) == BLKmode)
+    return decl;
 
-  if (fundecl && TREE_THIS_VOLATILE (fundecl))
-    current_function_returns_abnormally = 1;
+  ret = decl_constant_value (decl);
+  /* Avoid unwanted tree sharing between the initializer and current
+     function's body where the tree can be modified e.g. by the
+     gimplifier.  */
+  if (ret != decl && TREE_STATIC (decl))
+    ret = unshare_expr (ret);
+  return ret;
+}
 
-  /* fntype now gets the type of function pointed to.  */
-  fntype = TREE_TYPE (fntype);
+/* Convert the array expression EXP to a pointer.  */
+static tree
+array_to_pointer_conversion (tree exp)
+{
+  tree orig_exp = exp;
+  tree type = TREE_TYPE (exp);
+  tree adr;
+  tree restype = TREE_TYPE (type);
+  tree ptrtype;
 
-  /* Convert the parameters to the types declared in the
-     function prototype, or apply default promotions.  */
+  gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
 
-  coerced_params
-    = convert_arguments (TYPE_ARG_TYPES (fntype), params, name, fundecl);
+  STRIP_TYPE_NOPS (exp);
 
-  /* Check for errors in format strings.  */
+  if (TREE_NO_WARNING (orig_exp))
+    TREE_NO_WARNING (exp) = 1;
 
-  if (warn_format)
-    check_function_format (NULL, TYPE_ATTRIBUTES (fntype), coerced_params);
+  ptrtype = build_pointer_type (restype);
 
-  /* Recognize certain built-in functions so we can make tree-codes
-     other than CALL_EXPR.  We do this when it enables fold-const.c
-     to do something useful.  */
+  if (TREE_CODE (exp) == INDIRECT_REF)
+    return convert (ptrtype, TREE_OPERAND (exp, 0));
 
-  if (TREE_CODE (function) == ADDR_EXPR
-      && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL
-      && DECL_BUILT_IN (TREE_OPERAND (function, 0)))
+  if (TREE_CODE (exp) == VAR_DECL)
     {
-      result = expand_tree_builtin (TREE_OPERAND (function, 0),
-                                   params, coerced_params);
-      if (result)
-       return result;
+      /* We are making an ADDR_EXPR of ptrtype.  This is a valid
+        ADDR_EXPR because it's the best way of representing what
+        happens in C when we take the address of an array and place
+        it in a pointer to the element type.  */
+      adr = build1 (ADDR_EXPR, ptrtype, exp);
+      if (!c_mark_addressable (exp))
+       return error_mark_node;
+      TREE_SIDE_EFFECTS (adr) = 0;   /* Default would be, same as EXP.  */
+      return adr;
     }
 
-  result = build (CALL_EXPR, TREE_TYPE (fntype),
-                 function, coerced_params, NULL_TREE);
-  TREE_SIDE_EFFECTS (result) = 1;
-  result = fold (result);
-
-  if (VOID_TYPE_P (TREE_TYPE (result)))
-    return result;
-  return require_complete_type (result);
+  /* This way is better for a COMPONENT_REF since it can
+     simplify the offset for a component.  */
+  adr = build_unary_op (EXPR_LOCATION (exp), ADDR_EXPR, exp, 1);
+  return convert (ptrtype, adr);
 }
-\f
-/* Convert the argument expressions in the list VALUES
-   to the types in the list TYPELIST.  The result is a list of converted
-   argument expressions.
 
-   If TYPELIST is exhausted, or when an element has NULL as its type,
-   perform the default conversions.
+/* Convert the function expression EXP to a pointer.  */
+static tree
+function_to_pointer_conversion (tree exp)
+{
+  tree orig_exp = exp;
 
-   PARMLIST is the chain of parm decls for the function being called.
-   It may be 0, if that info is not available.
-   It is used only for generating error messages.
+  gcc_assert (TREE_CODE (TREE_TYPE (exp)) == FUNCTION_TYPE);
 
-   NAME is an IDENTIFIER_NODE or 0.  It is used only for error messages.
+  STRIP_TYPE_NOPS (exp);
 
-   This is also where warnings about wrong number of args are generated.
+  if (TREE_NO_WARNING (orig_exp))
+    TREE_NO_WARNING (exp) = 1;
 
-   Both VALUES and the returned value are chains of TREE_LIST nodes
-   with the elements of the list in the TREE_VALUE slots of those nodes.  */
+  return build_unary_op (EXPR_LOCATION (exp), ADDR_EXPR, exp, 0);
+}
 
-static tree
-convert_arguments (typelist, values, name, fundecl)
-     tree typelist, values, name, fundecl;
-{
-  tree typetail, valtail;
-  tree result = NULL;
-  int parmnum;
+/* Perform the default conversion of arrays and functions to pointers.
+   Return the result of converting EXP.  For any other expression, just
+   return EXP after removing NOPs.  */
 
-  /* Scan the given expressions and types, producing individual
-     converted arguments and pushing them on RESULT in reverse order.  */
+struct c_expr
+default_function_array_conversion (struct c_expr exp)
+{
+  tree orig_exp = exp.value;
+  tree type = TREE_TYPE (exp.value);
+  enum tree_code code = TREE_CODE (type);
 
-  for (valtail = values, typetail = typelist, parmnum = 0;
-       valtail;
-       valtail = TREE_CHAIN (valtail), parmnum++)
+  switch (code)
     {
-      tree type = typetail ? TREE_VALUE (typetail) : 0;
-      tree val = TREE_VALUE (valtail);
+    case ARRAY_TYPE:
+      {
+       bool not_lvalue = false;
+       bool lvalue_array_p;
 
-      if (type == void_type_node)
-       {
-         if (name)
-           error ("too many arguments to function `%s'",
-                  IDENTIFIER_POINTER (name));
-         else
-           error ("too many arguments to function");
-         break;
-       }
+       while ((TREE_CODE (exp.value) == NON_LVALUE_EXPR
+               || CONVERT_EXPR_P (exp.value))
+              && TREE_TYPE (TREE_OPERAND (exp.value, 0)) == type)
+         {
+           if (TREE_CODE (exp.value) == NON_LVALUE_EXPR)
+             not_lvalue = true;
+           exp.value = TREE_OPERAND (exp.value, 0);
+         }
 
-      /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
-      /* Do not use STRIP_NOPS here!  We do not want an enumerator with value 0
-        to convert automatically to a pointer.  */
-      if (TREE_CODE (val) == NON_LVALUE_EXPR)
-       val = TREE_OPERAND (val, 0);
+       if (TREE_NO_WARNING (orig_exp))
+         TREE_NO_WARNING (exp.value) = 1;
 
-      val = default_function_array_conversion (val);
+       lvalue_array_p = !not_lvalue && lvalue_p (exp.value);
+       if (!flag_isoc99 && !lvalue_array_p)
+         {
+           /* Before C99, non-lvalue arrays do not decay to pointers.
+              Normally, using such an array would be invalid; but it can
+              be used correctly inside sizeof or as a statement expression.
+              Thus, do not give an error here; an error will result later.  */
+           return exp;
+         }
 
-      val = require_complete_type (val);
+       exp.value = array_to_pointer_conversion (exp.value);
+      }
+      break;
+    case FUNCTION_TYPE:
+      exp.value = function_to_pointer_conversion (exp.value);
+      break;
+    default:
+      STRIP_TYPE_NOPS (exp.value);
+      if (TREE_NO_WARNING (orig_exp))
+       TREE_NO_WARNING (exp.value) = 1;
+      break;
+    }
 
-      if (type != 0)
-       {
-         /* Formal parm type is specified by a function prototype.  */
-         tree parmval;
+  return exp;
+}
 
-         if (!COMPLETE_TYPE_P (type))
-           {
-             error ("type of formal parameter %d is incomplete", parmnum + 1);
-             parmval = val;
-           }
-         else
-           {
-             /* Optionally warn about conversions that
-                differ from the default conversions.  */
-             if (warn_conversion || warn_traditional)
-               {
-                 int formal_prec = TYPE_PRECISION (type);
 
-                 if (INTEGRAL_TYPE_P (type)
-                     && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
-                   warn_for_assignment ("%s as integer rather than floating due to prototype", (char *) 0, name, parmnum + 1);
-                 if (INTEGRAL_TYPE_P (type)
-                     && TREE_CODE (TREE_TYPE (val)) == COMPLEX_TYPE)
-                   warn_for_assignment ("%s as integer rather than complex due to prototype", (char *) 0, name, parmnum + 1);
-                 else if (TREE_CODE (type) == COMPLEX_TYPE
-                          && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
-                   warn_for_assignment ("%s as complex rather than floating due to prototype", (char *) 0, name, parmnum + 1);
-                 else if (TREE_CODE (type) == REAL_TYPE
-                          && INTEGRAL_TYPE_P (TREE_TYPE (val)))
-                   warn_for_assignment ("%s as floating rather than integer due to prototype", (char *) 0, name, parmnum + 1);
-                 else if (TREE_CODE (type) == COMPLEX_TYPE
-                          && INTEGRAL_TYPE_P (TREE_TYPE (val)))
-                   warn_for_assignment ("%s as complex rather than integer due to prototype", (char *) 0, name, parmnum + 1);
-                 else if (TREE_CODE (type) == REAL_TYPE
-                          && TREE_CODE (TREE_TYPE (val)) == COMPLEX_TYPE)
-                   warn_for_assignment ("%s as floating rather than complex due to prototype", (char *) 0, name, parmnum + 1);
-                 /* ??? At some point, messages should be written about
-                    conversions between complex types, but that's too messy
-                    to do now.  */
-                 else if (TREE_CODE (type) == REAL_TYPE
-                          && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
-                   {
-                     /* Warn if any argument is passed as `float',
-                        since without a prototype it would be `double'.  */
-                     if (formal_prec == TYPE_PRECISION (float_type_node))
-                       warn_for_assignment ("%s as `float' rather than `double' due to prototype", (char *) 0, name, parmnum + 1);
-                   }
-                 /* Detect integer changing in width or signedness.
-                    These warnings are only activated with
-                    -Wconversion, not with -Wtraditional.  */
-                 else if (warn_conversion && INTEGRAL_TYPE_P (type)
-                          && INTEGRAL_TYPE_P (TREE_TYPE (val)))
-                   {
-                     tree would_have_been = default_conversion (val);
-                     tree type1 = TREE_TYPE (would_have_been);
+/* EXP is an expression of integer type.  Apply the integer promotions
+   to it and return the promoted value.  */
 
-                     if (TREE_CODE (type) == ENUMERAL_TYPE
-                         && (TYPE_MAIN_VARIANT (type)
-                             == TYPE_MAIN_VARIANT (TREE_TYPE (val))))
-                       /* No warning if function asks for enum
-                          and the actual arg is that enum type.  */
-                       ;
-                     else if (formal_prec != TYPE_PRECISION (type1))
-                       warn_for_assignment ("%s with different width due to prototype", (char *) 0, name, parmnum + 1);
-                     else if (TREE_UNSIGNED (type) == TREE_UNSIGNED (type1))
-                       ;
-                     /* Don't complain if the formal parameter type
-                        is an enum, because we can't tell now whether
-                        the value was an enum--even the same enum.  */
-                     else if (TREE_CODE (type) == ENUMERAL_TYPE)
-                       ;
-                     else if (TREE_CODE (val) == INTEGER_CST
-                              && int_fits_type_p (val, type))
-                       /* Change in signedness doesn't matter
-                          if a constant value is unaffected.  */
-                       ;
-                     /* Likewise for a constant in a NOP_EXPR.  */
-                     else if (TREE_CODE (val) == NOP_EXPR
-                              && TREE_CODE (TREE_OPERAND (val, 0)) == INTEGER_CST
-                              && int_fits_type_p (TREE_OPERAND (val, 0), type))
-                       ;
-#if 0 /* We never get such tree structure here.  */
-                     else if (TREE_CODE (TREE_TYPE (val)) == ENUMERAL_TYPE
-                              && int_fits_type_p (TYPE_MIN_VALUE (TREE_TYPE (val)), type)
-                              && int_fits_type_p (TYPE_MAX_VALUE (TREE_TYPE (val)), type))
-                       /* Change in signedness doesn't matter
-                          if an enum value is unaffected.  */
-                       ;
-#endif
-                     /* If the value is extended from a narrower
-                        unsigned type, it doesn't matter whether we
-                        pass it as signed or unsigned; the value
-                        certainly is the same either way.  */
-                     else if (TYPE_PRECISION (TREE_TYPE (val)) < TYPE_PRECISION (type)
-                              && TREE_UNSIGNED (TREE_TYPE (val)))
-                       ;
-                     else if (TREE_UNSIGNED (type))
-                       warn_for_assignment ("%s as unsigned due to prototype", (char *) 0, name, parmnum + 1);
-                     else
-                       warn_for_assignment ("%s as signed due to prototype", (char *) 0, name, parmnum + 1);
-                   }
-               }
+tree
+perform_integral_promotions (tree exp)
+{
+  tree type = TREE_TYPE (exp);
+  enum tree_code code = TREE_CODE (type);
 
-             parmval = convert_for_assignment (type, val, 
-                                               (char *) 0, /* arg passing  */
-                                               fundecl, name, parmnum + 1);
-             
-             if (PROMOTE_PROTOTYPES
-                 && INTEGRAL_TYPE_P (type)
-                 && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
-               parmval = default_conversion (parmval);
-           }
-         result = tree_cons (NULL_TREE, parmval, result);
-       }
-      else if (TREE_CODE (TREE_TYPE (val)) == REAL_TYPE
-               && (TYPE_PRECISION (TREE_TYPE (val))
-                  < TYPE_PRECISION (double_type_node)))
-       /* Convert `float' to `double'.  */
-       result = tree_cons (NULL_TREE, convert (double_type_node, val), result);
-      else
-       /* Convert `short' and `char' to full-size `int'.  */
-       result = tree_cons (NULL_TREE, default_conversion (val), result);
+  gcc_assert (INTEGRAL_TYPE_P (type));
 
-      if (typetail)
-       typetail = TREE_CHAIN (typetail);
+  /* Normally convert enums to int,
+     but convert wide enums to something wider.  */
+  if (code == ENUMERAL_TYPE)
+    {
+      type = c_common_type_for_size (MAX (TYPE_PRECISION (type),
+                                         TYPE_PRECISION (integer_type_node)),
+                                    ((TYPE_PRECISION (type)
+                                      >= TYPE_PRECISION (integer_type_node))
+                                     && TYPE_UNSIGNED (type)));
+
+      return convert (type, exp);
     }
 
-  if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
+  /* ??? This should no longer be needed now bit-fields have their
+     proper types.  */
+  if (TREE_CODE (exp) == COMPONENT_REF
+      && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1))
+      /* If it's thinner than an int, promote it like a
+        c_promoting_integer_type_p, otherwise leave it alone.  */
+      && 0 > compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)),
+                              TYPE_PRECISION (integer_type_node)))
+    return convert (integer_type_node, exp);
+
+  if (c_promoting_integer_type_p (type))
     {
-      if (name)
-       error ("too few arguments to function `%s'",
-              IDENTIFIER_POINTER (name));
-      else
-       error ("too few arguments to function");
+      /* Preserve unsignedness if not really getting any wider.  */
+      if (TYPE_UNSIGNED (type)
+         && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
+       return convert (unsigned_type_node, exp);
+
+      return convert (integer_type_node, exp);
     }
 
-  return nreverse (result);
+  return exp;
 }
-\f
-/* This is the entry point used by the parser
-   for binary operators in the input.
-   In addition to constructing the expression,
-   we check for operands that were written with other binary operators
-   in a way that is likely to confuse the user.  */
+
+
+/* Perform default promotions for C data used in expressions.
+   Enumeral types or short or char are converted to int.
+   In addition, manifest constants symbols are replaced by their values.  */
 
 tree
-parser_build_binary_op (code, arg1, arg2)
-     enum tree_code code;
-     tree arg1, arg2;
+default_conversion (tree exp)
 {
-  tree result = build_binary_op (code, arg1, arg2, 1);
-
-  char class;
-  char class1 = TREE_CODE_CLASS (TREE_CODE (arg1));
-  char class2 = TREE_CODE_CLASS (TREE_CODE (arg2));
-  enum tree_code code1 = ERROR_MARK;
-  enum tree_code code2 = ERROR_MARK;
+  tree orig_exp;
+  tree type = TREE_TYPE (exp);
+  enum tree_code code = TREE_CODE (type);
 
-  if (TREE_CODE (result) == ERROR_MARK)
-    return error_mark_node;
+  /* Functions and arrays have been converted during parsing.  */
+  gcc_assert (code != FUNCTION_TYPE);
+  if (code == ARRAY_TYPE)
+    return exp;
 
-  if (IS_EXPR_CODE_CLASS (class1))
-    code1 = C_EXP_ORIGINAL_CODE (arg1);
-  if (IS_EXPR_CODE_CLASS (class2))
-    code2 = C_EXP_ORIGINAL_CODE (arg2);
+  /* Constants can be used directly unless they're not loadable.  */
+  if (TREE_CODE (exp) == CONST_DECL)
+    exp = DECL_INITIAL (exp);
 
-  /* Check for cases such as x+y<<z which users are likely
-     to misinterpret.  If parens are used, C_EXP_ORIGINAL_CODE
-     is cleared to prevent these warnings.  */
-  if (warn_parentheses)
+  /* Replace a nonvolatile const static variable with its value unless
+     it is an array, in which case we must be sure that taking the
+     address of the array produces consistent results.  */
+  else if (optimize && TREE_CODE (exp) == VAR_DECL && code != ARRAY_TYPE)
     {
-      if (code == LSHIFT_EXPR || code == RSHIFT_EXPR)
-       {
-         if (code1 == PLUS_EXPR || code1 == MINUS_EXPR
-             || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
-           warning ("suggest parentheses around + or - inside shift");
-       }
-
-      if (code == TRUTH_ORIF_EXPR)
-       {
-         if (code1 == TRUTH_ANDIF_EXPR
-             || code2 == TRUTH_ANDIF_EXPR)
-           warning ("suggest parentheses around && within ||");
-       }
-
-      if (code == BIT_IOR_EXPR)
-       {
-         if (code1 == BIT_AND_EXPR || code1 == BIT_XOR_EXPR
-             || code1 == PLUS_EXPR || code1 == MINUS_EXPR
-             || code2 == BIT_AND_EXPR || code2 == BIT_XOR_EXPR
-             || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
-           warning ("suggest parentheses around arithmetic in operand of |");
-         /* Check cases like x|y==z */
-         if (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<')
-           warning ("suggest parentheses around comparison in operand of |");
-       }
-
-      if (code == BIT_XOR_EXPR)
-       {
-         if (code1 == BIT_AND_EXPR
-             || code1 == PLUS_EXPR || code1 == MINUS_EXPR
-             || code2 == BIT_AND_EXPR
-             || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
-           warning ("suggest parentheses around arithmetic in operand of ^");
-         /* Check cases like x^y==z */
-         if (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<')
-           warning ("suggest parentheses around comparison in operand of ^");
-       }
-
-      if (code == BIT_AND_EXPR)
-       {
-         if (code1 == PLUS_EXPR || code1 == MINUS_EXPR
-             || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
-           warning ("suggest parentheses around + or - in operand of &");
-         /* Check cases like x&y==z */
-         if (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<')
-           warning ("suggest parentheses around comparison in operand of &");
-       }
+      exp = decl_constant_value_for_broken_optimization (exp);
+      type = TREE_TYPE (exp);
     }
 
-  /* Similarly, check for cases like 1<=i<=10 that are probably errors.  */
-  if (TREE_CODE_CLASS (code) == '<' && extra_warnings
-      && (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<'))
-    warning ("comparisons like X<=Y<=Z do not have their mathematical meaning");
-
-  unsigned_conversion_warning (result, arg1);
-  unsigned_conversion_warning (result, arg2);
-  overflow_warning (result);
+  /* Strip no-op conversions.  */
+  orig_exp = exp;
+  STRIP_TYPE_NOPS (exp);
 
-  class = TREE_CODE_CLASS (TREE_CODE (result));
+  if (TREE_NO_WARNING (orig_exp))
+    TREE_NO_WARNING (exp) = 1;
 
-  /* Record the code that was specified in the source,
-     for the sake of warnings about confusing nesting.  */
-  if (IS_EXPR_CODE_CLASS (class))
-    C_SET_EXP_ORIGINAL_CODE (result, code);
-  else
+  if (code == VOID_TYPE)
     {
-      int flag = TREE_CONSTANT (result);
-      /* We used to use NOP_EXPR rather than NON_LVALUE_EXPR
-        so that convert_for_assignment wouldn't strip it.
-        That way, we got warnings for things like p = (1 - 1).
-        But it turns out we should not get those warnings.  */
-      result = build1 (NON_LVALUE_EXPR, TREE_TYPE (result), result);
-      C_SET_EXP_ORIGINAL_CODE (result, code);
-      TREE_CONSTANT (result) = flag;
+      error ("void value not ignored as it ought to be");
+      return error_mark_node;
     }
 
-  return result;
-}
+  exp = require_complete_type (exp);
+  if (exp == error_mark_node)
+    return error_mark_node;
 
-/* Build a binary-operation expression without default conversions.
-   CODE is the kind of expression to build.
-   This function differs from `build' in several ways:
-   the data type of the result is computed and recorded in it,
-   warnings are generated if arg data types are invalid,
-   special handling for addition and subtraction of pointers is known,
-   and some optimization is done (operations on narrow ints
-   are done in the narrower type when that gives the same result).
-   Constant folding is also done before the result is returned.
+  if (INTEGRAL_TYPE_P (type))
+    return perform_integral_promotions (exp);
 
-   Note that the operands will never have enumeral types, or function
-   or array types, because either they will have the default conversions
-   performed or they have both just been converted to some other type in which
-   the arithmetic is to be done.  */
+  return exp;
+}
+\f
+/* Look up COMPONENT in a structure or union DECL.
 
-tree
-build_binary_op (code, orig_op0, orig_op1, convert_p)
-     enum tree_code code;
-     tree orig_op0, orig_op1;
-     int convert_p;
-{
-  tree type0, type1;
-  enum tree_code code0, code1;
-  tree op0, op1;
+   If the component name is not found, returns NULL_TREE.  Otherwise,
+   the return value is a TREE_LIST, with each TREE_VALUE a FIELD_DECL
+   stepping down the chain to the component, which is in the last
+   TREE_VALUE of the list.  Normally the list is of length one, but if
+   the component is embedded within (nested) anonymous structures or
+   unions, the list steps down the chain to the component.  */
 
-  /* Expression code to give to the expression when it is built.
-     Normally this is CODE, which is what the caller asked for,
-     but in some special cases we change it.  */
-  enum tree_code resultcode = code;
+static tree
+lookup_field (tree decl, tree component)
+{
+  tree type = TREE_TYPE (decl);
+  tree field;
 
-  /* Data type in which the computation is to be performed.
-     In the simplest cases this is the common type of the arguments.  */
-  tree result_type = NULL;
+  /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
+     to the field elements.  Use a binary search on this array to quickly
+     find the element.  Otherwise, do a linear search.  TYPE_LANG_SPECIFIC
+     will always be set for structures which have many elements.  */
 
-  /* Nonzero means operands have already been type-converted
-     in whatever way is necessary.
-     Zero means they need to be converted to RESULT_TYPE.  */
-  int converted = 0;
+  if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s)
+    {
+      int bot, top, half;
+      tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0];
 
-  /* Nonzero means create the expression with this type, rather than
-     RESULT_TYPE.  */
-  tree build_type = 0;
+      field = TYPE_FIELDS (type);
+      bot = 0;
+      top = TYPE_LANG_SPECIFIC (type)->s->len;
+      while (top - bot > 1)
+       {
+         half = (top - bot + 1) >> 1;
+         field = field_array[bot+half];
 
-  /* Nonzero means after finally constructing the expression
-     convert it to this type.  */
-  tree final_type = 0;
+         if (DECL_NAME (field) == NULL_TREE)
+           {
+             /* Step through all anon unions in linear fashion.  */
+             while (DECL_NAME (field_array[bot]) == NULL_TREE)
+               {
+                 field = field_array[bot++];
+                 if (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
+                     || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
+                   {
+                     tree anon = lookup_field (field, component);
 
-  /* Nonzero if this is an operation like MIN or MAX which can
-     safely be computed in short if both args are promoted shorts.
-     Also implies COMMON.
-     -1 indicates a bitwise operation; this makes a difference
-     in the exact conditions for when it is safe to do the operation
-     in a narrower mode.  */
-  int shorten = 0;
+                     if (anon)
+                       return tree_cons (NULL_TREE, field, anon);
+                   }
+               }
 
-  /* Nonzero if this is a comparison operation;
-     if both args are promoted shorts, compare the original shorts.
-     Also implies COMMON.  */
-  int short_compare = 0;
+             /* Entire record is only anon unions.  */
+             if (bot > top)
+               return NULL_TREE;
 
-  /* Nonzero if this is a right-shift operation, which can be computed on the
-     original short and then promoted if the operand is a promoted short.  */
-  int short_shift = 0;
+             /* Restart the binary search, with new lower bound.  */
+             continue;
+           }
 
-  /* Nonzero means set RESULT_TYPE to the common type of the args.  */
-  int common = 0;
+         if (DECL_NAME (field) == component)
+           break;
+         if (DECL_NAME (field) < component)
+           bot += half;
+         else
+           top = bot + half;
+       }
 
-  if (convert_p)
-    {
-      op0 = default_conversion (orig_op0);
-      op1 = default_conversion (orig_op1);
+      if (DECL_NAME (field_array[bot]) == component)
+       field = field_array[bot];
+      else if (DECL_NAME (field) != component)
+       return NULL_TREE;
     }
   else
     {
-      op0 = orig_op0;
-      op1 = orig_op1;
-    }
-
-  type0 = TREE_TYPE (op0);
-  type1 = TREE_TYPE (op1);
+      for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+       {
+         if (DECL_NAME (field) == NULL_TREE
+             && (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
+                 || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE))
+           {
+             tree anon = lookup_field (field, component);
 
-  /* The expression codes of the data types of the arguments tell us
-     whether the arguments are integers, floating, pointers, etc.  */
-  code0 = TREE_CODE (type0);
-  code1 = TREE_CODE (type1);
+             if (anon)
+               return tree_cons (NULL_TREE, field, anon);
+           }
 
-  /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
-  STRIP_TYPE_NOPS (op0);
-  STRIP_TYPE_NOPS (op1);
+         if (DECL_NAME (field) == component)
+           break;
+       }
 
-  /* If an error was already reported for one of the arguments,
-     avoid reporting another error.  */
+      if (field == NULL_TREE)
+       return NULL_TREE;
+    }
 
-  if (code0 == ERROR_MARK || code1 == ERROR_MARK)
-    return error_mark_node;
+  return tree_cons (NULL_TREE, field, NULL_TREE);
+}
 
-  switch (code)
-    {
-    case PLUS_EXPR:
-      /* Handle the pointer + int case.  */
-      if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
-       return pointer_int_sum (PLUS_EXPR, op0, op1);
-      else if (code1 == POINTER_TYPE && code0 == INTEGER_TYPE)
-       return pointer_int_sum (PLUS_EXPR, op1, op0);
-      else
-       common = 1;
-      break;
+/* Make an expression to refer to the COMPONENT field of
+   structure or union value DATUM.  COMPONENT is an IDENTIFIER_NODE.  */
 
-    case MINUS_EXPR:
-      /* Subtraction of two similar pointers.
-        We must subtract them as integers, then divide by object size.  */
-      if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
-         && comp_target_types (type0, type1))
-       return pointer_diff (op0, op1);
-      /* Handle pointer minus int.  Just like pointer plus int.  */
-      else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
-       return pointer_int_sum (MINUS_EXPR, op0, op1);
-      else
-       common = 1;
-      break;
+tree
+build_component_ref (tree datum, tree component)
+{
+  tree type = TREE_TYPE (datum);
+  enum tree_code code = TREE_CODE (type);
+  tree field = NULL;
+  tree ref;
 
-    case MULT_EXPR:
-      common = 1;
-      break;
+  if (!objc_is_public (datum, component))
+    return error_mark_node;
 
-    case TRUNC_DIV_EXPR:
-    case CEIL_DIV_EXPR:
-    case FLOOR_DIV_EXPR:
-    case ROUND_DIV_EXPR:
-    case EXACT_DIV_EXPR:
-      /* Floating point division by zero is a legitimate way to obtain
-        infinities and NaNs.  */
-      if (warn_div_by_zero && skip_evaluation == 0 && integer_zerop (op1))
-       warning ("division by zero");
+  /* See if there is a field or component with name COMPONENT.  */
 
-      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
-          || code0 == COMPLEX_TYPE)
-         && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
-             || code1 == COMPLEX_TYPE))
+  if (code == RECORD_TYPE || code == UNION_TYPE)
+    {
+      if (!COMPLETE_TYPE_P (type))
        {
-         if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE))
-           resultcode = RDIV_EXPR;
-         else
-           /* Although it would be tempting to shorten always here, that
-              loses on some targets, since the modulo instruction is
-              undefined if the quotient can't be represented in the
-              computation mode.  We shorten only if unsigned or if
-              dividing by something we know != -1.  */
-           shorten = (TREE_UNSIGNED (TREE_TYPE (orig_op0))
-                      || (TREE_CODE (op1) == INTEGER_CST
-                          && ! integer_all_onesp (op1)));
-         common = 1;
+         c_incomplete_type_error (NULL_TREE, type);
+         return error_mark_node;
        }
-      break;
-
-    case BIT_AND_EXPR:
-    case BIT_ANDTC_EXPR:
-    case BIT_IOR_EXPR:
-    case BIT_XOR_EXPR:
-      if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
-       shorten = -1;
-      break;
 
-    case TRUNC_MOD_EXPR:
-    case FLOOR_MOD_EXPR:
-      if (warn_div_by_zero && skip_evaluation == 0 && integer_zerop (op1))
-       warning ("division by zero");
+      field = lookup_field (datum, component);
 
-      if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
+      if (!field)
        {
-         /* Although it would be tempting to shorten always here, that loses
-            on some targets, since the modulo instruction is undefined if the
-            quotient can't be represented in the computation mode.  We shorten
-            only if unsigned or if dividing by something we know != -1.  */
-         shorten = (TREE_UNSIGNED (TREE_TYPE (orig_op0))
-                    || (TREE_CODE (op1) == INTEGER_CST
-                        && ! integer_all_onesp (op1)));
-         common = 1;
+         error ("%qT has no member named %qE", type, component);
+         return error_mark_node;
        }
-      break;
 
-    case TRUTH_ANDIF_EXPR:
-    case TRUTH_ORIF_EXPR:
-    case TRUTH_AND_EXPR:
-    case TRUTH_OR_EXPR:
-    case TRUTH_XOR_EXPR:
-      if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
-          || code0 == REAL_TYPE || code0 == COMPLEX_TYPE)
-         && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
-             || code1 == REAL_TYPE || code1 == COMPLEX_TYPE))
+      /* Chain the COMPONENT_REFs if necessary down to the FIELD.
+        This might be better solved in future the way the C++ front
+        end does it - by giving the anonymous entities each a
+        separate name and type, and then have build_component_ref
+        recursively call itself.  We can't do that here.  */
+      do
        {
-         /* Result of these operations is always an int,
-            but that does not mean the operands should be
-            converted to ints!  */
-         result_type = integer_type_node;
-         op0 = truthvalue_conversion (op0);
-         op1 = truthvalue_conversion (op1);
-         converted = 1;
-       }
-      break;
+         tree subdatum = TREE_VALUE (field);
+         int quals;
+         tree subtype;
 
-      /* Shift operations: result has same type as first operand;
-        always convert second operand to int.
-        Also set SHORT_SHIFT if shifting rightward.  */
+         if (TREE_TYPE (subdatum) == error_mark_node)
+           return error_mark_node;
 
-    case RSHIFT_EXPR:
-      if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
-       {
-         if (TREE_CODE (op1) == INTEGER_CST && skip_evaluation == 0)
-           {
-             if (tree_int_cst_sgn (op1) < 0)
-               warning ("right shift count is negative");
-             else
-               {
-                 if (! integer_zerop (op1))
-                   short_shift = 1;
+         quals = TYPE_QUALS (strip_array_types (TREE_TYPE (subdatum)));
+         quals |= TYPE_QUALS (TREE_TYPE (datum));
+         subtype = c_build_qualified_type (TREE_TYPE (subdatum), quals);
 
-                 if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
-                   warning ("right shift count >= width of type");
-               }
-           }
-
-         /* Use the type of the value to be shifted.
-            This is what most traditional C compilers do.  */
-         result_type = type0;
-         /* Unless traditional, convert the shift-count to an integer,
-            regardless of size of value being shifted.  */
-         if (! flag_traditional)
-           {
-             if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
-               op1 = convert (integer_type_node, op1);
-             /* Avoid converting op1 to result_type later.  */
-             converted = 1;
-           }
-       }
-      break;
+         ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
+                       NULL_TREE);
+         if (TREE_READONLY (datum) || TREE_READONLY (subdatum))
+           TREE_READONLY (ref) = 1;
+         if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (subdatum))
+           TREE_THIS_VOLATILE (ref) = 1;
 
-    case LSHIFT_EXPR:
-      if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
-       {
-         if (TREE_CODE (op1) == INTEGER_CST && skip_evaluation == 0)
-           {
-             if (tree_int_cst_sgn (op1) < 0)
-               warning ("left shift count is negative");
+         if (TREE_DEPRECATED (subdatum))
+           warn_deprecated_use (subdatum);
 
-             else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
-               warning ("left shift count >= width of type");
-           }
+         datum = ref;
 
-         /* Use the type of the value to be shifted.
-            This is what most traditional C compilers do.  */
-         result_type = type0;
-         /* Unless traditional, convert the shift-count to an integer,
-            regardless of size of value being shifted.  */
-         if (! flag_traditional)
-           {
-             if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
-               op1 = convert (integer_type_node, op1);
-             /* Avoid converting op1 to result_type later.  */
-             converted = 1;
-           }
+         field = TREE_CHAIN (field);
        }
-      break;
+      while (field);
 
-    case RROTATE_EXPR:
-    case LROTATE_EXPR:
-      if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
-       {
-         if (TREE_CODE (op1) == INTEGER_CST && skip_evaluation == 0)
-           {
-             if (tree_int_cst_sgn (op1) < 0)
-               warning ("shift count is negative");
-             else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
-               warning ("shift count >= width of type");
-           }
+      return ref;
+    }
+  else if (code != ERROR_MARK)
+    error ("request for member %qE in something not a structure or union",
+          component);
 
-         /* Use the type of the value to be shifted.
-            This is what most traditional C compilers do.  */
-         result_type = type0;
-         /* Unless traditional, convert the shift-count to an integer,
-            regardless of size of value being shifted.  */
-         if (! flag_traditional)
-           {
-             if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
-               op1 = convert (integer_type_node, op1);
-             /* Avoid converting op1 to result_type later.  */
-             converted = 1;
-           }
-       }
-      break;
+  return error_mark_node;
+}
+\f
+/* Given an expression PTR for a pointer, return an expression
+   for the value pointed to.
+   ERRORSTRING is the name of the operator to appear in error messages.
 
-    case EQ_EXPR:
-    case NE_EXPR:
-      if (warn_float_equal && (code0 == REAL_TYPE || code1 == REAL_TYPE))
-       warning ("comparing floating point with == or != is unsafe");
-      /* Result of comparison is always int,
-        but don't convert the args to int!  */
-      build_type = integer_type_node;
-      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
-          || code0 == COMPLEX_TYPE)
-         && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
-             || code1 == COMPLEX_TYPE))
-       short_compare = 1;
-      else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
-       {
-         tree tt0 = TREE_TYPE (type0);
-         tree tt1 = TREE_TYPE (type1);
-         /* Anything compares with void *.  void * compares with anything.
-            Otherwise, the targets must be compatible
-            and both must be object or both incomplete.  */
-         if (comp_target_types (type0, type1))
-           result_type = common_type (type0, type1);
-         else if (VOID_TYPE_P (tt0))
-           {
-             /* op0 != orig_op0 detects the case of something
-                whose value is 0 but which isn't a valid null ptr const.  */
-             if (pedantic && (!integer_zerop (op0) || op0 != orig_op0)
-                 && TREE_CODE (tt1) == FUNCTION_TYPE)
-               pedwarn ("ISO C forbids comparison of `void *' with function pointer");
-           }
-         else if (VOID_TYPE_P (tt1))
-           {
-             if (pedantic && (!integer_zerop (op1) || op1 != orig_op1)
-                 && TREE_CODE (tt0) == FUNCTION_TYPE)
-               pedwarn ("ISO C forbids comparison of `void *' with function pointer");
-           }
-         else
-           pedwarn ("comparison of distinct pointer types lacks a cast");
+   LOC is the location to use for the generated tree.  */
 
-         if (result_type == NULL_TREE)
-           result_type = ptr_type_node;
-       }
-      else if (code0 == POINTER_TYPE && TREE_CODE (op1) == INTEGER_CST
-              && integer_zerop (op1))
-       result_type = type0;
-      else if (code1 == POINTER_TYPE && TREE_CODE (op0) == INTEGER_CST
-              && integer_zerop (op0))
-       result_type = type1;
-      else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
-       {
-         result_type = type0;
-         if (! flag_traditional)
-           pedwarn ("comparison between pointer and integer");
-       }
-      else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
+tree
+build_indirect_ref (location_t loc, tree ptr, const char *errorstring)
+{
+  tree pointer = default_conversion (ptr);
+  tree type = TREE_TYPE (pointer);
+  tree ref;
+
+  if (TREE_CODE (type) == POINTER_TYPE)
+    {
+      if (CONVERT_EXPR_P (pointer)
+          || TREE_CODE (pointer) == VIEW_CONVERT_EXPR)
        {
-         result_type = type1;
-         if (! flag_traditional)
-           pedwarn ("comparison between pointer and integer");
+         /* If a warning is issued, mark it to avoid duplicates from
+            the backend.  This only needs to be done at
+            warn_strict_aliasing > 2.  */
+         if (warn_strict_aliasing > 2)
+           if (strict_aliasing_warning (TREE_TYPE (TREE_OPERAND (pointer, 0)),
+                                        type, TREE_OPERAND (pointer, 0)))
+             TREE_NO_WARNING (pointer) = 1;
        }
-      break;
 
-    case MAX_EXPR:
-    case MIN_EXPR:
-      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
-         && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
-       shorten = 1;
-      else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+      if (TREE_CODE (pointer) == ADDR_EXPR
+         && (TREE_TYPE (TREE_OPERAND (pointer, 0))
+             == TREE_TYPE (type)))
        {
-         if (comp_target_types (type0, type1))
-           {
-             result_type = common_type (type0, type1);
-             if (pedantic 
-                 && TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
-               pedwarn ("ISO C forbids ordered comparisons of pointers to functions");
-           }
-         else
-           {
-             result_type = ptr_type_node;
-             pedwarn ("comparison of distinct pointer types lacks a cast");
-           }
+         ref = TREE_OPERAND (pointer, 0);
+         protected_set_expr_location (ref, loc);
+         return ref;
        }
-      break;
-
-    case LE_EXPR:
-    case GE_EXPR:
-    case LT_EXPR:
-    case GT_EXPR:
-      build_type = integer_type_node;
-      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
-         && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
-       short_compare = 1;
-      else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+      else
        {
-         if (comp_target_types (type0, type1))
-           {
-             result_type = common_type (type0, type1);
-             if (!COMPLETE_TYPE_P (TREE_TYPE (type0))
-                 != !COMPLETE_TYPE_P (TREE_TYPE (type1)))
-               pedwarn ("comparison of complete and incomplete pointers");
-             else if (pedantic 
-                      && TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
-               pedwarn ("ISO C forbids ordered comparisons of pointers to functions");
-           }
-         else
+         tree t = TREE_TYPE (type);
+
+         ref = build1 (INDIRECT_REF, t, pointer);
+
+         if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE)
            {
-             result_type = ptr_type_node;
-             pedwarn ("comparison of distinct pointer types lacks a cast");
+             error_at (loc, "dereferencing pointer to incomplete type");
+             return error_mark_node;
            }
+         if (VOID_TYPE_P (t) && skip_evaluation == 0)
+           warning_at (loc, 0, "dereferencing %<void *%> pointer");
+
+         /* We *must* set TREE_READONLY when dereferencing a pointer to const,
+            so that we get the proper error message if the result is used
+            to assign to.  Also, &* is supposed to be a no-op.
+            And ANSI C seems to specify that the type of the result
+            should be the const type.  */
+         /* A de-reference of a pointer to const is not a const.  It is valid
+            to change it via some other pointer.  */
+         TREE_READONLY (ref) = TYPE_READONLY (t);
+         TREE_SIDE_EFFECTS (ref)
+           = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer);
+         TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
+         protected_set_expr_location (ref, loc);
+         return ref;
        }
-      else if (code0 == POINTER_TYPE && TREE_CODE (op1) == INTEGER_CST
-              && integer_zerop (op1))
-       {
-         result_type = type0;
-         if (pedantic || extra_warnings)
-           pedwarn ("ordered comparison of pointer with integer zero");
-       }
-      else if (code1 == POINTER_TYPE && TREE_CODE (op0) == INTEGER_CST
-              && integer_zerop (op0))
-       {
-         result_type = type1;
-         if (pedantic)
-           pedwarn ("ordered comparison of pointer with integer zero");
-       }
-      else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
-       {
-         result_type = type0;
-         if (! flag_traditional)
-           pedwarn ("comparison between pointer and integer");
-       }
-      else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
-       {
-         result_type = type1;
-         if (! flag_traditional)
-           pedwarn ("comparison between pointer and integer");
-       }
-      break;
+    }
+  else if (TREE_CODE (pointer) != ERROR_MARK)
+    error_at (loc,
+             "invalid type argument of %qs (have %qT)", errorstring, type);
+  return error_mark_node;
+}
 
-    case UNORDERED_EXPR:
-    case ORDERED_EXPR:
-    case UNLT_EXPR:
-    case UNLE_EXPR:
-    case UNGT_EXPR:
-    case UNGE_EXPR:
-    case UNEQ_EXPR:
-      build_type = integer_type_node;
-      if (code0 != REAL_TYPE || code1 != REAL_TYPE)
+/* This handles expressions of the form "a[i]", which denotes
+   an array reference.
+
+   This is logically equivalent in C to *(a+i), but we may do it differently.
+   If A is a variable or a member, we generate a primitive ARRAY_REF.
+   This avoids forcing the array out of registers, and can work on
+   arrays that are not lvalues (for example, members of structures returned
+   by functions).
+
+   LOC is the location to use for the returned expression.  */
+
+tree
+build_array_ref (tree array, tree index, location_t loc)
+{
+  tree ret;
+  bool swapped = false;
+  if (TREE_TYPE (array) == error_mark_node
+      || TREE_TYPE (index) == error_mark_node)
+    return error_mark_node;
+
+  if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
+      && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE)
+    {
+      tree temp;
+      if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE
+         && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE)
        {
-         error ("unordered comparison on non-floating point argument");
+         error_at (loc, "subscripted value is neither array nor pointer");
          return error_mark_node;
        }
-      common = 1;
-      break;
-
-    default:
-      break;
+      temp = array;
+      array = index;
+      index = temp;
+      swapped = true;
     }
 
-  if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE)
-      &&
-      (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE))
+  if (!INTEGRAL_TYPE_P (TREE_TYPE (index)))
     {
-      int none_complex = (code0 != COMPLEX_TYPE && code1 != COMPLEX_TYPE);
+      error_at (loc, "array subscript is not an integer");
+      return error_mark_node;
+    }
 
-      if (shorten || common || short_compare)
-       result_type = common_type (type0, type1);
+  if (TREE_CODE (TREE_TYPE (TREE_TYPE (array))) == FUNCTION_TYPE)
+    {
+      error_at (loc, "subscripted value is pointer to function");
+      return error_mark_node;
+    }
 
-      /* For certain operations (which identify themselves by shorten != 0)
-        if both args were extended from the same smaller type,
-        do the arithmetic in that type and then extend.
+  /* ??? Existing practice has been to warn only when the char
+     index is syntactically the index, not for char[array].  */
+  if (!swapped)
+     warn_array_subscript_with_type_char (index);
 
-        shorten !=0 and !=1 indicates a bitwise operation.
-        For them, this optimization is safe only if
-        both args are zero-extended or both are sign-extended.
-        Otherwise, we might change the result.
-        Eg, (short)-1 | (unsigned short)-1 is (int)-1
-        but calculated in (unsigned short) it would be (unsigned short)-1.  */
+  /* Apply default promotions *after* noticing character types.  */
+  index = default_conversion (index);
 
-      if (shorten && none_complex)
-       {
-         int unsigned0, unsigned1;
-         tree arg0 = get_narrower (op0, &unsigned0);
-         tree arg1 = get_narrower (op1, &unsigned1);
-         /* UNS is 1 if the operation to be done is an unsigned one.  */
-         int uns = TREE_UNSIGNED (result_type);
-         tree type;
+  gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE);
 
-         final_type = result_type;
+  if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
+    {
+      tree rval, type;
 
-         /* Handle the case that OP0 (or OP1) does not *contain* a conversion
-            but it *requires* conversion to FINAL_TYPE.  */
-
-         if ((TYPE_PRECISION (TREE_TYPE (op0))
-              == TYPE_PRECISION (TREE_TYPE (arg0)))
-             && TREE_TYPE (op0) != final_type)
-           unsigned0 = TREE_UNSIGNED (TREE_TYPE (op0));
-         if ((TYPE_PRECISION (TREE_TYPE (op1))
-              == TYPE_PRECISION (TREE_TYPE (arg1)))
-             && TREE_TYPE (op1) != final_type)
-           unsigned1 = TREE_UNSIGNED (TREE_TYPE (op1));
-
-         /* Now UNSIGNED0 is 1 if ARG0 zero-extends to FINAL_TYPE.  */
-
-         /* For bitwise operations, signedness of nominal type
-            does not matter.  Consider only how operands were extended.  */
-         if (shorten == -1)
-           uns = unsigned0;
-
-         /* Note that in all three cases below we refrain from optimizing
-            an unsigned operation on sign-extended args.
-            That would not be valid.  */
-
-         /* Both args variable: if both extended in same way
-            from same width, do it in that width.
-            Do it unsigned if args were zero-extended.  */
-         if ((TYPE_PRECISION (TREE_TYPE (arg0))
-              < TYPE_PRECISION (result_type))
-             && (TYPE_PRECISION (TREE_TYPE (arg1))
-                 == TYPE_PRECISION (TREE_TYPE (arg0)))
-             && unsigned0 == unsigned1
-             && (unsigned0 || !uns))
-           result_type
-             = signed_or_unsigned_type (unsigned0,
-                                        common_type (TREE_TYPE (arg0), TREE_TYPE (arg1)));
-         else if (TREE_CODE (arg0) == INTEGER_CST
-                  && (unsigned1 || !uns)
-                  && (TYPE_PRECISION (TREE_TYPE (arg1))
-                      < TYPE_PRECISION (result_type))
-                  && (type = signed_or_unsigned_type (unsigned1,
-                                                      TREE_TYPE (arg1)),
-                      int_fits_type_p (arg0, type)))
-           result_type = type;
-         else if (TREE_CODE (arg1) == INTEGER_CST
-                  && (unsigned0 || !uns)
-                  && (TYPE_PRECISION (TREE_TYPE (arg0))
-                      < TYPE_PRECISION (result_type))
-                  && (type = signed_or_unsigned_type (unsigned0,
-                                                      TREE_TYPE (arg0)),
-                      int_fits_type_p (arg1, type)))
-           result_type = type;
+      /* An array that is indexed by a non-constant
+        cannot be stored in a register; we must be able to do
+        address arithmetic on its address.
+        Likewise an array of elements of variable size.  */
+      if (TREE_CODE (index) != INTEGER_CST
+         || (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array)))
+             && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
+       {
+         if (!c_mark_addressable (array))
+           return error_mark_node;
+       }
+      /* An array that is indexed by a constant value which is not within
+        the array bounds cannot be stored in a register either; because we
+        would get a crash in store_bit_field/extract_bit_field when trying
+        to access a non-existent part of the register.  */
+      if (TREE_CODE (index) == INTEGER_CST
+         && TYPE_DOMAIN (TREE_TYPE (array))
+         && !int_fits_type_p (index, TYPE_DOMAIN (TREE_TYPE (array))))
+       {
+         if (!c_mark_addressable (array))
+           return error_mark_node;
        }
 
-      /* Shifts can be shortened if shifting right.  */
-
-      if (short_shift)
+      if (pedantic)
        {
-         int unsigned_arg;
-         tree arg0 = get_narrower (op0, &unsigned_arg);
+         tree foo = array;
+         while (TREE_CODE (foo) == COMPONENT_REF)
+           foo = TREE_OPERAND (foo, 0);
+         if (TREE_CODE (foo) == VAR_DECL && C_DECL_REGISTER (foo))
+           pedwarn (loc, OPT_pedantic, 
+                    "ISO C forbids subscripting %<register%> array");
+         else if (!flag_isoc99 && !lvalue_p (foo))
+           pedwarn (loc, OPT_pedantic, 
+                    "ISO C90 forbids subscripting non-lvalue array");
+       }
 
-         final_type = result_type;
+      type = TREE_TYPE (TREE_TYPE (array));
+      rval = build4 (ARRAY_REF, type, array, index, NULL_TREE, NULL_TREE);
+      /* Array ref is const/volatile if the array elements are
+        or if the array is.  */
+      TREE_READONLY (rval)
+       |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
+           | TREE_READONLY (array));
+      TREE_SIDE_EFFECTS (rval)
+       |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
+           | TREE_SIDE_EFFECTS (array));
+      TREE_THIS_VOLATILE (rval)
+       |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
+           /* This was added by rms on 16 Nov 91.
+              It fixes  vol struct foo *a;  a->elts[1]
+              in an inline function.
+              Hope it doesn't break something else.  */
+           | TREE_THIS_VOLATILE (array));
+      ret = require_complete_type (fold (rval));
+      protected_set_expr_location (ret, loc);
+      return ret;
+    }
+  else
+    {
+      tree ar = default_conversion (array);
 
-         if (arg0 == op0 && final_type == TREE_TYPE (op0))
-           unsigned_arg = TREE_UNSIGNED (TREE_TYPE (op0));
+      if (ar == error_mark_node)
+       return ar;
 
-         if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
-             /* We can shorten only if the shift count is less than the
-                number of bits in the smaller type size.  */
-             && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
-             /* We cannot drop an unsigned shift after sign-extension.  */
-             && (!TREE_UNSIGNED (final_type) || unsigned_arg))
-           {
-             /* Do an unsigned shift if the operand was zero-extended.  */
-             result_type
-               = signed_or_unsigned_type (unsigned_arg, TREE_TYPE (arg0));
-             /* Convert value-to-be-shifted to that type.  */
-             if (TREE_TYPE (op0) != result_type)
-               op0 = convert (result_type, op0);
-             converted = 1;
-           }
-       }
+      gcc_assert (TREE_CODE (TREE_TYPE (ar)) == POINTER_TYPE);
+      gcc_assert (TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) != FUNCTION_TYPE);
 
-      /* Comparison operations are shortened too but differently.
-        They identify themselves by setting short_compare = 1.  */
+      return build_indirect_ref
+       (loc, build_binary_op (loc, PLUS_EXPR, ar, index, 0),
+        "array indexing");
+    }
+}
+\f
+/* Build an external reference to identifier ID.  FUN indicates
+   whether this will be used for a function call.  LOC is the source
+   location of the identifier.  */
+tree
+build_external_ref (tree id, int fun, location_t loc)
+{
+  tree ref;
+  tree decl = lookup_name (id);
 
-      if (short_compare)
-       {
-         /* Don't write &op0, etc., because that would prevent op0
-            from being kept in a register.
-            Instead, make copies of the our local variables and
-            pass the copies by reference, then copy them back afterward.  */
-         tree xop0 = op0, xop1 = op1, xresult_type = result_type;
-         enum tree_code xresultcode = resultcode;
-         tree val 
-           = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode);
+  /* In Objective-C, an instance variable (ivar) may be preferred to
+     whatever lookup_name() found.  */
+  decl = objc_lookup_ivar (decl, id);
+
+  if (decl && decl != error_mark_node)
+    ref = decl;
+  else if (fun)
+    /* Implicit function declaration.  */
+    ref = implicitly_declare (id);
+  else if (decl == error_mark_node)
+    /* Don't complain about something that's already been
+       complained about.  */
+    return error_mark_node;
+  else
+    {
+      undeclared_variable (id, loc);
+      return error_mark_node;
+    }
 
-         if (val != 0)
-           return val;
+  if (TREE_TYPE (ref) == error_mark_node)
+    return error_mark_node;
 
-         op0 = xop0, op1 = xop1;
-         converted = 1;
-         resultcode = xresultcode;
+  if (TREE_DEPRECATED (ref))
+    warn_deprecated_use (ref);
 
-         if ((warn_sign_compare < 0 ? extra_warnings : warn_sign_compare != 0)
-             && skip_evaluation == 0)
-           {
-             int op0_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op0));
-             int op1_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op1));
-             int unsignedp0, unsignedp1;
-             tree primop0 = get_narrower (op0, &unsignedp0);
-             tree primop1 = get_narrower (op1, &unsignedp1);
+  /* Recursive call does not count as usage.  */
+  if (ref != current_function_decl) 
+    {
+      TREE_USED (ref) = 1;
+    }
 
-             xop0 = orig_op0;
-             xop1 = orig_op1;
-             STRIP_TYPE_NOPS (xop0);
-             STRIP_TYPE_NOPS (xop1);
+  if (TREE_CODE (ref) == FUNCTION_DECL && !in_alignof)
+    {
+      if (!in_sizeof && !in_typeof)
+       C_DECL_USED (ref) = 1;
+      else if (DECL_INITIAL (ref) == 0
+              && DECL_EXTERNAL (ref)
+              && !TREE_PUBLIC (ref))
+       record_maybe_used_decl (ref);
+    }
+
+  if (TREE_CODE (ref) == CONST_DECL)
+    {
+      used_types_insert (TREE_TYPE (ref));
+      ref = DECL_INITIAL (ref);
+      TREE_CONSTANT (ref) = 1;
+    }
+  else if (current_function_decl != 0
+          && !DECL_FILE_SCOPE_P (current_function_decl)
+          && (TREE_CODE (ref) == VAR_DECL
+              || TREE_CODE (ref) == PARM_DECL
+              || TREE_CODE (ref) == FUNCTION_DECL))
+    {
+      tree context = decl_function_context (ref);
+
+      if (context != 0 && context != current_function_decl)
+       DECL_NONLOCAL (ref) = 1;
+    }
+  /* C99 6.7.4p3: An inline definition of a function with external
+     linkage ... shall not contain a reference to an identifier with
+     internal linkage.  */
+  else if (current_function_decl != 0
+          && DECL_DECLARED_INLINE_P (current_function_decl)
+          && DECL_EXTERNAL (current_function_decl)
+          && VAR_OR_FUNCTION_DECL_P (ref)
+          && (TREE_CODE (ref) != VAR_DECL || TREE_STATIC (ref))
+          && ! TREE_PUBLIC (ref)
+          && DECL_CONTEXT (ref) != current_function_decl)
+    pedwarn (loc, 0, "%qD is static but used in inline function %qD "
+            "which is not static", ref, current_function_decl);
 
-             /* Give warnings for comparisons between signed and unsigned
-                quantities that may fail. 
+  return ref;
+}
 
-                Do the checking based on the original operand trees, so that
-                casts will be considered, but default promotions won't be.
+/* Record details of decls possibly used inside sizeof or typeof.  */
+struct maybe_used_decl
+{
+  /* The decl.  */
+  tree decl;
+  /* The level seen at (in_sizeof + in_typeof).  */
+  int level;
+  /* The next one at this level or above, or NULL.  */
+  struct maybe_used_decl *next;
+};
 
-                Do not warn if the comparison is being done in a signed type,
-                since the signed type will only be chosen if it can represent
-                all the values of the unsigned type.  */
-             if (! TREE_UNSIGNED (result_type))
-               /* OK */;
-              /* Do not warn if both operands are the same signedness.  */
-              else if (op0_signed == op1_signed)
-                /* OK */;
-             else
-               {
-                 tree sop, uop;
+static struct maybe_used_decl *maybe_used_decls;
 
-                 if (op0_signed)
-                   sop = xop0, uop = xop1;
-                 else
-                   sop = xop1, uop = xop0;
-
-                 /* Do not warn if the signed quantity is an
-                    unsuffixed integer literal (or some static
-                    constant expression involving such literals or a
-                    conditional expression involving such literals)
-                    and it is non-negative.  */
-                 if (tree_expr_nonnegative_p (sop))
-                   /* OK */;
-                 /* Do not warn if the comparison is an equality operation,
-                    the unsigned quantity is an integral constant, and it
-                    would fit in the result if the result were signed.  */
-                 else if (TREE_CODE (uop) == INTEGER_CST
-                          && (resultcode == EQ_EXPR || resultcode == NE_EXPR)
-                          && int_fits_type_p (uop, signed_type (result_type)))
-                   /* OK */;
-                 /* Do not warn if the unsigned quantity is an enumeration
-                    constant and its maximum value would fit in the result
-                    if the result were signed.  */
-                 else if (TREE_CODE (uop) == INTEGER_CST
-                          && TREE_CODE (TREE_TYPE (uop)) == ENUMERAL_TYPE
-                          && int_fits_type_p (TYPE_MAX_VALUE (TREE_TYPE(uop)),
-                                              signed_type (result_type)))
-                   /* OK */;
-                 else
-                   warning ("comparison between signed and unsigned");
-               }
+/* Record that DECL, an undefined static function reference seen
+   inside sizeof or typeof, might be used if the operand of sizeof is
+   a VLA type or the operand of typeof is a variably modified
+   type.  */
 
-             /* Warn if two unsigned values are being compared in a size
-                larger than their original size, and one (and only one) is the
-                result of a `~' operator.  This comparison will always fail.
+static void
+record_maybe_used_decl (tree decl)
+{
+  struct maybe_used_decl *t = XOBNEW (&parser_obstack, struct maybe_used_decl);
+  t->decl = decl;
+  t->level = in_sizeof + in_typeof;
+  t->next = maybe_used_decls;
+  maybe_used_decls = t;
+}
 
-                Also warn if one operand is a constant, and the constant
-                does not have all bits set that are set in the ~ operand
-                when it is extended.  */
+/* Pop the stack of decls possibly used inside sizeof or typeof.  If
+   USED is false, just discard them.  If it is true, mark them used
+   (if no longer inside sizeof or typeof) or move them to the next
+   level up (if still inside sizeof or typeof).  */
 
-             if ((TREE_CODE (primop0) == BIT_NOT_EXPR)
-                 != (TREE_CODE (primop1) == BIT_NOT_EXPR))
-               {
-                 if (TREE_CODE (primop0) == BIT_NOT_EXPR)
-                   primop0 = get_narrower (TREE_OPERAND (primop0, 0),
-                                           &unsignedp0);
-                 else
-                   primop1 = get_narrower (TREE_OPERAND (primop1, 0),
-                                           &unsignedp1);
-             
-                 if (host_integerp (primop0, 0) || host_integerp (primop1, 0))
-                   {
-                     tree primop;
-                     HOST_WIDE_INT constant, mask;
-                     int unsignedp, bits;
-
-                     if (host_integerp (primop0, 0))
-                       {
-                         primop = primop1;
-                         unsignedp = unsignedp1;
-                         constant = tree_low_cst (primop0, 0);
-                       }
-                     else
-                       {
-                         primop = primop0;
-                         unsignedp = unsignedp0;
-                         constant = tree_low_cst (primop1, 0);
-                       }
-
-                     bits = TYPE_PRECISION (TREE_TYPE (primop));
-                     if (bits < TYPE_PRECISION (result_type)
-                         && bits < HOST_BITS_PER_WIDE_INT && unsignedp)
-                       {
-                         mask = (~ (HOST_WIDE_INT) 0) << bits;
-                         if ((mask & constant) != mask)
-                           warning ("comparison of promoted ~unsigned with constant");
-                       }
-                   }
-                 else if (unsignedp0 && unsignedp1
-                          && (TYPE_PRECISION (TREE_TYPE (primop0))
-                              < TYPE_PRECISION (result_type))
-                          && (TYPE_PRECISION (TREE_TYPE (primop1))
-                              < TYPE_PRECISION (result_type)))
-                   warning ("comparison of promoted ~unsigned with unsigned");
-               }
-           }
+void
+pop_maybe_used (bool used)
+{
+  struct maybe_used_decl *p = maybe_used_decls;
+  int cur_level = in_sizeof + in_typeof;
+  while (p && p->level > cur_level)
+    {
+      if (used)
+       {
+         if (cur_level == 0)
+           C_DECL_USED (p->decl) = 1;
+         else
+           p->level = cur_level;
        }
+      p = p->next;
     }
+  if (!used || cur_level == 0)
+    maybe_used_decls = p;
+}
 
-  /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
-     If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
-     Then the expression will be built.
-     It will be given type FINAL_TYPE if that is nonzero;
-     otherwise, it will be given type RESULT_TYPE.  */
+/* Return the result of sizeof applied to EXPR.  */
 
-  if (!result_type)
+struct c_expr
+c_expr_sizeof_expr (struct c_expr expr)
+{
+  struct c_expr ret;
+  if (expr.value == error_mark_node)
     {
-      binary_op_error (code);
-      return error_mark_node;
+      ret.value = error_mark_node;
+      ret.original_code = ERROR_MARK;
+      pop_maybe_used (false);
     }
-
-  if (! converted)
+  else
     {
-      if (TREE_TYPE (op0) != result_type)
-       op0 = convert (result_type, op0); 
-      if (TREE_TYPE (op1) != result_type)
-       op1 = convert (result_type, op1); 
+      ret.value = c_sizeof (TREE_TYPE (expr.value));
+      ret.original_code = ERROR_MARK;
+      if (c_vla_type_p (TREE_TYPE (expr.value)))
+       {
+         /* sizeof is evaluated when given a vla (C99 6.5.3.4p2).  */
+         ret.value = build2 (COMPOUND_EXPR, TREE_TYPE (ret.value), expr.value, ret.value);
+       }
+      pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (expr.value)));
     }
+  return ret;
+}
 
-  if (build_type == NULL_TREE)
-    build_type = result_type;
+/* Return the result of sizeof applied to T, a structure for the type
+   name passed to sizeof (rather than the type itself).  */
 
-  {
-    tree result = build (resultcode, build_type, op0, op1);
-    tree folded;
-
-    folded = fold (result);
-    if (folded == result)
-      TREE_CONSTANT (folded) = TREE_CONSTANT (op0) & TREE_CONSTANT (op1);
-    if (final_type != 0)
-      return convert (final_type, folded);
-    return folded;
-  }
+struct c_expr
+c_expr_sizeof_type (struct c_type_name *t)
+{
+  tree type;
+  struct c_expr ret;
+  type = groktypename (t);
+  ret.value = c_sizeof (type);
+  ret.original_code = ERROR_MARK;
+  pop_maybe_used (type != error_mark_node
+                 ? C_TYPE_VARIABLE_SIZE (type) : false);
+  return ret;
 }
-\f
-/* Return a tree for the difference of pointers OP0 and OP1.
-   The resulting tree has type int.  */
 
-static tree
-pointer_diff (op0, op1)
-     tree op0, op1;
+/* Build a function call to function FUNCTION with parameters PARAMS.
+   PARAMS is a list--a chain of TREE_LIST nodes--in which the
+   TREE_VALUE of each node is a parameter-expression.
+   FUNCTION's data type may be a function type or a pointer-to-function.  */
+
+tree
+build_function_call (tree function, tree params)
 {
-  tree result, folded;
-  tree restype = ptrdiff_type_node;
+  tree fntype, fundecl = 0;
+  tree name = NULL_TREE, result;
+  tree tem;
+  int nargs;
+  tree *argarray;
+  
 
-  tree target_type = TREE_TYPE (TREE_TYPE (op0));
-  tree con0, con1, lit0, lit1;
-  tree orig_op1 = op1;
+  /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
+  STRIP_TYPE_NOPS (function);
 
-  if (pedantic || warn_pointer_arith)
+  /* Convert anything with function type to a pointer-to-function.  */
+  if (TREE_CODE (function) == FUNCTION_DECL)
     {
-      if (TREE_CODE (target_type) == VOID_TYPE)
-       pedwarn ("pointer of type `void *' used in subtraction");
-      if (TREE_CODE (target_type) == FUNCTION_TYPE)
-       pedwarn ("pointer to a function used in subtraction");
+      /* Implement type-directed function overloading for builtins.
+        resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
+        handle all the type checking.  The result is a complete expression
+        that implements this function call.  */
+      tem = resolve_overloaded_builtin (function, params);
+      if (tem)
+       return tem;
+
+      name = DECL_NAME (function);
+      fundecl = function;
     }
+  if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
+    function = function_to_pointer_conversion (function);
 
-  /* If the conversion to ptrdiff_type does anything like widening or
-     converting a partial to an integral mode, we get a convert_expression
-     that is in the way to do any simplifications.
-     (fold-const.c doesn't know that the extra bits won't be needed.
-     split_tree uses STRIP_SIGN_NOPS, which leaves conversions to a
-     different mode in place.)
-     So first try to find a common term here 'by hand'; we want to cover
-     at least the cases that occur in legal static initializers.  */
-  con0 = TREE_CODE (op0) == NOP_EXPR ? TREE_OPERAND (op0, 0) : op0;
-  con1 = TREE_CODE (op1) == NOP_EXPR ? TREE_OPERAND (op1, 0) : op1;
+  /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
+     expressions, like those used for ObjC messenger dispatches.  */
+  function = objc_rewrite_function_call (function, params);
 
-  if (TREE_CODE (con0) == PLUS_EXPR)
+  fntype = TREE_TYPE (function);
+
+  if (TREE_CODE (fntype) == ERROR_MARK)
+    return error_mark_node;
+
+  if (!(TREE_CODE (fntype) == POINTER_TYPE
+       && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
     {
-      lit0 = TREE_OPERAND (con0, 1);
-      con0 = TREE_OPERAND (con0, 0);
+      error ("called object %qE is not a function", function);
+      return error_mark_node;
     }
-  else
-    lit0 = integer_zero_node;
 
-  if (TREE_CODE (con1) == PLUS_EXPR)
-    {
-      lit1 = TREE_OPERAND (con1, 1);
-      con1 = TREE_OPERAND (con1, 0);
+  if (fundecl && TREE_THIS_VOLATILE (fundecl))
+    current_function_returns_abnormally = 1;
+
+  /* fntype now gets the type of function pointed to.  */
+  fntype = TREE_TYPE (fntype);
+
+  /* Convert the parameters to the types declared in the
+     function prototype, or apply default promotions.  */
+
+  nargs = list_length (params);
+  argarray = (tree *) alloca (nargs * sizeof (tree));
+  nargs = convert_arguments (nargs, argarray, TYPE_ARG_TYPES (fntype), 
+                            params, function, fundecl);
+  if (nargs < 0)
+    return error_mark_node;
+
+  /* Check that the function is called through a compatible prototype.
+     If it is not, replace the call by a trap, wrapped up in a compound
+     expression if necessary.  This has the nice side-effect to prevent
+     the tree-inliner from generating invalid assignment trees which may
+     blow up in the RTL expander later.  */
+  if (CONVERT_EXPR_P (function)
+      && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
+      && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
+      && !comptypes (fntype, TREE_TYPE (tem)))
+    {
+      tree return_type = TREE_TYPE (fntype);
+      tree trap = build_function_call (built_in_decls[BUILT_IN_TRAP],
+                                      NULL_TREE);
+      int i;
+
+      /* This situation leads to run-time undefined behavior.  We can't,
+        therefore, simply error unless we can prove that all possible
+        executions of the program must execute the code.  */
+      if (warning (0, "function called through a non-compatible type"))
+       /* We can, however, treat "undefined" any way we please.
+          Call abort to encourage the user to fix the program.  */
+       inform (input_location, "if this code is reached, the program will abort");
+      /* Before the abort, allow the function arguments to exit or
+        call longjmp.  */
+      for (i = 0; i < nargs; i++)
+       trap = build2 (COMPOUND_EXPR, void_type_node, argarray[i], trap);
+
+      if (VOID_TYPE_P (return_type))
+       return trap;
+      else
+       {
+         tree rhs;
+
+         if (AGGREGATE_TYPE_P (return_type))
+           rhs = build_compound_literal (return_type,
+                                         build_constructor (return_type, 0));
+         else
+           rhs = fold_convert (return_type, integer_zero_node);
+
+         return build2 (COMPOUND_EXPR, return_type, trap, rhs);
+       }
     }
-  else
-    lit1 = integer_zero_node;
 
-  if (operand_equal_p (con0, con1, 0))
+  /* Check that arguments to builtin functions match the expectations.  */
+  if (fundecl
+      && DECL_BUILT_IN (fundecl)
+      && DECL_BUILT_IN_CLASS (fundecl) == BUILT_IN_NORMAL
+      && !check_builtin_function_arguments (fundecl, nargs, argarray))
+    return error_mark_node;
+
+  /* Check that the arguments to the function are valid.  */
+  check_function_arguments (TYPE_ATTRIBUTES (fntype), nargs, argarray,
+                           TYPE_ARG_TYPES (fntype));
+
+  if (require_constant_value)
     {
-      op0 = lit0;
-      op1 = lit1;
+      result = fold_build_call_array_initializer (TREE_TYPE (fntype),
+                                                 function, nargs, argarray);
+      if (TREE_CONSTANT (result)
+         && (name == NULL_TREE
+             || strncmp (IDENTIFIER_POINTER (name), "__builtin_", 10) != 0))
+       pedwarn_init (input_location, 0, "initializer element is not constant");
     }
+  else
+    result = fold_build_call_array (TREE_TYPE (fntype),
+                                   function, nargs, argarray);
 
+  if (VOID_TYPE_P (TREE_TYPE (result)))
+    return result;
+  return require_complete_type (result);
+}
+\f
+/* Convert the argument expressions in the list VALUES
+   to the types in the list TYPELIST.  The resulting arguments are
+   stored in the array ARGARRAY which has size NARGS.
 
-  /* First do the subtraction as integers;
-     then drop through to build the divide operator.
-     Do not do default conversions on the minus operator
-     in case restype is a short type.  */
+   If TYPELIST is exhausted, or when an element has NULL as its type,
+   perform the default conversions.
 
-  op0 = build_binary_op (MINUS_EXPR, convert (restype, op0),
-                        convert (restype, op1), 0);
-  /* This generates an error if op1 is pointer to incomplete type.  */
-  if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1))))
-    error ("arithmetic on pointer to an incomplete type");
+   PARMLIST is the chain of parm decls for the function being called.
+   It may be 0, if that info is not available.
+   It is used only for generating error messages.
 
-  /* This generates an error if op0 is pointer to incomplete type.  */
-  op1 = c_size_in_bytes (target_type);
+   FUNCTION is a tree for the called function.  It is used only for
+   error messages, where it is formatted with %qE.
 
-  /* Divide by the size, in easiest possible way.  */
+   This is also where warnings about wrong number of args are generated.
 
-  result = build (EXACT_DIV_EXPR, restype, op0, convert (restype, op1));
+   VALUES is a chain of TREE_LIST nodes with the elements of the list
+   in the TREE_VALUE slots of those nodes.
 
-  folded = fold (result);
-  if (folded == result)
-    TREE_CONSTANT (folded) = TREE_CONSTANT (op0) & TREE_CONSTANT (op1);
-  return folded;
-}
-\f
-/* Construct and perhaps optimize a tree representation
-   for a unary operation.  CODE, a tree_code, specifies the operation
-   and XARG is the operand.
-   For any CODE other than ADDR_EXPR, FLAG nonzero suppresses
-   the default promotions (such as from short to int).
-   For ADDR_EXPR, the default promotions are not applied; FLAG nonzero
-   allows non-lvalues; this is only used to handle conversion of non-lvalue
-   arrays to pointers in C99.  */
+   Returns the actual number of arguments processed (which may be less
+   than NARGS in some error situations), or -1 on failure.  */
 
-tree
-build_unary_op (code, xarg, flag)
-     enum tree_code code;
-     tree xarg;
-     int flag;
+static int
+convert_arguments (int nargs, tree *argarray,
+                  tree typelist, tree values, tree function, tree fundecl)
 {
-  /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
-  tree arg = xarg;
-  tree argtype = 0;
-  enum tree_code typecode = TREE_CODE (TREE_TYPE (arg));
-  tree val;
-  int noconvert = flag;
+  tree typetail, valtail;
+  int parmnum;
+  bool error_args = false;
+  const bool type_generic = fundecl
+    && lookup_attribute ("type generic", TYPE_ATTRIBUTES(TREE_TYPE (fundecl)));
+  tree selector;
 
-  if (typecode == ERROR_MARK)
-    return error_mark_node;
-  if (typecode == ENUMERAL_TYPE || typecode == BOOLEAN_TYPE)
-    typecode = INTEGER_TYPE;
+  /* Change pointer to function to the function itself for
+     diagnostics.  */
+  if (TREE_CODE (function) == ADDR_EXPR
+      && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
+    function = TREE_OPERAND (function, 0);
 
-  switch (code)
+  /* Handle an ObjC selector specially for diagnostics.  */
+  selector = objc_message_selector ();
+
+  /* Scan the given expressions and types, producing individual
+     converted arguments and storing them in ARGARRAY.  */
+
+  for (valtail = values, typetail = typelist, parmnum = 0;
+       valtail;
+       valtail = TREE_CHAIN (valtail), parmnum++)
     {
-    case CONVERT_EXPR:
-      /* This is used for unary plus, because a CONVERT_EXPR
-        is enough to prevent anybody from looking inside for
-        associativity, but won't generate any code.  */
-      if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
-           || typecode == COMPLEX_TYPE))
+      tree type = typetail ? TREE_VALUE (typetail) : 0;
+      tree val = TREE_VALUE (valtail);
+      tree rname = function;
+      int argnum = parmnum + 1;
+      const char *invalid_func_diag;
+
+      if (type == void_type_node)
        {
-         error ("wrong type argument to unary plus");
-         return error_mark_node;
+         error ("too many arguments to function %qE", function);
+         return parmnum;
        }
-      else if (!noconvert)
-       arg = default_conversion (arg);
-      break;
 
-    case NEGATE_EXPR:
-      if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
-           || typecode == COMPLEX_TYPE))
+      if (selector && argnum > 2)
        {
-         error ("wrong type argument to unary minus");
-         return error_mark_node;
+         rname = selector;
+         argnum -= 2;
        }
-      else if (!noconvert)
-       arg = default_conversion (arg);
-      break;
 
-    case BIT_NOT_EXPR:
-      if (typecode == COMPLEX_TYPE)
+      STRIP_TYPE_NOPS (val);
+
+      val = require_complete_type (val);
+
+      if (type != 0)
+       {
+         /* Formal parm type is specified by a function prototype.  */
+         tree parmval;
+
+         if (type == error_mark_node || !COMPLETE_TYPE_P (type))
+           {
+             error ("type of formal parameter %d is incomplete", parmnum + 1);
+             parmval = val;
+           }
+         else
+           {
+             /* Optionally warn about conversions that
+                differ from the default conversions.  */
+             if (warn_traditional_conversion || warn_traditional)
+               {
+                 unsigned int formal_prec = TYPE_PRECISION (type);
+
+                 if (INTEGRAL_TYPE_P (type)
+                     && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
+                   warning (0, "passing argument %d of %qE as integer "
+                            "rather than floating due to prototype",
+                            argnum, rname);
+                 if (INTEGRAL_TYPE_P (type)
+                     && TREE_CODE (TREE_TYPE (val)) == COMPLEX_TYPE)
+                   warning (0, "passing argument %d of %qE as integer "
+                            "rather than complex due to prototype",
+                            argnum, rname);
+                 else if (TREE_CODE (type) == COMPLEX_TYPE
+                          && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
+                   warning (0, "passing argument %d of %qE as complex "
+                            "rather than floating due to prototype",
+                            argnum, rname);
+                 else if (TREE_CODE (type) == REAL_TYPE
+                          && INTEGRAL_TYPE_P (TREE_TYPE (val)))
+                   warning (0, "passing argument %d of %qE as floating "
+                            "rather than integer due to prototype",
+                            argnum, rname);
+                 else if (TREE_CODE (type) == COMPLEX_TYPE
+                          && INTEGRAL_TYPE_P (TREE_TYPE (val)))
+                   warning (0, "passing argument %d of %qE as complex "
+                            "rather than integer due to prototype",
+                            argnum, rname);
+                 else if (TREE_CODE (type) == REAL_TYPE
+                          && TREE_CODE (TREE_TYPE (val)) == COMPLEX_TYPE)
+                   warning (0, "passing argument %d of %qE as floating "
+                            "rather than complex due to prototype",
+                            argnum, rname);
+                 /* ??? At some point, messages should be written about
+                    conversions between complex types, but that's too messy
+                    to do now.  */
+                 else if (TREE_CODE (type) == REAL_TYPE
+                          && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
+                   {
+                     /* Warn if any argument is passed as `float',
+                        since without a prototype it would be `double'.  */
+                     if (formal_prec == TYPE_PRECISION (float_type_node)
+                         && type != dfloat32_type_node)
+                       warning (0, "passing argument %d of %qE as %<float%> "
+                                "rather than %<double%> due to prototype",
+                                argnum, rname);
+
+                     /* Warn if mismatch between argument and prototype
+                        for decimal float types.  Warn of conversions with
+                        binary float types and of precision narrowing due to
+                        prototype. */
+                     else if (type != TREE_TYPE (val)
+                              && (type == dfloat32_type_node
+                                  || type == dfloat64_type_node
+                                  || type == dfloat128_type_node
+                                  || TREE_TYPE (val) == dfloat32_type_node
+                                  || TREE_TYPE (val) == dfloat64_type_node
+                                  || TREE_TYPE (val) == dfloat128_type_node)
+                              && (formal_prec
+                                  <= TYPE_PRECISION (TREE_TYPE (val))
+                                  || (type == dfloat128_type_node
+                                      && (TREE_TYPE (val)
+                                          != dfloat64_type_node
+                                          && (TREE_TYPE (val)
+                                              != dfloat32_type_node)))
+                                  || (type == dfloat64_type_node
+                                      && (TREE_TYPE (val)
+                                          != dfloat32_type_node))))
+                       warning (0, "passing argument %d of %qE as %qT "
+                                "rather than %qT due to prototype",
+                                argnum, rname, type, TREE_TYPE (val));
+
+                   }
+                 /* Detect integer changing in width or signedness.
+                    These warnings are only activated with
+                    -Wtraditional-conversion, not with -Wtraditional.  */
+                 else if (warn_traditional_conversion && INTEGRAL_TYPE_P (type)
+                          && INTEGRAL_TYPE_P (TREE_TYPE (val)))
+                   {
+                     tree would_have_been = default_conversion (val);
+                     tree type1 = TREE_TYPE (would_have_been);
+
+                     if (TREE_CODE (type) == ENUMERAL_TYPE
+                         && (TYPE_MAIN_VARIANT (type)
+                             == TYPE_MAIN_VARIANT (TREE_TYPE (val))))
+                       /* No warning if function asks for enum
+                          and the actual arg is that enum type.  */
+                       ;
+                     else if (formal_prec != TYPE_PRECISION (type1))
+                       warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+                                "with different width due to prototype",
+                                argnum, rname);
+                     else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1))
+                       ;
+                     /* Don't complain if the formal parameter type
+                        is an enum, because we can't tell now whether
+                        the value was an enum--even the same enum.  */
+                     else if (TREE_CODE (type) == ENUMERAL_TYPE)
+                       ;
+                     else if (TREE_CODE (val) == INTEGER_CST
+                              && int_fits_type_p (val, type))
+                       /* Change in signedness doesn't matter
+                          if a constant value is unaffected.  */
+                       ;
+                     /* If the value is extended from a narrower
+                        unsigned type, it doesn't matter whether we
+                        pass it as signed or unsigned; the value
+                        certainly is the same either way.  */
+                     else if (TYPE_PRECISION (TREE_TYPE (val)) < TYPE_PRECISION (type)
+                              && TYPE_UNSIGNED (TREE_TYPE (val)))
+                       ;
+                     else if (TYPE_UNSIGNED (type))
+                       warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+                                "as unsigned due to prototype",
+                                argnum, rname);
+                     else
+                       warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+                                "as signed due to prototype", argnum, rname);
+                   }
+               }
+
+             parmval = convert_for_assignment (type, val, ic_argpass,
+                                               fundecl, function,
+                                               parmnum + 1);
+
+             if (targetm.calls.promote_prototypes (fundecl ? TREE_TYPE (fundecl) : 0)
+                 && INTEGRAL_TYPE_P (type)
+                 && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
+               parmval = default_conversion (parmval);
+           }
+         argarray[parmnum] = parmval;
+       }
+      else if (TREE_CODE (TREE_TYPE (val)) == REAL_TYPE
+              && (TYPE_PRECISION (TREE_TYPE (val))
+                  < TYPE_PRECISION (double_type_node))
+              && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (val))))
+        {
+         if (type_generic)
+           argarray[parmnum] = val;
+         else
+           /* Convert `float' to `double'.  */
+           argarray[parmnum] = convert (double_type_node, val);
+       }
+      else if ((invalid_func_diag =
+               targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
+       {
+         error (invalid_func_diag);
+         return -1;
+       }
+      else
+       /* Convert `short' and `char' to full-size `int'.  */
+       argarray[parmnum] = default_conversion (val);
+
+      if (argarray[parmnum] == error_mark_node)
+       error_args = true;
+
+      if (typetail)
+       typetail = TREE_CHAIN (typetail);
+    }
+
+  gcc_assert (parmnum == nargs);
+
+  if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
+    {
+      error ("too few arguments to function %qE", function);
+      return -1;
+    }
+
+  return error_args ? -1 : parmnum;
+}
+\f
+/* This is the entry point used by the parser to build unary operators
+   in the input.  CODE, a tree_code, specifies the unary operator, and
+   ARG is the operand.  For unary plus, the C parser currently uses
+   CONVERT_EXPR for code.
+
+   LOC is the location to use for the tree generated.
+*/
+
+struct c_expr
+parser_build_unary_op (enum tree_code code, struct c_expr arg, location_t loc)
+{
+  struct c_expr result;
+
+  result.value = build_unary_op (loc, code, arg.value, 0);
+  result.original_code = code;
+  
+  if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
+    overflow_warning (result.value);
+
+  return result;
+}
+
+/* This is the entry point used by the parser to build binary operators
+   in the input.  CODE, a tree_code, specifies the binary operator, and
+   ARG1 and ARG2 are the operands.  In addition to constructing the
+   expression, we check for operands that were written with other binary
+   operators in a way that is likely to confuse the user.
+
+   LOCATION is the location of the binary operator.  */
+
+struct c_expr
+parser_build_binary_op (location_t location, enum tree_code code,
+                       struct c_expr arg1, struct c_expr arg2)
+{
+  struct c_expr result;
+
+  enum tree_code code1 = arg1.original_code;
+  enum tree_code code2 = arg2.original_code;
+
+  result.value = build_binary_op (location, code,
+                                 arg1.value, arg2.value, 1);
+  result.original_code = code;
+
+  if (TREE_CODE (result.value) == ERROR_MARK)
+    return result;
+
+  if (location != UNKNOWN_LOCATION)
+    protected_set_expr_location (result.value, location);
+
+  /* Check for cases such as x+y<<z which users are likely
+     to misinterpret.  */
+  if (warn_parentheses)
+    warn_about_parentheses (code, code1, arg1.value, code2, arg2.value);
+
+  if (TREE_CODE_CLASS (code1) != tcc_comparison)
+    warn_logical_operator (code, arg1.value, arg2.value);
+
+  /* Warn about comparisons against string literals, with the exception
+     of testing for equality or inequality of a string literal with NULL.  */
+  if (code == EQ_EXPR || code == NE_EXPR)
+    {
+      if ((code1 == STRING_CST && !integer_zerop (arg2.value))
+         || (code2 == STRING_CST && !integer_zerop (arg1.value)))
+       warning (OPT_Waddress, "comparison with string literal results in unspecified behavior");
+    }
+  else if (TREE_CODE_CLASS (code) == tcc_comparison
+          && (code1 == STRING_CST || code2 == STRING_CST))
+    warning (OPT_Waddress, "comparison with string literal results in unspecified behavior");
+
+  if (TREE_OVERFLOW_P (result.value) 
+      && !TREE_OVERFLOW_P (arg1.value) 
+      && !TREE_OVERFLOW_P (arg2.value))
+    overflow_warning (result.value);
+
+  return result;
+}
+\f
+/* Return a tree for the difference of pointers OP0 and OP1.
+   The resulting tree has type int.  */
+
+static tree
+pointer_diff (tree op0, tree op1)
+{
+  tree restype = ptrdiff_type_node;
+
+  tree target_type = TREE_TYPE (TREE_TYPE (op0));
+  tree con0, con1, lit0, lit1;
+  tree orig_op1 = op1;
+
+  if (TREE_CODE (target_type) == VOID_TYPE)
+    pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, 
+            "pointer of type %<void *%> used in subtraction");
+  if (TREE_CODE (target_type) == FUNCTION_TYPE)
+    pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, 
+            "pointer to a function used in subtraction");
+
+  /* If the conversion to ptrdiff_type does anything like widening or
+     converting a partial to an integral mode, we get a convert_expression
+     that is in the way to do any simplifications.
+     (fold-const.c doesn't know that the extra bits won't be needed.
+     split_tree uses STRIP_SIGN_NOPS, which leaves conversions to a
+     different mode in place.)
+     So first try to find a common term here 'by hand'; we want to cover
+     at least the cases that occur in legal static initializers.  */
+  if (CONVERT_EXPR_P (op0)
+      && (TYPE_PRECISION (TREE_TYPE (op0))
+         == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))))
+    con0 = TREE_OPERAND (op0, 0);
+  else
+    con0 = op0;
+  if (CONVERT_EXPR_P (op1)
+      && (TYPE_PRECISION (TREE_TYPE (op1))
+         == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op1, 0)))))
+    con1 = TREE_OPERAND (op1, 0);
+  else
+    con1 = op1;
+
+  if (TREE_CODE (con0) == PLUS_EXPR)
+    {
+      lit0 = TREE_OPERAND (con0, 1);
+      con0 = TREE_OPERAND (con0, 0);
+    }
+  else
+    lit0 = integer_zero_node;
+
+  if (TREE_CODE (con1) == PLUS_EXPR)
+    {
+      lit1 = TREE_OPERAND (con1, 1);
+      con1 = TREE_OPERAND (con1, 0);
+    }
+  else
+    lit1 = integer_zero_node;
+
+  if (operand_equal_p (con0, con1, 0))
+    {
+      op0 = lit0;
+      op1 = lit1;
+    }
+
+
+  /* First do the subtraction as integers;
+     then drop through to build the divide operator.
+     Do not do default conversions on the minus operator
+     in case restype is a short type.  */
+
+  op0 = build_binary_op (input_location,
+                        MINUS_EXPR, convert (restype, op0),
+                        convert (restype, op1), 0);
+  /* This generates an error if op1 is pointer to incomplete type.  */
+  if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1))))
+    error ("arithmetic on pointer to an incomplete type");
+
+  /* This generates an error if op0 is pointer to incomplete type.  */
+  op1 = c_size_in_bytes (target_type);
+
+  /* Divide by the size, in easiest possible way.  */
+  return fold_build2 (EXACT_DIV_EXPR, restype, op0, convert (restype, op1));
+}
+\f
+/* Construct and perhaps optimize a tree representation
+   for a unary operation.  CODE, a tree_code, specifies the operation
+   and XARG is the operand.
+   For any CODE other than ADDR_EXPR, FLAG nonzero suppresses
+   the default promotions (such as from short to int).
+   For ADDR_EXPR, the default promotions are not applied; FLAG nonzero
+   allows non-lvalues; this is only used to handle conversion of non-lvalue
+   arrays to pointers in C99.
+
+   LOCATION is the location of the operator.  */
+
+tree
+build_unary_op (location_t location,
+               enum tree_code code, tree xarg, int flag)
+{
+  /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
+  tree arg = xarg;
+  tree argtype = 0;
+  enum tree_code typecode;
+  tree val;
+  tree ret = error_mark_node;
+  int noconvert = flag;
+  const char *invalid_op_diag;
+
+  if (code != ADDR_EXPR)
+    arg = require_complete_type (arg);
+
+  typecode = TREE_CODE (TREE_TYPE (arg));
+  if (typecode == ERROR_MARK)
+    return error_mark_node;
+  if (typecode == ENUMERAL_TYPE || typecode == BOOLEAN_TYPE)
+    typecode = INTEGER_TYPE;
+
+  if ((invalid_op_diag
+       = targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
+    {
+      error_at (location, invalid_op_diag);
+      return error_mark_node;
+    }
+
+  switch (code)
+    {
+    case CONVERT_EXPR:
+      /* This is used for unary plus, because a CONVERT_EXPR
+        is enough to prevent anybody from looking inside for
+        associativity, but won't generate any code.  */
+      if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
+           || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
+           || typecode == VECTOR_TYPE))
+       {
+         error_at (location, "wrong type argument to unary plus");
+         return error_mark_node;
+       }
+      else if (!noconvert)
+       arg = default_conversion (arg);
+      arg = non_lvalue (arg);
+      break;
+
+    case NEGATE_EXPR:
+      if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
+           || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
+           || typecode == VECTOR_TYPE))
+       {
+         error_at (location, "wrong type argument to unary minus");
+         return error_mark_node;
+       }
+      else if (!noconvert)
+       arg = default_conversion (arg);
+      break;
+
+    case BIT_NOT_EXPR:
+      /* ~ works on integer types and non float vectors. */
+      if (typecode == INTEGER_TYPE
+         || (typecode == VECTOR_TYPE
+             && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (arg))))
+       {
+         if (!noconvert)
+           arg = default_conversion (arg);
+       }
+      else if (typecode == COMPLEX_TYPE)
        {
          code = CONJ_EXPR;
-         if (pedantic)
-           pedwarn ("ISO C does not support `~' for complex conjugation");
+         pedwarn (location, OPT_pedantic, 
+                  "ISO C does not support %<~%> for complex conjugation");
          if (!noconvert)
            arg = default_conversion (arg);
        }
-      else if (typecode != INTEGER_TYPE)
+      else
        {
-         error ("wrong type argument to bit-complement");
+         error_at (location, "wrong type argument to bit-complement");
          return error_mark_node;
        }
-      else if (!noconvert)
-       arg = default_conversion (arg);
       break;
 
     case ABS_EXPR:
-      if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
-           || typecode == COMPLEX_TYPE))
+      if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE))
        {
-         error ("wrong type argument to abs");
+         error_at (location, "wrong type argument to abs");
          return error_mark_node;
        }
       else if (!noconvert)
@@ -2805,7 +3024,7 @@ build_unary_op (code, xarg, flag)
       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
            || typecode == COMPLEX_TYPE))
        {
-         error ("wrong type argument to conjugation");
+         error_at (location, "wrong type argument to conjugation");
          return error_mark_node;
        }
       else if (!noconvert)
@@ -2813,47 +3032,40 @@ build_unary_op (code, xarg, flag)
       break;
 
     case TRUTH_NOT_EXPR:
-      if (typecode != INTEGER_TYPE
+      if (typecode != INTEGER_TYPE && typecode != FIXED_POINT_TYPE
          && typecode != REAL_TYPE && typecode != POINTER_TYPE
-         && typecode != COMPLEX_TYPE
-         /* These will convert to a pointer.  */
-         && typecode != ARRAY_TYPE && typecode != FUNCTION_TYPE)
+         && typecode != COMPLEX_TYPE)
        {
-         error ("wrong type argument to unary exclamation mark");
+         error_at (location,
+                   "wrong type argument to unary exclamation mark");
          return error_mark_node;
        }
-      arg = truthvalue_conversion (arg);
-      return invert_truthvalue (arg);
-
-    case NOP_EXPR:
-      break;
+      arg = c_objc_common_truthvalue_conversion (location, arg);
+      ret = invert_truthvalue (arg);
+      goto return_build_unary_op;
 
     case REALPART_EXPR:
       if (TREE_CODE (arg) == COMPLEX_CST)
-       return TREE_REALPART (arg);
+       ret = TREE_REALPART (arg);
       else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
-       return fold (build1 (REALPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg));
+       ret = fold_build1 (REALPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg);
       else
-       return arg;
+       ret = arg;
+      goto return_build_unary_op;
 
     case IMAGPART_EXPR:
       if (TREE_CODE (arg) == COMPLEX_CST)
-       return TREE_IMAGPART (arg);
+       ret = TREE_IMAGPART (arg);
       else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
-       return fold (build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg));
+       ret = fold_build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg);
       else
-       return convert (TREE_TYPE (arg), integer_zero_node);
-      
+       ret = omit_one_operand (TREE_TYPE (arg), integer_zero_node, arg);
+      goto return_build_unary_op;
+
     case PREINCREMENT_EXPR:
     case POSTINCREMENT_EXPR:
     case PREDECREMENT_EXPR:
     case POSTDECREMENT_EXPR:
-      /* Handle complex lvalues (when permitted)
-        by reduction to simpler cases.  */
-
-      val = unary_complex_lvalue (code, arg, 0);
-      if (val != 0)
-       return val;
 
       /* Increment or decrement the real part of the value,
         and don't change the imaginary part.  */
@@ -2861,32 +3073,37 @@ build_unary_op (code, xarg, flag)
        {
          tree real, imag;
 
-         if (pedantic)
-           pedwarn ("ISO C does not support `++' and `--' on complex types");
+         pedwarn (location, OPT_pedantic, 
+                  "ISO C does not support %<++%> and %<--%> on complex types");
 
          arg = stabilize_reference (arg);
-         real = build_unary_op (REALPART_EXPR, arg, 1);
-         imag = build_unary_op (IMAGPART_EXPR, arg, 1);
-         return build (COMPLEX_EXPR, TREE_TYPE (arg),
-                       build_unary_op (code, real, 1), imag);
+         real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg, 1);
+         imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg, 1);
+         real = build_unary_op (EXPR_LOCATION (arg), code, real, 1);
+         if (real == error_mark_node || imag == error_mark_node)
+           return error_mark_node;
+         ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg),
+                       real, imag);
+         goto return_build_unary_op;
        }
 
       /* Report invalid types.  */
 
-      if (typecode != POINTER_TYPE
+      if (typecode != POINTER_TYPE && typecode != FIXED_POINT_TYPE
          && typecode != INTEGER_TYPE && typecode != REAL_TYPE)
        {
          if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
-            error ("wrong type argument to increment");
-          else
-            error ("wrong type argument to decrement");
+           error_at (location, "wrong type argument to increment");
+         else
+           error_at (location, "wrong type argument to decrement");
 
          return error_mark_node;
        }
 
       {
        tree inc;
-       tree result_type = TREE_TYPE (arg);
+
+       argtype = TREE_TYPE (arg);
 
        /* Compute the increment.  */
 
@@ -2894,107 +3111,80 @@ build_unary_op (code, xarg, flag)
          {
            /* If pointer target is an undefined struct,
               we just cannot know how to do the arithmetic.  */
-           if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (result_type)))
+           if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (argtype)))
              {
                if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
-                 error ("increment of pointer to unknown structure");
+                 error_at (location,
+                           "increment of pointer to unknown structure");
                else
-                 error ("decrement of pointer to unknown structure");
+                 error_at (location,
+                           "decrement of pointer to unknown structure");
              }
-           else if ((pedantic || warn_pointer_arith)
-                    && (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE
-                        || TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE))
-              {
+           else if (TREE_CODE (TREE_TYPE (argtype)) == FUNCTION_TYPE
+                    || TREE_CODE (TREE_TYPE (argtype)) == VOID_TYPE)
+             {
                if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
-                 pedwarn ("wrong type argument to increment");
+                 pedwarn (location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, 
+                          "wrong type argument to increment");
                else
-                 pedwarn ("wrong type argument to decrement");
+                 pedwarn (location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, 
+                          "wrong type argument to decrement");
              }
 
-           inc = c_size_in_bytes (TREE_TYPE (result_type));
+           inc = c_size_in_bytes (TREE_TYPE (argtype));
+           inc = fold_convert (sizetype, inc);
+         }
+       else if (FRACT_MODE_P (TYPE_MODE (argtype)))
+         {
+           /* For signed fract types, we invert ++ to -- or
+              -- to ++, and change inc from 1 to -1, because
+              it is not possible to represent 1 in signed fract constants.
+              For unsigned fract types, the result always overflows and
+              we get an undefined (original) or the maximum value.  */
+           if (code == PREINCREMENT_EXPR)
+             code = PREDECREMENT_EXPR;
+           else if (code == PREDECREMENT_EXPR)
+             code = PREINCREMENT_EXPR;
+           else if (code == POSTINCREMENT_EXPR)
+             code = POSTDECREMENT_EXPR;
+           else /* code == POSTDECREMENT_EXPR  */
+             code = POSTINCREMENT_EXPR;
+
+           inc = integer_minus_one_node;
+           inc = convert (argtype, inc);
          }
        else
-         inc = integer_one_node;
-
-       arg = get_unwidened (arg, 0);
-       argtype = TREE_TYPE (arg);
-
-       inc = convert (argtype, inc);
-
-       /* Handle incrementing a cast-expression.  */
-
-       while (1)
-         switch (TREE_CODE (arg))
-           {
-           case NOP_EXPR:
-           case CONVERT_EXPR:
-           case FLOAT_EXPR:
-           case FIX_TRUNC_EXPR:
-           case FIX_FLOOR_EXPR:
-           case FIX_ROUND_EXPR:
-           case FIX_CEIL_EXPR:
-             pedantic_lvalue_warning (CONVERT_EXPR);
-             /* If the real type has the same machine representation
-                as the type it is cast to, we can make better output
-                by adding directly to the inside of the cast.  */
-             if ((TREE_CODE (TREE_TYPE (arg))
-                  == TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))))
-                 && (TYPE_MODE (TREE_TYPE (arg))
-                     == TYPE_MODE (TREE_TYPE (TREE_OPERAND (arg, 0)))))
-               arg = TREE_OPERAND (arg, 0);
-             else
-               {
-                 tree incremented, modify, value;
-                 if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE)
-                   value = boolean_increment (code, arg);
-                 else
-                   {
-                     arg = stabilize_reference (arg);
-                     if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR)
-                       value = arg;
-                     else
-                       value = save_expr (arg);
-                     incremented = build (((code == PREINCREMENT_EXPR
-                                            || code == POSTINCREMENT_EXPR)
-                                           ? PLUS_EXPR : MINUS_EXPR),
-                                          argtype, value, inc);
-                     TREE_SIDE_EFFECTS (incremented) = 1;
-                     modify = build_modify_expr (arg, NOP_EXPR, incremented);
-                     value = build (COMPOUND_EXPR, TREE_TYPE (arg), modify, value);
-                   }
-                 TREE_USED (value) = 1;
-                 return value;
-               }
-             break;
-
-           default:
-             goto give_up;
-           }
-      give_up:
+         {
+           inc = integer_one_node;
+           inc = convert (argtype, inc);
+         }
 
        /* Complain about anything else that is not a true lvalue.  */
        if (!lvalue_or_else (arg, ((code == PREINCREMENT_EXPR
                                    || code == POSTINCREMENT_EXPR)
-                                  ? "invalid lvalue in increment"
-                                  : "invalid lvalue in decrement")))
+                                  ? lv_increment
+                                  : lv_decrement)))
          return error_mark_node;
 
        /* Report a read-only lvalue.  */
        if (TREE_READONLY (arg))
-         readonly_warning (arg, 
+         {
+           readonly_error (arg,
                            ((code == PREINCREMENT_EXPR
                              || code == POSTINCREMENT_EXPR)
-                            ? "increment" : "decrement"));
+                            ? lv_increment : lv_decrement));
+           return error_mark_node;
+         }
 
        if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE)
          val = boolean_increment (code, arg);
        else
-         val = build (code, TREE_TYPE (arg), arg, inc);
+         val = build2 (code, TREE_TYPE (arg), arg, inc);
        TREE_SIDE_EFFECTS (val) = 1;
-       val = convert (result_type, val);
        if (TREE_CODE (val) != code)
-         TREE_NO_UNUSED_WARNING (val) = 1;
-       return val;
+         TREE_NO_WARNING (val) = 1;
+       ret = val;
+       goto return_build_unary_op;
       }
 
     case ADDR_EXPR:
@@ -3006,149 +3196,90 @@ build_unary_op (code, xarg, flag)
          /* Don't let this be an lvalue.  */
          if (lvalue_p (TREE_OPERAND (arg, 0)))
            return non_lvalue (TREE_OPERAND (arg, 0));
-         return TREE_OPERAND (arg, 0);
+         ret = TREE_OPERAND (arg, 0);
+         goto return_build_unary_op;
        }
 
       /* For &x[y], return x+y */
       if (TREE_CODE (arg) == ARRAY_REF)
        {
-         if (mark_addressable (TREE_OPERAND (arg, 0)) == 0)
+         tree op0 = TREE_OPERAND (arg, 0);
+         if (!c_mark_addressable (op0))
            return error_mark_node;
-         return build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0),
+         return build_binary_op (location, PLUS_EXPR,
+                                 (TREE_CODE (TREE_TYPE (op0)) == ARRAY_TYPE
+                                  ? array_to_pointer_conversion (op0)
+                                  : op0),
                                  TREE_OPERAND (arg, 1), 1);
        }
 
-      /* Handle complex lvalues (when permitted)
-        by reduction to simpler cases.  */
-      val = unary_complex_lvalue (code, arg, flag);
-      if (val != 0)
-       return val;
-
-#if 0 /* Turned off because inconsistent;
-        float f; *&(int)f = 3.4 stores in int format
-        whereas (int)f = 3.4 stores in float format.  */
-      /* Address of a cast is just a cast of the address
-        of the operand of the cast.  */
-      switch (TREE_CODE (arg))
-       {
-       case NOP_EXPR:
-       case CONVERT_EXPR:
-       case FLOAT_EXPR:
-       case FIX_TRUNC_EXPR:
-       case FIX_FLOOR_EXPR:
-       case FIX_ROUND_EXPR:
-       case FIX_CEIL_EXPR:
-         if (pedantic)
-           pedwarn ("ISO C forbids the address of a cast expression");
-         return convert (build_pointer_type (TREE_TYPE (arg)),
-                         build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0),
-                                         0));
-       }
-#endif
-
       /* Anything not already handled and not a true memory reference
         or a non-lvalue array is an error.  */
       else if (typecode != FUNCTION_TYPE && !flag
-              && !lvalue_or_else (arg, "invalid lvalue in unary `&'"))
+              && !lvalue_or_else (arg, lv_addressof))
        return error_mark_node;
 
       /* Ordinary case; arg is a COMPONENT_REF or a decl.  */
       argtype = TREE_TYPE (arg);
 
       /* If the lvalue is const or volatile, merge that into the type
-         to which the address will point.  Note that you can't get a
+        to which the address will point.  Note that you can't get a
         restricted pointer by taking the address of something, so we
         only have to deal with `const' and `volatile' here.  */
-      if ((DECL_P (arg) || TREE_CODE_CLASS (TREE_CODE (arg)) == 'r')
+      if ((DECL_P (arg) || REFERENCE_CLASS_P (arg))
          && (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg)))
          argtype = c_build_type_variant (argtype,
                                          TREE_READONLY (arg),
                                          TREE_THIS_VOLATILE (arg));
 
-      argtype = build_pointer_type (argtype);
-
-      if (mark_addressable (arg) == 0)
+      if (!c_mark_addressable (arg))
        return error_mark_node;
 
-      {
-       tree addr;
+      gcc_assert (TREE_CODE (arg) != COMPONENT_REF
+                 || !DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)));
 
-       if (TREE_CODE (arg) == COMPONENT_REF)
-         {
-           tree field = TREE_OPERAND (arg, 1);
+      argtype = build_pointer_type (argtype);
 
-           addr = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0), flag);
+      /* ??? Cope with user tricks that amount to offsetof.  Delete this
+        when we have proper support for integer constant expressions.  */
+      val = get_base_address (arg);
+      if (val && TREE_CODE (val) == INDIRECT_REF
+          && TREE_CONSTANT (TREE_OPERAND (val, 0)))
+       {
+         tree op0 = fold_convert (sizetype, fold_offsetof (arg, val)), op1;
 
-           if (DECL_C_BIT_FIELD (field))
-             {
-               error ("attempt to take address of bit-field structure member `%s'",
-                      IDENTIFIER_POINTER (DECL_NAME (field)));
-               return error_mark_node;
-             }
+         op1 = fold_convert (argtype, TREE_OPERAND (val, 0));
+         ret = fold_build2 (POINTER_PLUS_EXPR, argtype, op1, op0);
+         goto return_build_unary_op;
+       }
 
-           addr = fold (build (PLUS_EXPR, argtype,
-                               convert (argtype, addr),
-                               convert (argtype, byte_position (field))));
-         }
-       else
-         addr = build1 (code, argtype, arg);
-
-       /* Address of a static or external variable or
-          file-scope function counts as a constant.  */
-       if (staticp (arg)
-           && ! (TREE_CODE (arg) == FUNCTION_DECL
-                 && DECL_CONTEXT (arg) != 0))
-         TREE_CONSTANT (addr) = 1;
-       return addr;
-      }
+      val = build1 (ADDR_EXPR, argtype, arg);
+
+      ret = val;
+      goto return_build_unary_op;
 
     default:
-      break;
+      gcc_unreachable ();
     }
 
   if (argtype == 0)
     argtype = TREE_TYPE (arg);
-  return fold (build1 (code, argtype, arg));
-}
-
-#if 0
-/* If CONVERSIONS is a conversion expression or a nested sequence of such,
-   convert ARG with the same conversions in the same order
-   and return the result.  */
-
-static tree
-convert_sequence (conversions, arg)
-     tree conversions;
-     tree arg;
-{
-  switch (TREE_CODE (conversions))
-    {
-    case NOP_EXPR:
-    case CONVERT_EXPR:
-    case FLOAT_EXPR:
-    case FIX_TRUNC_EXPR:
-    case FIX_FLOOR_EXPR:
-    case FIX_ROUND_EXPR:
-    case FIX_CEIL_EXPR:
-      return convert (TREE_TYPE (conversions),
-                     convert_sequence (TREE_OPERAND (conversions, 0),
-                                       arg));
-
-    default:
-      return arg;
-    }
+  ret = require_constant_value ? fold_build1_initializer (code, argtype, arg)
+                              : fold_build1 (code, argtype, arg);
+ return_build_unary_op:
+  gcc_assert (ret != error_mark_node);
+  protected_set_expr_location (ret, location);
+  return ret;
 }
-#endif /* 0 */
 
 /* Return nonzero if REF is an lvalue valid for this language.
    Lvalues can be assigned, unless their type has TYPE_READONLY.
-   Lvalues can have their address taken, unless they have DECL_REGISTER.  */
+   Lvalues can have their address taken, unless they have C_DECL_REGISTER.  */
 
-int
-lvalue_p (ref)
-     tree ref;
+static int
+lvalue_p (const_tree ref)
 {
-  enum tree_code code = TREE_CODE (ref);
+  const enum tree_code code = TREE_CODE (ref);
 
   switch (code)
     {
@@ -3171,137 +3302,85 @@ lvalue_p (ref)
              && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE);
 
     case BIND_EXPR:
-    case RTL_EXPR:
       return TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE;
 
     default:
       return 0;
     }
 }
-
-/* Return nonzero if REF is an lvalue valid for this language;
-   otherwise, print an error message and return zero.  */
-
-int
-lvalue_or_else (ref, msgid)
-     tree ref;
-     const char *msgid;
-{
-  int win = lvalue_p (ref);
-
-  if (! win)
-    error ("%s", msgid);
-
-  return win;
-}
-
-/* Apply unary lvalue-demanding operator CODE to the expression ARG
-   for certain kinds of expressions which are not really lvalues
-   but which we can accept as lvalues.  If FLAG is nonzero, then
-   non-lvalues are OK since we may be converting a non-lvalue array to
-   a pointer in C99.
-
-   If ARG is not a kind of expression we can handle, return zero.  */
-   
-static tree
-unary_complex_lvalue (code, arg, flag)
-     enum tree_code code;
-     tree arg;
-     int flag;
-{
-  /* Handle (a, b) used as an "lvalue".  */
-  if (TREE_CODE (arg) == COMPOUND_EXPR)
-    {
-      tree real_result = build_unary_op (code, TREE_OPERAND (arg, 1), 0);
-
-      /* If this returns a function type, it isn't really being used as
-        an lvalue, so don't issue a warning about it.  */
-      if (TREE_CODE (TREE_TYPE (arg)) != FUNCTION_TYPE && !flag)
-       pedantic_lvalue_warning (COMPOUND_EXPR);
-
-      return build (COMPOUND_EXPR, TREE_TYPE (real_result),
-                   TREE_OPERAND (arg, 0), real_result);
-    }
-
-  /* Handle (a ? b : c) used as an "lvalue".  */
-  if (TREE_CODE (arg) == COND_EXPR)
-    {
-      if (!flag)
-       pedantic_lvalue_warning (COND_EXPR);
-      if (TREE_CODE (TREE_TYPE (arg)) != FUNCTION_TYPE && !flag)
-       pedantic_lvalue_warning (COMPOUND_EXPR);
-
-      return (build_conditional_expr
-             (TREE_OPERAND (arg, 0),
-              build_unary_op (code, TREE_OPERAND (arg, 1), flag),
-              build_unary_op (code, TREE_OPERAND (arg, 2), flag)));
-    }
-
-  return 0;
-}
-
-/* If pedantic, warn about improper lvalue.   CODE is either COND_EXPR
-   COMPOUND_EXPR, or CONVERT_EXPR (for casts).  */
-
-static void
-pedantic_lvalue_warning (code)
-     enum tree_code code;
-{
-  if (pedantic)
-    switch (code)
-      {
-      case COND_EXPR:
-       pedwarn ("ISO C forbids use of conditional expressions as lvalues");
-       break;
-      case COMPOUND_EXPR:
-       pedwarn ("ISO C forbids use of compound expressions as lvalues");
-       break;
-      default:
-       pedwarn ("ISO C forbids use of cast expressions as lvalues");
-       break;
-      }
-}
 \f
-/* Warn about storing in something that is `const'.  */
+/* Give an error for storing in something that is 'const'.  */
 
-void
-readonly_warning (arg, msgid)
-     tree arg;
-     const char *msgid;
+static void
+readonly_error (tree arg, enum lvalue_use use)
 {
+  gcc_assert (use == lv_assign || use == lv_increment || use == lv_decrement
+             || use == lv_asm);
+  /* Using this macro rather than (for example) arrays of messages
+     ensures that all the format strings are checked at compile
+     time.  */
+#define READONLY_MSG(A, I, D, AS) (use == lv_assign ? (A)              \
+                                  : (use == lv_increment ? (I)         \
+                                  : (use == lv_decrement ? (D) : (AS))))
   if (TREE_CODE (arg) == COMPONENT_REF)
     {
       if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
-       readonly_warning (TREE_OPERAND (arg, 0), msgid);
+       readonly_error (TREE_OPERAND (arg, 0), use);
       else
-       pedwarn ("%s of read-only member `%s'", _(msgid),
-                IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (arg, 1))));
+       error (READONLY_MSG (G_("assignment of read-only member %qD"),
+                            G_("increment of read-only member %qD"),
+                            G_("decrement of read-only member %qD"),
+                            G_("read-only member %qD used as %<asm%> output")),
+              TREE_OPERAND (arg, 1));
     }
   else if (TREE_CODE (arg) == VAR_DECL)
-    pedwarn ("%s of read-only variable `%s'", _(msgid),
-            IDENTIFIER_POINTER (DECL_NAME (arg)));
+    error (READONLY_MSG (G_("assignment of read-only variable %qD"),
+                        G_("increment of read-only variable %qD"),
+                        G_("decrement of read-only variable %qD"),
+                        G_("read-only variable %qD used as %<asm%> output")),
+          arg);
   else
-    pedwarn ("%s of read-only location", _(msgid));
+    error (READONLY_MSG (G_("assignment of read-only location %qE"),
+                        G_("increment of read-only location %qE"),
+                        G_("decrement of read-only location %qE"),
+                        G_("read-only location %qE used as %<asm%> output")),
+          arg);
+}
+
+
+/* Return nonzero if REF is an lvalue valid for this language;
+   otherwise, print an error message and return zero.  USE says
+   how the lvalue is being used and so selects the error message.  */
+
+static int
+lvalue_or_else (const_tree ref, enum lvalue_use use)
+{
+  int win = lvalue_p (ref);
+
+  if (!win)
+    lvalue_error (use);
+
+  return win;
 }
 \f
 /* Mark EXP saying that we need to be able to take the
    address of it; it should not be allocated in a register.
-   Value is 1 if successful.  */
+   Returns true if successful.  */
 
-int
-mark_addressable (exp)
-     tree exp;
+bool
+c_mark_addressable (tree exp)
 {
   tree x = exp;
+
   while (1)
     switch (TREE_CODE (x))
       {
       case COMPONENT_REF:
        if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
          {
-           error ("cannot take address of bit-field `%s'",
-                  IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (x, 1))));
-           return 0;
+           error
+             ("cannot take address of bit-field %qD", TREE_OPERAND (x, 1));
+           return false;
          }
 
        /* ... fall through ...  */
@@ -3316,67 +3395,45 @@ mark_addressable (exp)
       case COMPOUND_LITERAL_EXPR:
       case CONSTRUCTOR:
        TREE_ADDRESSABLE (x) = 1;
-       return 1;
+       return true;
 
       case VAR_DECL:
       case CONST_DECL:
       case PARM_DECL:
       case RESULT_DECL:
-       if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
+       if (C_DECL_REGISTER (x)
            && DECL_NONLOCAL (x))
          {
-           if (TREE_PUBLIC (x))
+           if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
              {
-               error ("global register variable `%s' used in nested function",
-                      IDENTIFIER_POINTER (DECL_NAME (x)));
-               return 0;
+               error
+                 ("global register variable %qD used in nested function", x);
+               return false;
              }
-           pedwarn ("register variable `%s' used in nested function",
-                    IDENTIFIER_POINTER (DECL_NAME (x)));
+           pedwarn (input_location, 0, "register variable %qD used in nested function", x);
          }
-       else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
+       else if (C_DECL_REGISTER (x))
          {
-           if (TREE_PUBLIC (x))
-             {
-               error ("address of global register variable `%s' requested",
-                      IDENTIFIER_POINTER (DECL_NAME (x)));
-               return 0;
-             }
-
-           /* If we are making this addressable due to its having
-              volatile components, give a different error message.  Also
-              handle the case of an unnamed parameter by not trying
-              to give the name.  */
-
-           else if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (x)))
-             {
-               error ("cannot put object with volatile field into register");
-               return 0;
-             }
-
-           pedwarn ("address of register variable `%s' requested",
-                    IDENTIFIER_POINTER (DECL_NAME (x)));
+           if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
+             error ("address of global register variable %qD requested", x);
+           else
+             error ("address of register variable %qD requested", x);
+           return false;
          }
-       put_var_into_stack (x);
 
        /* drops in */
       case FUNCTION_DECL:
        TREE_ADDRESSABLE (x) = 1;
-#if 0  /* poplevel deals with this now.  */
-       if (DECL_CONTEXT (x) == 0)
-         TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
-#endif
-
+       /* drops out */
       default:
-       return 1;
+       return true;
     }
 }
 \f
 /* Build and return a conditional expression IFEXP ? OP1 : OP2.  */
 
 tree
-build_conditional_expr (ifexp, op1, op2)
-     tree ifexp, op1, op2;
+build_conditional_expr (tree ifexp, tree op1, tree op2)
 {
   tree type1;
   tree type2;
@@ -3384,25 +3441,7 @@ build_conditional_expr (ifexp, op1, op2)
   enum tree_code code2;
   tree result_type = NULL;
   tree orig_op1 = op1, orig_op2 = op2;
-
-  ifexp = truthvalue_conversion (default_conversion (ifexp));
-
-#if 0 /* Produces wrong result if within sizeof.  */
-  /* Don't promote the operands separately if they promote
-     the same way.  Return the unpromoted type and let the combined
-     value get promoted if necessary.  */
-
-  if (TREE_TYPE (op1) == TREE_TYPE (op2)
-      && TREE_CODE (TREE_TYPE (op1)) != ARRAY_TYPE
-      && TREE_CODE (TREE_TYPE (op1)) != ENUMERAL_TYPE
-      && TREE_CODE (TREE_TYPE (op1)) != FUNCTION_TYPE)
-    {
-      if (TREE_CODE (ifexp) == INTEGER_CST)
-       return pedantic_non_lvalue (integer_zerop (ifexp) ? op2 : op1);
-
-      return fold (build (COND_EXPR, TREE_TYPE (op1), ifexp, op1, op2));
-    }
-#endif
+  bool objc_ok;
 
   /* Promote both alternatives.  */
 
@@ -3420,7 +3459,17 @@ build_conditional_expr (ifexp, op1, op2)
   code1 = TREE_CODE (type1);
   type2 = TREE_TYPE (op2);
   code2 = TREE_CODE (type2);
-      
+
+  /* C90 does not permit non-lvalue arrays in conditional expressions.
+     In C99 they will be pointers by now.  */
+  if (code1 == ARRAY_TYPE || code2 == ARRAY_TYPE)
+    {
+      error ("non-lvalue array in conditional expression");
+      return error_mark_node;
+    }
+
+  objc_ok = objc_compare_types (type1, type2, -3, NULL_TREE);
+
   /* Quickly detect the usual case where op1 and op2 have the same type
      after promotion.  */
   if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))
@@ -3431,81 +3480,90 @@ build_conditional_expr (ifexp, op1, op2)
        result_type = TYPE_MAIN_VARIANT (type1);
     }
   else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE
-            || code1 == COMPLEX_TYPE)
-           && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
-               || code2 == COMPLEX_TYPE))
+           || code1 == COMPLEX_TYPE)
+          && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
+              || code2 == COMPLEX_TYPE))
     {
-      result_type = common_type (type1, type2);
+      result_type = c_common_type (type1, type2);
 
       /* If -Wsign-compare, warn here if type1 and type2 have
         different signedness.  We'll promote the signed to unsigned
         and later code won't know it used to be different.
         Do this check on the original types, so that explicit casts
         will be considered, but default promotions won't.  */
-      if ((warn_sign_compare < 0 ? extra_warnings : warn_sign_compare)
-         && !skip_evaluation)
+      if (warn_sign_compare && !skip_evaluation)
        {
-         int unsigned_op1 = TREE_UNSIGNED (TREE_TYPE (orig_op1));
-         int unsigned_op2 = TREE_UNSIGNED (TREE_TYPE (orig_op2));
+         int unsigned_op1 = TYPE_UNSIGNED (TREE_TYPE (orig_op1));
+         int unsigned_op2 = TYPE_UNSIGNED (TREE_TYPE (orig_op2));
 
          if (unsigned_op1 ^ unsigned_op2)
            {
+             bool ovf;
+
              /* Do not warn if the result type is signed, since the
                 signed type will only be chosen if it can represent
                 all the values of the unsigned type.  */
-             if (! TREE_UNSIGNED (result_type))
+             if (!TYPE_UNSIGNED (result_type))
                /* OK */;
              /* Do not warn if the signed quantity is an unsuffixed
                 integer literal (or some static constant expression
                 involving such literals) and it is non-negative.  */
-             else if ((unsigned_op2 && tree_expr_nonnegative_p (op1))
-                      || (unsigned_op1 && tree_expr_nonnegative_p (op2)))
+             else if ((unsigned_op2
+                       && tree_expr_nonnegative_warnv_p (op1, &ovf))
+                      || (unsigned_op1
+                          && tree_expr_nonnegative_warnv_p (op2, &ovf)))
                /* OK */;
              else
-               warning ("signed and unsigned type in conditional expression");
+               warning (OPT_Wsign_compare, "signed and unsigned type in conditional expression");
            }
        }
     }
   else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
     {
-      if (pedantic && (code1 != VOID_TYPE || code2 != VOID_TYPE))
-       pedwarn ("ISO C forbids conditional expr with only one void side");
+      if (code1 != VOID_TYPE || code2 != VOID_TYPE)
+       pedwarn (input_location, OPT_pedantic, 
+                "ISO C forbids conditional expr with only one void side");
       result_type = void_type_node;
     }
   else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
     {
       if (comp_target_types (type1, type2))
-       result_type = common_type (type1, type2);
-      else if (integer_zerop (op1) && TREE_TYPE (type1) == void_type_node
-              && TREE_CODE (orig_op1) != NOP_EXPR)
+       result_type = common_pointer_type (type1, type2);
+      else if (null_pointer_constant_p (orig_op1))
        result_type = qualify_type (type2, type1);
-      else if (integer_zerop (op2) && TREE_TYPE (type2) == void_type_node
-              && TREE_CODE (orig_op2) != NOP_EXPR)
+      else if (null_pointer_constant_p (orig_op2))
        result_type = qualify_type (type1, type2);
       else if (VOID_TYPE_P (TREE_TYPE (type1)))
        {
-         if (pedantic && TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
-           pedwarn ("ISO C forbids conditional expr between `void *' and function pointer");
+         if (TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
+           pedwarn (input_location, OPT_pedantic, 
+                    "ISO C forbids conditional expr between "
+                    "%<void *%> and function pointer");
          result_type = build_pointer_type (qualify_type (TREE_TYPE (type1),
                                                          TREE_TYPE (type2)));
        }
       else if (VOID_TYPE_P (TREE_TYPE (type2)))
        {
-         if (pedantic && TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)
-           pedwarn ("ISO C forbids conditional expr between `void *' and function pointer");
+         if (TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)
+           pedwarn (input_location, OPT_pedantic, 
+                    "ISO C forbids conditional expr between "
+                    "%<void *%> and function pointer");
          result_type = build_pointer_type (qualify_type (TREE_TYPE (type2),
                                                          TREE_TYPE (type1)));
        }
       else
        {
-         pedwarn ("pointer type mismatch in conditional expression");
+         if (!objc_ok)
+           pedwarn (input_location, 0, 
+                    "pointer type mismatch in conditional expression");
          result_type = build_pointer_type (void_type_node);
        }
     }
   else if (code1 == POINTER_TYPE && code2 == INTEGER_TYPE)
     {
-      if (! integer_zerop (op2))
-       pedwarn ("pointer/integer type mismatch in conditional expression");
+      if (!null_pointer_constant_p (orig_op2))
+       pedwarn (input_location, 0, 
+                "pointer/integer type mismatch in conditional expression");
       else
        {
          op2 = null_pointer_node;
@@ -3514,8 +3572,9 @@ build_conditional_expr (ifexp, op1, op2)
     }
   else if (code2 == POINTER_TYPE && code1 == INTEGER_TYPE)
     {
-      if (!integer_zerop (op1))
-       pedwarn ("pointer/integer type mismatch in conditional expression");
+      if (!null_pointer_constant_p (orig_op1))
+       pedwarn (input_location, 0, 
+                "pointer/integer type mismatch in conditional expression");
       else
        {
          op1 = null_pointer_node;
@@ -3544,68 +3603,34 @@ build_conditional_expr (ifexp, op1, op2)
     op1 = convert_and_check (result_type, op1);
   if (result_type != TREE_TYPE (op2))
     op2 = convert_and_check (result_type, op2);
-    
-  if (TREE_CODE (ifexp) == INTEGER_CST)
-    return pedantic_non_lvalue (integer_zerop (ifexp) ? op2 : op1);
 
-  return fold (build (COND_EXPR, result_type, ifexp, op1, op2));
+  return fold_build3 (COND_EXPR, result_type, ifexp, op1, op2);
 }
 \f
-/* Given a list of expressions, return a compound expression
-   that performs them all and returns the value of the last of them.  */
+/* Return a compound expression that performs two expressions and
+   returns the value of the second of them.  */
 
 tree
-build_compound_expr (list)
-     tree list;
-{
-  return internal_build_compound_expr (list, TRUE);
-}
-
-static tree
-internal_build_compound_expr (list, first_p)
-     tree list;
-     int first_p;
+build_compound_expr (tree expr1, tree expr2)
 {
-  tree rest;
-
-  if (TREE_CHAIN (list) == 0)
-    {
-      /* Convert arrays and functions to pointers when there
-        really is a comma operator.  */
-      if (!first_p)
-       TREE_VALUE (list)
-         = default_function_array_conversion (TREE_VALUE (list));
-
-#if 0 /* If something inside inhibited lvalueness, we should not override.  */
-      /* Consider (x, y+0), which is not an lvalue since y+0 is not.  */
-
-      /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
-      if (TREE_CODE (list) == NON_LVALUE_EXPR)
-       list = TREE_OPERAND (list, 0);
-#endif
-
-      /* Don't let (0, 0) be null pointer constant.  */
-      if (!first_p && integer_zerop (TREE_VALUE (list)))
-       return non_lvalue (TREE_VALUE (list));
-      return TREE_VALUE (list);
-    }
-
-  rest = internal_build_compound_expr (TREE_CHAIN (list), FALSE);
-
-  if (! TREE_SIDE_EFFECTS (TREE_VALUE (list)))
+  if (!TREE_SIDE_EFFECTS (expr1))
     {
       /* The left-hand operand of a comma expression is like an expression
-         statement: with -W or -Wunused, we should warn if it doesn't have
+        statement: with -Wunused, we should warn if it doesn't have
         any side-effects, unless it was explicitly cast to (void).  */
-      if ((extra_warnings || warn_unused_value)
-           && ! (TREE_CODE (TREE_VALUE (list)) == CONVERT_EXPR
-                && VOID_TYPE_P (TREE_TYPE (TREE_VALUE (list)))))
-        warning ("left-hand operand of comma expression has no effect");
-
-      /* When pedantic, a compound expression can be neither an lvalue
-         nor an integer constant expression.  */
-      if (! pedantic)
-        return rest;
+      if (warn_unused_value)
+       {
+         if (VOID_TYPE_P (TREE_TYPE (expr1))
+             && CONVERT_EXPR_P (expr1))
+           ; /* (void) a, b */
+         else if (VOID_TYPE_P (TREE_TYPE (expr1))
+                  && TREE_CODE (expr1) == COMPOUND_EXPR
+                  && CONVERT_EXPR_P (TREE_OPERAND (expr1, 1)))
+           ; /* (void) a, (void) b, c */
+         else
+           warning (OPT_Wunused_value, 
+                    "left-hand operand of comma expression has no effect");
+       }
     }
 
   /* With -Wunused, we should also warn if the left-hand operand does have
@@ -3613,29 +3638,31 @@ internal_build_compound_expr (list, first_p)
      `foo() + bar(), baz()' the result of the `+' operator is not used,
      so we should issue a warning.  */
   else if (warn_unused_value)
-    warn_if_unused_value (TREE_VALUE (list));
+    warn_if_unused_value (expr1, input_location);
+
+  if (expr2 == error_mark_node)
+    return error_mark_node;
 
-  return build (COMPOUND_EXPR, TREE_TYPE (rest), TREE_VALUE (list), rest);
+  return build2 (COMPOUND_EXPR, TREE_TYPE (expr2), expr1, expr2);
 }
 
 /* Build an expression representing a cast to type TYPE of expression EXPR.  */
 
 tree
-build_c_cast (type, expr)
-     tree type;
-     tree expr;
+build_c_cast (tree type, tree expr)
 {
   tree value = expr;
-  
+
   if (type == error_mark_node || expr == error_mark_node)
     return error_mark_node;
-  type = TYPE_MAIN_VARIANT (type);
 
-#if 0
-  /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
-  if (TREE_CODE (value) == NON_LVALUE_EXPR)
-    value = TREE_OPERAND (value, 0);
-#endif
+  /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
+     only in <protocol> qualifications.  But when constructing cast expressions,
+     the protocols do matter and must be kept around.  */
+  if (objc_is_object_ptr (type) && objc_is_object_ptr (TREE_TYPE (expr)))
+    return build1 (NOP_EXPR, type, expr);
+
+  type = TYPE_MAIN_VARIANT (type);
 
   if (TREE_CODE (type) == ARRAY_TYPE)
     {
@@ -3649,44 +3676,39 @@ build_c_cast (type, expr)
       return error_mark_node;
     }
 
+  if (!VOID_TYPE_P (type))
+    {
+      value = require_complete_type (value);
+      if (value == error_mark_node)
+       return error_mark_node;
+    }
+
   if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
     {
-      if (pedantic)
-       {
-         if (TREE_CODE (type) == RECORD_TYPE
-             || TREE_CODE (type) == UNION_TYPE)
-           pedwarn ("ISO C forbids casting nonscalar to the same type");
-       }
+      if (TREE_CODE (type) == RECORD_TYPE
+         || TREE_CODE (type) == UNION_TYPE)
+       pedwarn (input_location, OPT_pedantic, 
+                "ISO C forbids casting nonscalar to the same type");
     }
   else if (TREE_CODE (type) == UNION_TYPE)
     {
       tree field;
-      value = default_function_array_conversion (value);
 
       for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
-       if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
-                      TYPE_MAIN_VARIANT (TREE_TYPE (value))))
+       if (TREE_TYPE (field) != error_mark_node
+           && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
+                         TYPE_MAIN_VARIANT (TREE_TYPE (value))))
          break;
 
       if (field)
        {
-         const char *name;
          tree t;
 
-         if (pedantic)
-           pedwarn ("ISO C forbids casts to union type");
-         if (TYPE_NAME (type) != 0)
-           {
-             if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
-               name = IDENTIFIER_POINTER (TYPE_NAME (type));
-             else
-               name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
-           }
-         else
-           name = "";
-         t = digest_init (type, build (CONSTRUCTOR, type, NULL_TREE,
-                                       build_tree_list (field, value)),
-                          0, 0);
+         pedwarn (input_location, OPT_pedantic,
+                  "ISO C forbids casts to union type");
+         t = digest_init (type,
+                          build_constructor_single (type, field, value),
+                          true, 0);
          TREE_CONSTANT (t) = TREE_CONSTANT (value);
          return t;
        }
@@ -3697,14 +3719,9 @@ build_c_cast (type, expr)
     {
       tree otype, ovalue;
 
-      /* If casting to void, avoid the error that would come
-        from default_conversion in the case of a non-lvalue array.  */
       if (type == void_type_node)
        return build1 (CONVERT_EXPR, type, value);
 
-      /* Convert functions and arrays to pointers,
-        but don't convert any other types.  */
-      value = default_function_array_conversion (value);
       otype = TREE_TYPE (value);
 
       /* Optionally warn about potentially worrisome casts.  */
@@ -3741,16 +3758,16 @@ build_c_cast (type, expr)
                 && TREE_CODE (in_otype) == POINTER_TYPE);
 
          if (added)
-           warning ("cast adds new qualifiers to function type");
+           warning (OPT_Wcast_qual, "cast adds new qualifiers to function type");
 
          if (discarded)
            /* There are qualifiers present in IN_OTYPE that are not
               present in IN_TYPE.  */
-           warning ("cast discards qualifiers from pointer target type");
+           warning (OPT_Wcast_qual, "cast discards qualifiers from pointer target type");
        }
 
       /* Warn about possible alignment problems.  */
-      if (STRICT_ALIGNMENT && warn_cast_align
+      if (STRICT_ALIGNMENT
          && TREE_CODE (type) == POINTER_TYPE
          && TREE_CODE (otype) == POINTER_TYPE
          && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
@@ -3761,25 +3778,55 @@ build_c_cast (type, expr)
                || TREE_CODE (TREE_TYPE (otype)) == RECORD_TYPE)
               && TYPE_MODE (TREE_TYPE (otype)) == VOIDmode)
          && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype)))
-       warning ("cast increases required alignment of target type");
+       warning (OPT_Wcast_align,
+                "cast increases required alignment of target type");
 
       if (TREE_CODE (type) == INTEGER_TYPE
          && TREE_CODE (otype) == POINTER_TYPE
-         && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
-         && !TREE_CONSTANT (value))
-       warning ("cast from pointer to integer of different size");
-
-      if (warn_bad_function_cast
-         && TREE_CODE (value) == CALL_EXPR
+         && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
+      /* Unlike conversion of integers to pointers, where the
+         warning is disabled for converting constants because
+         of cases such as SIG_*, warn about converting constant
+         pointers to integers. In some cases it may cause unwanted
+         sign extension, and a warning is appropriate.  */
+       warning (OPT_Wpointer_to_int_cast,
+                "cast from pointer to integer of different size");
+
+      if (TREE_CODE (value) == CALL_EXPR
          && TREE_CODE (type) != TREE_CODE (otype))
-       warning ("cast does not match function type");
+       warning (OPT_Wbad_function_cast, "cast from function call of type %qT "
+                "to non-matching type %qT", otype, type);
 
       if (TREE_CODE (type) == POINTER_TYPE
          && TREE_CODE (otype) == INTEGER_TYPE
          && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
          /* Don't warn about converting any constant.  */
          && !TREE_CONSTANT (value))
-       warning ("cast to pointer from integer of different size");
+       warning (OPT_Wint_to_pointer_cast, "cast to pointer from integer "
+                "of different size");
+
+      if (warn_strict_aliasing <= 2)
+        strict_aliasing_warning (otype, type, expr);
+
+      /* If pedantic, warn for conversions between function and object
+        pointer types, except for converting a null pointer constant
+        to function pointer type.  */
+      if (pedantic
+         && TREE_CODE (type) == POINTER_TYPE
+         && TREE_CODE (otype) == POINTER_TYPE
+         && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
+         && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
+       pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+                "conversion of function pointer to object pointer type");
+
+      if (pedantic
+         && TREE_CODE (type) == POINTER_TYPE
+         && TREE_CODE (otype) == POINTER_TYPE
+         && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
+         && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
+         && !null_pointer_constant_p (value))
+       pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+                "conversion of object pointer to function pointer type");
 
       ovalue = value;
       value = convert (type, value);
@@ -3787,19 +3834,25 @@ build_c_cast (type, expr)
       /* Ignore any integer overflow caused by the cast.  */
       if (TREE_CODE (value) == INTEGER_CST)
        {
-         TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
-         TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
+         if (CONSTANT_CLASS_P (ovalue) && TREE_OVERFLOW (ovalue))
+           {
+             if (!TREE_OVERFLOW (value))
+               {
+                 /* Avoid clobbering a shared constant.  */
+                 value = copy_node (value);
+                 TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
+               }
+           }
+         else if (TREE_OVERFLOW (value))
+           /* Reset VALUE's overflow flags, ensuring constant sharing.  */
+           value = build_int_cst_wide (TREE_TYPE (value),
+                                       TREE_INT_CST_LOW (value),
+                                       TREE_INT_CST_HIGH (value));
        }
     }
 
-  /* Pedantically, don't let (void *) (FOO *) 0 be a null pointer constant.  */
-  if (pedantic && TREE_CODE (value) == INTEGER_CST
-      && TREE_CODE (expr) == INTEGER_CST
-      && TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE)
-    value = non_lvalue (value);
-
-  /* If pedantic, don't let a cast be an lvalue.  */
-  if (value == expr && pedantic)
+  /* Don't let a cast be an lvalue.  */
+  if (value == expr)
     value = non_lvalue (value);
 
   return value;
@@ -3807,31 +3860,31 @@ build_c_cast (type, expr)
 
 /* Interpret a cast of expression EXPR to type TYPE.  */
 tree
-c_cast_expr (type, expr)
-     tree type, expr;
+c_cast_expr (struct c_type_name *type_name, tree expr)
 {
+  tree type;
   int saved_wsp = warn_strict_prototypes;
 
   /* This avoids warnings about unprototyped casts on
      integers.  E.g. "#define SIG_DFL (void(*)())0".  */
   if (TREE_CODE (expr) == INTEGER_CST)
     warn_strict_prototypes = 0;
-  type = groktypename (type);
+  type = groktypename (type_name);
   warn_strict_prototypes = saved_wsp;
 
   return build_c_cast (type, expr);
 }
-
 \f
 /* Build an assignment expression of lvalue LHS from value RHS.
    MODIFYCODE is the code for a binary operator that we use
    to combine the old value of LHS with RHS to get the new value.
-   Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.  */
+   Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.
+
+   LOCATION is the location of the MODIFYCODE operator.  */
 
 tree
-build_modify_expr (lhs, modifycode, rhs)
-     tree lhs, rhs;
-     enum tree_code modifycode;
+build_modify_expr (location_t location,
+                  tree lhs, enum tree_code modifycode, tree rhs)
 {
   tree result;
   tree newrhs;
@@ -3845,52 +3898,12 @@ build_modify_expr (lhs, modifycode, rhs)
   if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
     return error_mark_node;
 
-  /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
-  /* Do not use STRIP_NOPS here.  We do not want an enumerator
-     whose value is 0 to count as a null pointer constant.  */
-  if (TREE_CODE (rhs) == NON_LVALUE_EXPR)
-    rhs = TREE_OPERAND (rhs, 0);
-
-  newrhs = rhs;
+  if (!lvalue_or_else (lhs, lv_assign))
+    return error_mark_node;
 
-  /* Handle control structure constructs used as "lvalues".  */
+  STRIP_TYPE_NOPS (rhs);
 
-  switch (TREE_CODE (lhs))
-    {
-      /* Handle (a, b) used as an "lvalue".  */
-    case COMPOUND_EXPR:
-      pedantic_lvalue_warning (COMPOUND_EXPR);
-      newrhs = build_modify_expr (TREE_OPERAND (lhs, 1), modifycode, rhs);
-      if (TREE_CODE (newrhs) == ERROR_MARK)
-       return error_mark_node;
-      return build (COMPOUND_EXPR, lhstype,
-                   TREE_OPERAND (lhs, 0), newrhs);
-      /* Handle (a ? b : c) used as an "lvalue".  */
-    case COND_EXPR:
-      pedantic_lvalue_warning (COND_EXPR);
-      rhs = save_expr (rhs);
-      {
-       /* Produce (a ? (b = rhs) : (c = rhs))
-          except that the RHS goes through a save-expr
-          so the code to compute it is only emitted once.  */
-       tree cond
-         = build_conditional_expr (TREE_OPERAND (lhs, 0),
-                                   build_modify_expr (TREE_OPERAND (lhs, 1),
-                                                      modifycode, rhs),
-                                   build_modify_expr (TREE_OPERAND (lhs, 2),
-                                                      modifycode, rhs));
-       if (TREE_CODE (cond) == ERROR_MARK)
-         return cond;
-       /* Make sure the code to compute the rhs comes out
-          before the split.  */
-       return build (COMPOUND_EXPR, TREE_TYPE (lhs),
-                     /* But cast it to void to avoid an "unused" error.  */
-                     convert (void_type_node, rhs), cond);
-      }
-    default:
-      break;
-    }
+  newrhs = rhs;
 
   /* If a binary op has been requested, combine the old LHS value with the RHS
      producing the value we should actually store into the LHS.  */
@@ -3898,55 +3911,20 @@ build_modify_expr (lhs, modifycode, rhs)
   if (modifycode != NOP_EXPR)
     {
       lhs = stabilize_reference (lhs);
-      newrhs = build_binary_op (modifycode, lhs, rhs, 1);
-    }
-
-  /* Handle a cast used as an "lvalue".
-     We have already performed any binary operator using the value as cast.
-     Now convert the result to the cast type of the lhs,
-     and then true type of the lhs and store it there;
-     then convert result back to the cast type to be the value
-     of the assignment.  */
-
-  switch (TREE_CODE (lhs))
-    {
-    case NOP_EXPR:
-    case CONVERT_EXPR:
-    case FLOAT_EXPR:
-    case FIX_TRUNC_EXPR:
-    case FIX_FLOOR_EXPR:
-    case FIX_ROUND_EXPR:
-    case FIX_CEIL_EXPR:
-      newrhs = default_function_array_conversion (newrhs);
-      {
-       tree inner_lhs = TREE_OPERAND (lhs, 0);
-       tree result;
-       result = build_modify_expr (inner_lhs, NOP_EXPR,
-                                   convert (TREE_TYPE (inner_lhs),
-                                            convert (lhstype, newrhs)));
-       if (TREE_CODE (result) == ERROR_MARK)
-         return result;
-       pedantic_lvalue_warning (CONVERT_EXPR);
-       return convert (TREE_TYPE (lhs), result);
-      }
-      
-    default:
-      break;
+      newrhs = build_binary_op (location,
+                               modifycode, lhs, rhs, 1);
     }
 
-  /* Now we have handled acceptable kinds of LHS that are not truly lvalues.
-     Reject anything strange now.  */
-
-  if (!lvalue_or_else (lhs, "invalid lvalue in assignment"))
-    return error_mark_node;
-
-  /* Warn about storing in something that is `const'.  */
+  /* Give an error for storing in something that is 'const'.  */
 
   if (TREE_READONLY (lhs) || TYPE_READONLY (lhstype)
       || ((TREE_CODE (lhstype) == RECORD_TYPE
           || TREE_CODE (lhstype) == UNION_TYPE)
          && C_TYPE_FIELDS_READONLY (lhstype)))
-    readonly_warning (lhs, "assignment");
+    {
+      readonly_error (lhs, lv_assign);
+      return error_mark_node;
+    }
 
   /* If storing into a structure or union member,
      it has probably been given type `int'.
@@ -3971,15 +3949,27 @@ build_modify_expr (lhs, modifycode, rhs)
 
   /* Convert new value to destination type.  */
 
-  newrhs = convert_for_assignment (lhstype, newrhs, _("assignment"),
+  newrhs = convert_for_assignment (lhstype, newrhs, ic_assign,
                                   NULL_TREE, NULL_TREE, 0);
   if (TREE_CODE (newrhs) == ERROR_MARK)
     return error_mark_node;
 
-  /* Scan operands */
+  /* Emit ObjC write barrier, if necessary.  */
+  if (c_dialect_objc () && flag_objc_gc)
+    {
+      result = objc_generate_write_barrier (lhs, modifycode, newrhs);
+      if (result)
+       {
+         protected_set_expr_location (result, location);
+         return result;
+       }
+    }
+
+  /* Scan operands.  */
 
-  result = build (MODIFY_EXPR, lhstype, lhs, newrhs);
+  result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);
   TREE_SIDE_EFFECTS (result) = 1;
+  protected_set_expr_location (result, location);
 
   /* If we got the LHS in a different type for storing in,
      convert the result back to the nominal type of LHS
@@ -3988,8 +3978,11 @@ build_modify_expr (lhs, modifycode, rhs)
 
   if (olhstype == TREE_TYPE (result))
     return result;
-  return convert_for_assignment (olhstype, result, _("assignment"),
-                                NULL_TREE, NULL_TREE, 0);
+
+  result = convert_for_assignment (olhstype, result, ic_assign,
+                                  NULL_TREE, NULL_TREE, 0);
+  protected_set_expr_location (result, location);
+  return result;
 }
 \f
 /* Convert value RHS to type TYPE as preparation for an assignment
@@ -3997,35 +3990,73 @@ build_modify_expr (lhs, modifycode, rhs)
    The real work of conversion is done by `convert'.
    The purpose of this function is to generate error messages
    for assignments that are not allowed in C.
-   ERRTYPE is a string to use in error messages:
-   "assignment", "return", etc.  If it is null, this is parameter passing
-   for a function call (and different error messages are output).
+   ERRTYPE says whether it is argument passing, assignment,
+   initialization or return.
 
-   FUNNAME is the name of the function being called,
-   as an IDENTIFIER_NODE, or null.
+   FUNCTION is a tree for the function being called.
    PARMNUM is the number of the argument, for printing in error messages.  */
 
 static tree
-convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
-     tree type, rhs;
-     const char *errtype;
-     tree fundecl, funname;
-     int parmnum;
+convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
+                       tree fundecl, tree function, int parmnum)
 {
   enum tree_code codel = TREE_CODE (type);
   tree rhstype;
   enum tree_code coder;
+  tree rname = NULL_TREE;
+  bool objc_ok = false;
+
+  if (errtype == ic_argpass)
+    {
+      tree selector;
+      /* Change pointer to function to the function itself for
+        diagnostics.  */
+      if (TREE_CODE (function) == ADDR_EXPR
+         && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
+       function = TREE_OPERAND (function, 0);
+
+      /* Handle an ObjC selector specially for diagnostics.  */
+      selector = objc_message_selector ();
+      rname = function;
+      if (selector && parmnum > 2)
+       {
+         rname = selector;
+         parmnum -= 2;
+       }
+    }
 
-  /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
-  /* Do not use STRIP_NOPS here.  We do not want an enumerator
-     whose value is 0 to count as a null pointer constant.  */
-  if (TREE_CODE (rhs) == NON_LVALUE_EXPR)
-    rhs = TREE_OPERAND (rhs, 0);
-
-  if (TREE_CODE (TREE_TYPE (rhs)) == ARRAY_TYPE
-      || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE)
-    rhs = default_conversion (rhs);
-  else if (optimize && TREE_CODE (rhs) == VAR_DECL)
+  /* This macro is used to emit diagnostics to ensure that all format
+     strings are complete sentences, visible to gettext and checked at
+     compile time.  */
+#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE)               \
+  do {                                                                   \
+    switch (errtype)                                                     \
+      {                                                                  \
+      case ic_argpass:                                                   \
+        if (pedwarn (LOCATION, OPT, AR, parmnum, rname))                 \
+          inform ((fundecl && !DECL_IS_BUILTIN (fundecl))                \
+                 ? DECL_SOURCE_LOCATION (fundecl) : LOCATION,           \
+                  "expected %qT but argument is of type %qT",            \
+                  type, rhstype);                                        \
+        break;                                                           \
+      case ic_assign:                                                    \
+        pedwarn (LOCATION, OPT, AS);                                     \
+        break;                                                           \
+      case ic_init:                                                      \
+        pedwarn (LOCATION, OPT, IN);                                     \
+        break;                                                           \
+      case ic_return:                                                    \
+        pedwarn (LOCATION, OPT, RE);                                     \
+        break;                                                           \
+      default:                                                           \
+        gcc_unreachable ();                                              \
+      }                                                                  \
+  } while (0)
+
+  STRIP_TYPE_NOPS (rhs);
+
+  if (optimize && TREE_CODE (rhs) == VAR_DECL
+          && TREE_CODE (TREE_TYPE (rhs)) != ARRAY_TYPE)
     rhs = decl_constant_value_for_broken_optimization (rhs);
 
   rhstype = TREE_TYPE (rhs);
@@ -4034,27 +4065,60 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
   if (coder == ERROR_MARK)
     return error_mark_node;
 
-  if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
+  if (c_dialect_objc ())
     {
-      overflow_warning (rhs);
-      /* Check for Objective-C protocols.  This will issue a warning if
-        there are protocol violations.  No need to use the return value.  */
-      maybe_objc_comptypes (type, rhstype, 0);
-      return rhs;
+      int parmno;
+
+      switch (errtype)
+       {
+       case ic_return:
+         parmno = 0;
+         break;
+
+       case ic_assign:
+         parmno = -1;
+         break;
+
+       case ic_init:
+         parmno = -2;
+         break;
+
+       default:
+         parmno = parmnum;
+         break;
+       }
+
+      objc_ok = objc_compare_types (type, rhstype, parmno, rname);
     }
 
-  if (coder == VOID_TYPE)
+  if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
+    return rhs;
+
+  if (coder == VOID_TYPE)
     {
+      /* Except for passing an argument to an unprototyped function,
+        this is a constraint violation.  When passing an argument to
+        an unprototyped function, it is compile-time undefined;
+        making it a constraint in that case was rejected in
+        DR#252.  */
       error ("void value not ignored as it ought to be");
       return error_mark_node;
     }
-  /* A type converts to a reference to it.  
+  rhs = require_complete_type (rhs);
+  if (rhs == error_mark_node)
+    return error_mark_node;
+  /* A type converts to a reference to it.
      This code doesn't fully support references, it's just for the
      special case of va_start and va_copy.  */
   if (codel == REFERENCE_TYPE
       && comptypes (TREE_TYPE (type), TREE_TYPE (rhs)) == 1)
     {
-      if (mark_addressable (rhs) == 0)
+      if (!lvalue_p (rhs))
+       {
+         error ("cannot pass rvalue to reference parameter");
+         return error_mark_node;
+       }
+      if (!c_mark_addressable (rhs))
        return error_mark_node;
       rhs = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (rhs)), rhs);
 
@@ -4069,26 +4133,37 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
       rhs = build1 (NOP_EXPR, type, rhs);
       return rhs;
     }
+  /* Some types can interconvert without explicit casts.  */
+  else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
+          && vector_types_convertible_p (type, TREE_TYPE (rhs), true))
+    return convert (type, rhs);
   /* Arithmetic types all interconvert, and enum is treated like int.  */
-  else if ((codel == INTEGER_TYPE || codel == REAL_TYPE 
+  else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
+           || codel == FIXED_POINT_TYPE
            || codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
            || codel == BOOLEAN_TYPE)
-          && (coder == INTEGER_TYPE || coder == REAL_TYPE 
+          && (coder == INTEGER_TYPE || coder == REAL_TYPE
+              || coder == FIXED_POINT_TYPE
               || coder == ENUMERAL_TYPE || coder == COMPLEX_TYPE
               || coder == BOOLEAN_TYPE))
     return convert_and_check (type, rhs);
 
+  /* Aggregates in different TUs might need conversion.  */
+  if ((codel == RECORD_TYPE || codel == UNION_TYPE)
+      && codel == coder
+      && comptypes (type, rhstype))
+    return convert_and_check (type, rhs);
+
   /* Conversion to a transparent union from its member types.
      This applies only to function arguments.  */
-  else if (codel == UNION_TYPE && TYPE_TRANSPARENT_UNION (type) && ! errtype)
+  if (codel == UNION_TYPE && TYPE_TRANSPARENT_UNION (type)
+      && errtype == ic_argpass)
     {
-      tree memb_types;
-      tree marginal_memb_type = 0;
+      tree memb, marginal_memb = NULL_TREE;
 
-      for (memb_types = TYPE_FIELDS (type); memb_types;
-          memb_types = TREE_CHAIN (memb_types))
+      for (memb = TYPE_FIELDS (type); memb ; memb = TREE_CHAIN (memb))
        {
-         tree memb_type = TREE_TYPE (memb_types);
+         tree memb_type = TREE_TYPE (memb);
 
          if (comptypes (TYPE_MAIN_VARIANT (memb_type),
                         TYPE_MAIN_VARIANT (rhstype)))
@@ -4120,28 +4195,26 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
                    break;
 
                  /* Keep looking for a better type, but remember this one.  */
-                 if (! marginal_memb_type)
-                   marginal_memb_type = memb_type;
+                 if (!marginal_memb)
+                   marginal_memb = memb;
                }
            }
 
          /* Can convert integer zero to any pointer type.  */
-         if (integer_zerop (rhs)
-             || (TREE_CODE (rhs) == NOP_EXPR
-                 && integer_zerop (TREE_OPERAND (rhs, 0))))
+         if (null_pointer_constant_p (rhs))
            {
              rhs = null_pointer_node;
              break;
            }
        }
 
-      if (memb_types || marginal_memb_type)
+      if (memb || marginal_memb)
        {
-         if (! memb_types)
+         if (!memb)
            {
              /* We have only a marginally acceptable member type;
                 it needs a warning.  */
-             tree ttl = TREE_TYPE (marginal_memb_type);
+             tree ttl = TREE_TYPE (TREE_TYPE (marginal_memb));
              tree ttr = TREE_TYPE (rhstype);
 
              /* Const and volatile mean something different for function
@@ -4155,64 +4228,166 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
                     function where an ordinary one is wanted, but not
                     vice-versa.  */
                  if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
-                   warn_for_assignment ("%s makes qualified function pointer from unqualified",
-                                        errtype, funname, parmnum);
+                   WARN_FOR_ASSIGNMENT (input_location, 0,
+                                        G_("passing argument %d of %qE "
+                                           "makes qualified function "
+                                           "pointer from unqualified"),
+                                        G_("assignment makes qualified "
+                                           "function pointer from "
+                                           "unqualified"),
+                                        G_("initialization makes qualified "
+                                           "function pointer from "
+                                           "unqualified"),
+                                        G_("return makes qualified function "
+                                           "pointer from unqualified"));
                }
              else if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl))
-               warn_for_assignment ("%s discards qualifiers from pointer target type",
-                                    errtype, funname,
-                                    parmnum);
+               WARN_FOR_ASSIGNMENT (input_location, 0,
+                                    G_("passing argument %d of %qE discards "
+                                       "qualifiers from pointer target type"),
+                                    G_("assignment discards qualifiers "
+                                       "from pointer target type"),
+                                    G_("initialization discards qualifiers "
+                                       "from pointer target type"),
+                                    G_("return discards qualifiers from "
+                                       "pointer target type"));
+
+             memb = marginal_memb;
            }
-         
-         if (pedantic && ! DECL_IN_SYSTEM_HEADER (fundecl))
-           pedwarn ("ISO C prohibits argument conversion to union type");
 
-         return build1 (NOP_EXPR, type, rhs);
+         if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
+           pedwarn (input_location, OPT_pedantic, 
+                    "ISO C prohibits argument conversion to union type");
+
+         rhs = fold_convert (TREE_TYPE (memb), rhs);
+         return build_constructor_single (type, memb, rhs);
        }
     }
 
   /* Conversions among pointers */
   else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
-          && (coder == POINTER_TYPE || coder == REFERENCE_TYPE))
+          && (coder == codel))
     {
       tree ttl = TREE_TYPE (type);
       tree ttr = TREE_TYPE (rhstype);
+      tree mvl = ttl;
+      tree mvr = ttr;
+      bool is_opaque_pointer;
+      int target_cmp = 0;   /* Cache comp_target_types () result.  */
+
+      if (TREE_CODE (mvl) != ARRAY_TYPE)
+       mvl = TYPE_MAIN_VARIANT (mvl);
+      if (TREE_CODE (mvr) != ARRAY_TYPE)
+       mvr = TYPE_MAIN_VARIANT (mvr);
+      /* Opaque pointers are treated like void pointers.  */
+      is_opaque_pointer = vector_targets_convertible_p (ttl, ttr);
+
+      /* C++ does not allow the implicit conversion void* -> T*.  However,
+        for the purpose of reducing the number of false positives, we
+        tolerate the special case of
+
+               int *p = NULL;
+
+        where NULL is typically defined in C to be '(void *) 0'.  */
+      if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
+       warning (OPT_Wc___compat, "request for implicit conversion from "
+                "%qT to %qT not permitted in C++", rhstype, type);
+
+      /* Check if the right-hand side has a format attribute but the
+        left-hand side doesn't.  */
+      if (warn_missing_format_attribute
+         && check_missing_format_attribute (type, rhstype))
+       {
+         switch (errtype)
+         {
+         case ic_argpass:
+           warning (OPT_Wmissing_format_attribute,
+                    "argument %d of %qE might be "
+                    "a candidate for a format attribute",
+                    parmnum, rname);
+           break;
+         case ic_assign:
+           warning (OPT_Wmissing_format_attribute,
+                    "assignment left-hand side might be "
+                    "a candidate for a format attribute");
+           break;
+         case ic_init:
+           warning (OPT_Wmissing_format_attribute,
+                    "initialization left-hand side might be "
+                    "a candidate for a format attribute");
+           break;
+         case ic_return:
+           warning (OPT_Wmissing_format_attribute,
+                    "return type might be "
+                    "a candidate for a format attribute");
+           break;
+         default:
+           gcc_unreachable ();
+         }
+       }
 
       /* Any non-function converts to a [const][volatile] void *
         and vice versa; otherwise, targets must be the same.
         Meanwhile, the lhs target must have all the qualifiers of the rhs.  */
       if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
-         || comp_target_types (type, rhstype)
-         || (unsigned_type (TYPE_MAIN_VARIANT (ttl))
-             == unsigned_type (TYPE_MAIN_VARIANT (ttr))))
+         || (target_cmp = comp_target_types (type, rhstype))
+         || is_opaque_pointer
+         || (c_common_unsigned_type (mvl)
+             == c_common_unsigned_type (mvr)))
        {
          if (pedantic
              && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
                  ||
                  (VOID_TYPE_P (ttr)
-                  /* Check TREE_CODE to catch cases like (void *) (char *) 0
-                     which are not ANSI null ptr constants.  */
-                  && (!integer_zerop (rhs) || TREE_CODE (rhs) == NOP_EXPR)
+                  && !null_pointer_constant_p (rhs)
                   && TREE_CODE (ttl) == FUNCTION_TYPE)))
-           warn_for_assignment ("ISO C forbids %s between function pointer and `void *'",
-                                errtype, funname, parmnum);
+           WARN_FOR_ASSIGNMENT (input_location, OPT_pedantic,
+                                G_("ISO C forbids passing argument %d of "
+                                   "%qE between function pointer "
+                                   "and %<void *%>"),
+                                G_("ISO C forbids assignment between "
+                                   "function pointer and %<void *%>"),
+                                G_("ISO C forbids initialization between "
+                                   "function pointer and %<void *%>"),
+                                G_("ISO C forbids return between function "
+                                   "pointer and %<void *%>"));
          /* Const and volatile mean something different for function types,
             so the usual warnings are not appropriate.  */
          else if (TREE_CODE (ttr) != FUNCTION_TYPE
                   && TREE_CODE (ttl) != FUNCTION_TYPE)
            {
              if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl))
-               warn_for_assignment ("%s discards qualifiers from pointer target type",
-                                    errtype, funname, parmnum);
+               {
+                 /* Types differing only by the presence of the 'volatile'
+                    qualifier are acceptable if the 'volatile' has been added
+                    in by the Objective-C EH machinery.  */
+                 if (!objc_type_quals_match (ttl, ttr))
+                   WARN_FOR_ASSIGNMENT (input_location, 0,
+                                        G_("passing argument %d of %qE discards "
+                                           "qualifiers from pointer target type"),
+                                        G_("assignment discards qualifiers "
+                                           "from pointer target type"),
+                                        G_("initialization discards qualifiers "
+                                           "from pointer target type"),
+                                        G_("return discards qualifiers from "
+                                           "pointer target type"));
+               }
              /* If this is not a case of ignoring a mismatch in signedness,
                 no warning.  */
              else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
-                      || comp_target_types (type, rhstype))
+                      || target_cmp)
                ;
              /* If there is a mismatch, do warn.  */
-             else if (pedantic)
-               warn_for_assignment ("pointer targets in %s differ in signedness",
-                                    errtype, funname, parmnum);
+             else if (warn_pointer_sign)
+               WARN_FOR_ASSIGNMENT (input_location, OPT_Wpointer_sign,
+                                    G_("pointer targets in passing argument "
+                                       "%d of %qE differ in signedness"),
+                                    G_("pointer targets in assignment "
+                                       "differ in signedness"),
+                                    G_("pointer targets in initialization "
+                                       "differ in signedness"),
+                                    G_("pointer targets in return differ "
+                                       "in signedness"));
            }
          else if (TREE_CODE (ttl) == FUNCTION_TYPE
                   && TREE_CODE (ttr) == FUNCTION_TYPE)
@@ -4222,133 +4397,98 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
                 it is okay to use a const or volatile function
                 where an ordinary one is wanted, but not vice-versa.  */
              if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
-               warn_for_assignment ("%s makes qualified function pointer from unqualified",
-                                    errtype, funname, parmnum);
+               WARN_FOR_ASSIGNMENT (input_location, 0,
+                                    G_("passing argument %d of %qE makes "
+                                       "qualified function pointer "
+                                       "from unqualified"),
+                                    G_("assignment makes qualified function "
+                                       "pointer from unqualified"),
+                                    G_("initialization makes qualified "
+                                       "function pointer from unqualified"),
+                                    G_("return makes qualified function "
+                                       "pointer from unqualified"));
            }
        }
       else
-       warn_for_assignment ("%s from incompatible pointer type",
-                            errtype, funname, parmnum);
+       /* Avoid warning about the volatile ObjC EH puts on decls.  */
+       if (!objc_ok)
+         WARN_FOR_ASSIGNMENT (input_location, 0,
+                              G_("passing argument %d of %qE from "
+                                 "incompatible pointer type"),
+                              G_("assignment from incompatible pointer type"),
+                              G_("initialization from incompatible "
+                                 "pointer type"),
+                              G_("return from incompatible pointer type"));
+
       return convert (type, rhs);
     }
+  else if (codel == POINTER_TYPE && coder == ARRAY_TYPE)
+    {
+      /* ??? This should not be an error when inlining calls to
+        unprototyped functions.  */
+      error ("invalid use of non-lvalue array");
+      return error_mark_node;
+    }
   else if (codel == POINTER_TYPE && coder == INTEGER_TYPE)
     {
       /* An explicit constant 0 can convert to a pointer,
         or one that results from arithmetic, even including
         a cast to integer type.  */
-      if (! (TREE_CODE (rhs) == INTEGER_CST && integer_zerop (rhs))
-         &&
-         ! (TREE_CODE (rhs) == NOP_EXPR
-            && TREE_CODE (TREE_TYPE (rhs)) == INTEGER_TYPE
-            && TREE_CODE (TREE_OPERAND (rhs, 0)) == INTEGER_CST
-            && integer_zerop (TREE_OPERAND (rhs, 0))))
-       {
-         warn_for_assignment ("%s makes pointer from integer without a cast",
-                              errtype, funname, parmnum);
-         return convert (type, rhs);
-       }
-      return null_pointer_node;
+      if (!null_pointer_constant_p (rhs))
+       WARN_FOR_ASSIGNMENT (input_location, 0,
+                            G_("passing argument %d of %qE makes "
+                               "pointer from integer without a cast"),
+                            G_("assignment makes pointer from integer "
+                               "without a cast"),
+                            G_("initialization makes pointer from "
+                               "integer without a cast"),
+                            G_("return makes pointer from integer "
+                               "without a cast"));
+
+      return convert (type, rhs);
     }
   else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
     {
-      warn_for_assignment ("%s makes integer from pointer without a cast",
-                          errtype, funname, parmnum);
+      WARN_FOR_ASSIGNMENT (input_location, 0,
+                          G_("passing argument %d of %qE makes integer "
+                             "from pointer without a cast"),
+                          G_("assignment makes integer from pointer "
+                             "without a cast"),
+                          G_("initialization makes integer from pointer "
+                             "without a cast"),
+                          G_("return makes integer from pointer "
+                             "without a cast"));
       return convert (type, rhs);
     }
   else if (codel == BOOLEAN_TYPE && coder == POINTER_TYPE)
     return convert (type, rhs);
 
-  if (!errtype)
+  switch (errtype)
     {
-      if (funname)
-       {
-         tree selector = maybe_building_objc_message_expr ();
-         if (selector && parmnum > 2)
-           error ("incompatible type for argument %d of `%s'",
-                  parmnum - 2, IDENTIFIER_POINTER (selector));
-         else
-           error ("incompatible type for argument %d of `%s'",
-                  parmnum, IDENTIFIER_POINTER (funname));
-       }
-      else
-       error ("incompatible type for argument %d of indirect function call",
-              parmnum);
+    case ic_argpass:
+      error ("incompatible type for argument %d of %qE", parmnum, rname);
+      inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
+             ? DECL_SOURCE_LOCATION (fundecl) : input_location,
+             "expected %qT but argument is of type %qT", type, rhstype);
+      break;
+    case ic_assign:
+      error ("incompatible types when assigning to type %qT from type %qT",
+            type, rhstype);
+      break;
+    case ic_init:
+      error ("incompatible types when initializing type %qT using type %qT",
+            type, rhstype);
+      break;
+    case ic_return:
+      error ("incompatible types when returning type %qT but %qT was expected",
+            rhstype, type);
+      break;
+    default:
+      gcc_unreachable ();
     }
-  else
-    error ("incompatible types in %s", errtype);
 
   return error_mark_node;
 }
-
-/* Convert VALUE for assignment into inlined parameter PARM.  */
-
-tree
-c_convert_parm_for_inlining (parm, value, fn)
-     tree parm, value, fn;
-{
-  tree ret, type;
-
-  /* If FN was prototyped, the value has been converted already
-     in convert_arguments.  */
-  if (! value || TYPE_ARG_TYPES (TREE_TYPE (fn)))
-    return value;
-
-  type = TREE_TYPE (parm);
-  ret = convert_for_assignment (type, value, 
-                               (char *) 0 /* arg passing  */, fn,
-                               DECL_NAME (fn), 0);
-  if (PROMOTE_PROTOTYPES
-      && INTEGRAL_TYPE_P (type)
-      && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
-    ret = default_conversion (ret);
-  return ret;
-}
-
-/* Print a warning using MSGID.
-   It gets OPNAME as its one parameter.
-   If OPNAME is null, it is replaced by "passing arg ARGNUM of `FUNCTION'".
-   FUNCTION and ARGNUM are handled specially if we are building an
-   Objective-C selector.  */
-
-static void
-warn_for_assignment (msgid, opname, function, argnum)
-     const char *msgid;
-     const char *opname;
-     tree function;
-     int argnum;
-{
-  if (opname == 0)
-    {
-      tree selector = maybe_building_objc_message_expr ();
-      char * new_opname;
-      
-      if (selector && argnum > 2)
-       {
-         function = selector;
-         argnum -= 2;
-       }
-      if (function)
-       {
-         /* Function name is known; supply it.  */
-         const char *const argstring = _("passing arg %d of `%s'");
-         new_opname = (char *) alloca (IDENTIFIER_LENGTH (function)
-                                       + strlen (argstring) + 1 + 25
-                                       /*%d*/ + 1);
-         sprintf (new_opname, argstring, argnum,
-                  IDENTIFIER_POINTER (function));
-       }
-      else
-       {
-         /* Function name unknown (call through ptr); just give arg number.  */
-         const char *const argnofun = _("passing arg %d of pointer to function");
-         new_opname = (char *) alloca (strlen (argnofun) + 1 + 25 /*%d*/ + 1);
-         sprintf (new_opname, argnofun, argnum);
-       }
-      opname = new_opname;
-    }
-  pedwarn (msgid, opname);
-}
 \f
 /* If VALUE is a compound expr all of whose expressions are constant, then
    return its value.  Otherwise, return error_mark_node.
@@ -4357,9 +4497,7 @@ warn_for_assignment (msgid, opname, function, argnum)
    which is allowed with a warning when -pedantic is specified.  */
 
 static tree
-valid_compound_expr_initializer (value, endtype)
-     tree value;
-     tree endtype;
+valid_compound_expr_initializer (tree value, tree endtype)
 {
   if (TREE_CODE (value) == COMPOUND_EXPR)
     {
@@ -4369,8 +4507,7 @@ valid_compound_expr_initializer (value, endtype)
       return valid_compound_expr_initializer (TREE_OPERAND (value, 1),
                                              endtype);
     }
-  else if (! TREE_CONSTANT (value)
-          && ! initializer_constant_valid_p (value, endtype))
+  else if (!initializer_constant_valid_p (value, endtype))
     return error_mark_node;
   else
     return value;
@@ -4382,8 +4519,7 @@ valid_compound_expr_initializer (value, endtype)
    If the init is invalid, store an ERROR_MARK.  */
 
 void
-store_init_value (decl, init)
-     tree decl, init;
+store_init_value (tree decl, tree init)
 {
   tree value, type;
 
@@ -4395,49 +4531,21 @@ store_init_value (decl, init)
 
   /* Digest the specified initializer into an expression.  */
 
-  value = digest_init (type, init, TREE_STATIC (decl),
-                      TREE_STATIC (decl) || (pedantic && !flag_isoc99));
+  value = digest_init (type, init, true, TREE_STATIC (decl));
 
   /* Store the expression if valid; else report error.  */
 
-#if 0
-  /* Note that this is the only place we can detect the error
-     in a case such as   struct foo bar = (struct foo) { x, y };
-     where there is one initial value which is a constructor expression.  */
-  if (value == error_mark_node)
-    ;
-  else if (TREE_STATIC (decl) && ! TREE_CONSTANT (value))
-    {
-      error ("initializer for static variable is not constant");
-      value = error_mark_node;
-    }
-  else if (TREE_STATIC (decl)
-          && initializer_constant_valid_p (value, TREE_TYPE (value)) == 0)
-    {
-      error ("initializer for static variable uses complicated arithmetic");
-      value = error_mark_node;
-    }
-  else
-    {
-      if (pedantic && TREE_CODE (value) == CONSTRUCTOR)
-       {
-         if (! TREE_CONSTANT (value))
-           pedwarn ("aggregate initializer is not constant");
-         else if (! TREE_STATIC (value))
-           pedwarn ("aggregate initializer uses complicated arithmetic");
-       }
-    }
-#endif
-
-  if (warn_traditional && !in_system_header
-      && AGGREGATE_TYPE_P (TREE_TYPE (decl)) && ! TREE_STATIC (decl))
-    warning ("traditional C rejects automatic aggregate initialization");
+  if (!in_system_header
+      && AGGREGATE_TYPE_P (TREE_TYPE (decl)) && !TREE_STATIC (decl))
+    warning (OPT_Wtraditional, "traditional C rejects automatic "
+            "aggregate initialization");
 
   DECL_INITIAL (decl) = value;
 
   /* ANSI wants warnings about out-of-range constant initializers.  */
   STRIP_TYPE_NOPS (value);
-  constant_expression_warning (value);
+  if (TREE_STATIC (decl)) 
+    constant_expression_warning (value);
 
   /* Check if we need to set array size from compound literal size.  */
   if (TREE_CODE (type) == ARRAY_TYPE
@@ -4446,22 +4554,23 @@ store_init_value (decl, init)
     {
       tree inside_init = init;
 
-      if (TREE_CODE (init) == NON_LVALUE_EXPR)
-       inside_init = TREE_OPERAND (init, 0);
+      STRIP_TYPE_NOPS (inside_init);
       inside_init = fold (inside_init);
 
       if (TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
        {
-         tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
+         tree cldecl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
 
-         if (TYPE_DOMAIN (TREE_TYPE (decl)))
+         if (TYPE_DOMAIN (TREE_TYPE (cldecl)))
            {
              /* For int foo[] = (int [3]){1}; we need to set array size
                 now since later on array initializer will be just the
                 brace enclosed list of the compound literal.  */
-             TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (decl));
+             type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
+             TREE_TYPE (decl) = type;
+             TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl));
              layout_type (type);
-             layout_decl (decl, 0);
+             layout_decl (cldecl, 0);
            }
        }
     }
@@ -4477,7 +4586,7 @@ struct spelling
   int kind;
   union
     {
-      int i;
+      unsigned HOST_WIDE_INT i;
       const char *s;
     } u;
 };
@@ -4496,15 +4605,6 @@ static int spelling_size;                /* Size of the spelling stack.  */
 #define SPELLING_DEPTH() (spelling - spelling_base)
 #define RESTORE_SPELLING_DEPTH(DEPTH) (spelling = spelling_base + (DEPTH))
 
-/* Save and restore the spelling stack around arbitrary C code.  */
-
-#define SAVE_SPELLING_DEPTH(code)              \
-{                                              \
-  int __depth = SPELLING_DEPTH ();             \
-  code;                                                \
-  RESTORE_SPELLING_DEPTH (__depth);            \
-}
-
 /* Push an element on the spelling stack with type KIND and assign VALUE
    to MEMBER.  */
 
@@ -4515,13 +4615,8 @@ static int spelling_size;                /* Size of the spelling stack.  */
   if (depth >= spelling_size)                                          \
     {                                                                  \
       spelling_size += 10;                                             \
-      if (spelling_base == 0)                                          \
-       spelling_base                                                   \
-         = (struct spelling *) xmalloc (spelling_size * sizeof (struct spelling));     \
-      else                                                             \
-        spelling_base                                                  \
-         = (struct spelling *) xrealloc (spelling_base,                \
-                                         spelling_size * sizeof (struct spelling));    \
+      spelling_base = XRESIZEVEC (struct spelling, spelling_base,      \
+                                 spelling_size);                       \
       RESTORE_SPELLING_DEPTH (depth);                                  \
     }                                                                  \
                                                                        \
@@ -4533,8 +4628,7 @@ static int spelling_size;         /* Size of the spelling stack.  */
 /* Push STRING on the stack.  Printed literally.  */
 
 static void
-push_string (string)
-     const char *string;
+push_string (const char *string)
 {
   PUSH_SPELLING (SPELLING_STRING, string, u.s);
 }
@@ -4542,9 +4636,7 @@ push_string (string)
 /* Push a member name on the stack.  Printed as '.' STRING.  */
 
 static void
-push_member_name (decl)
-     tree decl;
-     
+push_member_name (tree decl)
 {
   const char *const string
     = DECL_NAME (decl) ? IDENTIFIER_POINTER (DECL_NAME (decl)) : "<anonymous>";
@@ -4554,8 +4646,7 @@ push_member_name (decl)
 /* Push an array bounds on the stack.  Printed as [BOUNDS].  */
 
 static void
-push_array_bounds (bounds)
-     int bounds;
+push_array_bounds (unsigned HOST_WIDE_INT bounds)
 {
   PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i);
 }
@@ -4563,7 +4654,7 @@ push_array_bounds (bounds)
 /* Compute the maximum size in bytes of the printed spelling.  */
 
 static int
-spelling_length ()
+spelling_length (void)
 {
   int size = 0;
   struct spelling *p;
@@ -4582,8 +4673,7 @@ spelling_length ()
 /* Print the spelling to BUFFER and return it.  */
 
 static char *
-print_spelling (buffer)
-     char *buffer;
+print_spelling (char *buffer)
 {
   char *d = buffer;
   struct spelling *p;
@@ -4591,7 +4681,7 @@ print_spelling (buffer)
   for (p = spelling_base; p < spelling; p++)
     if (p->kind == SPELLING_BOUNDS)
       {
-       sprintf (d, "[%d]", p->u.i);
+       sprintf (d, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", p->u.i);
        d += strlen (d);
       }
     else
@@ -4611,129 +4701,204 @@ print_spelling (buffer)
    The component name is taken from the spelling stack.  */
 
 void
-error_init (msgid)
-     const char *msgid;
+error_init (const char *msgid)
 {
   char *ofwhat;
 
   error ("%s", _(msgid));
   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
   if (*ofwhat)
-    error ("(near initialization for `%s')", ofwhat);
+    error ("(near initialization for %qs)", ofwhat);
 }
 
-/* Issue a pedantic warning for a bad initializer component.
-   MSGID identifies the message.
-   The component name is taken from the spelling stack.  */
+/* Issue a pedantic warning for a bad initializer component.  OPT is
+   the option OPT_* (from options.h) controlling this warning or 0 if
+   it is unconditionally given.  MSGID identifies the message.  The
+   component name is taken from the spelling stack.  */
 
 void
-pedwarn_init (msgid)
-     const char *msgid;
+pedwarn_init (location_t location, int opt, const char *msgid)
 {
   char *ofwhat;
 
-  pedwarn ("%s", _(msgid));
+  pedwarn (location, opt, "%s", _(msgid));
   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
   if (*ofwhat)
-    pedwarn ("(near initialization for `%s')", ofwhat);
+    pedwarn (location, opt, "(near initialization for %qs)", ofwhat);
 }
 
-/* Issue a warning for a bad initializer component.
-   MSGID identifies the message.
-   The component name is taken from the spelling stack.  */
+/* Issue a warning for a bad initializer component.  
+
+   OPT is the OPT_W* value corresponding to the warning option that
+   controls this warning.  MSGID identifies the message.  The
+   component name is taken from the spelling stack.  */
 
 static void
-warning_init (msgid)
-     const char *msgid;
+warning_init (int opt, const char *msgid)
 {
   char *ofwhat;
 
-  warning ("%s", _(msgid));
+  warning (opt, "%s", _(msgid));
   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
   if (*ofwhat)
-    warning ("(near initialization for `%s')", ofwhat);
+    warning (opt, "(near initialization for %qs)", ofwhat);
 }
 \f
+/* If TYPE is an array type and EXPR is a parenthesized string
+   constant, warn if pedantic that EXPR is being used to initialize an
+   object of type TYPE.  */
+
+void
+maybe_warn_string_init (tree type, struct c_expr expr)
+{
+  if (pedantic
+      && TREE_CODE (type) == ARRAY_TYPE
+      && TREE_CODE (expr.value) == STRING_CST
+      && expr.original_code != STRING_CST)
+    pedwarn_init (input_location, OPT_pedantic, 
+                 "array initialized from parenthesized string constant");
+}
+
 /* Digest the parser output INIT as an initializer for type TYPE.
    Return a C expression of type TYPE to represent the initial value.
 
-   The arguments REQUIRE_CONSTANT and CONSTRUCTOR_CONSTANT request errors
-   if non-constant initializers or elements are seen.  CONSTRUCTOR_CONSTANT
-   applies only to elements of constructors.  */
+   If INIT is a string constant, STRICT_STRING is true if it is
+   unparenthesized or we should not warn here for it being parenthesized.
+   For other types of INIT, STRICT_STRING is not used.
+
+   REQUIRE_CONSTANT requests an error if non-constant initializers or
+   elements are seen.  */
 
 static tree
-digest_init (type, init, require_constant, constructor_constant)
-     tree type, init;
-     int require_constant, constructor_constant;
+digest_init (tree type, tree init, bool strict_string, int require_constant)
 {
   enum tree_code code = TREE_CODE (type);
   tree inside_init = init;
 
   if (type == error_mark_node
+      || !init
       || init == error_mark_node
       || TREE_TYPE (init) == error_mark_node)
     return error_mark_node;
 
-  /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
-  /* Do not use STRIP_NOPS here.  We do not want an enumerator
-     whose value is 0 to count as a null pointer constant.  */
-  if (TREE_CODE (init) == NON_LVALUE_EXPR)
-    inside_init = TREE_OPERAND (init, 0);
+  STRIP_TYPE_NOPS (inside_init);
 
   inside_init = fold (inside_init);
 
   /* Initialization of an array of chars from a string constant
      optionally enclosed in braces.  */
 
-  if (code == ARRAY_TYPE)
+  if (code == ARRAY_TYPE && inside_init
+      && TREE_CODE (inside_init) == STRING_CST)
     {
       tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
-      if ((typ1 == char_type_node
-          || typ1 == signed_char_type_node
-          || typ1 == unsigned_char_type_node
-          || typ1 == unsigned_wchar_type_node
-          || typ1 == signed_wchar_type_node)
-         && ((inside_init && TREE_CODE (inside_init) == STRING_CST)))
+      /* Note that an array could be both an array of character type
+        and an array of wchar_t if wchar_t is signed char or unsigned
+        char.  */
+      bool char_array = (typ1 == char_type_node
+                        || typ1 == signed_char_type_node
+                        || typ1 == unsigned_char_type_node);
+      bool wchar_array = !!comptypes (typ1, wchar_type_node);
+      bool char16_array = !!comptypes (typ1, char16_type_node);
+      bool char32_array = !!comptypes (typ1, char32_type_node);
+
+      if (char_array || wchar_array || char16_array || char32_array)
        {
+         struct c_expr expr;
+         tree typ2 = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)));
+         expr.value = inside_init;
+         expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
+         maybe_warn_string_init (type, expr);
+
          if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
                         TYPE_MAIN_VARIANT (type)))
            return inside_init;
 
-         if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)))
-              != char_type_node)
-             && TYPE_PRECISION (typ1) == TYPE_PRECISION (char_type_node))
+         if (char_array)
            {
-             error_init ("char-array initialized from wide string");
-             return error_mark_node;
+             if (typ2 != char_type_node)
+               {
+                 error_init ("char-array initialized from wide string");
+                 return error_mark_node;
+               }
            }
-         if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)))
-              == char_type_node)
-             && TYPE_PRECISION (typ1) != TYPE_PRECISION (char_type_node))
+         else
            {
-             error_init ("int-array initialized from non-wide string");
-             return error_mark_node;
+             if (typ2 == char_type_node)
+               {
+                 error_init ("wide character array initialized from non-wide "
+                             "string");
+                 return error_mark_node;
+               }
+             else if (!comptypes(typ1, typ2))
+               {
+                 error_init ("wide character array initialized from "
+                             "incompatible wide string");
+                 return error_mark_node;
+               }
            }
 
          TREE_TYPE (inside_init) = type;
          if (TYPE_DOMAIN (type) != 0
              && TYPE_SIZE (type) != 0
              && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
-             /* Subtract 1 (or sizeof (wchar_t))
+             /* Subtract the size of a single (possibly wide) character
                 because it's ok to ignore the terminating null char
                 that is counted in the length of the constant.  */
              && 0 > compare_tree_int (TYPE_SIZE_UNIT (type),
                                       TREE_STRING_LENGTH (inside_init)
-                                      - ((TYPE_PRECISION (typ1)
-                                          != TYPE_PRECISION (char_type_node))
-                                         ? (TYPE_PRECISION (wchar_type_node)
-                                            / BITS_PER_UNIT)
-                                         : 1)))
-           pedwarn_init ("initializer-string for array of chars is too long");
+                                      - (TYPE_PRECISION (typ1)
+                                         / BITS_PER_UNIT)))
+           pedwarn_init (input_location, 0, 
+                         "initializer-string for array of chars is too long");
 
          return inside_init;
        }
+      else if (INTEGRAL_TYPE_P (typ1))
+       {
+         error_init ("array of inappropriate type initialized "
+                     "from string constant");
+         return error_mark_node;
+       }
+    }
+
+  /* Build a VECTOR_CST from a *constant* vector constructor.  If the
+     vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
+     below and handle as a constructor.  */
+  if (code == VECTOR_TYPE
+      && TREE_CODE (TREE_TYPE (inside_init)) == VECTOR_TYPE
+      && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
+      && TREE_CONSTANT (inside_init))
+    {
+      if (TREE_CODE (inside_init) == VECTOR_CST
+         && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
+                       TYPE_MAIN_VARIANT (type)))
+       return inside_init;
+
+      if (TREE_CODE (inside_init) == CONSTRUCTOR)
+       {
+         unsigned HOST_WIDE_INT ix;
+         tree value;
+         bool constant_p = true;
+
+         /* Iterate through elements and check if all constructor
+            elements are *_CSTs.  */
+         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (inside_init), ix, value)
+           if (!CONSTANT_CLASS_P (value))
+             {
+               constant_p = false;
+               break;
+             }
+
+         if (constant_p)
+           return build_vector_from_ctor (type,
+                                          CONSTRUCTOR_ELTS (inside_init));
+       }
     }
 
+  if (warn_sequence_point)
+    verify_sequence_points (inside_init);
+
   /* Any type can be initialized
      from an expression of the same type, optionally with braces.  */
 
@@ -4745,20 +4910,38 @@ digest_init (type, init, require_constant, constructor_constant)
          || (code == VECTOR_TYPE
              && comptypes (TREE_TYPE (inside_init), type))
          || (code == POINTER_TYPE
-             && (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
-                 || TREE_CODE (TREE_TYPE (inside_init)) == FUNCTION_TYPE)
+             && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
              && comptypes (TREE_TYPE (TREE_TYPE (inside_init)),
                            TREE_TYPE (type)))))
     {
       if (code == POINTER_TYPE)
-       inside_init = default_function_array_conversion (inside_init);
+       {
+         if (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE)
+           {
+             if (TREE_CODE (inside_init) == STRING_CST
+                 || TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
+               inside_init = array_to_pointer_conversion (inside_init);
+             else
+               {
+                 error_init ("invalid use of non-lvalue array");
+                 return error_mark_node;
+               }
+           }
+       }
 
-      if (require_constant && !flag_isoc99
+      if (code == VECTOR_TYPE)
+       /* Although the types are compatible, we may require a
+          conversion.  */
+       inside_init = convert (type, inside_init);
+
+      if (require_constant
+         && (code == VECTOR_TYPE || !flag_isoc99)
          && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
        {
          /* As an extension, allow initializing objects with static storage
             duration with compound literals (which are then treated just as
-            the brace enclosed list they contain).  */
+            the brace enclosed list they contain).  Also allow this for
+            vectors, as we can only assign them with compound literals.  */
          tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
          inside_init = DECL_INITIAL (decl);
        }
@@ -4785,48 +4968,51 @@ digest_init (type, init, require_constant, constructor_constant)
          if (inside_init == error_mark_node)
            error_init ("initializer element is not constant");
          else
-           pedwarn_init ("initializer element is not constant");
+           pedwarn_init (input_location, OPT_pedantic,
+                         "initializer element is not constant");
          if (flag_pedantic_errors)
            inside_init = error_mark_node;
        }
-      else if (require_constant 
-              && (!TREE_CONSTANT (inside_init)
-                  /* This test catches things like `7 / 0' which
-                     result in an expression for which TREE_CONSTANT
-                     is true, but which is not actually something
-                     that is a legal constant.  We really should not
-                     be using this function, because it is a part of
-                     the back-end.  Instead, the expression should
-                     already have been turned into ERROR_MARK_NODE.  */
-                  || !initializer_constant_valid_p (inside_init,
-                                                    TREE_TYPE (inside_init))))
+      else if (require_constant
+              && !initializer_constant_valid_p (inside_init,
+                                                TREE_TYPE (inside_init)))
        {
          error_init ("initializer element is not constant");
          inside_init = error_mark_node;
        }
 
+      /* Added to enable additional -Wmissing-format-attribute warnings.  */
+      if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
+       inside_init = convert_for_assignment (type, inside_init, ic_init, NULL_TREE,
+                                             NULL_TREE, 0);
       return inside_init;
     }
 
   /* Handle scalar types, including conversions.  */
 
-  if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
-      || code == ENUMERAL_TYPE || code == BOOLEAN_TYPE || code == COMPLEX_TYPE)
+  if (code == INTEGER_TYPE || code == REAL_TYPE || code == FIXED_POINT_TYPE
+      || code == POINTER_TYPE || code == ENUMERAL_TYPE || code == BOOLEAN_TYPE
+      || code == COMPLEX_TYPE || code == VECTOR_TYPE)
     {
-      /* Note that convert_for_assignment calls default_conversion
-        for arrays and functions.  We must not call it in the
-        case where inside_init is a null pointer constant.  */
+      if (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
+         && (TREE_CODE (init) == STRING_CST
+             || TREE_CODE (init) == COMPOUND_LITERAL_EXPR))
+       init = array_to_pointer_conversion (init);
       inside_init
-       = convert_for_assignment (type, init, _("initialization"),
+       = convert_for_assignment (type, init, ic_init,
                                  NULL_TREE, NULL_TREE, 0);
 
-      if (require_constant && ! TREE_CONSTANT (inside_init))
+      /* Check to see if we have already given an error message.  */
+      if (inside_init == error_mark_node)
+       ;
+      else if (require_constant && !TREE_CONSTANT (inside_init))
        {
          error_init ("initializer element is not constant");
          inside_init = error_mark_node;
        }
       else if (require_constant
-              && initializer_constant_valid_p (inside_init, TREE_TYPE (inside_init)) == 0)
+              && !initializer_constant_valid_p (inside_init,
+                                                TREE_TYPE (inside_init)))
        {
          error_init ("initializer element is not computable at load time");
          inside_init = error_mark_node;
@@ -4843,44 +5029,6 @@ digest_init (type, init, require_constant, constructor_constant)
       return error_mark_node;
     }
 
-  /* Traditionally, you can write  struct foo x = 0;
-     and it initializes the first element of x to 0.  */
-  if (flag_traditional)
-    {
-      tree top = 0, prev = 0, otype = type;
-      while (TREE_CODE (type) == RECORD_TYPE
-            || TREE_CODE (type) == ARRAY_TYPE
-            || TREE_CODE (type) == QUAL_UNION_TYPE
-            || TREE_CODE (type) == UNION_TYPE)
-       {
-         tree temp = build (CONSTRUCTOR, type, NULL_TREE, NULL_TREE);
-         if (prev == 0)
-           top = temp;
-         else
-           TREE_OPERAND (prev, 1) = build_tree_list (NULL_TREE, temp);
-         prev = temp;
-         if (TREE_CODE (type) == ARRAY_TYPE)
-           type = TREE_TYPE (type);
-         else if (TYPE_FIELDS (type))
-           type = TREE_TYPE (TYPE_FIELDS (type));
-         else
-           {
-             error_init ("invalid initializer");
-             return error_mark_node;
-           }
-       }
-
-      if (otype != type)
-       {
-         TREE_OPERAND (prev, 1)
-           = build_tree_list (NULL_TREE,
-                              digest_init (type, init, require_constant,
-                                           constructor_constant));
-         return top;
-       }
-      else
-       return error_mark_node;
-    }
   error_init ("invalid initializer");
   return error_mark_node;
 }
@@ -4916,7 +5064,7 @@ static tree constructor_bit_index;
 /* If we are saving up the elements rather than allocating them,
    this is the list of elements so far (in reverse order,
    most recent first).  */
-static tree constructor_elements;
+static VEC(constructor_elt,gc) *constructor_elements;
 
 /* 1 if constructor should be incrementally stored into a constructor chain,
    0 if all the elements should be kept in AVL tree.  */
@@ -4931,9 +5079,6 @@ static int constructor_simple;
 /* 1 if this constructor is erroneous so far.  */
 static int constructor_erroneous;
 
-/* 1 if have called defer_addressed_constants.  */
-static int constructor_subconstants_deferred;
-
 /* Structure for managing pending initializer elements, organized as an
    AVL tree.  */
 
@@ -4956,20 +5101,11 @@ static struct init_node *constructor_pending_elts;
 /* The SPELLING_DEPTH of this constructor.  */
 static int constructor_depth;
 
-/* 0 if implicitly pushing constructor levels is allowed.  */
-int constructor_no_implicit = 0; /* 0 for C; 1 for some other languages.  */
-
-static int require_constant_value;
-static int require_constant_elements;
-
 /* DECL node for which an initializer is being read.
    0 means we are reading a constructor expression
    such as (struct foo) {...}.  */
 static tree constructor_decl;
 
-/* start_init saves the ASMSPEC arg here for really_start_incremental_init.  */
-static const char *constructor_asmspec;
-
 /* Nonzero if this is an initializer for a top-level decl.  */
 static int constructor_top_level;
 
@@ -4980,7 +5116,7 @@ static int constructor_designated;
 static int designator_depth;
 
 /* Nonzero if there were diagnosed errors in this designator list.  */
-static int designator_errorneous;
+static int designator_erroneous;
 
 \f
 /* This stack has a level for each implicit or explicit level of
@@ -4999,13 +5135,13 @@ struct constructor_stack
   tree unfilled_index;
   tree unfilled_fields;
   tree bit_index;
-  tree elements;
+  VEC(constructor_elt,gc) *elements;
   struct init_node *pending_elts;
   int offset;
   int depth;
-  /* If nonzero, this value should replace the entire
+  /* If value nonzero, this value should replace the entire
      constructor at this level.  */
-  tree replacement_value;
+  struct c_expr replacement_value;
   struct constructor_range_stack *range_stack;
   char constant;
   char simple;
@@ -5016,7 +5152,7 @@ struct constructor_stack
   char designated;
 };
 
-struct constructor_stack *constructor_stack;
+static struct constructor_stack *constructor_stack;
 
 /* This stack represents designators from some range designator up to
    the last designator in the list.  */
@@ -5031,7 +5167,7 @@ struct constructor_range_stack
   tree fields;
 };
 
-struct constructor_range_stack *constructor_range_stack;
+static struct constructor_range_stack *constructor_range_stack;
 
 /* This stack records separate initializers that are nested.
    Nested initializers can't happen in ANSI C, but GNU C allows them
@@ -5041,39 +5177,28 @@ struct initializer_stack
 {
   struct initializer_stack *next;
   tree decl;
-  const char *asmspec;
   struct constructor_stack *constructor_stack;
   struct constructor_range_stack *constructor_range_stack;
-  tree elements;
+  VEC(constructor_elt,gc) *elements;
   struct spelling *spelling;
   struct spelling *spelling_base;
   int spelling_size;
   char top_level;
   char require_constant_value;
   char require_constant_elements;
-  char deferred;
 };
 
-struct initializer_stack *initializer_stack;
+static struct initializer_stack *initializer_stack;
 \f
 /* Prepare to parse and output the initializer for variable DECL.  */
 
 void
-start_init (decl, asmspec_tree, top_level)
-     tree decl;
-     tree asmspec_tree;
-     int top_level;
+start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED, int top_level)
 {
   const char *locus;
-  struct initializer_stack *p
-    = (struct initializer_stack *) xmalloc (sizeof (struct initializer_stack));
-  const char *asmspec = 0;
-
-  if (asmspec_tree)
-    asmspec = TREE_STRING_POINTER (asmspec_tree);
+  struct initializer_stack *p = XNEW (struct initializer_stack);
 
   p->decl = constructor_decl;
-  p->asmspec = constructor_asmspec;
   p->require_constant_value = require_constant_value;
   p->require_constant_elements = require_constant_elements;
   p->constructor_stack = constructor_stack;
@@ -5082,18 +5207,15 @@ start_init (decl, asmspec_tree, top_level)
   p->spelling = spelling;
   p->spelling_base = spelling_base;
   p->spelling_size = spelling_size;
-  p->deferred = constructor_subconstants_deferred;
   p->top_level = constructor_top_level;
   p->next = initializer_stack;
   initializer_stack = p;
 
   constructor_decl = decl;
-  constructor_asmspec = asmspec;
-  constructor_subconstants_deferred = 0;
   constructor_designated = 0;
   constructor_top_level = top_level;
 
-  if (decl != 0)
+  if (decl != 0 && decl != error_mark_node)
     {
       require_constant_value = TREE_STATIC (decl);
       require_constant_elements
@@ -5127,16 +5249,10 @@ start_init (decl, asmspec_tree, top_level)
 }
 
 void
-finish_init ()
+finish_init (void)
 {
   struct initializer_stack *p = initializer_stack;
 
-  /* Output subconstants (string constants, usually)
-     that were referenced within this initializer and saved up.
-     Must do this if and only if we called defer_addressed_constants.  */
-  if (constructor_subconstants_deferred)
-    output_deferred_addressed_constants ();
-
   /* Free the whole constructor stack of this initializer.  */
   while (constructor_stack)
     {
@@ -5145,12 +5261,12 @@ finish_init ()
       free (q);
     }
 
-  if (constructor_range_stack)
-    abort ();
+  gcc_assert (!constructor_range_stack);
 
   /* Pop back to the data of the outer initializer (if any).  */
+  free (spelling_base);
+
   constructor_decl = p->decl;
-  constructor_asmspec = p->asmspec;
   require_constant_value = p->require_constant_value;
   require_constant_elements = p->require_constant_elements;
   constructor_stack = p->constructor_stack;
@@ -5159,7 +5275,6 @@ finish_init ()
   spelling = p->spelling;
   spelling_base = p->spelling_base;
   spelling_size = p->spelling_size;
-  constructor_subconstants_deferred = p->deferred;
   constructor_top_level = p->top_level;
   initializer_stack = p->next;
   free (p);
@@ -5173,15 +5288,16 @@ finish_init ()
    For an initializer for a decl, TYPE is zero.  */
 
 void
-really_start_incremental_init (type)
-     tree type;
+really_start_incremental_init (tree type)
 {
-  struct constructor_stack *p
-    = (struct constructor_stack *) xmalloc (sizeof (struct constructor_stack));
+  struct constructor_stack *p = XNEW (struct constructor_stack);
 
   if (type == 0)
     type = TREE_TYPE (constructor_decl);
 
+  if (targetm.vector_opaque_p (type))
+    error ("opaque vector types cannot be initialized");
+
   p->type = constructor_type;
   p->fields = constructor_fields;
   p->index = constructor_index;
@@ -5195,7 +5311,8 @@ really_start_incremental_init (type)
   p->erroneous = constructor_erroneous;
   p->pending_elts = constructor_pending_elts;
   p->depth = constructor_depth;
-  p->replacement_value = 0;
+  p->replacement_value.value = 0;
+  p->replacement_value.original_code = ERROR_MARK;
   p->implicit = 0;
   p->range_stack = 0;
   p->outer = 0;
@@ -5213,7 +5330,7 @@ really_start_incremental_init (type)
   constructor_incremental = 1;
   constructor_designated = 0;
   designator_depth = 0;
-  designator_errorneous = 0;
+  designator_erroneous = 0;
 
   if (TREE_CODE (constructor_type) == RECORD_TYPE
       || TREE_CODE (constructor_type) == UNION_TYPE)
@@ -5237,21 +5354,24 @@ really_start_incremental_init (type)
          /* Detect non-empty initializations of zero-length arrays.  */
          if (constructor_max_index == NULL_TREE
              && TYPE_SIZE (constructor_type))
-           constructor_max_index = build_int_2 (-1, -1);
+           constructor_max_index = build_int_cst (NULL_TREE, -1);
 
          /* constructor_max_index needs to be an INTEGER_CST.  Attempts
-            to initialize VLAs will cause an proper error; avoid tree
+            to initialize VLAs will cause a proper error; avoid tree
             checking errors as well by setting a safe value.  */
          if (constructor_max_index
              && TREE_CODE (constructor_max_index) != INTEGER_CST)
-           constructor_max_index = build_int_2 (-1, -1);
+           constructor_max_index = build_int_cst (NULL_TREE, -1);
 
          constructor_index
            = convert (bitsizetype,
                       TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
        }
       else
-       constructor_index = bitsize_zero_node;
+       {
+         constructor_index = bitsize_zero_node;
+         constructor_max_index = NULL_TREE;
+       }
 
       constructor_unfilled_index = constructor_index;
     }
@@ -5259,8 +5379,8 @@ really_start_incremental_init (type)
     {
       /* Vectors are like simple fixed-size arrays.  */
       constructor_max_index =
-       build_int_2 (TYPE_VECTOR_SUBPARTS (constructor_type) - 1, 0);
-      constructor_index = convert (bitsizetype, integer_zero_node);
+       build_int_cst (NULL_TREE, TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
+      constructor_index = bitsize_zero_node;
       constructor_unfilled_index = constructor_index;
     }
   else
@@ -5277,26 +5397,33 @@ really_start_incremental_init (type)
    IMPLICIT is 1 (or 2 if the push is because of designator list).  */
 
 void
-push_init_level (implicit)
-     int implicit;
+push_init_level (int implicit)
 {
   struct constructor_stack *p;
   tree value = NULL_TREE;
 
   /* If we've exhausted any levels that didn't have braces,
-     pop them now.  */
-  while (constructor_stack->implicit)
+     pop them now.  If implicit == 1, this will have been done in
+     process_init_element; do not repeat it here because in the case
+     of excess initializers for an empty aggregate this leads to an
+     infinite cycle of popping a level and immediately recreating
+     it.  */
+  if (implicit != 1)
     {
-      if ((TREE_CODE (constructor_type) == RECORD_TYPE
-          || TREE_CODE (constructor_type) == UNION_TYPE)
-         && constructor_fields == 0)
-       process_init_element (pop_init_level (1));
-      else if (TREE_CODE (constructor_type) == ARRAY_TYPE
-              && constructor_max_index 
-              && tree_int_cst_lt (constructor_max_index, constructor_index))
-       process_init_element (pop_init_level (1));
-      else
-       break;
+      while (constructor_stack->implicit)
+       {
+         if ((TREE_CODE (constructor_type) == RECORD_TYPE
+              || TREE_CODE (constructor_type) == UNION_TYPE)
+             && constructor_fields == 0)
+           process_init_element (pop_init_level (1), true);
+         else if (TREE_CODE (constructor_type) == ARRAY_TYPE
+                  && constructor_max_index
+                  && tree_int_cst_lt (constructor_max_index,
+                                      constructor_index))
+           process_init_element (pop_init_level (1), true);
+         else
+           break;
+       }
     }
 
   /* Unless this is an explicit brace, we need to preserve previous
@@ -5311,7 +5438,7 @@ push_init_level (implicit)
        value = find_init_member (constructor_index);
     }
 
-  p = (struct constructor_stack *) xmalloc (sizeof (struct constructor_stack));
+  p = XNEW (struct constructor_stack);
   p->type = constructor_type;
   p->fields = constructor_fields;
   p->index = constructor_index;
@@ -5325,7 +5452,8 @@ push_init_level (implicit)
   p->erroneous = constructor_erroneous;
   p->pending_elts = constructor_pending_elts;
   p->depth = constructor_depth;
-  p->replacement_value = 0;
+  p->replacement_value.value = 0;
+  p->replacement_value.original_code = ERROR_MARK;
   p->implicit = implicit;
   p->outer = 0;
   p->incremental = constructor_incremental;
@@ -5346,7 +5474,7 @@ push_init_level (implicit)
       p->range_stack = constructor_range_stack;
       constructor_range_stack = 0;
       designator_depth = 0;
-      designator_errorneous = 0;
+      designator_erroneous = 0;
     }
 
   /* Don't die if an entire brace-pair level is superfluous
@@ -5369,7 +5497,7 @@ push_init_level (implicit)
   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
     {
       constructor_type = TREE_TYPE (constructor_type);
-      push_array_bounds (tree_low_cst (constructor_index, 0));
+      push_array_bounds (tree_low_cst (constructor_index, 1));
       constructor_depth++;
     }
 
@@ -5385,8 +5513,8 @@ push_init_level (implicit)
     {
       constructor_constant = TREE_CONSTANT (value);
       constructor_simple = TREE_STATIC (value);
-      constructor_elements = TREE_OPERAND (value, 1);
-      if (constructor_elements
+      constructor_elements = CONSTRUCTOR_ELTS (value);
+      if (!VEC_empty (constructor_elt, constructor_elements)
          && (TREE_CODE (constructor_type) == RECORD_TYPE
              || TREE_CODE (constructor_type) == ARRAY_TYPE))
        set_nonincremental_init ();
@@ -5395,7 +5523,7 @@ push_init_level (implicit)
   if (implicit == 1 && warn_missing_braces && !missing_braces_mentioned)
     {
       missing_braces_mentioned = 1;
-      warning_init ("missing braces around initializer");
+      warning_init (OPT_Wmissing_braces, "missing braces around initializer");
     }
 
   if (TREE_CODE (constructor_type) == RECORD_TYPE
@@ -5414,7 +5542,7 @@ push_init_level (implicit)
     {
       /* Vectors are like simple fixed-size arrays.  */
       constructor_max_index =
-       build_int_2 (TYPE_VECTOR_SUBPARTS (constructor_type) - 1, 0);
+       build_int_cst (NULL_TREE, TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
       constructor_index = convert (bitsizetype, integer_zero_node);
       constructor_unfilled_index = constructor_index;
     }
@@ -5428,17 +5556,17 @@ push_init_level (implicit)
          /* Detect non-empty initializations of zero-length arrays.  */
          if (constructor_max_index == NULL_TREE
              && TYPE_SIZE (constructor_type))
-           constructor_max_index = build_int_2 (-1, -1);
+           constructor_max_index = build_int_cst (NULL_TREE, -1);
 
          /* constructor_max_index needs to be an INTEGER_CST.  Attempts
-            to initialize VLAs will cause an proper error; avoid tree
+            to initialize VLAs will cause a proper error; avoid tree
             checking errors as well by setting a safe value.  */
          if (constructor_max_index
              && TREE_CODE (constructor_max_index) != INTEGER_CST)
-           constructor_max_index = build_int_2 (-1, -1);
+           constructor_max_index = build_int_cst (NULL_TREE, -1);
 
          constructor_index
-           = convert (bitsizetype, 
+           = convert (bitsizetype,
                       TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
        }
       else
@@ -5455,38 +5583,46 @@ push_init_level (implicit)
     }
   else
     {
-      warning_init ("braces around scalar initializer");
+      if (constructor_type != error_mark_node)
+       warning_init (0, "braces around scalar initializer");
       constructor_fields = constructor_type;
       constructor_unfilled_fields = constructor_type;
     }
 }
 
-/* At the end of an implicit or explicit brace level, 
-   finish up that level of constructor.
-   If we were outputting the elements as they are read, return 0
+/* At the end of an implicit or explicit brace level,
+   finish up that level of constructor.  If a single expression
+   with redundant braces initialized that level, return the
+   c_expr structure for that expression.  Otherwise, the original_code
+   element is set to ERROR_MARK.
+   If we were outputting the elements as they are read, return 0 as the value
    from inner levels (process_init_element ignores that),
-   but return error_mark_node from the outermost level
+   but return error_mark_node as the value from the outermost level
    (that's what we want to put in DECL_INITIAL).
-   Otherwise, return a CONSTRUCTOR expression.  */
+   Otherwise, return a CONSTRUCTOR expression as the value.  */
 
-tree
-pop_init_level (implicit)
-     int implicit;
+struct c_expr
+pop_init_level (int implicit)
 {
   struct constructor_stack *p;
-  tree constructor = 0;
+  struct c_expr ret;
+  ret.value = 0;
+  ret.original_code = ERROR_MARK;
 
   if (implicit == 0)
     {
       /* When we come to an explicit close brace,
         pop any inner levels that didn't have explicit braces.  */
       while (constructor_stack->implicit)
-       process_init_element (pop_init_level (1));
+       process_init_element (pop_init_level (1), true);
 
-      if (constructor_range_stack)
-       abort ();
+      gcc_assert (!constructor_range_stack);
     }
 
+  /* Now output all pending elements.  */
+  constructor_incremental = 1;
+  output_pending_init_elements (1);
+
   p = constructor_stack;
 
   /* Error for initializing a flexible array member, or a zero-length
@@ -5494,40 +5630,39 @@ pop_init_level (implicit)
   if (constructor_type && constructor_fields
       && TREE_CODE (constructor_type) == ARRAY_TYPE
       && TYPE_DOMAIN (constructor_type)
-      && ! TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
+      && !TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
     {
       /* Silently discard empty initializations.  The parser will
         already have pedwarned for empty brackets.  */
       if (integer_zerop (constructor_unfilled_index))
        constructor_type = NULL_TREE;
-      else if (! TYPE_SIZE (constructor_type))
+      else
        {
+         gcc_assert (!TYPE_SIZE (constructor_type));
+
          if (constructor_depth > 2)
            error_init ("initialization of flexible array member in a nested context");
-         else if (pedantic)
-           pedwarn_init ("initialization of a flexible array member");
+         else
+           pedwarn_init (input_location, OPT_pedantic,
+                         "initialization of a flexible array member");
 
          /* We have already issued an error message for the existence
             of a flexible array member not at the end of the structure.
-            Discard the initializer so that we do not abort later.  */
+            Discard the initializer so that we do not die later.  */
          if (TREE_CHAIN (constructor_fields) != NULL_TREE)
            constructor_type = NULL_TREE;
        }
-      else
-       /* Zero-length arrays are no longer special, so we should no longer
-          get here.  */
-       abort ();
     }
 
   /* Warn when some struct elements are implicitly initialized to zero.  */
-  if (extra_warnings
+  if (warn_missing_field_initializers
       && constructor_type
       && TREE_CODE (constructor_type) == RECORD_TYPE
       && constructor_unfilled_fields)
     {
        /* Do not warn for flexible array members or zero-length arrays.  */
        while (constructor_unfilled_fields
-              && (! DECL_SIZE (constructor_unfilled_fields)
+              && (!DECL_SIZE (constructor_unfilled_fields)
                   || integer_zerop (DECL_SIZE (constructor_unfilled_fields))))
          constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
 
@@ -5536,20 +5671,17 @@ pop_init_level (implicit)
        if (constructor_unfilled_fields && !constructor_designated)
          {
            push_member_name (constructor_unfilled_fields);
-           warning_init ("missing initializer");
+           warning_init (OPT_Wmissing_field_initializers,
+                          "missing initializer");
            RESTORE_SPELLING_DEPTH (constructor_depth);
          }
     }
 
-  /* Now output all pending elements.  */
-  constructor_incremental = 1;
-  output_pending_init_elements (1);
-
   /* Pad out the end of the structure.  */
-  if (p->replacement_value)
+  if (p->replacement_value.value)
     /* If this closes a superfluous brace pair,
        just pass out the element between them.  */
-    constructor = p->replacement_value;
+    ret = p->replacement_value;
   else if (constructor_type == 0)
     ;
   else if (TREE_CODE (constructor_type) != RECORD_TYPE
@@ -5559,32 +5691,32 @@ pop_init_level (implicit)
     {
       /* A nonincremental scalar initializer--just return
         the element, after verifying there is just one.  */
-      if (constructor_elements == 0)
+      if (VEC_empty (constructor_elt,constructor_elements))
        {
          if (!constructor_erroneous)
            error_init ("empty scalar initializer");
-         constructor = error_mark_node;
+         ret.value = error_mark_node;
        }
-      else if (TREE_CHAIN (constructor_elements) != 0)
+      else if (VEC_length (constructor_elt,constructor_elements) != 1)
        {
          error_init ("extra elements in scalar initializer");
-         constructor = TREE_VALUE (constructor_elements);
+         ret.value = VEC_index (constructor_elt,constructor_elements,0)->value;
        }
       else
-       constructor = TREE_VALUE (constructor_elements);
+       ret.value = VEC_index (constructor_elt,constructor_elements,0)->value;
     }
   else
     {
       if (constructor_erroneous)
-       constructor = error_mark_node;
+       ret.value = error_mark_node;
       else
        {
-         constructor = build (CONSTRUCTOR, constructor_type, NULL_TREE,
-                              nreverse (constructor_elements));
+         ret.value = build_constructor (constructor_type,
+                                        constructor_elements);
          if (constructor_constant)
-           TREE_CONSTANT (constructor) = 1;
+           TREE_CONSTANT (ret.value) = 1;
          if (constructor_constant && constructor_simple)
-           TREE_STATIC (constructor) = 1;
+           TREE_STATIC (ret.value) = 1;
        }
     }
 
@@ -5610,21 +5742,16 @@ pop_init_level (implicit)
   constructor_stack = p->next;
   free (p);
 
-  if (constructor == 0)
-    {
-      if (constructor_stack == 0)
-       return error_mark_node;
-      return NULL_TREE;
-    }
-  return constructor;
+  if (ret.value == 0 && constructor_stack == 0)
+    ret.value = error_mark_node;
+  return ret;
 }
 
 /* Common handling for both array range and field name designators.
-   ARRAY argument is non-zero for array ranges.  Returns zero for success.  */
+   ARRAY argument is nonzero for array ranges.  Returns zero for success.  */
 
 static int
-set_designator (array)
-     int array;
+set_designator (int array)
 {
   tree subtype;
   enum tree_code subcode;
@@ -5634,42 +5761,37 @@ set_designator (array)
   if (constructor_type == 0)
     return 1;
 
-  /* If there were errors in this designator list already, bail out silently.  */
-  if (designator_errorneous)
+  /* If there were errors in this designator list already, bail out
+     silently.  */
+  if (designator_erroneous)
     return 1;
 
   if (!designator_depth)
     {
-      if (constructor_range_stack)
-       abort ();
+      gcc_assert (!constructor_range_stack);
 
       /* Designator list starts at the level of closest explicit
         braces.  */
       while (constructor_stack->implicit)
-       process_init_element (pop_init_level (1));
+       process_init_element (pop_init_level (1), true);
       constructor_designated = 1;
       return 0;
     }
 
-  if (constructor_no_implicit)
-    {
-      error_init ("initialization designators may not nest");
-      return 1;
-    }
-
-  if (TREE_CODE (constructor_type) == RECORD_TYPE
-      || TREE_CODE (constructor_type) == UNION_TYPE)
+  switch (TREE_CODE (constructor_type))
     {
+    case  RECORD_TYPE:
+    case  UNION_TYPE:
       subtype = TREE_TYPE (constructor_fields);
       if (subtype != error_mark_node)
        subtype = TYPE_MAIN_VARIANT (subtype);
-    }
-  else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
-    {
+      break;
+    case ARRAY_TYPE:
       subtype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
+      break;
+    default:
+      gcc_unreachable ();
     }
-  else
-    abort ();
 
   subcode = TREE_CODE (subtype);
   if (array && subcode != ARRAY_TYPE)
@@ -5693,13 +5815,11 @@ set_designator (array)
    NULL_TREE if there is no range designator at this level.  */
 
 static void
-push_range_stack (range_end)
-     tree range_end;
+push_range_stack (tree range_end)
 {
   struct constructor_range_stack *p;
 
-  p = (struct constructor_range_stack *)
-      ggc_alloc (sizeof (struct constructor_range_stack));
+  p = GGC_NEW (struct constructor_range_stack);
   p->prev = constructor_range_stack;
   p->next = 0;
   p->fields = constructor_fields;
@@ -5717,28 +5837,19 @@ push_range_stack (range_end)
    of indices, running from FIRST through LAST.  */
 
 void
-set_init_index (first, last)
-     tree first, last;
+set_init_index (tree first, tree last)
 {
   if (set_designator (1))
     return;
 
-  designator_errorneous = 1;
+  designator_erroneous = 1;
 
-  while ((TREE_CODE (first) == NOP_EXPR
-         || TREE_CODE (first) == CONVERT_EXPR
-         || TREE_CODE (first) == NON_LVALUE_EXPR)
-        && (TYPE_MODE (TREE_TYPE (first))
-            == TYPE_MODE (TREE_TYPE (TREE_OPERAND (first, 0)))))
-    first = TREE_OPERAND (first, 0);
-
-  if (last)
-    while ((TREE_CODE (last) == NOP_EXPR
-           || TREE_CODE (last) == CONVERT_EXPR
-           || TREE_CODE (last) == NON_LVALUE_EXPR)
-          && (TYPE_MODE (TREE_TYPE (last))
-              == TYPE_MODE (TREE_TYPE (TREE_OPERAND (last, 0)))))
-      last = TREE_OPERAND (last, 0);
+  if (!INTEGRAL_TYPE_P (TREE_TYPE (first))
+      || (last && !INTEGRAL_TYPE_P (TREE_TYPE (last))))
+    {
+      error_init ("array index in initializer not of integer type");
+      return;
+    }
 
   if (TREE_CODE (first) != INTEGER_CST)
     error_init ("nonconstant array index in initializer");
@@ -5746,6 +5857,8 @@ set_init_index (first, last)
     error_init ("nonconstant array index in initializer");
   else if (TREE_CODE (constructor_type) != ARRAY_TYPE)
     error_init ("array index in non-array initializer");
+  else if (tree_int_cst_sgn (first) == -1)
+    error_init ("array index in initializer exceeds array bounds");
   else if (constructor_max_index
           && tree_int_cst_lt (constructor_max_index, first))
     error_init ("array index in initializer exceeds array bounds");
@@ -5775,7 +5888,7 @@ set_init_index (first, last)
        }
 
       designator_depth++;
-      designator_errorneous = 0;
+      designator_erroneous = 0;
       if (constructor_range_stack || last)
        push_range_stack (last);
     }
@@ -5784,15 +5897,14 @@ set_init_index (first, last)
 /* Within a struct initializer, specify the next field to be initialized.  */
 
 void
-set_init_label (fieldname)
-     tree fieldname;
+set_init_label (tree fieldname)
 {
   tree tail;
 
   if (set_designator (0))
     return;
 
-  designator_errorneous = 1;
+  designator_erroneous = 1;
 
   if (TREE_CODE (constructor_type) != RECORD_TYPE
       && TREE_CODE (constructor_type) != UNION_TYPE)
@@ -5800,7 +5912,7 @@ set_init_label (fieldname)
       error_init ("field name not in record or union initializer");
       return;
     }
-    
+
   for (tail = TYPE_FIELDS (constructor_type); tail;
        tail = TREE_CHAIN (tail))
     {
@@ -5809,25 +5921,28 @@ set_init_label (fieldname)
     }
 
   if (tail == 0)
-    error ("unknown field `%s' specified in initializer",
-          IDENTIFIER_POINTER (fieldname));
+    error ("unknown field %qE specified in initializer", fieldname);
   else
     {
       constructor_fields = tail;
       designator_depth++;
-      designator_errorneous = 0;
+      designator_erroneous = 0;
       if (constructor_range_stack)
        push_range_stack (NULL_TREE);
     }
 }
 \f
 /* Add a new initializer to the tree of pending initializers.  PURPOSE
-   identifies the initializer, either array index or field in a structure. 
-   VALUE is the value of that index or field.  */
+   identifies the initializer, either array index or field in a structure.
+   VALUE is the value of that index or field.
+
+   IMPLICIT is true if value comes from pop_init_level (1),
+   the new initializer has been merged with the existing one
+   and thus no warnings should be emitted about overriding an
+   existing initializer.  */
 
 static void
-add_pending_init (purpose, value)
-     tree purpose, value;
+add_pending_init (tree purpose, tree value, bool implicit)
 {
   struct init_node *p, **q, *r;
 
@@ -5845,8 +5960,13 @@ add_pending_init (purpose, value)
            q = &p->right;
          else
            {
-             if (TREE_SIDE_EFFECTS (p->value))
-               warning_init ("initialized field with side-effects overwritten");
+             if (!implicit)
+               {
+                 if (TREE_SIDE_EFFECTS (p->value))
+                   warning_init (0, "initialized field with side-effects overwritten");
+                 else if (warn_override_init)
+                   warning_init (OPT_Woverride_init, "initialized field overwritten");
+               }
              p->value = value;
              return;
            }
@@ -5866,15 +5986,20 @@ add_pending_init (purpose, value)
            q = &p->right;
          else
            {
-             if (TREE_SIDE_EFFECTS (p->value))
-               warning_init ("initialized field with side-effects overwritten");
+             if (!implicit)
+               {
+                 if (TREE_SIDE_EFFECTS (p->value))
+                   warning_init (0, "initialized field with side-effects overwritten");
+                 else if (warn_override_init)
+                   warning_init (OPT_Woverride_init, "initialized field overwritten");
+               }
              p->value = value;
              return;
            }
        }
     }
 
-  r = (struct init_node *) ggc_alloc (sizeof (struct init_node));
+  r = GGC_NEW (struct init_node);
   r->purpose = purpose;
   r->value = value;
 
@@ -6042,16 +6167,17 @@ add_pending_init (purpose, value)
 /* Build AVL tree from a sorted chain.  */
 
 static void
-set_nonincremental_init ()
+set_nonincremental_init (void)
 {
-  tree chain;
+  unsigned HOST_WIDE_INT ix;
+  tree index, value;
 
   if (TREE_CODE (constructor_type) != RECORD_TYPE
       && TREE_CODE (constructor_type) != ARRAY_TYPE)
     return;
 
-  for (chain = constructor_elements; chain; chain = TREE_CHAIN (chain))
-    add_pending_init (TREE_PURPOSE (chain), TREE_VALUE (chain));
+  FOR_EACH_CONSTRUCTOR_ELT (constructor_elements, ix, index, value)
+    add_pending_init (index, value, false);
   constructor_elements = 0;
   if (TREE_CODE (constructor_type) == RECORD_TYPE)
     {
@@ -6061,7 +6187,7 @@ set_nonincremental_init ()
             && DECL_C_BIT_FIELD (constructor_unfilled_fields)
             && DECL_NAME (constructor_unfilled_fields) == 0)
        constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
-      
+
     }
   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
     {
@@ -6078,26 +6204,16 @@ set_nonincremental_init ()
 /* Build AVL tree from a string constant.  */
 
 static void
-set_nonincremental_init_from_string (str)
-     tree str;
+set_nonincremental_init_from_string (tree str)
 {
   tree value, purpose, type;
   HOST_WIDE_INT val[2];
   const char *p, *end;
   int byte, wchar_bytes, charwidth, bitpos;
 
-  if (TREE_CODE (constructor_type) != ARRAY_TYPE)
-    abort ();
-
-  if (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str)))
-      == TYPE_PRECISION (char_type_node))
-    wchar_bytes = 1;
-  else if (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str)))
-          == TYPE_PRECISION (wchar_type_node))
-    wchar_bytes = TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT;
-  else
-    abort ();
+  gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE);
 
+  wchar_bytes = TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) / BITS_PER_UNIT;
   charwidth = TYPE_PRECISION (char_type_node);
   type = TREE_TYPE (constructor_type);
   p = TREE_STRING_POINTER (str);
@@ -6128,7 +6244,7 @@ set_nonincremental_init_from_string (str)
            }
        }
 
-      if (!TREE_UNSIGNED (type))
+      if (!TYPE_UNSIGNED (type))
        {
          bitpos = ((wchar_bytes - 1) * charwidth) + HOST_BITS_PER_CHAR;
          if (bitpos < HOST_BITS_PER_WIDE_INT)
@@ -6142,7 +6258,7 @@ set_nonincremental_init_from_string (str)
          else if (bitpos == HOST_BITS_PER_WIDE_INT)
            {
              if (val[1] < 0)
-               val[0] = -1;
+               val[0] = -1;
            }
          else if (val[0] & (((HOST_WIDE_INT) 1)
                             << (bitpos - 1 - HOST_BITS_PER_WIDE_INT)))
@@ -6150,9 +6266,8 @@ set_nonincremental_init_from_string (str)
                      << (bitpos - HOST_BITS_PER_WIDE_INT);
        }
 
-      value = build_int_2 (val[1], val[0]);
-      TREE_TYPE (value) = type;
-      add_pending_init (purpose, value);
+      value = build_int_cst_wide (type, val[1], val[0]);
+      add_pending_init (purpose, value, false);
     }
 
   constructor_incremental = 0;
@@ -6162,8 +6277,7 @@ set_nonincremental_init_from_string (str)
    not initialized yet.  */
 
 static tree
-find_init_member (field)
-     tree field;
+find_init_member (tree field)
 {
   struct init_node *p;
 
@@ -6207,9 +6321,10 @@ find_init_member (field)
     }
   else if (TREE_CODE (constructor_type) == UNION_TYPE)
     {
-      if (constructor_elements
-         && TREE_PURPOSE (constructor_elements) == field)
-       return TREE_VALUE (constructor_elements);
+      if (!VEC_empty (constructor_elt, constructor_elements)
+         && (VEC_last (constructor_elt, constructor_elements)->index
+             == field))
+       return VEC_last (constructor_elt, constructor_elements)->value;
     }
   return 0;
 }
@@ -6219,24 +6334,39 @@ find_init_member (field)
    Otherwise, collect it in a list from which we will make a CONSTRUCTOR.
    TYPE is the data type that the containing data type wants here.
    FIELD is the field (a FIELD_DECL) or the index that this element fills.
+   If VALUE is a string constant, STRICT_STRING is true if it is
+   unparenthesized or we should not warn here for it being parenthesized.
+   For other types of VALUE, STRICT_STRING is not used.
 
    PENDING if non-nil means output pending elements that belong
    right after this element.  (PENDING is normally 1;
-   it is 0 while outputting pending elements, to avoid recursion.)  */
+   it is 0 while outputting pending elements, to avoid recursion.)
+
+   IMPLICIT is true if value comes from pop_init_level (1),
+   the new initializer has been merged with the existing one
+   and thus no warnings should be emitted about overriding an
+   existing initializer.  */
 
 static void
-output_init_element (value, type, field, pending)
-     tree value, type, field;
-     int pending;
+output_init_element (tree value, bool strict_string, tree type, tree field,
+                    int pending, bool implicit)
 {
-  if (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE
-      || (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
-         && !(TREE_CODE (value) == STRING_CST
-              && TREE_CODE (type) == ARRAY_TYPE
-              && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
-         && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
-                        TYPE_MAIN_VARIANT (type))))
-    value = default_conversion (value);
+  constructor_elt *celt;
+
+  if (type == error_mark_node || value == error_mark_node)
+    {
+      constructor_erroneous = 1;
+      return;
+    }
+  if (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
+      && (TREE_CODE (value) == STRING_CST
+         || TREE_CODE (value) == COMPOUND_LITERAL_EXPR)
+      && !(TREE_CODE (value) == STRING_CST
+          && TREE_CODE (type) == ARRAY_TYPE
+          && INTEGRAL_TYPE_P (TREE_TYPE (type)))
+      && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
+                    TYPE_MAIN_VARIANT (type)))
+    value = array_to_pointer_conversion (value);
 
   if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
       && require_constant_value && !flag_isoc99 && pending)
@@ -6252,21 +6382,24 @@ output_init_element (value, type, field, pending)
     constructor_erroneous = 1;
   else if (!TREE_CONSTANT (value))
     constructor_constant = 0;
-  else if (initializer_constant_valid_p (value, TREE_TYPE (value)) == 0
+  else if (!initializer_constant_valid_p (value, TREE_TYPE (value))
           || ((TREE_CODE (constructor_type) == RECORD_TYPE
                || TREE_CODE (constructor_type) == UNION_TYPE)
               && DECL_C_BIT_FIELD (field)
               && TREE_CODE (value) != INTEGER_CST))
     constructor_simple = 0;
 
-  if (require_constant_value && ! TREE_CONSTANT (value))
+  if (!initializer_constant_valid_p (value, TREE_TYPE (value)))
     {
-      error_init ("initializer element is not constant");
-      value = error_mark_node;
+      if (require_constant_value)
+       {
+         error_init ("initializer element is not constant");
+         value = error_mark_node;
+       }
+      else if (require_constant_elements)
+       pedwarn (input_location, 0,
+                "initializer element is not computable at load time");
     }
-  else if (require_constant_elements
-          && initializer_constant_valid_p (value, TREE_TYPE (value)) == 0)
-    pedwarn ("initializer element is not computable at load time");
 
   /* If this field is empty (and not at the end of structure),
      don't do anything other than checking the initializer.  */
@@ -6278,8 +6411,7 @@ output_init_element (value, type, field, pending)
                  || TREE_CHAIN (field)))))
     return;
 
-  value = digest_init (type, value, require_constant_value,
-                      require_constant_elements);
+  value = digest_init (type, value, strict_string, require_constant_value);
   if (value == error_mark_node)
     {
       constructor_erroneous = 1;
@@ -6296,7 +6428,7 @@ output_init_element (value, type, field, pending)
          && tree_int_cst_lt (field, constructor_unfilled_index))
        set_nonincremental_init ();
 
-      add_pending_init (field, value);
+      add_pending_init (field, value, implicit);
       return;
     }
   else if (TREE_CODE (constructor_type) == RECORD_TYPE
@@ -6322,14 +6454,21 @@ output_init_element (value, type, field, pending)
            }
        }
 
-      add_pending_init (field, value);
+      add_pending_init (field, value, implicit);
       return;
     }
   else if (TREE_CODE (constructor_type) == UNION_TYPE
-          && constructor_elements)
+          && !VEC_empty (constructor_elt, constructor_elements))
     {
-      if (TREE_SIDE_EFFECTS (TREE_VALUE (constructor_elements)))
-       warning_init ("initialized field with side-effects overwritten");
+      if (!implicit)
+       {
+         if (TREE_SIDE_EFFECTS (VEC_last (constructor_elt,
+                                          constructor_elements)->value))
+           warning_init (0,
+                         "initialized field with side-effects overwritten");
+         else if (warn_override_init)
+           warning_init (OPT_Woverride_init, "initialized field overwritten");
+       }
 
       /* We can have just one union field set.  */
       constructor_elements = 0;
@@ -6338,10 +6477,9 @@ output_init_element (value, type, field, pending)
   /* Otherwise, output this element either to
      constructor_elements or to the assembler file.  */
 
-  if (field && TREE_CODE (field) == INTEGER_CST)
-    field = copy_node (field);
-  constructor_elements
-    = tree_cons (field, value, constructor_elements);
+  celt = VEC_safe_push (constructor_elt, gc, constructor_elements, NULL);
+  celt->index = field;
+  celt->value = value;
 
   /* Advance the variable that indicates sequential elements output.  */
   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
@@ -6380,19 +6518,18 @@ output_init_element (value, type, field, pending)
    we can output all the pending elements.  */
 
 static void
-output_pending_init_elements (all)
-     int all;
+output_pending_init_elements (int all)
 {
   struct init_node *elt = constructor_pending_elts;
   tree next;
 
  retry:
 
-  /* Look thru the whole pending tree.
+  /* Look through the whole pending tree.
      If we find an element that should be output now,
      output it.  Otherwise, set NEXT to the element
      that comes first among those still pending.  */
-     
+
   next = 0;
   while (elt)
     {
@@ -6400,9 +6537,9 @@ output_pending_init_elements (all)
        {
          if (tree_int_cst_equal (elt->purpose,
                                  constructor_unfilled_index))
-           output_init_element (elt->value,
+           output_init_element (elt->value, true,
                                 TREE_TYPE (constructor_type),
-                                constructor_unfilled_index, 0);
+                                constructor_unfilled_index, 0, false);
          else if (tree_int_cst_lt (constructor_unfilled_index,
                                    elt->purpose))
            {
@@ -6454,8 +6591,8 @@ output_pending_init_elements (all)
          if (tree_int_cst_equal (elt_bitpos, ctor_unfilled_bitpos))
            {
              constructor_unfilled_fields = elt->purpose;
-             output_init_element (elt->value, TREE_TYPE (elt->purpose),
-                                  elt->purpose, 0);
+             output_init_element (elt->value, true, TREE_TYPE (elt->purpose),
+                                  elt->purpose, 0, false);
            }
          else if (tree_int_cst_lt (ctor_unfilled_bitpos, elt_bitpos))
            {
@@ -6496,7 +6633,7 @@ output_pending_init_elements (all)
 
   /* Ordinarily return, but not if we want to output all
      and there are elements left.  */
-  if (! (all && next != 0))
+  if (!(all && next != 0))
     return;
 
   /* If it's not incremental, just skip over the gap, so that after
@@ -6518,33 +6655,38 @@ output_pending_init_elements (all)
    to handle a partly-braced initializer.
 
    Once this has found the correct level for the new element,
-   it calls output_init_element.  */
+   it calls output_init_element.
+
+   IMPLICIT is true if value comes from pop_init_level (1),
+   the new initializer has been merged with the existing one
+   and thus no warnings should be emitted about overriding an
+   existing initializer.  */
 
 void
-process_init_element (value)
-     tree value;
+process_init_element (struct c_expr value, bool implicit)
 {
-  tree orig_value = value;
-  int string_flag = value != 0 && TREE_CODE (value) == STRING_CST;
+  tree orig_value = value.value;
+  int string_flag = orig_value != 0 && TREE_CODE (orig_value) == STRING_CST;
+  bool strict_string = value.original_code == STRING_CST;
 
   designator_depth = 0;
-  designator_errorneous = 0;
+  designator_erroneous = 0;
 
   /* Handle superfluous braces around string cst as in
      char x[] = {"foo"}; */
   if (string_flag
       && constructor_type
       && TREE_CODE (constructor_type) == ARRAY_TYPE
-      && TREE_CODE (TREE_TYPE (constructor_type)) == INTEGER_TYPE
+      && INTEGRAL_TYPE_P (TREE_TYPE (constructor_type))
       && integer_zerop (constructor_unfilled_index))
     {
-      if (constructor_stack->replacement_value)
-        error_init ("excess elements in char array initializer");
+      if (constructor_stack->replacement_value.value)
+       error_init ("excess elements in char array initializer");
       constructor_stack->replacement_value = value;
       return;
     }
 
-  if (constructor_stack->replacement_value != 0)
+  if (constructor_stack->replacement_value.value != 0)
     {
       error_init ("excess elements in struct initializer");
       return;
@@ -6562,12 +6704,12 @@ process_init_element (value)
       if ((TREE_CODE (constructor_type) == RECORD_TYPE
           || TREE_CODE (constructor_type) == UNION_TYPE)
          && constructor_fields == 0)
-       process_init_element (pop_init_level (1));
+       process_init_element (pop_init_level (1), true);
       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
               && (constructor_max_index == 0
                   || tree_int_cst_lt (constructor_max_index,
                                       constructor_index)))
-       process_init_element (pop_init_level (1));
+       process_init_element (pop_init_level (1), true);
       else
        break;
     }
@@ -6577,10 +6719,10 @@ process_init_element (value)
     {
       /* If value is a compound literal and we'll be just using its
         content, don't put it into a SAVE_EXPR.  */
-      if (TREE_CODE (value) != COMPOUND_LITERAL_EXPR
+      if (TREE_CODE (value.value) != COMPOUND_LITERAL_EXPR
          || !require_constant_value
          || flag_isoc99)
-       value = save_expr (value);
+       value.value = save_expr (value.value);
     }
 
   while (1)
@@ -6592,7 +6734,8 @@ process_init_element (value)
 
          if (constructor_fields == 0)
            {
-             pedwarn_init ("excess elements in struct initializer");
+             pedwarn_init (input_location, 0,
+                           "excess elements in struct initializer");
              break;
            }
 
@@ -6612,16 +6755,16 @@ process_init_element (value)
            }
 
          /* Accept a string constant to initialize a subarray.  */
-         if (value != 0
+         if (value.value != 0
              && fieldcode == ARRAY_TYPE
-             && TREE_CODE (TREE_TYPE (fieldtype)) == INTEGER_TYPE
+             && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
              && string_flag)
-           value = orig_value;
+           value.value = orig_value;
          /* Otherwise, if we have come to a subaggregate,
             and we don't have an element of its type, push into it.  */
-         else if (value != 0 && !constructor_no_implicit
-                  && value != error_mark_node
-                  && TYPE_MAIN_VARIANT (TREE_TYPE (value)) != fieldtype
+         else if (value.value != 0
+                  && value.value != error_mark_node
+                  && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != fieldtype
                   && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE
                       || fieldcode == UNION_TYPE))
            {
@@ -6629,10 +6772,11 @@ process_init_element (value)
              continue;
            }
 
-         if (value)
+         if (value.value)
            {
              push_member_name (constructor_fields);
-             output_init_element (value, fieldtype, constructor_fields, 1);
+             output_init_element (value.value, strict_string,
+                                  fieldtype, constructor_fields, 1, implicit);
              RESTORE_SPELLING_DEPTH (constructor_depth);
            }
          else
@@ -6641,10 +6785,10 @@ process_init_element (value)
            {
              /* For a record, keep track of end position of last field.  */
              if (DECL_SIZE (constructor_fields))
-               constructor_bit_index
+               constructor_bit_index
                  = size_binop (PLUS_EXPR,
-                               bit_position (constructor_fields),
-                               DECL_SIZE (constructor_fields));
+                               bit_position (constructor_fields),
+                               DECL_SIZE (constructor_fields));
 
              /* If the current field was the first one not yet written out,
                 it isn't now, so update.  */
@@ -6672,565 +6816,2169 @@ process_init_element (value)
          tree fieldtype;
          enum tree_code fieldcode;
 
-         if (constructor_fields == 0)
-           {
-             pedwarn_init ("excess elements in union initializer");
-             break;
+         if (constructor_fields == 0)
+           {
+             pedwarn_init (input_location, 0,
+                           "excess elements in union initializer");
+             break;
+           }
+
+         fieldtype = TREE_TYPE (constructor_fields);
+         if (fieldtype != error_mark_node)
+           fieldtype = TYPE_MAIN_VARIANT (fieldtype);
+         fieldcode = TREE_CODE (fieldtype);
+
+         /* Warn that traditional C rejects initialization of unions.
+            We skip the warning if the value is zero.  This is done
+            under the assumption that the zero initializer in user
+            code appears conditioned on e.g. __STDC__ to avoid
+            "missing initializer" warnings and relies on default
+            initialization to zero in the traditional C case.
+            We also skip the warning if the initializer is designated,
+            again on the assumption that this must be conditional on
+            __STDC__ anyway (and we've already complained about the
+            member-designator already).  */
+         if (!in_system_header && !constructor_designated
+             && !(value.value && (integer_zerop (value.value)
+                                  || real_zerop (value.value))))
+           warning (OPT_Wtraditional, "traditional C rejects initialization "
+                    "of unions");
+
+         /* Accept a string constant to initialize a subarray.  */
+         if (value.value != 0
+             && fieldcode == ARRAY_TYPE
+             && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
+             && string_flag)
+           value.value = orig_value;
+         /* Otherwise, if we have come to a subaggregate,
+            and we don't have an element of its type, push into it.  */
+         else if (value.value != 0
+                  && value.value != error_mark_node
+                  && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != fieldtype
+                  && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE
+                      || fieldcode == UNION_TYPE))
+           {
+             push_init_level (1);
+             continue;
+           }
+
+         if (value.value)
+           {
+             push_member_name (constructor_fields);
+             output_init_element (value.value, strict_string,
+                                  fieldtype, constructor_fields, 1, implicit);
+             RESTORE_SPELLING_DEPTH (constructor_depth);
+           }
+         else
+           /* Do the bookkeeping for an element that was
+              directly output as a constructor.  */
+           {
+             constructor_bit_index = DECL_SIZE (constructor_fields);
+             constructor_unfilled_fields = TREE_CHAIN (constructor_fields);
+           }
+
+         constructor_fields = 0;
+       }
+      else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
+       {
+         tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
+         enum tree_code eltcode = TREE_CODE (elttype);
+
+         /* Accept a string constant to initialize a subarray.  */
+         if (value.value != 0
+             && eltcode == ARRAY_TYPE
+             && INTEGRAL_TYPE_P (TREE_TYPE (elttype))
+             && string_flag)
+           value.value = orig_value;
+         /* Otherwise, if we have come to a subaggregate,
+            and we don't have an element of its type, push into it.  */
+         else if (value.value != 0
+                  && value.value != error_mark_node
+                  && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != elttype
+                  && (eltcode == RECORD_TYPE || eltcode == ARRAY_TYPE
+                      || eltcode == UNION_TYPE))
+           {
+             push_init_level (1);
+             continue;
+           }
+
+         if (constructor_max_index != 0
+             && (tree_int_cst_lt (constructor_max_index, constructor_index)
+                 || integer_all_onesp (constructor_max_index)))
+           {
+             pedwarn_init (input_location, 0,
+                           "excess elements in array initializer");
+             break;
+           }
+
+         /* Now output the actual element.  */
+         if (value.value)
+           {
+             push_array_bounds (tree_low_cst (constructor_index, 1));
+             output_init_element (value.value, strict_string,
+                                  elttype, constructor_index, 1, implicit);
+             RESTORE_SPELLING_DEPTH (constructor_depth);
+           }
+
+         constructor_index
+           = size_binop (PLUS_EXPR, constructor_index, bitsize_one_node);
+
+         if (!value.value)
+           /* If we are doing the bookkeeping for an element that was
+              directly output as a constructor, we must update
+              constructor_unfilled_index.  */
+           constructor_unfilled_index = constructor_index;
+       }
+      else if (TREE_CODE (constructor_type) == VECTOR_TYPE)
+       {
+         tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
+
+        /* Do a basic check of initializer size.  Note that vectors
+           always have a fixed size derived from their type.  */
+         if (tree_int_cst_lt (constructor_max_index, constructor_index))
+           {
+             pedwarn_init (input_location, 0,
+                           "excess elements in vector initializer");
+             break;
+           }
+
+         /* Now output the actual element.  */
+         if (value.value)
+           output_init_element (value.value, strict_string,
+                                elttype, constructor_index, 1, implicit);
+
+         constructor_index
+           = size_binop (PLUS_EXPR, constructor_index, bitsize_one_node);
+
+         if (!value.value)
+           /* If we are doing the bookkeeping for an element that was
+              directly output as a constructor, we must update
+              constructor_unfilled_index.  */
+           constructor_unfilled_index = constructor_index;
+       }
+
+      /* Handle the sole element allowed in a braced initializer
+        for a scalar variable.  */
+      else if (constructor_type != error_mark_node
+              && constructor_fields == 0)
+       {
+         pedwarn_init (input_location, 0,
+                       "excess elements in scalar initializer");
+         break;
+       }
+      else
+       {
+         if (value.value)
+           output_init_element (value.value, strict_string,
+                                constructor_type, NULL_TREE, 1, implicit);
+         constructor_fields = 0;
+       }
+
+      /* Handle range initializers either at this level or anywhere higher
+        in the designator stack.  */
+      if (constructor_range_stack)
+       {
+         struct constructor_range_stack *p, *range_stack;
+         int finish = 0;
+
+         range_stack = constructor_range_stack;
+         constructor_range_stack = 0;
+         while (constructor_stack != range_stack->stack)
+           {
+             gcc_assert (constructor_stack->implicit);
+             process_init_element (pop_init_level (1), true);
+           }
+         for (p = range_stack;
+              !p->range_end || tree_int_cst_equal (p->index, p->range_end);
+              p = p->prev)
+           {
+             gcc_assert (constructor_stack->implicit);
+             process_init_element (pop_init_level (1), true);
+           }
+
+         p->index = size_binop (PLUS_EXPR, p->index, bitsize_one_node);
+         if (tree_int_cst_equal (p->index, p->range_end) && !p->prev)
+           finish = 1;
+
+         while (1)
+           {
+             constructor_index = p->index;
+             constructor_fields = p->fields;
+             if (finish && p->range_end && p->index == p->range_start)
+               {
+                 finish = 0;
+                 p->prev = 0;
+               }
+             p = p->next;
+             if (!p)
+               break;
+             push_init_level (2);
+             p->stack = constructor_stack;
+             if (p->range_end && tree_int_cst_equal (p->index, p->range_end))
+               p->index = p->range_start;
+           }
+
+         if (!finish)
+           constructor_range_stack = range_stack;
+         continue;
+       }
+
+      break;
+    }
+
+  constructor_range_stack = 0;
+}
+\f
+/* Build a complete asm-statement, whose components are a CV_QUALIFIER
+   (guaranteed to be 'volatile' or null) and ARGS (represented using
+   an ASM_EXPR node).  */
+tree
+build_asm_stmt (tree cv_qualifier, tree args)
+{
+  if (!ASM_VOLATILE_P (args) && cv_qualifier)
+    ASM_VOLATILE_P (args) = 1;
+  return add_stmt (args);
+}
+
+/* Build an asm-expr, whose components are a STRING, some OUTPUTS,
+   some INPUTS, and some CLOBBERS.  The latter three may be NULL.
+   SIMPLE indicates whether there was anything at all after the
+   string in the asm expression -- asm("blah") and asm("blah" : )
+   are subtly different.  We use a ASM_EXPR node to represent this.  */
+tree
+build_asm_expr (tree string, tree outputs, tree inputs, tree clobbers,
+               bool simple)
+{
+  tree tail;
+  tree args;
+  int i;
+  const char *constraint;
+  const char **oconstraints;
+  bool allows_mem, allows_reg, is_inout;
+  int ninputs, noutputs;
+
+  ninputs = list_length (inputs);
+  noutputs = list_length (outputs);
+  oconstraints = (const char **) alloca (noutputs * sizeof (const char *));
+
+  string = resolve_asm_operand_names (string, outputs, inputs);
+
+  /* Remove output conversions that change the type but not the mode.  */
+  for (i = 0, tail = outputs; tail; ++i, tail = TREE_CHAIN (tail))
+    {
+      tree output = TREE_VALUE (tail);
+
+      /* ??? Really, this should not be here.  Users should be using a
+        proper lvalue, dammit.  But there's a long history of using casts
+        in the output operands.  In cases like longlong.h, this becomes a
+        primitive form of typechecking -- if the cast can be removed, then
+        the output operand had a type of the proper width; otherwise we'll
+        get an error.  Gross, but ...  */
+      STRIP_NOPS (output);
+
+      if (!lvalue_or_else (output, lv_asm))
+       output = error_mark_node;
+
+      if (output != error_mark_node
+         && (TREE_READONLY (output)
+             || TYPE_READONLY (TREE_TYPE (output))
+             || ((TREE_CODE (TREE_TYPE (output)) == RECORD_TYPE
+                  || TREE_CODE (TREE_TYPE (output)) == UNION_TYPE)
+                 && C_TYPE_FIELDS_READONLY (TREE_TYPE (output)))))
+       readonly_error (output, lv_asm);
+
+      constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
+      oconstraints[i] = constraint;
+
+      if (parse_output_constraint (&constraint, i, ninputs, noutputs,
+                                  &allows_mem, &allows_reg, &is_inout))
+       {
+         /* If the operand is going to end up in memory,
+            mark it addressable.  */
+         if (!allows_reg && !c_mark_addressable (output))
+           output = error_mark_node;
+       }
+      else
+       output = error_mark_node;
+
+      TREE_VALUE (tail) = output;
+    }
+
+  for (i = 0, tail = inputs; tail; ++i, tail = TREE_CHAIN (tail))
+    {
+      tree input;
+
+      constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
+      input = TREE_VALUE (tail);
+
+      if (parse_input_constraint (&constraint, i, ninputs, noutputs, 0,
+                                 oconstraints, &allows_mem, &allows_reg))
+       {
+         /* If the operand is going to end up in memory,
+            mark it addressable.  */
+         if (!allows_reg && allows_mem)
+           {
+             /* Strip the nops as we allow this case.  FIXME, this really
+                should be rejected or made deprecated.  */
+             STRIP_NOPS (input);
+             if (!c_mark_addressable (input))
+               input = error_mark_node;
+         }
+       }
+      else
+       input = error_mark_node;
+
+      TREE_VALUE (tail) = input;
+    }
+
+  args = build_stmt (ASM_EXPR, string, outputs, inputs, clobbers);
+
+  /* asm statements without outputs, including simple ones, are treated
+     as volatile.  */
+  ASM_INPUT_P (args) = simple;
+  ASM_VOLATILE_P (args) = (noutputs == 0);
+
+  return args;
+}
+\f
+/* Generate a goto statement to LABEL.  */
+
+tree
+c_finish_goto_label (tree label)
+{
+  tree decl = lookup_label (label);
+  if (!decl)
+    return NULL_TREE;
+
+  if (C_DECL_UNJUMPABLE_STMT_EXPR (decl))
+    {
+      error ("jump into statement expression");
+      return NULL_TREE;
+    }
+
+  if (C_DECL_UNJUMPABLE_VM (decl))
+    {
+      error ("jump into scope of identifier with variably modified type");
+      return NULL_TREE;
+    }
+
+  if (!C_DECL_UNDEFINABLE_STMT_EXPR (decl))
+    {
+      /* No jump from outside this statement expression context, so
+        record that there is a jump from within this context.  */
+      struct c_label_list *nlist;
+      nlist = XOBNEW (&parser_obstack, struct c_label_list);
+      nlist->next = label_context_stack_se->labels_used;
+      nlist->label = decl;
+      label_context_stack_se->labels_used = nlist;
+    }
+
+  if (!C_DECL_UNDEFINABLE_VM (decl))
+    {
+      /* No jump from outside this context context of identifiers with
+        variably modified type, so record that there is a jump from
+        within this context.  */
+      struct c_label_list *nlist;
+      nlist = XOBNEW (&parser_obstack, struct c_label_list);
+      nlist->next = label_context_stack_vm->labels_used;
+      nlist->label = decl;
+      label_context_stack_vm->labels_used = nlist;
+    }
+
+  TREE_USED (decl) = 1;
+  return add_stmt (build1 (GOTO_EXPR, void_type_node, decl));
+}
+
+/* Generate a computed goto statement to EXPR.  */
+
+tree
+c_finish_goto_ptr (tree expr)
+{
+  pedwarn (input_location, OPT_pedantic, "ISO C forbids %<goto *expr;%>");
+  expr = convert (ptr_type_node, expr);
+  return add_stmt (build1 (GOTO_EXPR, void_type_node, expr));
+}
+
+/* Generate a C `return' statement.  RETVAL is the expression for what
+   to return, or a null pointer for `return;' with no value.  */
+
+tree
+c_finish_return (tree retval)
+{
+  tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
+  bool no_warning = false;
+
+  if (TREE_THIS_VOLATILE (current_function_decl))
+    warning (0, "function declared %<noreturn%> has a %<return%> statement");
+
+  if (!retval)
+    {
+      current_function_returns_null = 1;
+      if ((warn_return_type || flag_isoc99)
+         && valtype != 0 && TREE_CODE (valtype) != VOID_TYPE)
+       {
+         pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wreturn_type, 
+                      "%<return%> with no value, in "
+                      "function returning non-void");
+         no_warning = true;
+       }
+    }
+  else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE)
+    {
+      current_function_returns_null = 1;
+      if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
+       pedwarn (input_location, 0, 
+                "%<return%> with a value, in function returning void");
+      else 
+       pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+                "%<return%> with expression, in function returning void");
+    }
+  else
+    {
+      tree t = convert_for_assignment (valtype, retval, ic_return,
+                                      NULL_TREE, NULL_TREE, 0);
+      tree res = DECL_RESULT (current_function_decl);
+      tree inner;
+
+      current_function_returns_value = 1;
+      if (t == error_mark_node)
+       return NULL_TREE;
+
+      inner = t = convert (TREE_TYPE (res), t);
+
+      /* Strip any conversions, additions, and subtractions, and see if
+        we are returning the address of a local variable.  Warn if so.  */
+      while (1)
+       {
+         switch (TREE_CODE (inner))
+           {
+           CASE_CONVERT:
+           case NON_LVALUE_EXPR:
+           case PLUS_EXPR:
+           case POINTER_PLUS_EXPR:
+             inner = TREE_OPERAND (inner, 0);
+             continue;
+
+           case MINUS_EXPR:
+             /* If the second operand of the MINUS_EXPR has a pointer
+                type (or is converted from it), this may be valid, so
+                don't give a warning.  */
+             {
+               tree op1 = TREE_OPERAND (inner, 1);
+
+               while (!POINTER_TYPE_P (TREE_TYPE (op1))
+                      && (CONVERT_EXPR_P (op1)
+                          || TREE_CODE (op1) == NON_LVALUE_EXPR))
+                 op1 = TREE_OPERAND (op1, 0);
+
+               if (POINTER_TYPE_P (TREE_TYPE (op1)))
+                 break;
+
+               inner = TREE_OPERAND (inner, 0);
+               continue;
+             }
+
+           case ADDR_EXPR:
+             inner = TREE_OPERAND (inner, 0);
+
+             while (REFERENCE_CLASS_P (inner)
+                    && TREE_CODE (inner) != INDIRECT_REF)
+               inner = TREE_OPERAND (inner, 0);
+
+             if (DECL_P (inner)
+                 && !DECL_EXTERNAL (inner)
+                 && !TREE_STATIC (inner)
+                 && DECL_CONTEXT (inner) == current_function_decl)
+               warning (0, "function returns address of local variable");
+             break;
+
+           default:
+             break;
+           }
+
+         break;
+       }
+
+      retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, t);
+
+      if (warn_sequence_point)
+       verify_sequence_points (retval);
+    }
+
+  ret_stmt = build_stmt (RETURN_EXPR, retval);
+  TREE_NO_WARNING (ret_stmt) |= no_warning;
+  return add_stmt (ret_stmt);
+}
+\f
+struct c_switch {
+  /* The SWITCH_EXPR being built.  */
+  tree switch_expr;
+
+  /* The original type of the testing expression, i.e. before the
+     default conversion is applied.  */
+  tree orig_type;
+
+  /* A splay-tree mapping the low element of a case range to the high
+     element, or NULL_TREE if there is no high element.  Used to
+     determine whether or not a new case label duplicates an old case
+     label.  We need a tree, rather than simply a hash table, because
+     of the GNU case range extension.  */
+  splay_tree cases;
+
+  /* Number of nested statement expressions within this switch
+     statement; if nonzero, case and default labels may not
+     appear.  */
+  unsigned int blocked_stmt_expr;
+
+  /* Scope of outermost declarations of identifiers with variably
+     modified type within this switch statement; if nonzero, case and
+     default labels may not appear.  */
+  unsigned int blocked_vm;
+
+  /* The next node on the stack.  */
+  struct c_switch *next;
+};
+
+/* A stack of the currently active switch statements.  The innermost
+   switch statement is on the top of the stack.  There is no need to
+   mark the stack for garbage collection because it is only active
+   during the processing of the body of a function, and we never
+   collect at that point.  */
+
+struct c_switch *c_switch_stack;
+
+/* Start a C switch statement, testing expression EXP.  Return the new
+   SWITCH_EXPR.  */
+
+tree
+c_start_case (tree exp)
+{
+  tree orig_type = error_mark_node;
+  struct c_switch *cs;
+
+  if (exp != error_mark_node)
+    {
+      orig_type = TREE_TYPE (exp);
+
+      if (!INTEGRAL_TYPE_P (orig_type))
+       {
+         if (orig_type != error_mark_node)
+           {
+             error ("switch quantity not an integer");
+             orig_type = error_mark_node;
+           }
+         exp = integer_zero_node;
+       }
+      else
+       {
+         tree type = TYPE_MAIN_VARIANT (orig_type);
+
+         if (!in_system_header
+             && (type == long_integer_type_node
+                 || type == long_unsigned_type_node))
+           warning (OPT_Wtraditional, "%<long%> switch expression not "
+                    "converted to %<int%> in ISO C");
+
+         exp = default_conversion (exp);
+
+         if (warn_sequence_point)
+           verify_sequence_points (exp);
+       }
+    }
+
+  /* Add this new SWITCH_EXPR to the stack.  */
+  cs = XNEW (struct c_switch);
+  cs->switch_expr = build3 (SWITCH_EXPR, orig_type, exp, NULL_TREE, NULL_TREE);
+  cs->orig_type = orig_type;
+  cs->cases = splay_tree_new (case_compare, NULL, NULL);
+  cs->blocked_stmt_expr = 0;
+  cs->blocked_vm = 0;
+  cs->next = c_switch_stack;
+  c_switch_stack = cs;
+
+  return add_stmt (cs->switch_expr);
+}
+
+/* Process a case label.  */
+
+tree
+do_case (tree low_value, tree high_value)
+{
+  tree label = NULL_TREE;
+
+  if (c_switch_stack && !c_switch_stack->blocked_stmt_expr
+      && !c_switch_stack->blocked_vm)
+    {
+      label = c_add_case_label (c_switch_stack->cases,
+                               SWITCH_COND (c_switch_stack->switch_expr),
+                               c_switch_stack->orig_type,
+                               low_value, high_value);
+      if (label == error_mark_node)
+       label = NULL_TREE;
+    }
+  else if (c_switch_stack && c_switch_stack->blocked_stmt_expr)
+    {
+      if (low_value)
+       error ("case label in statement expression not containing "
+              "enclosing switch statement");
+      else
+       error ("%<default%> label in statement expression not containing "
+              "enclosing switch statement");
+    }
+  else if (c_switch_stack && c_switch_stack->blocked_vm)
+    {
+      if (low_value)
+       error ("case label in scope of identifier with variably modified "
+              "type not containing enclosing switch statement");
+      else
+       error ("%<default%> label in scope of identifier with variably "
+              "modified type not containing enclosing switch statement");
+    }
+  else if (low_value)
+    error ("case label not within a switch statement");
+  else
+    error ("%<default%> label not within a switch statement");
+
+  return label;
+}
+
+/* Finish the switch statement.  */
+
+void
+c_finish_case (tree body)
+{
+  struct c_switch *cs = c_switch_stack;
+  location_t switch_location;
+
+  SWITCH_BODY (cs->switch_expr) = body;
+
+  /* We must not be within a statement expression nested in the switch
+     at this point; we might, however, be within the scope of an
+     identifier with variably modified type nested in the switch.  */
+  gcc_assert (!cs->blocked_stmt_expr);
+
+  /* Emit warnings as needed.  */
+  if (EXPR_HAS_LOCATION (cs->switch_expr))
+    switch_location = EXPR_LOCATION (cs->switch_expr);
+  else
+    switch_location = input_location;
+  c_do_switch_warnings (cs->cases, switch_location,
+                       TREE_TYPE (cs->switch_expr),
+                       SWITCH_COND (cs->switch_expr));
+
+  /* Pop the stack.  */
+  c_switch_stack = cs->next;
+  splay_tree_delete (cs->cases);
+  XDELETE (cs);
+}
+\f
+/* Emit an if statement.  IF_LOCUS is the location of the 'if'.  COND,
+   THEN_BLOCK and ELSE_BLOCK are expressions to be used; ELSE_BLOCK
+   may be null.  NESTED_IF is true if THEN_BLOCK contains another IF
+   statement, and was not surrounded with parenthesis.  */
+
+void
+c_finish_if_stmt (location_t if_locus, tree cond, tree then_block,
+                 tree else_block, bool nested_if)
+{
+  tree stmt;
+
+  /* Diagnose an ambiguous else if if-then-else is nested inside if-then.  */
+  if (warn_parentheses && nested_if && else_block == NULL)
+    {
+      tree inner_if = then_block;
+
+      /* We know from the grammar productions that there is an IF nested
+        within THEN_BLOCK.  Due to labels and c99 conditional declarations,
+        it might not be exactly THEN_BLOCK, but should be the last
+        non-container statement within.  */
+      while (1)
+       switch (TREE_CODE (inner_if))
+         {
+         case COND_EXPR:
+           goto found;
+         case BIND_EXPR:
+           inner_if = BIND_EXPR_BODY (inner_if);
+           break;
+         case STATEMENT_LIST:
+           inner_if = expr_last (then_block);
+           break;
+         case TRY_FINALLY_EXPR:
+         case TRY_CATCH_EXPR:
+           inner_if = TREE_OPERAND (inner_if, 0);
+           break;
+         default:
+           gcc_unreachable ();
+         }
+    found:
+
+      if (COND_EXPR_ELSE (inner_if))
+        warning (OPT_Wparentheses,
+                 "%Hsuggest explicit braces to avoid ambiguous %<else%>",
+                 &if_locus);
+    }
+
+  stmt = build3 (COND_EXPR, void_type_node, cond, then_block, else_block);
+  SET_EXPR_LOCATION (stmt, if_locus);
+  add_stmt (stmt);
+}
+
+/* Emit a general-purpose loop construct.  START_LOCUS is the location of
+   the beginning of the loop.  COND is the loop condition.  COND_IS_FIRST
+   is false for DO loops.  INCR is the FOR increment expression.  BODY is
+   the statement controlled by the loop.  BLAB is the break label.  CLAB is
+   the continue label.  Everything is allowed to be NULL.  */
+
+void
+c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
+              tree blab, tree clab, bool cond_is_first)
+{
+  tree entry = NULL, exit = NULL, t;
+
+  /* If the condition is zero don't generate a loop construct.  */
+  if (cond && integer_zerop (cond))
+    {
+      if (cond_is_first)
+       {
+         t = build_and_jump (&blab);
+         SET_EXPR_LOCATION (t, start_locus);
+         add_stmt (t);
+       }
+    }
+  else
+    {
+      tree top = build1 (LABEL_EXPR, void_type_node, NULL_TREE);
+
+      /* If we have an exit condition, then we build an IF with gotos either
+        out of the loop, or to the top of it.  If there's no exit condition,
+        then we just build a jump back to the top.  */
+      exit = build_and_jump (&LABEL_EXPR_LABEL (top));
+
+      if (cond && !integer_nonzerop (cond))
+       {
+         /* Canonicalize the loop condition to the end.  This means
+            generating a branch to the loop condition.  Reuse the
+            continue label, if possible.  */
+         if (cond_is_first)
+           {
+             if (incr || !clab)
+               {
+                 entry = build1 (LABEL_EXPR, void_type_node, NULL_TREE);
+                 t = build_and_jump (&LABEL_EXPR_LABEL (entry));
+               }
+             else
+               t = build1 (GOTO_EXPR, void_type_node, clab);
+             SET_EXPR_LOCATION (t, start_locus);
+             add_stmt (t);
+           }
+
+         t = build_and_jump (&blab);
+         exit = fold_build3 (COND_EXPR, void_type_node, cond, exit, t);
+         if (cond_is_first)
+           SET_EXPR_LOCATION (exit, start_locus);
+         else
+           SET_EXPR_LOCATION (exit, input_location);
+       }
+
+      add_stmt (top);
+    }
+
+  if (body)
+    add_stmt (body);
+  if (clab)
+    add_stmt (build1 (LABEL_EXPR, void_type_node, clab));
+  if (incr)
+    add_stmt (incr);
+  if (entry)
+    add_stmt (entry);
+  if (exit)
+    add_stmt (exit);
+  if (blab)
+    add_stmt (build1 (LABEL_EXPR, void_type_node, blab));
+}
+
+tree
+c_finish_bc_stmt (tree *label_p, bool is_break)
+{
+  bool skip;
+  tree label = *label_p;
+
+  /* In switch statements break is sometimes stylistically used after
+     a return statement.  This can lead to spurious warnings about
+     control reaching the end of a non-void function when it is
+     inlined.  Note that we are calling block_may_fallthru with
+     language specific tree nodes; this works because
+     block_may_fallthru returns true when given something it does not
+     understand.  */
+  skip = !block_may_fallthru (cur_stmt_list);
+
+  if (!label)
+    {
+      if (!skip)
+       *label_p = label = create_artificial_label ();
+    }
+  else if (TREE_CODE (label) == LABEL_DECL)
+    ;
+  else switch (TREE_INT_CST_LOW (label))
+    {
+    case 0:
+      if (is_break)
+       error ("break statement not within loop or switch");
+      else
+       error ("continue statement not within a loop");
+      return NULL_TREE;
+
+    case 1:
+      gcc_assert (is_break);
+      error ("break statement used with OpenMP for loop");
+      return NULL_TREE;
+
+    default:
+      gcc_unreachable ();
+    }
+
+  if (skip)
+    return NULL_TREE;
+
+  if (!is_break)
+    add_stmt (build_predict_expr (PRED_CONTINUE, NOT_TAKEN));
+
+  return add_stmt (build1 (GOTO_EXPR, void_type_node, label));
+}
+
+/* A helper routine for c_process_expr_stmt and c_finish_stmt_expr.  */
+
+static void
+emit_side_effect_warnings (tree expr)
+{
+  if (expr == error_mark_node)
+    ;
+  else if (!TREE_SIDE_EFFECTS (expr))
+    {
+      if (!VOID_TYPE_P (TREE_TYPE (expr)) && !TREE_NO_WARNING (expr))
+       warning (OPT_Wunused_value, "%Hstatement with no effect",
+                EXPR_HAS_LOCATION (expr) ? EXPR_LOCUS (expr) : &input_location);
+    }
+  else
+    warn_if_unused_value (expr, input_location);
+}
+
+/* Process an expression as if it were a complete statement.  Emit
+   diagnostics, but do not call ADD_STMT.  */
+
+tree
+c_process_expr_stmt (tree expr)
+{
+  if (!expr)
+    return NULL_TREE;
+
+  if (warn_sequence_point)
+    verify_sequence_points (expr);
+
+  if (TREE_TYPE (expr) != error_mark_node
+      && !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
+      && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
+    error ("expression statement has incomplete type");
+
+  /* If we're not processing a statement expression, warn about unused values.
+     Warnings for statement expressions will be emitted later, once we figure
+     out which is the result.  */
+  if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
+      && warn_unused_value)
+    emit_side_effect_warnings (expr);
+
+  /* If the expression is not of a type to which we cannot assign a line
+     number, wrap the thing in a no-op NOP_EXPR.  */
+  if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
+    expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
+
+  if (CAN_HAVE_LOCATION_P (expr))
+    SET_EXPR_LOCATION (expr, input_location);
+
+  return expr;
+}
+
+/* Emit an expression as a statement.  */
+
+tree
+c_finish_expr_stmt (tree expr)
+{
+  if (expr)
+    return add_stmt (c_process_expr_stmt (expr));
+  else
+    return NULL;
+}
+
+/* Do the opposite and emit a statement as an expression.  To begin,
+   create a new binding level and return it.  */
+
+tree
+c_begin_stmt_expr (void)
+{
+  tree ret;
+  struct c_label_context_se *nstack;
+  struct c_label_list *glist;
+
+  /* We must force a BLOCK for this level so that, if it is not expanded
+     later, there is a way to turn off the entire subtree of blocks that
+     are contained in it.  */
+  keep_next_level ();
+  ret = c_begin_compound_stmt (true);
+  if (c_switch_stack)
+    {
+      c_switch_stack->blocked_stmt_expr++;
+      gcc_assert (c_switch_stack->blocked_stmt_expr != 0);
+    }
+  for (glist = label_context_stack_se->labels_used;
+       glist != NULL;
+       glist = glist->next)
+    {
+      C_DECL_UNDEFINABLE_STMT_EXPR (glist->label) = 1;
+    }
+  nstack = XOBNEW (&parser_obstack, struct c_label_context_se);
+  nstack->labels_def = NULL;
+  nstack->labels_used = NULL;
+  nstack->next = label_context_stack_se;
+  label_context_stack_se = nstack;
+
+  /* Mark the current statement list as belonging to a statement list.  */
+  STATEMENT_LIST_STMT_EXPR (ret) = 1;
+
+  return ret;
+}
+
+tree
+c_finish_stmt_expr (tree body)
+{
+  tree last, type, tmp, val;
+  tree *last_p;
+  struct c_label_list *dlist, *glist, *glist_prev = NULL;
+
+  body = c_end_compound_stmt (body, true);
+  if (c_switch_stack)
+    {
+      gcc_assert (c_switch_stack->blocked_stmt_expr != 0);
+      c_switch_stack->blocked_stmt_expr--;
+    }
+  /* It is no longer possible to jump to labels defined within this
+     statement expression.  */
+  for (dlist = label_context_stack_se->labels_def;
+       dlist != NULL;
+       dlist = dlist->next)
+    {
+      C_DECL_UNJUMPABLE_STMT_EXPR (dlist->label) = 1;
+    }
+  /* It is again possible to define labels with a goto just outside
+     this statement expression.  */
+  for (glist = label_context_stack_se->next->labels_used;
+       glist != NULL;
+       glist = glist->next)
+    {
+      C_DECL_UNDEFINABLE_STMT_EXPR (glist->label) = 0;
+      glist_prev = glist;
+    }
+  if (glist_prev != NULL)
+    glist_prev->next = label_context_stack_se->labels_used;
+  else
+    label_context_stack_se->next->labels_used
+      = label_context_stack_se->labels_used;
+  label_context_stack_se = label_context_stack_se->next;
+
+  /* Locate the last statement in BODY.  See c_end_compound_stmt
+     about always returning a BIND_EXPR.  */
+  last_p = &BIND_EXPR_BODY (body);
+  last = BIND_EXPR_BODY (body);
+
+ continue_searching:
+  if (TREE_CODE (last) == STATEMENT_LIST)
+    {
+      tree_stmt_iterator i;
+
+      /* This can happen with degenerate cases like ({ }).  No value.  */
+      if (!TREE_SIDE_EFFECTS (last))
+       return body;
+
+      /* If we're supposed to generate side effects warnings, process
+        all of the statements except the last.  */
+      if (warn_unused_value)
+       {
+         for (i = tsi_start (last); !tsi_one_before_end_p (i); tsi_next (&i))
+           emit_side_effect_warnings (tsi_stmt (i));
+       }
+      else
+       i = tsi_last (last);
+      last_p = tsi_stmt_ptr (i);
+      last = *last_p;
+    }
+
+  /* If the end of the list is exception related, then the list was split
+     by a call to push_cleanup.  Continue searching.  */
+  if (TREE_CODE (last) == TRY_FINALLY_EXPR
+      || TREE_CODE (last) == TRY_CATCH_EXPR)
+    {
+      last_p = &TREE_OPERAND (last, 0);
+      last = *last_p;
+      goto continue_searching;
+    }
+
+  /* In the case that the BIND_EXPR is not necessary, return the
+     expression out from inside it.  */
+  if (last == error_mark_node
+      || (last == BIND_EXPR_BODY (body)
+         && BIND_EXPR_VARS (body) == NULL))
+    {
+      /* Do not warn if the return value of a statement expression is
+        unused.  */
+      if (CAN_HAVE_LOCATION_P (last))
+       TREE_NO_WARNING (last) = 1;
+      return last;
+    }
+
+  /* Extract the type of said expression.  */
+  type = TREE_TYPE (last);
+
+  /* If we're not returning a value at all, then the BIND_EXPR that
+     we already have is a fine expression to return.  */
+  if (!type || VOID_TYPE_P (type))
+    return body;
+
+  /* Now that we've located the expression containing the value, it seems
+     silly to make voidify_wrapper_expr repeat the process.  Create a
+     temporary of the appropriate type and stick it in a TARGET_EXPR.  */
+  tmp = create_tmp_var_raw (type, NULL);
+
+  /* Unwrap a no-op NOP_EXPR as added by c_finish_expr_stmt.  This avoids
+     tree_expr_nonnegative_p giving up immediately.  */
+  val = last;
+  if (TREE_CODE (val) == NOP_EXPR
+      && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0)))
+    val = TREE_OPERAND (val, 0);
+
+  *last_p = build2 (MODIFY_EXPR, void_type_node, tmp, val);
+  SET_EXPR_LOCUS (*last_p, EXPR_LOCUS (last));
+
+  return build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
+}
+
+/* Begin the scope of an identifier of variably modified type, scope
+   number SCOPE.  Jumping from outside this scope to inside it is not
+   permitted.  */
+
+void
+c_begin_vm_scope (unsigned int scope)
+{
+  struct c_label_context_vm *nstack;
+  struct c_label_list *glist;
+
+  gcc_assert (scope > 0);
+
+  /* At file_scope, we don't have to do any processing.  */
+  if (label_context_stack_vm == NULL)
+    return;
+
+  if (c_switch_stack && !c_switch_stack->blocked_vm)
+    c_switch_stack->blocked_vm = scope;
+  for (glist = label_context_stack_vm->labels_used;
+       glist != NULL;
+       glist = glist->next)
+    {
+      C_DECL_UNDEFINABLE_VM (glist->label) = 1;
+    }
+  nstack = XOBNEW (&parser_obstack, struct c_label_context_vm);
+  nstack->labels_def = NULL;
+  nstack->labels_used = NULL;
+  nstack->scope = scope;
+  nstack->next = label_context_stack_vm;
+  label_context_stack_vm = nstack;
+}
+
+/* End a scope which may contain identifiers of variably modified
+   type, scope number SCOPE.  */
+
+void
+c_end_vm_scope (unsigned int scope)
+{
+  if (label_context_stack_vm == NULL)
+    return;
+  if (c_switch_stack && c_switch_stack->blocked_vm == scope)
+    c_switch_stack->blocked_vm = 0;
+  /* We may have a number of nested scopes of identifiers with
+     variably modified type, all at this depth.  Pop each in turn.  */
+  while (label_context_stack_vm->scope == scope)
+    {
+      struct c_label_list *dlist, *glist, *glist_prev = NULL;
+
+      /* It is no longer possible to jump to labels defined within this
+        scope.  */
+      for (dlist = label_context_stack_vm->labels_def;
+          dlist != NULL;
+          dlist = dlist->next)
+       {
+         C_DECL_UNJUMPABLE_VM (dlist->label) = 1;
+       }
+      /* It is again possible to define labels with a goto just outside
+        this scope.  */
+      for (glist = label_context_stack_vm->next->labels_used;
+          glist != NULL;
+          glist = glist->next)
+       {
+         C_DECL_UNDEFINABLE_VM (glist->label) = 0;
+         glist_prev = glist;
+       }
+      if (glist_prev != NULL)
+       glist_prev->next = label_context_stack_vm->labels_used;
+      else
+       label_context_stack_vm->next->labels_used
+         = label_context_stack_vm->labels_used;
+      label_context_stack_vm = label_context_stack_vm->next;
+    }
+}
+\f
+/* Begin and end compound statements.  This is as simple as pushing
+   and popping new statement lists from the tree.  */
+
+tree
+c_begin_compound_stmt (bool do_scope)
+{
+  tree stmt = push_stmt_list ();
+  if (do_scope)
+    push_scope ();
+  return stmt;
+}
+
+tree
+c_end_compound_stmt (tree stmt, bool do_scope)
+{
+  tree block = NULL;
+
+  if (do_scope)
+    {
+      if (c_dialect_objc ())
+       objc_clear_super_receiver ();
+      block = pop_scope ();
+    }
+
+  stmt = pop_stmt_list (stmt);
+  stmt = c_build_bind_expr (block, stmt);
+
+  /* If this compound statement is nested immediately inside a statement
+     expression, then force a BIND_EXPR to be created.  Otherwise we'll
+     do the wrong thing for ({ { 1; } }) or ({ 1; { } }).  In particular,
+     STATEMENT_LISTs merge, and thus we can lose track of what statement
+     was really last.  */
+  if (cur_stmt_list
+      && STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
+      && TREE_CODE (stmt) != BIND_EXPR)
+    {
+      stmt = build3 (BIND_EXPR, void_type_node, NULL, stmt, NULL);
+      TREE_SIDE_EFFECTS (stmt) = 1;
+    }
+
+  return stmt;
+}
+
+/* Queue a cleanup.  CLEANUP is an expression/statement to be executed
+   when the current scope is exited.  EH_ONLY is true when this is not
+   meant to apply to normal control flow transfer.  */
+
+void
+push_cleanup (tree ARG_UNUSED (decl), tree cleanup, bool eh_only)
+{
+  enum tree_code code;
+  tree stmt, list;
+  bool stmt_expr;
+
+  code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
+  stmt = build_stmt (code, NULL, cleanup);
+  add_stmt (stmt);
+  stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
+  list = push_stmt_list ();
+  TREE_OPERAND (stmt, 0) = list;
+  STATEMENT_LIST_STMT_EXPR (list) = stmt_expr;
+}
+\f
+/* Build a binary-operation expression without default conversions.
+   CODE is the kind of expression to build.
+   LOCATION is the operator's location.
+   This function differs from `build' in several ways:
+   the data type of the result is computed and recorded in it,
+   warnings are generated if arg data types are invalid,
+   special handling for addition and subtraction of pointers is known,
+   and some optimization is done (operations on narrow ints
+   are done in the narrower type when that gives the same result).
+   Constant folding is also done before the result is returned.
+
+   Note that the operands will never have enumeral types, or function
+   or array types, because either they will have the default conversions
+   performed or they have both just been converted to some other type in which
+   the arithmetic is to be done.  */
+
+tree
+build_binary_op (location_t location, enum tree_code code,
+                tree orig_op0, tree orig_op1, int convert_p)
+{
+  tree type0, type1;
+  enum tree_code code0, code1;
+  tree op0, op1;
+  tree ret = error_mark_node;
+  const char *invalid_op_diag;
+
+  /* Expression code to give to the expression when it is built.
+     Normally this is CODE, which is what the caller asked for,
+     but in some special cases we change it.  */
+  enum tree_code resultcode = code;
+
+  /* Data type in which the computation is to be performed.
+     In the simplest cases this is the common type of the arguments.  */
+  tree result_type = NULL;
+
+  /* Nonzero means operands have already been type-converted
+     in whatever way is necessary.
+     Zero means they need to be converted to RESULT_TYPE.  */
+  int converted = 0;
+
+  /* Nonzero means create the expression with this type, rather than
+     RESULT_TYPE.  */
+  tree build_type = 0;
+
+  /* Nonzero means after finally constructing the expression
+     convert it to this type.  */
+  tree final_type = 0;
+
+  /* Nonzero if this is an operation like MIN or MAX which can
+     safely be computed in short if both args are promoted shorts.
+     Also implies COMMON.
+     -1 indicates a bitwise operation; this makes a difference
+     in the exact conditions for when it is safe to do the operation
+     in a narrower mode.  */
+  int shorten = 0;
+
+  /* Nonzero if this is a comparison operation;
+     if both args are promoted shorts, compare the original shorts.
+     Also implies COMMON.  */
+  int short_compare = 0;
+
+  /* Nonzero if this is a right-shift operation, which can be computed on the
+     original short and then promoted if the operand is a promoted short.  */
+  int short_shift = 0;
+
+  /* Nonzero means set RESULT_TYPE to the common type of the args.  */
+  int common = 0;
+
+  /* True means types are compatible as far as ObjC is concerned.  */
+  bool objc_ok;
+
+  if (location == UNKNOWN_LOCATION)
+    location = input_location;
+
+  if (convert_p)
+    {
+      op0 = default_conversion (orig_op0);
+      op1 = default_conversion (orig_op1);
+    }
+  else
+    {
+      op0 = orig_op0;
+      op1 = orig_op1;
+    }
+
+  type0 = TREE_TYPE (op0);
+  type1 = TREE_TYPE (op1);
+
+  /* The expression codes of the data types of the arguments tell us
+     whether the arguments are integers, floating, pointers, etc.  */
+  code0 = TREE_CODE (type0);
+  code1 = TREE_CODE (type1);
+
+  /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
+  STRIP_TYPE_NOPS (op0);
+  STRIP_TYPE_NOPS (op1);
+
+  /* If an error was already reported for one of the arguments,
+     avoid reporting another error.  */
+
+  if (code0 == ERROR_MARK || code1 == ERROR_MARK)
+    return error_mark_node;
+
+  if ((invalid_op_diag
+       = targetm.invalid_binary_op (code, type0, type1)))
+    {
+      error_at (location, invalid_op_diag);
+      return error_mark_node;
+    }
+
+  objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE);
+
+  switch (code)
+    {
+    case PLUS_EXPR:
+      /* Handle the pointer + int case.  */
+      if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+       {
+         ret = pointer_int_sum (PLUS_EXPR, op0, op1);
+         goto return_build_binary_op;
+       }
+      else if (code1 == POINTER_TYPE && code0 == INTEGER_TYPE)
+       {
+         ret = pointer_int_sum (PLUS_EXPR, op1, op0);
+         goto return_build_binary_op;
+       }
+      else
+       common = 1;
+      break;
+
+    case MINUS_EXPR:
+      /* Subtraction of two similar pointers.
+        We must subtract them as integers, then divide by object size.  */
+      if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
+         && comp_target_types (type0, type1))
+       {
+         ret = pointer_diff (op0, op1);
+         goto return_build_binary_op;
+       }
+      /* Handle pointer minus int.  Just like pointer plus int.  */
+      else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+       {
+         ret = pointer_int_sum (MINUS_EXPR, op0, op1);
+         goto return_build_binary_op;
+       }
+      else
+       common = 1;
+      break;
+
+    case MULT_EXPR:
+      common = 1;
+      break;
+
+    case TRUNC_DIV_EXPR:
+    case CEIL_DIV_EXPR:
+    case FLOOR_DIV_EXPR:
+    case ROUND_DIV_EXPR:
+    case EXACT_DIV_EXPR:
+      warn_for_div_by_zero (location, op1);
+
+      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
+          || code0 == FIXED_POINT_TYPE
+          || code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
+         && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
+             || code1 == FIXED_POINT_TYPE
+             || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE))
+       {
+         enum tree_code tcode0 = code0, tcode1 = code1;
+
+         if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
+           tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
+         if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
+           tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
+
+         if (!((tcode0 == INTEGER_TYPE && tcode1 == INTEGER_TYPE)
+             || (tcode0 == FIXED_POINT_TYPE && tcode1 == FIXED_POINT_TYPE)))
+           resultcode = RDIV_EXPR;
+         else
+           /* Although it would be tempting to shorten always here, that
+              loses on some targets, since the modulo instruction is
+              undefined if the quotient can't be represented in the
+              computation mode.  We shorten only if unsigned or if
+              dividing by something we know != -1.  */
+           shorten = (TYPE_UNSIGNED (TREE_TYPE (orig_op0))
+                      || (TREE_CODE (op1) == INTEGER_CST
+                          && !integer_all_onesp (op1)));
+         common = 1;
+       }
+      break;
+
+    case BIT_AND_EXPR:
+    case BIT_IOR_EXPR:
+    case BIT_XOR_EXPR:
+      if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
+       shorten = -1;
+      /* Allow vector types which are not floating point types.   */
+      else if (code0 == VECTOR_TYPE
+              && code1 == VECTOR_TYPE
+              && !VECTOR_FLOAT_TYPE_P (type0)
+              && !VECTOR_FLOAT_TYPE_P (type1))
+       common = 1;
+      break;
+
+    case TRUNC_MOD_EXPR:
+    case FLOOR_MOD_EXPR:
+      warn_for_div_by_zero (location, op1);
+
+      if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
+       {
+         /* Although it would be tempting to shorten always here, that loses
+            on some targets, since the modulo instruction is undefined if the
+            quotient can't be represented in the computation mode.  We shorten
+            only if unsigned or if dividing by something we know != -1.  */
+         shorten = (TYPE_UNSIGNED (TREE_TYPE (orig_op0))
+                    || (TREE_CODE (op1) == INTEGER_CST
+                        && !integer_all_onesp (op1)));
+         common = 1;
+       }
+      break;
+
+    case TRUTH_ANDIF_EXPR:
+    case TRUTH_ORIF_EXPR:
+    case TRUTH_AND_EXPR:
+    case TRUTH_OR_EXPR:
+    case TRUTH_XOR_EXPR:
+      if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
+          || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
+          || code0 == FIXED_POINT_TYPE)
+         && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
+             || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
+             || code1 == FIXED_POINT_TYPE))
+       {
+         /* Result of these operations is always an int,
+            but that does not mean the operands should be
+            converted to ints!  */
+         result_type = integer_type_node;
+         op0 = c_common_truthvalue_conversion (location, op0);
+         op1 = c_common_truthvalue_conversion (location, op1);
+         converted = 1;
+       }
+      break;
+
+      /* Shift operations: result has same type as first operand;
+        always convert second operand to int.
+        Also set SHORT_SHIFT if shifting rightward.  */
+
+    case RSHIFT_EXPR:
+      if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE)
+         && code1 == INTEGER_TYPE)
+       {
+         if (TREE_CODE (op1) == INTEGER_CST && skip_evaluation == 0)
+           {
+             if (tree_int_cst_sgn (op1) < 0)
+               warning (0, "right shift count is negative");
+             else
+               {
+                 if (!integer_zerop (op1))
+                   short_shift = 1;
+
+                 if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
+                   warning (0, "right shift count >= width of type");
+               }
            }
 
-         fieldtype = TREE_TYPE (constructor_fields);
-         if (fieldtype != error_mark_node)
-           fieldtype = TYPE_MAIN_VARIANT (fieldtype);
-         fieldcode = TREE_CODE (fieldtype);
-
-         /* Warn that traditional C rejects initialization of unions.
-            We skip the warning if the value is zero.  This is done
-            under the assumption that the zero initializer in user
-            code appears conditioned on e.g. __STDC__ to avoid
-            "missing initializer" warnings and relies on default
-            initialization to zero in the traditional C case.
-            We also skip the warning if the initializer is designated,
-            again on the assumption that this must be conditional on
-            __STDC__ anyway (and we've already complained about the
-            member-designator already).  */
-         if (warn_traditional && !in_system_header && !constructor_designated
-             && !(value && (integer_zerop (value) || real_zerop (value))))
-           warning ("traditional C rejects initialization of unions");
+         /* Use the type of the value to be shifted.  */
+         result_type = type0;
+         /* Convert the shift-count to an integer, regardless of size
+            of value being shifted.  */
+         if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
+           op1 = convert (integer_type_node, op1);
+         /* Avoid converting op1 to result_type later.  */
+         converted = 1;
+       }
+      break;
 
-         /* Accept a string constant to initialize a subarray.  */
-         if (value != 0
-             && fieldcode == ARRAY_TYPE
-             && TREE_CODE (TREE_TYPE (fieldtype)) == INTEGER_TYPE
-             && string_flag)
-           value = orig_value;
-         /* Otherwise, if we have come to a subaggregate,
-            and we don't have an element of its type, push into it.  */
-         else if (value != 0 && !constructor_no_implicit
-                  && value != error_mark_node
-                  && TYPE_MAIN_VARIANT (TREE_TYPE (value)) != fieldtype
-                  && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE
-                      || fieldcode == UNION_TYPE))
+    case LSHIFT_EXPR:
+      if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE)
+         && code1 == INTEGER_TYPE)
+       {
+         if (TREE_CODE (op1) == INTEGER_CST && skip_evaluation == 0)
            {
-             push_init_level (1);
-             continue;
+             if (tree_int_cst_sgn (op1) < 0)
+               warning (0, "left shift count is negative");
+
+             else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
+               warning (0, "left shift count >= width of type");
            }
 
-         if (value)
+         /* Use the type of the value to be shifted.  */
+         result_type = type0;
+         /* Convert the shift-count to an integer, regardless of size
+            of value being shifted.  */
+         if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
+           op1 = convert (integer_type_node, op1);
+         /* Avoid converting op1 to result_type later.  */
+         converted = 1;
+       }
+      break;
+
+    case EQ_EXPR:
+    case NE_EXPR:
+      if (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))
+       warning_at (location,
+                   OPT_Wfloat_equal,
+                   "comparing floating point with == or != is unsafe");
+      /* Result of comparison is always int,
+        but don't convert the args to int!  */
+      build_type = integer_type_node;
+      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
+          || code0 == FIXED_POINT_TYPE || code0 == COMPLEX_TYPE)
+         && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
+             || code1 == FIXED_POINT_TYPE || code1 == COMPLEX_TYPE))
+       short_compare = 1;
+      else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+       {
+         tree tt0 = TREE_TYPE (type0);
+         tree tt1 = TREE_TYPE (type1);
+         /* Anything compares with void *.  void * compares with anything.
+            Otherwise, the targets must be compatible
+            and both must be object or both incomplete.  */
+         if (comp_target_types (type0, type1))
+           result_type = common_pointer_type (type0, type1);
+         else if (VOID_TYPE_P (tt0))
            {
-             push_member_name (constructor_fields);
-             output_init_element (value, fieldtype, constructor_fields, 1);
-             RESTORE_SPELLING_DEPTH (constructor_depth);
+             /* op0 != orig_op0 detects the case of something
+                whose value is 0 but which isn't a valid null ptr const.  */
+             if (pedantic && !null_pointer_constant_p (orig_op0)
+                 && TREE_CODE (tt1) == FUNCTION_TYPE)
+               pedwarn (location, OPT_pedantic, "ISO C forbids "
+                        "comparison of %<void *%> with function pointer");
            }
-         else
-           /* Do the bookkeeping for an element that was
-              directly output as a constructor.  */
+         else if (VOID_TYPE_P (tt1))
            {
-             constructor_bit_index = DECL_SIZE (constructor_fields);
-             constructor_unfilled_fields = TREE_CHAIN (constructor_fields);
+             if (pedantic && !null_pointer_constant_p (orig_op1)
+                 && TREE_CODE (tt0) == FUNCTION_TYPE)
+               pedwarn (location, OPT_pedantic, "ISO C forbids "
+                        "comparison of %<void *%> with function pointer");
            }
+         else
+           /* Avoid warning about the volatile ObjC EH puts on decls.  */
+           if (!objc_ok)
+             pedwarn (location, 0,
+                      "comparison of distinct pointer types lacks a cast");
 
-         constructor_fields = 0;
+         if (result_type == NULL_TREE)
+           result_type = ptr_type_node;
        }
-      else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
+      else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
        {
-         tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
-         enum tree_code eltcode = TREE_CODE (elttype);
-
-         /* Accept a string constant to initialize a subarray.  */
-         if (value != 0
-             && eltcode == ARRAY_TYPE
-             && TREE_CODE (TREE_TYPE (elttype)) == INTEGER_TYPE
-             && string_flag)
-           value = orig_value;
-         /* Otherwise, if we have come to a subaggregate,
-            and we don't have an element of its type, push into it.  */
-         else if (value != 0 && !constructor_no_implicit
-                  && value != error_mark_node
-                  && TYPE_MAIN_VARIANT (TREE_TYPE (value)) != elttype
-                  && (eltcode == RECORD_TYPE || eltcode == ARRAY_TYPE
-                      || eltcode == UNION_TYPE))
-           {
-             push_init_level (1);
-             continue;
-           }
+         if (TREE_CODE (op0) == ADDR_EXPR
+             && decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)))
+           warning_at (location,
+                       OPT_Waddress, "the address of %qD will never be NULL",
+                       TREE_OPERAND (op0, 0));
+         result_type = type0;
+       }
+      else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
+       {
+         if (TREE_CODE (op1) == ADDR_EXPR
+             && decl_with_nonnull_addr_p (TREE_OPERAND (op1, 0)))
+           warning_at (location,
+                       OPT_Waddress, "the address of %qD will never be NULL",
+                       TREE_OPERAND (op1, 0));
+         result_type = type1;
+       }
+      else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+       {
+         result_type = type0;
+         pedwarn (location, 0, "comparison between pointer and integer");
+       }
+      else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
+       {
+         result_type = type1;
+         pedwarn (location, 0, "comparison between pointer and integer");
+       }
+      break;
 
-         if (constructor_max_index != 0
-             && (tree_int_cst_lt (constructor_max_index, constructor_index)
-                 || integer_all_onesp (constructor_max_index)))
+    case LE_EXPR:
+    case GE_EXPR:
+    case LT_EXPR:
+    case GT_EXPR:
+      build_type = integer_type_node;
+      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
+          || code0 == FIXED_POINT_TYPE)
+         && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
+             || code1 == FIXED_POINT_TYPE))
+       short_compare = 1;
+      else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+       {
+         if (comp_target_types (type0, type1))
            {
-             pedwarn_init ("excess elements in array initializer");
-             break;
+             result_type = common_pointer_type (type0, type1);
+             if (!COMPLETE_TYPE_P (TREE_TYPE (type0))
+                 != !COMPLETE_TYPE_P (TREE_TYPE (type1)))
+               pedwarn (location, 0,
+                        "comparison of complete and incomplete pointers");
+             else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
+               pedwarn (location, OPT_pedantic, "ISO C forbids "
+                        "ordered comparisons of pointers to functions");
            }
-
-         /* Now output the actual element.  */
-         if (value)
+         else
            {
-             push_array_bounds (tree_low_cst (constructor_index, 0));
-             output_init_element (value, elttype, constructor_index, 1);
-             RESTORE_SPELLING_DEPTH (constructor_depth);
+             result_type = ptr_type_node;
+             pedwarn (location, 0,
+                      "comparison of distinct pointer types lacks a cast");
            }
-
-         constructor_index
-           = size_binop (PLUS_EXPR, constructor_index, bitsize_one_node);
-
-         if (! value)
-           /* If we are doing the bookkeeping for an element that was
-              directly output as a constructor, we must update
-              constructor_unfilled_index.  */
-           constructor_unfilled_index = constructor_index;
        }
-      else if (TREE_CODE (constructor_type) == VECTOR_TYPE)
+      else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
        {
-         tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
+         result_type = type0;
+         if (pedantic)
+           pedwarn (location, OPT_pedantic, 
+                    "ordered comparison of pointer with integer zero");
+         else if (extra_warnings)
+           warning_at (location, OPT_Wextra,
+                    "ordered comparison of pointer with integer zero");
+       }
+      else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
+       {
+         result_type = type1;
+         pedwarn (location, OPT_pedantic, 
+                  "ordered comparison of pointer with integer zero");
+       }
+      else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+       {
+         result_type = type0;
+         pedwarn (location, 0, "comparison between pointer and integer");
+       }
+      else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
+       {
+         result_type = type1;
+         pedwarn (location, 0, "comparison between pointer and integer");
+       }
+      break;
 
-         /* Do a basic check of initializer size.  Note that vectors
-            always have a fixed size derived from their type.  */
-         if (tree_int_cst_lt (constructor_max_index, constructor_index))
-           {
-             pedwarn_init ("excess elements in vector initializer");
-             break;
-           }
+    default:
+      gcc_unreachable ();
+    }
 
-         /* Now output the actual element.  */
-         if (value)
-           output_init_element (value, elttype, constructor_index, 1);
+  if (code0 == ERROR_MARK || code1 == ERROR_MARK)
+    return error_mark_node;
 
-         constructor_index
-           = size_binop (PLUS_EXPR, constructor_index, bitsize_one_node);
+  if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE
+      && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
+         || !same_scalar_type_ignoring_signedness (TREE_TYPE (type0),
+                                                   TREE_TYPE (type1))))
+    {
+      binary_op_error (location, code, type0, type1);
+      return error_mark_node;
+    }
 
-         if (! value)
-           /* If we are doing the bookkeeping for an element that was
-              directly output as a constructor, we must update
-              constructor_unfilled_index.  */
-           constructor_unfilled_index = constructor_index;
-       }
+  if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
+       || code0 == FIXED_POINT_TYPE || code0 == VECTOR_TYPE)
+      &&
+      (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
+       || code1 == FIXED_POINT_TYPE || code1 == VECTOR_TYPE))
+    {
+      int none_complex = (code0 != COMPLEX_TYPE && code1 != COMPLEX_TYPE);
 
-      /* Handle the sole element allowed in a braced initializer
-        for a scalar variable.  */
-      else if (constructor_fields == 0)
+      if (shorten || common || short_compare)
        {
-         pedwarn_init ("excess elements in scalar initializer");
-         break;
+         result_type = c_common_type (type0, type1);
+         if (result_type == error_mark_node)
+           return error_mark_node;
        }
-      else
+
+      /* For certain operations (which identify themselves by shorten != 0)
+        if both args were extended from the same smaller type,
+        do the arithmetic in that type and then extend.
+
+        shorten !=0 and !=1 indicates a bitwise operation.
+        For them, this optimization is safe only if
+        both args are zero-extended or both are sign-extended.
+        Otherwise, we might change the result.
+        Eg, (short)-1 | (unsigned short)-1 is (int)-1
+        but calculated in (unsigned short) it would be (unsigned short)-1.  */
+
+      if (shorten && none_complex)
        {
-         if (value)
-           output_init_element (value, constructor_type, NULL_TREE, 1);
-         constructor_fields = 0;
+         final_type = result_type;
+         result_type = shorten_binary_op (result_type, op0, op1, 
+                                          shorten == -1);
        }
 
-      /* Handle range initializers either at this level or anywhere higher
-        in the designator stack.  */
-      if (constructor_range_stack)
+      /* Shifts can be shortened if shifting right.  */
+
+      if (short_shift)
        {
-         struct constructor_range_stack *p, *range_stack;
-         int finish = 0;
+         int unsigned_arg;
+         tree arg0 = get_narrower (op0, &unsigned_arg);
 
-         range_stack = constructor_range_stack;
-         constructor_range_stack = 0;
-         while (constructor_stack != range_stack->stack)
-           {
-             if (!constructor_stack->implicit)
-               abort ();
-             process_init_element (pop_init_level (1));
-           }
-         for (p = range_stack;
-              !p->range_end || tree_int_cst_equal (p->index, p->range_end);
-              p = p->prev)
+         final_type = result_type;
+
+         if (arg0 == op0 && final_type == TREE_TYPE (op0))
+           unsigned_arg = TYPE_UNSIGNED (TREE_TYPE (op0));
+
+         if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
+             && tree_int_cst_sgn (op1) > 0
+             /* We can shorten only if the shift count is less than the
+                number of bits in the smaller type size.  */
+             && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
+             /* We cannot drop an unsigned shift after sign-extension.  */
+             && (!TYPE_UNSIGNED (final_type) || unsigned_arg))
            {
-             if (!constructor_stack->implicit)
-               abort ();
-             process_init_element (pop_init_level (1));
+             /* Do an unsigned shift if the operand was zero-extended.  */
+             result_type
+               = c_common_signed_or_unsigned_type (unsigned_arg,
+                                                   TREE_TYPE (arg0));
+             /* Convert value-to-be-shifted to that type.  */
+             if (TREE_TYPE (op0) != result_type)
+               op0 = convert (result_type, op0);
+             converted = 1;
            }
+       }
 
-         p->index = size_binop (PLUS_EXPR, p->index, bitsize_one_node);
-         if (tree_int_cst_equal (p->index, p->range_end) && !p->prev)
-           finish = 1;
+      /* Comparison operations are shortened too but differently.
+        They identify themselves by setting short_compare = 1.  */
 
-         while (1)
-           {
-             constructor_index = p->index;
-             constructor_fields = p->fields;
-             if (finish && p->range_end && p->index == p->range_start)
-               {
-                 finish = 0;
-                 p->prev = 0;
-               }
-             p = p->next;
-             if (!p)
-               break;
-             push_init_level (2);
-             p->stack = constructor_stack;
-             if (p->range_end && tree_int_cst_equal (p->index, p->range_end))
-               p->index = p->range_start;
+      if (short_compare)
+       {
+         /* Don't write &op0, etc., because that would prevent op0
+            from being kept in a register.
+            Instead, make copies of the our local variables and
+            pass the copies by reference, then copy them back afterward.  */
+         tree xop0 = op0, xop1 = op1, xresult_type = result_type;
+         enum tree_code xresultcode = resultcode;
+         tree val
+           = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode);
+
+         if (val != 0)
+           {
+             ret = val;
+             goto return_build_binary_op;
            }
 
-         if (!finish)
-           constructor_range_stack = range_stack;
-         continue;
+         op0 = xop0, op1 = xop1;
+         converted = 1;
+         resultcode = xresultcode;
+
+         if (warn_sign_compare && !skip_evaluation)
+            {
+              warn_for_sign_compare (location, orig_op0, orig_op1, op0, op1, 
+                                     result_type, resultcode);
+           }
        }
+    }
 
-      break;
+  /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
+     If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
+     Then the expression will be built.
+     It will be given type FINAL_TYPE if that is nonzero;
+     otherwise, it will be given type RESULT_TYPE.  */
+
+  if (!result_type)
+    {
+      binary_op_error (location, code, TREE_TYPE (op0), TREE_TYPE (op1));
+      return error_mark_node;
     }
 
-  constructor_range_stack = 0;
+  if (!converted)
+    {
+      if (TREE_TYPE (op0) != result_type)
+       op0 = convert_and_check (result_type, op0);
+      if (TREE_TYPE (op1) != result_type)
+       op1 = convert_and_check (result_type, op1);
+
+      /* This can happen if one operand has a vector type, and the other
+        has a different type.  */
+      if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
+       return error_mark_node;
+    }
+
+  if (build_type == NULL_TREE)
+    build_type = result_type;
+
+  /* Treat expressions in initializers specially as they can't trap.  */
+  ret = require_constant_value ? fold_build2_initializer (resultcode,
+                                                         build_type,
+                                                         op0, op1)
+                              : fold_build2 (resultcode, build_type,
+                                             op0, op1);
+  if (final_type != 0)
+    ret = convert (final_type, ret);
+
+ return_build_binary_op:
+  gcc_assert (ret != error_mark_node);
+  protected_set_expr_location (ret, location);
+  return ret;
 }
-\f
-/* Build a simple asm-statement, from one string literal.  */
+
+
+/* Convert EXPR to be a truth-value, validating its type for this
+   purpose.  LOCATION is the source location for the expression.  */
+
 tree
-simple_asm_stmt (expr)
-     tree expr;
+c_objc_common_truthvalue_conversion (location_t location, tree expr)
 {
-  STRIP_NOPS (expr);
+  switch (TREE_CODE (TREE_TYPE (expr)))
+    {
+    case ARRAY_TYPE:
+      error_at (location, "used array that cannot be converted to pointer where scalar is required");
+      return error_mark_node;
 
-  if (TREE_CODE (expr) == ADDR_EXPR)
-    expr = TREE_OPERAND (expr, 0);
+    case RECORD_TYPE:
+      error_at (location, "used struct type value where scalar is required");
+      return error_mark_node;
 
-  if (TREE_CODE (expr) == STRING_CST)
-    {
-      tree stmt;
+    case UNION_TYPE:
+      error_at (location, "used union type value where scalar is required");
+      return error_mark_node;
 
-      if (TREE_CHAIN (expr))
-       expr = combine_strings (expr);
+    case FUNCTION_TYPE:
+      gcc_unreachable ();
 
-      /* Simple asm statements are treated as volatile.  */
-      stmt = add_stmt (build_stmt (ASM_STMT, ridpointers[(int) RID_VOLATILE],
-                                  expr, NULL_TREE, NULL_TREE, NULL_TREE));
-      ASM_INPUT_P (stmt) = 1;
-      return stmt;
+    default:
+      break;
     }
 
-  error ("argument of `asm' is not a constant string");
-  return NULL_TREE;
+  /* ??? Should we also give an error for void and vectors rather than
+     leaving those to give errors later?  */
+  return c_common_truthvalue_conversion (location, expr);
 }
+\f
 
-/* Build an asm-statement, whose components are a CV_QUALIFIER, a
-   STRING, some OUTPUTS, some INPUTS, and some CLOBBERS.  */
+/* Convert EXPR to a contained DECL, updating *TC, *TI and *SE as
+   required.  */
 
 tree
-build_asm_stmt (cv_qualifier, string, outputs, inputs, clobbers)
-     tree cv_qualifier;
-     tree string;
-     tree outputs;
-     tree inputs;
-     tree clobbers;
+c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se)
 {
-  tree tail;
-
-  if (TREE_CHAIN (string))
-    string = combine_strings (string);
-  if (TREE_CODE (string) != STRING_CST)
+  if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
     {
-      error ("asm template is not a string constant");
-      return NULL_TREE;
+      tree decl = COMPOUND_LITERAL_EXPR_DECL (expr);
+      /* Executing a compound literal inside a function reinitializes
+        it.  */
+      if (!TREE_STATIC (decl))
+       *se = true;
+      return decl;
     }
+  else
+    return expr;
+}
+\f
+/* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
 
-  if (cv_qualifier != NULL_TREE
-      && cv_qualifier != ridpointers[(int) RID_VOLATILE])
-    {
-      warning ("%s qualifier ignored on asm",
-              IDENTIFIER_POINTER (cv_qualifier));
-      cv_qualifier = NULL_TREE;
-    }
+tree
+c_begin_omp_parallel (void)
+{
+  tree block;
 
-  /* We can remove output conversions that change the type,
-     but not the mode.  */
-  for (tail = outputs; tail; tail = TREE_CHAIN (tail))
-    {
-      tree output = TREE_VALUE (tail);
+  keep_next_level ();
+  block = c_begin_compound_stmt (true);
 
-      STRIP_NOPS (output);
-      TREE_VALUE (tail) = output;
+  return block;
+}
 
-      /* Allow conversions as LHS here.  build_modify_expr as called below
-        will do the right thing with them.  */
-      while (TREE_CODE (output) == NOP_EXPR
-            || TREE_CODE (output) == CONVERT_EXPR
-            || TREE_CODE (output) == FLOAT_EXPR
-            || TREE_CODE (output) == FIX_TRUNC_EXPR
-            || TREE_CODE (output) == FIX_FLOOR_EXPR
-            || TREE_CODE (output) == FIX_ROUND_EXPR
-            || TREE_CODE (output) == FIX_CEIL_EXPR)
-       output = TREE_OPERAND (output, 0);
+/* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound statement.  */
 
-      lvalue_or_else (TREE_VALUE (tail), "invalid lvalue in asm statement");
-    }
+tree
+c_finish_omp_parallel (tree clauses, tree block)
+{
+  tree stmt;
 
-  /* Remove output conversions that change the type but not the mode.  */
-  for (tail = outputs; tail; tail = TREE_CHAIN (tail))
-    {
-      tree output = TREE_VALUE (tail);
-      STRIP_NOPS (output);
-      TREE_VALUE (tail) = output;
-    }
+  block = c_end_compound_stmt (block, true);
 
-  /* Perform default conversions on array and function inputs. 
-     Don't do this for other types as it would screw up operands
-     expected to be in memory.  */
-  for (tail = inputs; tail; tail = TREE_CHAIN (tail))
-    TREE_VALUE (tail) = default_function_array_conversion (TREE_VALUE (tail));
+  stmt = make_node (OMP_PARALLEL);
+  TREE_TYPE (stmt) = void_type_node;
+  OMP_PARALLEL_CLAUSES (stmt) = clauses;
+  OMP_PARALLEL_BODY (stmt) = block;
 
-  return add_stmt (build_stmt (ASM_STMT, cv_qualifier, string,
-                              outputs, inputs, clobbers));
+  return add_stmt (stmt);
 }
 
-/* Expand an ASM statement with operands, handling output operands
-   that are not variables or INDIRECT_REFS by transforming such
-   cases into cases that expand_asm_operands can handle.
-
-   Arguments are same as for expand_asm_operands.  */
+/* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
 
-void
-c_expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
-     tree string, outputs, inputs, clobbers;
-     int vol;
-     const char *filename;
-     int line;
+tree
+c_begin_omp_task (void)
 {
-  int noutputs = list_length (outputs);
-  int i;
-  /* o[I] is the place that output number I should be written.  */
-  tree *o = (tree *) alloca (noutputs * sizeof (tree));
-  tree tail;
+  tree block;
 
-  /* Record the contents of OUTPUTS before it is modified.  */
-  for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
-    o[i] = TREE_VALUE (tail);
+  keep_next_level ();
+  block = c_begin_compound_stmt (true);
 
-  /* Generate the ASM_OPERANDS insn; store into the TREE_VALUEs of
-     OUTPUTS some trees for where the values were actually stored.  */
-  expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line);
+  return block;
+}
 
-  /* Copy all the intermediate outputs into the specified outputs.  */
-  for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
-    {
-      if (o[i] != TREE_VALUE (tail))
-       {
-         expand_expr (build_modify_expr (o[i], NOP_EXPR, TREE_VALUE (tail)),
-                      NULL_RTX, VOIDmode, EXPAND_NORMAL);
-         free_temp_slots ();
+/* Generate OMP_TASK, with CLAUSES and BLOCK as its compound statement.  */
 
-         /* Restore the original value so that it's correct the next
-            time we expand this function.  */
-         TREE_VALUE (tail) = o[i];
-       }
-      /* Detect modification of read-only values.
-        (Otherwise done by build_modify_expr.)  */
-      else
-       {
-         tree type = TREE_TYPE (o[i]);
-         if (TREE_READONLY (o[i])
-             || TYPE_READONLY (type)
-             || ((TREE_CODE (type) == RECORD_TYPE
-                  || TREE_CODE (type) == UNION_TYPE)
-                 && C_TYPE_FIELDS_READONLY (type)))
-           readonly_warning (o[i], "modification by `asm'");
-       }
-    }
+tree
+c_finish_omp_task (tree clauses, tree block)
+{
+  tree stmt;
+
+  block = c_end_compound_stmt (block, true);
+
+  stmt = make_node (OMP_TASK);
+  TREE_TYPE (stmt) = void_type_node;
+  OMP_TASK_CLAUSES (stmt) = clauses;
+  OMP_TASK_BODY (stmt) = block;
 
-  /* Those MODIFY_EXPRs could do autoincrements.  */
-  emit_queue ();
+  return add_stmt (stmt);
 }
-\f
-/* Expand a C `return' statement.
-   RETVAL is the expression for what to return,
-   or a null pointer for `return;' with no value.  */
+
+/* For all elements of CLAUSES, validate them vs OpenMP constraints.
+   Remove any elements from the list that are invalid.  */
 
 tree
-c_expand_return (retval)
-     tree retval;
+c_finish_omp_clauses (tree clauses)
 {
-  tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl));
+  bitmap_head generic_head, firstprivate_head, lastprivate_head;
+  tree c, t, *pc = &clauses;
+  const char *name;
 
-  if (TREE_THIS_VOLATILE (current_function_decl))
-    warning ("function declared `noreturn' has a `return' statement");
+  bitmap_obstack_initialize (NULL);
+  bitmap_initialize (&generic_head, &bitmap_default_obstack);
+  bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
+  bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
 
-  if (!retval)
-    {
-      current_function_returns_null = 1;
-      if ((warn_return_type || flag_isoc99)
-         && valtype != 0 && TREE_CODE (valtype) != VOID_TYPE)
-       pedwarn_c99 ("`return' with no value, in function returning non-void");
-    }
-  else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE)
-    {
-      current_function_returns_null = 1;
-      if (pedantic || TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
-       pedwarn ("`return' with a value, in function returning void");
-    }
-  else
+  for (pc = &clauses, c = clauses; c ; c = *pc)
     {
-      tree t = convert_for_assignment (valtype, retval, _("return"),
-                                      NULL_TREE, NULL_TREE, 0);
-      tree res = DECL_RESULT (current_function_decl);
-      tree inner;
+      bool remove = false;
+      bool need_complete = false;
+      bool need_implicitly_determined = false;
 
-      current_function_returns_value = 1;
-      if (t == error_mark_node)
-       return NULL_TREE;
+      switch (OMP_CLAUSE_CODE (c))
+       {
+       case OMP_CLAUSE_SHARED:
+         name = "shared";
+         need_implicitly_determined = true;
+         goto check_dup_generic;
+
+       case OMP_CLAUSE_PRIVATE:
+         name = "private";
+         need_complete = true;
+         need_implicitly_determined = true;
+         goto check_dup_generic;
+
+       case OMP_CLAUSE_REDUCTION:
+         name = "reduction";
+         need_implicitly_determined = true;
+         t = OMP_CLAUSE_DECL (c);
+         if (AGGREGATE_TYPE_P (TREE_TYPE (t))
+             || POINTER_TYPE_P (TREE_TYPE (t)))
+           {
+             error ("%qE has invalid type for %<reduction%>", t);
+             remove = true;
+           }
+         else if (FLOAT_TYPE_P (TREE_TYPE (t)))
+           {
+             enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c);
+             const char *r_name = NULL;
 
-      inner = t = convert (TREE_TYPE (res), t);
+             switch (r_code)
+               {
+               case PLUS_EXPR:
+               case MULT_EXPR:
+               case MINUS_EXPR:
+                 break;
+               case BIT_AND_EXPR:
+                 r_name = "&";
+                 break;
+               case BIT_XOR_EXPR:
+                 r_name = "^";
+                 break;
+               case BIT_IOR_EXPR:
+                 r_name = "|";
+                 break;
+               case TRUTH_ANDIF_EXPR:
+                 r_name = "&&";
+                 break;
+               case TRUTH_ORIF_EXPR:
+                 r_name = "||";
+                 break;
+               default:
+                 gcc_unreachable ();
+               }
+             if (r_name)
+               {
+                 error ("%qE has invalid type for %<reduction(%s)%>",
+                        t, r_name);
+                 remove = true;
+               }
+           }
+         goto check_dup_generic;
 
-      /* Strip any conversions, additions, and subtractions, and see if
-        we are returning the address of a local variable.  Warn if so.  */
-      while (1)
-       {
-         switch (TREE_CODE (inner))
+       case OMP_CLAUSE_COPYPRIVATE:
+         name = "copyprivate";
+         goto check_dup_generic;
+
+       case OMP_CLAUSE_COPYIN:
+         name = "copyin";
+         t = OMP_CLAUSE_DECL (c);
+         if (TREE_CODE (t) != VAR_DECL || !DECL_THREAD_LOCAL_P (t))
            {
-           case NOP_EXPR:   case NON_LVALUE_EXPR:  case CONVERT_EXPR:
-           case PLUS_EXPR:
-             inner = TREE_OPERAND (inner, 0);
-             continue;
+             error ("%qE must be %<threadprivate%> for %<copyin%>", t);
+             remove = true;
+           }
+         goto check_dup_generic;
 
-           case MINUS_EXPR:
-             /* If the second operand of the MINUS_EXPR has a pointer
-                type (or is converted from it), this may be valid, so
-                don't give a warning.  */
-             {
-               tree op1 = TREE_OPERAND (inner, 1);
+       check_dup_generic:
+         t = OMP_CLAUSE_DECL (c);
+         if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+           {
+             error ("%qE is not a variable in clause %qs", t, name);
+             remove = true;
+           }
+         else if (bitmap_bit_p (&generic_head, DECL_UID (t))
+                  || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
+                  || bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
+           {
+             error ("%qE appears more than once in data clauses", t);
+             remove = true;
+           }
+         else
+           bitmap_set_bit (&generic_head, DECL_UID (t));
+         break;
 
-               while (! POINTER_TYPE_P (TREE_TYPE (op1))
-                      && (TREE_CODE (op1) == NOP_EXPR
-                          || TREE_CODE (op1) == NON_LVALUE_EXPR
-                          || TREE_CODE (op1) == CONVERT_EXPR))
-                 op1 = TREE_OPERAND (op1, 0);
+       case OMP_CLAUSE_FIRSTPRIVATE:
+         name = "firstprivate";
+         t = OMP_CLAUSE_DECL (c);
+         need_complete = true;
+         need_implicitly_determined = true;
+         if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+           {
+             error ("%qE is not a variable in clause %<firstprivate%>", t);
+             remove = true;
+           }
+         else if (bitmap_bit_p (&generic_head, DECL_UID (t))
+                  || bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
+           {
+             error ("%qE appears more than once in data clauses", t);
+             remove = true;
+           }
+         else
+           bitmap_set_bit (&firstprivate_head, DECL_UID (t));
+         break;
 
-               if (POINTER_TYPE_P (TREE_TYPE (op1)))
-                 break;
+       case OMP_CLAUSE_LASTPRIVATE:
+         name = "lastprivate";
+         t = OMP_CLAUSE_DECL (c);
+         need_complete = true;
+         need_implicitly_determined = true;
+         if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
+           {
+             error ("%qE is not a variable in clause %<lastprivate%>", t);
+             remove = true;
+           }
+         else if (bitmap_bit_p (&generic_head, DECL_UID (t))
+                  || bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
+           {
+             error ("%qE appears more than once in data clauses", t);
+             remove = true;
+           }
+         else
+           bitmap_set_bit (&lastprivate_head, DECL_UID (t));
+         break;
 
-               inner = TREE_OPERAND (inner, 0);
-               continue;
-             }
-             
-           case ADDR_EXPR:
-             inner = TREE_OPERAND (inner, 0);
+       case OMP_CLAUSE_IF:
+       case OMP_CLAUSE_NUM_THREADS:
+       case OMP_CLAUSE_SCHEDULE:
+       case OMP_CLAUSE_NOWAIT:
+       case OMP_CLAUSE_ORDERED:
+       case OMP_CLAUSE_DEFAULT:
+       case OMP_CLAUSE_UNTIED:
+       case OMP_CLAUSE_COLLAPSE:
+         pc = &OMP_CLAUSE_CHAIN (c);
+         continue;
 
-             while (TREE_CODE_CLASS (TREE_CODE (inner)) == 'r')
-               inner = TREE_OPERAND (inner, 0);
+       default:
+         gcc_unreachable ();
+       }
 
-             if (TREE_CODE (inner) == VAR_DECL
-                 && ! DECL_EXTERNAL (inner)
-                 && ! TREE_STATIC (inner)
-                 && DECL_CONTEXT (inner) == current_function_decl)
-               warning ("function returns address of local variable");
-             break;
+      if (!remove)
+       {
+         t = OMP_CLAUSE_DECL (c);
 
-           default:
-             break;
+         if (need_complete)
+           {
+             t = require_complete_type (t);
+             if (t == error_mark_node)
+               remove = true;
            }
 
-         break;
+         if (need_implicitly_determined)
+           {
+             const char *share_name = NULL;
+
+             if (TREE_CODE (t) == VAR_DECL && DECL_THREAD_LOCAL_P (t))
+               share_name = "threadprivate";
+             else switch (c_omp_predetermined_sharing (t))
+               {
+               case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
+                 break;
+               case OMP_CLAUSE_DEFAULT_SHARED:
+                 share_name = "shared";
+                 break;
+               case OMP_CLAUSE_DEFAULT_PRIVATE:
+                 share_name = "private";
+                 break;
+               default:
+                 gcc_unreachable ();
+               }
+             if (share_name)
+               {
+                 error ("%qE is predetermined %qs for %qs",
+                        t, share_name, name);
+                 remove = true;
+               }
+           }
        }
 
-      retval = build (MODIFY_EXPR, TREE_TYPE (res), res, t);
+      if (remove)
+       *pc = OMP_CLAUSE_CHAIN (c);
+      else
+       pc = &OMP_CLAUSE_CHAIN (c);
     }
 
- return add_stmt (build_return_stmt (retval));
+  bitmap_obstack_release (NULL);
+  return clauses;
 }
-\f
-struct c_switch {
-  /* The SWITCH_STMT being built.  */
-  tree switch_stmt;
-  /* A splay-tree mapping the low element of a case range to the high
-     element, or NULL_TREE if there is no high element.  Used to
-     determine whether or not a new case label duplicates an old case
-     label.  We need a tree, rather than simply a hash table, because
-     of the GNU case range extension.  */
-  splay_tree cases;
-  /* The next node on the stack.  */
-  struct c_switch *next;
-};
-
-/* A stack of the currently active switch statements.  The innermost
-   switch statement is on the top of the stack.  There is no need to
-   mark the stack for garbage collection because it is only active
-   during the processing of the body of a function, and we never
-   collect at that point.  */
-
-static struct c_switch *switch_stack;
 
-/* Start a C switch statement, testing expression EXP.  Return the new
-   SWITCH_STMT.  */
+/* Make a variant type in the proper way for C/C++, propagating qualifiers
+   down to the element type of an array.  */
 
 tree
-c_start_case (exp)
-     tree exp;
+c_build_qualified_type (tree type, int type_quals)
 {
-  enum tree_code code;
-  tree type, orig_type = error_mark_node;
-  struct c_switch *cs;
+  if (type == error_mark_node)
+    return type;
 
-  if (exp != error_mark_node)
+  if (TREE_CODE (type) == ARRAY_TYPE)
     {
-      code = TREE_CODE (TREE_TYPE (exp));
-      orig_type = TREE_TYPE (exp);
+      tree t;
+      tree element_type = c_build_qualified_type (TREE_TYPE (type),
+                                                 type_quals);
 
-      if (! INTEGRAL_TYPE_P (orig_type)
-         && code != ERROR_MARK)
+      /* See if we already have an identically qualified type.  */
+      for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
        {
-         error ("switch quantity not an integer");
-         exp = integer_zero_node;
+         if (TYPE_QUALS (strip_array_types (t)) == type_quals
+             && TYPE_NAME (t) == TYPE_NAME (type)
+             && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
+             && attribute_list_equal (TYPE_ATTRIBUTES (t),
+                                      TYPE_ATTRIBUTES (type)))
+           break;
        }
-      else
+      if (!t)
        {
-         type = TYPE_MAIN_VARIANT (TREE_TYPE (exp));
-
-         if (warn_traditional && !in_system_header
-             && (type == long_integer_type_node
-                 || type == long_unsigned_type_node))
-           warning ("`long' switch expression not converted to `int' in ISO C");
-
-         exp = default_conversion (exp);
-         type = TREE_TYPE (exp);
+          tree domain = TYPE_DOMAIN (type);
+
+         t = build_variant_type_copy (type);
+         TREE_TYPE (t) = element_type;
+
+          if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
+              || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain)))
+            SET_TYPE_STRUCTURAL_EQUALITY (t);
+          else if (TYPE_CANONICAL (element_type) != element_type
+                   || (domain && TYPE_CANONICAL (domain) != domain))
+            {
+              tree unqualified_canon 
+                = build_array_type (TYPE_CANONICAL (element_type),
+                                    domain? TYPE_CANONICAL (domain) 
+                                          : NULL_TREE);
+              TYPE_CANONICAL (t) 
+                = c_build_qualified_type (unqualified_canon, type_quals);
+            }
+          else
+            TYPE_CANONICAL (t) = t;
        }
+      return t;
     }
 
-  /* Add this new SWITCH_STMT to the stack.  */
-  cs = (struct c_switch *) xmalloc (sizeof (*cs));
-  cs->switch_stmt = build_stmt (SWITCH_STMT, exp, NULL_TREE, orig_type);
-  cs->cases = splay_tree_new (case_compare, NULL, NULL);
-  cs->next = switch_stack;
-  switch_stack = cs;
-
-  return add_stmt (switch_stack->switch_stmt);
-}
-
-/* Process a case label.  */
-
-tree
-do_case (low_value, high_value)
-     tree low_value;
-     tree high_value;
-{
-  tree label = NULL_TREE;
-
-  if (switch_stack)
+  /* A restrict-qualified pointer type must be a pointer to object or
+     incomplete type.  Note that the use of POINTER_TYPE_P also allows
+     REFERENCE_TYPEs, which is appropriate for C++.  */
+  if ((type_quals & TYPE_QUAL_RESTRICT)
+      && (!POINTER_TYPE_P (type)
+         || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
     {
-      label = c_add_case_label (switch_stack->cases, 
-                               SWITCH_COND (switch_stack->switch_stmt), 
-                               low_value, high_value);
-      if (label == error_mark_node)
-       label = NULL_TREE;
+      error ("invalid use of %<restrict%>");
+      type_quals &= ~TYPE_QUAL_RESTRICT;
     }
-  else if (low_value)
-    error ("case label not within a switch statement");
-  else
-    error ("`default' label not within a switch statement");
-
-  return label;
-}
 
-/* Finish the switch statement.  */
-
-void
-c_finish_case ()
-{
-  struct c_switch *cs = switch_stack;
-
-  RECHAIN_STMTS (cs->switch_stmt, SWITCH_BODY (cs->switch_stmt)); 
-
-  /* Pop the stack.  */
-  switch_stack = switch_stack->next;
-  splay_tree_delete (cs->cases);
-  free (cs);
+  return build_qualified_type (type, type_quals);
 }