re PR c++/9924 (Multiple using statements for builtin functions not allowed)
authorMark Mitchell <mark@codesourcery.com>
Tue, 11 Mar 2003 23:07:45 +0000 (23:07 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 11 Mar 2003 23:07:45 +0000 (23:07 +0000)
PR c++/9924
* g++.dg/overload/builtin2.C: New test.

2003-03-11  Mark Mitchell  <mark@codesourcery.com>

PR c++/9924
* decl2.c (do_nonmember_using_decl): Ignore anticipated builtins.

From-SVN: r64197

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/overload/builtin2.C [new file with mode: 0644]

index 679cd1158c996bb70b063815ca7a9ab851d32f49..9dcd1c7c2cd2ee4bc9c3d5c7ceab048610c943cd 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-11  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9924
+       * decl2.c (do_nonmember_using_decl): Ignore anticipated builtins.
+
 2003-03-11  Jason Merrill  <jason@redhat.com>
 
        PR c++/9820
index c2f1f6c35597340b516165841b3c5be267c1ab72..b96f65f2034e9fa451fdd4197484ebed01d63e81 100644 (file)
@@ -4251,21 +4251,27 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype,
              else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
                                  TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
                {
-                  /* If this using declaration introduces a function
-                     recognized as a built-in, no longer mark it as
-                     anticipated in this scope.  */
-                  if (DECL_ANTICIPATED (old_fn))
-                    {
-                      DECL_ANTICIPATED (old_fn) = 0;
-                      break;
-                    }
-
                  /* 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))
-                   error ("`%D' is already declared in this scope", name);
-                 break;
+                  if (decls_match (new_fn, old_fn))
+                   {
+                     /* If the OLD_FN was a builtin, there is now a
+                        real declaration.  */
+                     if (DECL_ANTICIPATED (old_fn))
+                       DECL_ANTICIPATED (old_fn) = 0;
+                     break;
+                   }
+                 else if (!DECL_ANTICIPATED (old_fn))
+                   {
+                     /* If the OLD_FN was really declared, the
+                        declarations don't match.  */
+                     error ("`%D' is already declared in this scope", name);
+                     break;
+                   }
+
+                 /* If the OLD_FN was not really there, just ignore
+                    it and keep going.  */
                }
            }
 
index 6ec4a1580d0a02dbcdfbca2ce0838fdff49eea04..8cd81afe61f0181baf3e4609ac5c2c4babbc84da 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-11  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9924
+       * g++.dg/overload/builtin2.C: New test.
+
 2003-03-11  Steven Bosscher  <s.bosscher@student.tudelft.nl>
 
        * gcc.dg/return-type-3.c: New test.
diff --git a/gcc/testsuite/g++.dg/overload/builtin2.C b/gcc/testsuite/g++.dg/overload/builtin2.C
new file mode 100644 (file)
index 0000000..4f9f52d
--- /dev/null
@@ -0,0 +1,8 @@
+namespace __gnu_cxx {
+    void llabs(long long x);
+}
+
+namespace std {
+    using __gnu_cxx::llabs;
+    using __gnu_cxx::llabs;
+}