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]

(C++) patch for TYPE_READONLY handling


Applied.  grokdeclarator was stripping const from an array typedef.
Fixes g++.other/conv3.C.

1998-10-23  Jason Merrill  <jason@yorick.cygnus.com>

	* cp-tree.h (CP_TYPE_READONLY): New macro to handle arrays.
	(CP_TYPE_VOLATILE): Likewise.
	* decl.c (grokdeclarator): Use them.
	* tree.c (canonical_type_variant): Likewise.

Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.156
diff -c -p -r1.156 cp-tree.h
*** cp-tree.h	1998/10/19 20:08:11	1.156
--- cp-tree.h	1998/10/23 09:01:27
*************** enum languages { lang_c, lang_cplusplus,
*** 514,519 ****
--- 514,528 ----
  /* The _DECL for this _TYPE.  */
  #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
  
+ #define CP_TYPE_READONLY(NODE)			\
+   (TREE_CODE (NODE) == ARRAY_TYPE		\
+    ? TYPE_READONLY (TREE_TYPE (NODE))		\
+    : TYPE_READONLY (NODE))
+ #define CP_TYPE_VOLATILE(NODE)			\
+   (TREE_CODE (NODE) == ARRAY_TYPE		\
+    ? TYPE_VOLATILE (TREE_TYPE (NODE))		\
+    : TYPE_VOLATILE (NODE))
+ 
  /* Nonzero if T is a class (or struct or union) type.  Also nonzero
     for template type parameters and typename types.  Despite its name,
     this macro has nothing to do with the definition of aggregate given
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.241
diff -c -p -r1.241 decl.c
*** decl.c	1998/10/18 04:18:02	1.241
--- decl.c	1998/10/23 09:01:28
*************** grokdeclarator (declarator, declspecs, d
*** 9196,9203 ****
       explicit specification or via a typedef.
       Likewise for VOLATILEP.  */
  
!   constp = !! RIDBIT_SETP (RID_CONST, specbits) + TYPE_READONLY (type);
!   volatilep = !! RIDBIT_SETP (RID_VOLATILE, specbits) + TYPE_VOLATILE (type);
    type = cp_build_type_variant (type, constp, volatilep);
    staticp = 0;
    inlinep = !! RIDBIT_SETP (RID_INLINE, specbits);
--- 9196,9203 ----
       explicit specification or via a typedef.
       Likewise for VOLATILEP.  */
  
!   constp = !!RIDBIT_SETP (RID_CONST, specbits) + CP_TYPE_READONLY (type);
!   volatilep = !!RIDBIT_SETP (RID_VOLATILE, specbits) + CP_TYPE_VOLATILE (type);
    type = cp_build_type_variant (type, constp, volatilep);
    staticp = 0;
    inlinep = !! RIDBIT_SETP (RID_INLINE, specbits);
Index: tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.72
diff -c -p -r1.72 tree.c
*** tree.c	1998/10/19 20:08:20	1.72
--- tree.c	1998/10/23 09:01:28
*************** tree
*** 501,518 ****
  canonical_type_variant (t)
       tree t;
  {
!   int constp, volatilep;
!   if (TREE_CODE (t) == ARRAY_TYPE)
!     {
!       constp = TYPE_READONLY (TREE_TYPE (t));
!       volatilep = TYPE_VOLATILE (TREE_TYPE (t));
!     }
!   else
!     {
!       constp = TYPE_READONLY (t);
!       volatilep = TYPE_VOLATILE (t);
!     }
!   return cp_build_type_variant (TYPE_MAIN_VARIANT (t), constp, volatilep);
  }
  
  /* Add OFFSET to all base types of T.
--- 501,508 ----
  canonical_type_variant (t)
       tree t;
  {
!   return cp_build_type_variant (TYPE_MAIN_VARIANT (t), CP_TYPE_READONLY (t),
! 				CP_TYPE_VOLATILE (t));
  }
  
  /* Add OFFSET to all base types of T.


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