diff options
author | Jason Merrill <jason@yorick.cygnus.com> | 1998-12-12 16:41:15 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-12-12 11:41:15 -0500 |
commit | 4d7614e9f1741e6d01c35ba1e40e22da4abe91cd (patch) | |
tree | ca189ed953b571a2b77b7df975656cfd2e91ab68 /gcc | |
parent | d5db8224ad6c2ef118b67e22ec6820b94fa5fbb2 (diff) | |
download | gcc-4d7614e9f1741e6d01c35ba1e40e22da4abe91cd.zip gcc-4d7614e9f1741e6d01c35ba1e40e22da4abe91cd.tar.gz gcc-4d7614e9f1741e6d01c35ba1e40e22da4abe91cd.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/class.c | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 13 | ||||
-rw-r--r-- | gcc/cp/lex.c | 3 |
4 files changed, 23 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fa24fae..1c3bd37 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 46d162e..a73605a 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c278875..c2afcb7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 4c11871..45d3d41 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -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; } |