mangle.c (mangle_decl_string): Mangle the names of overloaded operators, even when...
authorMark Mitchell <mark@codesourcery.com>
Wed, 21 Mar 2001 17:19:54 +0000 (17:19 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 21 Mar 2001 17:19:54 +0000 (17:19 +0000)
* mangle.c (mangle_decl_string): Mangle the names of overloaded
operators, even when they have `extern "C"' linkage.

From-SVN: r40690

gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/testsuite/g++.old-deja/g++.other/mangle2.C [new file with mode: 0644]

index 15ff7b546bb335993a144a83958297f1e0d61c78..3488b1149ef23d7f3201b68598b492d8c3f61841 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-21  Mark Mitchell  <mark@codesourcery.com>
+
+       * mangle.c (mangle_decl_string): Mangle the names of overloaded
+       operators, even when they have `extern "C"' linkage.
+
 2001-03-19  Mark Mitchell  <mark@codesourcery.com>
 
        * class.c (get_vtable_decl): Use SET_DECL_ASSEMBLER_NAME,
index 4d63f768b35cc0a91bb6fbada040a8d950605add..101f412385276b8ea298fdaad46d69e3bbb1d8a2 100644 (file)
@@ -2071,6 +2071,8 @@ mangle_decl_string (decl)
     write_type (TREE_TYPE (decl));
   else if (/* The names of `extern "C"' functions are not mangled.  */
           (TREE_CODE (decl) == FUNCTION_DECL 
+           /* But overloaded operator names *are* mangled.  */
+           && !DECL_OVERLOADED_OPERATOR_P (decl)
            /* If there's no DECL_LANG_SPECIFIC, it's a function built
               by language-independent code, which never builds
               functions with C++ linkage.  */
diff --git a/gcc/testsuite/g++.old-deja/g++.other/mangle2.C b/gcc/testsuite/g++.old-deja/g++.other/mangle2.C
new file mode 100644 (file)
index 0000000..25bab87
--- /dev/null
@@ -0,0 +1,24 @@
+// Test for overloaded operators in "C" linkage
+// Build don't link:
+
+extern "C" {
+typedef struct b
+{
+  int a;
+} c;
+
+extern const c z;
+
+inline bool operator!=(const c& x, const c& y)
+{
+  return x.a != y.a;
+}
+};
+
+void foo();
+
+void bar(c x)
+{
+  if (x != z)
+    foo();
+}