mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/87861 (ICE in output_constructor_regular_field, at varasm.c:5165)
PR c++/87861 * class.c (build_vtbl_initializer): For TARGET_VTABLE_USES_DESCRIPTORS bump index for each added word. * constexpr.c (find_array_ctor_elt): Add forward declaration. (cxx_eval_call_expression): Handle TARGET_VTABLE_USES_DESCRIPTORS vtable calls. (cxx_eval_constant_expression) <case OBJ_TYPE_REF>: Divide token by TARGET_VTABLE_USES_DESCRIPTORS if non-zero. From-SVN: r267032
This commit is contained in:
parent
3c0517a653
commit
582d2481f7
|
|
@ -1,3 +1,14 @@
|
|||
2018-12-11 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/87861
|
||||
* class.c (build_vtbl_initializer): For TARGET_VTABLE_USES_DESCRIPTORS
|
||||
bump index for each added word.
|
||||
* constexpr.c (find_array_ctor_elt): Add forward declaration.
|
||||
(cxx_eval_call_expression): Handle TARGET_VTABLE_USES_DESCRIPTORS
|
||||
vtable calls.
|
||||
(cxx_eval_constant_expression) <case OBJ_TYPE_REF>: Divide token
|
||||
by TARGET_VTABLE_USES_DESCRIPTORS if non-zero.
|
||||
|
||||
2018-12-11 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/86608 - reading constexpr volatile variable.
|
||||
|
|
|
|||
|
|
@ -9351,7 +9351,6 @@ build_vtbl_initializer (tree binfo,
|
|||
tree vcall_index;
|
||||
tree fn, fn_original;
|
||||
tree init = NULL_TREE;
|
||||
tree idx = size_int (jx++);
|
||||
|
||||
fn = BV_FN (v);
|
||||
fn_original = fn;
|
||||
|
|
@ -9455,7 +9454,7 @@ build_vtbl_initializer (tree binfo,
|
|||
int i;
|
||||
if (init == size_zero_node)
|
||||
for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i)
|
||||
CONSTRUCTOR_APPEND_ELT (*inits, idx, init);
|
||||
CONSTRUCTOR_APPEND_ELT (*inits, size_int (jx++), init);
|
||||
else
|
||||
for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i)
|
||||
{
|
||||
|
|
@ -9463,11 +9462,11 @@ build_vtbl_initializer (tree binfo,
|
|||
fn, build_int_cst (NULL_TREE, i));
|
||||
TREE_CONSTANT (fdesc) = 1;
|
||||
|
||||
CONSTRUCTOR_APPEND_ELT (*inits, idx, fdesc);
|
||||
CONSTRUCTOR_APPEND_ELT (*inits, size_int (jx++), fdesc);
|
||||
}
|
||||
}
|
||||
else
|
||||
CONSTRUCTOR_APPEND_ELT (*inits, idx, init);
|
||||
CONSTRUCTOR_APPEND_ELT (*inits, size_int (jx++), init);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ do { \
|
|||
return t; \
|
||||
} while (0)
|
||||
|
||||
static HOST_WIDE_INT find_array_ctor_elt (tree ary, tree dindex,
|
||||
bool insert = false);
|
||||
|
||||
/* Returns true iff FUN is an instantiation of a constexpr function
|
||||
template or a defaulted constexpr function. */
|
||||
|
||||
|
|
@ -1516,6 +1519,36 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
|
|||
STRIP_NOPS (fun);
|
||||
if (TREE_CODE (fun) == ADDR_EXPR)
|
||||
fun = TREE_OPERAND (fun, 0);
|
||||
/* For TARGET_VTABLE_USES_DESCRIPTORS targets, there is no
|
||||
indirection, the called expression is a pointer into the
|
||||
virtual table which should contain FDESC_EXPR. Extract the
|
||||
FUNCTION_DECL from there. */
|
||||
else if (TARGET_VTABLE_USES_DESCRIPTORS
|
||||
&& TREE_CODE (fun) == POINTER_PLUS_EXPR
|
||||
&& TREE_CODE (TREE_OPERAND (fun, 0)) == ADDR_EXPR
|
||||
&& TREE_CODE (TREE_OPERAND (fun, 1)) == INTEGER_CST)
|
||||
{
|
||||
tree d = TREE_OPERAND (TREE_OPERAND (fun, 0), 0);
|
||||
if (VAR_P (d)
|
||||
&& DECL_VTABLE_OR_VTT_P (d)
|
||||
&& TREE_CODE (TREE_TYPE (d)) == ARRAY_TYPE
|
||||
&& TREE_TYPE (TREE_TYPE (d)) == vtable_entry_type
|
||||
&& DECL_INITIAL (d)
|
||||
&& TREE_CODE (DECL_INITIAL (d)) == CONSTRUCTOR)
|
||||
{
|
||||
tree i = int_const_binop (TRUNC_DIV_EXPR, TREE_OPERAND (fun, 1),
|
||||
TYPE_SIZE_UNIT (vtable_entry_type));
|
||||
HOST_WIDE_INT idx = find_array_ctor_elt (DECL_INITIAL (d), i);
|
||||
if (idx >= 0)
|
||||
{
|
||||
tree fdesc
|
||||
= (*CONSTRUCTOR_ELTS (DECL_INITIAL (d)))[idx].value;
|
||||
if (TREE_CODE (fdesc) == FDESC_EXPR
|
||||
&& integer_zerop (TREE_OPERAND (fdesc, 1)))
|
||||
fun = TREE_OPERAND (fdesc, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TREE_CODE (fun) != FUNCTION_DECL)
|
||||
{
|
||||
|
|
@ -2240,7 +2273,7 @@ array_index_cmp (tree key, tree index)
|
|||
if none. If INSERT is true, insert a matching element rather than fail. */
|
||||
|
||||
static HOST_WIDE_INT
|
||||
find_array_ctor_elt (tree ary, tree dindex, bool insert = false)
|
||||
find_array_ctor_elt (tree ary, tree dindex, bool insert)
|
||||
{
|
||||
if (tree_int_cst_sgn (dindex) < 0)
|
||||
return -1;
|
||||
|
|
@ -4834,6 +4867,8 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
|
|||
/* Find the function decl in the virtual functions list. TOKEN is
|
||||
the DECL_VINDEX that says which function we're looking for. */
|
||||
tree virtuals = BINFO_VIRTUALS (TYPE_BINFO (objtype));
|
||||
if (TARGET_VTABLE_USES_DESCRIPTORS)
|
||||
token /= MAX (TARGET_VTABLE_USES_DESCRIPTORS, 1);
|
||||
r = TREE_VALUE (chain_index (token, virtuals));
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue