xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/sol2-cxx.c (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg /* C++ specific Solaris system support.
2*8feb0f0bSmrg    Copyright (C) 2011-2020 Free Software Foundation, Inc.
31debfc3dSmrg 
41debfc3dSmrg This file is part of GCC.
51debfc3dSmrg 
61debfc3dSmrg GCC is free software; you can redistribute it and/or modify
71debfc3dSmrg it under the terms of the GNU General Public License as published by
81debfc3dSmrg the Free Software Foundation; either version 3, or (at your option)
91debfc3dSmrg any later version.
101debfc3dSmrg 
111debfc3dSmrg GCC is distributed in the hope that it will be useful,
121debfc3dSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
131debfc3dSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
141debfc3dSmrg GNU General Public License for more details.
151debfc3dSmrg 
161debfc3dSmrg You should have received a copy of the GNU General Public License
171debfc3dSmrg along with GCC; see the file COPYING3.  If not see
181debfc3dSmrg <http://www.gnu.org/licenses/>.  */
191debfc3dSmrg 
201debfc3dSmrg #include "config.h"
211debfc3dSmrg #include "system.h"
221debfc3dSmrg #include "coretypes.h"
231debfc3dSmrg #include "cp/cp-tree.h"
241debfc3dSmrg #include "stringpool.h"
251debfc3dSmrg 
261debfc3dSmrg /* Before GCC 4.7, g++ defined __cplusplus 1 to avoid coping with the C++98
271debfc3dSmrg    overloads in Solaris system headers.  Since this was fixed, 4 structure
281debfc3dSmrg    types would move to namespace std, breaking the Solaris libstdc++ ABI.
291debfc3dSmrg    To avoid this, we forcefully keep those types in the global namespace.
301debfc3dSmrg    This can be removed once the next major version of libstdc++ is
311debfc3dSmrg    released.  */
321debfc3dSmrg 
331debfc3dSmrg /* Cache the identifiers of the affected types to speed up lookup.  */
341debfc3dSmrg #define NUM_FGID 4
351debfc3dSmrg static GTY(()) tree force_global_identifiers[NUM_FGID];
361debfc3dSmrg 
371debfc3dSmrg /* Check if DECL is one of the affected types and move it to the global
381debfc3dSmrg    namespace if so.  */
391debfc3dSmrg tree
solaris_cxx_decl_mangling_context(const_tree decl)401debfc3dSmrg solaris_cxx_decl_mangling_context (const_tree decl)
411debfc3dSmrg {
421debfc3dSmrg   static bool init = false;
431debfc3dSmrg   int i = 0;
441debfc3dSmrg 
451debfc3dSmrg   if (!init)
461debfc3dSmrg     {
471debfc3dSmrg       force_global_identifiers[i++] = get_identifier ("div_t");
481debfc3dSmrg       force_global_identifiers[i++] = get_identifier ("ldiv_t");
491debfc3dSmrg       force_global_identifiers[i++] = get_identifier ("lconv");
501debfc3dSmrg       force_global_identifiers[i++] = get_identifier ("tm");
511debfc3dSmrg       init = true;
521debfc3dSmrg     }
531debfc3dSmrg 
541debfc3dSmrg   if (!(DECL_P (decl) && DECL_NAMESPACE_STD_P (CP_DECL_CONTEXT (decl))))
551debfc3dSmrg     return NULL_TREE;
561debfc3dSmrg 
571debfc3dSmrg   for (i = 0; i < NUM_FGID; i++)
581debfc3dSmrg     if (DECL_NAME (decl) == force_global_identifiers[i])
591debfc3dSmrg 	return global_namespace;
601debfc3dSmrg 
611debfc3dSmrg   return NULL_TREE;
621debfc3dSmrg }
63