+2001-01-09 Nathan Sidwell <nathan@codesourcery.com>
+
+ * class.c (handle_using_decl): Reject using of constructor name
+ of sourcing class. Allow injecting of a method with same name as
+ nested class. Fixup error messages.
+
2001-01-09 Joseph S. Myers <jsm28@cam.ac.uk>
* decl2.c (lang_decode_option): Handle -Wformat=2.
if (name == constructor_name (ctype)
|| name == constructor_name_full (ctype))
{
- cp_error_at ("using-declaration for constructor", using_decl);
+ cp_error_at ("`%D' names constructor", using_decl);
+ return;
+ }
+ if (name == constructor_name (t)
+ || name == constructor_name_full (t))
+ {
+ cp_error_at ("`%D' invalid in `%T'", using_decl, t);
return;
}
the same name already present in the current class. */;
else
{
- cp_error ("`%D' invalid in `%#T'", using_decl, t);
+ cp_error_at ("`%D' invalid in `%#T'", using_decl, t);
cp_error_at (" because of local method `%#D' with same name",
OVL_CURRENT (old_value));
return;
}
}
- else
+ else if (!DECL_ARTIFICIAL (old_value))
{
- cp_error ("`%D' invalid in `%#T'", using_decl, t);
- cp_error_at (" because of local field `%#D' with same name", old_value);
+ cp_error_at ("`%D' invalid in `%#T'", using_decl, t);
+ cp_error_at (" because of local member `%#D' with same name", old_value);
return;
}
+2001-01-09 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old_deja/g++.pt/using8.C: New test.
+
2001-01-09 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.dg/format/attr-2.c, gcc.dg/format/attr-3.c: New tests.
--- /dev/null
+// Build don't link:
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com>
+
+// We rejected using decls bringing in functions from a base which would hide a
+// nested class of the same name, but only if we had no functions by that name
+// already. Also, we failed to find that using declaration during lookup. Also
+// we failed to reject using declarations which matched the constructor name.
+
+struct A
+{
+ int f ();
+ void D ();
+};
+
+struct A2 {
+ typedef int f;
+};
+
+struct B : A
+{
+ using A::f;
+ struct f {};
+};
+
+struct C : A
+{
+ using A::f;
+ int f (int);
+ struct f {};
+};
+
+void foo (B *bp, C* cp)
+{
+ bp->f ();
+ cp->f ();
+}
+
+struct D : A
+{
+ using A::D; // ERROR - names constructor
+};