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]

[C++ PATCH, committed] Tweak my previous PR10496 fix.


Hi

This is a slight change to the PR10496 fix as suggested by Jason.
Committed to main trunk.

--Kriang


2003-05-06  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	* typeck.c (build_unary_op): Deal with const qualifier in
	invalid pointer-to-member earlier.


diff -cprN gcc-main-save/gcc/cp/typeck.c gcc-main-new/gcc/cp/typeck.c
*** gcc-main-save/gcc/cp/typeck.c	Mon May  5 21:37:11 2003
--- gcc-main-new/gcc/cp/typeck.c	Tue May  6 20:59:19 2003
*************** build_unary_op (code, xarg, noconvert)
*** 4430,4455 ****
  	     We could defer this in non-MS mode, but it's easier to give
  	     a useful error here.  */
  
! 	  tree base = TREE_TYPE (TREE_OPERAND (arg, 0));
  	  tree name = DECL_NAME (get_first_fn (TREE_OPERAND (arg, 1)));
  
  	  if (! flag_ms_extensions)
  	    {
- 	      /* Inside constant member functions, the `this' pointer
- 		 contains an extra const qualifier.  TYPE_MAIN_VARIANT
- 		 is used here to remove this const from the diagnostics.  */
  	      if (current_class_type
  		  && TREE_OPERAND (arg, 0) == current_class_ref)
  		/* An expression like &memfn.  */
  		pedwarn ("ISO C++ forbids taking the address of an unqualified"
  			 " or parenthesized non-static member function to form"
  			 " a pointer to member function.  Say `&%T::%D'",
! 			 TYPE_MAIN_VARIANT (base), name);
  	      else
  		pedwarn ("ISO C++ forbids taking the address of a bound member"
  			 " function to form a pointer to member function."
  			 "  Say `&%T::%D'",
! 			 TYPE_MAIN_VARIANT (base), name);
  	    }
  	  arg = build_offset_ref (base, name);
          }
--- 4430,4456 ----
  	     We could defer this in non-MS mode, but it's easier to give
  	     a useful error here.  */
  
! 	  /* Inside constant member functions, the `this' pointer
! 	     contains an extra const qualifier.  TYPE_MAIN_VARIANT
! 	     is used here to remove this const from the diagnostics
! 	     and the created OFFSET_REF.  */
! 	  tree base = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg, 0)));
  	  tree name = DECL_NAME (get_first_fn (TREE_OPERAND (arg, 1)));
  
  	  if (! flag_ms_extensions)
  	    {
  	      if (current_class_type
  		  && TREE_OPERAND (arg, 0) == current_class_ref)
  		/* An expression like &memfn.  */
  		pedwarn ("ISO C++ forbids taking the address of an unqualified"
  			 " or parenthesized non-static member function to form"
  			 " a pointer to member function.  Say `&%T::%D'",
! 			 base, name);
  	      else
  		pedwarn ("ISO C++ forbids taking the address of a bound member"
  			 " function to form a pointer to member function."
  			 "  Say `&%T::%D'",
! 			 base, name);
  	    }
  	  arg = build_offset_ref (base, name);
          }


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