From: Jason Merrill Date: Fri, 1 Jul 2011 20:24:38 +0000 (-0400) Subject: re PR c++/48261 (internal compiler error: in lookup_template_function, at cp/pt.c... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=948587e7984eca232fcc1d05866c0e40ac1e0af9;p=gcc.git re PR c++/48261 (internal compiler error: in lookup_template_function, at cp/pt.c:6227) PR c++/48261 * pt.c (lookup_template_function): Handle non-function. From-SVN: r175766 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5cfdfbf9b0e..38ede649311 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-07-01 Jason Merrill + PR c++/48261 + * pt.c (lookup_template_function): Handle non-function. + PR c++/48593 * pt.c (tsubst_qualified_id): Check PTRMEM_OK_P. * tree.c (build_qualified_name): Set PTRMEM_OK_P. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 57431598148..7236e7e5168 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6622,8 +6622,12 @@ lookup_template_function (tree fns, tree arglist) return error_mark_node; gcc_assert (!arglist || TREE_CODE (arglist) == TREE_VEC); - gcc_assert (fns && (is_overloaded_fn (fns) - || TREE_CODE (fns) == IDENTIFIER_NODE)); + + if (!is_overloaded_fn (fns) && TREE_CODE (fns) != IDENTIFIER_NODE) + { + error ("%q#D is not a function template", fns); + return error_mark_node; + } if (BASELINK_P (fns)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a201db2df80..c13fd9f5da3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-07-01 Jason Merrill + PR c++/48261 + * g++.dg/template/template-id-3.C: New. + PR c++/48593 * g++.dg/template/qualified-id4.C: New. diff --git a/gcc/testsuite/g++.dg/template/template-id-3.C b/gcc/testsuite/g++.dg/template/template-id-3.C new file mode 100644 index 00000000000..e0753abd9e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/template-id-3.C @@ -0,0 +1,22 @@ +// PR c++/48261 + +typedef double (*gaddType)(double,double); +struct Foo2 +{ + static gaddType add; +}; + +template +struct Something +{ + void work() + { + double x=T::template add(5.0,6.0); // { dg-error "add" } + } +}; + +int main() +{ + Something s2; + s2.work(); +}