aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-03-01 13:51:00 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-03-01 13:51:00 +0000
commit4d24a8896575dfb50d733d1213dbe00bb6df3ab3 (patch)
treeecf8d73f71d1b29c4061ae400e32663c70aa3aef
parent1abdf5e7476e4390edf3556d43a5601870cd3418 (diff)
downloadgcc-4d24a8896575dfb50d733d1213dbe00bb6df3ab3.zip
gcc-4d24a8896575dfb50d733d1213dbe00bb6df3ab3.tar.gz
gcc-4d24a8896575dfb50d733d1213dbe00bb6df3ab3.tar.bz2
decl2.c (do_nonmember_using_decl): Don't complain if we find same function.
cp: * decl2.c (do_nonmember_using_decl): Don't complain if we find same function. Do complain about ambiguating extern "C" declarations. testsuite: * g++.old-deja/g++.other/using9.C: New test. From-SVN: r40148
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c25
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/using9.C21
4 files changed, 43 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fc3fb94..c5d0c95 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2001-03-01 Nathan Sidwell <nathan@codesourcery.com>
+
+ * decl2.c (do_nonmember_using_decl): Don't complain if we find
+ same function. Do complain about ambiguating extern "C"
+ declarations.
+
2001-02-28 Nathan Sidwell <nathan@codesourcery.com>
Remove floating point and complex type template constant parms.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b371611..d115dcc 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -5126,22 +5126,21 @@ do_nonmember_using_decl (scope, name, oldval, oldtype, newval, newtype)
{
tree old_fn = OVL_CURRENT (tmp1);
- if (!OVL_USED (tmp1)
- && compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
- TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
+ if (new_fn == old_fn)
+ /* The function already exists in the current namespace. */
+ break;
+ else if (OVL_USED (tmp1))
+ continue; /* this is a using decl */
+ else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
+ TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
{
- if (!(DECL_EXTERN_C_P (new_fn)
- && DECL_EXTERN_C_P (old_fn)))
- /* There was already a non-using declaration in
- this scope with the same parameter types. */
- cp_error ("`%D' is already declared in this scope",
- name);
+ /* There was already a non-using declaration in
+ this scope with the same parameter types. If both
+ are the same extern "C" functions, that's ok. */
+ if (!decls_match (new_fn, old_fn))
+ cp_error ("`%D' is already declared in this scope", name);
break;
}
- else if (duplicate_decls (new_fn, old_fn))
- /* We're re-using something we already used
- before. We don't need to add it again. */
- break;
}
/* If we broke out of the loop, there's no reason to add
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fd0371d..414c253 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-03-01 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.other/using9.C: New test.
+
2001-02-28 Ovidiu Predescu <ovidiu@cup.hp.com>
* objc/execute/bycopy-3.m: Added new test from Nicola Pero.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/using9.C b/gcc/testsuite/g++.old-deja/g++.other/using9.C
new file mode 100644
index 0000000..acfab50
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/using9.C
@@ -0,0 +1,21 @@
+// Build don't link:
+//
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Feb 2001 <nathan@codesourcery.com>
+
+// Bug 75. using declarations cannot introduce functions which ambiguate
+// those in the current namespace, BUT here we're reaccessing the current
+// namespace -- the function is not being 'introduced'.
+
+extern int a();
+struct x {};
+
+using ::x;
+using ::a;
+
+extern "C" void foo ();
+
+namespace {
+ extern "C" int foo ();
+ using ::foo; // ERROR - already in use
+}