[cfe-commits] r98806 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/CXX/class.access/p4.cpp
John McCall
rjmccall at apple.com
Wed Mar 17 23:42:38 PDT 2010
Author: rjmccall
Date: Thu Mar 18 01:42:38 2010
New Revision: 98806
URL: http://llvm.org/viewvc/llvm-project?rev=98806&view=rev
Log:
Redeclaration lookups for parameter names should be flagged as redeclaration lookups
so they don't trigger diagnostics like (say) access control.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/class.access/p4.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=98806&r1=98805&r2=98806&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Mar 18 01:42:38 2010
@@ -3950,7 +3950,11 @@
// 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);
Modified: cfe/trunk/test/CXX/class.access/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/p4.cpp?rev=98806&r1=98805&r2=98806&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/p4.cpp (original)
+++ cfe/trunk/test/CXX/class.access/p4.cpp Thu Mar 18 01:42:38 2010
@@ -221,3 +221,15 @@
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;
+ }
+ };
+}
More information about the cfe-commits
mailing list