diff options
author | Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> | 2011-08-18 14:47:46 +0000 |
---|---|---|
committer | Rainer Orth <ro@gcc.gnu.org> | 2011-08-18 14:47:46 +0000 |
commit | 5b880ea61c107da98ea87a5ffad4520445d60007 (patch) | |
tree | 15183626c4d31ca839660bc4750300b8ed0ef58d /gcc/config/sol2-cxx.c | |
parent | 901ebcdf97fefd24e464f98593bfa6dc741d4525 (diff) | |
download | gcc-5b880ea61c107da98ea87a5ffad4520445d60007.tar.gz |
Keep tm, div_t, ldiv_t, lconv mangling on Solaris (PR libstdc++-v3/1773)
Co-Authored-By: Marc Glisse <marc.glisse@normalesup.org>
From-SVN: r177863
Diffstat (limited to 'gcc/config/sol2-cxx.c')
-rw-r--r-- | gcc/config/sol2-cxx.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/gcc/config/sol2-cxx.c b/gcc/config/sol2-cxx.c new file mode 100644 index 00000000000..4c89d0d3607 --- /dev/null +++ b/gcc/config/sol2-cxx.c @@ -0,0 +1,64 @@ +/* C++ specific Solaris system support. + Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "cp/cp-tree.h" +#include "tm.h" +#include "tm_p.h" + +/* Before GCC 4.7, g++ defined __cplusplus 1 to avoid coping with the C++98 + overloads in Solaris system headers. Since this was fixed, 4 structure + types would move to namespace std, breaking the Solaris libstdc++ ABI. + To avoid this, we forcefully keep those types in the global namespace. + This can be removed once the next major version of libstdc++ is + released. */ + +/* Cache the identifiers of the affected types to speed up lookup. */ +#define NUM_FGID 4 +static GTY(()) tree force_global_identifiers[NUM_FGID]; + +/* Check if DECL is one of the affected types and move it to the global + namespace if so. */ +tree +solaris_cxx_decl_mangling_context (const_tree decl) +{ + static bool init = false; + int i = 0; + + if (!init) + { + force_global_identifiers[i++] = get_identifier ("div_t"); + force_global_identifiers[i++] = get_identifier ("ldiv_t"); + force_global_identifiers[i++] = get_identifier ("lconv"); + force_global_identifiers[i++] = get_identifier ("tm"); + init = true; + } + + if (!(DECL_P (decl) && DECL_NAMESPACE_STD_P (CP_DECL_CONTEXT (decl)))) + return NULL_TREE; + + for (i = 0; i < NUM_FGID; i++) + if (DECL_NAME (decl) == force_global_identifiers[i]) + return global_namespace; + + return NULL_TREE; +} |