re PR c++/9820 (ice in build_baselink (templates))
authorJason Merrill <jason@redhat.com>
Tue, 11 Mar 2003 22:43:44 +0000 (17:43 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 11 Mar 2003 22:43:44 +0000 (17:43 -0500)
        PR c++/9820
        * search.c (lookup_member): Fix handling of functions in a class
        being defined.

From-SVN: r64193

gcc/cp/ChangeLog
gcc/cp/search.c
gcc/testsuite/g++.dg/template/init2.C [new file with mode: 0644]

index 121c2aefbac8a11c3fdcb9afed4e882fa742b914..679cd1158c996bb70b063815ca7a9ab851d32f49 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-11  Jason Merrill  <jason@redhat.com>
+
+       PR c++/9820
+       * search.c (lookup_member): Fix handling of functions in a class 
+       being defined.
+
 2003-03-11  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/8700
index f97cb743d2d33da9592cd475d3ce65ed0cea9206..3d23766d1527703e226c5a84b8866784d30133d4 100644 (file)
@@ -1212,11 +1212,15 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type)
 
   const char *errstr = 0;
 
+  /* Sanity check.  */
+  if (TREE_CODE (name) != IDENTIFIER_NODE)
+    abort ();
+
   if (xbasetype == current_class_type && TYPE_BEING_DEFINED (xbasetype)
       && IDENTIFIER_CLASS_VALUE (name))
     {
       tree field = IDENTIFIER_CLASS_VALUE (name);
-      if (TREE_CODE (field) != FUNCTION_DECL
+      if (! is_overloaded_fn (field)
          && ! (want_type && TREE_CODE (field) != TYPE_DECL))
        /* We're in the scope of this class, and the value has already
           been looked up.  Just return the cached value.  */
diff --git a/gcc/testsuite/g++.dg/template/init2.C b/gcc/testsuite/g++.dg/template/init2.C
new file mode 100644 (file)
index 0000000..b81e4be
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/9820
+
+template <typename T> struct X {
+  template<typename> static int test(...);
+  template<typename> static int test(int *);
+
+  static const int i = sizeof(X<T>::template test<int>(0));
+};
+
+template class X<int>;