OSDN Git Service

2010-04-29 Jon Grant <04@jguk.org>
[pf3gnuchains/gcc-fork.git] / gcc / c-typeck.c
index 1bac4fd..96b2ab1 100644 (file)
@@ -1953,7 +1953,7 @@ default_conversion (tree exp)
   return exp;
 }
 \f
-/* Look up COMPONENT in a structure or union TYPE.
+/* Look up COMPONENT in a structure or union DECL.
 
    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
@@ -1963,8 +1963,9 @@ default_conversion (tree exp)
    unions, the list steps down the chain to the component.  */
 
 static tree
-lookup_field (tree type, tree component)
+lookup_field (tree decl, tree component)
 {
+  tree type = TREE_TYPE (decl);
   tree field;
 
   /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
@@ -1994,7 +1995,7 @@ lookup_field (tree type, tree component)
                  if (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
                      || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
                    {
-                     tree anon = lookup_field (TREE_TYPE (field), component);
+                     tree anon = lookup_field (field, component);
 
                      if (anon)
                        return tree_cons (NULL_TREE, field, anon);
@@ -2030,7 +2031,7 @@ lookup_field (tree type, tree component)
              && (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
                  || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE))
            {
-             tree anon = lookup_field (TREE_TYPE (field), component);
+             tree anon = lookup_field (field, component);
 
              if (anon)
                return tree_cons (NULL_TREE, field, anon);
@@ -2073,7 +2074,7 @@ build_component_ref (location_t loc, tree datum, tree component)
          return error_mark_node;
        }
 
-      field = lookup_field (type, component);
+      field = lookup_field (datum, component);
 
       if (!field)
        {
@@ -6982,7 +6983,7 @@ set_init_index (tree first, tree last,
 void
 set_init_label (tree fieldname, struct obstack * braced_init_obstack)
 {
-  tree field;
+  tree tail;
 
   if (set_designator (0, braced_init_obstack))
     return;
@@ -6996,26 +6997,23 @@ set_init_label (tree fieldname, struct obstack * braced_init_obstack)
       return;
     }
 
-  field = lookup_field (constructor_type, fieldname);
+  for (tail = TYPE_FIELDS (constructor_type); tail;
+       tail = TREE_CHAIN (tail))
+    {
+      if (DECL_NAME (tail) == fieldname)
+       break;
+    }
 
-  if (field == 0)
+  if (tail == 0)
     error ("unknown field %qE specified in initializer", fieldname);
   else
-    do
-      {
-       constructor_fields = TREE_VALUE (field);
-       designator_depth++;
-       designator_erroneous = 0;
-       if (constructor_range_stack)
-         push_range_stack (NULL_TREE, braced_init_obstack);
-       field = TREE_CHAIN (field);
-       if (field)
-         {
-           if (set_designator (0, braced_init_obstack))
-             return;
-         }
-      }
-    while (field != NULL_TREE);
+    {
+      constructor_fields = tail;
+      designator_depth++;
+      designator_erroneous = 0;
+      if (constructor_range_stack)
+       push_range_stack (NULL_TREE, braced_init_obstack);
+    }
 }
 \f
 /* Add a new initializer to the tree of pending initializers.  PURPOSE
@@ -9627,11 +9625,6 @@ build_binary_op (location_t location, enum tree_code code,
              else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
                pedwarn (location, OPT_pedantic, "ISO C forbids "
                         "ordered comparisons of pointers to functions");
-             else if (null_pointer_constant_p (orig_op0)
-                      || null_pointer_constant_p (orig_op1))
-               warning_at (location, OPT_Wextra,
-                           "ordered comparison of pointer with null pointer");
-
            }
          else if (!addr_space_superset (as0, as1, &as_common))
            {
@@ -9656,17 +9649,13 @@ build_binary_op (location_t location, enum tree_code code,
                     "ordered comparison of pointer with integer zero");
          else if (extra_warnings)
            warning_at (location, OPT_Wextra,
-                       "ordered comparison of pointer with integer zero");
+                    "ordered comparison of pointer with integer zero");
        }
       else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
        {
          result_type = type1;
-         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");
+         pedwarn (location, OPT_pedantic,
+                  "ordered comparison of pointer with integer zero");
        }
       else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
        {