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]

Re: C++ PATCH: PR c++/7228


> Yes, that is what we should do.  If you do that, and tests pass, that
> patch is pre-approved.

	Bootstrapped successfully on powerpc-ibm-aix4.3.3.0 with no
regressions using the following patch, which I have checked in.

	PR c++/7228
	* cp-tree.h (CLASSTYPE_READONLY_FIELDS_NEED_INIT): Check that
	lang_type structure exists before accessing field.
	(SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT): New macro.
	(CLASSTYPE_REF_FIELDS_NEED_INIT): Similar.
	(SET_CLASSTYPE_REF_FIELDS_NEED_INIT): New macro.
	* class.c (check_field_decls): Use new macros.
	* typeck2.c (process_init_constructor): Remove redundant check for
	existence of lang_type structure.

Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.485
diff -c -p -r1.485 class.c
*** class.c	25 Oct 2002 06:01:54 -0000	1.485
--- class.c	25 Oct 2002 15:05:36 -0000
*************** check_field_decls (tree t, tree *access_
*** 3264,3270 ****
   	{
  	  CLASSTYPE_NON_POD_P (t) = 1;
  	  if (DECL_INITIAL (x) == NULL_TREE)
! 	    CLASSTYPE_REF_FIELDS_NEED_INIT (t) = 1;
  
  	  /* ARM $12.6.2: [A member initializer list] (or, for an
  	     aggregate, initialization by a brace-enclosed list) is the
--- 3264,3270 ----
   	{
  	  CLASSTYPE_NON_POD_P (t) = 1;
  	  if (DECL_INITIAL (x) == NULL_TREE)
! 	    SET_CLASSTYPE_REF_FIELDS_NEED_INIT (t, 1);
  
  	  /* ARM $12.6.2: [A member initializer list] (or, for an
  	     aggregate, initialization by a brace-enclosed list) is the
*************** check_field_decls (tree t, tree *access_
*** 3299,3305 ****
  	{
  	  C_TYPE_FIELDS_READONLY (t) = 1;
  	  if (DECL_INITIAL (x) == NULL_TREE)
! 	    CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) = 1;
  
  	  /* ARM $12.6.2: [A member initializer list] (or, for an
  	     aggregate, initialization by a brace-enclosed list) is the
--- 3299,3305 ----
  	{
  	  C_TYPE_FIELDS_READONLY (t) = 1;
  	  if (DECL_INITIAL (x) == NULL_TREE)
! 	    SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t, 1);
  
  	  /* ARM $12.6.2: [A member initializer list] (or, for an
  	     aggregate, initialization by a brace-enclosed list) is the
*************** check_field_decls (tree t, tree *access_
*** 3316,3323 ****
        else if (IS_AGGR_TYPE (type))
  	{
  	  C_TYPE_FIELDS_READONLY (t) |= C_TYPE_FIELDS_READONLY (type);
! 	  CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) 
! 	    |= CLASSTYPE_READONLY_FIELDS_NEED_INIT (type);
  	}
  
        /* Core issue 80: A nonstatic data member is required to have a
--- 3316,3324 ----
        else if (IS_AGGR_TYPE (type))
  	{
  	  C_TYPE_FIELDS_READONLY (t) |= C_TYPE_FIELDS_READONLY (type);
! 	  SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t,
! 	    CLASSTYPE_READONLY_FIELDS_NEED_INIT (t)
! 	    | CLASSTYPE_READONLY_FIELDS_NEED_INIT (type));
  	}
  
        /* Core issue 80: A nonstatic data member is required to have a
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.762
diff -c -p -r1.762 cp-tree.h
*** cp-tree.h	23 Oct 2002 17:13:17 -0000	1.762
--- cp-tree.h	25 Oct 2002 15:05:37 -0000
*************** struct lang_type GTY(())
*** 1476,1488 ****
  #define CLASSTYPE_DECLARED_CLASS(NODE) \
    (LANG_TYPE_CLASS_CHECK (NODE)->declared_class)
  
! /* Nonzero if this class has const members which have no specified initialization.  */
! #define CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE) \
!   (LANG_TYPE_CLASS_CHECK (NODE)->h.const_needs_init)
  
! /* Nonzero if this class has ref members which have no specified initialization.  */
! #define CLASSTYPE_REF_FIELDS_NEED_INIT(NODE) \
!   (LANG_TYPE_CLASS_CHECK (NODE)->h.ref_needs_init)
  
  /* Nonzero if this class is included from a header file which employs
     `#pragma interface', and it is not included in its implementation file.  */
--- 1476,1496 ----
  #define CLASSTYPE_DECLARED_CLASS(NODE) \
    (LANG_TYPE_CLASS_CHECK (NODE)->declared_class)
  
! /* Nonzero if this class has const members
!    which have no specified initialization.  */
! #define CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE)	\
!   (TYPE_LANG_SPECIFIC (NODE)				\
!    ? LANG_TYPE_CLASS_CHECK (NODE)->h.const_needs_init : 0)
! #define SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE, VALUE) \
!   (LANG_TYPE_CLASS_CHECK (NODE)->h.const_needs_init = (VALUE))
  
! /* Nonzero if this class has ref members
!    which have no specified initialization.  */
! #define CLASSTYPE_REF_FIELDS_NEED_INIT(NODE)		\
!   (TYPE_LANG_SPECIFIC (NODE)				\
!    ? LANG_TYPE_CLASS_CHECK (NODE)->h.ref_needs_init : 0)
! #define SET_CLASSTYPE_REF_FIELDS_NEED_INIT(NODE, VALUE) \
!   (LANG_TYPE_CLASS_CHECK (NODE)->h.ref_needs_init = (VALUE))
  
  /* Nonzero if this class is included from a header file which employs
     `#pragma interface', and it is not included in its implementation file.  */
Index: typeck2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck2.c,v
retrieving revision 1.130
diff -c -p -r1.130 typeck2.c
*** typeck2.c	11 Oct 2002 16:50:42 -0000	1.130
--- typeck2.c	25 Oct 2002 15:05:37 -0000
*************** process_init_constructor (type, init, el
*** 830,837 ****
  	    {
  	      if (TREE_READONLY (field))
  		error ("uninitialized const member `%D'", field);
! 	      else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field))
! 		       && CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
  		error ("member `%D' with uninitialized const fields",
  			  field);
  	      else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
--- 830,836 ----
  	    {
  	      if (TREE_READONLY (field))
  		error ("uninitialized const member `%D'", field);
! 	      else if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
  		error ("member `%D' with uninitialized const fields",
  			  field);
  	      else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)


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