aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2011-11-04 21:46:07 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2011-11-04 21:46:07 +0000
commitcf9e9959d1a5e8c7ddb506f68017b4f9c9292b94 (patch)
tree15bbae4a0d50f8d41bd44c607cad67495a7c994c /gcc/cp
parentc62c54419cf1bcdebbe2313b509e1892b85832d0 (diff)
downloadgcc-cf9e9959d1a5e8c7ddb506f68017b4f9c9292b94.zip
gcc-cf9e9959d1a5e8c7ddb506f68017b4f9c9292b94.tar.gz
gcc-cf9e9959d1a5e8c7ddb506f68017b4f9c9292b94.tar.bz2
re PR c++/50608 (cannot apply 'offsetof' to a non-constant address)
2011-11-04 Eric Botcazou <ebotcazou@adacore.com> PR c++/50608 * c-parser.c (c_parser_postfix_expression) <RID_OFFSETOF>: Adjust call to fold_offsetof. * c-typeck.c (build_unary_op) <ADDR_EXPR>: Call fold_offsetof_1. c-family/ * c-common.c (c_fully_fold_internal) <ADDR_EXPR>: Call fold_offsetof_1. (fold_offsetof_1): Make global.  Remove STOP_REF argument and adjust. <INDIRECT_REF>: Return the argument. <ARRAY_REF>: Remove special code for negative offset. Call fold_build_pointer_plus instead of size_binop. (fold_offsetof): Remove STOP_REF argument and adjust. * c-common.h (fold_offsetof_1): Declare. (fold_offsetof): Remove STOP_REF argument. cp/ * semantics.c (finish_offsetof): Adjust call to fold_offsetof. * typeck.c (cp_build_addr_expr_1): Call fold_offsetof_1. From-SVN: r180986
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c2
-rw-r--r--gcc/cp/typeck.c4
3 files changed, 8 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2a1db7a..ffb085c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2011-11-04 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR c++/50608
+ * semantics.c (finish_offsetof): Adjust call to fold_offsetof.
+ * typeck.c (cp_build_addr_expr_1): Call fold_offsetof_1.
+
2011-11-04 Paolo Carlini <paolo.carlini@oracle.com>
* typeck.c (build_indirect_ref): Use ATTRIBUTE_UNUSED.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index a80aec6..cebb7df 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3568,7 +3568,7 @@ finish_offsetof (tree expr)
if (!complete_type_or_else (TREE_TYPE (object), object))
return error_mark_node;
}
- return fold_offsetof (expr, NULL_TREE);
+ return fold_offsetof (expr);
}
/* Replace the AGGR_INIT_EXPR at *TP with an equivalent CALL_EXPR. This
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index f4e45b4..386f3b8 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4881,9 +4881,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
&& TREE_CONSTANT (TREE_OPERAND (val, 0)))
{
tree type = build_pointer_type (argtype);
- tree op0 = fold_convert (type, TREE_OPERAND (val, 0));
- tree op1 = fold_offsetof (arg, val);
- return fold_build_pointer_plus (op0, op1);
+ return fold_convert (type, fold_offsetof_1 (arg));
}
/* Handle complex lvalues (when permitted)