aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2005-05-09 20:48:33 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2005-05-09 20:48:33 +0000
commit43f6dfd3ec224e73a7175987f651b3d455f7803f (patch)
tree55b63c7bc470ab9a0ee49ea53a931e7a2f5a48d4
parent32df413ae734d59d5579b05b1751ebe7a79ac014 (diff)
downloadgcc-43f6dfd3ec224e73a7175987f651b3d455f7803f.zip
gcc-43f6dfd3ec224e73a7175987f651b3d455f7803f.tar.gz
gcc-43f6dfd3ec224e73a7175987f651b3d455f7803f.tar.bz2
c-tree.h (parser_build_unary_op): New prototype.
* c-tree.h (parser_build_unary_op): New prototype. * c-typeck.c (parser_build_unary_op): New function to construct a unary operation in the C parser. * c-parser.c (c_parser_unary_expression): Use the new function parser_build_unary_op when appropriate. From-SVN: r99471
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-parser.c71
-rw-r--r--gcc/c-tree.h1
-rw-r--r--gcc/c-typeck.c26
4 files changed, 53 insertions, 53 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e9a1a6a..ae7d68e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2005-05-09 Roger Sayle <roger@eyesopen.com>
+
+ * c-tree.h (parser_build_unary_op): New prototype.
+ * c-typeck.c (parser_build_unary_op): New function to construct
+ a unary operation in the C parser.
+ * c-parser.c (c_parser_unary_expression): Use the new function
+ parser_build_unary_op when appropriate.
+
2005-05-09 Mark Mitchell <mark@codesourcery.com>
PR 18655
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 7774b72..96bab46 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -4495,66 +4495,45 @@ c_parser_unary_expression (c_parser *parser)
{
int ext;
struct c_expr ret;
- ret.original_code = ERROR_MARK;
switch (c_parser_peek_token (parser)->type)
{
case CPP_PLUS_PLUS:
c_parser_consume_token (parser);
- ret.value
- = build_unary_op (PREINCREMENT_EXPR,
- c_parser_cast_expression (parser, NULL).value, 0);
- overflow_warning (ret.value);
- return ret;
+ return parser_build_unary_op (PREINCREMENT_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_MINUS_MINUS:
c_parser_consume_token (parser);
- ret.value
- = build_unary_op (PREDECREMENT_EXPR,
- c_parser_cast_expression (parser, NULL).value, 0);
- overflow_warning (ret.value);
- return ret;
+ return parser_build_unary_op (PREDECREMENT_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_AND:
c_parser_consume_token (parser);
- ret.value
- = build_unary_op (ADDR_EXPR,
- c_parser_cast_expression (parser, NULL).value, 0);
- overflow_warning (ret.value);
- return ret;
+ return parser_build_unary_op (ADDR_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_MULT:
c_parser_consume_token (parser);
ret.value
= build_indirect_ref (c_parser_cast_expression (parser, NULL).value,
"unary *");
+ ret.original_code = ERROR_MARK;
return ret;
case CPP_PLUS:
c_parser_consume_token (parser);
if (!c_dialect_objc () && warn_traditional && !in_system_header)
warning (0, "traditional C rejects the unary plus operator");
- ret.value
- = build_unary_op (CONVERT_EXPR,
- c_parser_cast_expression (parser, NULL).value, 0);
- overflow_warning (ret.value);
- return ret;
+ return parser_build_unary_op (CONVERT_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_MINUS:
c_parser_consume_token (parser);
- ret.value
- = build_unary_op (NEGATE_EXPR,
- c_parser_cast_expression (parser, NULL).value, 0);
- overflow_warning (ret.value);
- return ret;
+ return parser_build_unary_op (NEGATE_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_COMPL:
c_parser_consume_token (parser);
- ret.value
- = build_unary_op (BIT_NOT_EXPR,
- c_parser_cast_expression (parser, NULL).value, 0);
- overflow_warning (ret.value);
- return ret;
+ return parser_build_unary_op (BIT_NOT_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_NOT:
c_parser_consume_token (parser);
- ret.value
- = build_unary_op (TRUTH_NOT_EXPR,
- c_parser_cast_expression (parser, NULL).value, 0);
- overflow_warning (ret.value);
- return ret;
+ return parser_build_unary_op (TRUTH_NOT_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_AND_AND:
/* Refer to the address of a label as a pointer. */
c_parser_consume_token (parser);
@@ -4563,14 +4542,14 @@ c_parser_unary_expression (c_parser *parser)
ret.value = finish_label_address_expr
(c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
- return ret;
}
else
{
c_parser_error (parser, "expected identifier");
ret.value = error_mark_node;
- return ret;
}
+ ret.original_code = ERROR_MARK;
+ return ret;
case CPP_KEYWORD:
switch (c_parser_peek_token (parser)->keyword)
{
@@ -4586,18 +4565,14 @@ c_parser_unary_expression (c_parser *parser)
return ret;
case RID_REALPART:
c_parser_consume_token (parser);
- ret.value
- = build_unary_op (REALPART_EXPR,
- c_parser_cast_expression (parser, NULL).value,
- 0);
- return ret;
+ return parser_build_unary_op (REALPART_EXPR,
+ c_parser_cast_expression (parser,
+ NULL));
case RID_IMAGPART:
c_parser_consume_token (parser);
- ret.value
- = build_unary_op (IMAGPART_EXPR,
- c_parser_cast_expression (parser, NULL).value,
- 0);
- return ret;
+ return parser_build_unary_op (IMAGPART_EXPR,
+ c_parser_cast_expression (parser,
+ NULL));
default:
return c_parser_postfix_expression (parser);
}
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index c22ae8a..7af8130 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -531,6 +531,7 @@ extern tree build_external_ref (tree, int, location_t);
extern void pop_maybe_used (bool);
extern struct c_expr c_expr_sizeof_expr (struct c_expr);
extern struct c_expr c_expr_sizeof_type (struct c_type_name *);
+extern struct c_expr parser_build_unary_op (enum tree_code, struct c_expr);
extern struct c_expr parser_build_binary_op (enum tree_code, struct c_expr,
struct c_expr);
extern tree build_conditional_expr (tree, tree, tree);
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 07471c7..d3b1c95 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -2312,11 +2312,27 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl)
return nreverse (result);
}
-/* 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. */
+/* 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. */
+
+struct c_expr
+parser_build_unary_op (enum tree_code code, struct c_expr arg)
+{
+ struct c_expr result;
+
+ result.original_code = ERROR_MARK;
+ result.value = build_unary_op (code, arg.value, 0);
+ 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. */
struct c_expr
parser_build_binary_op (enum tree_code code, struct c_expr arg1,