diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 23b3601f09a1..e32a308af58b 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -3880,8 +3880,9 @@ bool Sema::CheckUsingDeclRedeclaration(SourceLocation UsingLoc, // A using-declaration is a declaration and can therefore be used // repeatedly where (and only where) multiple declarations are // allowed. - // That's only in file contexts. - if (CurContext->getLookupContext()->isFileContext()) + // + // That's in non-member contexts. + if (!CurContext->getLookupContext()->isRecord()) return false; NestedNameSpecifier *Qual diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp index fd2df010fc9b..466097171c8d 100644 --- a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp +++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp @@ -81,3 +81,18 @@ namespace test2 { template struct Derived; // expected-note {{in instantiation of template class}} } + +// Redeclarations are okay in a function. +namespace test3 { + namespace N { + int f(int); + typedef int type; + } + + void g() { + using N::f; + using N::f; + using N::type; + using N::type; + } +}