]> git.ipfire.org Git - thirdparty/gcc.git/commit
re PR c++/89285 (ICE after casting the this pointer in the constructor in C++17 mode)
authorJakub Jelinek <jakub@redhat.com>
Thu, 21 Feb 2019 21:21:25 +0000 (22:21 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 21 Feb 2019 21:21:25 +0000 (22:21 +0100)
commit43574e4ff2afd4a2e47c179921a9b5661786ebf3
tree5130c82c404a6ffc07359ce1e92a747310754653
parentd331c5f10d5e6c9f41a24ff7cb7a8c6493790885
re PR c++/89285 (ICE after casting the this pointer in the constructor in C++17 mode)

PR c++/89285
* builtins.c (fold_builtin_arith_overflow): If first two args are
INTEGER_CSTs, set intres and ovfres to constants rather than calls
to ifn.

* constexpr.c (struct constexpr_fundef): Add parms and result members.
(retrieve_constexpr_fundef): Adjust for the above change.
(register_constexpr_fundef): Save constexpr body with copy_fn,
temporarily set DECL_CONTEXT on DECL_RESULT before that.
(get_fundef_copy): Change FUN argument to FUNDEF with
constexpr_fundef * type, grab body and parms/result out of
constexpr_fundef struct and temporarily change it for copy_fn calls
too.
(cxx_eval_builtin_function_call): For __builtin_FUNCTION temporarily
adjust current_function_decl from ctx->call context.  Test
!potential_constant_expression instead of !is_constant_expression.
(cxx_bind_parameters_in_call): Grab parameters from new_call.  Undo
convert_for_arg_passing changes for TREE_ADDRESSABLE type passing.
(cxx_eval_call_expression): Adjust get_fundef_copy caller.
(cxx_eval_conditional_expression): For IF_STMT, allow then or else
operands to be NULL.
(label_matches): Handle BREAK_STMT and CONTINUE_STMT.
(cxx_eval_loop_expr): Add support for FOR_STMT, WHILE_STMT and DO_STMT.
(cxx_eval_switch_expr): Add support for SWITCH_STMT.
(cxx_eval_constant_expression): Handle IF_STMT, FOR_STMT, WHILE_STMT,
DO_STMT, CONTINUE_STMT, SWITCH_STMT, BREAK_STMT and CONTINUE_STMT.
For SIZEOF_EXPR, recurse on the result of fold_sizeof_expr.  Ignore
DECL_EXPR with USING_DECL operand.
* lambda.c (maybe_add_lambda_conv_op): Build thisarg using
build_int_cst to make it a valid constant expression.

* g++.dg/ubsan/vptr-4.C: Expect reinterpret_cast errors.
* g++.dg/cpp1y/constexpr-84192.C (f2): Adjust expected diagnostics.
* g++.dg/cpp1y/constexpr-70265-2.C (foo): Adjust expected line of
diagnostics.
* g++.dg/cpp1y/constexpr-89285.C: New test.
* g++.dg/cpp0x/constexpr-arith-overflow.C (add, sub, mul): Ifdef out
for C++11.
(TEST_ADD, TEST_SUB, TEST_MUL): Define to Assert (true) for C++11.
* g++.dg/cpp0x/constexpr-arith-overflow2.C: New test.

From-SVN: r269078
12 files changed:
gcc/ChangeLog
gcc/builtins.c
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/lambda.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-arith-overflow.C
gcc/testsuite/g++.dg/cpp0x/constexpr-arith-overflow2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/constexpr-70265-2.C
gcc/testsuite/g++.dg/cpp1y/constexpr-84192.C
gcc/testsuite/g++.dg/cpp1y/constexpr-89285.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ubsan/vptr-4.C