re PR c++/85662 ("error: non-constant condition for static assertion" from __builtin_...
authorJakub Jelinek <jakub@redhat.com>
Thu, 10 May 2018 17:40:28 +0000 (19:40 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 10 May 2018 17:40:28 +0000 (19:40 +0200)
commit79e7b1fe3290f351f178dafee4b3df4ece61ba9c
treed48f413c93e9cc59329413239736490ef5c5f916
parentc7b7749d9f2c68ca4f9cda52b21ef690aef009bd
re PR c++/85662 ("error: non-constant condition for static assertion" from __builtin_offsetof in C++)

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.

From-SVN: r260119
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]