aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-18 06:42:38 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-18 06:42:38 +0000
commit10f2873c0df7f662bfdb9a3e8bc834b68c1ead48 (patch)
tree737c9beaebf45839d8ee44123bfab94876903f19
parent7133c1aa1c55cb8b9c86a5e1f1318a0d82658c31 (diff)
Redeclaration lookups for parameter names should be flagged as redeclaration lookups
so they don't trigger diagnostics like (say) access control. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98806 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--test/CXX/class.access/p4.cpp12
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 19885ba9cf..2e69108617 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3950,7 +3950,11 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
// Check for redeclaration of parameters, e.g. int foo(int x, int x);
IdentifierInfo *II = D.getIdentifier();
if (II) {
- if (NamedDecl *PrevDecl = LookupSingleName(S, II, LookupOrdinaryName)) {
+ LookupResult R(*this, II, D.getIdentifierLoc(), LookupOrdinaryName,
+ ForRedeclaration);
+ LookupName(R, S);
+ if (R.isSingleResult()) {
+ NamedDecl *PrevDecl = R.getFoundDecl();
if (PrevDecl->isTemplateParameter()) {
// Maybe we will complain about the shadowed template parameter.
DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl);
diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp
index 0a7459b50a..d6244aaea0 100644
--- a/test/CXX/class.access/p4.cpp
+++ b/test/CXX/class.access/p4.cpp
@@ -221,3 +221,15 @@ namespace test6 {
Test2 a = t;
}
}
+
+// Redeclaration lookups are not accesses.
+namespace test7 {
+ class A {
+ int private_member;
+ };
+ class B : A {
+ int foo(int private_member) {
+ return 0;
+ }
+ };
+}