OSDN Git Service

PR c++/13178
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Jan 2004 18:39:58 +0000 (18:39 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Jan 2004 18:39:58 +0000 (18:39 +0000)
* call.c (name_as_c_string): Print conversion operator names
correctly.

PR c++/13178
* g++.dg/conversion/op1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75986 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/op1.C [new file with mode: 0644]

index c2458ab..06733cc 100644 (file)
@@ -1,5 +1,9 @@
 2004-01-16  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/13178
+       * call.c (name_as_c_string): Print conversion operator names
+       correctly.
+
        PR c++/13478
        * call.c (initialize_reference): Pass -1 for inner parameter to
        convert_like_real.
index aaf902c..7864d08 100644 (file)
@@ -4986,6 +4986,15 @@ name_as_c_string (tree name, tree type, bool *free_p)
          *free_p = true;
        }
     }
+  else if (IDENTIFIER_TYPENAME_P (name))
+    {
+      pretty_name = concat ("operator ",
+                           type_as_string (TREE_TYPE (name),
+                                           TFF_PLAIN_IDENTIFIER),
+                           NULL);
+      /* Remember that we need to free the memory allocated.  */
+      *free_p = true;
+    }
   else
     pretty_name = (char *) IDENTIFIER_POINTER (name);
 
index b5d83dc..573156e 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13178
+       * g++.dg/conversion/op1.C: New test.
+
 2004-01-16  J"orn Rennecke <joern.rennecke@superh.com>
 
        PR 10392
diff --git a/gcc/testsuite/g++.dg/conversion/op1.C b/gcc/testsuite/g++.dg/conversion/op1.C
new file mode 100644 (file)
index 0000000..3aa21c7
--- /dev/null
@@ -0,0 +1,10 @@
+class C
+{
+  template<typename U> 
+  operator U();
+};
+
+int fn (C c) 
+{ 
+  return C::operator float(c); // { dg-error "operator U" }
+}