From: Marek Polacek Date: Tue, 4 Dec 2018 19:28:27 +0000 (+0000) Subject: PR c++/88184 - ICE when treating name as template-name. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22f309bc29de788fc686f9f98b194996b109b218;p=gcc.git PR c++/88184 - ICE when treating name as template-name. * pt.c (lookup_template_function): Always build the TEMPLATE_ID_EXPR with unknown_type_node. * g++.dg/cpp2a/fn-template17.C: New test. * g++.dg/cpp2a/fn-template18.C: New test. From-SVN: r266793 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 866fd33e6bd..d43d6132d34 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-12-04 Marek Polacek + + PR c++/88184 - ICE when treating name as template-name. + * pt.c (lookup_template_function): Always build the TEMPLATE_ID_EXPR + with unknown_type_node. + 2018-12-04 Julian Brown * parser.c (cp_parser_oacc_wait_list): Fix error message and avoid diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a0d899f594b..78addc6c1c2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9068,8 +9068,6 @@ add_pending_template (tree d) tree lookup_template_function (tree fns, tree arglist) { - tree type; - if (fns == error_mark_node || arglist == error_mark_node) return error_mark_node; @@ -9090,11 +9088,7 @@ lookup_template_function (tree fns, tree arglist) return fns; } - type = TREE_TYPE (fns); - if (TREE_CODE (fns) == OVERLOAD || !type) - type = unknown_type_node; - - return build2 (TEMPLATE_ID_EXPR, type, fns, arglist); + return build2 (TEMPLATE_ID_EXPR, unknown_type_node, fns, arglist); } /* Within the scope of a template class S, the name S gets bound diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 558f0deed0f..887705e2503 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-12-04 Marek Polacek + + PR c++/88184 - ICE when treating name as template-name. + * g++.dg/cpp2a/fn-template17.C: New test. + * g++.dg/cpp2a/fn-template18.C: New test. + 2018-12-04 David Edelsohn * gcc.dg/live-patching-2.c: Require LTO. diff --git a/gcc/testsuite/g++.dg/cpp2a/fn-template17.C b/gcc/testsuite/g++.dg/cpp2a/fn-template17.C new file mode 100644 index 00000000000..f0d24107682 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/fn-template17.C @@ -0,0 +1,21 @@ +// PR c++/88184 +// { dg-do compile } +// { dg-options "-std=c++2a -fchecking=2" } + +namespace A +{ + void f (); +} + +using A::f; + +template void g () +{ + f (); // { dg-error "no matching function for call" } +} + +void +fn () +{ + g(); +} diff --git a/gcc/testsuite/g++.dg/cpp2a/fn-template18.C b/gcc/testsuite/g++.dg/cpp2a/fn-template18.C new file mode 100644 index 00000000000..7fe5e89ace3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/fn-template18.C @@ -0,0 +1,23 @@ +// PR c++/88184 +// { dg-do compile } +// { dg-options "-std=c++2a -fchecking=2" } + +namespace A +{ + void f (); + void f (int); + void f (int, int); +} + +using A::f; + +template void g () +{ + f (); // { dg-error "no matching function for call" } +} + +void +fn () +{ + g(); +}