mirror of git://gcc.gnu.org/git/gcc.git
Fix ICE on class-template argument deduction (PR c++/88795)
PR c++/88795 reports an ICE building a function_type for a deduction guide when the substitution into the function signature fails, due to an error_mark_node being returned from tsubst_arg_types but not being checked for. This error_mark_node gets used as the TYPE_ARG_TYPES, leading to ICEs in various places that assume this is a TREE_LIST. This patch checks the result of tsubst_arg_types and propagates the failure if it returns error_mark_node. It also adds an assertion to build_function_type, to fail faster if passed in error_mark_node. gcc/cp/ChangeLog: PR c++/88795 * pt.c (build_deduction_guide): Bail out if tsubst_arg_types fails. gcc/testsuite/ChangeLog: PR c++/88795 * g++.dg/template/pr88795.C: New test. gcc/ChangeLog: PR c++/88795 * tree.c (build_function_type): Assert that arg_types is not error_mark_node. From-SVN: r267957
This commit is contained in:
parent
b7ec44e82b
commit
1abb44f863
|
|
@ -1,3 +1,9 @@
|
||||||
|
2019-01-15 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
|
PR c++/88795
|
||||||
|
* tree.c (build_function_type): Assert that arg_types is not
|
||||||
|
error_mark_node.
|
||||||
|
|
||||||
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
|
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
|
||||||
|
|
||||||
PR inline-asm/52813
|
PR inline-asm/52813
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
2019-01-15 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
|
PR c++/88795
|
||||||
|
* pt.c (build_deduction_guide): Bail out if tsubst_arg_types
|
||||||
|
fails.
|
||||||
|
|
||||||
2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
|
2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
* decl.c (start_decl): Improve error location.
|
* decl.c (start_decl): Improve error location.
|
||||||
|
|
|
||||||
|
|
@ -26932,6 +26932,8 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain)
|
||||||
targs = template_parms_to_args (tparms);
|
targs = template_parms_to_args (tparms);
|
||||||
fparms = tsubst_arg_types (fparms, tsubst_args, NULL_TREE,
|
fparms = tsubst_arg_types (fparms, tsubst_args, NULL_TREE,
|
||||||
complain, ctor);
|
complain, ctor);
|
||||||
|
if (fparms == error_mark_node)
|
||||||
|
ok = false;
|
||||||
fargs = tsubst (fargs, tsubst_args, complain, ctor);
|
fargs = tsubst (fargs, tsubst_args, complain, ctor);
|
||||||
if (ci)
|
if (ci)
|
||||||
ci = tsubst_constraint_info (ci, tsubst_args, complain, ctor);
|
ci = tsubst_constraint_info (ci, tsubst_args, complain, ctor);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
2019-01-15 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
|
PR c++/88795
|
||||||
|
* g++.dg/template/pr88795.C: New test.
|
||||||
|
|
||||||
2019-01-15 Thomas Koenig <tkoenig@gcc.gnu.org>
|
2019-01-15 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||||
|
|
||||||
PR fortran/43136
|
PR fortran/43136
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
// { dg-do compile { target c++17 } }
|
||||||
|
|
||||||
|
template<class, int>
|
||||||
|
struct Array {};
|
||||||
|
|
||||||
|
template<class T, int size_>
|
||||||
|
struct Foo {
|
||||||
|
static constexpr int size() {
|
||||||
|
return size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class U>
|
||||||
|
Foo(U, Array<T, size()>) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, int size, class U>
|
||||||
|
Foo(U, Array<T, size>) -> Foo<T, size>;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Array<int, 2> arr{};
|
||||||
|
|
||||||
|
Foo foo{2.0, arr};
|
||||||
|
}
|
||||||
|
|
@ -8455,6 +8455,8 @@ build_function_type (tree value_type, tree arg_types)
|
||||||
bool any_structural_p, any_noncanonical_p;
|
bool any_structural_p, any_noncanonical_p;
|
||||||
tree canon_argtypes;
|
tree canon_argtypes;
|
||||||
|
|
||||||
|
gcc_assert (arg_types != error_mark_node);
|
||||||
|
|
||||||
if (TREE_CODE (value_type) == FUNCTION_TYPE)
|
if (TREE_CODE (value_type) == FUNCTION_TYPE)
|
||||||
{
|
{
|
||||||
error ("function return type cannot be function");
|
error ("function return type cannot be function");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue