https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85662

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Jun 22 21:23:03 2018
New Revision: 261962

URL: https://gcc.gnu.org/viewcvs?rev=261962&root=gcc&view=rev
Log:
        Backported from mainline
        2018-06-22  Jakub Jelinek  <ja...@redhat.com>

        PR c++/85662
        * g++.dg/ext/offsetof3.C: New test.

        2018-05-10  Jakub Jelinek  <ja...@redhat.com>

        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.

Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/ext/offsetof2.C
    branches/gcc-7-branch/gcc/testsuite/g++.dg/ext/offsetof3.C
Modified:
    branches/gcc-7-branch/gcc/c-family/ChangeLog
    branches/gcc-7-branch/gcc/c-family/c-common.c
    branches/gcc-7-branch/gcc/c-family/c-common.h
    branches/gcc-7-branch/gcc/c/ChangeLog
    branches/gcc-7-branch/gcc/c/c-fold.c
    branches/gcc-7-branch/gcc/c/c-typeck.c
    branches/gcc-7-branch/gcc/cp/ChangeLog
    branches/gcc-7-branch/gcc/cp/cp-gimplify.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog

Reply via email to