diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-01-26 20:39:40 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-01-26 20:39:40 +0100 |
commit | 905d2812e7bd7e41e833ef9bf4c953381b31c83b (patch) | |
tree | 156a3b12a0ead50dbb85377ac732b5a2b10a9341 /gcc/cp/cp-tree.def | |
parent | c1cadde1cbd95e051885c3c9c5794a8d8c64e27a (diff) | |
download | gcc-905d2812e7bd7e41e833ef9bf4c953381b31c83b.tar.gz |
re PR c++/68727 (invalid offsetof expressions accepted)
PR c++/68727
* cp-tree.def (OFFSETOF_EXPR): Bump number of operands to 2.
* cp-tree.h (finish_offsetof): Add OBJECT_PTR argument.
* parser.c (cp_parser_builtin_offsetof): Pass result of
build_static_cast of null_pointer_node to finish_offsetof.
* semantics.c (finish_offsetof): Add OBJECT_PTR argument, use
it for -Winvalid-offsetof pedwarn instead of trying to guess
original offsetof type from EXPR. Save OBJECT_PTR as a new
second operand to OFFSETOF_EXPR.
* pt.c (tsubst_copy_and_build) <case OFFSETOF_EXPR>: Adjust
finish_offsetof caller, pass the second operand of OFFSETOF_EXPR
as OBJECT_PTR.
* g++.dg/other/offsetof8.C: Add expected error.
* g++.dg/other/offsetof9.C: New test.
From-SVN: r244949
Diffstat (limited to 'gcc/cp/cp-tree.def')
-rw-r--r-- | gcc/cp/cp-tree.def | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index ff4f4ef4698..c51c5c1dc21 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -333,7 +333,7 @@ DEFTREECODE (EXPR_STMT, "expr_stmt", tcc_expression, 1) DEFTREECODE (TAG_DEFN, "tag_defn", tcc_expression, 0) /* Represents an 'offsetof' expression during template expansion. */ -DEFTREECODE (OFFSETOF_EXPR, "offsetof_expr", tcc_expression, 1) +DEFTREECODE (OFFSETOF_EXPR, "offsetof_expr", tcc_expression, 2) /* Represents an '__builtin_addressof' expression during template expansion. This is similar to ADDR_EXPR, but it doesn't invoke |