re PR c++/48261 (internal compiler error: in lookup_template_function, at cp/pt.c...
authorJason Merrill <jason@redhat.com>
Fri, 1 Jul 2011 20:24:38 +0000 (16:24 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 1 Jul 2011 20:24:38 +0000 (16:24 -0400)
PR c++/48261
* pt.c (lookup_template_function): Handle non-function.

From-SVN: r175766

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/template-id-3.C [new file with mode: 0644]

index 5cfdfbf9b0eb999d49f542af6be69f6d397e6723..38ede649311d270decf2b5604b06c13200233852 100644 (file)
@@ -1,5 +1,8 @@
 2011-07-01  Jason Merrill  <jason@redhat.com>
 
+       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.
index 5743159814831ee3234c011379b654ab263e5e20..7236e7e5168ecee87f43e27275e1d2ec8cab61e1 100644 (file)
@@ -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))
     {
index a201db2df806736e4fb98e0860e0a766ec6d2cd8..c13fd9f5da3f690dfedf8185ea8b5bdfbeb49c56 100644 (file)
@@ -1,5 +1,8 @@
 2011-07-01  Jason Merrill  <jason@redhat.com>
 
+       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 (file)
index 0000000..e0753ab
--- /dev/null
@@ -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();
+}