decl.c (grokdeclarator): Allow field with same name as class in extern "C".

* decl.c (grokdeclarator): Allow field with same name as class
	in extern "C".
	* decl.c (lookup_name_real): Don't limit field lookup to types.
	* class.c (check_member_decl_is_same_in_complete_scope): No error
	if icv and x are the same.
	* lex.c (do_identifier): Tweak error message.

From-SVN: r24269
This commit is contained in:
Jason Merrill 1998-12-12 16:41:15 +00:00 committed by Jason Merrill
parent d5db8224ad
commit 4d7614e9f1
4 changed files with 23 additions and 7 deletions

View File

@ -1,3 +1,13 @@
1998-12-08 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Allow field with same name as class
in extern "C".
* decl.c (lookup_name_real): Don't limit field lookup to types.
* class.c (check_member_decl_is_same_in_complete_scope): No error
if icv and x are the same.
* lex.c (do_identifier): Tweak error message.
1998-12-10 Mark Mitchell <mark@markmitchell.com>
* decl.c (start_enum): Use push_obstacks, not

View File

@ -4371,7 +4371,9 @@ check_member_decl_is_same_in_complete_scope (t, x)
else
icv = NULL_TREE;
if (icv
/* This should match pushdecl_class_level. */
if (icv && icv != x
&& flag_optional_diags
/* Don't complain about constructors. */
&& name != constructor_name (current_class_type)
/* Or inherited names. */

View File

@ -3809,6 +3809,7 @@ pushdecl_class_level (x)
members are checked in finish_struct. */
tree icv = IDENTIFIER_CLASS_VALUE (name);
/* This should match check_member_decl_is_same_in_complete_scope. */
if (icv && icv != x
&& flag_optional_diags
/* Don't complain about inherited names. */
@ -5191,9 +5192,9 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
classval = IDENTIFIER_CLASS_VALUE (name);
if (classval == NULL_TREE && TYPE_BEING_DEFINED (current_class_type))
/* Try to find values from base classes if we are presently
defining a type. We are presently only interested in
TYPE_DECLs. */
classval = lookup_field (current_class_type, name, 0, 1);
defining a type. We are primarily interested in
TYPE_DECLs or constants. */
classval = lookup_field (current_class_type, name, 0, prefer_type);
/* Add implicit 'typename' to types from template bases. lookup_field
will do this for us. If classval is actually from an enclosing
@ -10824,7 +10825,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
}
/* 9.2p13 [class.mem] */
if (declarator == constructor_name (current_class_type))
if (declarator == constructor_name (current_class_type)
/* Divergence from the standard: In extern "C", we
allow non-static data members here, because C does
and /usr/include/netinet/in.h uses that. */
&& (staticp || current_lang_name != lang_c))
cp_pedwarn ("ANSI C++ forbids data member `%D' with same name as enclosing class",
declarator);

View File

@ -2934,8 +2934,7 @@ do_identifier (token, parsing, args)
my_friendly_abort (61);
else
{
cp_error ("invalid use of member `%D' from base class `%T'", field,
DECL_FIELD_CONTEXT (field));
cp_error ("invalid use of member `%D'", field);
id = error_mark_node;
return id;
}