From: Jason Merrill Date: Tue, 11 Mar 2003 22:43:44 +0000 (-0500) Subject: re PR c++/9820 (ice in build_baselink (templates)) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cf237c199cde6ed297fcf41bc6ea2a6a9723387a;p=gcc.git re PR c++/9820 (ice in build_baselink (templates)) PR c++/9820 * search.c (lookup_member): Fix handling of functions in a class being defined. From-SVN: r64193 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 121c2aefbac..679cd1158c9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-03-11 Jason Merrill + + PR c++/9820 + * search.c (lookup_member): Fix handling of functions in a class + being defined. + 2003-03-11 Mark Mitchell PR c++/8700 diff --git a/gcc/cp/search.c b/gcc/cp/search.c index f97cb743d2d..3d23766d152 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -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 index 00000000000..b81e4be94b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/init2.C @@ -0,0 +1,10 @@ +// PR c++/9820 + +template struct X { + template static int test(...); + template static int test(int *); + + static const int i = sizeof(X::template test(0)); +}; + +template class X;