]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/11713 (declaration conflicts)
authorMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 4 Aug 2003 11:30:06 +0000 (11:30 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 4 Aug 2003 11:30:06 +0000 (11:30 +0000)
PR c++/11713
* search.c (setup_class_bindings): Handle conversion operators
specially.

PR c++/11713
* g++.dg/overload/operator1.C: New test.

From-SVN: r70136

gcc/cp/search.c
gcc/testsuite/g++.dg/overload/operator1.C [new file with mode: 0644]

index 3f8e2daf8a86fbb1fa510bbc6337fec47f178145..c64637519261d184e3aee2554d5a863176678991 100644 (file)
@@ -2123,6 +2123,20 @@ setup_class_bindings (tree name, int type_binding_p)
          if (BASELINK_P (value_binding))
            /* NAME is some overloaded functions.  */
            value_binding = BASELINK_FUNCTIONS (value_binding);
+         /* Two conversion operators that convert to the same type
+            may have different names.  (See
+            mangle_conv_op_name_for_type.)  To avoid recording the
+            same conversion operator declaration more than once we
+            must check to see that the same operator was not already
+            found under another name.  */
+         if (IDENTIFIER_TYPENAME_P (name)
+             && is_overloaded_fn (value_binding))
+           {
+             tree fns;
+             for (fns = value_binding; fns; fns = OVL_NEXT (fns))
+               if (IDENTIFIER_CLASS_VALUE (DECL_NAME (OVL_CURRENT (fns))))
+                 return;
+           }
          pushdecl_class_level (value_binding);
        }
     }
diff --git a/gcc/testsuite/g++.dg/overload/operator1.C b/gcc/testsuite/g++.dg/overload/operator1.C
new file mode 100644 (file)
index 0000000..f4d1f53
--- /dev/null
@@ -0,0 +1,34 @@
+typedef struct _GdkDrawable GdkDrawable; 
+typedef struct _GdkDrawable GdkBitmap; 
+typedef struct _GdkDrawable GdkPixmap; 
+class Drawable 
+{ 
+public: 
+ operator GdkDrawable* () const; 
+}; 
+class Pixmap : public Drawable 
+{ 
+public: 
+ operator GdkPixmap* () const; 
+}; 
+class Bitmap : public Pixmap 
+{ 
+public: 
+  operator GdkBitmap* () const; 
+}; 
+class Event 
+{ 
+}; 
+Bitmap::operator GdkBitmap* () const 
+{ 
+ return  0; 
+}