From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Elizabeth Chastain To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: libstdc++/2445: undefined reference to `std::errno' Date: Sun, 15 Apr 2001 00:46:00 -0000 Message-id: <20010415074601.691.qmail@sourceware.cygnus.com> X-SW-Source: 2001-04/msg00273.html List-Id: The following reply was made to PR libstdc++/2445; it has been noted by GNATS. From: Michael Elizabeth Chastain To: gcc-gnats@gcc.gnu.org Cc: Subject: Re: libstdc++/2445: undefined reference to `std::errno' Date: Sun, 15 Apr 2001 00:41:49 -0700 Hmmm, this patch fragment looks suspicious to me. It handles extern "C" functions, and it handles extern "C" variables in the global namespace. I suspect that it also needs to handle extern "C" variables in subordinate namespaces. diff -u -r -N 2001-03-20-14-00-00/source/gcc/cp/mangle.c 2001-03-20-14-05-00/source/gcc/cp/mangle.c --- 2001-03-20-14-00-00/source/gcc/cp/mangle.c Thu Feb 22 13:37:39 2001 +++ 2001-03-20-14-05-00/source/gcc/cp/mangle.c Tue Mar 20 14:03:45 2001 @@ -2069,6 +2069,17 @@ if (TREE_CODE (decl) == TYPE_DECL) write_type (TREE_TYPE (decl)); + else if (/* The names of `extern "C"' functions are not mangled. */ + (TREE_CODE (decl) == FUNCTION_DECL + /* If there's no DECL_LANG_SPECIFIC, it's a function built + by language-independent code, which never builds + functions with C++ linkage. */ + && (!DECL_LANG_SPECIFIC (decl) + || DECL_EXTERN_C_FUNCTION_P (decl))) + /* The names of global variables aren't mangled either. */ + || (TREE_CODE (decl) == VAR_DECL + && CP_DECL_CONTEXT (decl) == global_namespace)) + write_string (IDENTIFIER_POINTER (DECL_NAME (decl))); else { write_mangled_name (decl);