This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/34691 testcase #3
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 31 Mar 2009 23:34:12 -0400
- Subject: C++ PATCH for c++/34691 testcase #3
Pretty trivial to make the code Dodji previously added also check for
mismatched signatures.
Tested x86_64-pc-linux-gnu, applied to trunk.
2009-03-31 Jason Merrill <jason@redhat.com>
PR c++/34691
* name-lookup.c (pushdecl_maybe_friend): Diagnose mismatched
extern "C" declarations.
* libsupc++/unwind-cxx.h: Correct __cxa_call_terminate prototype.
Index: gcc/cp/name-lookup.c
===================================================================
*** gcc/cp/name-lookup.c (revision 145359)
--- gcc/cp/name-lookup.c (working copy)
*************** pushdecl_maybe_friend (tree x, bool is_f
*** 778,789 ****
if ((TREE_CODE (x) == FUNCTION_DECL)
&& DECL_EXTERN_C_P (x)
/* We should ignore declarations happening in system headers. */
&& !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->value;
--- 778,795 ----
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);
! 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;
*************** pushdecl_maybe_friend (tree x, bool is_f
*** 810,815 ****
--- 816,829 ----
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: libstdc++-v3/libsupc++/unwind-cxx.h
===================================================================
*** libstdc++-v3/libsupc++/unwind-cxx.h (revision 145291)
--- libstdc++-v3/libsupc++/unwind-cxx.h (working copy)
*************** extern "C" void __cxa_bad_typeid ();
*** 192,198 ****
// 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));
#ifdef __ARM_EABI_UNWINDER__
// Arm EABI specified routines.
--- 192,198 ----
// 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 (_Unwind_Exception*) __attribute__((noreturn));
#ifdef __ARM_EABI_UNWINDER__
// Arm EABI specified routines.
Index: gcc/testsuite/g++.old-deja/g++.other/using9.C
===================================================================
*** gcc/testsuite/g++.old-deja/g++.other/using9.C (revision 145291)
--- gcc/testsuite/g++.old-deja/g++.other/using9.C (working copy)
*************** struct x {};
*** 13,21 ****
using ::x;
using ::a;
! extern "C" void foo ();
namespace {
! extern "C" int foo ();
using ::foo; // { dg-error "" } already in use
}
--- 13,21 ----
using ::x;
using ::a;
! extern "C" void foo (); // { dg-error "previous declaration" }
namespace {
! extern "C" int foo (); // { dg-error "C.*linkage" }
using ::foo; // { dg-error "" } already in use
}