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] fix diag thinko


Hi,
I've installed this obvious patch which corrects a diagnostic like
current/ptr.ii:2: parameter `<anonymous>' includes reference to array of 
   unknown bound `int[]'
into 
current/ptr.ii:2: parameter `<anonymous>' includes pointer to array of unknown 
   bound `int[]'
for
	typedef int ary[];
	void foo (ary *&);

built & tested on i686-pc-linux-gnu

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-01-11  Nathan Sidwell  <nathan@codesourcery.com>

	* decl.c (grokparms): Unobfuscate and get correct diagnostic for
	parameters with pointers to arrays of unknown bound.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.734
diff -c -3 -p -r1.734 decl.c
*** decl.c	2001/01/08 14:41:00	1.734
--- decl.c	2001/01/11 09:09:59
*************** grokparms (first_parm)
*** 11907,11921 ****
  	    {
  	      /* [dcl.fct]/6, parameter types cannot contain pointers
  		 (references) to arrays of unknown bound.  */
! 	      tree t = type;
  
! 	      while (POINTER_TYPE_P (t)
! 		     || (TREE_CODE (t) == ARRAY_TYPE
! 			 && TYPE_DOMAIN (t) != NULL_TREE))
! 		t = TREE_TYPE (t);
  	      if (TREE_CODE (t) == ARRAY_TYPE)
  		cp_error ("parameter `%D' includes %s to array of unknown bound `%T'",
! 			  decl, TYPE_PTR_P (type) ? "pointer" : "reference", t);
  	    }
  
  	  DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
--- 11907,11928 ----
  	    {
  	      /* [dcl.fct]/6, parameter types cannot contain pointers
  		 (references) to arrays of unknown bound.  */
! 	      tree t = TREE_TYPE (type);
! 	      int ptr = TYPE_PTR_P (type);
  
!               while (1)
!                 {
!                   if (TYPE_PTR_P (t))
!                     ptr = 1;
!                   else if (TREE_CODE (t) != ARRAY_TYPE)
!                     break;
!                   else if (!TYPE_DOMAIN (t))
! 	            break;
! 	          t = TREE_TYPE (t);
! 	        }
  	      if (TREE_CODE (t) == ARRAY_TYPE)
  		cp_error ("parameter `%D' includes %s to array of unknown bound `%T'",
! 			  decl, ptr ? "pointer" : "reference", t);
  	    }
  
  	  DECL_ARG_TYPE (decl) = TREE_TYPE (decl);

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