PR c++/85662
commit3c43ed347ea9c2ca617403c3c058ea6ba5433afd
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 May 2018 17:40:28 +0000 (10 17:40 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 May 2018 17:40:28 +0000 (10 17:40 +0000)
treed48f413c93e9cc59329413239736490ef5c5f916
parent05fcd2f2bf55a0b12792c0e29676af93739c7af9
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: svn+ssh://gcc.gnu.org/svn/gcc/trunk@260119 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c/ChangeLog
gcc/c/c-fold.c
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/offsetof2.C [new file with mode: 0644]