]> granicus.if.org Git - clang/commitdiff
Redeclarations of using declarations are not okay in function scopes.
authorJohn McCall <rjmccall@apple.com>
Tue, 23 Nov 2010 22:03:51 +0000 (22:03 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 23 Nov 2010 22:03:51 +0000 (22:03 +0000)
Not sure what I was thinking before.

Fixes PR8668.

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

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

index 235b41e342e6ec5ab611a393257f585daf9e9250..ad8b8695ccdacbec80a512503b9081f31b3731ff 100644 (file)
@@ -3961,8 +3961,8 @@ bool Sema::CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
   //   repeatedly where (and only where) multiple declarations are
   //   allowed.
   //
-  // That's in non-member contexts.
-  if (!CurContext->getRedeclContext()->isRecord())
+  // That's in file contexts.
+  if (CurContext->isFileContext())
     return false;
 
   NestedNameSpecifier *Qual
index 466097171c8dec9381ceae7f17c4f15bd5a58172..5ba22c84191bd8e1d2d2de54cb56d9d67a8d517b 100644 (file)
@@ -82,7 +82,7 @@ namespace test2 {
   template struct Derived<int>; // expected-note {{in instantiation of template class}}
 }
 
-// Redeclarations are okay in a function.
+// PR8668: redeclarations are not okay in a function.
 namespace test3 {
   namespace N {
     int f(int);
@@ -90,9 +90,18 @@ namespace test3 {
   }
 
   void g() {
+    using N::f; // expected-note {{previous using declaration}}
+    using N::f; // expected-error {{redeclaration of using decl}}
+    using N::type; // expected-note {{previous using declaration}}
+    using N::type; // expected-error {{redeclaration of using decl}}
+  }
+
+  void h() {
     using N::f;
-    using N::f;
-    using N::type;
     using N::type;
+    {
+      using N::f;
+      using N::type;
+    }
   }
 }