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]

Re: expression mangling (was: typeof C++ extension patch)


On Friday 26 January 2001 06:06, you wrote:
> >>>>> "Doug" == Doug Gregor <gregod@cs.rpi.edu> writes:
> >
> > *** mangle.c	2001/01/11 03:15:49	1.25
> > --- mangle.c	2001/01/23 20:31:53
> > *************** write_type (type)
> > *** 1357,1362 ****
> > --- 1357,1366 ----
> >
> > + 	case TYPEOF_TYPE:
> > + 	  write_string("U8__typeof");
> > + 	  break;
>
> This is wrong, but it's not clear what the right answer is.  The support
> for mangling expressions only deals with constant-expressions, which makes
> sense.  typeof can be applied to any expression, so to encode it uniquely
> would mean extending the mangling system to support arbitrary expressions.
>
> Actually, it occurs to me that the current support isn't even sufficient
> for everything that can appear in a sizeof().  Consider the following
> pathological testcase:
>
>   template <class T> int (* f (T))[sizeof (T()+2)] { }
>
>   int main ()
>   {
>     f (42);
>   }
>
> How do we mangle that?  Any thoughts, Alex?
>
> Going back to the patch above, U types are supposed to be qualifiers to the
> next type mentioned.  Since you don't mention another type, this is
> broken.  A simple fix would be to use 'u8__typeof' instead.  That would
> make all typeofs look alike for mangling purposes, but I'm OK with that.

Both sizeof() and typeof() can take arbitrary expressions, so the problem of 
mangling arbitrary expressions isn't going away. Why is it that GCC mangles 
uninstantiated templates in the first place?

	Doug
Index: error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.148
diff -c -3 -p -r1.148 error.c
*** error.c	2001/01/10 15:40:58	1.148
--- error.c	2001/01/26 16:49:35
*************** dump_type_prefix (t, flags)
*** 744,749 ****
--- 744,750 ----
      case TYPENAME_TYPE:
      case COMPLEX_TYPE:
      case VECTOR_TYPE:
+     case TYPEOF_TYPE:
        dump_type (t, flags);
        padding = before;
        break;
*************** dump_type_suffix (t, flags)
*** 840,845 ****
--- 841,847 ----
      case TYPENAME_TYPE:
      case COMPLEX_TYPE:
      case VECTOR_TYPE:
+     case TYPEOF_TYPE:
        break;
  
      default:
Index: mangle.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/mangle.c,v
retrieving revision 1.26
diff -c -3 -p -r1.26 mangle.c
*** mangle.c	2001/01/25 07:35:20	1.26
--- mangle.c	2001/01/26 16:49:36
*************** write_type (type)
*** 1366,1371 ****
--- 1366,1375 ----
  	  write_type (TREE_TYPE (type));
  	  break;
  
+ 	case TYPEOF_TYPE:
+ 	  write_string("u8__typeof");
+ 	  break;
+ 
  	default:
  	  my_friendly_abort (20000409);
  	}
template<typename Arg1, typename Arg2>
struct plus
{
  static Arg1 lhs;
  static Arg2 rhs;
  
  typedef typeof(lhs+rhs) result_type;
  inline result_type operator()(Arg1 lhs, Arg2 rhs) { return lhs+rhs; }
};

int
main()
{
}
2001-01-26  Douglas Gregor  <gregod@cs.rpi.edu>
	* mangle.c (write_type): Emit u8__typeof for TYPEOF_TYPE.
	* error.c (dump_type_prefix): Support TYPEOF_TYPE.
	  (dump_type_suffix): Support TYPEOF_TYPE.

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