diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-19 15:53:51 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-19 15:53:51 +0000 |
commit | bff4ad11a7fb0ced47d88c7e330e02a65d5d141b (patch) | |
tree | 6962b481efb1f6dbc36e80864a62800c7cd68b11 /gcc/c-parser.c | |
parent | ffebd9c539372d8c2780ca84b63b8600c6f3f12f (diff) | |
download | gcc-bff4ad11a7fb0ced47d88c7e330e02a65d5d141b.tar.gz |
* c-parser.c (c_parser_postfix_expression): Handle
RID_BUILTIN_COMPLEX.
* doc/extend.texi (__builtin_complex): Document.
c-family:
* c-common.c (c_common_reswords): Add __builtin_complex.
* c-common.h (RID_BUILTIN_COMPLEX): New.
testsuite:
* gcc.dg/builtin-complex-err-1.c, gcc.dg/builtin-complex-err-2.c,
gcc.dg/dfp/builtin-complex.c, gcc.dg/torture/builtin-complex-1.c:
New tests.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177911 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r-- | gcc/c-parser.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 8d7bb995beb..92821b17261 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -6026,6 +6026,7 @@ c_parser_alignof_expression (c_parser *parser) assignment-expression , assignment-expression ) __builtin_types_compatible_p ( type-name , type-name ) + __builtin_complex ( assignment-expression , assignment-expression ) offsetof-member-designator: identifier @@ -6408,6 +6409,52 @@ c_parser_postfix_expression (c_parser *parser) = comptypes (e1, e2) ? integer_one_node : integer_zero_node; } break; + case RID_BUILTIN_COMPLEX: + c_parser_consume_token (parser); + if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) + { + expr.value = error_mark_node; + break; + } + loc = c_parser_peek_token (parser)->location; + e1 = c_parser_expr_no_commas (parser, NULL); + if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>")) + { + c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL); + expr.value = error_mark_node; + break; + } + e2 = c_parser_expr_no_commas (parser, NULL); + c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, + "expected %<)%>"); + mark_exp_read (e1.value); + mark_exp_read (e2.value); + if (!SCALAR_FLOAT_TYPE_P (TREE_TYPE (e1.value)) + || DECIMAL_FLOAT_TYPE_P (TREE_TYPE (e1.value)) + || !SCALAR_FLOAT_TYPE_P (TREE_TYPE (e2.value)) + || DECIMAL_FLOAT_TYPE_P (TREE_TYPE (e2.value))) + { + error_at (loc, "%<__builtin_complex%> operand " + "not of real binary floating-point type"); + expr.value = error_mark_node; + break; + } + if (TYPE_MAIN_VARIANT (TREE_TYPE (e1.value)) + != TYPE_MAIN_VARIANT (TREE_TYPE (e2.value))) + { + error_at (loc, + "%<__builtin_complex%> operands of different types"); + expr.value = error_mark_node; + break; + } + if (!flag_isoc99) + pedwarn (loc, OPT_pedantic, + "ISO C90 does not support complex types"); + expr.value = build2 (COMPLEX_EXPR, + build_complex_type (TYPE_MAIN_VARIANT + (TREE_TYPE (e1.value))), + e1.value, e2.value); + break; case RID_AT_SELECTOR: gcc_assert (c_dialect_objc ()); c_parser_consume_token (parser); |