diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-05-10 19:40:28 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-05-10 19:40:28 +0200 |
commit | 79e7b1fe3290f351f178dafee4b3df4ece61ba9c (patch) | |
tree | d48f413c93e9cc59329413239736490ef5c5f916 /gcc/cp | |
parent | c7b7749d9f2c68ca4f9cda52b21ef690aef009bd (diff) | |
download | gcc-79e7b1fe3290f351f178dafee4b3df4ece61ba9c.zip gcc-79e7b1fe3290f351f178dafee4b3df4ece61ba9c.tar.gz gcc-79e7b1fe3290f351f178dafee4b3df4ece61ba9c.tar.bz2 |
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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a2de8f6..e21afc7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-05-10 Jakub Jelinek <jakub@redhat.com> + + PR c++/85662 + * 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. + 2018-05-10 Eric Botcazou <ebotcazou@adacore.com> PR c++/85400 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 7449065..84882f8 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; |