]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 20 Apr 2003 11:48:36 +0000 (11:48 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 20 Apr 2003 11:48:36 +0000 (11:48 +0000)
PR c++/10405
* search.c (lookup_field_1): Final scan goes backwards for
types, forwards for non-types.
testsuite:
PR c++/10405
* g++.dg/lookup/struct-hack1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65846 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/search.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/struct-hack1.C [new file with mode: 0644]

index 05545f13c66d2264c084706edb22e2e0392d6f25..0667a9718055577a8c682b668ab346790de1ba70 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-19  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/10405
+       * search.c (lookup_field_1): Final scan goes backwards for
+       types, forwards for non-types.
+
 2003-04-17  Roger Sayle  <roger@eyesopen.com>
 
        PR c/10375
index 9fc84311d38d45ba25f9841ad13cdf180671f632..433e1ac13ae046c4b6e5364604b9796711a12ced 100644 (file)
@@ -472,19 +472,23 @@ lookup_field_1 (tree type, tree name, bool want_type)
 
              /* We might have a nested class and a field with the
                 same name; we sorted them appropriately via
-                field_decl_cmp, so just look for the last field with
-                this name.  */
-             while (true)
+                field_decl_cmp, so just look for the first or last
+                field with this name.  */
+             if (want_type)
                {
-                 if (!want_type 
-                     || TREE_CODE (fields[i]) == TYPE_DECL
-                     || DECL_CLASS_TEMPLATE_P (fields[i]))
-                   field = fields[i];
-                 if (i + 1 == hi || DECL_NAME (fields[i+1]) != name)
-                   break;
-                 i++;
+                 do
+                   field = fields[i--];
+                 while (i >= lo && DECL_NAME (fields[i]) == name);
+                 if (TREE_CODE (field) != TYPE_DECL
+                     && !DECL_CLASS_TEMPLATE_P (field))
+                   field = NULL_TREE;
+               }
+             else
+               {
+                 do
+                   field = fields[i++];
+                 while (i < hi && DECL_NAME (fields[i]) == name);
                }
-
              return field;
            }
        }
index 41df38fa7aa1cce726779995b0f75bb223ff1224..408d817eea36cb971f65f8f90e078c194d2573f6 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-19  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/10405
+       * g++.dg/lookup/struct-hack1.C: New test.
+
 2003-04-20  Neil Booth  <neil@daikokuya.co.uk>
 
        * ucs.c: Update diagnostic messages.
diff --git a/gcc/testsuite/g++.dg/lookup/struct-hack1.C b/gcc/testsuite/g++.dg/lookup/struct-hack1.C
new file mode 100644 (file)
index 0000000..e84d65b
--- /dev/null
@@ -0,0 +1,38 @@
+// { dg-do compile }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 19 Apr 2003 <nathan@codesourcery.com>
+
+// PR 10405. ICE
+
+#define MEM_ENUM(name) int name; enum name {};
+
+struct Base
+{
+  MEM_ENUM (a)
+  MEM_ENUM (b)
+  MEM_ENUM (c)
+  MEM_ENUM (d)
+  MEM_ENUM (e)
+  MEM_ENUM (f)
+  MEM_ENUM (g)
+  MEM_ENUM (h)
+  MEM_ENUM (i)
+  MEM_ENUM (j)
+  MEM_ENUM (k)
+  MEM_ENUM (l)
+  MEM_ENUM (m)
+  MEM_ENUM (n)
+  MEM_ENUM (o)
+  MEM_ENUM (p)
+  MEM_ENUM (q)
+  MEM_ENUM (r)
+  MEM_ENUM (s)
+  MEM_ENUM (t)
+  MEM_ENUM (u)
+  MEM_ENUM (v)
+  MEM_ENUM (w)
+    };
+
+struct D : Base  {};
+