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: PR 9400


This patch fixes another warning regression.

Tested on i686-pc-linux-gnu, applied on the branch and on the
mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com

2003-03-06  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9400
	* decl.c (pushdecl): Don't check for shadowing of DECL_ARTIFICIAL
	PARM_DECLs.

2003-03-06  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9400
	* g++.dg/warn/Wshadow-2.C: New test.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1014
diff -c -5 -p -r1.1014 decl.c
*** cp/decl.c	5 Mar 2003 22:08:39 -0000	1.1014
--- cp/decl.c	6 Mar 2003 21:08:56 -0000
*************** pushdecl (tree x)
*** 4099,4109 ****
  
  	  /* Warn if shadowing an argument at the top level of the body.  */
  	  if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x)
  	      /* Inline decls shadow nothing.  */
  	      && !DECL_FROM_INLINE (x)
! 	      && TREE_CODE (oldlocal) == PARM_DECL)
  	    {
  	      bool err = false;
  
  	      /* Don't complain if it's from an enclosing function.  */
  	      if (DECL_CONTEXT (oldlocal) == current_function_decl
--- 4099,4111 ----
  
  	  /* Warn if shadowing an argument at the top level of the body.  */
  	  if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x)
  	      /* Inline decls shadow nothing.  */
  	      && !DECL_FROM_INLINE (x)
! 	      && TREE_CODE (oldlocal) == PARM_DECL
! 	      /* Don't check the `this' parameter.  */
! 	      && !DECL_ARTIFICIAL (oldlocal))
  	    {
  	      bool err = false;
  
  	      /* Don't complain if it's from an enclosing function.  */
  	      if (DECL_CONTEXT (oldlocal) == current_function_decl
Index: testsuite/g++.dg/warn/Wshadow-2.C
===================================================================
RCS file: testsuite/g++.dg/warn/Wshadow-2.C
diff -N testsuite/g++.dg/warn/Wshadow-2.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/Wshadow-2.C	6 Mar 2003 21:08:56 -0000
***************
*** 0 ****
--- 1,10 ----
+ /* { dg-options "-Wshadow" } */
+ 
+ struct A {
+   void a1 () {
+     struct B { B() {} }; // There should be no warning here.
+   }
+   void a2 () {
+       struct B { };
+   }
+ };


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