]> granicus.if.org Git - clang/commitdiff
It turns out that we should be allowing redeclarations within function
authorDouglas Gregor <dgregor@apple.com>
Thu, 6 May 2010 23:31:27 +0000 (23:31 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 6 May 2010 23:31:27 +0000 (23:31 +0000)
scope. Thanks to Steven Watanabe for correcting me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103210 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp

index 23b3601f09a176b45d5eb713cd10c2a9d1e16164..e32a308af58b246cf0bf95ba4c3103e058cba5c9 100644 (file)
@@ -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
index fd2df010fc9b838952bb6a979744d0346a0f6685..466097171c8dec9381ceae7f17c4f15bd5a58172 100644 (file)
@@ -81,3 +81,18 @@ namespace test2 {
 
   template struct Derived<int>; // 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;
+  }
+}