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]

PATCH:mutable const objects (again)


Hi,
The patch I previously submitted
(http://www.cygnus.com/ml/egcs-patches/1998-Oct/0906.html) was
incomplete. That patch has not been installed. It did not fix all the
cases of erroneously placing mutable objects in a readonly section.

What I'd missed were static const member variables. It turned out that
the simple fix for that wasn't so simple after all. Both patches add a
`contains_mutable' member to class definitions, and originally I was
using that to clear the TREE_CONSTANT flag in cp_finish_decl (as Jason
Merrill suggested). However, this lying to the compiler confused things
like SAVE_EXPR which attempted to do various bad things to static member
variables. The problem is that TREE_CONSTANT has the semantics
'evaluating this tree causes side effects and/or function calls' neither
of which are true of a simple initializer list to a PoD struct.

So, I took Martin von Loewis's suggestion
(http://www.cygnus.com/ml/egcs/1998-Aug/0074.html) of removing the front
end code from SELECT_SECTION by adding a language independant function
(var_readonly_p) which DECL_READONLY_SECTION uses to determine if a
declaration can really go in a read only section. There is a language
specific hook (lang_var_readonly_p) which points to a language specific
test. For C++, this checks the contains_mutable member of the type
definition.

Then I removed the font end cruft from all the target specific files in
the config directory. Most of the cases were changing the definition of
SELECT_SECTION to use DECL_READONLY_P.

It seems that there was a lot of code duplication here which 
DECL_READONLY_P was attempting to avoid, but that wasn't being used by
all the target selection macros. This patch changes that. Also in some
cases I changed the ordering of if ..else tests, because there were too
many double negatives going on for my liking.

Hopefully I've not broken any of these implementations, but as Martin
originally said this is a significant change and will require review. It
works on a sparc-sun-solaris2.5.1 box.

I enclose the patch file (against the 19981109 snapshot) and a test
case.

Let me know of any problems.

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
egcs/gcc/ChangeLog

Thu Nov 19 14:59:21 GMT 1998  Nathan Sidwell  <nathan@acm.org>

	* output.h (DECL_READONLY_SECTION): Use DECL_READONLY_P.
	* tree.c (lang_var_readonly_p): Define new language callback.
	(var_readonly_p): Language independant part of readonly variable.
	* tree.h (DECL_READONLY_P): Macro to call var_readonly_p.
	(var_readonly_p): Prototype.
	(lang_var_readonly_p): Declare.
	* config/nextstep.h (SELECT_SECTION): Use DECL_READONLY_P.
	* config/ptx4.h (SELECT_SECTION): Likewise.
	* config/svr3.h (SELECT_SECTION): Likewise.
	* config/alpha/elf.h (SELECT_SECTION): Likewise.
	* config/arm/linux-elf.h (SELECT_SECTION): Likewise.
	* config/c4x/c4x.h (SELECT_SECTION): Likewise.
	* config/i386/osfrose.h (SELECT_SECTION): Likewise.
	* config/i386/svr3gas.h (SELECT_SECTION): Likewise.
	* config/m32r/m32r.c (m32r_select_section): Likewise.
	(m32r_encode_section_info): Likewise.
	* config/m88k/m88k.h (SELECT_SECTION): Likewise.
	* config/mips/mips.c (mips_select_section): Likewise.
	* config/pa/pa.h (TEXT_SPACE_P): Likewise.
	(SELECT_SECTION): Likewise.
	* config/rs6000/rs6000.c (rs6000_select_section): Likewise.
	* config/rs6000/rs6000.h (SELECT_SECTION): Likewise.
	* config/sparc/sparc.h (SELECT_SECTION): Likewise.
	* config/v850/v850.c (v850_set_default_decl_attr): Likewise.
	* config/v850/v850.h (SELECT_SECTION): Likewise.
	* config/vax/vax.c (vms_check_external): Likewise.
	* config/vax/vms.h (ASM_OUTPUT_COMMON): Likewise.
	(SELECT_SECTION): Likewise.

egcs/gcc/cp/ChangeLog

Thu Nov 19 14:59:21 GMT 1998  Nathan Sidwell  <nathan@acm.org>

	* cp-tree.h (struct lang_type): Added has_mutable flag.
	(CLASSTYPE_HAS_MUTABLE): New macro to access it.
	(TYPE_HAS_MUTABLE): New macro to read it.
	(cp_var_readonly_p): Prototype new language specific function.
	(cp_has_mutable): Prototype new function.
	* decl.c (init_decl_processing): Override lang_var_readonly_p.
	* class.c (finish_struct_1): Set has_mutable from members.
	* tree.c (cp_var_readonly_p): New language specific function.
	* typeck.c (cp_has_mutable): New function.

Index: egcs/gcc/output.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/output.h,v
retrieving revision 1.13
diff -c -3 -p -r1.13 output.h
*** output.h	1998/10/28 22:30:59	1.13
--- output.h	1998/11/19 14:32:41
*************** extern FILE *rtl_dump_file;
*** 476,487 ****
     as for SELECT_SECTION.  */
  
  #define DECL_READONLY_SECTION(DECL,RELOC)		\
!   (TREE_READONLY (DECL)					\
!    && ! TREE_THIS_VOLATILE (DECL)			\
!    && DECL_INITIAL (DECL)				\
!    && (DECL_INITIAL (DECL) == error_mark_node		\
!        || TREE_CONSTANT (DECL_INITIAL (DECL)))		\
!    && ! (RELOC && (flag_pic || DECL_ONE_ONLY (DECL))))
  
  /* User label prefix in effect for this compilation.  */
  extern char *user_label_prefix;
--- 476,483 ----
     as for SELECT_SECTION.  */
  
  #define DECL_READONLY_SECTION(DECL,RELOC)		\
!   (DECL_READONLY_P (DECL)				\
!    && ! ((RELOC) && (flag_pic || DECL_ONE_ONLY (DECL))))
  
  /* User label prefix in effect for this compilation.  */
  extern char *user_label_prefix;
Index: egcs/gcc/tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/tree.c,v
retrieving revision 1.49
diff -c -3 -p -r1.49 tree.c
*** tree.c	1998/11/08 15:10:24	1.49
--- tree.c	1998/11/19 14:32:45
*************** static int next_type_uid = 1;
*** 260,265 ****
--- 260,269 ----
     language does not do any special alias analysis.  */
  int (*lang_get_alias_set) PROTO((tree));
  
+ /* Language specific test for readonly variables. Return 0, if the variable
+  * must not be in read-only memory. */
+ int (*lang_var_readonly_p) PROTO((tree));
+ 
  /* Here is how primitive or already-canonicalized types' hash
     codes are made.  */
  #define TYPE_HASH(TYPE) ((unsigned long) (TYPE) & 0777777)
*************** new_alias_set ()
*** 5143,5146 ****
--- 5147,5168 ----
  {
    static int last_alias_set;
    return ++last_alias_set;
+ }
+ 
+  /*return 1, if the vardecl can be placed in read only memory, return 0, if it
+    can't be.
+   */
+ int
+ var_readonly_p (decl)
+       tree decl;
+ {
+   if (! TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl) || TREE_THIS_VOLATILE (decl))
+     return 0;
+   if ( DECL_INITIAL (decl)
+       && DECL_INITIAL (decl) != error_mark_node
+       && ! TREE_CONSTANT (DECL_INITIAL (decl)))
+     return 0;
+   if (lang_var_readonly_p && !lang_var_readonly_p (decl))
+     return 0;
+   return 1;
  }
Index: egcs/gcc/tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/tree.h,v
retrieving revision 1.58
diff -c -3 -p -r1.58 tree.h
*** tree.h	1998/11/07 13:00:41	1.58
--- tree.h	1998/11/19 14:32:50
*************** struct tree_type
*** 1275,1280 ****
--- 1277,1286 ----
  #define DECL_POINTER_ALIAS_SET_KNOWN_P(NODE) \
    (DECL_POINTER_ALIAS_SET (NODE) != - 1)
  
+ /* Nonzero if a VAR_DECL _could_ be placed in readonly memory. Zero if it
+  * _must_ be in a writable section */
+ #define DECL_READONLY_P(NODE) (var_readonly_p (NODE))
+ 
  struct tree_decl
  {
    char common[sizeof (struct tree_common)];
*************** extern tree get_set_constructor_bytes		P
*** 1916,1921 ****
--- 1925,1932 ----
  extern int get_alias_set                        PROTO((tree));
  extern int new_alias_set			PROTO((void));
  extern int (*lang_get_alias_set)                PROTO((tree));
+ extern int var_readonly_p                       PROTO((tree));
+ extern int (*lang_var_readonly_p)               PROTO((tree));
  
  /* In stmt.c */
  
Index: egcs/gcc/config/nextstep.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/nextstep.h,v
retrieving revision 1.4
diff -c -3 -p -r1.4 nextstep.h
*** nextstep.h	1998/10/28 22:31:02	1.4
--- nextstep.h	1998/11/19 14:32:52
*************** objc_section_init ()				\
*** 503,510 ****
  	  if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))), \
  			"NXConstantString"))				\
  	  objc_string_object_section ();				\
! 	else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))		\
! 		&& !TREE_SIDE_EFFECTS (exp))				\
  	  readonly_data_section ();					\
  	else								\
  	  data_section ();						\
--- 503,509 ----
  	  if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))), \
  			"NXConstantString"))				\
  	  objc_string_object_section ();				\
! 	else if (DECL_READONLY_P (exp))					\
  	  readonly_data_section ();					\
  	else								\
  	  data_section ();						\
*************** objc_section_init ()				\
*** 559,580 ****
  	    objc_cat_cls_meth_section ();                               \
  	  else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))              \
  	    objc_protocol_section ();                                   \
! 	  else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))		\
! 		&& !TREE_SIDE_EFFECTS (exp))     			\
  	    readonly_data_section ();                                   \
  	  else								\
  	    data_section ();						\
  	}								\
        else if (TREE_CODE (exp) == VAR_DECL)				\
  	{								\
! 	  if ((flag_pic && reloc)					\
! 	      || !TREE_READONLY (exp) || TREE_SIDE_EFFECTS (exp)	\
! 	      || !DECL_INITIAL (exp)					\
! 	      || (DECL_INITIAL (exp) != error_mark_node			\
! 		  && !TREE_CONSTANT (DECL_INITIAL (exp))))		\
! 	    data_section ();						\
! 	  else								\
  	    readonly_data_section ();					\
  	}								\
        else								\
  	readonly_data_section ();					\
--- 558,574 ----
  	    objc_cat_cls_meth_section ();                               \
  	  else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))              \
  	    objc_protocol_section ();                                   \
! 	  else if (DECL_READONLY_P (exp))				\
  	    readonly_data_section ();                                   \
  	  else								\
  	    data_section ();						\
  	}								\
        else if (TREE_CODE (exp) == VAR_DECL)				\
  	{								\
! 	  if (DECL_READONLY_SECTION (exp, reloc))			\
  	    readonly_data_section ();					\
+ 	  else								\
+ 	    data_section ();						\
  	}								\
        else								\
  	readonly_data_section ();					\
Index: egcs/gcc/config/ptx4.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/ptx4.h,v
retrieving revision 1.4
diff -c -3 -p -r1.4 ptx4.h
*** ptx4.h	1998/01/13 21:43:38	1.4
--- ptx4.h	1998/11/19 14:32:52
*************** dtors_section ()							\
*** 583,596 ****
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if ((flag_pic && RELOC)						\
! 	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)		\
! 	  || !DECL_INITIAL (DECL)					\
! 	  || (DECL_INITIAL (DECL) != error_mark_node			\
! 	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))			\
! 	data_section ();						\
!       else								\
  	const_section ();						\
      }									\
    else									\
      const_section ();							\
--- 583,592 ----
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if (DECL_READONLY_SECTION (DELC, RELOC))				\
  	const_section ();						\
+       else								\
+ 	data_section ();						\
      }									\
    else									\
      const_section ();							\
Index: egcs/gcc/config/svr3.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/svr3.h,v
retrieving revision 1.1.1.1
diff -c -3 -p -r1.1.1.1 svr3.h
*** svr3.h	1997/08/11 15:57:15	1.1.1.1
--- svr3.h	1998/11/19 14:32:55
*************** dtors_section ()							\
*** 353,366 ****
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if ((0 && RELOC)	/* should be (flag_pic && RELOC) */		\
! 	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)		\
! 	  || !DECL_INITIAL (DECL)					\
! 	  || (DECL_INITIAL (DECL) != error_mark_node			\
! 	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))			\
! 	data_section ();						\
!       else								\
  	const_section ();						\
      }									\
    else									\
      const_section ();							\
--- 353,362 ----
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if (DECL_READONLY_SECTION (DECL, 0)) /* should be RELOC */	\
  	const_section ();						\
+       else								\
+ 	data_section ();						\
      }									\
    else									\
      const_section ();							\
Index: egcs/gcc/config/alpha/elf.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/alpha/elf.h,v
retrieving revision 1.11
diff -c -3 -p -r1.11 elf.h
*** elf.h	1998/09/05 22:22:07	1.11
--- elf.h	1998/11/19 14:33:00
*************** void FN ()								\
*** 340,350 ****
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if ((flag_pic && RELOC)						\
! 	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)		\
! 	  || !DECL_INITIAL (DECL)					\
! 	  || (DECL_INITIAL (DECL) != error_mark_node			\
! 	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))			\
  	{								\
  	  int size = int_size_in_bytes (TREE_TYPE (DECL));		\
  	  if (size >= 0 && size <= g_switch_value)			\
--- 340,348 ----
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if (DECL_READONLY_SECTION (DECL, RELOC))				\
! 	const_section ();						\
!       else								\
  	{								\
  	  int size = int_size_in_bytes (TREE_TYPE (DECL));		\
  	  if (size >= 0 && size <= g_switch_value)			\
*************** void FN ()								\
*** 352,359 ****
  	  else								\
  	    data_section ();						\
  	}								\
-       else								\
- 	const_section ();						\
      }									\
    else									\
      const_section ();							\
--- 350,355 ----
Index: egcs/gcc/config/arm/linux-elf.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/arm/linux-elf.h,v
retrieving revision 1.1
diff -c -3 -p -r1.1 linux-elf.h
*** linux-elf.h	1998/10/27 11:13:37	1.1
--- linux-elf.h	1998/11/19 14:33:01
*************** const_section ()							\
*** 158,171 ****
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if ((flag_pic && RELOC)						\
! 	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)		\
! 	  || !DECL_INITIAL (DECL)					\
! 	  || (DECL_INITIAL (DECL) != error_mark_node			\
! 	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))			\
! 	data_section ();						\
!       else								\
  	const_section ();						\
      }									\
    else									\
      const_section ();							\
--- 158,167 ----
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if (DECL_READONLY_SECTION (DECL, RELOC))				\
  	const_section ();						\
+       else								\
+ 	data_section ();						\
      }									\
    else									\
      const_section ();							\
Index: egcs/gcc/config/c4x/c4x.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/c4x/c4x.h,v
retrieving revision 1.3
diff -c -3 -p -r1.3 c4x.h
*** c4x.h	1998/10/14 22:46:02	1.3
--- c4x.h	1998/11/19 14:33:06
*************** dtors_section ()							\
*** 1906,1919 ****
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if ((0 && RELOC)	/* should be (flag_pic && RELOC) */		\
! 	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)		\
! 	  || !DECL_INITIAL (DECL)					\
! 	  || (DECL_INITIAL (DECL) != error_mark_node			\
! 	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))			\
! 	data_section ();						\
!       else								\
  	const_section ();						\
      }									\
    else									\
      const_section ();							\
--- 1906,1915 ----
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if (DECL_READONLY_SECTION (DECL, 0))	/* should be RELOC */	\
  	const_section ();						\
+       else								\
+ 	data_section ();						\
      }									\
    else									\
      const_section ();							\
Index: egcs/gcc/config/i386/osfrose.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/i386/osfrose.h,v
retrieving revision 1.4
diff -c -3 -p -r1.4 osfrose.h
*** osfrose.h	1998/07/13 22:38:45	1.4
--- osfrose.h	1998/11/19 14:33:07
*************** while (0)
*** 592,605 ****
    else if (TREE_CODE (DECL) != VAR_DECL)				\
      readonly_data_section ();						\
  									\
!   else if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)		\
! 	   || !DECL_INITIAL (DECL)					\
! 	   || (DECL_INITIAL (DECL) != error_mark_node			\
! 	       && !TREE_CONSTANT (DECL_INITIAL (DECL))))		\
!     data_section ();							\
  									\
    else									\
!     readonly_data_section ();						\
  }
  
  
--- 592,602 ----
    else if (TREE_CODE (DECL) != VAR_DECL)				\
      readonly_data_section ();						\
  									\
!   else if (DECL_READONLY_SECTION (DECL, 0))				\
!     readonly_data_section ();						\
  									\
    else									\
!     data_section ();							\
  }
  
  
Index: egcs/gcc/config/i386/svr3gas.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/i386/svr3gas.h,v
retrieving revision 1.1.1.1
diff -c -3 -p -r1.1.1.1 svr3gas.h
*** svr3gas.h	1997/08/11 15:57:17	1.1.1.1
--- svr3gas.h	1998/11/19 14:33:08
*************** dtors_section ()							\
*** 243,256 ****
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if ((0 && RELOC)	/* should be (flag_pic && RELOC) */		\
! 	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)		\
! 	  || !DECL_INITIAL (DECL)					\
! 	  || (DECL_INITIAL (DECL) != error_mark_node 			\
! 	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))			\
! 	data_section ();						\
!       else								\
  	const_section ();						\
      }									\
    else									\
      const_section ();							\
--- 243,252 ----
      }									\
    else if (TREE_CODE (DECL) == VAR_DECL)				\
      {									\
!       if (DECL_READONLY_SECTION (DECL, 0)) /* should be RELOC */	\
  	const_section ();						\
+       else								\
+ 	data_section ();						\
      }									\
    else									\
      const_section ();							\
Index: egcs/gcc/config/m32r/m32r.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/m32r/m32r.c,v
retrieving revision 1.8
diff -c -3 -p -r1.8 m32r.c
*** m32r.c	1998/11/02 11:48:08	1.8
--- m32r.c	1998/11/19 14:33:10
*************** m32r_select_section (decl, reloc)
*** 278,292 ****
      {
        if (SDATA_NAME_P (XSTR (XEXP (DECL_RTL (decl), 0), 0)))
  	sdata_section ();
!       else if ((flag_pic && reloc)
! 	       || !TREE_READONLY (decl)
! 	       || TREE_SIDE_EFFECTS (decl)
! 	       || !DECL_INITIAL (decl)
! 	       || (DECL_INITIAL (decl) != error_mark_node
! 		   && !TREE_CONSTANT (DECL_INITIAL (decl))))
! 	data_section ();
!       else
  	const_section ();
      }
    else
      const_section ();
--- 278,287 ----
      {
        if (SDATA_NAME_P (XSTR (XEXP (DECL_RTL (decl), 0), 0)))
  	sdata_section ();
!       else if (DECL_READONLY_SECTION (decl, reloc))
  	const_section ();
+       else
+ 	data_section ();
      }
    else
      const_section ();
*************** m32r_encode_section_info (decl)
*** 355,361 ****
        else
  	{
  	  if (TREE_CODE (decl) == VAR_DECL
! 	      && ! TREE_READONLY (decl)
  	      && ! TARGET_SDATA_NONE)
  	    {
  	      int size = int_size_in_bytes (TREE_TYPE (decl));
--- 350,356 ----
        else
  	{
  	  if (TREE_CODE (decl) == VAR_DECL
! 	      && ! DECL_READONLY_P (decl)
  	      && ! TARGET_SDATA_NONE)
  	    {
  	      int size = int_size_in_bytes (TREE_TYPE (decl));
Index: egcs/gcc/config/m88k/m88k.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/m88k/m88k.h,v
retrieving revision 1.10
diff -c -3 -p -r1.10 m88k.h
*** m88k.h	1998/10/16 00:08:50	1.10
--- m88k.h	1998/11/19 14:33:12
*************** sdata_section ()							\
*** 2583,2596 ****
      {									\
        if (SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)))			\
  	sdata_section ();						\
!       else if ((flag_pic && RELOC)					\
! 	       || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)	\
! 	       || !DECL_INITIAL (DECL)					\
! 	       || (DECL_INITIAL (DECL) != error_mark_node		\
! 		   && !TREE_CONSTANT (DECL_INITIAL (DECL))))		\
! 	data_section ();						\
!       else								\
  	const_section ();						\
      }									\
    else									\
      const_section ();							\
--- 2583,2592 ----
      {									\
        if (SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)))			\
  	sdata_section ();						\
!       else if (DECL_READONLY_SECTION (DECL, RELOC))			\
  	const_section ();						\
+       else								\
+ 	data_section ();						\
      }									\
    else									\
      const_section ();							\
Index: egcs/gcc/config/mips/mips.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mips/mips.c,v
retrieving revision 1.42
diff -c -3 -p -r1.42 mips.c
*** mips.c	1998/10/22 17:17:26	1.42
--- mips.c	1998/11/19 14:33:19
*************** mips_select_section (decl, reloc)
*** 6872,6887 ****
        /* For embedded applications, always put an object in read-only data
  	 if possible, in order to reduce RAM usage.  */
  
!       if (((TREE_CODE (decl) == VAR_DECL
! 	    && TREE_READONLY (decl) && !TREE_SIDE_EFFECTS (decl)
! 	    && DECL_INITIAL (decl)
! 	    && (DECL_INITIAL (decl) == error_mark_node
! 		|| TREE_CONSTANT (DECL_INITIAL (decl))))
  	   /* Deal with calls from output_constant_def_contents.  */
! 	   || (TREE_CODE (decl) != VAR_DECL
! 	       && (TREE_CODE (decl) != STRING_CST
! 		   || !flag_writable_strings)))
! 	  && ! (flag_pic && reloc))
  	READONLY_DATA_SECTION ();
        else if (size > 0 && size <= mips_section_threshold)
  	SMALL_DATA_SECTION ();
--- 6872,6884 ----
        /* For embedded applications, always put an object in read-only data
  	 if possible, in order to reduce RAM usage.  */
  
!       if ((TREE_CODE (decl) == VAR_DECL
! 	    && DECL_READONLY_SECTION (decl, reloc))
  	   /* Deal with calls from output_constant_def_contents.  */
! 	   || ! (flag_pic && reloc)
! 	      && (TREE_CODE (decl) != VAR_DECL
! 	          && (TREE_CODE (decl) != STRING_CST
! 		      || !flag_writable_strings)))
  	READONLY_DATA_SECTION ();
        else if (size > 0 && size <= mips_section_threshold)
  	SMALL_DATA_SECTION ();
*************** mips_select_section (decl, reloc)
*** 6895,6910 ****
  
        if (size > 0 && size <= mips_section_threshold)
  	SMALL_DATA_SECTION ();
!       else if (((TREE_CODE (decl) == VAR_DECL
! 		 && TREE_READONLY (decl) && !TREE_SIDE_EFFECTS (decl)
! 		 && DECL_INITIAL (decl)
! 		 && (DECL_INITIAL (decl) == error_mark_node
! 		     || TREE_CONSTANT (DECL_INITIAL (decl))))
  		/* Deal with calls from output_constant_def_contents.  */
! 		|| (TREE_CODE (decl) != VAR_DECL
! 		    && (TREE_CODE (decl) != STRING_CST
! 			|| !flag_writable_strings)))
! 	       && ! (flag_pic && reloc))
  	READONLY_DATA_SECTION ();
        else
  	data_section ();
--- 6892,6904 ----
  
        if (size > 0 && size <= mips_section_threshold)
  	SMALL_DATA_SECTION ();
!       else if ((TREE_CODE (decl) == VAR_DECL
! 		 && DECL_SECTION_READONLY (decl, reloc))
  		/* Deal with calls from output_constant_def_contents.  */
! 		|| ! (flag_pic && reloc)
! 	            && (TREE_CODE (decl) != VAR_DECL
!   		        && (TREE_CODE (decl) != STRING_CST
! 			    || !flag_writable_strings)))
  	READONLY_DATA_SECTION ();
        else
  	data_section ();
Index: egcs/gcc/config/pa/pa.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/pa/pa.h,v
retrieving revision 1.28
diff -c -3 -p -r1.28 pa.h
*** pa.h	1998/11/03 19:56:12	1.28
--- pa.h	1998/11/19 14:33:21
*************** extern struct rtx_def *hppa_legitimize_a
*** 1730,1736 ****
  #define TEXT_SPACE_P(DECL)\
    (TREE_CODE (DECL) == FUNCTION_DECL					\
     || (TREE_CODE (DECL) == VAR_DECL					\
!        && TREE_READONLY (DECL) && ! TREE_SIDE_EFFECTS (DECL)		\
         && (! DECL_INITIAL (DECL) || ! reloc_needed (DECL_INITIAL (DECL))) \
         && !flag_pic)							\
     || (TREE_CODE_CLASS (TREE_CODE (DECL)) == 'c'			\
--- 1730,1736 ----
  #define TEXT_SPACE_P(DECL)\
    (TREE_CODE (DECL) == FUNCTION_DECL					\
     || (TREE_CODE (DECL) == VAR_DECL					\
!        && DECL_READONLY_P (DECL)					\
         && (! DECL_INITIAL (DECL) || ! reloc_needed (DECL_INITIAL (DECL))) \
         && !flag_pic)							\
     || (TREE_CODE_CLASS (TREE_CODE (DECL)) == 'c'			\
*************** while (0)
*** 1769,1780 ****
     not be placed in the read-only data section.  */
  #define SELECT_SECTION(EXP,RELOC) \
    if (TREE_CODE (EXP) == VAR_DECL \
!       && TREE_READONLY (EXP) \
!       && !TREE_THIS_VOLATILE (EXP) \
!       && DECL_INITIAL (EXP) \
!       && (DECL_INITIAL (EXP) == error_mark_node \
!           || TREE_CONSTANT (DECL_INITIAL (EXP))) \
!       && !RELOC) \
      readonly_data_section (); \
    else if (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'c' \
  	   && !(TREE_CODE (EXP) == STRING_CST && flag_writable_strings) \
--- 1769,1775 ----
     not be placed in the read-only data section.  */
  #define SELECT_SECTION(EXP,RELOC) \
    if (TREE_CODE (EXP) == VAR_DECL \
!       && DECL_READONLY_SECTION (EXP, RELOC)) \
      readonly_data_section (); \
    else if (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'c' \
  	   && !(TREE_CODE (EXP) == STRING_CST && flag_writable_strings) \
Index: egcs/gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.47
diff -c -3 -p -r1.47 rs6000.c
*** rs6000.c	1998/10/15 16:52:52	1.47
--- rs6000.c	1998/11/19 14:33:23
*************** rs6000_select_section (decl, reloc)
*** 5514,5534 ****
      }
    else if (TREE_CODE (decl) == VAR_DECL)
      {
!       if ((flag_pic && reloc)
! 	  || !TREE_READONLY (decl)
! 	  || TREE_SIDE_EFFECTS (decl)
! 	  || !DECL_INITIAL (decl)
! 	  || (DECL_INITIAL (decl) != error_mark_node
! 	      && !TREE_CONSTANT (DECL_INITIAL (decl))))
  	{
  	  if (rs6000_sdata != SDATA_NONE && (size > 0) && (size <= g_switch_value))
- 	    sdata_section ();
- 	  else
- 	    data_section ();
- 	}
-       else
- 	{
- 	  if (rs6000_sdata != SDATA_NONE && (size > 0) && (size <= g_switch_value))
  	    {
  	      if (rs6000_sdata == SDATA_EABI)
  		sdata2_section ();
--- 5514,5522 ----
      }
    else if (TREE_CODE (decl) == VAR_DECL)
      {
!       if (DECL_READONLY_SECTION (decl, reloc))
  	{
  	  if (rs6000_sdata != SDATA_NONE && (size > 0) && (size <= g_switch_value))
  	    {
  	      if (rs6000_sdata == SDATA_EABI)
  		sdata2_section ();
*************** rs6000_select_section (decl, reloc)
*** 5537,5542 ****
--- 5525,5537 ----
  	    }
  	  else
  	    const_section ();
+ 	}
+       else
+ 	{
+ 	  if (rs6000_sdata != SDATA_NONE && (size > 0) && (size <= g_switch_value))
+ 	    sdata_section ();
+ 	  else
+ 	    data_section ();
  	}
      }
    else
Index: egcs/gcc/config/rs6000/rs6000.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.30
diff -c -3 -p -r1.30 rs6000.h
*** rs6000.h	1998/10/08 21:04:53	1.30
--- rs6000.h	1998/11/19 14:33:25
*************** extern int toc_initialized;
*** 2664,2674 ****
    if ((TREE_CODE (EXP) == STRING_CST			\
         && !flag_writable_strings)			\
        || (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'd'	\
! 	  && TREE_READONLY (EXP) && ! TREE_THIS_VOLATILE (EXP) \
! 	  && DECL_INITIAL (EXP)				\
! 	  && (DECL_INITIAL (EXP) == error_mark_node	\
! 	      || TREE_CONSTANT (DECL_INITIAL (EXP)))	\
! 	  && ! (RELOC)))				\
      {							\
        if (TREE_PUBLIC (EXP))				\
          read_only_data_section ();			\
--- 2664,2670 ----
    if ((TREE_CODE (EXP) == STRING_CST			\
         && !flag_writable_strings)			\
        || (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'd'	\
! 	  && DECL_READONLY_SECTION (EXP, RELOC)))	\
      {							\
        if (TREE_PUBLIC (EXP))				\
          read_only_data_section ();			\
Index: egcs/gcc/config/sparc/sparc.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/sparc/sparc.h,v
retrieving revision 1.50
diff -c -3 -p -r1.50 sparc.h
*** sparc.h	1998/10/28 18:00:53	1.50
--- sparc.h	1998/11/19 14:33:27
*************** if (TARGET_ARCH64				\
*** 821,832 ****
  {									\
    if (TREE_CODE (T) == VAR_DECL)					\
      {									\
!       if (TREE_READONLY (T) && ! TREE_SIDE_EFFECTS (T)			\
! 	  && DECL_INITIAL (T)						\
! 	  && (DECL_INITIAL (T) == error_mark_node			\
! 	      || TREE_CONSTANT (DECL_INITIAL (T)))			\
! 	  && DECL_ALIGN (T) <= MAX_TEXT_ALIGN				\
! 	  && ! (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES)))	\
  	text_section ();						\
        else								\
  	data_section ();						\
--- 821,828 ----
  {									\
    if (TREE_CODE (T) == VAR_DECL)					\
      {									\
!       if (DECL_READONLY_SECTION (T, RELOC || SUNOS4_SHARED_LIBRARIES)	\
! 	  && DECL_ALIGN (T) <= MAX_TEXT_ALIGN)				\
  	text_section ();						\
        else								\
  	data_section ();						\
Index: egcs/gcc/config/v850/v850.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/v850/v850.c,v
retrieving revision 1.12
diff -c -3 -p -r1.12 v850.c
*** v850.c	1998/10/22 22:37:03	1.12
--- v850.c	1998/11/19 14:33:28
*************** v850_set_default_decl_attr (decl)
*** 3073,3079 ****
  	      abort ();
  	      
  	    case DATA_AREA_SDA:
! 	      kind = ((TREE_READONLY (decl))
  		      ? GHS_SECTION_KIND_ROSDATA
  		      : GHS_SECTION_KIND_SDATA);
  	      break;
--- 3073,3079 ----
  	      abort ();
  	      
  	    case DATA_AREA_SDA:
! 	      kind = ((DECL_READONLY_P (decl))
  		      ? GHS_SECTION_KIND_ROSDATA
  		      : GHS_SECTION_KIND_SDATA);
  	      break;
*************** v850_set_default_decl_attr (decl)
*** 3083,3095 ****
  	      break;
  	      
  	    case DATA_AREA_ZDA:
! 	      kind = ((TREE_READONLY (decl))
  		      ? GHS_SECTION_KIND_ROZDATA
  		      : GHS_SECTION_KIND_ZDATA);
  	      break;
  	      
  	    case DATA_AREA_NORMAL:		 /* default data area */
! 	      if (TREE_READONLY (decl))
  		kind = GHS_SECTION_KIND_RODATA;
  	      else if (DECL_INITIAL (decl))
  		kind = GHS_SECTION_KIND_DATA;
--- 3083,3095 ----
  	      break;
  	      
  	    case DATA_AREA_ZDA:
! 	      kind = ((DECL_READONLY_P (decl))
  		      ? GHS_SECTION_KIND_ROZDATA
  		      : GHS_SECTION_KIND_ZDATA);
  	      break;
  	      
  	    case DATA_AREA_NORMAL:		 /* default data area */
! 	      if (DECL_READONLY_P (decl))
  		kind = GHS_SECTION_KIND_RODATA;
  	      else if (DECL_INITIAL (decl))
  		kind = GHS_SECTION_KIND_DATA;
Index: egcs/gcc/config/v850/v850.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/v850/v850.h,v
retrieving revision 1.17
diff -c -3 -p -r1.17 v850.h
*** v850.h	1998/11/07 13:00:46	1.17
--- v850.h	1998/11/19 14:33:29
*************** zbss_section ()								\
*** 1175,1189 ****
  do {									\
    if (TREE_CODE (EXP) == VAR_DECL)					\
      {									\
!       int is_const;							\
!       if (!TREE_READONLY (EXP)						\
! 	  || TREE_SIDE_EFFECTS (EXP)					\
! 	  || !DECL_INITIAL (EXP)					\
! 	  || (DECL_INITIAL (EXP) != error_mark_node			\
! 	      && !TREE_CONSTANT (DECL_INITIAL (EXP))))			\
!         is_const = FALSE;						\
!       else								\
!         is_const = TRUE;						\
  									\
        switch (v850_get_data_area (EXP))					\
          {								\
--- 1175,1181 ----
  do {									\
    if (TREE_CODE (EXP) == VAR_DECL)					\
      {									\
!       int is_const = DECL_READONLY_SECTION (EXP, 0); /* what about RELOC? */ \
  									\
        switch (v850_get_data_area (EXP))					\
          {								\
Index: egcs/gcc/config/vax/vax.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/vax/vax.c,v
retrieving revision 1.1.1.3
diff -c -3 -p -r1.1.1.3 vax.c
*** vax.c	1998/04/04 05:29:18	1.1.1.3
--- vax.c	1998/11/19 14:33:30
*************** vms_check_external (decl, name, pending)
*** 707,713 ****
        p->size = (DECL_SIZE (decl) == 0) ? 0 :
  	TREE_INT_CST_LOW (size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),
  				      size_int (BITS_PER_UNIT)));
!       p->in_const = (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl));
  
        p->next = pending_head;
        pending_head = p;
--- 707,713 ----
        p->size = (DECL_SIZE (decl) == 0) ? 0 :
  	TREE_INT_CST_LOW (size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),
  				      size_int (BITS_PER_UNIT)));
!       p->in_const = DECL_READONLY_P (decl);
  
        p->next = pending_head;
        pending_head = p;
Index: egcs/gcc/config/vax/vms.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/vax/vms.h,v
retrieving revision 1.3
diff -c -3 -p -r1.3 vms.h
*** vms.h	1998/04/04 17:39:36	1.3
--- vms.h	1998/11/19 14:33:31
*************** Boston, MA 02111-1307, USA.  */
*** 207,213 ****
  #undef ASM_OUTPUT_COMMON
  
  #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)		\
! ( ((TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl))	\
     ? (const_section (), 0) : (data_section (), 0)),		\
    fputs (".comm ", (FILE)),					\
    assemble_name ((FILE), (NAME)),				\
--- 207,213 ----
  #undef ASM_OUTPUT_COMMON
  
  #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)		\
! ( (DECL_READONLY_P (decl)					\
     ? (const_section (), 0) : (data_section (), 0)),		\
    fputs (".comm ", (FILE)),					\
    assemble_name ((FILE), (NAME)),				\
*************** const_section ()					\
*** 251,260 ****
  {									\
    if (TREE_CODE (T) == VAR_DECL)					\
      {									\
!       if (TREE_READONLY (T) && ! TREE_THIS_VOLATILE (T)			\
! 	  && DECL_INITIAL (T)						\
! 	  && (DECL_INITIAL (T) == error_mark_node			\
! 	      || TREE_CONSTANT (DECL_INITIAL (T))))			\
  	{								\
  	  if (TREE_PUBLIC (T))						\
  	    const_section ();						\
--- 251,257 ----
  {									\
    if (TREE_CODE (T) == VAR_DECL)					\
      {									\
!       if (DECL_READONLY_SECTION (T, 0))	/* what about RELOC? */		\
  	{								\
  	  if (TREE_PUBLIC (T))						\
  	    const_section ();						\
Index: egcs/gcc/cp/class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.105
diff -c -3 -p -r1.105 class.c
*** class.c	1998/11/03 17:37:46	1.105
--- class.c	1998/11/19 14:33:35
*************** finish_struct_1 (t, warn_anon)
*** 3286,3291 ****
--- 3286,3292 ----
    int cant_have_default_ctor;
    int cant_have_const_ctor;
    int no_const_asn_ref;
+   int has_mutable = 0;
  
    /* The index of the first base class which has virtual
       functions.  Only applied to non-virtual baseclasses.  */
*************** finish_struct_1 (t, warn_anon)
*** 3544,3549 ****
--- 3545,3553 ----
        if (TREE_CODE (TREE_TYPE (x)) == POINTER_TYPE)
  	has_pointers = 1;
  
+       if (DECL_MUTABLE_P (x) || TYPE_HAS_MUTABLE (TREE_TYPE (x)))
+         has_mutable = 1;
+ 
        /* If any field is const, the structure type is pseudo-const.  */
        if (TREE_READONLY (x))
  	{
*************** finish_struct_1 (t, warn_anon)
*** 3759,3764 ****
--- 3763,3769 ----
    CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) = const_sans_init;
    CLASSTYPE_REF_FIELDS_NEED_INIT (t) = ref_sans_init;
    CLASSTYPE_ABSTRACT_VIRTUALS (t) = abstract_virtuals;
+   CLASSTYPE_HAS_MUTABLE (t) = has_mutable;
  
    /* Effective C++ rule 11.  */
    if (has_pointers && warn_ecpp && TYPE_HAS_CONSTRUCTOR (t)
Index: egcs/gcc/cp/cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.170
diff -c -3 -p -r1.170 cp-tree.h
*** cp-tree.h	1998/11/07 12:54:32	1.170
--- cp-tree.h	1998/11/19 14:33:38
*************** struct lang_type
*** 652,657 ****
--- 652,658 ----
        unsigned has_complex_assign_ref : 1;
        unsigned has_abstract_assign_ref : 1;
        unsigned non_aggregate : 1;
+       unsigned has_mutable : 1;
  
        /* The MIPS compiler gets it wrong if this struct also
  	 does not fill out to a multiple of 4 bytes.  Add a
*************** struct lang_type
*** 947,952 ****
--- 948,959 ----
  /* Ditto, for operator=.  */
  #define TYPE_HAS_NONPUBLIC_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_nonpublic_assign_ref)
  
+ /* Nonzero means that this type contains a mutable member */
+ #define CLASSTYPE_HAS_MUTABLE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_mutable)
+ #define TYPE_HAS_MUTABLE(NODE)        \
+     (TREE_CODE (NODE) == ARRAY_TYPE ? cp_has_mutable (NODE) \
+     : CLASS_TYPE_P (NODE) && CLASSTYPE_HAS_MUTABLE (NODE))
+ 
  /* Many routines need to cons up a list of basetypes for access
     checking.  This field contains a TREE_LIST node whose TREE_VALUE
     is the main variant of the type, and whose TREE_VIA_PUBLIC
*************** extern void push_expression_obstack		PRO
*** 3166,3171 ****
--- 3173,3179 ----
  extern tree build_dummy_object			PROTO((tree));
  extern tree maybe_dummy_object			PROTO((tree, tree *));
  extern int is_dummy_object			PROTO((tree));
+ extern int cp_var_readonly_p                    PROTO((tree));
  #define scratchalloc expralloc
  #define scratch_tree_cons expr_tree_cons
  #define build_scratch_list build_expr_list
*************** extern int comp_ptr_ttypes			PROTO((tree
*** 3244,3249 ****
--- 3252,3258 ----
  extern int ptr_reasonably_similar		PROTO((tree, tree));
  extern tree build_ptrmemfunc			PROTO((tree, tree, int));
  extern int cp_type_quals                        PROTO((tree));
+ extern int cp_has_mutable                       PROTO((tree));
  extern int at_least_as_qualified_p              PROTO((tree, tree));
  extern int more_qualified_p                     PROTO((tree, tree));
  
Index: egcs/gcc/cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.256
diff -c -3 -p -r1.256 decl.c
*** decl.c	1998/11/08 03:19:20	1.256
--- decl.c	1998/11/19 14:33:48
*************** init_decl_processing ()
*** 6302,6307 ****
--- 6304,6310 ----
  
    print_error_function = lang_print_error_function;
    lang_get_alias_set = &c_get_alias_set;
+   lang_var_readonly_p = &cp_var_readonly_p;
  
    /* Maintain consistency.  Perhaps we should just complain if they
       say -fwritable-strings?  */
*************** cp_finish_decl (decl, init, asmspec_tree
*** 7703,7708 ****
--- 7706,7712 ----
  		}
  	    }
  	}
+ 
      finish_end0:
  
        /* Undo call to `pushclass' that was done in `start_decl'
Index: egcs/gcc/cp/tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.76
diff -c -3 -p -r1.76 tree.c
*** tree.c	1998/11/01 15:45:09	1.76
--- tree.c	1998/11/19 14:34:20
*************** is_dummy_object (ob)
*** 2680,2682 ****
--- 2680,2693 ----
    return (TREE_CODE (ob) == NOP_EXPR
  	  && TREE_OPERAND (ob, 0) == error_mark_node);
  }
