Commit 71e6353e authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

c++: Don't emit repeated -Wshadow warnings for templates/ctors [PR104379]

The following patch suppresses extraneous -Wshadow warnings.
On the testcase without the patch we emit 14 -Wshadow warnings,
with the patch just 4.  It is enough to warn once e.g. during parsing of the
template or the abstract ctor, while previously we'd warn also on the clones
of the ctors and on instantiation.
In GCC 8 and earlier we didn't warn because check_local_shadow did
  /* Inline decls shadow nothing.  */
  if (DECL_FROM_INLINE (decl))
    return;

2022-02-08  Jakub Jelinek  <jakub@redhat.com>

	PR c++/104379
	* name-lookup.cc (check_local_shadow): When diagnosing shadowing
	of a member or global declaration, add warning suppression for
	the decl and don't warn again on it.

	* g++.dg/warn/Wshadow-18.C: New test.
parent 1755141a
Supports Markdown
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