OSDN Git Service

2009-08-17 Emmanuel Briot <briot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / c-parser.c
index 6c7b830..43b0c8c 100644 (file)
@@ -1447,6 +1447,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
     {
       struct c_typespec t;
       tree attrs;
+      location_t loc = c_parser_peek_token (parser)->location;
       if (c_parser_next_token_is (parser, CPP_NAME))
        {
          tree value = c_parser_peek_token (parser)->value;
@@ -1482,7 +1483,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
              t.expr = NULL_TREE;
              t.expr_const_operands = true;
            }
-         declspecs_add_type (specs, t);
+         declspecs_add_type (loc, specs, t);
          continue;
        }
       if (c_parser_next_token_is (parser, CPP_LESS))
@@ -1498,7 +1499,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
          t.spec = objc_get_protocol_qualified_type (NULL_TREE, proto);
          t.expr = NULL_TREE;
          t.expr_const_operands = true;
-         declspecs_add_type (specs, t);
+         declspecs_add_type (loc, specs, t);
          continue;
        }
       gcc_assert (c_parser_next_token_is (parser, CPP_KEYWORD));
@@ -1547,7 +1548,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
          t.spec = c_parser_peek_token (parser)->value;
          t.expr = NULL_TREE;
          t.expr_const_operands = true;
-         declspecs_add_type (specs, t);
+         declspecs_add_type (loc, specs, t);
          c_parser_consume_token (parser);
          break;
        case RID_ENUM:
@@ -1556,7 +1557,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
          attrs_ok = true;
          seen_type = true;
          t = c_parser_enum_specifier (parser);
-         declspecs_add_type (specs, t);
+         declspecs_add_type (loc, specs, t);
          break;
        case RID_STRUCT:
        case RID_UNION:
@@ -1566,7 +1567,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
          seen_type = true;
          t = c_parser_struct_or_union_specifier (parser);
           invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, t.spec);
-         declspecs_add_type (specs, t);
+         declspecs_add_type (loc, specs, t);
          break;
        case RID_TYPEOF:
          /* ??? The old parser rejected typeof after other type
@@ -1577,7 +1578,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
          attrs_ok = true;
          seen_type = true;
          t = c_parser_typeof_specifier (parser);
-         declspecs_add_type (specs, t);
+         declspecs_add_type (loc, specs, t);
          break;
        case RID_CONST:
        case RID_VOLATILE:
@@ -1815,10 +1816,8 @@ c_parser_struct_or_union_specifier (c_parser *parser)
     {
       /* Parse a struct or union definition.  Start the scope of the
         tag before parsing components.  */
