Commit b5f8e89e by Jakub Jelinek Committed by Jakub Jelinek

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
parent d8ee9c7e
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.
......
......@@ -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;
......
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
......
// PR c++/72707
// { dg-do compile }
void
foo (double x)
{
union { int x; }; // { dg-error "shadows a parameter" }
x = 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment