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]

typeof C++ extension patch


Hello all,
	The typeof extension is broken in CVS GCC and when it is dependent on 
template parameters. The attached (trivial) patch produces no regressions on 
i686-pc-linux-gnu.
	The attached typeof.C is a testcase of (and provides significant motivation 
for) the typeof operator.

	Doug Gregor
	gregod@cs.rpi.edu
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()
{
}
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/23 20:31:52
*************** 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.25
diff -c -3 -p -r1.25 mangle.c
*** 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 ----
  	  write_type (TREE_TYPE (type));
  	  break;
  
+ 	case TYPEOF_TYPE:
+ 	  write_string("U8__typeof");
+ 	  break;
+ 
  	default:
  	  my_friendly_abort (20000409);
  	}
2001-01-23  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]