]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/15285 (instantiate_type ICE when forming pointer to template function)
authorMark Mitchell <mark@codesourcery.com>
Sat, 22 May 2004 21:45:24 +0000 (21:45 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sat, 22 May 2004 21:45:24 +0000 (21:45 +0000)
PR c++/15285
PR c++/15299
* pt.c (build_non_dependent_expr): Expand the set of tree nodes
recognized as overloaded functions.

PR c++/15285
PR c++/15299
* g++.dg/template/non-dependent5.C: New test.
* g++.dg/template/non-dependent6.C: New test.

From-SVN: r82149

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

index 063ea63f819c3b54295af09d7359a620b14e45f1..9af31d52885222cfb4c59b7bec6afa14156dae99 100644 (file)
@@ -1,3 +1,10 @@
+2004-05-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15285
+       PR c++/15299
+       * pt.c (build_non_dependent_expr): Expand the set of tree nodes
+       recognized as overloaded functions.
+
 2004-05-22  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/15507
index 043e3e467c25f80af9d0a1ca83991c5b96581bb6..c506609b7f1c00c1b9ef729f01f1c16d94cd2f69 100644 (file)
@@ -12158,15 +12158,20 @@ resolve_typename_type (tree type, bool only_current_p)
 tree
 build_non_dependent_expr (tree expr)
 {
+  tree inner_expr;
+
   /* Preserve null pointer constants so that the type of things like 
      "p == 0" where "p" is a pointer can be determined.  */
   if (null_ptr_cst_p (expr))
     return expr;
   /* Preserve OVERLOADs; the functions must be available to resolve
      types.  */
-  if (TREE_CODE (expr) == OVERLOAD 
-      || TREE_CODE (expr) == FUNCTION_DECL
-      || TREE_CODE (expr) == TEMPLATE_DECL)
+  inner_expr = (TREE_CODE (expr) == ADDR_EXPR ? 
+               TREE_OPERAND (expr, 0) : expr);
+  if (TREE_CODE (inner_expr) == OVERLOAD 
+      || TREE_CODE (inner_expr) == FUNCTION_DECL
+      || TREE_CODE (inner_expr) == TEMPLATE_DECL
+      || TREE_CODE (inner_expr) == TEMPLATE_ID_EXPR)
     return expr;
   /* Preserve string constants; conversions from string constants to
      "char *" are allowed, even though normally a "const char *"
index 2d7c928f9d0f14680a8e0cbc7853dac46c78a738..c8f51f5297d6dd31fb17cb9799512bc2217b3f26 100644 (file)
@@ -1,3 +1,10 @@
+2004-05-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15285
+       PR c++/15299
+       * g++.dg/template/non-dependent5.C: New test.
+       * g++.dg/template/non-dependent6.C: New test.
+
 2004-05-22  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/15507
diff --git a/gcc/testsuite/g++.dg/template/non-dependent5.C b/gcc/testsuite/g++.dg/template/non-dependent5.C
new file mode 100644 (file)
index 0000000..bd6ce6b
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/15299
+
+template <class T>  void fun_ptr(T (*)()); 
+template <class T>  T    bar(); 
+template <class> void foo () { 
+  fun_ptr(bar<int>); 
+} 
diff --git a/gcc/testsuite/g++.dg/template/non-dependent6.C b/gcc/testsuite/g++.dg/template/non-dependent6.C
new file mode 100644 (file)
index 0000000..0959a3d
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/15285
+
+void foo(void (*func)()) {}
+
+template<typename T>
+void bar()
+{}
+
+template<typename T>
+void baz()
+{
+  foo(&bar<long>);
+}
This page took 0.11242 seconds and 5 git commands to generate.