summaryrefslogtreecommitdiff
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@codesourcery.com>2010-11-18 16:24:56 +0000
committerNathan Froyd <froydnj@gcc.gnu.org>2010-11-18 16:24:56 +0000
commitfb52b50a920a7571af3de43d679fa42483c56a96 (patch)
tree45ef94c714a23d36859dc3c9c965f946052c1cbc /gcc/c-typeck.c
parentcfaa55890b6f9fb5fde5c84fc51326427dc48259 (diff)
downloadgcc-fb52b50a920a7571af3de43d679fa42483c56a96.tar.gz
re PR c/33193 (slopiness in __real/__imag)
gcc/ PR c/33193 * c-typeck.c (build_unary_op): Call build_real_imag_expr for REALPART_EXPR and IMAGPART_EXPR. gcc/c-family/ PR c/33193 * c-common.h (build_real_imag_expr): Declare. * c-semantics.c (build_real_imag_expr): Define. gcc/cp/ PR c/33193 * typeck.c (cp_build_unary_op): Call build_real_imag_expr for REALPART_EXPR and IMAGPART_EXPR. gcc/testsuite/ PR c/33193 * c-c++-common/pr33193.c: New test. From-SVN: r166909
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 2bfa97be68e..9aca720fd71 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -3561,26 +3561,10 @@ build_unary_op (location_t location,
goto return_build_unary_op;
case REALPART_EXPR:
- if (TREE_CODE (arg) == COMPLEX_CST)
- ret = TREE_REALPART (arg);
- else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
- ret = fold_build1_loc (location,
- REALPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg);
- else
- ret = arg;
- if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE)
- eptype = TREE_TYPE (eptype);
- goto return_build_unary_op;
-
case IMAGPART_EXPR:
- if (TREE_CODE (arg) == COMPLEX_CST)
- ret = TREE_IMAGPART (arg);
- else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
- ret = fold_build1_loc (location,
- IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg);
- else
- ret = omit_one_operand_loc (location, TREE_TYPE (arg),
- integer_zero_node, arg);
+ ret = build_real_imag_expr (location, code, arg);
+ if (ret == error_mark_node)
+ return error_mark_node;
if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE)
eptype = TREE_TYPE (eptype);
goto return_build_unary_op;