diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-04-03 17:53:05 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-04-03 17:53:05 +0000 |
commit | e52c093a9fd668cddc2397719e8a5449f8cf27de (patch) | |
tree | 66afd0fff1476271b4724b3c274dc15d0101b79a /gcc | |
parent | 83afe9b528896ba26d774839c930098f4833cb87 (diff) | |
download | gcc-e52c093a9fd668cddc2397719e8a5449f8cf27de.zip gcc-e52c093a9fd668cddc2397719e8a5449f8cf27de.tar.gz gcc-e52c093a9fd668cddc2397719e8a5449f8cf27de.tar.bz2 |
re PR c++/84768 (ICE with failed class template argument deduction because of invalid template parameter)
/cp
2018-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84768
* pt.c (rewrite_template_parm): If the first argument is
error_mark_node return it immediately.
(build_deduction_guide): Check the return value of the
latter for error_mark_node.
(do_class_deduction): Check the return value of the latter.
/testsuite
2018-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84768
* g++.dg/cpp1z/class-deduction52.C: New.
From-SVN: r259049
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/pt.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/class-deduction52.C | 11 |
4 files changed, 38 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8759dc2..505b225 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2018-04-03 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/84768 + * pt.c (rewrite_template_parm): If the first argument is + error_mark_node return it immediately. + (build_deduction_guide): Check the return value of the + latter for error_mark_node. + (do_class_deduction): Check the return value of the latter. + 2018-04-03 Jason Merrill <jason@redhat.com> * semantics.c (finish_if_stmt_cond): Use diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4c0d298..80670a4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -25834,6 +25834,9 @@ static tree rewrite_template_parm (tree olddecl, unsigned index, unsigned level, tree tsubst_args, tsubst_flags_t complain) { + if (olddecl == error_mark_node) + return error_mark_node; + tree oldidx = get_template_parm_index (olddecl); tree newtype; @@ -25969,6 +25972,7 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain) else { ++processing_template_decl; + bool ok = true; fn_tmpl = (TREE_CODE (ctor) == TEMPLATE_DECL ? ctor @@ -26039,6 +26043,8 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain) tree olddecl = TREE_VALUE (oldelt); tree newdecl = rewrite_template_parm (olddecl, index, level, tsubst_args, complain); + if (newdecl == error_mark_node) + ok = false; tree newdef = tsubst_template_arg (TREE_PURPOSE (oldelt), tsubst_args, complain, ctor); tree list = build_tree_list (newdef, newdecl); @@ -26060,7 +26066,10 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain) current_template_parms = save_parms; } + --processing_template_decl; + if (!ok) + return error_mark_node; } if (!memtmpl) @@ -26187,6 +26196,8 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags, for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type)); iter; ++iter) { tree guide = build_deduction_guide (*iter, outer_args, complain); + if (guide == error_mark_node) + return error_mark_node; if ((flags & LOOKUP_ONLYCONVERTING) && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide))) elided = true; @@ -26238,6 +26249,8 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags, if (gtype) { tree guide = build_deduction_guide (gtype, outer_args, complain); + if (guide == error_mark_node) + return error_mark_node; cands = lookup_add (guide, cands); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 70fd513..220fd8f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-03 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/84768 + * g++.dg/cpp1z/class-deduction52.C: New. + 2018-04-03 Jakub Jelinek <jakub@redhat.com> PR c++/85147 diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction52.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction52.C new file mode 100644 index 0000000..db786ce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction52.C @@ -0,0 +1,11 @@ +// PR c++/84768 +// { dg-additional-options -std=c++17 } + +template<typename> struct A {}; + +template<typename T> struct B +{ + template<X Y> B(A<T>); // { dg-error "declared" } +}; + +B b = A<void>(); |