aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/mangle.cc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2022-03-02 19:42:23 -0500
committerNathan Sidwell <nathan@acm.org>2022-03-04 14:59:28 -0500
commit591d2130348b15ec9158bb69a7fd9442bb81fa3a (patch)
tree4a89a8904660c32c058face949c8068d47d32f03 /gcc/cp/mangle.cc
parent14dfbb53594e164fe222476523a68039a8bd5252 (diff)
downloadgcc-591d2130348b15ec9158bb69a7fd9442bb81fa3a.zip
gcc-591d2130348b15ec9158bb69a7fd9442bb81fa3a.tar.gz
gcc-591d2130348b15ec9158bb69a7fd9442bb81fa3a.tar.bz2
c++: Standard mangling abbreviations & modules
The std manglings for things like std::string should not apply if we're not in the global module. gcc/cp/ * mangle.cc (is_std_substitution): Check global module. (is_std_substitution_char): Return bool. gcc/testsuite/ * g++.dg/modules/std-subst-2.C: New. * g++.dg/modules/std-subst-3.C: New. * g++.dg/modules/std-subst-4_a.C: New. * g++.dg/modules/std-subst-4_b.C: New. * g++.dg/modules/std-subst-4_c.C: New.
Diffstat (limited to 'gcc/cp/mangle.cc')
-rw-r--r--gcc/cp/mangle.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 6657ce4..dbcec0a 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -180,9 +180,9 @@ static tree maybe_template_info (const tree);
static inline tree canonicalize_for_substitution (tree);
static void add_substitution (tree);
-static inline int is_std_substitution (const tree,
+static inline bool is_std_substitution (const tree,
const substitution_identifier_index_t);
-static inline int is_std_substitution_char (const tree,
+static inline bool is_std_substitution_char (const tree,
const substitution_identifier_index_t);
static int find_substitution (tree);
static void mangle_call_offset (const tree, const tree);
@@ -467,9 +467,10 @@ add_substitution (tree node)
/* Helper function for find_substitution. Returns nonzero if NODE,
which may be a decl or a CLASS_TYPE, is a template-id with template
- name of substitution_index[INDEX] in the ::std namespace. */
+ name of substitution_index[INDEX] in the ::std namespace, with
+ global module attachment. */
-static inline int
+static bool
is_std_substitution (const tree node,
const substitution_identifier_index_t index)
{
@@ -488,13 +489,22 @@ is_std_substitution (const tree node,
}
else
/* These are not the droids you're looking for. */
- return 0;
+ return false;
+
+ if (!DECL_NAMESPACE_STD_P (CP_DECL_CONTEXT (decl)))
+ return false;
+
+ if (!(TYPE_LANG_SPECIFIC (type) && TYPE_TEMPLATE_INFO (type)))
+ return false;
- return (DECL_NAMESPACE_STD_P (CP_DECL_CONTEXT (decl))
- && TYPE_LANG_SPECIFIC (type)
- && TYPE_TEMPLATE_INFO (type)
- && (DECL_NAME (TYPE_TI_TEMPLATE (type))
- == subst_identifiers[index]));
+ tree tmpl = TYPE_TI_TEMPLATE (type);
+ if (DECL_NAME (tmpl) != subst_identifiers[index])
+ return false;
+
+ if (modules_p () && get_originating_module (tmpl, true) >= 0)
+ return false;
+
+ return true;
}
/* Return the ABI tags (the TREE_VALUE of the "abi_tag" attribute entry) for T,
@@ -526,7 +536,7 @@ get_abi_tags (tree t)
::std::identifier<char>, where identifier is
substitution_index[INDEX]. */
-static inline int
+static bool
is_std_substitution_char (const tree node,
const substitution_identifier_index_t index)
{