aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cp-gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-05-10 17:40:28 +0000
committerJakub Jelinek <jakub@redhat.com>2018-05-10 17:40:28 +0000
commit710302fed08d07d8d12587c2cbf9b11541e3e880 (patch)
treed48f413c93e9cc59329413239736490ef5c5f916 /gcc/cp/cp-gimplify.c
parent3c4e50738634b8dab7dac8ea24dfedb000901d97 (diff)
PR c++/85662
* c-common.h (fold_offsetof_1): Removed. (fold_offsetof): Add TYPE argument defaulted to size_type_node and CTX argument defaulted to ERROR_MARK. * c-common.c (fold_offsetof_1): Renamed to ... (fold_offsetof): ... this. Remove wrapper function. Add TYPE argument, convert the pointer constant to TYPE and use size_binop with PLUS_EXPR instead of fold_build_pointer_plus if type is not a pointer type. Adjust recursive calls. * c-fold.c (c_fully_fold_internal): Use fold_offsetof rather than fold_offsetof_1, pass TREE_TYPE (expr) as TYPE to it and drop the fold_convert_loc. * c-typeck.c (build_unary_op): Use fold_offsetof rather than fold_offsetof_1, pass argtype as TYPE to it and drop the fold_convert_loc. * cp-gimplify.c (cp_fold): Use fold_offsetof rather than fold_offsetof_1, pass TREE_TYPE (x) as TYPE to it and drop the fold_convert. * g++.dg/ext/offsetof2.C: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@260119 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/cp-gimplify.c')
-rw-r--r--gcc/cp/cp-gimplify.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 74490654631..84882f8dbb7 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2232,7 +2232,7 @@ cp_fold (tree x)
val = TREE_OPERAND (val, 0);
STRIP_NOPS (val);
if (TREE_CODE (val) == INTEGER_CST)
- return fold_convert (TREE_TYPE (x), fold_offsetof_1 (op0));
+ return fold_offsetof (op0, TREE_TYPE (x));
}
}
goto finish_unary;