-      bool in_struct;
-      VEC(tree,heap) *struct_types;
-      tree type = start_struct (struct_loc, code, ident,
-                               &in_struct, &struct_types);
+      struct c_struct_parse_info *struct_info;
+      tree type = start_struct (struct_loc, code, ident, &struct_info);
       tree postfix_attrs;
       /* We chain the components in reverse order, then put them in
         forward order at the end.  Each struct-declaration may
@@ -1908,8 +1907,7 @@ c_parser_struct_or_union_specifier (c_parser *parser)
        }
       postfix_attrs = c_parser_attributes (parser);
       ret.spec = finish_struct (struct_loc, type, nreverse (contents),
-                               chainon (attrs, postfix_attrs),
-                               in_struct, struct_types);
+                               chainon (attrs, postfix_attrs), struct_info);
       ret.kind = ctsk_tagdef;
       ret.expr = NULL_TREE;
       ret.expr_const_operands = true;
@@ -2102,18 +2100,18 @@ c_parser_typeof_specifier (c_parser *parser)
   ret.expr_const_operands = true;
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_TYPEOF));
   c_parser_consume_token (parser);
-  skip_evaluation++;
+  c_inhibit_evaluation_warnings++;
   in_typeof++;
   if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
     {
-      skip_evaluation--;
+      c_inhibit_evaluation_warnings--;
       in_typeof--;
       return ret;
     }
   if (c_parser_next_token_starts_typename (parser))
     {
       struct c_type_name *type = c_parser_type_name (parser);
-      skip_evaluation--;
+      c_inhibit_evaluation_warnings--;
       in_typeof--;
       if (type != NULL)
        {
@@ -2126,7 +2124,7 @@ c_parser_typeof_specifier (c_parser *parser)
       bool was_vm;
       location_t here = c_parser_peek_token (parser)->location;
       struct c_expr expr = c_parser_expression (parser);
-      skip_evaluation--;
+      c_inhibit_evaluation_warnings--;
       in_typeof--;
       if (TREE_CODE (expr.value) == COMPONENT_REF
          && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
@@ -4568,23 +4566,24 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after)
        exp1.value = build1 (EXCESS_PRECISION_EXPR, eptype, exp1.value);
       exp1.original_type = NULL;
       cond.value = c_objc_common_truthvalue_conversion (cond_loc, exp1.value);
-      skip_evaluation += cond.value == truthvalue_true_node;
+      c_inhibit_evaluation_warnings += cond.value == truthvalue_true_node;
     }
   else
     {
       cond.value
        = c_objc_common_truthvalue_conversion
        (cond_loc, default_conversion (cond.value));
-      skip_evaluation += cond.value == truthvalue_false_node;
+      c_inhibit_evaluation_warnings += cond.value == truthvalue_false_node;
       exp1 = c_parser_expression_conv (parser);
-      skip_evaluation += ((cond.value == truthvalue_true_node)
-                         - (cond.value == truthvalue_false_node));
+      c_inhibit_evaluation_warnings +=
+       ((cond.value == truthvalue_true_node)
+        - (cond.value == truthvalue_false_node));
     }
 
   colon_loc = c_parser_peek_token (parser)->location;
   if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
     {
-      skip_evaluation -= cond.value == truthvalue_true_node;
+      c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node;
       ret.value = error_mark_node;
       ret.original_code = ERROR_MARK;
       ret.original_type = NULL;
@@ -4595,10 +4594,11 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after)
     exp2 = c_parser_conditional_expression (parser, NULL);
     exp2 = default_function_array_conversion (exp2_loc, exp2);
   }
-  skip_evaluation -= cond.value == truthvalue_true_node;
+  c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node;
   ret.value = build_conditional_expr (colon_loc, cond.value,
                                      cond.original_code == C_MAYBE_CONST_EXPR,
-                                     exp1.value, exp2.value);
+                                     exp1.value, exp1.original_type,
+                                     exp2.value, exp2.original_type);
   ret.original_code = ERROR_MARK;
   if (exp1.value == error_mark_node || exp2.value == error_mark_node)
     ret.original_type = NULL;
@@ -4696,8 +4696,8 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
      the stack has lower precedence than the new operator or there is
      only one element on the stack; then the top expression is the LHS
      of the new operator.  In the case of logical AND and OR
-     expressions, we also need to adjust skip_evaluation as
-     appropriate when the operators are pushed and popped.  */
+     expressions, we also need to adjust c_inhibit_evaluation_warnings
+     as appropriate when the operators are pushed and popped.  */
 
   /* The precedence levels, where 0 is a dummy lowest level used for
      the bottom of the stack.  */
@@ -4734,10 +4734,12 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
     switch (stack[sp].op)                                                    \
       {                                                                              \
       case TRUTH_ANDIF_EXPR:                                                 \
-       skip_evaluation -= stack[sp - 1].expr.value == truthvalue_false_node; \
+       c_inhibit_evaluation_warnings -= (stack[sp - 1].expr.value            \
+                                         == truthvalue_false_node);          \
        break;                                                                \
       case TRUTH_ORIF_EXPR:                                                  \
-       skip_evaluation -= stack[sp - 1].expr.value == truthvalue_true_node;  \
+       c_inhibit_evaluation_warnings -= (stack[sp - 1].expr.value            \
+                                         == truthvalue_true_node);           \
        break;                                                                \
       default:                                                               \
        break;                                                                \
@@ -4855,7 +4857,8 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
                                                 stack[sp].expr);
          stack[sp].expr.value = c_objc_common_truthvalue_conversion
            (stack[sp].loc, default_conversion (stack[sp].expr.value));
-         skip_evaluation += stack[sp].expr.value == truthvalue_false_node;
+         c_inhibit_evaluation_warnings += (stack[sp].expr.value
+                                           == truthvalue_false_node);
          break;
        case TRUTH_ORIF_EXPR:
          stack[sp].expr
