diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-05-11 19:22:53 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-05-11 19:22:53 +0000 |
commit | f532d265f2093efd384e935396745753c83d4b9e (patch) | |
tree | 2e25afbafb429444bc7e2ede193a2c071080f184 /gcc | |
parent | 2ebcbfe8585b320bb16b1201c562f3d000f6c499 (diff) | |
download | gcc-f532d265f2093efd384e935396745753c83d4b9e.tar.gz |
* class.c (check_field_decls): Complain about non-static data
members with same name as class in class with constructor.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33856 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/class.c | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ad66b8deb82..34834b1ea46 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-05-11 Jason Merrill <jason@casey.cygnus.com> + + * class.c (check_field_decls): Complain about non-static data + members with same name as class in class with constructor. + 2000-05-10 Jason Merrill <jason@casey.cygnus.com> * decl.c (grokdeclarator): Allow non-static data members with diff --git a/gcc/cp/class.c b/gcc/cp/class.c index cbc367c3173..de9195e3a83 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3442,6 +3442,13 @@ check_field_decls (t, access_decls, empty_p, |= CLASSTYPE_READONLY_FIELDS_NEED_INIT (type); } + /* Core issue 80: A nonstatic data member is required to have a + different name from the class iff the class has a + user-defined constructor. */ + if (DECL_NAME (x) == constructor_name (t) + && TYPE_HAS_CONSTRUCTOR (t)) + cp_error_at ("field `%#D' with same name as class", x); + /* We set DECL_C_BIT_FIELD in grokbitfield. If the type and width are valid, we'll also set DECL_BIT_FIELD. */ if (DECL_C_BIT_FIELD (x)) |