On 03/04/2016 01:37 PM, Jakub Jelinek wrote:
Hi!
As mentioned in the PR, on the following testcase we emit invalid
error on s390* in the va_arg ((ap), int) case, va_arg (ap, int) is fine
(and the former is fine in -std=c++11 or -std=c++98 too).
The bug only triggers in constructors (or destructors), and happens because
build_va_arg creates ADDR_EXPR that has slightly different type, and has
INDIRECT_REF inside of it. copy_tree_body_r notices this and cancels the
two, but unlike e.g. build_fold_addr_expr_with_type_loc
if (TREE_CODE (t) == INDIRECT_REF)
{
t = TREE_OPERAND (t, 0);
if (TREE_TYPE (t) != ptrtype)
t = build1_loc (loc, NOP_EXPR, ptrtype, t); <<<<<<---------- this
}
it doesn't attempt to handle the case where ADDR_EXPR contained different
type from the type of INDIRECT_REF's operand.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
bootstrap/regtest on s390{,x}-linux pending. Ok for trunk if it passes
even there?
2016-03-04 Jakub Jelinek <ja...@redhat.com>
PR c++/70084
* tree-inline.c (copy_tree_body_r): When cancelling ADDR_EXPR
of INDIRECT_REF and ADDR_EXPR changed type, fold_convert it
to the right type.
* g++.dg/expr/stdarg3.C: New test.
OK.
jeff