@@ -4863,7 +4866,8 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
                                                 stack[sp].expr);
          stack[sp].expr.value = c_objc_common_truthvalue_conversion
            (stack[sp].loc, default_conversion (stack[sp].expr.value));
-         skip_evaluation += stack[sp].expr.value == truthvalue_true_node;
+         c_inhibit_evaluation_warnings += (stack[sp].expr.value
+                                           == truthvalue_true_node);
          break;
        default:
          break;
@@ -5086,7 +5090,7 @@ c_parser_sizeof_expression (c_parser *parser)
   location_t expr_loc;
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_SIZEOF));
   c_parser_consume_token (parser);
-  skip_evaluation++;
+  c_inhibit_evaluation_warnings++;
   in_sizeof++;
   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
       && c_token_starts_typename (c_parser_peek_2nd_token (parser)))
@@ -5101,7 +5105,7 @@ c_parser_sizeof_expression (c_parser *parser)
       if (type_name == NULL)
        {
          struct c_expr ret;
-         skip_evaluation--;
+         c_inhibit_evaluation_warnings--;
          in_sizeof--;
          ret.value = error_mark_node;
          ret.original_code = ERROR_MARK;
@@ -5116,7 +5120,7 @@ c_parser_sizeof_expression (c_parser *parser)
          goto sizeof_expr;
        }
       /* sizeof ( type-name ).  */
-      skip_evaluation--;
+      c_inhibit_evaluation_warnings--;
       in_sizeof--;
       return c_expr_sizeof_type (expr_loc, type_name);
     }
@@ -5125,7 +5129,7 @@ c_parser_sizeof_expression (c_parser *parser)
       expr_loc = c_parser_peek_token (parser)->location;
       expr = c_parser_unary_expression (parser);
     sizeof_expr:
-      skip_evaluation--;
+      c_inhibit_evaluation_warnings--;
       in_sizeof--;
       if (TREE_CODE (expr.value) == COMPONENT_REF
          && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
@@ -5143,7 +5147,7 @@ c_parser_alignof_expression (c_parser *parser)
   location_t loc = c_parser_peek_token (parser)->location;
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNOF));
   c_parser_consume_token (parser);
-  skip_evaluation++;
+  c_inhibit_evaluation_warnings++;
   in_alignof++;
   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
       && c_token_starts_typename (c_parser_peek_2nd_token (parser)))
@@ -5160,7 +5164,7 @@ c_parser_alignof_expression (c_parser *parser)
       if (type_name == NULL)
        {
          struct c_expr ret;
-         skip_evaluation--;
+         c_inhibit_evaluation_warnings--;
          in_alignof--;
          ret.value = error_mark_node;
          ret.original_code = ERROR_MARK;
@@ -5175,7 +5179,7 @@ c_parser_alignof_expression (c_parser *parser)
          goto alignof_expr;
        }
       /* alignof ( type-name ).  */
-      skip_evaluation--;
+      c_inhibit_evaluation_warnings--;
       in_alignof--;
       ret.value = c_alignof (loc, groktypename (type_name, NULL, NULL));
       ret.original_code = ERROR_MARK;
@@ -5187,7 +5191,7 @@ c_parser_alignof_expression (c_parser *parser)
       struct c_expr ret;
       expr = c_parser_unary_expression (parser);
     alignof_expr:
-      skip_evaluation--;
+      c_inhibit_evaluation_warnings--;
       in_alignof--;
       ret.value = c_alignof_expr (loc, expr.value);
       ret.original_code = ERROR_MARK;
@@ -6814,7 +6818,7 @@ c_parser_objc_message_args (c_parser *parser)
     {
       tree keywordexpr;
       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
-       return list;
+       return error_mark_node;
       keywordexpr = c_parser_objc_keywordexpr (parser);
       list = chainon (list, build_tree_list (sel, keywordexpr));
       sel = c_parser_objc_selector (parser);
@@ -7334,7 +7338,7 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list)
        }
 
       /* Attempt to statically determine when the number isn't positive.  */
-      c = fold_build2 (LE_EXPR, boolean_type_node, t,
+      c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t,
                       build_int_cst (TREE_TYPE (t), 0));
       if (CAN_HAVE_LOCATION_P (c))
        SET_EXPR_LOCATION (c, expr_loc);