<rdar://problem/
6952203>.
To do this, we actually remove a not-quite-correct optimization in the
C++ name lookup routines. We'll revisit this optimization for the
general case once more C++ is working.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73659
91177308-0d34-0410-b5e6-
96231b3b80d8
Diag(D.getDeclSpec().getThreadSpecLoc(), diag::err_invalid_thread);
NamedDecl *PrevDecl = LookupName(S, II, LookupMemberName, true);
+
+ if (PrevDecl && PrevDecl->isTemplateParameter()) {
+ // Maybe we will complain about the shadowed template parameter.
+ DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl);
+ // Just pretend that we didn't see the previous declaration.
+ PrevDecl = 0;
+ }
+
if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
PrevDecl = 0;
// identifier chain.
if (isa<RecordDecl>(Ctx)) {
R = LookupQualifiedName(Ctx, Name, NameKind, RedeclarationOnly);
- if (R || RedeclarationOnly)
+ if (R)
return std::make_pair(true, R);
}
if (Ctx->getParent() != Ctx->getLexicalParent()
for (OutOfLineCtx = Ctx; OutOfLineCtx && !OutOfLineCtx->isFileContext();
OutOfLineCtx = OutOfLineCtx->getParent()) {
R = LookupQualifiedName(OutOfLineCtx, Name, NameKind, RedeclarationOnly);
- if (R || RedeclarationOnly)
+ if (R)
return std::make_pair(true, R);
}
}
if (Previous.begin() != Previous.end())
PrevDecl = *Previous.begin();
+ if (PrevDecl && !isDeclInScope(PrevDecl, CurContext, S))
+ PrevDecl = 0;
+
DeclContext *SemanticContext = CurContext;
if (SS.isNotEmpty() && !SS.isInvalid()) {
SemanticContext = computeDeclContext(SS);
template<int Size> // expected-note{{template parameter is declared here}}
void shadow3(int Size); // expected-error{{declaration of 'Size' shadows template parameter}}
+// <rdar://problem/6952203>
+template<typename T> // expected-note{{here}}
+struct shadow4 {
+ int T; // expected-error{{shadows}}
+};
+
+template<typename T> // expected-note{{here}}
+struct shadow5 {
+ int T(int, float); // expected-error{{shadows}}
+};
+
// Non-type template parameters in scope
template<int Size>
void f(int& i) {
-// RUN: clang-cc -fsyntax-only %s
+// RUN: clang-cc -fsyntax-only -verify %s
class A;