From a70f5987c4ae6de9f238eacd636f07305ce76d73 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 31 Mar 2009 23:34:30 -0400 Subject: [PATCH] re PR c++/34691 (Default argument checking not performed after overload resolution with C linkage) 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 | 4 ++++ gcc/cp/name-lookup.c | 18 ++++++++++++++++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.old-deja/g++.other/using9.C | 4 ++-- libstdc++-v3/ChangeLog | 2 ++ libstdc++-v3/libsupc++/unwind-cxx.h | 2 +- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index adb5be358ad..5b5268157e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2009-03-31 Jason Merrill + 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. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 5a92dc6ed89..277de78b420 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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); + } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 00dbf448019..6e723c3ec5c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-03-31 Jason Merrill + + * g++.old-deja/g++.other/using9.C: Add expected errors. + 2009-03-31 H.J. Lu * gcc.c-torture/compile/pr33009.c: Removed. diff --git a/gcc/testsuite/g++.old-deja/g++.other/using9.C b/gcc/testsuite/g++.old-deja/g++.other/using9.C index 9779f72d861..0e34156d8f6 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/using9.C +++ b/gcc/testsuite/g++.old-deja/g++.other/using9.C @@ -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 } diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1bcfc0b8045..27c8848822c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,7 @@ 2009-03-31 Jason Merrill + * 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. diff --git a/libstdc++-v3/libsupc++/unwind-cxx.h b/libstdc++-v3/libsupc++/unwind-cxx.h index 3e2cf0f00b4..ee42f6ad14e 100644 --- a/libstdc++-v3/libsupc++/unwind-cxx.h +++ b/libstdc++-v3/libsupc++/unwind-cxx.h @@ -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.