aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-01-09 11:37:07 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-01-09 11:37:07 +0000
commit186c0fbe03c0b420d7164796a7e19688f1fa0ceb (patch)
treee130c908745dc3ab0bc23e553a26fbe7056fcfea /gcc
parent10a855c7f4b3347a55198395ff12f8847f0c33c6 (diff)
downloadgcc-186c0fbe03c0b420d7164796a7e19688f1fa0ceb.zip
gcc-186c0fbe03c0b420d7164796a7e19688f1fa0ceb.tar.gz
gcc-186c0fbe03c0b420d7164796a7e19688f1fa0ceb.tar.bz2
class.c (handle_using_decl): Reject using of constructor name of sourcing class.
cp: * 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. testsuite: * g++.old_deja/g++.pt/using8.C: New test. From-SVN: r38831
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/class.c16
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/using8.C43
4 files changed, 64 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4c84be0..fe4ee20 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 8b04aa3..ada9779 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1527,7 +1527,13 @@ handle_using_decl (using_decl, t)
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;
}
@@ -1567,16 +1573,16 @@ handle_using_decl (using_decl, t)
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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5eac771..c47778d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/using8.C b/gcc/testsuite/g++.old-deja/g++.other/using8.C
new file mode 100644
index 0000000..1dc29de
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/using8.C
@@ -0,0 +1,43 @@
+// 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
+};