This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: Fix PR 13178


This patch fixes our pretty-printing of conversion operator names.

Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-01-16  Mark Mitchell  <mark@codesourcery.com>

	PR c++/13178
	* call.c (name_as_c_string): Print conversion operator names
	correctly.

2004-01-16  Mark Mitchell  <mark@codesourcery.com>

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

Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.451
diff -c -5 -p -r1.451 call.c
*** cp/call.c	16 Jan 2004 17:54:25 -0000	1.451
--- cp/call.c	16 Jan 2004 18:35:34 -0000
*************** name_as_c_string (tree name, tree type, 
*** 4984,4993 ****
--- 4984,5002 ----
  	  pretty_name = concat ("~", pretty_name, NULL);
  	  /* Remember that we need to free the memory allocated.  */
  	  *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);
  
    return pretty_name;
  }
Index: testsuite/g++.dg/conversion/op1.C
===================================================================
RCS file: testsuite/g++.dg/conversion/op1.C
diff -N testsuite/g++.dg/conversion/op1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/conversion/op1.C	16 Jan 2004 18:35:34 -0000
***************
*** 0 ****
--- 1,10 ----
+ class C
+ {
+   template<typename U> 
+   operator U();
+ };
+ 
+ int fn (C c) 
+ { 
+   return C::operator float(c); // { dg-error "operator U" }
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]