aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-parser.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2011-08-19 16:53:51 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2011-08-19 16:53:51 +0100
commitd4a83c103c7a266631bc93abcfebc2451a8d5dcd (patch)
tree6962b481efb1f6dbc36e80864a62800c7cd68b11 /gcc/c-parser.c
parenta6f969f4cb4b8363b2f20f942d36dd96906ba253 (diff)
downloadgcc-d4a83c103c7a266631bc93abcfebc2451a8d5dcd.zip
gcc-d4a83c103c7a266631bc93abcfebc2451a8d5dcd.tar.gz
gcc-d4a83c103c7a266631bc93abcfebc2451a8d5dcd.tar.bz2
c-parser.c (c_parser_postfix_expression): Handle RID_BUILTIN_COMPLEX.
* 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. From-SVN: r177911
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r--gcc/c-parser.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 8d7bb99..92821b1 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);