Commit de0c0e69 by Nathan Sidwell Committed by Nathan Sidwell

re PR c++/10405 (Segfault in setup_class_bindings)

cp:
	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.

From-SVN: r65846
parent 1613e52b
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> 2003-04-17 Roger Sayle <roger@eyesopen.com>
PR c/10375 PR c/10375
......
...@@ -472,19 +472,23 @@ lookup_field_1 (tree type, tree name, bool want_type) ...@@ -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 /* We might have a nested class and a field with the
same name; we sorted them appropriately via same name; we sorted them appropriately via
field_decl_cmp, so just look for the last field with field_decl_cmp, so just look for the first or last
this name. */ field with this name. */
while (true) if (want_type)
{ {
if (!want_type do
|| TREE_CODE (fields[i]) == TYPE_DECL field = fields[i--];
|| DECL_CLASS_TEMPLATE_P (fields[i])) while (i >= lo && DECL_NAME (fields[i]) == name);
field = fields[i]; if (TREE_CODE (field) != TYPE_DECL
if (i + 1 == hi || DECL_NAME (fields[i+1]) != name) && !DECL_CLASS_TEMPLATE_P (field))
break; field = NULL_TREE;
i++; }
else
{
do
field = fields[i++];
while (i < hi && DECL_NAME (fields[i]) == name);
} }
return field; return field;
} }
} }
......
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> 2003-04-20 Neil Booth <neil@daikokuya.co.uk>
* ucs.c: Update diagnostic messages. * ucs.c: Update diagnostic messages.
......
// { 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 {};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment