aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@casey.cygnus.com>2000-05-11 19:22:53 +0000
committerJason Merrill <jason@gcc.gnu.org>2000-05-11 15:22:53 -0400
commitc10bffd02ffc4d35cd2aaaf9410e3ff3eb696932 (patch)
tree2e25afbafb429444bc7e2ede193a2c071080f184 /gcc/cp
parentb58c068a646378dace11c00354c9f8132d856304 (diff)
downloadgcc-c10bffd02ffc4d35cd2aaaf9410e3ff3eb696932.zip
gcc-c10bffd02ffc4d35cd2aaaf9410e3ff3eb696932.tar.gz
gcc-c10bffd02ffc4d35cd2aaaf9410e3ff3eb696932.tar.bz2
class.c (check_field_decls): Complain about non-static data members with same name as class in class with...
* class.c (check_field_decls): Complain about non-static data members with same name as class in class with constructor. From-SVN: r33856
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/class.c7
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ad66b8d..34834b1 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 cbc367c..de9195e 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))