]> granicus.if.org Git - clang/commitdiff
Restrict redeclaration of tags introduced by using decls to MSVCCompat
authorAlp Toker <alp@nuanti.com>
Sat, 18 Jan 2014 00:59:32 +0000 (00:59 +0000)
committerAlp Toker <alp@nuanti.com>
Sat, 18 Jan 2014 00:59:32 +0000 (00:59 +0000)
This limits the facility added in r199490 while we seek clarification on the
standard.

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

lib/Sema/SemaDecl.cpp
test/SemaCXX/MicrosoftCompatibility.cpp
test/SemaCXX/using-decl-1.cpp

index 62fedbf9691d7e3ff00baf1108a965f101e67c7b..f71540c2040fb4c5a74f1e4ad769c5f4bfafa75d 100644 (file)
@@ -10681,8 +10681,9 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
   }
 
   if (!Previous.empty()) {
-    NamedDecl *DirectPrevDecl = *Previous.begin();
-    NamedDecl *PrevDecl = DirectPrevDecl->getUnderlyingDecl();
+    NamedDecl *PrevDecl = Previous.getFoundDecl();
+    NamedDecl *DirectPrevDecl =
+        getLangOpts().MSVCCompat ? *Previous.begin() : PrevDecl;
 
     // It's okay to have a tag decl in the same scope as a typedef
     // which hides a tag decl in the same scope.  Finding this
index 1f27deb0ee10b5159d86c24dbf22b605f70b5553..0971646e73b5999a4d6a739f934698bef55cf394 100644 (file)
@@ -120,6 +120,27 @@ private:
 
 }
 
+namespace using_tag_redeclaration
+{
+  struct S;
+  namespace N {
+    using ::using_tag_redeclaration::S;
+    struct S {}; // expected-note {{previous definition is here}}
+  }
+  void f() {
+    N::S s1;
+    S s2;
+  }
+  void g() {
+    struct S; // expected-note {{forward declaration of 'S'}}
+    S s3; // expected-error {{variable has incomplete type 'S'}}
+  }
+  void h() {
+    using ::using_tag_redeclaration::S;
+    struct S {}; // expected-error {{redefinition of 'S'}}
+  }
+}
+
 
 namespace MissingTypename {
 
index ed5cce7c9746d7436418fa45900646a312d73728..24d92f175c302d271df2a19869f4f1e69fdc17d3 100644 (file)
@@ -119,27 +119,6 @@ namespace foo
   };
 }
 
-namespace using_tag_redeclaration
-{
-  struct S;
-  namespace N {
-    using ::using_tag_redeclaration::S;
-    struct S {}; // expected-note {{previous definition is here}}
-  }
-  void f() {
-    N::S s1;
-    S s2;
-  }
-  void g() {
-    struct S; // expected-note {{forward declaration of 'S'}}
-    S s3; // expected-error {{variable has incomplete type 'S'}}
-  }
-  void h() {
-    using ::using_tag_redeclaration::S;
-    struct S {}; // expected-error {{redefinition of 'S'}}
-  }
-}
-
 // Don't suggest non-typenames for positions requiring typenames.
 namespace using_suggestion_tyname_val {
 namespace N { void FFF() {} }