re PR c++/68727 (invalid offsetof expressions accepted)
authorJakub Jelinek <jakub@redhat.com>
Thu, 26 Jan 2017 19:39:40 +0000 (20:39 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 26 Jan 2017 19:39:40 +0000 (20:39 +0100)
commit905d2812e7bd7e41e833ef9bf4c953381b31c83b
tree156a3b12a0ead50dbb85377ac732b5a2b10a9341
parentc1cadde1cbd95e051885c3c9c5794a8d8c64e27a
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
gcc/cp/ChangeLog
gcc/cp/cp-tree.def
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/offsetof8.C
gcc/testsuite/g++.dg/other/offsetof9.C [new file with mode: 0644]