Commit 582d2481 by Jakub Jelinek

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
parent 3c0517a6
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> 2018-12-11 Marek Polacek <polacek@redhat.com>
PR c++/86608 - reading constexpr volatile variable. PR c++/86608 - reading constexpr volatile variable.
...@@ -114,7 +125,7 @@ ...@@ -114,7 +125,7 @@
* decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error message; * decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error message;
print the type too; fix thinko in INDIRECT_TYPE_P use. print the type too; fix thinko in INDIRECT_TYPE_P use.
2018-12-05 Alexandre Oliva <aoliva@redhat.com> 2018-12-05 Alexandre Oliva <aoliva@redhat.com>
PR c++/85569 PR c++/85569
* constexpr.c (adjust_temp_type): Test for type equality with * constexpr.c (adjust_temp_type): Test for type equality with
...@@ -573,7 +584,7 @@ ...@@ -573,7 +584,7 @@
if it is true. if it is true.
(cp_parser_omp_clause_name): Handle nontemporal, in_reduction and (cp_parser_omp_clause_name): Handle nontemporal, in_reduction and
task_reduction clauses. task_reduction clauses.
(cp_parser_omp_var_list_no_open): Handle (cp_parser_omp_var_list_no_open): Handle
OMP_CLAUSE_{IN,TASK}_REDUCTION. For OMP_CLAUSE_DEPEND, parse clause OMP_CLAUSE_{IN,TASK}_REDUCTION. For OMP_CLAUSE_DEPEND, parse clause
operands as either an array section, or lvalue assignment expression. operands as either an array section, or lvalue assignment expression.
(cp_parser_omp_clause_if): Handle cancel and simd modifiers. (cp_parser_omp_clause_if): Handle cancel and simd modifiers.
...@@ -801,7 +812,7 @@ ...@@ -801,7 +812,7 @@
PR ipa/81277 PR ipa/81277
* cp-tree.h (DECL_FNAME_P): New macro. * cp-tree.h (DECL_FNAME_P): New macro.
* decl.c (cp_make_fname_decl): Set DECL_DECLARED_CONSTEXPR_P, * decl.c (cp_make_fname_decl): Set DECL_DECLARED_CONSTEXPR_P,
DECL_VALUE_EXPR, DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P. DECL_VALUE_EXPR, DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P.
(cp_finish_decl): (cp_finish_decl):
* lambda.c (is_capture_proxy): Use DECL_FNAME_P. * lambda.c (is_capture_proxy): Use DECL_FNAME_P.
* pt.c (tsubst_expr): Handle DECL_PRETTY_FUNCTION_P. * pt.c (tsubst_expr): Handle DECL_PRETTY_FUNCTION_P.
...@@ -926,9 +937,9 @@ ...@@ -926,9 +937,9 @@
2018-10-29 Joseph Myers <joseph@codesourcery.com> 2018-10-29 Joseph Myers <joseph@codesourcery.com>
Julian Brown <julian@codesourcery.com> Julian Brown <julian@codesourcery.com>
PR c++/66053 PR c++/66053
* semantics.c (handle_omp_array_sections_1): Allow array * semantics.c (handle_omp_array_sections_1): Allow array
sections with "this" pointer for OpenACC. sections with "this" pointer for OpenACC.
2018-10-25 Jason Merrill <jason@redhat.com> 2018-10-25 Jason Merrill <jason@redhat.com>
...@@ -1086,7 +1097,7 @@ ...@@ -1086,7 +1097,7 @@
* name-lookup.c (check_local_shadow): Do not test DECL_FROM_INLINE. * name-lookup.c (check_local_shadow): Do not test DECL_FROM_INLINE.
2018-09-28 Eric Botcazou <ebotcazou@adacore.com> 2018-09-28 Eric Botcazou <ebotcazou@adacore.com>
Pierre-Marie de Rodat <derodat@adacore.com> Pierre-Marie de Rodat <derodat@adacore.com>
* method.c (use_thunk): Adjust call to cgraph_node::create_thunk. * method.c (use_thunk): Adjust call to cgraph_node::create_thunk.
...@@ -1232,7 +1243,7 @@ ...@@ -1232,7 +1243,7 @@
case into complain_about_bad_argument. case into complain_about_bad_argument.
2018-09-09 Cesar Philippidis <cesar@codesourcery.com> 2018-09-09 Cesar Philippidis <cesar@codesourcery.com>
Julian Brown <julian@codesourcery.com> Julian Brown <julian@codesourcery.com>
PR middle-end/86336 PR middle-end/86336
* semantics.c (finish_omp_clauses): Treat C++ references the same in * semantics.c (finish_omp_clauses): Treat C++ references the same in
...@@ -2041,8 +2052,8 @@ ...@@ -2041,8 +2052,8 @@
information in a few additional error messages. information in a few additional error messages.
(grokdeclarator): Update calls. (grokdeclarator): Update calls.
2018-06-20 Chung-Lin Tang <cltang@codesourcery.com> 2018-06-20 Chung-Lin Tang <cltang@codesourcery.com>
Thomas Schwinge <thomas@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com>
Cesar Philippidis <cesar@codesourcery.com> Cesar Philippidis <cesar@codesourcery.com>
* parser.c (cp_parser_omp_clause_name): Add support for finalize * parser.c (cp_parser_omp_clause_name): Add support for finalize
...@@ -2965,7 +2976,7 @@ ...@@ -2965,7 +2976,7 @@
* cp-gimplify.c (cp_fold) <case ADDR_EXPR>: ... here. Only use it * cp-gimplify.c (cp_fold) <case ADDR_EXPR>: ... here. Only use it
if INDIRECT_REF's operand is INTEGER_CST cast to pointer type. if INDIRECT_REF's operand is INTEGER_CST cast to pointer type.
2018-04-18 Alexandre Oliva <aoliva@redhat.com> 2018-04-18 Alexandre Oliva <aoliva@redhat.com>
PR c++/80290 PR c++/80290
* cp-tree.h (struct tinst_level): Split decl into tldcl and * cp-tree.h (struct tinst_level): Split decl into tldcl and
...@@ -3007,7 +3018,7 @@ ...@@ -3007,7 +3018,7 @@
for refcount. Release pending_template to freelist. for refcount. Release pending_template to freelist.
(instantiating_current_function_p): Use new accessors. (instantiating_current_function_p): Use new accessors.
2018-04-16 Alexandre Oliva <aoliva@redhat.com> 2018-04-16 Alexandre Oliva <aoliva@redhat.com>
PR c++/85039 PR c++/85039
* parser.c (cp_parser_builtin_offset): Reject type definitions. * parser.c (cp_parser_builtin_offset): Reject type definitions.
...@@ -3249,7 +3260,7 @@ ...@@ -3249,7 +3260,7 @@
* pt.c (extract_locals_r): Don't record the local specs of variables * pt.c (extract_locals_r): Don't record the local specs of variables
declared within the pattern. declared within the pattern.
2018-04-05 Alexandre Oliva <aoliva@redhat.com> 2018-04-05 Alexandre Oliva <aoliva@redhat.com>
PR c++/84979 PR c++/84979
* pt.c (check_auto_in_tmpl_args): New. * pt.c (check_auto_in_tmpl_args): New.
...@@ -3331,7 +3342,7 @@ ...@@ -3331,7 +3342,7 @@
* decl.c (grokfndecl): Handle standard UDL diagnostics here.. * decl.c (grokfndecl): Handle standard UDL diagnostics here..
* parser.c (cp_parser_unqualified_id): ..not here. * parser.c (cp_parser_unqualified_id): ..not here.
2018-04-04 Alexandre Oliva <aoliva@redhat.com> 2018-04-04 Alexandre Oliva <aoliva@redhat.com>
PR c++/84943 PR c++/84943
* typeck.c (cp_build_addr_expr_1): Mark FUNCTION_DECL as * typeck.c (cp_build_addr_expr_1): Mark FUNCTION_DECL as
...@@ -3392,7 +3403,7 @@ ...@@ -3392,7 +3403,7 @@
into packs here. into packs here.
(cp_parser_parameter_declaration_list): Not here. (cp_parser_parameter_declaration_list): Not here.
2018-03-31 Alexandre Oliva <aoliva@redhat.com> 2018-03-31 Alexandre Oliva <aoliva@redhat.com>
PR c++/85027 PR c++/85027
* class.c (instantiate_type): Peel off SAVE_EXPR before * class.c (instantiate_type): Peel off SAVE_EXPR before
...@@ -3446,7 +3457,7 @@ ...@@ -3446,7 +3457,7 @@
* pt.c (tsubst_default_argument): Early return if the type of the * pt.c (tsubst_default_argument): Early return if the type of the
parameter is erroneous. parameter is erroneous.
2018-03-28 Alexandre Oliva <aoliva@redhat.com> 2018-03-28 Alexandre Oliva <aoliva@redhat.com>
PR c++/84973 PR c++/84973
* decl2.c (note_vague_linkage_fn): Don't defer uninstantiated * decl2.c (note_vague_linkage_fn): Don't defer uninstantiated
...@@ -3535,7 +3546,7 @@ ...@@ -3535,7 +3546,7 @@
PR c++/85033 PR c++/85033
* semantics.c (finish_offsetof): Don't allow CONST_DECLs. * semantics.c (finish_offsetof): Don't allow CONST_DECLs.
2018-03-23 Alexandre Oliva <aoliva@redhat.com> 2018-03-23 Alexandre Oliva <aoliva@redhat.com>
PR c++/71251 PR c++/71251
* parser.c (cp_parser_alias_declaration): Call * parser.c (cp_parser_alias_declaration): Call
...@@ -3576,7 +3587,7 @@ ...@@ -3576,7 +3587,7 @@
(build_special_member_call): Only do C++17 copy elision here if the (build_special_member_call): Only do C++17 copy elision here if the
argument is already the right type. argument is already the right type.
2018-03-21 Alexandre Oliva <aoliva@redhat.com> 2018-03-21 Alexandre Oliva <aoliva@redhat.com>
PR c++/71965 PR c++/71965
* init.c (build_vec_init): Silence error, former sorry, * init.c (build_vec_init): Silence error, former sorry,
...@@ -3944,7 +3955,7 @@ ...@@ -3944,7 +3955,7 @@
* constexpr.c (cxx_bind_parameters_in_call): Unshare evaluated * constexpr.c (cxx_bind_parameters_in_call): Unshare evaluated
arguments. arguments.
2018-03-06 Alexandre Oliva <aoliva@redhat.com> 2018-03-06 Alexandre Oliva <aoliva@redhat.com>
PR c++/84231 PR c++/84231
* tree.c (lvalue_kind): Use presence/absence of REFERENCE_TYPE * tree.c (lvalue_kind): Use presence/absence of REFERENCE_TYPE
...@@ -4096,7 +4107,7 @@ ...@@ -4096,7 +4107,7 @@
require_potential_rvalue_constant_expression. require_potential_rvalue_constant_expression.
2018-03-01 Jason Merrill <jason@redhat.com> 2018-03-01 Jason Merrill <jason@redhat.com>
Alexandre Oliva <aoliva@redhat.com> Alexandre Oliva <aoliva@redhat.com>
PR c++/71569 - ICE with redundant args on member variable template. PR c++/71569 - ICE with redundant args on member variable template.
* decl.c (start_decl): Handle partial specialization of member * decl.c (start_decl): Handle partial specialization of member
......
...@@ -9351,7 +9351,6 @@ build_vtbl_initializer (tree binfo, ...@@ -9351,7 +9351,6 @@ build_vtbl_initializer (tree binfo,
tree vcall_index; tree vcall_index;
tree fn, fn_original; tree fn, fn_original;
tree init = NULL_TREE; tree init = NULL_TREE;
tree idx = size_int (jx++);
fn = BV_FN (v); fn = BV_FN (v);
fn_original = fn; fn_original = fn;
...@@ -9455,7 +9454,7 @@ build_vtbl_initializer (tree binfo, ...@@ -9455,7 +9454,7 @@ build_vtbl_initializer (tree binfo,
int i; int i;
if (init == size_zero_node) if (init == size_zero_node)
for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i) for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i)
CONSTRUCTOR_APPEND_ELT (*inits, idx, init); CONSTRUCTOR_APPEND_ELT (*inits, size_int (jx++), init);
else else
for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i) for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i)
{ {
...@@ -9463,11 +9462,11 @@ build_vtbl_initializer (tree binfo, ...@@ -9463,11 +9462,11 @@ build_vtbl_initializer (tree binfo,
fn, build_int_cst (NULL_TREE, i)); fn, build_int_cst (NULL_TREE, i));
TREE_CONSTANT (fdesc) = 1; TREE_CONSTANT (fdesc) = 1;
CONSTRUCTOR_APPEND_ELT (*inits, idx, fdesc); CONSTRUCTOR_APPEND_ELT (*inits, size_int (jx++), fdesc);
} }
} }
else else
CONSTRUCTOR_APPEND_ELT (*inits, idx, init); CONSTRUCTOR_APPEND_ELT (*inits, size_int (jx++), init);
} }
} }
......
...@@ -41,6 +41,9 @@ do { \ ...@@ -41,6 +41,9 @@ do { \
return t; \ return t; \
} while (0) } 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 /* Returns true iff FUN is an instantiation of a constexpr function
template or a defaulted constexpr function. */ template or a defaulted constexpr function. */
...@@ -1516,6 +1519,36 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1516,6 +1519,36 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
STRIP_NOPS (fun); STRIP_NOPS (fun);
if (TREE_CODE (fun) == ADDR_EXPR) if (TREE_CODE (fun) == ADDR_EXPR)
fun = TREE_OPERAND (fun, 0); 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) if (TREE_CODE (fun) != FUNCTION_DECL)
{ {
...@@ -2240,7 +2273,7 @@ array_index_cmp (tree key, tree index) ...@@ -2240,7 +2273,7 @@ array_index_cmp (tree key, tree index)
if none. If INSERT is true, insert a matching element rather than fail. */ if none. If INSERT is true, insert a matching element rather than fail. */
static HOST_WIDE_INT 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) if (tree_int_cst_sgn (dindex) < 0)
return -1; return -1;
...@@ -4834,6 +4867,8 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -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 /* Find the function decl in the virtual functions list. TOKEN is
the DECL_VINDEX that says which function we're looking for. */ the DECL_VINDEX that says which function we're looking for. */
tree virtuals = BINFO_VIRTUALS (TYPE_BINFO (objtype)); 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)); r = TREE_VALUE (chain_index (token, virtuals));
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment