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
This commit is contained in:
Jason Merrill 2009-03-31 23:34:30 -04:00 committed by Jason Merrill
parent 9daa490df6
commit a70f5987c4
6 changed files with 29 additions and 5 deletions

View 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.

View 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);
}
}
}

View 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.

View 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
}

View 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.

View 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.