diff options
author | Jason Merrill <jason@redhat.com> | 2009-03-31 23:34:30 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-03-31 23:34:30 -0400 |
commit | a70f5987c4ae6de9f238eacd636f07305ce76d73 (patch) | |
tree | 28baec4727faa9cf2f25112d0142bb8542c05ea1 | |
parent | 9daa490df62bde7a1e310e83f903103251370536 (diff) | |
download | gcc-a70f5987c4ae6de9f238eacd636f07305ce76d73.zip gcc-a70f5987c4ae6de9f238eacd636f07305ce76d73.tar.gz gcc-a70f5987c4ae6de9f238eacd636f07305ce76d73.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/using9.C | 4 | ||||
-rw-r--r-- | libstdc++-v3/ChangeLog | 2 | ||||
-rw-r--r-- | 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 adb5be3..5b52681 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 5a92dc6..277de78 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 00dbf44..6e723c3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. diff --git a/gcc/testsuite/g++.old-deja/g++.other/using9.C b/gcc/testsuite/g++.old-deja/g++.other/using9.C index 9779f72..0e34156 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 1bcfc0b..27c8848 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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. diff --git a/libstdc++-v3/libsupc++/unwind-cxx.h b/libstdc++-v3/libsupc++/unwind-cxx.h index 3e2cf0f..ee42f6a 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. |