summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2018-11-02 21:04:44 +0000
committerAaron Ballman <aaron@aaronballman.com>2018-11-02 21:04:44 +0000
commit38ae8879fa59652fb89e9383c6ff89bfad099439 (patch)
tree94b0c097467926c381211fe0eb13659cfb03c8bc /lib/Sema/SemaDecl.cpp
parent90458949c1c82c72ec45267838ad6b313d25b745 (diff)
downloadclang-38ae8879fa59652fb89e9383c6ff89bfad099439.tar.gz
Diagnose parameter names that shadow the names of inherited fields under -Wshadow-field.
This addresses PR34120. Note, unlike GCC, we take into account the accessibility of the field when deciding whether to warn or not. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346041 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index bf15e25d62..f8068dd9c8 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -12366,6 +12366,13 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
D.setInvalidType(true);
}
}
+
+ if (LangOpts.CPlusPlus) {
+ DeclarationNameInfo DNI = GetNameForDeclarator(D);
+ if (auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
+ CheckShadowInheritedFields(DNI.getLoc(), DNI.getName(), RD,
+ /*DeclIsField*/ false);
+ }
}
// Temporarily put parameter variables in the translation unit, not