* decl.c (lookup_and_check_tag): Diagnose nested class with
the same name as enclosing class.
* g++.dg/lookup/name-clash4.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91866
138bc75d-0d04-0410-961f-
82ee72b054a4
+2004-12-08 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/18100
+ * decl.c (lookup_and_check_tag): Diagnose nested class with
+ the same name as enclosing class.
+
2004-12-08 Nathan Sidwell <nathan@codesourcery.com>
PR c++/18803
if (decl && TREE_CODE (decl) == TYPE_DECL)
{
+ /* Look for invalid nested type:
+ class C {
+ class C {};
+ }; */
+ if (scope == ts_current && DECL_SELF_REFERENCE_P (decl))
+ {
+ error ("%qD has the same name as the class in which it is "
+ "declared",
+ decl);
+ return error_mark_node;
+ }
+
/* Two cases we need to consider when deciding if a class
template is allowed as an elaborated type specifier:
1. It is a self reference to its own class.
+2004-12-08 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/18100
+ * g++.dg/lookup/name-clash4.C: New test.
+
2004-12-08 Nathan Sidwell <nathan@codesourcery.com>
PR c++/18672
--- /dev/null
+// { dg-do compile }
+
+// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
+
+// PR c++/18100: Invalid nested type.
+
+struct A
+{
+ template<int> struct A {}; // { dg-error "same name" }
+};
+
+A::A<0> a; // { dg-error "not a template" }