+ 
+ /* returns 0, if the VAR_DECL DECL cannot be in a readonly section. */
+ 
+ int
+ cp_var_readonly_p (decl)
+       tree decl;
+ {
+   if (TYPE_HAS_MUTABLE (TREE_TYPE (decl)))
+     return 0;
+   return 1;
+ }
Index: egcs/gcc/cp/typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.122
diff -c -3 -p -r1.122 typeck.c
*** typeck.c	1998/11/01 15:45:11	1.122
--- typeck.c	1998/11/19 14:34:26
*************** cp_type_quals (type)
*** 7483,7485 ****
--- 7483,7497 ----
  
    return TYPE_QUALS (type);
  }
+ 
+ /* Returns non-zero if the TYPE contains a mutable member */
+ 
+ int
+ cp_has_mutable (type)
+      tree type;
+ {
+   while (TREE_CODE (type) == ARRAY_TYPE)
+     type = TREE_TYPE (type);
+ 
+   return CLASS_TYPE_P (type) && CLASSTYPE_HAS_MUTABLE (type);
+ }
  

struct A
{
  mutable int i;
};

struct B
{
  A a;
};

struct C
{
  A a[1];
};
struct D
{
  static A const a;
};
static const int i = 0;
static const A a = {0};
static const B b = {{0}};
static const C c = {{{0}}};
static const A aa[] = {{0}};
static const B bb[] = {{{0}}};
static const C cc[] = {{{{0}}}};
A const D::a = {0};
extern "C" void abort();
int main(int argc, char **argv)
{
  switch(argc)
    {
      case 1:
        a.i = 05;
      case 2:
        b.a.i = 05;
      case 3:
        c.a[0].i = 05;
      case 4:
        aa[0].i = 05;
      case 5:
        bb[0].a.i = 05;
      case 6:
        cc[0].a[0].i = 05;
      case 7:
        D::a.i = 05;
      case 9:
        if(!a.i) abort();
        if(!D::a.i) abort();
    }
  return 0;
}

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