]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/34691 (Default argument checking not performed after overload resolution...
authorJason Merrill <jason@redhat.com>
Wed, 1 Apr 2009 03:34:30 +0000 (23:34 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 1 Apr 2009 03:34:30 +0000 (23:34 -0400)
        PR c++/34691
        * name-lookup.c (pushdecl_maybe_friend): Diagnose mismatched
        extern C declarations.

        * libsupc++/unwind-cxx.h: Correct __cxa_call_terminate prototype.

From-SVN: r145386

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/using9.C
libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/unwind-cxx.h

index adb5be358ad48f2bf9b02ff81f55bbae876c076d..5b5268157e333c301770a7223fc0f9f4d14fd7c1 100644 (file)
@@ -1,5 +1,9 @@
 2009-03-31  Jason Merrill  <jason@redhat.com>
 
+       PR c++/34691
+       * name-lookup.c (pushdecl_maybe_friend): Diagnose mismatched
+       extern "C" declarations.
+
        C++ DR 613
        * semantics.c (finish_non_static_data_member): Allow such references
        without an associated object in sizeof/decltype/alignof.
index 5a92dc6ed89d68151a7ef51039b25711ac46e3d4..277de78b420e737ef8cd9c416e4378a2f291504d 100644 (file)
@@ -778,12 +778,18 @@ pushdecl_maybe_friend (tree x, bool is_friend)
       if ((TREE_CODE (x) == FUNCTION_DECL)
          && DECL_EXTERN_C_P (x)
           /* We should ignore declarations happening in system headers.  */
+         && !DECL_ARTIFICIAL (x)
          && !DECL_IN_SYSTEM_HEADER (x))
        {
          cxx_binding *function_binding =
              lookup_extern_c_fun_binding_in_all_ns (x);
-         if (function_binding
-              && !DECL_IN_SYSTEM_HEADER (function_binding->value))
+         tree previous = (function_binding
+                          ? function_binding->value
+                          : NULL_TREE);
+         if (previous
+             && !DECL_ARTIFICIAL (previous)
+              && !DECL_IN_SYSTEM_HEADER (previous)
+             && DECL_CONTEXT (previous) != DECL_CONTEXT (x))
            {
              tree previous = function_binding->value;
 
@@ -810,6 +816,14 @@ pushdecl_maybe_friend (tree x, bool is_friend)
                      POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
                    }
                }
+             else
+               {
+                 pedwarn (input_location, 0,
+                          "declaration of %q#D with C language linkage", x);
+                 pedwarn (input_location, 0,
+                          "conflicts with previous declaration %q+#D",
+                          previous);
+               }
            }
        }
 
index 00dbf4480194fc45695d9bb0523f7075e625a2c9..6e723c3ec5c7382284357e6baaf8d2574009a2e4 100644 (file)
@@ -1,3 +1,7 @@
+2009-03-31  Jason Merrill  <jason@redhat.com>
+
+       * g++.old-deja/g++.other/using9.C: Add expected errors.
+
 2009-03-31  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gcc.c-torture/compile/pr33009.c: Removed.
index 9779f72d8611a1cd5f7a53dd1fed0946b498d619..0e34156d8f6d7d0af99210c8f7a909d8f644bdb9 100644 (file)
@@ -13,9 +13,9 @@ struct x {};
 using ::x;
 using ::a;
 
-extern "C" void foo ();
+extern "C" void foo ();                // { dg-error "previous declaration" }
 
 namespace {
-  extern "C" int foo ();
+  extern "C" int foo ();       // { dg-error "C.*linkage" }
   using ::foo; // { dg-error "" } already in use
 }
index 1bcfc0b8045147d3ffa68759aaacd0808d1a2bf9..27c8848822c182f760ccb0e8d55069653c125ea7 100644 (file)
@@ -1,5 +1,7 @@
 2009-03-31  Jason Merrill  <jason@redhat.com>
 
+       * libsupc++/unwind-cxx.h: Correct __cxa_call_terminate prototype.
+
        PR libstdc++/39310
        * include/tr1_impl/type_traits (is_function): Add partial
        specializations with function cv-quals.
index 3e2cf0f00b40cd2223ca3cc322bc412371a17faa..ee42f6ad14e1bacea3c11a362c9a01d30dc5d7a7 100644 (file)
@@ -192,7 +192,7 @@ extern "C" void __cxa_bad_typeid ();
 // throws, and if bad_exception needs to be thrown.  Called from the
 // compiler.
 extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn));
-extern "C" void __cxa_call_terminate (void*) __attribute__((noreturn));
+extern "C" void __cxa_call_terminate (_Unwind_Exception*) __attribute__((noreturn));
 
 #ifdef __ARM_EABI_UNWINDER__
 // Arm EABI specified routines.