+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.
{
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
--- /dev/null
+// 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
+}