re PR c++/72707 (local anonymous union member hides names in the same scope)

PR c++/72707
	* name-lookup.c (pushdecl_maybe_friend_1): Do check shadowing of
	artificial x if it is an anonymous union variable.

	* g++.dg/warn/Wshadow-12.C: New test.

From-SVN: r243877
This commit is contained in:
Jakub Jelinek 2016-12-21 23:49:59 +01:00 committed by Jakub Jelinek
parent d8ee9c7e54
commit b5f8e89ed7
4 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,9 @@
2016-12-21 Jakub Jelinek <jakub@redhat.com>
PR c++/72707
* name-lookup.c (pushdecl_maybe_friend_1): Do check shadowing of
artificial x if it is an anonymous union variable.
PR bootstrap/78817
* typeck.c (cp_build_function_call_vec): If check_function_arguments
returns true, set TREE_NO_WARNING on CALL_EXPR.

View File

@ -1111,8 +1111,10 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend)
|| TREE_CODE (x) == TYPE_DECL)))
/* Don't check for internally generated vars unless
it's an implicit typedef (see create_implicit_typedef
in decl.c). */
&& (!DECL_ARTIFICIAL (x) || DECL_IMPLICIT_TYPEDEF_P (x)))
in decl.c) or anonymous union variable. */
&& (!DECL_ARTIFICIAL (x)
|| DECL_IMPLICIT_TYPEDEF_P (x)
|| (VAR_P (x) && DECL_ANON_UNION_VAR_P (x))))
{
bool nowarn = false;

View File

@ -1,3 +1,8 @@
2016-12-21 Jakub Jelinek <jakub@redhat.com>
PR c++/72707
* g++.dg/warn/Wshadow-12.C: New test.
2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/78580

View File

@ -0,0 +1,9 @@
// PR c++/72707
// { dg-do compile }
void
foo (double x)
{
union { int x; }; // { dg-error "shadows a parameter" }
x = 0;
}