Replacing assert with error. Tested x86_64-pc-linux-gnu, applying to trunk.
commit e42789795f05e88b0b55c5da0670aa827ad046b2 Author: Jason Merrill <ja...@redhat.com> Date: Fri Jul 1 14:06:46 2011 -0400
PR c++/48261 * pt.c (lookup_template_function): Handle non-function. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5743159..7236e7e 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/g++.dg/template/template-id-3.C b/gcc/testsuite/g++.dg/template/template-id-3.C new file mode 100644 index 0000000..e0753ab --- /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<typename T> +struct Something +{ + void work() + { + double x=T::template add<double>(5.0,6.0); // { dg-error "add" } + } +}; + +int main() +{ + Something<Foo2> s2; + s2.work(); +}