summaryrefslogtreecommitdiff
path: root/gcc/config/sol2-cxx.c
blob: 56bcec2c507b0eb665fd788573e774fac6b967a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* C++ specific Solaris system support.
   Copyright (C) 2011-2014 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 "stringpool.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;
}