(lib)C++: vars shadowing globals

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Tue Dec 14 15:17:00 GMT 1999


> I would like to use the  -Wshadow switch along switches to
> stop on warning.  There are 3 header files and one source file
> which shadow globals.  If you have a chance, would you please
> change them?  I have enclosed specifics below.

Thanks for your bug report. Here is a patch.

May I install it? Also in the mainline?

Martin

P.S. When approving or rejecting this patch, could you also have a
look at

http://gcc.gnu.org/ml/gcc-patches/1999-11/msg00660.html

1999-12-14  Martin v. Löwis  <loewis@informatik.hu-berlin.de>

	* strstream.h (strstreambuf::streambuf): Rename parameters to
	avoid shadow warning.
	* stream.h (WS): Likewise.

1999-12-14  Martin v. Löwis  <loewis@informatik.hu-berlin.de>

	* std/bastring.h (basic_string::basic_string): Rename parameters
	to avoid shadow warnings.
	* std/bastring.cc (alloc): Likewise.

Index: stream.h
===================================================================
RCS file: /cvs/gcc/egcs/libio/stream.h,v
retrieving revision 1.2
diff -u -r1.2 stream.h
--- stream.h	1999/09/04 15:08:50	1.2
+++ stream.h	1999/12/14 22:57:24
@@ -1,5 +1,5 @@
 /* 
-Copyright (C) 1993 Free Software Foundation
+Copyright (C) 1993, 1999 Free Software Foundation
 
 This file is part of the GNU IO Library.  This library is free
 software; you can redistribute it and/or modify it under the
@@ -53,7 +53,7 @@
 char*        chr(char ch, int width = 0);
 char*        str(const char* s, int width = 0);
 
-inline istream& WS(istream& str) { return ws(str); }
+inline istream& WS(istream& __str) { return ws(__str); }
 } // extern "C++"
 
 #endif /* !_COMPAT_STREAM_H */
Index: strstream.h
===================================================================
RCS file: /cvs/gcc/egcs/libio/strstream.h,v
retrieving revision 1.2
diff -u -r1.2 strstream.h
--- strstream.h	1999/09/04 15:08:50	1.2
+++ strstream.h	1999/12/14 22:57:24
@@ -1,5 +1,5 @@
 /* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
+Copyright (C) 1993, 1999 Free Software Foundation
 
 This file is part of the GNU IO Library.  This library is free
 software; you can redistribute it and/or modify it under the
@@ -50,8 +50,8 @@
     virtual ~strstreambuf();
     strstreambuf() { init_dynamic(0, 0); }
     strstreambuf(int initial_size) { init_dynamic(0, 0, initial_size); }
-    strstreambuf(void *(*alloc)(_IO_size_t), void (*free)(void*))
-	{ init_dynamic(alloc, free); }
+    strstreambuf(void *(*__alloc)(_IO_size_t), void (*__free)(void*))
+	{ init_dynamic(__alloc, __free); }
     strstreambuf(char *ptr, int size, char *pstart = NULL)
 	{ init_static(ptr, size, pstart); }
     strstreambuf(unsigned char *ptr, int size, unsigned char *pstart = NULL)

Index: bastring.cc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++/std/bastring.cc,v
retrieving revision 1.10
diff -u -r1.10 bastring.cc
--- bastring.cc	1998/11/30 09:40:56	1.10
+++ bastring.cc	1999/12/14 22:57:07
@@ -1,5 +1,5 @@
 // Member templates for the -*- C++ -*- string classes.
-// Copyright (C) 1994 Free Software Foundation
+// Copyright (C) 1994, 1999 Free Software Foundation
 
 // This file is part of the GNU ANSI C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -94,14 +94,14 @@
 
 template <class charT, class traits, class Allocator>
 void basic_string <charT, traits, Allocator>::
-alloc (basic_string::size_type size, bool save)
+alloc (basic_string::size_type __size, bool __save)
 {
-  if (! check_realloc (size))
+  if (! check_realloc (__size))
     return;
 
-  Rep *p = Rep::create (size);
+  Rep *p = Rep::create (__size);
 
-  if (save)
+  if (__save)
     {
       p->copy (0, data (), length ());
       p->len = length ();
Index: bastring.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++/std/bastring.h,v
retrieving revision 1.19
diff -u -r1.19 bastring.h
--- bastring.h	1999/12/14 08:48:11	1.19
+++ bastring.h	1999/12/14 22:57:08
@@ -1,5 +1,5 @@
 // Main templates for the -*- C++ -*- string classes.
-// Copyright (C) 1994, 1995 Free Software Foundation
+// Copyright (C) 1994, 1995, 1999 Free Software Foundation
 
 // This file is part of the GNU ANSI C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -144,8 +144,8 @@
   typedef const charT* const_pointer;
   typedef pointer iterator;
   typedef const_pointer const_iterator;
-  typedef ::reverse_iterator<iterator> reverse_iterator;
-  typedef ::reverse_iterator<const_iterator> const_reverse_iterator;
+  typedef std::reverse_iterator<iterator> reverse_iterator;
+  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
   static const size_type npos = static_cast<size_type>(-1);
 
 private:
@@ -185,11 +185,11 @@
     : dat (nilRep.grab ()) { assign (n, c); }
 #ifdef __STL_MEMBER_TEMPLATES
   template<class InputIterator>
-    basic_string(InputIterator begin, InputIterator end)
+    basic_string(InputIterator __begin, InputIterator __end)
 #else
-  basic_string(const_iterator begin, const_iterator end)
+  basic_string(const_iterator __begin, const_iterator __end)
 #endif
-    : dat (nilRep.grab ()) { assign (begin, end); }
+    : dat (nilRep.grab ()) { assign (__begin, __end); }
 
   ~basic_string ()
     { rep ()->release (); }


More information about the Gcc-bugs mailing list