re PR c++/68374 (G++ -Wshadow doesn't warn about static member shadowing)

/cp
2018-05-02  Paolo Carlini  <paolo.carlini@oracle.com>
	    Jason Merrill  <jason@redhat.com>

	PR c++/68374
	* name-lookup.c (check_local_shadow): Don't handle static old
	declarations in the block handling locals shadowing locals.

/testsuite
2018-05-02  Paolo Carlini  <paolo.carlini@oracle.com>
	    Jason Merrill  <jason@redhat.com>

	PR c++/68374
	* g++.dg/warn/Wshadow-13.C: New.
	* g++.dg/warn/Wshadow-14.C: Likewise.

Co-Authored-By: Jason Merrill <jason@redhat.com>

From-SVN: r259853
This commit is contained in:
Paolo Carlini 2018-05-02 18:15:56 +00:00 committed by Paolo Carlini
parent ec00d3faf4
commit 006fbbe952
5 changed files with 33 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2018-05-02 Paolo Carlini <paolo.carlini@oracle.com>
Jason Merrill <jason@redhat.com>
PR c++/68374
* name-lookup.c (check_local_shadow): Don't handle static old
declarations in the block handling locals shadowing locals.
2018-05-01 Jason Merrill <jason@redhat.com>
PR c++/85587 - error with scoped enum in template.

View file

@ -2642,6 +2642,7 @@ check_local_shadow (tree decl)
|| (TREE_CODE (old) == TYPE_DECL
&& (!DECL_ARTIFICIAL (old)
|| TREE_CODE (decl) == TYPE_DECL)))
&& DECL_FUNCTION_SCOPE_P (old)
&& (!DECL_ARTIFICIAL (decl)
|| DECL_IMPLICIT_TYPEDEF_P (decl)
|| (VAR_P (decl) && DECL_ANON_UNION_VAR_P (decl))))

View file

@ -1,3 +1,10 @@
2018-05-02 Paolo Carlini <paolo.carlini@oracle.com>
Jason Merrill <jason@redhat.com>
PR c++/68374
* g++.dg/warn/Wshadow-13.C: New.
* g++.dg/warn/Wshadow-14.C: Likewise.
2018-05-02 Tom de Vries <tom@codesourcery.com>
PR libgomp/82428

View file

@ -0,0 +1,8 @@
// PR c++/68374
// { dg-options "-Wshadow" }
class f {
static int mVar; // { dg-message "shadowed declaration" }
int g(int x) { int mVar=3; return x+mVar; } // { dg-warning "shadows a member of 'f'" }
};
int f::mVar = 1;

View file

@ -0,0 +1,10 @@
// PR c++/68374
// { dg-options "-Wshadow" }
void foo ()
{
static int i; // { dg-message "shadowed declaration" }
{
int i; // { dg-warning "shadows a previous local" }
}
}